diff options
author | Seth Alves <alves@src.gnome.org> | 2000-04-19 21:39:43 +0800 |
---|---|---|
committer | Seth Alves <alves@src.gnome.org> | 2000-04-19 21:39:43 +0800 |
commit | 528fe3b08ead2edcf246a49fdd0089ace5a83cc0 (patch) | |
tree | 10bfd24ad7c3a6474c627db40bea078ccdac144c | |
parent | f3a84bec06a82e86b7903d01e13589d0fcf4a2bc (diff) | |
download | gsoc2013-evolution-528fe3b08ead2edcf246a49fdd0089ace5a83cc0.tar.gz gsoc2013-evolution-528fe3b08ead2edcf246a49fdd0089ace5a83cc0.tar.zst gsoc2013-evolution-528fe3b08ead2edcf246a49fdd0089ace5a83cc0.zip |
set calendar's uri with a property bag
* e-shell-view.c (get_view): set calendar's uri with a property bag
* gui/evolution-calendar-control.c (calendar_properties_init): create
a property bag for this control
(set_prop): callback for property sets
(get_prop): callback for proprety gets
* gui/calendar-commands.c (calendar_set_uri): new function,
called when the "calendar_uri" property is set on the calendar-
control's property bag.
svn path=/trunk/; revision=2501
-rw-r--r-- | calendar/ChangeLog | 11 | ||||
-rw-r--r-- | calendar/gui/calendar-commands.c | 50 | ||||
-rw-r--r-- | calendar/gui/calendar-commands.h | 10 | ||||
-rw-r--r-- | calendar/gui/evolution-calendar-control.c | 110 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.h | 4 | ||||
-rw-r--r-- | calendar/gui/main.c | 18 | ||||
-rw-r--r-- | shell/ChangeLog | 4 | ||||
-rw-r--r-- | shell/e-shell-view.c | 18 | ||||
-rw-r--r-- | wombat/wombat.c | 2 |
9 files changed, 179 insertions, 48 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index d2e7395d38..cb6314bdb4 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,14 @@ +2000-04-19 Seth Alves <alves@hungry.com> + + * gui/evolution-calendar-control.c (calendar_properties_init): create + a property bag for this control + (set_prop): callback for property sets + (get_prop): callback for proprety gets + + * gui/calendar-commands.c (calendar_set_uri): new function, + called when the "calendar_uri" property is set on the calendar- + control's property bag. + 2000-04-18 Federico Mena Quintero <federico@helixcode.com> * cal-util/Makefile.am (INCLUDES): Fix include path. diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c index 12b3c92774..850b5d95d9 100644 --- a/calendar/gui/calendar-commands.c +++ b/calendar/gui/calendar-commands.c @@ -32,9 +32,6 @@ char *user_name; /* The full user name from the Gecos field */ char *full_name; -/* The user's default calendar file */ -char *user_calendar_file; - /* a gnome-config string prefix that can be used to access the calendar config info */ char *calendar_settings; @@ -288,7 +285,7 @@ goto_clicked (BonoboUIHandler *uih, void *user_data, const char *path) static void new_calendar_cmd (BonoboUIHandler *uih, void *user_data, const char *path) { - new_calendar (full_name, NULL, NULL, NULL, FALSE); + new_calendar (full_name, NULL, NULL, FALSE); } static void @@ -342,7 +339,10 @@ open_ok (GtkWidget *widget, GtkFileSelection *fs) ret = gnome_dialog_run (GNOME_DIALOG (error_dialog)); } else { /* FIXME: find out who owns this calendar and use that name */ +#warning "fix me: find out who owns this calendar and use that name" + /* new_calendar ("Somebody", gtk_file_selection_get_filename (fs), NULL, NULL, FALSE); + */ gtk_widget_destroy (GTK_WIDGET (fs)); } } @@ -568,12 +568,12 @@ calendar_close_event (GtkWidget *widget, GdkEvent *event, GnomeCalendar *gcal) GnomeCalendar * -new_calendar (char *full_name, char *calendar_file, char *geometry, char *page, gboolean hidden) +new_calendar (char *full_name, char *geometry, char *page, gboolean hidden) { GtkWidget *toplevel; char title[128]; int xpos, ypos, width, height; - gboolean success; + /* i18n: This "%s%s" indicates possession. Languages where the order is * the inverse should translate it to "%2$s%1$s". @@ -590,21 +590,6 @@ new_calendar (char *full_name, char *calendar_file, char *geometry, char *page, if (page) gnome_calendar_set_view (GNOME_CALENDAR (toplevel), page); - printf ("calendar_file is '%s'\n", calendar_file?calendar_file:"NULL"); - if (calendar_file && g_file_exists (calendar_file)) { - printf ("loading calendar\n"); - success = gnome_calendar_load (GNOME_CALENDAR (toplevel), - calendar_file); - } - else { - printf ("creating calendar\n"); - success = gnome_calendar_create (GNOME_CALENDAR (toplevel), - calendar_file); - } - - printf ("load or create returned %d\n", success); - - gtk_signal_connect (GTK_OBJECT (toplevel), "delete_event", GTK_SIGNAL_FUNC(calendar_close_event), toplevel); @@ -627,9 +612,30 @@ new_calendar (char *full_name, char *calendar_file, char *geometry, char *page, return GNOME_CALENDAR (toplevel); } + +void calendar_set_uri (GnomeCalendar *gcal, char *calendar_file) +{ + gboolean success; + + printf ("calendar_set_uri: calendar_file is '%s'\n", + calendar_file ? calendar_file : "NULL"); + + if (calendar_file && g_file_exists (calendar_file)) { + printf ("loading calendar\n"); + success = gnome_calendar_load (gcal, calendar_file); + } + else { + printf ("creating calendar\n"); + success = gnome_calendar_create (gcal, calendar_file); + } + + printf (" load or create returned %d\n", success); +} + + /* * Initializes the calendar internal variables, loads defaults */ @@ -640,7 +646,7 @@ void init_calendar (void) char *str; init_username (); - user_calendar_file = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/user-cal.vcf"); + /*user_calendar_file = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/user-cal.vcf");*/ gnome_config_push_prefix (calendar_settings); diff --git a/calendar/gui/calendar-commands.h b/calendar/gui/calendar-commands.h index ab9b4d5d08..62e9d87512 100644 --- a/calendar/gui/calendar-commands.h +++ b/calendar/gui/calendar-commands.h @@ -92,8 +92,12 @@ void parse_color_spec (char *spec, int *r, int *g, int *b); /* Calls build_color_spec() for the color in the specified property number */ char *color_spec_from_prop (ColorProp propnum); -GnomeCalendar *new_calendar (char *full_name, char *calendar_file, - char *geometry, char *page, gboolean hidden); +GnomeCalendar *new_calendar (char *full_name, + char *geometry, + char *page, + gboolean hidden); + +void calendar_set_uri (GnomeCalendar *gcal, char *calendar_file); /*----------------------------------------------------------------------*/ @@ -124,7 +128,7 @@ void calendar_control_deactivate (BonoboControl *control); void quit_cmd (BonoboUIHandler *uih, void *user_data, const char *path); -extern char *user_calendar_file; +/*extern char *user_calendar_file;*/ extern char *user_name; extern char *full_name; extern int debug_alarms; diff --git a/calendar/gui/evolution-calendar-control.c b/calendar/gui/evolution-calendar-control.c index cba1180cf4..721a5e871c 100644 --- a/calendar/gui/evolution-calendar-control.c +++ b/calendar/gui/evolution-calendar-control.c @@ -12,7 +12,10 @@ #include <gui/eventedit.h> #include <gui/gnome-cal.h> #include <gui/calendar-commands.h> -/*#include <control/calendar-control.h>*/ + +#define PROPERTY_CALENDAR_URI "calendar_uri" + +#define PROPERTY_CALENDAR_URI_IDX 1 CORBA_Environment ev; @@ -31,18 +34,100 @@ control_activate_cb (BonoboControl *control, } + +static void +init_bonobo (int argc, char **argv) +{ + gnome_CORBA_init_with_popt_table ( + "evolution-calendar", "0.0", + &argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev); + + orb = gnome_CORBA_ORB (); + + if (bonobo_init (orb, NULL, NULL) == FALSE) + g_error (_("Could not initialize Bonobo")); +} + + + +static void +get_prop (BonoboPropertyBag *bag, + BonoboArg *arg, + guint arg_id, + gpointer user_data) +{ + GnomeCalendar *gcal = user_data; + + switch (arg_id) { + + case PROPERTY_CALENDAR_URI_IDX: + /* + if (fb && fb->uri) + BONOBO_ARG_SET_STRING (arg, fb->uri); + else + BONOBO_ARG_SET_STRING (arg, ""); + */ + break; + + default: + g_warning ("Unhandled arg %d\n", arg_id); + } +} + +static void +set_prop (BonoboPropertyBag *bag, + const BonoboArg *arg, + guint arg_id, + gpointer user_data) +{ + GnomeCalendar *gcal = user_data; + + switch (arg_id) { + + case PROPERTY_CALENDAR_URI_IDX: + printf ("set_prop: '%s'\n", BONOBO_ARG_GET_STRING (arg)); + calendar_set_uri (gcal, BONOBO_ARG_GET_STRING (arg)); + break; + + default: + g_warning ("Unhandled arg %d\n", arg_id); + break; + } +} + + +static void +calendar_properties_init (GnomeCalendar *gcal) +{ + gcal->properties = bonobo_property_bag_new (get_prop, set_prop, gcal); + + bonobo_property_bag_add (gcal->properties, + PROPERTY_CALENDAR_URI, + PROPERTY_CALENDAR_URI_IDX, + BONOBO_ARG_STRING, + NULL, + _("The URI that the calendar will display"), + 0); + + bonobo_control_set_property_bag (gcal->control, gcal->properties); +} + + + static BonoboObject * calendar_factory (BonoboGenericFactory *Factory, void *closure) { - BonoboControl *control; + BonoboControl *control; /* Create the control. */ - GnomeCalendar *cal = new_calendar (full_name, - user_calendar_file, - NULL, NULL, 0); + GnomeCalendar *cal = new_calendar (full_name, NULL, NULL, 0); + gtk_widget_show (GTK_WIDGET (cal)); control = bonobo_control_new (GTK_WIDGET (cal)); + cal->control = control; + + calendar_properties_init (cal); gtk_signal_connect (GTK_OBJECT (control), "activate", control_activate_cb, cal); @@ -69,26 +154,13 @@ calendar_factory_init (void) } -static void -init_bonobo (int argc, char **argv) -{ - gnome_CORBA_init_with_popt_table ( - "evolution-calendar", "0.0", - &argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev); - - orb = gnome_CORBA_ORB (); - - if (bonobo_init (orb, NULL, NULL) == FALSE) - g_error (_("Could not initialize Bonobo")); -} - int main (int argc, char **argv) { alarm_init (); init_calendar (); - /*g_log_set_always_fatal ((GLogLevelFlags) 0xFFFF);*/ + g_log_set_always_fatal ((GLogLevelFlags) 0xFFFF); CORBA_exception_init (&ev); diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index fec7b95bb5..6437977d6b 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -14,6 +14,7 @@ #include <gtk/gtkcalendar.h> #include <libgnomeui/gnome-app.h> #include <cal-client/cal-client.h> +#include <bonobo.h> BEGIN_GNOME_DECLS @@ -28,6 +29,9 @@ typedef struct { CalClient *client; time_t current_display; + BonoboPropertyBag *properties; + BonoboControl *control; + GtkWidget *notebook; GtkWidget *day_view; GtkWidget *week_view; diff --git a/calendar/gui/main.c b/calendar/gui/main.c index 871485750f..904868513e 100644 --- a/calendar/gui/main.c +++ b/calendar/gui/main.c @@ -44,10 +44,10 @@ static GList *start_views; static time_t from_t, to_t; /* If set, show events for the specified date and quit */ -static int show_events; +/*static int show_events;*/ /* If set, show todo items quit */ -static int show_todo; +/*static int show_todo;*/ /* If true, do not show our top level window */ int startup_hidden = 0; @@ -76,6 +76,8 @@ same_day (struct tm *a, struct tm *b) a->tm_year == b->tm_year); } + +#if 0 static void dump_events (void) { @@ -134,8 +136,10 @@ dump_events (void) /* calendar_destroy (cal); DELETE */ exit (0); } +#endif /* 0 */ +#if 0 static void dump_todo (void) { @@ -178,6 +182,8 @@ dump_todo (void) /* calendar_destroy (cal); DELETE */ exit (0); } +#endif /* 0 */ + static void session_die (void) @@ -269,13 +275,17 @@ parse_an_arg (poptContext ctx, start_calendars = g_list_append (start_calendars, arg); break; + /* case TODO_KEY: show_todo = 1; break; - + */ + + /* case 'e': show_events = 1; break; + */ case HIDDEN_KEY: startup_hidden = 1; @@ -339,11 +349,13 @@ main (int argc, char **argv) process_dates (); +# if 0 if (show_events) dump_events (); if (show_todo) dump_todo (); +# endif /* 0 */ client = gnome_master_client (); if (client) { diff --git a/shell/ChangeLog b/shell/ChangeLog index 6616d98314..de2478e268 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,7 @@ +2000-04-19 Seth Alves <alves@hungry.com> + + * e-shell-view.c (get_view): set calendar's uri with a property bag + 2000-04-19 Christopher James Lahey <clahey@helixcode.com> * idl/folder.idl: New idl file. Still unused. diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index ce77f55055..e18af8550d 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -150,9 +150,25 @@ get_view (EShellView *eshell_view, EFolder *efolder, Bonobo_UIHandler uih) w = bonobo_widget_new_control ("control:addressbook", uih); break; - case E_FOLDER_CALENDAR : + case E_FOLDER_CALENDAR : { + gchar *user_cal_file; + BonoboPropertyBagClient *pbc; + BonoboControlFrame *cf; + w = bonobo_widget_new_control ("control:calendar", uih); + cf = bonobo_widget_get_control_frame (BONOBO_WIDGET (w)); + pbc = bonobo_control_frame_get_control_property_bag (cf); + /*pbc = bonobo_control_get_property_bag (w);*/ + + user_cal_file = + g_concat_dir_and_file (gnome_util_user_home (), + ".gnome/user-cal.vcf"); + + bonobo_property_bag_client_set_value_string (pbc, + "calendar_uri", + user_cal_file); break; + } case E_FOLDER_TASKS : case E_FOLDER_OTHER : diff --git a/wombat/wombat.c b/wombat/wombat.c index 1d703e3833..a1bad2e858 100644 --- a/wombat/wombat.c +++ b/wombat/wombat.c @@ -136,6 +136,8 @@ main (int argc, char **argv) setup_pcs (argc, argv); setup_config (argc, argv); + /*g_log_set_always_fatal ((GLogLevelFlags) 0xFFFF);*/ + bonobo_main (); return 0; |