From 7ee6ef65f1019389c172478a80b8f0aa73a1453e Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 13 Sep 2008 04:02:09 +0000 Subject: Allow EShellContent, EShellSidebar, and EShellTaskbar to be subclassed, and begin doing so for Calendars, Memos and Tasks. Makes the code cleaner. svn path=/branches/kill-bonobo/; revision=36317 --- .../gui/component/e-book-shell-view-actions.c | 2 +- .../gui/component/e-book-shell-view-private.c | 3 +- .../gui/component/e-book-shell-view-private.h | 5 +- addressbook/gui/component/e-book-shell-view.c | 2 +- addressbook/gui/widgets/e-addressbook-selector.c | 26 +- addressbook/gui/widgets/e-addressbook-selector.h | 6 +- calendar/gui/Makefile.am | 42 ++- calendar/gui/calendar-component.c | 320 ------------------- calendar/gui/calendar-component.h | 3 - calendar/gui/e-cal-shell-sidebar.c | 331 +++++++++++++++++++ calendar/gui/e-cal-shell-sidebar.h | 67 ++++ calendar/gui/e-cal-shell-view-private.h | 2 +- calendar/gui/e-cal-shell-view.c | 1 + calendar/gui/e-calendar-table.c | 7 +- calendar/gui/e-calendar-table.h | 4 +- calendar/gui/e-memo-shell-module.c | 2 + calendar/gui/e-memo-shell-sidebar.c | 264 +++++++++++++++ calendar/gui/e-memo-shell-sidebar.h | 68 ++++ calendar/gui/e-memo-shell-view-actions.c | 136 ++++++++ calendar/gui/e-memo-shell-view-private.c | 26 ++ calendar/gui/e-memo-shell-view-private.h | 14 +- calendar/gui/e-memo-shell-view.c | 1 + calendar/gui/e-memos.c | 15 - calendar/gui/e-memos.h | 4 - calendar/gui/e-task-shell-sidebar.c | 264 +++++++++++++++ calendar/gui/e-task-shell-sidebar.h | 68 ++++ calendar/gui/e-task-shell-view-private.h | 2 +- calendar/gui/e-task-shell-view.c | 1 + calendar/gui/memos-component.c | 246 -------------- calendar/gui/memos-component.h | 1 - calendar/gui/memos-control.c | 353 --------------------- calendar/gui/memos-control.h | 36 --- calendar/gui/tasks-component.c | 194 ----------- calendar/gui/tasks-component.h | 2 - shell/e-shell-sidebar.c | 3 +- shell/e-shell-sidebar.h | 5 - shell/e-shell-view.c | 122 +++++-- shell/e-shell-view.h | 13 +- shell/e-shell-window-actions.c | 4 +- shell/e-shell-window.c | 6 +- 40 files changed, 1405 insertions(+), 1266 deletions(-) create mode 100644 calendar/gui/e-cal-shell-sidebar.c create mode 100644 calendar/gui/e-cal-shell-sidebar.h create mode 100644 calendar/gui/e-memo-shell-sidebar.c create mode 100644 calendar/gui/e-memo-shell-sidebar.h create mode 100644 calendar/gui/e-task-shell-sidebar.c create mode 100644 calendar/gui/e-task-shell-sidebar.h delete mode 100644 calendar/gui/memos-control.c delete mode 100644 calendar/gui/memos-control.h diff --git a/addressbook/gui/component/e-book-shell-view-actions.c b/addressbook/gui/component/e-book-shell-view-actions.c index 515531af88..d12f15e1f4 100644 --- a/addressbook/gui/component/e-book-shell-view-actions.c +++ b/addressbook/gui/component/e-book-shell-view-actions.c @@ -728,7 +728,7 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view) } void -e_book_shell_view_update_actions (EBookShellView *book_shell_view, +e_book_shell_view_actions_update (EBookShellView *book_shell_view, EABView *view) { EShellView *shell_view; diff --git a/addressbook/gui/component/e-book-shell-view-private.c b/addressbook/gui/component/e-book-shell-view-private.c index 1ed66f8289..037ef035bf 100644 --- a/addressbook/gui/component/e-book-shell-view-private.c +++ b/addressbook/gui/component/e-book-shell-view-private.c @@ -190,7 +190,7 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view) g_signal_connect_swapped ( uid_view, "command-state-change", - G_CALLBACK (e_book_shell_view_update_actions), + G_CALLBACK (e_book_shell_view_actions_update), book_shell_view); book = e_book_new (source, NULL); @@ -396,7 +396,6 @@ e_book_shell_view_private_dispose (EBookShellView *book_shell_view) DISPOSE (priv->contact_actions); DISPOSE (priv->notebook); - DISPOSE (priv->scrolled_window); DISPOSE (priv->selector); DISPOSE (priv->activity_handler); diff --git a/addressbook/gui/component/e-book-shell-view-private.h b/addressbook/gui/component/e-book-shell-view-private.h index 6fbff31c5d..ba805b0dc9 100644 --- a/addressbook/gui/component/e-book-shell-view-private.h +++ b/addressbook/gui/component/e-book-shell-view-private.h @@ -33,10 +33,10 @@ #include #include +#include #include #include -#include #include #include #include @@ -92,7 +92,6 @@ struct _EBookShellViewPrivate { /*** Other Stuff ***/ GtkWidget *notebook; - GtkWidget *scrolled_window; GtkWidget *selector; EActivityHandler *activity_handler; @@ -121,7 +120,7 @@ void e_book_shell_view_private_finalize void e_book_shell_view_actions_init (EBookShellView *book_shell_view); -void e_book_shell_view_update_actions +void e_book_shell_view_actions_update (EBookShellView *book_shell_view, EABView *view); EABView * e_book_shell_view_get_current_view diff --git a/addressbook/gui/component/e-book-shell-view.c b/addressbook/gui/component/e-book-shell-view.c index ce0c8f2b55..262c7da616 100644 --- a/addressbook/gui/component/e-book-shell-view.c +++ b/addressbook/gui/component/e-book-shell-view.c @@ -151,7 +151,7 @@ book_shell_view_source_list_changed_cb (EBookShellView *book_shell_view, #if 0 eab_view_setup_menus (view, bonobo_uic); #endif - e_book_shell_view_update_actions (book_shell_view, view); + e_book_shell_view_actions_update (book_shell_view, view); } } diff --git a/addressbook/gui/widgets/e-addressbook-selector.c b/addressbook/gui/widgets/e-addressbook-selector.c index e071e948f4..dfd0e32a7a 100644 --- a/addressbook/gui/widgets/e-addressbook-selector.c +++ b/addressbook/gui/widgets/e-addressbook-selector.c @@ -147,6 +147,9 @@ addressbook_selector_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time_) { + /* XXX This is exactly the same as in ECalendarSelector. + * Consider merging this callback into ESourceSelector. */ + GtkTreeView *tree_view; GtkTreeViewDropPosition pos; @@ -163,6 +166,9 @@ addressbook_selector_drag_motion (GtkWidget *widget, gint y, guint time_) { + /* XXX This is exactly the same as in ECalendarSelector. + * Consider merging this callback into ESourceSelector. */ + GtkTreeView *tree_view; GtkTreeModel *model; GtkTreePath *path = NULL; @@ -201,9 +207,9 @@ exit: gtk_tree_path_free (path); if (object != NULL) - g_object_ref (object); + g_object_unref (object); - gdk_drag_status (context, action, GDK_CURRENT_TIME); + gdk_drag_status (context, action, time_); return TRUE; } @@ -215,6 +221,9 @@ addressbook_selector_drag_drop (GtkWidget *widget, gint y, guint time_) { + /* XXX This is exactly the same as in ECalendarSelector. + * Consider merging this callback into ESourceSelector. */ + GtkTreeView *tree_view; GtkTreeModel *model; GtkTreePath *path; @@ -235,7 +244,7 @@ addressbook_selector_drag_drop (GtkWidget *widget, g_return_val_if_fail (valid, FALSE); gtk_tree_model_get (model, &iter, 0, &object, -1); - drop_zone = !E_IS_SOURCE_GROUP (object); + drop_zone = E_IS_SOURCE (object); g_object_unref (object); return drop_zone; @@ -250,6 +259,11 @@ addressbook_selector_drag_data_received (GtkWidget *widget, guint info, guint time_) { + /* XXX This is NEARLY the same as in ECalendarSelector. + * Consider merging this callback into ESourceSelector. + * Use a callback to allow subclasses to handle the + * received selection data. */ + MergeContext *merge_context; GtkTreeView *tree_view; GtkTreeModel *model; @@ -266,7 +280,7 @@ addressbook_selector_drag_data_received (GtkWidget *widget, tree_view = GTK_TREE_VIEW (widget); model = gtk_tree_view_get_model (tree_view); - string = (gchar *) selection_data->data; + string = (const gchar *) selection_data->data; remove_from_source = (context->action == GDK_ACTION_MOVE); if (!gtk_tree_view_get_dest_row_at_pos (tree_view, x, y, &path, NULL)) @@ -303,10 +317,10 @@ addressbook_selector_drag_data_received (GtkWidget *widget, success = TRUE; exit: - if (path) + if (path != NULL) gtk_tree_path_free (path); - if (object) + if (object != NULL) g_object_unref (object); gtk_drag_finish (context, success, remove_from_source, time_); diff --git a/addressbook/gui/widgets/e-addressbook-selector.h b/addressbook/gui/widgets/e-addressbook-selector.h index f78442601d..67a2c8f6e5 100644 --- a/addressbook/gui/widgets/e-addressbook-selector.h +++ b/addressbook/gui/widgets/e-addressbook-selector.h @@ -34,13 +34,13 @@ (G_TYPE_CHECK_CLASS_CAST \ ((cls), E_TYPE_ADDRESSBOOK_SELECTOR, EAddressbookSelectorClass)) #define E_IS_ADDRESSBOOK_SELECTOR(obj) \ - (E_TYPE_CHECK_INSTANCE_TYPE \ + (G_TYPE_CHECK_INSTANCE_TYPE \ ((obj), E_TYPE_ADDRESSBOOK_SELECTOR)) #define E_IS_ADDRESSBOOK_SELECTOR_CLASS(cls) \ - (E_TYPE_CHECK_CLASS_TYPE \ + (G_TYPE_CHECK_CLASS_TYPE \ ((cls), E_TYPE_ADDRESSBOOK_SELECTOR)) #define E_ADDRESSBOOK_SELECTOR_GET_CLASS(obj) \ - (E_TYPE_INSTANCE_GET_CLASS \ + (G_TYPE_INSTANCE_GET_CLASS \ ((obj), E_TYPE_ADDRESSBOOK_SELECTOR, EAddressbookSelectorClass)) G_BEGIN_DECLS diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index d2f092e422..f08b0272c3 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -44,40 +44,54 @@ module_LTLIBRARIES = \ libevolution-tasks.la libevolution_calendar_la_SOURCES = \ + calendar-config-keys.h \ calendar-config.c \ calendar-config.h \ - calendar-config-keys.h \ e-cal-shell-module.c \ - e-cal-shell-view.c \ - e-cal-shell-view.h \ + e-cal-shell-sidebar.c \ + e-cal-shell-sidebar.h \ e-cal-shell-view-actions.c \ e-cal-shell-view-actions.h \ e-cal-shell-view-private.c \ - e-cal-shell-view-private.h + e-cal-shell-view-private.h \ + e-cal-shell-view.c \ + e-cal-shell-view.h \ + e-calendar-selector.c \ + e-calendar-selector.h libevolution_memos_la_SOURCES = \ + calendar-config-keys.h \ calendar-config.c \ calendar-config.h \ - calendar-config-keys.h \ + e-calendar-selector.c \ + e-calendar-selector.h \ e-memo-shell-module.c \ - e-memo-shell-view.c \ - e-memo-shell-view.h \ + e-memo-shell-sidebar.c \ + e-memo-shell-sidebar.h \ e-memo-shell-view-actions.c \ e-memo-shell-view-actions.h \ e-memo-shell-view-private.c \ - e-memo-shell-view-private.h + e-memo-shell-view-private.h \ + e-memo-shell-view.c \ + e-memo-shell-view.h \ + e-memos.c \ + e-memos.h libevolution_tasks_la_SOURCES = \ + calendar-config-keys.h \ calendar-config.c \ calendar-config.h \ - calendar-config-keys.h \ + e-calendar-selector.c \ + e-calendar-selector.h \ e-task-shell-module.c \ - e-task-shell-view.c \ - e-task-shell-view.h \ + e-task-shell-sidebar.c \ + e-task-shell-sidebar.h \ e-task-shell-view-actions.c \ e-task-shell-view-actions.h \ e-task-shell-view-private.c \ - e-task-shell-view-private.h + e-task-shell-view-private.h \ + e-task-shell-view.c \ + e-task-shell-view.h glade_DATA = \ e-itip-control.glade \ @@ -219,8 +233,6 @@ etspec_DATA = \ # main.c \ # memos-component.c \ # memos-component.h \ -# memos-control.c \ -# memos-control.h \ # migration.c \ # migration.h \ # misc.c \ @@ -263,7 +275,6 @@ libevolution_memos_la_LIBADD = \ $(top_builddir)/widgets/misc/libemiscwidgets.la \ $(top_builddir)/filter/libfilter.la \ $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/a11y/calendar/libevolution-calendar-a11y.la \ $(LIBSOUP_LIBS) \ $(CAMEL_LIBS) \ $(EVOLUTION_CALENDAR_LIBS) @@ -279,7 +290,6 @@ libevolution_tasks_la_LIBADD = \ $(top_builddir)/widgets/misc/libemiscwidgets.la \ $(top_builddir)/filter/libfilter.la \ $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/a11y/calendar/libevolution-calendar-a11y.la \ $(LIBSOUP_LIBS) \ $(CAMEL_LIBS) \ $(EVOLUTION_CALENDAR_LIBS) diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c index 12a946418c..5f81c81acc 100644 --- a/calendar/gui/calendar-component.c +++ b/calendar/gui/calendar-component.c @@ -62,21 +62,6 @@ #define CREATE_MEETING_ID "meeting" #define CREATE_ALLDAY_EVENT_ID "allday-event" #define CREATE_CALENDAR_ID "calendar" -#define WEB_BASE_URI "webcal://" -#define CONTACTS_BASE_URI "contacts://" -#define WEATHER_BASE_URI "weather://" -#define PERSONAL_RELATIVE_URI "system" - -enum DndTargetType { - DND_TARGET_TYPE_CALENDAR_LIST, -}; -#define CALENDAR_TYPE "text/calendar" -#define XCALENDAR_TYPE "text/x-calendar" -static GtkTargetEntry drag_types[] = { - { CALENDAR_TYPE, 0, DND_TARGET_TYPE_CALENDAR_LIST }, - { XCALENDAR_TYPE, 0, DND_TARGET_TYPE_CALENDAR_LIST } -}; -static gint num_drag_types = sizeof(drag_types) / sizeof(drag_types[0]); #define PARENT_TYPE bonobo_object_get_type () static BonoboObjectClass *parent_class = NULL; @@ -521,109 +506,6 @@ source_removed_cb (GnomeCalendar *calendar, ECalSourceType source_type, ESource } } -static void -set_info (CalendarComponentView *component_view) -{ - icaltimezone *zone; - struct icaltimetype start_tt, end_tt; - time_t start_time, end_time; - struct tm start_tm, end_tm; - char buffer[512], end_buffer[256]; - GnomeCalendarViewType view; - - gnome_calendar_get_visible_time_range (component_view->calendar, &start_time, &end_time); - zone = gnome_calendar_get_timezone (component_view->calendar); - - start_tt = icaltime_from_timet_with_zone (start_time, FALSE, zone); - start_tm.tm_year = start_tt.year - 1900; - start_tm.tm_mon = start_tt.month - 1; - start_tm.tm_mday = start_tt.day; - start_tm.tm_hour = start_tt.hour; - start_tm.tm_min = start_tt.minute; - start_tm.tm_sec = start_tt.second; - start_tm.tm_isdst = -1; - start_tm.tm_wday = time_day_of_week (start_tt.day, start_tt.month - 1, - start_tt.year); - - /* Take one off end_time so we don't get an extra day. */ - end_tt = icaltime_from_timet_with_zone (end_time - 1, FALSE, zone); - end_tm.tm_year = end_tt.year - 1900; - end_tm.tm_mon = end_tt.month - 1; - end_tm.tm_mday = end_tt.day; - end_tm.tm_hour = end_tt.hour; - end_tm.tm_min = end_tt.minute; - end_tm.tm_sec = end_tt.second; - end_tm.tm_isdst = -1; - end_tm.tm_wday = time_day_of_week (end_tt.day, end_tt.month - 1, - end_tt.year); - - view = gnome_calendar_get_view (component_view->calendar); - - switch (view) { - case GNOME_CAL_DAY_VIEW: - case GNOME_CAL_WORK_WEEK_VIEW: - case GNOME_CAL_WEEK_VIEW: - if (start_tm.tm_year == end_tm.tm_year - && start_tm.tm_mon == end_tm.tm_mon - && start_tm.tm_mday == end_tm.tm_mday) { - e_utf8_strftime (buffer, sizeof (buffer), - _("%A %d %b %Y"), &start_tm); - } else if (start_tm.tm_year == end_tm.tm_year) { - e_utf8_strftime (buffer, sizeof (buffer), - _("%a %d %b"), &start_tm); - e_utf8_strftime (end_buffer, sizeof (end_buffer), - _("%a %d %b %Y"), &end_tm); - strcat (buffer, " - "); - strcat (buffer, end_buffer); - } else { - e_utf8_strftime (buffer, sizeof (buffer), - _("%a %d %b %Y"), &start_tm); - e_utf8_strftime (end_buffer, sizeof (end_buffer), - _("%a %d %b %Y"), &end_tm); - strcat (buffer, " - "); - strcat (buffer, end_buffer); - } - break; - case GNOME_CAL_MONTH_VIEW: - case GNOME_CAL_LIST_VIEW: - if (start_tm.tm_year == end_tm.tm_year) { - if (start_tm.tm_mon == end_tm.tm_mon) { - e_utf8_strftime (buffer, sizeof (buffer), - "%d", &start_tm); - e_utf8_strftime (end_buffer, sizeof (end_buffer), - _("%d %b %Y"), &end_tm); - strcat (buffer, " - "); - strcat (buffer, end_buffer); - } else { - e_utf8_strftime (buffer, sizeof (buffer), - _("%d %b"), &start_tm); - e_utf8_strftime (end_buffer, sizeof (end_buffer), - _("%d %b %Y"), &end_tm); - strcat (buffer, " - "); - strcat (buffer, end_buffer); - } - } else { - e_utf8_strftime (buffer, sizeof (buffer), - _("%d %b %Y"), &start_tm); - e_utf8_strftime (end_buffer, sizeof (end_buffer), - _("%d %b %Y"), &end_tm); - strcat (buffer, " - "); - strcat (buffer, end_buffer); - } - break; - default: - g_return_if_reached (); - } - - e_info_label_set_info (component_view->info_label, _("Calendars"), buffer); -} - -static void -calendar_dates_changed_cb (GnomeCalendar *calendar, CalendarComponentView *component_view) -{ - set_info (component_view); -} - static void config_primary_selection_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) { @@ -768,88 +650,6 @@ impl_upgradeFromVersion (PortableServer_Servant servant, g_error_free(err); } -static gboolean -selector_tree_drag_drop (GtkWidget *widget, - GdkDragContext *context, - int x, - int y, - guint time, - CalendarComponent *component) -{ - GtkTreeViewColumn *column; - int cell_x; - int cell_y; - GtkTreePath *path; - GtkTreeModel *model; - GtkTreeIter iter; - gpointer data; - - if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), x, y, &path, - &column, &cell_x, &cell_y)) - return FALSE; - - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - - if (!gtk_tree_model_get_iter (model, &iter, path)) { - gtk_tree_path_free (path); - return FALSE; - } - - gtk_tree_model_get (model, &iter, 0, &data, -1); - - if (E_IS_SOURCE_GROUP (data)) { - g_object_unref (data); - gtk_tree_path_free (path); - return FALSE; - } - - gtk_tree_path_free (path); - return TRUE; -} - -static gboolean -selector_tree_drag_motion (GtkWidget *widget, - GdkDragContext *context, - int x, - int y, - guint time, - gpointer user_data) -{ - GtkTreePath *path = NULL; - gpointer data = NULL; - GtkTreeViewDropPosition pos; - GtkTreeModel *model; - GtkTreeIter iter; - GdkDragAction action = GDK_ACTION_DEFAULT; - - if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget), - x, y, &path, &pos)) - goto finish; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - - if (!gtk_tree_model_get_iter (model, &iter, path)) - goto finish; - - gtk_tree_model_get (model, &iter, 0, &data, -1); - - if (E_IS_SOURCE_GROUP (data) || e_source_get_readonly (data)) - goto finish; - - gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget), path, GTK_TREE_VIEW_DROP_INTO_OR_BEFORE); - action = context->suggested_action; - - finish: - if (path) - gtk_tree_path_free (path); - if (data) - g_object_unref (data); - - gdk_drag_status (context, action, time); - return TRUE; -} - static gboolean update_single_object (ECal *client, icalcomponent *icalcomp) { @@ -904,96 +704,6 @@ update_objects (ECal *client, icalcomponent *icalcomp) return TRUE; } -static void -selector_tree_drag_data_received (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *data, - guint info, - guint time, - gpointer user_data) -{ - GtkTreePath *path = NULL; - GtkTreeViewDropPosition pos; - gpointer source = NULL; - GtkTreeModel *model; - GtkTreeIter iter; - gboolean success = FALSE; - icalcomponent *icalcomp = NULL; - ECal *client = NULL; - - if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget), - x, y, &path, &pos)) - goto finish; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - - if (!gtk_tree_model_get_iter (model, &iter, path)) - goto finish; - - - gtk_tree_model_get (model, &iter, 0, &source, -1); - - if (E_IS_SOURCE_GROUP (source) || e_source_get_readonly (source)) - goto finish; - - icalcomp = icalparser_parse_string ((char *)data->data); - - if (icalcomp) { - char * uid; - - /* FIXME deal with GDK_ACTION_ASK */ - if (context->action == GDK_ACTION_COPY) { - uid = e_cal_component_gen_uid (); - icalcomponent_set_uid (icalcomp, uid); - } - - client = auth_new_cal_from_source (source, - E_CAL_SOURCE_TYPE_EVENT); - - if (client) { - if (e_cal_open (client, TRUE, NULL)) { - success = TRUE; - update_objects (client, icalcomp); - } - - g_object_unref (client); - } - - icalcomponent_free (icalcomp); - } - - finish: - if (source) - g_object_unref (source); - if (path) - gtk_tree_path_free (path); - - gtk_drag_finish (context, success, context->action == GDK_ACTION_MOVE, time); -} - -static void -selector_tree_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time, gpointer data) -{ - gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget), - NULL, GTK_TREE_VIEW_DROP_BEFORE); -} - -static void -control_activate_cb (BonoboControl *control, gboolean activate, gpointer data) -{ - CalendarComponentView *component_view = data; - - if (activate) { - BonoboUIComponent *uic; - uic = bonobo_control_get_ui_component (component_view->view_control); - - e_user_creatable_items_handler_activate (component_view->creatable_items_handler, uic); - } -} - - static void config_create_ecal_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) { @@ -1189,18 +899,6 @@ create_component_view (CalendarComponent *calendar_component) a11y = gtk_widget_get_accessible (GTK_WIDGET (component_view->source_selector)); atk_object_set_name (a11y, _("Calendar Source Selector")); - g_signal_connect (component_view->source_selector, "drag-motion", G_CALLBACK (selector_tree_drag_motion), - calendar_component); - g_signal_connect (component_view->source_selector, "drag-leave", G_CALLBACK (selector_tree_drag_leave), - calendar_component); - g_signal_connect (component_view->source_selector, "drag-drop", G_CALLBACK (selector_tree_drag_drop), - calendar_component); - g_signal_connect (component_view->source_selector, "drag-data-received", - G_CALLBACK (selector_tree_drag_data_received), calendar_component); - - gtk_drag_dest_set(component_view->source_selector, GTK_DEST_DEFAULT_ALL, drag_types, - num_drag_types, GDK_ACTION_COPY | GDK_ACTION_MOVE); - gtk_widget_show (component_view->source_selector); selector_scrolled_window = gtk_scrolled_window_new (NULL, NULL); @@ -1211,10 +909,6 @@ create_component_view (CalendarComponent *calendar_component) GTK_SHADOW_IN); gtk_widget_show (selector_scrolled_window); - component_view->info_label = (EInfoLabel *)e_info_label_new("x-office-calendar"); - e_info_label_set_info (component_view->info_label, _("Calendars"), ""); - gtk_widget_show (GTK_WIDGET (component_view->info_label)); - vbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (component_view->info_label), FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX (vbox), selector_scrolled_window, TRUE, TRUE, 0); @@ -1265,11 +959,6 @@ create_component_view (CalendarComponent *calendar_component) component_view->creatable_items_handler = e_user_creatable_items_handler_new ("calendar", create_local_item_cb, calendar_component); g_signal_connect (component_view->view_control, "activate", G_CALLBACK (control_activate_cb), component_view); - /* We use this to update the component information */ - set_info (component_view); - g_signal_connect (component_view->calendar, "dates_shown_changed", - G_CALLBACK (calendar_dates_changed_cb), component_view); - /* Load the selection from the last run */ update_selection (component_view); update_primary_selection (component_view); @@ -1516,13 +1205,4 @@ calendar_component_init (CalendarComponent *component) ; } - -/* Public API. */ - -ESourceList * -calendar_component_peek_source_list (CalendarComponent *component) -{ - return component->priv->source_list; -} - BONOBO_TYPE_FUNC_FULL (CalendarComponent, GNOME_Evolution_Component, PARENT_TYPE, calendar_component) diff --git a/calendar/gui/calendar-component.h b/calendar/gui/calendar-component.h index 8fdb92abbb..1e23bd52c1 100644 --- a/calendar/gui/calendar-component.h +++ b/calendar/gui/calendar-component.h @@ -55,7 +55,4 @@ struct _CalendarComponentClass { GType calendar_component_get_type (void); -ESourceList *calendar_component_peek_source_list (CalendarComponent *component); - - #endif /* _CALENDAR_COMPONENT_H_ */ diff --git a/calendar/gui/e-cal-shell-sidebar.c b/calendar/gui/e-cal-shell-sidebar.c new file mode 100644 index 0000000000..5d14f589f0 --- /dev/null +++ b/calendar/gui/e-cal-shell-sidebar.c @@ -0,0 +1,331 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-cal-shell-sidebar.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-cal-shell-sidebar.h" + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#define E_CAL_SHELL_SIDEBAR_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_CAL_SHELL_SIDEBAR, ECalShellSidebarPrivate)) + +struct _ECalShellSidebarPrivate { + GtkWidget *selector; +}; + +enum { + PROP_0, + PROP_SELECTOR +}; + +static gpointer parent_class; + +static void +cal_shell_sidebar_update (EShellSidebar *shell_sidebar) +{ + EShellView *shell_view; + GnomeCalendar *calendar; + GnomeCalendarViewType view; + time_t start_time, end_time; + struct tm start_tm, end_tm; + struct icaltimetype start_tt, end_tt; + icaltimezone *timezone; + gchar buffer[512]; + gchar end_buffer[512]; + + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + calendar = e_cal_shell_view_get_calendar ( + E_CAL_SHELL_VIEW (shell_view)); + + gnome_calendar_get_visible_time_range ( + calendar, &start_time, &end_time); + timezone = gnome_calendar_get_timezone (calendar); + view = gnome_calendar_get_view (calendar); + + start_tt = icaltime_from_timet_with_zone (start_time, FALSE, timezone); + start_tm.tm_year = start_tt.year - 1900; + start_tm.tm_mon = start_tt.month - 1; + start_tm.tm_mday = start_tt.day; + start_tm.tm_hour = start_tt.hour; + start_tm.tm_min = start_tt.minute; + start_tm.tm_sec = start_tt.second; + start_tm.tm_isdst = -1; + start_tm.tm_wday = time_day_of_week ( + start_tt.day, start_tt.month - 1, start_tt.year); + + /* Subtract one from end_time so we don't get an extra day. */ + end_tt = icaltime_from_timet_with_zone (end_time - 1, FALSE, timezone); + end_tm.tm_year = end_tt.year - 1900; + end_tm.tm_mon = end_tt.month - 1; + end_tm.tm_mday = end_tt.day; + end_tm.tm_hour = end_tt.hour; + end_tm.tm_min = end_tt.minute; + end_tm.tm_sec = end_tt.second; + end_tm.tm_isdst = -1; + end_tm.tm_wday = time_day_of_week ( + end_tt.day, end_tt.month - 1, end_tt.year); + + switch (view) { + case GNOME_CAL_DAY_VIEW: + case GNOME_CAL_WORK_WEEK_VIEW: + case GNOME_CAL_WEEK_VIEW: + if (start_tm.tm_year == end_tm.tm_year && + start_tm.tm_mon == end_tm.tm_mon && + start_tm.tm_mday == end_tm.tm_mday) { + e_utf8_strftime ( + buffer, sizeof (buffer), + _("%A %d %b %Y"), &start_tm); + } else if (start_tm.tm_year == end_tm.tm_year) { + e_utf8_strftime ( + buffer, sizeof (buffer), + _("%a %d %b"), &start_tm); + e_utf8_strftime ( + end_buffer, sizeof (end_buffer), + _("%a %d %b %Y"), &end_tm); + strcat (buffer, " - "); + strcat (buffer, end_buffer); + } else { + e_utf8_strftime ( + buffer, sizeof (buffer), + _("%a %d %b %Y"), &start_tm); + e_utf8_strftime ( + end_buffer, sizeof (end_buffer), + _("%a %d %b %Y"), &end_tm); + strcat (buffer, " - "); + strcat (buffer, end_buffer); + } + break; + + case GNOME_CAL_MONTH_VIEW: + case GNOME_CAL_LIST_VIEW: + if (start_tm.tm_year == end_tm.tm_year) { + if (start_tm.tm_mon == end_tm.tm_mon) { + e_utf8_strftime ( + buffer, + sizeof (buffer), + "%d", &start_tm); + e_utf8_strftime ( + end_buffer, + sizeof (end_buffer), + _("%d %b %Y"), &end_tm); + strcat (buffer, " - "); + strcat (buffer, end_buffer); + } else { + e_utf8_strftime ( + buffer, + sizeof (buffer), + _("%d %b"), &start_tm); + e_utf8_strftime ( + end_buffer, + sizeof (end_buffer), + _("%d %b %Y"), &end_tm); + strcat (buffer, " - "); + strcat (buffer, end_buffer); + } + } else { + e_utf8_strftime ( + buffer, sizeof (buffer), + _("%d %b %Y"), &start_tm); + e_utf8_strftime ( + end_buffer, sizeof (end_buffer), + _("%d %b %Y"), &end_tm); + strcat (buffer, " - "); + strcat (buffer, end_buffer); + } + break; + + default: + g_return_if_reached (); + } + + e_shell_sidebar_set_secondary_text (shell_sidebar, buffer); +} + +static void +cal_shell_sidebar_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SELECTOR: + g_value_set_object ( + value, e_cal_shell_sidebar_get_selector ( + E_CAL_SHELL_SIDEBAR (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +cal_shell_sidebar_dispose (GObject *object) +{ + ECalShellSidebarPrivate *priv; + + priv = E_CAL_SHELL_SIDEBAR_GET_PRIVATE (object); + + if (priv->selector != NULL) { + g_object_unref (priv->selector); + priv->selector = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +cal_shell_sidebar_constructed (GObject *object) +{ + ECalShellSidebarPrivate *priv; + EShellView *shell_view; + EShellSidebar *shell_sidebar; + ECalShellView *cal_shell_view; + ESourceList *source_list; + GtkContainer *container; + GtkWidget *widget; + GnomeCalendar *calendar; + + priv = E_CAL_SHELL_SIDEBAR_GET_PRIVATE (object); + + shell_sidebar = E_SHELL_SIDEBAR (object); + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + cal_shell_view = E_CAL_SHELL_VIEW (shell_view); + source_list = e_cal_shell_view_get_source_list (cal_shell_view); + + container = GTK_CONTAINER (shell_sidebar); + + widget = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy ( + GTK_SCROLLED_WINDOW (widget), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type ( + GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); + gtk_container_add (container, widget); + gtk_widget_show (widget); + + container = GTK_CONTAINER (widget); + + widget = e_calendar_selector_new (source_list); + e_source_selector_set_select_new (E_SOURCE_SELECTOR (widget), TRUE); + gtk_container_add (container, widget); + priv->selector = g_object_ref (widget); + gtk_widget_show (widget); + + /* Setup signal handlers. */ + + calendar = e_cal_shell_view_get_calendar (cal_shell_view); + + g_signal_connect_swapped ( + calendar, "dates-shown-changed", + G_CALLBACK (cal_shell_sidebar_update), + shell_sidebar); + + cal_shell_sidebar_update (shell_sidebar); +} + +static void +cal_shell_sidebar_class_init (ECalShellSidebarClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (ECalShellSidebarPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->get_property = cal_shell_sidebar_get_property; + object_class->dispose = cal_shell_sidebar_dispose; + object_class->constructed = cal_shell_sidebar_constructed; + + g_object_class_install_property ( + object_class, + PROP_SELECTOR, + g_param_spec_object ( + "selector", + _("Source Selector Widget"), + _("This widget displays groups of calendars"), + E_TYPE_SOURCE_SELECTOR, + G_PARAM_READABLE)); +} + +static void +cal_shell_sidebar_init (ECalShellSidebar *cal_shell_sidebar) +{ + cal_shell_sidebar->priv = + E_CAL_SHELL_SIDEBAR_GET_PRIVATE (cal_shell_sidebar); + + /* Postpone widget construction until we have a shell view. */ +} + +GType +e_cal_shell_sidebar_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (ECalShellSidebarClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) cal_shell_sidebar_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (ECalShellSidebar), + 0, /* n_preallocs */ + (GInstanceInitFunc) cal_shell_sidebar_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + E_TYPE_SHELL_SIDEBAR, "ECalShellSidebar", + &type_info, 0); + } + + return type; +} + +GtkWidget * +e_cal_shell_sidebar_new (EShellView *shell_view) +{ + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + return g_object_new ( + E_TYPE_CAL_SHELL_SIDEBAR, + "shell-view", shell_view, NULL); +} + +GtkWidget * +e_cal_shell_sidebar_get_selector (ECalShellSidebar *cal_shell_sidebar) +{ + g_return_val_if_fail ( + E_IS_CAL_SHELL_SIDEBAR (cal_shell_sidebar), NULL); + + return cal_shell_sidebar->priv->selector; +} diff --git a/calendar/gui/e-cal-shell-sidebar.h b/calendar/gui/e-cal-shell-sidebar.h new file mode 100644 index 0000000000..89eaee7613 --- /dev/null +++ b/calendar/gui/e-cal-shell-sidebar.h @@ -0,0 +1,67 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-cal-shell-sidebar.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_CAL_SHELL_SIDEBAR_H +#define E_CAL_SHELL_SIDEBAR_H + +#include +#include + +/* Standard GObject macros */ +#define E_TYPE_CAL_SHELL_SIDEBAR \ + (e_cal_shell_sidebar_get_type ()) +#define E_CAL_SHELL_SIDEBAR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_CAL_SHELL_SIDEBAR, ECalShellSidebar)) +#define E_CAL_SHELL_SIDEBAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_CAL_SHELL_SIDEBAR, ECalShellSidebarClass)) +#define E_IS_CAL_SHELL_SIDEBAR(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_CAL_SHELL_SIDEBAR)) +#define E_IS_CAL_SHELL_SIDEBAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_CAL_SHELL_SIDEBAR)) +#define E_CAL_SHELL_SIDEBAR_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_CAL_SHELL_SIDEBAR, ECalShellSidebarClass)) + +G_BEGIN_DECLS + +typedef struct _ECalShellSidebar ECalShellSidebar; +typedef struct _ECalShellSidebarClass ECalShellSidebarClass; +typedef struct _ECalShellSidebarPrivate ECalShellSidebarPrivate; + +struct _ECalShellSidebar { + EShellSidebar parent; + ECalShellSidebarPrivate *priv; +}; + +struct _ECalShellSidebarClass { + EShellSidebarClass parent_class; +}; + +GType e_cal_shell_sidebar_get_type (void); +GtkWidget * e_cal_shell_sidebar_new (EShellView *shell_view); +GtkWidget * e_cal_shell_sidebar_get_selector(ECalShellSidebar *cal_shell_sidebar); + +G_END_DECLS + +#endif /* E_CAL_SHELL_SIDEBAR_H */ diff --git a/calendar/gui/e-cal-shell-view-private.h b/calendar/gui/e-cal-shell-view-private.h index 0b2633d2be..553dc5246c 100644 --- a/calendar/gui/e-cal-shell-view-private.h +++ b/calendar/gui/e-cal-shell-view-private.h @@ -27,9 +27,9 @@ #include #include -#include #include +#include #include #define E_CAL_SHELL_VIEW_GET_PRIVATE(obj) \ diff --git a/calendar/gui/e-cal-shell-view.c b/calendar/gui/e-cal-shell-view.c index a1e21ab36f..7d7ebd009c 100644 --- a/calendar/gui/e-cal-shell-view.c +++ b/calendar/gui/e-cal-shell-view.c @@ -107,6 +107,7 @@ cal_shell_view_class_init (ECalShellView *class, shell_view_class->icon_name = "evolution-cals"; shell_view_class->type_module = type_module; shell_view_class->changed = cal_shell_view_changed; + shell_view_class->new_shell_sidebar = e_cal_shell_sidebar_new; g_object_class_install_property ( object_class, diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index 71c8cfae1f..9e74ea2c26 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -50,7 +50,6 @@ #include #include -#include "calendar-component.h" #include "calendar-config.h" #include "dialogs/delete-comp.h" #include "dialogs/delete-error.h" @@ -1858,12 +1857,8 @@ e_calendar_table_set_status_message (ECalendarTable *cal_table, const gchar *mes cal_table->activity_id = 0; } } else if (cal_table->activity_id == 0) { - char *client_id = g_strdup_printf ("%p", cal_table); - cal_table->activity_id = e_activity_handler_operation_started ( - cal_table->activity_handler, client_id, message, TRUE); - - g_free (client_id); + cal_table->activity_handler, message, TRUE); } else { double progress; diff --git a/calendar/gui/e-calendar-table.h b/calendar/gui/e-calendar-table.h index 519a540d4a..d2d95fbc73 100644 --- a/calendar/gui/e-calendar-table.h +++ b/calendar/gui/e-calendar-table.h @@ -26,6 +26,7 @@ #include #include #include +#include #include "e-cal-model.h" G_BEGIN_DECLS @@ -35,9 +36,6 @@ G_BEGIN_DECLS * Used for calendar events and tasks. */ -/* FIXME */ -typedef struct { gint bogus; } EActivityHandler; - #define E_CALENDAR_TABLE(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_calendar_table_get_type (), ECalendarTable) #define E_CALENDAR_TABLE_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_calendar_table_get_type (), ECalendarTableClass) #define E_IS_CALENDAR_TABLE(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_calendar_table_get_type ()) diff --git a/calendar/gui/e-memo-shell-module.c b/calendar/gui/e-memo-shell-module.c index 7629c2d0e3..05781d478f 100644 --- a/calendar/gui/e-memo-shell-module.c +++ b/calendar/gui/e-memo-shell-module.c @@ -31,6 +31,7 @@ #include #include +#include #define MODULE_NAME "memos" #define MODULE_ALIASES "" @@ -207,6 +208,7 @@ static void action_memo_list_new_cb (GtkAction *action, EShellWindow *shell_window) { + calendar_setup_new_memo_list (NULL); } static GtkActionEntry item_entries[] = { diff --git a/calendar/gui/e-memo-shell-sidebar.c b/calendar/gui/e-memo-shell-sidebar.c new file mode 100644 index 0000000000..43e61edef9 --- /dev/null +++ b/calendar/gui/e-memo-shell-sidebar.c @@ -0,0 +1,264 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-memo-shell-sidebar.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-memo-shell-sidebar.h" + +#include +#include + +#include +#include +#include + +#define E_MEMO_SHELL_SIDEBAR_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MEMO_SHELL_SIDEBAR, EMemoShellSidebarPrivate)) + +struct _EMemoShellSidebarPrivate { + GtkWidget *selector; +}; + +enum { + PROP_0, + PROP_SELECTOR +}; + +static gpointer parent_class; + +static void +memo_shell_sidebar_update (EShellSidebar *shell_sidebar) +{ + EShellView *shell_view; + EMemos *memos; + ETable *table; + ECalModel *model; + EMemoTable *memo_table; + GString *string; + const gchar *format; + gint n_rows; + gint n_selected; + + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + memos = e_memo_shell_view_get_memos (E_MEMO_SHELL_VIEW (shell_view)); + memo_table = e_memos_get_calendar_table (memos); + model = e_memo_table_get_model (memo_table); + table = e_memo_table_get_table (memo_table); + + n_rows = e_table_model_get_row_count (model); + n_selected = e_table_selected_count (table); + + string = g_string_sized_new (64); + + format = ngettext ("%d memo", "%d memos", n_rows); + g_string_append_printf (string, format, n_rows); + + if (n_selected > 0) { + format = _("%d selected"); + g_string_append_len (string, ", ", 2); + g_string_append_printf (string, format, n_selected); + } + + e_shell_sidebar_set_secondary_text (shell_sidebar, string->str); + + g_string_free (string, TRUE); +} + +static void +memo_shell_sidebar_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SELECTOR: + g_value_set_object ( + value, e_memo_shell_sidebar_get_selector ( + E_MEMO_SHELL_SIDEBAR (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +memo_shell_sidebar_dispose (GObject *object) +{ + EMemoShellSidebarPrivate *priv; + + priv = E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (object); + + if (priv->selector != NULL) { + g_object_unref (priv->selector); + priv->selector = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +memo_shell_sidebar_constructed (GObject *object) +{ + EMemoShellSidebarPrivate *priv; + EShellView *shell_view; + EShellSidebar *shell_sidebar; + EMemoShellView *memo_shell_view; + ESourceList *source_list; + GtkContainer *container; + GtkWidget *widget; + EMemos *memos; + ETable *table; + ECalModel *model; + EMemoTable *memo_table; + + priv = E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (object); + + shell_sidebar = E_SHELL_SIDEBAR (object); + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + memo_shell_view = E_MEMO_SHELL_VIEW (shell_view); + source_list = e_memo_shell_view_get_source_list (memo_shell_view); + + container = GTK_CONTAINER (shell_sidebar); + + widget = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy ( + GTK_SCROLLED_WINDOW (widget), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type ( + GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); + gtk_container_add (container, widget); + gtk_widget_show (widget); + + container = GTK_CONTAINER (widget); + + widget = e_calendar_selector_new (source_list); + e_source_selector_set_select_new (E_SOURCE_SELECTOR (widget), TRUE); + gtk_container_add (container, widget); + priv->selector = g_object_ref (widget); + gtk_widget_show (widget); + + /* Setup signal handlers. */ + + memos = e_memo_shell_view_get_memos (memo_shell_view); + memo_table = e_memos_get_calendar_table (memos); + model = e_memo_table_get_model (memo_table); + table = e_memo_table_get_table (memo_table); + + g_signal_connect_swapped ( + model, "model-changed", + G_CALLBACK (memo_shell_sidebar_update), + shell_sidebar); + + g_signal_connect_swapped ( + model, "model-rows-deleted", + G_CALLBACK (memo_shell_sidebar_update), + shell_sidebar); + + g_signal_connect_swapped ( + model, "model-rows-inserted", + G_CALLBACK (memo_shell_sidebar_update), + shell_sidebar); + + g_signal_connect_swapped ( + model, "selection-change", + G_CALLBACK (memo_shell_sidebar_update), + shell_sidebar); + + memo_shell_sidebar_update (shell_sidebar); +} + +static void +memo_shell_sidebar_class_init (EMemoShellSidebarClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EMemoShellSidebarPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->get_property = memo_shell_sidebar_get_property; + object_class->dispose = memo_shell_sidebar_dispose; + object_class->constructed = memo_shell_sidebar_constructed; + + g_object_class_install_property ( + object_class, + PROP_SELECTOR, + g_param_spec_object ( + "selector", + _("Source Selector Widget"), + _("This widget displays groups of memo lists"), + E_TYPE_SOURCE_SELECTOR, + G_PARAM_READABLE)); +} + +static void +memo_shell_sidebar_init (EMemoShellSidebar *memo_shell_sidebar) +{ + memo_shell_sidebar->priv = + E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (memo_shell_sidebar); + + /* Postpone widget construction until we have a shell view. */ +} + +GType +e_memo_shell_sidebar_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (EMemoShellSidebarClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) memo_shell_sidebar_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EMemoShellSidebar), + 0, /* n_preallocs */ + (GInstanceInitFunc) memo_shell_sidebar_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + E_TYPE_SHELL_SIDEBAR, "EMemoShellSidebar", + &type_info, 0); + } + + return type; +} + +GtkWidget * +e_memo_shell_sidebar_new (EShellView *shell_view) +{ + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + return g_object_new ( + E_TYPE_MEMO_SHELL_SIDEBAR, + "shell-view", shell_view, NULL); +} + +GtkWidget * +e_memo_shell_sidebar_get_selector (EMemoShellSidebar *memo_shell_sidebar) +{ + g_return_val_if_fail ( + E_IS_MEMO_SHELL_SIDEBAR (memo_shell_sidebar), NULL); + + return memo_shell_sidebar->priv->selector; +} diff --git a/calendar/gui/e-memo-shell-sidebar.h b/calendar/gui/e-memo-shell-sidebar.h new file mode 100644 index 0000000000..ee487b07cb --- /dev/null +++ b/calendar/gui/e-memo-shell-sidebar.h @@ -0,0 +1,68 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-memo-shell-sidebar.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_MEMO_SHELL_SIDEBAR_H +#define E_MEMO_SHELL_SIDEBAR_H + +#include +#include + +/* Standard GObject macros */ +#define E_TYPE_MEMO_SHELL_SIDEBAR \ + (e_memo_shell_sidebar_get_type ()) +#define E_MEMO_SHELL_SIDEBAR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_MEMO_SHELL_SIDEBAR, EMemoShellSidebar)) +#define E_MEMO_SHELL_SIDEBAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_MEMO_SHELL_SIDEBAR, EMemoShellSidebarClass)) +#define E_IS_MEMO_SHELL_SIDEBAR(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_MEMO_SHELL_SIDEBAR)) +#define E_IS_MEMO_SHELL_SIDEBAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_MEMO_SHELL_SIDEBAR)) +#define E_MEMO_SHELL_SIDEBAR_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_MEMO_SHELL_SIDEBAR, EMemoShellSidebarClass)) + +G_BEGIN_DECLS + +typedef struct _EMemoShellSidebar EMemoShellSidebar; +typedef struct _EMemoShellSidebarClass EMemoShellSidebarClass; +typedef struct _EMemoShellSidebarPrivate EMemoShellSidebarPrivate; + +struct _EMemoShellSidebar { + EShellSidebar parent; + EMemoShellSidebarPrivate *priv; +}; + +struct _EMemoShellSidebarClass { + EShellSidebarClass parent_class; +}; + +GType e_memo_shell_sidebar_get_type (void); +GtkWidget * e_memo_shell_sidebar_new (EShellView *shell_view); +GtkWidget * e_memo_shell_sidebar_get_selector + (EMemoShellSidebar *memo_shell_sidebar); + +G_END_DECLS + +#endif /* E_MEMO_SHELL_SIDEBAR_H */ diff --git a/calendar/gui/e-memo-shell-view-actions.c b/calendar/gui/e-memo-shell-view-actions.c index 0e574cc618..1835cd144f 100644 --- a/calendar/gui/e-memo-shell-view-actions.c +++ b/calendar/gui/e-memo-shell-view-actions.c @@ -20,76 +20,150 @@ #include "e-memo-shell-view-private.h" +#include + +#include "print.h" + static void action_memo_clipboard_copy_cb (GtkAction *action, EMemoShellView *memo_shell_view) { + EMemos *memos; + EMemoTable *memo_table; + + memos = E_MEMOS (memo_shell_view->priv->memos); + memo_table = e_memos_get_calendar_table (memos); + e_memo_table_copy_clipboard (memo_table); } static void action_memo_clipboard_cut_cb (GtkAction *action, EMemoShellView *memo_shell_view) { + EMemos *memos; + EMemoTable *memo_table; + + memos = E_MEMOS (memo_shell_view->priv->memos); + memo_table = e_memos_get_calendar_table (memos); + e_memo_table_cut_clipboard (memo_table); } static void action_memo_clipboard_paste_cb (GtkAction *action, EMemoShellView *memo_shell_view) { + EMemos *memos; + EMemoTable *memo_table; + + memos = E_MEMOS (memo_shell_view->priv->memos); + memo_table = e_memos_get_calendar_table (memos); + e_memo_table_paste_clipboard (memo_table); } static void action_memo_delete_cb (GtkAction *action, EMemoShellView *memo_shell_view) { + EMemos *memos; + + memos = E_MEMOS (memo_shell_view->priv->memos); + e_memos_delete_selected (memos); } static void action_memo_list_copy_cb (GtkAction *action, EMemoShellView *memo_shell_view) { + /* FIXME */ } static void action_memo_list_delete_cb (GtkAction *action, EMemoShellView *memo_shell_view) { + /* FIXME */ } static void action_memo_list_new_cb (GtkAction *action, EMemoShellView *memo_shell_view) { + EShellView *shell_view; + EShellWindow *shell_window; + + shell_view = E_SHELL_VIEW (memo_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + calendar_setup_new_memo_list (GTK_WINDOW (shell_window)); } static void action_memo_list_properties_cb (GtkAction *action, EMemoShellView *memo_shell_view) { + EShellView *shell_view; + EShellWindow *shell_window; + ESource *source; + ESourceSelector *selector; + + shell_view = E_SHELL_VIEW (memo_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + selector = E_SOURCE_SELECTOR (memo_shell_view->priv->selector); + source = e_source_selector_peek_primary_selection (selector); + g_return_if_fail (source != NULL); + + calendar_setup_edit_memo_list (GTK_WINDOW (shell_window), source); } static void action_memo_open_cb (GtkAction *action, EMemoShellView *memo_shell_view) { + EMemos *memos; + + memos = E_MEMOS (memo_shell_view->priv->memos); + e_memos_open_memo (memos); } static void action_memo_preview_cb (GtkToggleAction *action, EMemoShellView *memo_shell_view) { + /* FIXME */ } static void action_memo_print_cb (GtkAction *action, EMemoShellView *memo_shell_view) { + EMemos *memos; + ETable *table; + EMemoTable *memo_table; + + memos = E_MEMOS (memo_shell_view->priv->memos); + memo_table = e_memos_get_calendar_table (memos); + table = e_memo_table_get_table (memo_table); + + print_table ( + table, _("Print Memos"), _("Memos"), + GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG); } static void action_memo_print_preview_cb (GtkAction *action, EMemoShellView *memo_shell_view) { + EMemos *memos; + ETable *table; + EMemoTable *memo_table; + + memos = E_MEMOS (memo_shell_view->priv->memos); + memo_table = e_memos_get_calendar_table (memos); + table = e_memo_table_get_table (memo_table); + + print_table ( + table, _("Print Memos"), _("Memos"), + GTK_PRINT_OPERATION_ACTION_PREVIEW); } static GtkActionEntry memo_entries[] = { @@ -190,7 +264,10 @@ e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view) EShellWindow *shell_window; GtkActionGroup *action_group; GtkUIManager *manager; + GConfBridge *bridge; + GObject *object; const gchar *domain; + const gchar *key; shell_view = E_SHELL_VIEW (memo_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); @@ -208,4 +285,63 @@ e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view) action_group, memo_toggle_entries, G_N_ELEMENTS (memo_toggle_entries), memo_shell_view); gtk_ui_manager_insert_action_group (manager, action_group, 0); + + /* Bind GObject properties to GConf keys. */ + + bridge = gconf_bridge_get (); + + object = G_OBJECT (ACTION (MEMO_PREVIEW)); + key = "/apps/evolution/calendar/display/show_memo_preview"; + gconf_bridge_bind_property (bridge, key, object, "active"); +} + +void +e_memo_shell_view_actions_update (EMemoShellView *memo_shell_view) +{ + ECal *cal; + EMemos *memos; + ETable *table; + ECalModel *model; + EMemoTable *memo_table; + EShellView *shell_view; + EShellWindow *shell_window; + GtkAction *action; + gboolean read_only = TRUE; + gboolean sensitive; + gint n_selected; + + shell_view = E_SHELL_VIEW (memo_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + memos = E_MEMOS (memo_shell_view->priv->memos); + memo_table = e_memos_get_calendar_table (memos); + + model = e_memo_table_get_model (memo_table); + cal = e_cal_model_get_default_client (model); + + table = e_memo_table_get_table (memo_table); + n_selected = e_table_selected_count (table); + + if (cal != NULL) + e_cal_is_read_only (cal, &read_only, NULL); + + action = ACTION (MEMO_OPEN); + sensitive = (n_selected == 1); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (MEMO_CLIPBOARD_COPY); + sensitive = (n_selected > 0); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (MEMO_CLIPBOARD_CUT); + sensitive = (n_selected > 0); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (MEMO_CLIPBOARD_PASTE); + sensitive = !read_only; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (MEMO_DELETE); + sensitive = (n_selected > 0) && !read_only; + gtk_action_set_sensitive (action, sensitive); } diff --git a/calendar/gui/e-memo-shell-view-private.c b/calendar/gui/e-memo-shell-view-private.c index bc38ee4a3e..36defa31af 100644 --- a/calendar/gui/e-memo-shell-view-private.c +++ b/calendar/gui/e-memo-shell-view-private.c @@ -34,12 +34,34 @@ e_memo_shell_view_private_init (EMemoShellView *memo_shell_view, priv->source_list = g_object_ref (source_list); priv->memo_actions = gtk_action_group_new ("memos"); + priv->activity_handler = e_activity_handler_new (); } void e_memo_shell_view_private_constructed (EMemoShellView *memo_shell_view) { EMemoShellViewPrivate *priv = memo_shell_view->priv; + EShellContent *shell_content; + EShellTaskbar *shell_taskbar; + EShellView *shell_view; + GtkWidget *container; + GtkWidget *widget; + + shell_view = E_SHELL_VIEW (memo_shell_view); + + /* Construct view widgets. */ + + widget = e_memos_new (); + shell_content = e_shell_view_get_content (shell_view); + gtk_container_add (GTK_CONTAINER (shell_content), widget); + priv->memos = g_object_ref (widget); + gtk_widget_show (widget); + + shell_taskbar = e_shell_view_get_taskbar (shell_view); + e_activity_handler_attach_task_bar ( + priv->activity_handler, shell_taskbar); + + e_memo_shell_view_actions_update (memo_shell_view); } void @@ -50,6 +72,10 @@ e_memo_shell_view_private_dispose (EMemoShellView *memo_shell_view) DISPOSE (priv->source_list); DISPOSE (priv->memo_actions); + + DISPOSE (priv->memos); + + DISPOSE (priv->activity_handler); } void diff --git a/calendar/gui/e-memo-shell-view-private.h b/calendar/gui/e-memo-shell-view-private.h index 1940dc0927..c53e55c487 100644 --- a/calendar/gui/e-memo-shell-view-private.h +++ b/calendar/gui/e-memo-shell-view-private.h @@ -27,9 +27,13 @@ #include #include -#include +#include +#include +#include +#include #include +#include #define E_MEMO_SHELL_VIEW_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -58,6 +62,12 @@ struct _EMemoShellViewPrivate { /*** UI Management ***/ GtkActionGroup *memo_actions; + + /*** Other Stuff ***/ + + GtkWidget *memos; + + EActivityHandler *activity_handler; }; void e_memo_shell_view_private_init @@ -74,6 +84,8 @@ void e_memo_shell_view_private_finalize void e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view); +void e_memo_shell_view_actions_update + (EMemoShellView *memo_shell_view); G_END_DECLS diff --git a/calendar/gui/e-memo-shell-view.c b/calendar/gui/e-memo-shell-view.c index 6b9032bb17..2f083ea23e 100644 --- a/calendar/gui/e-memo-shell-view.c +++ b/calendar/gui/e-memo-shell-view.c @@ -107,6 +107,7 @@ memo_shell_view_class_init (EMemoShellView *class, shell_view_class->icon_name = "evolution-memos"; shell_view_class->type_module = type_module; shell_view_class->changed = memo_shell_view_changed; + shell_view_class->new_shell_sidebar = e_memo_shell_sidebar_new; g_object_class_install_property ( object_class, diff --git a/calendar/gui/e-memos.c b/calendar/gui/e-memos.c index a8c5b41b2b..cc033942b4 100644 --- a/calendar/gui/e-memos.c +++ b/calendar/gui/e-memos.c @@ -38,20 +38,16 @@ #include "e-util/e-error.h" #include "e-util/e-categories-config.h" #include "e-util/e-util-private.h" -#include "shell/e-user-creatable-items-handler.h" #include #include #include #include "widgets/menus/gal-view-menus.h" #include "dialogs/delete-error.h" -#include "e-calendar-marshal.h" #include "calendar-config.h" #include "cal-search-bar.h" -#include "calendar-component.h" #include "comp-util.h" #include "e-memo-table-config.h" #include "misc.h" -#include "memos-component.h" #include "e-cal-component-memo-preview.h" #include "e-memos.h" #include "common/authentication.h" @@ -653,17 +649,6 @@ e_memos_new (void) } -void -e_memos_set_ui_component (EMemos *memos, - BonoboUIComponent *ui_component) -{ - g_return_if_fail (E_IS_MEMOS (memos)); - g_return_if_fail (ui_component == NULL || BONOBO_IS_UI_COMPONENT (ui_component)); - - e_search_bar_set_ui_component (E_SEARCH_BAR (memos->priv->search_bar), ui_component); -} - - static void e_memos_destroy (GtkObject *object) { diff --git a/calendar/gui/e-memos.h b/calendar/gui/e-memos.h index c4a4e96154..9f196ded22 100644 --- a/calendar/gui/e-memos.h +++ b/calendar/gui/e-memos.h @@ -25,7 +25,6 @@ #ifndef _E_MEMOS_H_ #define _E_MEMOS_H_ -#include #include #include #include @@ -64,9 +63,6 @@ GtkWidget *e_memos_construct (EMemos *memos); GtkWidget *e_memos_new (void); -void e_memos_set_ui_component (EMemos *memos, - BonoboUIComponent *ui_component); - gboolean e_memos_add_memo_source (EMemos *memos, ESource *source); gboolean e_memos_remove_memo_source (EMemos *memos, ESource *source); gboolean e_memos_set_default_source (EMemos *memos, ESource *source); diff --git a/calendar/gui/e-task-shell-sidebar.c b/calendar/gui/e-task-shell-sidebar.c new file mode 100644 index 0000000000..0b0668df86 --- /dev/null +++ b/calendar/gui/e-task-shell-sidebar.c @@ -0,0 +1,264 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-task-shell-sidebar.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-task-shell-sidebar.h" + +#include +#include + +#include +#include +#include + +#define E_TASK_SHELL_SIDEBAR_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_TASK_SHELL_SIDEBAR, ETaskShellSidebarPrivate)) + +struct _ETaskShellSidebarPrivate { + GtkWidget *selector; +}; + +enum { + PROP_0, + PROP_SELECTOR +}; + +static gpointer parent_class; + +static void +task_shell_sidebar_update (EShellSidebar *shell_sidebar) +{ + EShellView *shell_view; + ETasks *tasks; + ETable *table; + ECalModel *model; + ECalendarTable *cal_table; + GString *string; + const gchar *format; + gint n_rows; + gint n_selected; + + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + tasks = e_task_shell_view_get_tasks (E_TASK_SHELL_VIEW (shell_view)); + cal_table = e_tasks_get_calendar_table (tasks); + model = e_calendar_table_get_model (cal_table); + table = e_calendar_table_get_table (cal_table); + + n_rows = e_table_model_get_row_count (model); + n_selected = e_table_selected_count (table); + + string = g_string_sized_new (64); + + format = ngettext ("%d task", "%d tasks", n_rows); + g_string_append_printf (string, format, n_rows); + + if (n_selected > 0) { + format = _("%d selected"); + g_string_append_len (string, ", ", 2); + g_string_append_printf (string, format, n_selected); + } + + e_shell_sidebar_set_secondary_text (shell_sidebar, string->str); + + g_string_free (string, TRUE); +} + +static void +task_shell_sidebar_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SELECTOR: + g_value_set_object ( + value, e_task_shell_sidebar_get_selector ( + E_TASK_SHELL_SIDEBAR (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +task_shell_sidebar_dispose (GObject *object) +{ + ETaskShellSidebarPrivate *priv; + + priv = E_TASK_SHELL_SIDEBAR_GET_PRIVATE (object); + + if (priv->selector != NULL) { + g_object_unref (priv->selector); + priv->selector = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +task_shell_sidebar_constructed (GObject *object) +{ + ETaskShellSidebarPrivate *priv; + EShellView *shell_view; + EShellSidebar *shell_sidebar; + ETaskShellView *task_shell_view; + ESourceList *source_list; + GtkContainer *container; + GtkWidget *widget; + ETasks *tasks; + ETable *table; + ECalModel *model; + ECalendarTable *cal_table; + + priv = E_TASK_SHELL_SIDEBAR_GET_PRIVATE (object); + + shell_sidebar = E_SHELL_SIDEBAR (object); + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + task_shell_view = E_TASK_SHELL_VIEW (shell_view); + source_list = e_task_shell_view_get_source_list (task_shell_view); + + container = GTK_CONTAINER (shell_sidebar); + + widget = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy ( + GTK_SCROLLED_WINDOW (widget), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type ( + GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); + gtk_container_add (container, widget); + gtk_widget_show (widget); + + container = GTK_CONTAINER (widget); + + widget = e_calendar_selector_new (source_list); + e_source_selector_set_select_new (E_SOURCE_SELECTOR (widget), TRUE); + gtk_container_add (container, widget); + priv->selector = g_object_ref (widget); + gtk_widget_show (widget); + + /* Setup signal handlers. */ + + tasks = e_task_shell_view_get_tasks (task_shell_view); + cal_table = e_tasks_get_calendar_table (tasks); + model = e_calendar_table_get_model (cal_table); + table = e_calendar_table_get_table (cal_table); + + g_signal_connect_swapped ( + model, "model-changed", + G_CALLBACK (task_shell_sidebar_update), + shell_sidebar); + + g_signal_connect_swapped ( + model, "model-rows-deleted", + G_CALLBACK (task_shell_sidebar_update), + shell_sidebar); + + g_signal_connect_swapped ( + model, "model-rows-inserted", + G_CALLBACK (task_shell_sidebar_update), + shell_sidebar); + + g_signal_connect_swapped ( + model, "selection-change", + G_CALLBACK (task_shell_sidebar_update), + shell_sidebar); + + task_shell_sidebar_update (shell_sidebar); +} + +static void +task_shell_sidebar_class_init (ETaskShellSidebarClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (ETaskShellSidebarPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->get_property = task_shell_sidebar_get_property; + object_class->dispose = task_shell_sidebar_dispose; + object_class->constructed = task_shell_sidebar_constructed; + + g_object_class_install_property ( + object_class, + PROP_SELECTOR, + g_param_spec_object ( + "selector", + _("Source Selector Widget"), + _("This widget displays groups of task lists"), + E_TYPE_SOURCE_SELECTOR, + G_PARAM_READABLE)); +} + +static void +task_shell_sidebar_init (ETaskShellSidebar *task_shell_sidebar) +{ + task_shell_sidebar->priv = + E_TASK_SHELL_SIDEBAR_GET_PRIVATE (task_shell_sidebar); + + /* Postpone widget construction until we have a shell view. */ +} + +GType +e_task_shell_sidebar_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (ETaskShellSidebarClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) task_shell_sidebar_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (ETaskShellSidebar), + 0, /* n_preallocs */ + (GInstanceInitFunc) task_shell_sidebar_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + E_TYPE_SHELL_SIDEBAR, "ETaskShellSidebar", + &type_info, 0); + } + + return type; +} + +GtkWidget * +e_task_shell_sidebar_new (EShellView *shell_view) +{ + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + return g_object_new ( + E_TYPE_TASK_SHELL_SIDEBAR, + "shell-view", shell_view, NULL); +} + +GtkWidget * +e_task_shell_sidebar_get_selector (ETaskShellSidebar *task_shell_sidebar) +{ + g_return_val_if_fail ( + E_IS_TASK_SHELL_SIDEBAR (task_shell_sidebar), NULL); + + return task_shell_sidebar->priv->selector; +} diff --git a/calendar/gui/e-task-shell-sidebar.h b/calendar/gui/e-task-shell-sidebar.h new file mode 100644 index 0000000000..c50fde5d3c --- /dev/null +++ b/calendar/gui/e-task-shell-sidebar.h @@ -0,0 +1,68 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-task-shell-sidebar.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_TASK_SHELL_SIDEBAR_H +#define E_TASK_SHELL_SIDEBAR_H + +#include +#include + +/* Standard GObject macros */ +#define E_TYPE_TASK_SHELL_SIDEBAR \ + (e_task_shell_sidebar_get_type ()) +#define E_TASK_SHELL_SIDEBAR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_TASK_SHELL_SIDEBAR, ETaskShellSidebar)) +#define E_TASK_SHELL_SIDEBAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_TASK_SHELL_SIDEBAR, ETaskShellSidebarClass)) +#define E_IS_TASK_SHELL_SIDEBAR(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_TASK_SHELL_SIDEBAR)) +#define E_IS_TASK_SHELL_SIDEBAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_TASK_SHELL_SIDEBAR)) +#define E_TASK_SHELL_SIDEBAR_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_TASK_SHELL_SIDEBAR, ETaskShellSidebarClass)) + +G_BEGIN_DECLS + +typedef struct _ETaskShellSidebar ETaskShellSidebar; +typedef struct _ETaskShellSidebarClass ETaskShellSidebarClass; +typedef struct _ETaskShellSidebarPrivate ETaskShellSidebarPrivate; + +struct _ETaskShellSidebar { + EShellSidebar parent; + ETaskShellSidebarPrivate *priv; +}; + +struct _ETaskShellSidebarClass { + EShellSidebarClass parent_class; +}; + +GType e_task_shell_sidebar_get_type (void); +GtkWidget * e_task_shell_sidebar_new (EShellView *shell_view); +GtkWidget * e_task_shell_sidebar_get_selector + (ETaskShellSidebar *task_shell_sidebar); + +G_END_DECLS + +#endif /* E_TASK_SHELL_SIDEBAR_H */ diff --git a/calendar/gui/e-task-shell-view-private.h b/calendar/gui/e-task-shell-view-private.h index 22db8668c0..0c7f90c3be 100644 --- a/calendar/gui/e-task-shell-view-private.h +++ b/calendar/gui/e-task-shell-view-private.h @@ -27,8 +27,8 @@ #include #include -#include +#include #include #define E_TASK_SHELL_VIEW_GET_PRIVATE(obj) \ diff --git a/calendar/gui/e-task-shell-view.c b/calendar/gui/e-task-shell-view.c index 798d868910..6be8b48a4c 100644 --- a/calendar/gui/e-task-shell-view.c +++ b/calendar/gui/e-task-shell-view.c @@ -107,6 +107,7 @@ task_shell_view_class_init (ETaskShellView *class, shell_view_class->icon_name = "evolution-tasks"; shell_view_class->type_module = type_module; shell_view_class->changed = task_shell_view_changed; + shell_view_class->new_shell_sidebar = e_task_shell_sidebar_new; g_object_class_install_property ( object_class, diff --git a/calendar/gui/memos-component.c b/calendar/gui/memos-component.c index 93af51f061..4927dde9db 100644 --- a/calendar/gui/memos-component.c +++ b/calendar/gui/memos-component.c @@ -58,20 +58,9 @@ #define CREATE_SHARED_MEMO_ID "shared-memo" #define CREATE_MEMO_LIST_ID "memo-list" -enum DndTargetType { - DND_TARGET_TYPE_CALENDAR_LIST, -}; -#define CALENDAR_TYPE "text/calendar" -#define XCALENDAR_TYPE "text/x-calendar" #define WEB_BASE_URI "webcal://" #define PERSONAL_RELATIVE_URI "system" -static GtkTargetEntry drag_types[] = { - { CALENDAR_TYPE, 0, DND_TARGET_TYPE_CALENDAR_LIST }, - { XCALENDAR_TYPE, 0, DND_TARGET_TYPE_CALENDAR_LIST } -}; -static gint num_drag_types = sizeof(drag_types) / sizeof(drag_types[0]); - #define PARENT_TYPE bonobo_object_get_type () static BonoboObjectClass *parent_class = NULL; @@ -317,25 +306,6 @@ delete_memo_list_cb (EPopup *ep, EPopupItem *pitem, void *data) } } -static void -new_memo_list_cb (EPopup *ep, EPopupItem *pitem, void *data) -{ - calendar_setup_new_memo_list (GTK_WINDOW (gtk_widget_get_toplevel(ep->target->widget))); -} - -static void -edit_memo_list_cb (EPopup *ep, EPopupItem *pitem, void *data) -{ - MemosComponentView *component_view = data; - ESource *selected_source; - - selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector)); - if (!selected_source) - return; - - calendar_setup_edit_memo_list (GTK_WINDOW (gtk_widget_get_toplevel(ep->target->widget)), selected_source); -} - static EPopupItem emc_source_popups[] = { { E_POPUP_ITEM, "10.new", N_("_New Memo List"), new_memo_list_cb, NULL, "stock_notes", 0, 0 }, { E_POPUP_ITEM, "15.copy", N_("_Copy..."), copy_memo_list_cb, NULL, "edit-copy", 0, E_CAL_POPUP_SOURCE_PRIMARY }, @@ -408,48 +378,6 @@ source_removed_cb (EMemos *memos, ESource *source, MemosComponentView *component e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector), source); } -static void -set_info (MemosComponentView *component_view) -{ - GString *message = g_string_new (NULL); - int rows, selected_rows; - - rows = e_table_model_row_count (component_view->model); - selected_rows = e_table_selected_count (component_view->table); - - g_string_append_printf(message, ngettext("%d memo", "%d memos", rows), rows); - if (selected_rows > 0) - g_string_append_printf(message, ngettext(", %d selected", ", %d selected", selected_rows), selected_rows); - - e_info_label_set_info (component_view->info_label, _("Memos"), message->str); - - g_string_free (message, TRUE); -} - -static void -table_selection_change_cb (ETableModel *etm, MemosComponentView *component_view) -{ - set_info (component_view); -} - -static void -model_changed_cb (ETableModel *etm, MemosComponentView *component_view) -{ - set_info (component_view); -} - -static void -model_rows_inserted_cb (ETableModel *etm, int row, int count, MemosComponentView *component_view) -{ - set_info (component_view); -} - -static void -model_rows_deleted_cb (ETableModel *etm, int row, int count, MemosComponentView *component_view) -{ - set_info (component_view); -} - /* Evolution::Component CORBA methods */ static void @@ -475,90 +403,6 @@ impl_upgradeFromVersion (PortableServer_Servant servant, g_error_free(err); } -static gboolean -selector_tree_drag_drop (GtkWidget *widget, - GdkDragContext *context, - int x, - int y, - guint time, - CalendarComponent *component) -{ - GtkTreeViewColumn *column; - int cell_x; - int cell_y; - GtkTreePath *path; - GtkTreeModel *model; - GtkTreeIter iter; - gpointer data; - - if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), x, y, &path, - &column, &cell_x, &cell_y)) - return FALSE; - - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - - if (!gtk_tree_model_get_iter (model, &iter, path)) { - gtk_tree_path_free (path); - return FALSE; - } - - gtk_tree_model_get (model, &iter, 0, &data, -1); - - if (E_IS_SOURCE_GROUP (data)) { - g_object_unref (data); - gtk_tree_path_free (path); - return FALSE; - } - - gtk_tree_path_free (path); - return TRUE; -} - -static gboolean -selector_tree_drag_motion (GtkWidget *widget, - GdkDragContext *context, - int x, - int y, - guint time, - gpointer user_data) -{ - GtkTreePath *path = NULL; - gpointer data = NULL; - GtkTreeViewDropPosition pos; - GtkTreeModel *model; - GtkTreeIter iter; - GdkDragAction action = GDK_ACTION_DEFAULT; - - if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget), - x, y, &path, &pos)) - goto finish; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - - if (!gtk_tree_model_get_iter (model, &iter, path)) - goto finish; - - gtk_tree_model_get (model, &iter, 0, &data, -1); - - if (E_IS_SOURCE_GROUP (data) || e_source_get_readonly (data)) - goto finish; - - gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget), path, GTK_TREE_VIEW_DROP_INTO_OR_BEFORE); - action = context->suggested_action; - if (action == GDK_ACTION_COPY && (context->actions & GDK_ACTION_MOVE)) - action=GDK_ACTION_MOVE; - - finish: - if (path) - gtk_tree_path_free (path); - if (data) - g_object_unref (data); - - gdk_drag_status (context, action, time); - return TRUE; -} - static gboolean update_single_object (ECal *client, icalcomponent *icalcomp, gboolean fail_on_modify) { @@ -747,27 +591,6 @@ selector_tree_drag_data_received (GtkWidget *widget, gtk_drag_finish (context, success, success && context->action == GDK_ACTION_MOVE, time); } -static void -selector_tree_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time, gpointer data) -{ - gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget), - NULL, GTK_TREE_VIEW_DROP_BEFORE); -} - - -static void -control_activate_cb (BonoboControl *control, gboolean activate, gpointer data) -{ - MemosComponentView *component_view = data; - - if (activate) { - BonoboUIComponent *uic; - uic = bonobo_control_get_ui_component (component_view->view_control); - - e_user_creatable_items_handler_activate (component_view->creatable_items_handler, uic); - } -} - static void config_create_ecal_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) { @@ -942,48 +765,10 @@ create_component_view (MemosComponent *memos_component) /* Create the calendar component view */ component_view = g_new0 (MemosComponentView, 1); - /* Add the source lists */ - component_view->source_list = g_object_ref (priv->source_list); - /* Create sidebar selector */ - component_view->source_selector = e_source_selector_new (memos_component->priv->source_list); - e_source_selector_set_select_new ((ESourceSelector *)component_view->source_selector, TRUE); - a11y = gtk_widget_get_accessible (GTK_WIDGET (component_view->source_selector)); - atk_object_set_name (a11y, _("Memo Source Selector")); - - g_signal_connect (component_view->source_selector, "drag-motion", G_CALLBACK (selector_tree_drag_motion), - memos_component); - g_signal_connect (component_view->source_selector, "drag-leave", G_CALLBACK (selector_tree_drag_leave), - memos_component); - g_signal_connect (component_view->source_selector, "drag-drop", G_CALLBACK (selector_tree_drag_drop), - memos_component); g_signal_connect (component_view->source_selector, "drag-data-received", G_CALLBACK (selector_tree_drag_data_received), memos_component); - gtk_drag_dest_set(component_view->source_selector, GTK_DEST_DEFAULT_ALL, drag_types, - num_drag_types, GDK_ACTION_COPY | GDK_ACTION_MOVE); - - gtk_widget_show (component_view->source_selector); - - selector_scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_container_add (GTK_CONTAINER (selector_scrolled_window), component_view->source_selector); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (selector_scrolled_window), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (selector_scrolled_window), - GTK_SHADOW_IN); - gtk_widget_show (selector_scrolled_window); - - component_view->info_label = (EInfoLabel *)e_info_label_new("evolution-memos"); - e_info_label_set_info(component_view->info_label, _("Memos"), ""); - gtk_widget_show (GTK_WIDGET (component_view->info_label)); - - vbox = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (component_view->info_label), FALSE, TRUE, 0); - gtk_box_pack_start(GTK_BOX (vbox), selector_scrolled_window, TRUE, TRUE, 0); - gtk_widget_show (vbox); - - component_view->sidebar_control = bonobo_control_new (vbox); - /* Create main view */ component_view->view_control = memos_control_new (); if (!component_view->view_control) { @@ -1002,14 +787,6 @@ create_component_view (MemosComponent *memos_component) g_signal_connect (component_view->memos, "source_removed", G_CALLBACK (source_removed_cb), component_view); - /* Create status bar */ - statusbar_widget = e_task_bar_new (); - component_view->activity_handler = e_activity_handler_new (); - e_activity_handler_attach_task_bar (component_view->activity_handler, E_TASK_BAR (statusbar_widget)); - gtk_widget_show (statusbar_widget); - - component_view->statusbar_control = bonobo_control_new (statusbar_widget); - e_memo_table_set_activity_handler (e_memos_get_calendar_table (component_view->memos), component_view->activity_handler); /* connect after setting the initial selections, or we'll get unwanted calls @@ -1021,21 +798,6 @@ create_component_view (MemosComponent *memos_component) g_signal_connect (component_view->source_selector, "popup_event", G_CALLBACK (popup_event_cb), component_view); - /* Set up the "new" item handler */ - component_view->creatable_items_handler = e_user_creatable_items_handler_new ("memos", create_local_item_cb, memos_component); - g_signal_connect (component_view->view_control, "activate", G_CALLBACK (control_activate_cb), component_view); - - /* We use this to update the component information */ - set_info (component_view); - g_signal_connect (component_view->table, "selection_change", - G_CALLBACK (table_selection_change_cb), component_view); - g_signal_connect (component_view->model, "model_changed", - G_CALLBACK (model_changed_cb), component_view); - g_signal_connect (component_view->model, "model_rows_inserted", - G_CALLBACK (model_rows_inserted_cb), component_view); - g_signal_connect (component_view->model, "model_rows_deleted", - G_CALLBACK (model_rows_deleted_cb), component_view); - /* Load the selection from the last run */ update_selection (component_view); update_primary_selection (component_view); @@ -1226,12 +988,4 @@ memos_component_init (MemosComponent *component, MemosComponentClass *klass) component->priv = priv; } -/* Public API */ - -ESourceList * -memos_component_peek_source_list (MemosComponent *component) -{ - return component->priv->source_list; -} - BONOBO_TYPE_FUNC_FULL (MemosComponent, GNOME_Evolution_Component, PARENT_TYPE, memos_component) diff --git a/calendar/gui/memos-component.h b/calendar/gui/memos-component.h index 399f0ce06a..4841ef4c3e 100644 --- a/calendar/gui/memos-component.h +++ b/calendar/gui/memos-component.h @@ -56,6 +56,5 @@ struct _MemosComponentClass { GType memos_component_get_type (void); MemosComponent *memos_component_peek (void); -ESourceList *memos_component_peek_source_list (MemosComponent *component); #endif /* _MEMOS_COMPONENT_H_ */ diff --git a/calendar/gui/memos-control.c b/calendar/gui/memos-control.c deleted file mode 100644 index 052ac1fb49..0000000000 --- a/calendar/gui/memos-control.c +++ /dev/null @@ -1,353 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Damon Chaplin - * Ettore Perazzoli - * Nathan Owens - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "calendar-config.h" -#include "e-memos.h" -#include "e-memo-table.h" -#include "print.h" -#include "memos-control.h" -#include "evolution-shell-component-utils.h" - -#define FIXED_MARGIN .05 - - -static void memos_control_activate_cb (BonoboControl *control, - gboolean activate, - gpointer user_data); -static void memos_control_open_memo_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path); -static void memos_control_new_memo_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path); -static void memos_control_cut_cmd (BonoboUIComponent *uic, - gpointer data, - const gchar *path); -static void memos_control_copy_cmd (BonoboUIComponent *uic, - gpointer data, - const gchar *path); -static void memos_control_paste_cmd (BonoboUIComponent *uic, - gpointer data, - const gchar *path); -static void memos_control_delete_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path); -static void memos_control_print_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path); -static void memos_control_print_preview_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path); - - - -BonoboControl * -memos_control_new (void) -{ - BonoboControl *control; - GtkWidget *memos; - - memos = e_memos_new (); - if (!memos) - return NULL; - gtk_widget_show (memos); - - control = bonobo_control_new (memos); - if (!control) { - gtk_widget_destroy (memos); - g_message ("control_factory_fn(): could not create the control!"); - return NULL; - } - - g_signal_connect (control, "activate", G_CALLBACK (memos_control_activate_cb), memos); - - return control; -} - - -static void -memos_control_activate_cb (BonoboControl *control, - gboolean activate, - gpointer user_data) -{ - EMemos *memos; - - memos = E_MEMOS (user_data); - - if (activate) - memos_control_activate (control, memos); - else - memos_control_deactivate (control, memos); -} - -/* Sensitizes the UI Component menu/toolbar commands based on the number of - * selected memos. - */ -void -memos_control_sensitize_commands (BonoboControl *control, EMemos *memos, int n_selected) -{ - BonoboUIComponent *uic; - gboolean read_only = TRUE; - ECal *ecal; - ECalModel *model; - - uic = bonobo_control_get_ui_component (control); - g_return_if_fail (uic != NULL); - - if (bonobo_ui_component_get_container (uic) == CORBA_OBJECT_NIL) - return; - - model = e_memo_table_get_model (e_memos_get_calendar_table (memos)); - ecal = e_cal_model_get_default_client (model); - if (ecal) - e_cal_is_read_only (ecal, &read_only, NULL); - - bonobo_ui_component_set_prop (uic, "/commands/MemosOpenMemo", "sensitive", - n_selected != 1 ? "0" : "1", - NULL); - bonobo_ui_component_set_prop (uic, "/commands/MemosCut", "sensitive", - n_selected == 0 || read_only ? "0" : "1", - NULL); - bonobo_ui_component_set_prop (uic, "/commands/MemosCopy", "sensitive", - n_selected == 0 ? "0" : "1", - NULL); - bonobo_ui_component_set_prop (uic, "/commands/MemosPaste", "sensitive", - read_only ? "0" : "1", - NULL); - bonobo_ui_component_set_prop (uic, "/commands/MemosDelete", "sensitive", - n_selected == 0 || read_only ? "0" : "1", - NULL); -} - -/* Callback used when the selection in the table changes */ -static void -selection_changed_cb (EMemos *memos, int n_selected, gpointer data) -{ - BonoboControl *control; - - control = BONOBO_CONTROL (data); - - memos_control_sensitize_commands (control, memos, n_selected); -} - -static BonoboUIVerb verbs [] = { - BONOBO_UI_VERB ("MemosOpenMemo", memos_control_open_memo_cmd), - BONOBO_UI_VERB ("MemosNewMemo", memos_control_new_memo_cmd), - BONOBO_UI_VERB ("MemosCut", memos_control_cut_cmd), - BONOBO_UI_VERB ("MemosCopy", memos_control_copy_cmd), - BONOBO_UI_VERB ("MemosPaste", memos_control_paste_cmd), - BONOBO_UI_VERB ("MemosDelete", memos_control_delete_cmd), - BONOBO_UI_VERB ("MemosPrint", memos_control_print_cmd), - BONOBO_UI_VERB ("MemosPrintPreview", memos_control_print_preview_cmd), - - BONOBO_UI_VERB_END -}; - -void -memos_control_activate (BonoboControl *control, EMemos *memos) -{ - Bonobo_UIContainer remote_uih; - BonoboUIComponent *uic; - int n_selected; - EMemoTable *cal_table; - ETable *etable; - char *xmlfile; - - uic = bonobo_control_get_ui_component (control); - g_return_if_fail (uic != NULL); - - remote_uih = bonobo_control_get_remote_ui_container (control, NULL); - bonobo_ui_component_set_container (uic, remote_uih, NULL); - bonobo_object_release_unref (remote_uih, NULL); - - e_memos_set_ui_component (memos, uic); - - bonobo_ui_component_add_verb_list_with_data (uic, verbs, memos); - - bonobo_ui_component_freeze (uic, NULL); - - xmlfile = g_build_filename (EVOLUTION_UIDIR, - "evolution-memos.xml", - NULL); - bonobo_ui_util_set_ui (uic, PREFIX, - xmlfile, - "evolution-memos", - NULL); - g_free (xmlfile); - - e_memos_setup_view_menus (memos, uic); - - /* Signals from the memos widget; also sensitize the menu items as appropriate */ - - g_signal_connect (memos, "selection_changed", G_CALLBACK (selection_changed_cb), control); - - cal_table = e_memos_get_calendar_table (memos); - etable = e_memo_table_get_table (cal_table); - n_selected = e_table_selected_count (etable); - - memos_control_sensitize_commands (control, memos, n_selected); - - bonobo_ui_component_thaw (uic, NULL); -} - - -void -memos_control_deactivate (BonoboControl *control, EMemos *memos) -{ - BonoboUIComponent *uic = bonobo_control_get_ui_component (control); - - g_return_if_fail (uic != NULL); - - e_memos_set_ui_component (memos, NULL); - - e_memos_discard_view_menus (memos); - - /* Stop monitoring the "selection_changed" signal */ - g_signal_handlers_disconnect_matched (memos, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, control); - - bonobo_ui_component_rm (uic, "/", NULL); - bonobo_ui_component_unset_container (uic, NULL); -} - -static void memos_control_open_memo_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path) -{ - EMemos *memos; - - memos = E_MEMOS (data); - e_memos_open_memo (memos); -} - -static void -memos_control_new_memo_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path) -{ - EMemos *memos; - - memos = E_MEMOS (data); - e_memos_new_memo (memos); -} - -static void -memos_control_cut_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path) -{ - EMemos *memos; - EMemoTable *cal_table; - - memos = E_MEMOS (data); - cal_table = e_memos_get_calendar_table (memos); - e_memo_table_cut_clipboard (cal_table); -} - -static void -memos_control_copy_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path) -{ - EMemos *memos; - EMemoTable *cal_table; - - memos = E_MEMOS (data); - cal_table = e_memos_get_calendar_table (memos); - e_memo_table_copy_clipboard (cal_table); -} - -static void -memos_control_paste_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path) -{ - EMemos *memos; - EMemoTable *cal_table; - - memos = E_MEMOS (data); - cal_table = e_memos_get_calendar_table (memos); - e_memo_table_paste_clipboard (cal_table); -} - -static void -memos_control_delete_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path) -{ - EMemos *memos; - - memos = E_MEMOS (data); - e_memos_delete_selected (memos); -} - -/* File/Print callback */ -static void -memos_control_print_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path) -{ - EMemos *memos = E_MEMOS (data); - ETable *table; - - table = e_memo_table_get_table ( - E_MEMO_TABLE (e_memos_get_calendar_table (memos))); - - print_table ( - table, _("Print Memos"), _("Memos"), - GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG); -} - -static void -memos_control_print_preview_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path) -{ - EMemos *memos = E_MEMOS (data); - ETable *table; - - table = e_memo_table_get_table ( - E_MEMO_TABLE (e_memos_get_calendar_table (memos))); - - print_table ( - table, _("Print Memos"), _("Memos"), - GTK_PRINT_OPERATION_ACTION_PREVIEW); -} diff --git a/calendar/gui/memos-control.h b/calendar/gui/memos-control.h deleted file mode 100644 index 5861ae50e5..0000000000 --- a/calendar/gui/memos-control.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Federico Mena Quintero - * Damon Chaplin - * Nathan Owens - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef _MEMOS_CONTROL_H_ -#define _MEMOS_CONTROL_H_ - -#include "e-memos.h" - -BonoboControl *memos_control_new (void); -void memos_control_activate (BonoboControl *control, EMemos *memos); -void memos_control_deactivate (BonoboControl *control, EMemos *memos); -void memos_control_sensitize_commands (BonoboControl *control, EMemos *memos, int n_selected); - -#endif /* _MEMOS_CONTROL_H_ */ diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c index 92c45baab2..9100183048 100644 --- a/calendar/gui/tasks-component.c +++ b/calendar/gui/tasks-component.c @@ -57,20 +57,9 @@ #define CREATE_TASK_ASSIGNED_ID "task-assigned" #define CREATE_TASK_LIST_ID "task-list" -enum DndTargetType { - DND_TARGET_TYPE_CALENDAR_LIST, -}; -#define CALENDAR_TYPE "text/calendar" -#define XCALENDAR_TYPE "text/x-calendar" #define WEB_BASE_URI "webcal://" #define PERSONAL_RELATIVE_URI "system" -static GtkTargetEntry drag_types[] = { - { CALENDAR_TYPE, 0, DND_TARGET_TYPE_CALENDAR_LIST }, - { XCALENDAR_TYPE, 0, DND_TARGET_TYPE_CALENDAR_LIST } -}; -static gint num_drag_types = sizeof(drag_types) / sizeof(drag_types[0]); - #define PARENT_TYPE bonobo_object_get_type () static BonoboObjectClass *parent_class = NULL; @@ -399,48 +388,6 @@ source_removed_cb (ETasks *tasks, ESource *source, TasksComponentView *component e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector), source); } -static void -set_info (TasksComponentView *component_view) -{ - GString *message = g_string_new (NULL); - int rows, selected_rows; - - rows = e_table_model_row_count (component_view->model); - selected_rows = e_table_selected_count (component_view->table); - - g_string_append_printf(message, ngettext("%d task", "%d tasks", rows), rows); - if (selected_rows > 0) - g_string_append_printf(message, ngettext(", %d selected", ", %d selected", selected_rows), selected_rows); - - e_info_label_set_info (component_view->info_label, _("Tasks"), message->str); - - g_string_free (message, TRUE); -} - -static void -table_selection_change_cb (ETableModel *etm, TasksComponentView *component_view) -{ - set_info (component_view); -} - -static void -model_changed_cb (ETableModel *etm, TasksComponentView *component_view) -{ - set_info (component_view); -} - -static void -model_rows_inserted_cb (ETableModel *etm, int row, int count, TasksComponentView *component_view) -{ - set_info (component_view); -} - -static void -model_rows_deleted_cb (ETableModel *etm, int row, int count, TasksComponentView *component_view) -{ - set_info (component_view); -} - /* Evolution::Component CORBA methods */ static void @@ -466,90 +413,6 @@ impl_upgradeFromVersion (PortableServer_Servant servant, g_error_free(err); } -static gboolean -selector_tree_drag_drop (GtkWidget *widget, - GdkDragContext *context, - int x, - int y, - guint time, - CalendarComponent *component) -{ - GtkTreeViewColumn *column; - int cell_x; - int cell_y; - GtkTreePath *path; - GtkTreeModel *model; - GtkTreeIter iter; - gpointer data; - - if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), x, y, &path, - &column, &cell_x, &cell_y)) - return FALSE; - - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - - if (!gtk_tree_model_get_iter (model, &iter, path)) { - gtk_tree_path_free (path); - return FALSE; - } - - gtk_tree_model_get (model, &iter, 0, &data, -1); - - if (E_IS_SOURCE_GROUP (data)) { - g_object_unref (data); - gtk_tree_path_free (path); - return FALSE; - } - - gtk_tree_path_free (path); - return TRUE; -} - -static gboolean -selector_tree_drag_motion (GtkWidget *widget, - GdkDragContext *context, - int x, - int y, - guint time, - gpointer user_data) -{ - GtkTreePath *path = NULL; - gpointer data = NULL; - GtkTreeViewDropPosition pos; - GtkTreeModel *model; - GtkTreeIter iter; - GdkDragAction action = GDK_ACTION_DEFAULT; - - if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget), - x, y, &path, &pos)) - goto finish; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - - if (!gtk_tree_model_get_iter (model, &iter, path)) - goto finish; - - gtk_tree_model_get (model, &iter, 0, &data, -1); - - if (E_IS_SOURCE_GROUP (data) || e_source_get_readonly (data)) - goto finish; - - gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget), path, GTK_TREE_VIEW_DROP_INTO_OR_BEFORE); - action = context->suggested_action; - if (action == GDK_ACTION_COPY && (context->actions & GDK_ACTION_MOVE)) - action=GDK_ACTION_MOVE; - - finish: - if (path) - gtk_tree_path_free (path); - if (data) - g_object_unref (data); - - gdk_drag_status (context, action, time); - return TRUE; -} - static gboolean update_single_object (ECal *client, icalcomponent *icalcomp) { @@ -731,27 +594,6 @@ selector_tree_drag_data_received (GtkWidget *widget, gtk_drag_finish (context, success, context->action == GDK_ACTION_MOVE, time); } -static void -selector_tree_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time, gpointer data) -{ - gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget), - NULL, GTK_TREE_VIEW_DROP_BEFORE); -} - - -static void -control_activate_cb (BonoboControl *control, gboolean activate, gpointer data) -{ - TasksComponentView *component_view = data; - - if (activate) { - BonoboUIComponent *uic; - uic = bonobo_control_get_ui_component (component_view->view_control); - - e_user_creatable_items_handler_activate (component_view->creatable_items_handler, uic); - } -} - static void config_create_ecal_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) { @@ -940,18 +782,9 @@ create_component_view (TasksComponent *tasks_component) a11y = gtk_widget_get_accessible (GTK_WIDGET (component_view->source_selector)); atk_object_set_name (a11y, _("Task Source Selector")); - g_signal_connect (component_view->source_selector, "drag-motion", G_CALLBACK (selector_tree_drag_motion), - tasks_component); - g_signal_connect (component_view->source_selector, "drag-leave", G_CALLBACK (selector_tree_drag_leave), - tasks_component); - g_signal_connect (component_view->source_selector, "drag-drop", G_CALLBACK (selector_tree_drag_drop), - tasks_component); g_signal_connect (component_view->source_selector, "drag-data-received", G_CALLBACK (selector_tree_drag_data_received), tasks_component); - gtk_drag_dest_set(component_view->source_selector, GTK_DEST_DEFAULT_ALL, drag_types, - num_drag_types, GDK_ACTION_COPY | GDK_ACTION_MOVE); - gtk_widget_show (component_view->source_selector); selector_scrolled_window = gtk_scrolled_window_new (NULL, NULL); @@ -962,10 +795,6 @@ create_component_view (TasksComponent *tasks_component) GTK_SHADOW_IN); gtk_widget_show (selector_scrolled_window); - component_view->info_label = (EInfoLabel *)e_info_label_new("evolution-tasks"); - e_info_label_set_info(component_view->info_label, _("Tasks"), ""); - gtk_widget_show (GTK_WIDGET (component_view->info_label)); - vbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (component_view->info_label), FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX (vbox), selector_scrolled_window, TRUE, TRUE, 0); @@ -1010,21 +839,6 @@ create_component_view (TasksComponent *tasks_component) g_signal_connect (component_view->source_selector, "popup_event", G_CALLBACK (popup_event_cb), component_view); - /* Set up the "new" item handler */ - component_view->creatable_items_handler = e_user_creatable_items_handler_new ("tasks", create_local_item_cb, tasks_component); - g_signal_connect (component_view->view_control, "activate", G_CALLBACK (control_activate_cb), component_view); - - /* We use this to update the component information */ - set_info (component_view); - g_signal_connect (component_view->table, "selection_change", - G_CALLBACK (table_selection_change_cb), component_view); - g_signal_connect (component_view->model, "model_changed", - G_CALLBACK (model_changed_cb), component_view); - g_signal_connect (component_view->model, "model_rows_inserted", - G_CALLBACK (model_rows_inserted_cb), component_view); - g_signal_connect (component_view->model, "model_rows_deleted", - G_CALLBACK (model_rows_deleted_cb), component_view); - /* Load the selection from the last run */ update_selection (component_view); update_primary_selection (component_view); @@ -1290,12 +1104,4 @@ tasks_component_init (TasksComponent *component, TasksComponentClass *klass) component->priv = priv; } -/* Public API */ - -ESourceList * -tasks_component_peek_source_list (TasksComponent *component) -{ - return component->priv->source_list; -} - BONOBO_TYPE_FUNC_FULL (TasksComponent, GNOME_Evolution_Component, PARENT_TYPE, tasks_component) diff --git a/calendar/gui/tasks-component.h b/calendar/gui/tasks-component.h index 8947b3da3e..fc96c5a2a8 100644 --- a/calendar/gui/tasks-component.h +++ b/calendar/gui/tasks-component.h @@ -55,6 +55,4 @@ struct _TasksComponentClass { GType tasks_component_get_type (void); -ESourceList *tasks_component_peek_source_list (TasksComponent *component); - #endif /* _TASKS_COMPONENT_H_ */ diff --git a/shell/e-shell-sidebar.c b/shell/e-shell-sidebar.c index 13385d18b7..b67dc5b5e1 100644 --- a/shell/e-shell-sidebar.c +++ b/shell/e-shell-sidebar.c @@ -405,7 +405,8 @@ e_shell_sidebar_new (EShellView *shell_view) g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); return g_object_new ( - E_TYPE_SHELL_SIDEBAR, "shell-view", shell_view, NULL); + E_TYPE_SHELL_SIDEBAR, + "shell-view", shell_view, NULL); } EShellView * diff --git a/shell/e-shell-sidebar.h b/shell/e-shell-sidebar.h index 498f48c7f4..a6a67a40cc 100644 --- a/shell/e-shell-sidebar.h +++ b/shell/e-shell-sidebar.h @@ -42,8 +42,6 @@ (G_TYPE_INSTANCE_GET_CLASS \ ((obj), E_TYPE_SHELL_SIDEBAR, EShellSidebarClass)) -#define E_SHELL_SIDEBAR_DEFAULT_TOOLBAR_STYLE GTK_TOOLBAR_BOTH_HORIZ - G_BEGIN_DECLS /* Avoid including */ @@ -66,9 +64,6 @@ GType e_shell_sidebar_get_type (void); GtkWidget * e_shell_sidebar_new (struct _EShellView *shell_view); struct _EShellView * e_shell_sidebar_get_shell_view (EShellSidebar *shell_sidebar); -const gchar * e_shell_sidebar_get_icon_name (EShellSidebar *shell_sidebar); -void e_shell_sidebar_set_icon_name (EShellSidebar *shell_sidebar, - const gchar *icon_name); const gchar * e_shell_sidebar_get_primary_text(EShellSidebar *shell_sidebar); void e_shell_sidebar_set_primary_text(EShellSidebar *shell_sidebar, const gchar *primary_text); diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index 5d14834721..15e658cd68 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -41,9 +41,9 @@ struct _EShellViewPrivate { gint page_num; GtkAction *action; - GtkWidget *content; - GtkWidget *sidebar; - GtkWidget *taskbar; + GtkWidget *shell_content; + GtkWidget *shell_sidebar; + GtkWidget *shell_taskbar; GalViewInstance *view_instance; }; @@ -53,6 +53,9 @@ enum { PROP_ACTION, PROP_PAGE_NUM, PROP_TITLE, + PROP_SHELL_CONTENT, + PROP_SHELL_SIDEBAR, + PROP_SHELL_TASKBAR, PROP_SHELL_WINDOW, PROP_VIEW_INSTANCE }; @@ -166,6 +169,24 @@ shell_view_get_property (GObject *object, E_SHELL_VIEW (object))); return; + case PROP_SHELL_CONTENT: + g_value_set_object ( + value, e_shell_view_get_shell_content ( + E_SHELL_VIEW (object))); + return; + + case PROP_SHELL_SIDEBAR: + g_value_set_object ( + value, e_shell_view_get_shell_sidebar ( + E_SHELL_VIEW (object))); + return; + + case PROP_SHELL_TASKBAR: + g_value_set_object ( + value, e_shell_view_get_shell_taskbar ( + E_SHELL_VIEW (object))); + return; + case PROP_SHELL_WINDOW: g_value_set_object ( value, e_shell_view_get_shell_window ( @@ -195,19 +216,19 @@ shell_view_dispose (GObject *object) priv->shell_window = NULL; } - if (priv->content != NULL) { - g_object_unref (priv->content); - priv->content = NULL; + if (priv->shell_content != NULL) { + g_object_unref (priv->shell_content); + priv->shell_content = NULL; } - if (priv->sidebar != NULL) { - g_object_unref (priv->sidebar); - priv->sidebar = NULL; + if (priv->shell_sidebar != NULL) { + g_object_unref (priv->shell_sidebar); + priv->shell_sidebar = NULL; } - if (priv->taskbar != NULL) { - g_object_unref (priv->taskbar); - priv->taskbar = NULL; + if (priv->shell_taskbar != NULL) { + g_object_unref (priv->shell_taskbar); + priv->shell_taskbar = NULL; } if (priv->view_instance != NULL) { @@ -236,27 +257,25 @@ static void shell_view_constructed (GObject *object) { EShellView *shell_view; + EShellViewClass *class; GtkWidget *widget; shell_view = E_SHELL_VIEW (object); + class = E_SHELL_VIEW_GET_CLASS (object); - widget = e_shell_content_new (shell_view); - shell_view->priv->content = g_object_ref_sink (widget); - gtk_widget_show (widget); + /* Invoke factory methods. */ - widget = e_shell_sidebar_new (shell_view); - shell_view->priv->sidebar = g_object_ref_sink (widget); + widget = class->new_shell_content (shell_view); + shell_view->priv->shell_content = g_object_ref_sink (widget); gtk_widget_show (widget); - widget = e_shell_taskbar_new (shell_view); - shell_view->priv->taskbar = g_object_ref_sink (widget); + widget = class->new_shell_sidebar (shell_view); + shell_view->priv->shell_sidebar = g_object_ref_sink (widget); gtk_widget_show (widget); - /* XXX GObjectClass doesn't implement constructed(), so we will. - * Then subclasses won't have to check the function pointer - * before chaining up. - * - * http://bugzilla.gnome.org/show_bug?id=546593 */ + widget = class->new_shell_taskbar (shell_view); + shell_view->priv->shell_taskbar = g_object_ref_sink (widget); + gtk_widget_show (widget); } static void @@ -274,6 +293,11 @@ shell_view_class_init (EShellViewClass *class) object_class->finalize = shell_view_finalize; object_class->constructed = shell_view_constructed; + /* Default Factories */ + class->new_shell_content = e_shell_content_new; + class->new_shell_sidebar = e_shell_sidebar_new; + class->new_shell_taskbar = e_shell_taskbar_new; + g_object_class_install_property ( object_class, PROP_ACTION, @@ -308,6 +332,39 @@ shell_view_class_init (EShellViewClass *class) NULL, G_PARAM_READWRITE)); + g_object_class_install_property ( + object_class, + PROP_SHELL_CONTENT, + g_param_spec_object ( + "shell-content", + _("Shell Content Widget"), + _("The content widget appears in " + "a shell window's right pane"), + E_TYPE_SHELL_CONTENT, + G_PARAM_READABLE)); + + g_object_class_install_property ( + object_class, + PROP_SHELL_SIDEBAR, + g_param_spec_object ( + "shell-sidebar", + _("Shell Sidebar Widget"), + _("The sidebar widget appears in " + "a shell window's left pane"), + E_TYPE_SHELL_SIDEBAR, + G_PARAM_READABLE)); + + g_object_class_install_property ( + object_class, + PROP_SHELL_TASKBAR, + g_param_spec_object ( + "shell-taskbar", + _("Shell Taskbar Widget"), + _("The taskbar widget appears at " + "the bottom of a shell window"), + E_TYPE_SHELL_TASKBAR, + G_PARAM_READABLE)); + g_object_class_install_property ( object_class, PROP_SHELL_WINDOW, @@ -379,11 +436,10 @@ e_shell_view_get_name (EShellView *shell_view) g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - /* Switcher actions have a secret "view-name" data value. - * This gets set in e_shell_window_create_switcher_actions(). */ - action = e_shell_view_get_action (shell_view); + /* Switcher actions have a secret "view-name" data value. + * This gets set in e_shell_window_create_switcher_actions(). */ return g_object_get_data (G_OBJECT (action), "view-name"); } @@ -482,27 +538,27 @@ e_shell_view_get_page_num (EShellView *shell_view) } EShellContent * -e_shell_view_get_content (EShellView *shell_view) +e_shell_view_get_shell_content (EShellView *shell_view) { g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - return E_SHELL_CONTENT (shell_view->priv->content); + return E_SHELL_CONTENT (shell_view->priv->shell_content); } EShellSidebar * -e_shell_view_get_sidebar (EShellView *shell_view) +e_shell_view_get_shell_sidebar (EShellView *shell_view) { g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - return E_SHELL_SIDEBAR (shell_view->priv->sidebar); + return E_SHELL_SIDEBAR (shell_view->priv->shell_sidebar); } EShellTaskbar * -e_shell_view_get_taskbar (EShellView *shell_view) +e_shell_view_get_shell_taskbar (EShellView *shell_view) { g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - return E_SHELL_TASKBAR (shell_view->priv->taskbar); + return E_SHELL_TASKBAR (shell_view->priv->shell_taskbar); } void diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h index 34f2625e22..a30abf5e6c 100644 --- a/shell/e-shell-view.h +++ b/shell/e-shell-view.h @@ -72,6 +72,11 @@ struct _EShellViewClass { * the GTypeInfo they pass to g_type_module_register_type(). */ GTypeModule *type_module; + /* Factory Methods */ + GtkWidget * (*new_shell_content) (EShellView *shell_view); + GtkWidget * (*new_shell_sidebar) (EShellView *shell_view); + GtkWidget * (*new_shell_taskbar) (EShellView *shell_view); + /* Signals */ void (*changed) (EShellView *shell_view); }; @@ -86,12 +91,12 @@ GalViewInstance * e_shell_view_get_view_instance (EShellView *shell_view); void e_shell_view_set_view_instance (EShellView *shell_view, GalViewInstance *instance); -EShellWindow * e_shell_view_get_shell_window (EShellView *shell_view); gboolean e_shell_view_is_selected (EShellView *shell_view); gint e_shell_view_get_page_num (EShellView *shell_view); -EShellContent * e_shell_view_get_content (EShellView *shell_view); -EShellSidebar * e_shell_view_get_sidebar (EShellView *shell_view); -EShellTaskbar * e_shell_view_get_taskbar (EShellView *shell_view); +EShellContent * e_shell_view_get_shell_content (EShellView *shell_view); +EShellSidebar * e_shell_view_get_shell_sidebar (EShellView *shell_view); +EShellTaskbar * e_shell_view_get_shell_taskbar (EShellView *shell_view); +EShellWindow * e_shell_view_get_shell_window (EShellView *shell_view); void e_shell_view_changed (EShellView *shell_view); G_END_DECLS diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c index 090bee4025..917c6fce3b 100644 --- a/shell/e-shell-window-actions.c +++ b/shell/e-shell-window-actions.c @@ -871,7 +871,7 @@ action_search_clear_cb (GtkAction *action, view_name = e_shell_window_get_current_view (shell_window); shell_view = e_shell_window_get_view (shell_window, view_name); - shell_content = e_shell_view_get_content (shell_view); + shell_content = e_shell_view_get_shell_content (shell_view); e_shell_content_set_search_text (shell_content, ""); } @@ -888,7 +888,7 @@ action_search_edit_cb (GtkAction *action, view_name = e_shell_window_get_current_view (shell_window); shell_view = e_shell_window_get_view (shell_window, view_name); - shell_content = e_shell_view_get_content (shell_view); + shell_content = e_shell_view_get_shell_content (shell_view); context = e_shell_content_get_search_context (shell_content); g_return_if_fail (context != NULL); diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index 78c6a31836..b1a7e4b6b1 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -73,15 +73,15 @@ shell_window_new_view (EShellWindow *shell_window, /* Add pages to the various shell window notebooks. */ notebook = GTK_NOTEBOOK (shell_window->priv->content_notebook); - widget = GTK_WIDGET (e_shell_view_get_content (shell_view)); + widget = GTK_WIDGET (e_shell_view_get_shell_content (shell_view)); gtk_notebook_append_page (notebook, widget, NULL); notebook = GTK_NOTEBOOK (shell_window->priv->sidebar_notebook); - widget = GTK_WIDGET (e_shell_view_get_sidebar (shell_view)); + widget = GTK_WIDGET (e_shell_view_get_shell_sidebar (shell_view)); gtk_notebook_append_page (notebook, widget, NULL); notebook = GTK_NOTEBOOK (shell_window->priv->status_notebook); - widget = GTK_WIDGET (e_shell_view_get_taskbar (shell_view)); + widget = GTK_WIDGET (e_shell_view_get_shell_taskbar (shell_view)); gtk_notebook_append_page (notebook, widget, NULL); /* Listen for changes that affect the shell window. */ -- cgit v1.2.3