From bd9f473a896496b95b9896d30940f2ab27493432 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 23 Jan 2009 21:41:01 +0000 Subject: Redesign EPluginUI to accommodate merging and unmerging shell views. Get the "mark-all-read" and "plugin-manager" plugins working. svn path=/branches/kill-bonobo/; revision=37125 --- widgets/menus/gal-view-instance.c | 141 -------------------------------------- 1 file changed, 141 deletions(-) (limited to 'widgets/menus/gal-view-instance.c') diff --git a/widgets/menus/gal-view-instance.c b/widgets/menus/gal-view-instance.c index a1eac04b6c..19ec402fa3 100644 --- a/widgets/menus/gal-view-instance.c +++ b/widgets/menus/gal-view-instance.c @@ -46,10 +46,6 @@ G_DEFINE_TYPE (GalViewInstance, gal_view_instance, G_TYPE_OBJECT) -static const EPopupMenu separator = E_POPUP_SEPARATOR; -static const EPopupMenu terminator = E_POPUP_TERMINATOR; - - #define d(x) enum { @@ -467,140 +463,3 @@ gal_view_instance_exists (GalViewInstance *instance) return FALSE; } - -typedef struct { - GalViewInstance *instance; - char *id; -} ListenerClosure; - -static void -view_item_cb (GtkWidget *widget, - gpointer user_data) -{ - ListenerClosure *closure = user_data; - - if (GTK_CHECK_MENU_ITEM (widget)->active) { - gal_view_instance_set_current_view_id (closure->instance, closure->id); - } -} - -static void -add_popup_radio_item (EPopupMenu *menu_item, - gchar *title, - GCallback fn, - gpointer closure, - gboolean value) -{ - EPopupMenu menu_item_struct = - E_POPUP_RADIO_ITEM_CC (title, - fn, - closure, - 0, - 0); - menu_item_struct.is_active = value; - - e_popup_menu_copy_1 (menu_item, &menu_item_struct); -} - -static void -add_popup_menu_item (EPopupMenu *menu_item, - gchar *title, - GCallback fn, - gpointer closure) -{ - EPopupMenu menu_item_struct = - E_POPUP_ITEM_CC (title, - fn, - closure, - 0); - - e_popup_menu_copy_1 (menu_item, &menu_item_struct); -} - -static void -define_views_dialog_response(GtkWidget *dialog, int id, GalViewInstance *instance) -{ - if (id == GTK_RESPONSE_OK) { - gal_view_collection_save(instance->collection); - } - gtk_widget_destroy (dialog); -} - -static void -define_views_cb(GtkWidget *widget, - GalViewInstance *instance) -{ - GtkWidget *dialog = gal_define_views_dialog_new(instance->collection); - g_signal_connect(dialog, "response", - G_CALLBACK(define_views_dialog_response), instance); - gtk_widget_show(dialog); -} - -static void -save_current_view_cb(GtkWidget *widget, - GalViewInstance *instance) -{ - gal_view_instance_save_as (instance); -} - -EPopupMenu * -gal_view_instance_get_popup_menu (GalViewInstance *instance) -{ - EPopupMenu *ret_val; - int length; - int i; - gboolean found = FALSE; - char *id; - - length = gal_view_collection_get_count(instance->collection); - id = gal_view_instance_get_current_view_id (instance); - - ret_val = g_new (EPopupMenu, length + 6); - - for (i = 0; i < length; i++) { - gboolean value = FALSE; - GalViewCollectionItem *item = gal_view_collection_get_view_item(instance->collection, i); - ListenerClosure *closure; - - closure = g_new (ListenerClosure, 1); - closure->instance = instance; - closure->id = item->id; - g_object_ref (closure->instance); - - if (!found && id && !strcmp (id, item->id)) { - found = TRUE; - value = TRUE; - } - - add_popup_radio_item (ret_val + i, item->title, G_CALLBACK (view_item_cb), closure, value); - } - - if (!found) { - e_popup_menu_copy_1 (ret_val + i++, &separator); - - add_popup_radio_item (ret_val + i++, N_("Custom View"), NULL, NULL, TRUE); - add_popup_menu_item (ret_val + i++, N_("Save Custom View"), G_CALLBACK (save_current_view_cb), instance); - } - - e_popup_menu_copy_1 (ret_val + i++, &separator); - add_popup_menu_item (ret_val + i++, N_("Define Views..."), G_CALLBACK (define_views_cb), instance); - e_popup_menu_copy_1 (ret_val + i++, &terminator); - - if (id) - g_free (id); - - return ret_val; -} - -void -gal_view_instance_free_popup_menu (GalViewInstance *instance, EPopupMenu *menu) -{ - int i; - /* This depends on the first non-custom closure to be a separator or a terminator. */ - for (i = 0; menu[i].name && *(menu[i].name); i++) { - g_object_unref (((ListenerClosure *)(menu[i].closure))->instance); - g_free (menu[i].closure); - } - - e_popup_menu_free (menu); -} -- cgit v1.2.3