/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * gal-view-menus.c: Deploy a GalViewCollection in the menus. * * Author: * Chris Lahey * * (C) 2000, 2001 Ximian, Inc. */ #include #include "gal-view-menus.h" #include #include #include #include #include #include #include #include #include #include #include struct _GalViewMenusPrivate { GalViewCollection *collection; int collection_changed_id; BonoboUIVerb *verbs; BonoboUIComponent *component; EList *listenerClosures; }; typedef struct { GalViewCollection *collection; GalView *view; const char *id; } ListenerClosure; #define PARENT_TYPE (gtk_object_get_type()) static GtkObjectClass *gvm_parent_class; static void collection_changed (GalViewCollection *collection, GalViewMenus *gvm); #define d(x) static void free_verbs (GalViewMenus *gvm) { if (gvm->priv->verbs) { g_free(gvm->priv->verbs->cname); g_free(gvm->priv->verbs); } gvm->priv->verbs = NULL; } static void closure_free (void *data, void *user_data) { ListenerClosure *closure = data; GalViewMenus *gvm = user_data; gtk_object_ref(GTK_OBJECT(closure->view)); gtk_object_ref(GTK_OBJECT(closure->collection)); bonobo_ui_component_remove_listener (gvm->priv->component, closure->id); g_free (closure); } static void remove_listeners (GalViewMenus *gvm) { if (gvm->priv->listenerClosures) { gtk_object_unref (GTK_OBJECT(gvm->priv->listenerClosures)); } gvm->priv->listenerClosures = NULL; } static void remove_xml (GalViewMenus *gvm) { } static void gvm_destroy (GtkObject *object) { GalViewMenus *gvm = GAL_VIEW_MENUS (object); if (gvm->priv->collection && gvm->priv->collection_changed_id != 0) { gtk_signal_disconnect(GTK_OBJECT(gvm->priv->collection), gvm->priv->collection_changed_id); gvm->priv->collection_changed_id = 0; } if (gvm->priv->collection) gtk_object_unref(GTK_OBJECT(gvm->priv->collection)); free_verbs(gvm); remove_xml(gvm); remove_listeners(gvm); g_free(gvm->priv); gvm->priv = NULL; GTK_OBJECT_CLASS (gvm_parent_class)->destroy (object); } static void gvm_class_init (GtkObjectClass *klass) { gvm_parent_class = gtk_type_class (PARENT_TYPE); klass->destroy = gvm_destroy; } static void gvm_init (GalViewMenus *gvm) { gvm->priv = g_new(GalViewMenusPrivate, 1); gvm->priv->collection = NULL; gvm->priv->collection_changed_id = 0; gvm->priv->verbs = NULL; gvm->priv->component = NULL; gvm->priv->listenerClosures = NULL; } E_MAKE_TYPE(gal_view_menus, "GalViewMenus", GalViewMenus, gvm_class_init, gvm_init, PARENT_TYPE); GalViewMenus * gal_view_menus_new (GalViewCollection *collection) { GalViewMenus *gvm; g_return_val_if_fail (collection != NULL, NULL); g_return_val_if_fail (GAL_IS_VIEW_COLLECTION (collection), NULL); gvm = gtk_type_new (GAL_VIEW_MENUS_TYPE); gal_view_menus_construct(gvm, collection); return gvm; } GalViewMenus * gal_view_menus_construct (GalViewMenus *gvm, GalViewCollection *collection) { g_return_val_if_fail (gvm != NULL, NULL); g_return_val_if_fail (GAL_IS_VIEW_MENUS (gvm), NULL); g_return_val_if_fail (collection != NULL, NULL); g_return_val_if_fail (GAL_IS_VIEW_COLLECTION (collection), NULL); gtk_object_ref(GTK_OBJECT(collection)); gvm->priv->collection = collection; gvm->priv->collection_changed_id = gtk_signal_connect ( GTK_OBJECT(collection), "changed", GTK_SIGNAL_FUNC(collection_changed), gvm); return gvm; } static void dialog_clicked(GtkWidget *dialog, int button, GalViewMenus *menus) { if (button == 0) { gal_view_collection_save(menus->priv->collection); } gnome_dialog_close(GNOME_DIALOG(dialog)); } static void define_views(BonoboUIComponent *component, GalViewMenus *menus, char *cname) { GtkWidget *dialog = gal_define_views_dialog_new(menus->priv->collection); gtk_signal_connect(GTK_OBJECT(dialog), "clicked", GTK_SIGNAL_FUNC(dialog_clicked), menus); gtk_widget_show(dialog); } static void toggled_cb (BonoboUIComponent *component, const char *path, Bonobo_UIComponent_EventType type, const char *state, gpointer user_data) { ListenerClosure *closure = user_data; /* do nothing on state change to untoggled */ if (!strcmp (state, "0")) return; gal_view_collection_display_view(closure->collection, closure->view); } static char * build_menus(GalViewMenus *menus) { BonoboUINode *root, *menu, *submenu, *place, *menuitem; char *xml; xmlChar *string; int length; int i; GalViewCollection *collection = menus->priv->collection; root = bonobo_ui_node_new("Root"); menu = bonobo_ui_node_new_child(root, "menu"); submenu = bonobo_ui_node_new_child(menu, "submenu"); bonobo_ui_node_set_attr(submenu, "name", "View"); place = bonobo_ui_node_new_child(submenu, "placeholder"); bonobo_ui_node_set_attr(place, "name", "ViewBegin"); submenu = bonobo_ui_node_new_child(place, "submenu"); bonobo_ui_node_set_attr(submenu, "name", "CurrentView"); bonobo_ui_node_set_attr(submenu, "_label", N_("_Current View")); length = gal_view_collection_get_count(collection); menus->priv->listenerClosures = e_list_new (NULL, closure_free, menus); for (i = 0; i < length; i++) { char *label; GalViewCollectionItem *item = gal_view_collection_get_view_item(collection, i); ListenerClosure *closure; menuitem = bonobo_ui_node_new_child(submenu, "menuitem"); bonobo_ui_node_set_attr(menuitem, "name", item->id); bonobo_ui_node_set_attr(menuitem, "id", item->id); bonobo_ui_node_set_attr(menuitem, "group", "GalViewMenus"); bonobo_ui_node_set_attr(menuitem, "type", "radio"); /* bonobo displays this string so it must be in locale */ label = e_utf8_to_locale_string(item->title); /* All labels are bonobo_ui_util_decode_str()ed, * so even translated label must be set with _label */ bonobo_ui_node_set_attr(menuitem, "_label", label); g_free(label); closure = g_new (ListenerClosure, 1); closure->collection = collection; closure->view = item->view; closure->id = item->id; gtk_object_ref(GTK_OBJECT(closure->view)); gtk_object_ref(GTK_OBJECT(closure->collection)); bonobo_ui_component_add_listener (menus->priv->component, item->id, toggled_cb, closure); e_list_append (menus->priv->listenerClosures, closure); } menuitem = bonobo_ui_node_new_child(submenu, "separator"); menuitem = bonobo_ui_node_new_child(submenu, "menuitem"); bonobo_ui_node_set_attr(menuitem, "name", "DefineViews"); bonobo_ui_node_set_attr(menuitem, "_label", N_("Define Views")); bonobo_ui_node_set_attr(menuitem, "verb", "DefineViews"); string = bonobo_ui_node_to_string(root, TRUE); xml = g_strdup(string); bonobo_ui_node_free_string(string); bonobo_ui_node_free(root); d(g_print (xml)); return xml; } static BonoboUIVerb * build_verbs (GalViewMenus *menus) { BonoboUIVerb *verbs = g_new(BonoboUIVerb, 2); BonoboUIVerb *verb; verb = verbs; verb->cname = g_strdup("DefineViews"); verb->cb = (BonoboUIVerbFn) define_views; verb->user_data = menus; verb->dummy = NULL; verb ++; verb->cname = NULL; verb->cb = NULL; verb->user_data = NULL; verb->dummy = NULL; verb++; return verbs; } static void build_stuff (GalViewMenus *gvm, CORBA_Environment *ev) { char *xml; remove_xml(gvm); remove_listeners(gvm); xml = build_menus(gvm); bonobo_ui_component_set_translate(gvm->priv->component, "/", xml, ev); g_free(xml); free_verbs(gvm); gvm->priv->verbs = build_verbs(gvm); bonobo_ui_component_add_verb_list(gvm->priv->component, gvm->priv->verbs); } void gal_view_menus_apply (GalViewMenus *gvm, BonoboUIComponent *component, CORBA_Environment *ev) { gvm->priv->component = component; build_stuff (gvm, ev); } static void collection_changed (GalViewCollection *collection, GalViewMenus *gvm) { CORBA_Environment ev; CORBA_exception_init (&ev); build_stuff(gvm, &ev); CORBA_exception_free (&ev); } sertions'>+74 * font.png: Add for the font config prefs.Larry Ewing2002-04-262-0/+5 * Updated this for the new e_table_memory_store_insert function prototype.Christopher James Lahey2002-04-252-20/+13 * Allow providers to override text entry boxes too. (source_type_changed):Jeffrey Stedfast2002-04-252-31/+57 * Configure the default paths for mh, mbox, maildir, spools, etc.Jeffrey Stedfast2002-04-253-16/+62 * Changed this to match the new e_table_memory_store_insert functionChristopher James Lahey2002-04-251-1/+1 * Update to use E_POPUP_MENU_PIXMAP_WIDGET_ITEM_CC so that our callback getsJeffrey Stedfast2002-04-252-6/+11 * implement printing (pixbuf_print_height): implement print heightJP Rosevear2002-04-253-18/+53 * Set the default Username label and handle the newJeffrey Stedfast2002-04-252-6/+28 * Add a CAMEL_PROVIDER_CONF_LABEL enum.Jeffrey Stedfast2002-04-252-6/+11 * Added a "Browse..." button to switch to a different addressbook folder.Christopher James Lahey2002-04-255-17/+112 * launch pilot settings cappletJP Rosevear2002-04-243-0/+65 * free the view popup (e_week_view_show_popup_menu): add the view popup toJP Rosevear2002-04-247-30/+112 * Added back the checkmark icon for enabled accounts.Jeffrey Stedfast2002-04-243-7/+34 * Coded handling of the select_entry to search within the displayedChristopher James Lahey2002-04-244-68/+99 * Updated this dialog to match the redesign.Christopher James Lahey2002-04-242-205/+264 * Make unused menu items disappear instead of graying out.Christopher James Lahey2002-04-242-1/+34 * Removed e_addressbook_reflow_adapter_right_click andChristopher James Lahey2002-04-248-691/+474 * Re-added libversit stuff.Sebastian Rittau2002-04-2411-0/+4935 * Moved libversit to a separate module.Sebastian Rittau2002-04-2412-4945/+0 * Plug-in Anna's html for the flag-for-followup stuff. Finishes up bug #90.Jeffrey Stedfast2002-04-232-15/+34 * Updated this to match the changed function name in gal.Christopher James Lahey2002-04-232-2/+7 * Removed an unused variable here.Christopher James Lahey2002-04-233-2/+25 * Require gal 0.19.99.14.Christopher James Lahey2002-04-232-1/+5 * Bumped version number to 0.19.99.14.Christopher James Lahey2002-04-236-31/+254 * Allow GDK_ACTION_COPY also, since the composer for example does not acceptJeffrey Stedfast2002-04-232-2/+8 * use gpg --import, as per bug 23113Aaron Weber2002-04-232-1/+10 * Allow IMAP folders and VFolders and make the mail summaries show and make the...Iain Holmes2002-04-238-54/+153 * Just sorting out formatting and changelog-conflict issues.Aaron Weber2002-04-221-3/+0 * raise an exception if the backend's method returns NULL, since we can'tRodrigo Moya2002-04-222-0/+11 * Removed addressbook/gui/component/addressbook-config.[c,glade] and addedJeffrey Stedfast2002-04-202-2/+8 * Don't leak the base64 encoded password buffer.Jeffrey Stedfast2002-04-202-11/+19 * Free the LIST pop3 command.Jeffrey Stedfast2002-04-203-2/+11 * Unref the sort_info.Jeffrey Stedfast2002-04-201-0/+5 * After unreffing all the pixmaps, free the toggle_view->pixmap_cache.Jeffrey Stedfast2002-04-201-0/+1 * Free the priv->search_string and priv itself. More memory leak fixage.Jeffrey Stedfast2002-04-202-0/+9 * Free the loading/pending/new/loaded_uid string buffers.Jeffrey Stedfast2002-04-202-2/+10 * Free some temporary path buffers.Jeffrey Stedfast2002-04-202-8/+13 * Ref the html object here, this is an async handler so it's possible forJeffrey Stedfast2002-04-202-1/+22 * Added yet more accelerators for the new config dialog--this time for theAnna Marie Dirks2002-04-202-13/+22 * would help if I didn't name 2 widgets the same for the colour tab in the pref...Jeffrey Stedfast2002-04-201-2/+2 * Collapsed notebook into two pages and added accelerators for everything,Anna Marie Dirks2002-04-202-354/+332 * Don't g_return_val_if_fail here if the boundary is an empty string. SeeJeffrey Stedfast2002-04-202-3/+16 * Added a bunch of accelerators for the new config dialogAnna Marie Dirks2002-04-202-109/+125 * more cs translationsRadek Doulik2002-04-201-589/+594 * print the cell in the allotted area (etog_print_height): return the printJP Rosevear2002-04-201-0/+57 * Minor label tweaks; changed "Default folders" to "Default Folders", andAnna Marie Dirks2002-04-192-5/+10 * change order of scope option menu to match how it's stored.Chris Toshok2002-04-192-2/+7 * change ldap config control text so it fits in the config dialog.Chris Toshok2002-04-193-23/+105 * add LDAP_CFLAGS to INCLUDESChris Toshok2002-04-192-0/+5 * Start of a white-paperish document describing camel-index and olderNot Zed2002-04-192-0/+412 * no more source->type.Chris Toshok2002-04-192-1/+6 * fill in source->ssl. (addressbook_source_dialog_set_source): set upChris Toshok2002-04-195-47/+74 * properly handle -ve recurrence valuesJP Rosevear2002-04-192-67/+273 * Removed all Delivered-To headers before redirecting. Fixes bug #23635.Jeffrey Stedfast2002-04-192-0/+11 * fix memory leaks.Chris Toshok2002-04-1913-1848/+7606 * Append /addressbook.db to the end of the default URI if it starts withDan Winship2002-04-193-3/+19 * use default paper name in case of wrong translationRadek Doulik2002-04-192-1/+10 * The score "is" rule should have a value of "is" and not "less-than".Jeffrey Stedfast2002-04-192-1/+6 * show the settingsJP Rosevear2002-04-196-6/+90 * emit show_settings signal (corba_class_init): assign epv methodJP Rosevear2002-04-199-12/+136 * handle toggle and radio items (make_item): the item is now passed in fromJP Rosevear2002-04-181-17/+26 * begin of cs translationRadek Doulik2002-04-181-126/+138 * If we get a failure, make sure we set an exception.Not Zed2002-04-183-10/+24 * Turn off the code which downloads the part if we can't identify it. SeeNot Zed2002-04-182-0/+10 * Require GAL 0.19.99.13.Ettore Perazzoli2002-04-182-1/+5 * New, override for EShortcutBar::shortcut_drag_motion.Ettore Perazzoli2002-04-182-11/+83 * When doing a contains match, split the words and perform an and on it.Not Zed2002-04-187-95/+469 * If the vee-folder is the unmatched, we don't have our own expression so weJeffrey Stedfast2002-04-182-3/+14 * Bumped required gal version number to 0.19.99.12.Christopher James Lahey2002-04-182-1/+5 * Bumped required gal version number to 0.19.99.11.Christopher James Lahey2002-04-1816-225/+205 * Replace with an antialiased versionDan Winship2002-04-182-0/+4 * Bumped version number to 0.19.99.11.Christopher James Lahey2002-04-183-22/+67 * Handle broken multipart/signed parts such as where the signature part isJeffrey Stedfast2002-04-182-9/+0 * Handle broken multipart/signed parts such as where the signature part isJeffrey Stedfast2002-04-183-16/+57 * Just use g_basename. (mlf_finalize): Free the real_path.Jeffrey Stedfast2002-04-183-6/+14 * If there is a grabbed_item, send all events to it.Christopher James Lahey2002-04-181-22/+20 * Removed. (impl_tree_drag_motion): Rewritten to useEttore Perazzoli2002-04-175-321/+529 * reverted last change commited by mistakeRadek Doulik2002-04-171-31/+0 * untranslated cs.poRadek Doulik2002-04-172-0/+25848 * added cs to ALL_LINGUASRadek Doulik2002-04-171-1/+1 * Free the format string.Jeffrey Stedfast2002-04-174-2/+15 * Unref the priv->tooltips object here.Jeffrey Stedfast2002-04-17