diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | calendar/ChangeLog | 10 | ||||
-rw-r--r-- | calendar/gui/dialogs/comp-editor.c | 70 | ||||
-rw-r--r-- | composer/ChangeLog | 12 | ||||
-rw-r--r-- | composer/e-composer-actions.c | 4 | ||||
-rw-r--r-- | composer/e-composer-private.c | 38 | ||||
-rw-r--r-- | composer/evolution-composer.ui | 1 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | ui/ChangeLog | 7 | ||||
-rw-r--r-- | ui/evolution-editor.xml | 1 | ||||
-rw-r--r-- | widgets/misc/ChangeLog | 12 | ||||
-rw-r--r-- | widgets/misc/e-attachment-bar.c | 159 | ||||
-rw-r--r-- | widgets/misc/e-attachment-bar.h | 11 |
13 files changed, 311 insertions, 22 deletions
@@ -1,3 +1,7 @@ +2008-04-11 Suman Manjunath <msuman@novell.com> + + * configure.in: Bump glib package requirement: glib-2.0 >= 2.16.0 + 2008-04-05 Matthew Barnes <mbarnes@redhat.com> ** Fixes part of bug #526152 @@ -85,7 +89,7 @@ 2008-02-18 Akhil Laddha <lakhil@novell.com> - ** Fix for bug #517129 + ** Fix for bug #517129 * configure.in: Fix build break of pl translation. diff --git a/calendar/ChangeLog b/calendar/ChangeLog index fd7e79f3d7..cbd1b88f75 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,13 @@ +2008-04-11 Suman Manjunath <msuman@novell.com> + + ** Fix for bug #517134 + + * gui/dialogs/comp-editor.c: (add_to_bar), + (menu_insert_attachment_cb), (menu_insert_attach_recent_docs_cb), + (comp_editor_init): Code re-factoring. Extend the 'Insert' menu to + show a "Recent Documents" submenu (to quickly add them as + attachments). New callback to handle these actions. + 2008-04-07 Ondrej Jirman <megous@megous.com> ** Fix for bug #525234 diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index a5b2232a0b..f1308365cf 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -1432,35 +1432,70 @@ menu_edit_cut_cb (BonoboUIComponent *uic, } static void +add_to_bar (CompEditor *editor, GPtrArray *file_list, int is_inline) +{ + CompEditorPrivate *priv = editor->priv; + int i; + + for (i = 0; i < file_list->len; i++) { + CamelURL *url; + + if (!(url = camel_url_new (file_list->pdata[i], NULL))) + continue; + + if (!g_ascii_strcasecmp (url->protocol, "file")) { + e_attachment_bar_attach((EAttachmentBar *)priv->attachment_bar, url->path, is_inline ? "inline" : "attachment"); + } else { + e_attachment_bar_attach_remote_file ((EAttachmentBar *)priv->attachment_bar, file_list->pdata[i], is_inline ? "inline" : "attachment"); + } + + camel_url_free (url); + } +} + +static void menu_insert_attachment_cb (BonoboUIComponent *uic, void *data, const char *path) { CompEditor *editor = (CompEditor *) data; - EAttachmentBar *bar = (EAttachmentBar *)editor->priv->attachment_bar; GPtrArray *file_list; gboolean is_inline = FALSE; int i; file_list = comp_editor_select_file_attachments (editor, &is_inline); - /*TODO add a good implementation here */ - if (!file_list) - return; - for (i = 0; i < file_list->len; i++) { - CamelURL *url; - url = camel_url_new (file_list->pdata[i], NULL); - if (url == NULL) - continue; + if (file_list) { + add_to_bar (editor, file_list, is_inline); - if (!g_ascii_strcasecmp (url->protocol, "file")) - e_attachment_bar_attach (bar, url->path, is_inline ? "inline" : "attachment"); - else - e_attachment_bar_attach_remote_file (bar, file_list->pdata[i], is_inline ? "inline" : "attachment"); - g_free (file_list->pdata[i]); - camel_url_free (url); + for (i = 0; i < file_list->len; i++) + g_free (file_list->pdata[i]); + + g_ptr_array_free (file_list, TRUE); } +} + +static void +menu_insert_attach_recent_docs_cb (BonoboUIComponent *uic, + gpointer user_data, + const char *cname) +{ + CompEditor *editor = (CompEditor *) user_data; + gchar *command = NULL, *uri = NULL; + GPtrArray *file_list = g_ptr_array_new (); + int i; + command = g_strdup_printf ("/commands/%s", cname); + uri = bonobo_ui_component_get_prop (editor->uic, command, "uri", NULL); + g_free (command); + + if (uri && *uri) { + g_ptr_array_add (file_list, uri); + add_to_bar (editor, file_list, FALSE); + } + + for (i = 0; i < file_list->len; i++) + g_free (file_list->pdata[i]); g_ptr_array_free (file_list, TRUE); } @@ -1636,6 +1671,11 @@ comp_editor_init (CompEditor *editor) bonobo_ui_component_set_prop (editor->uic, "/commands/FileSave", "sensitive", "0", NULL); + /* FIXME: this should have been setup_widgets, but editor->uic is uninitialized then */ + e_attachment_bar_bonobo_ui_populate_with_recent (editor->uic, "/menu/Insert/RecentDocsPlaceholder", + E_ATTACHMENT_BAR (priv->attachment_bar), + menu_insert_attach_recent_docs_cb, editor); + /* DND support */ gtk_drag_dest_set (GTK_WIDGET (editor), GTK_DEST_DEFAULT_ALL, drop_types, num_drop_types, GDK_ACTION_COPY|GDK_ACTION_ASK|GDK_ACTION_MOVE); g_signal_connect(editor, "drag_data_received", G_CALLBACK (drag_data_received), NULL); diff --git a/composer/ChangeLog b/composer/ChangeLog index 5fccf25965..2a3d303a97 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,15 @@ +2008-04-11 Suman Manjunath <msuman@novell.com> + + ** Fix for bug #517134 + + * e-composer-actions.c: (action_attach_cb): Save some CPU cycles. + * e-composer-private.c: (composer_setup_charset_menu), + (composer_setup_recent_menu), (e_composer_private_init): Extend the + 'Insert' menu to show a "Recent Documents" submenu (to quickly add + them as attachments). + * evolution-composer.ui: Added a placeholder to dock the "Recent + Documents" menu. + 2008-04-08 Matthew Barnes <mbarnes@redhat.com> ** Fixes bug #523413 diff --git a/composer/e-composer-actions.c b/composer/e-composer-actions.c index ecf7e84346..33a865c5e6 100644 --- a/composer/e-composer-actions.c +++ b/composer/e-composer-actions.c @@ -36,6 +36,7 @@ action_attach_cb (GtkAction *action, GtkWidget *dialog; GtkWidget *option; GSList *uris, *iter; + const gchar *disposition; gboolean active; gint response; @@ -72,16 +73,15 @@ action_attach_cb (GtkAction *action, uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (dialog)); active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (option)); + disposition = active ? "inline" : "attachment"; for (iter = uris; iter != NULL; iter = iter->next) { - const gchar *disposition; CamelURL *url; url = camel_url_new (iter->data, NULL); if (url == NULL) continue; - disposition = active ? "inline" : "attachment"; if (!g_ascii_strcasecmp (url->protocol, "file")) e_attachment_bar_attach (bar, url->path, disposition); else diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c index f5e3e08c68..55c1a824e9 100644 --- a/composer/e-composer-private.c +++ b/composer/e-composer-private.c @@ -43,6 +43,38 @@ composer_setup_charset_menu (EMsgComposer *composer) list = g_list_delete_link (list, list); } + + gtk_ui_manager_ensure_update (manager); +} + +static void +composer_setup_recent_menu (EMsgComposer *composer) +{ + GtkUIManager *manager; + GtkAction *action = NULL; + const gchar *path, *action_name; + guint merge_id; + + manager = gtkhtml_editor_get_ui_manager (GTKHTML_EDITOR (composer)); + action_name = "recent-menu"; + path = "/main-menu/insert-menu/insert-menu-top/recent-placeholder"; + merge_id = gtk_ui_manager_new_merge_id (manager); + + action = e_attachment_bar_recent_action_new ( + e_msg_composer_get_attachment_bar (composer), + action_name, _("Recent _Documents")); + + if (action != NULL) { + gtk_action_group_add_action (composer->priv->composer_actions, action); + + gtk_ui_manager_add_ui ( + manager, merge_id, path, + action_name, + action_name, + GTK_UI_MANAGER_AUTO, FALSE); + } + + gtk_ui_manager_ensure_update (manager); } void @@ -86,10 +118,10 @@ e_composer_private_init (EMsgComposer *composer) filename = e_composer_find_data_file ("evolution-composer.ui"); gtk_ui_manager_add_ui_from_file (manager, filename, &error); - composer_setup_charset_menu (composer); - gtk_ui_manager_ensure_update (manager); g_free (filename); + composer_setup_charset_menu (composer); + if (error != NULL) { /* Henceforth, bad things start happening. */ g_critical ("%s", error->message); @@ -158,6 +190,8 @@ e_composer_private_init (EMsgComposer *composer) gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 6); priv->attachment_expander_num = g_object_ref (widget); gtk_widget_show (widget); + + composer_setup_recent_menu (composer); } void diff --git a/composer/evolution-composer.ui b/composer/evolution-composer.ui index ab907e1ca9..feb9cdfa9b 100644 --- a/composer/evolution-composer.ui +++ b/composer/evolution-composer.ui @@ -34,6 +34,7 @@ <menu action='insert-menu'> <placeholder name='insert-menu-top'> <menuitem action='attach'/> + <placeholder name='recent-placeholder'/> <separator/> <menuitem action='send-options'/> <separator/> diff --git a/configure.in b/configure.in index 0a47fc97ea..6fe28c1dde 100644 --- a/configure.in +++ b/configure.in @@ -11,7 +11,7 @@ EDS_PACKAGE=1.2 GTKHTML_PACKAGE=3.14 # Required Packages -m4_define([glib_minimum_version], [2.15.3]) +m4_define([glib_minimum_version], [2.16.0]) m4_define([gtk_minimum_version], [2.12.0]) m4_define([eds_minimum_version], [2.23.1]) m4_define([gnome_icon_theme_minimum_version], [2.19.91]) diff --git a/ui/ChangeLog b/ui/ChangeLog index b10f2ea2ce..e722d52260 100644 --- a/ui/ChangeLog +++ b/ui/ChangeLog @@ -1,3 +1,10 @@ +2008-04-11 Suman Manjunath <msuman@novell.com> + + ** Fix for bug #517134 + + * evolution-editor.xml: Added a placeholder to dock the "Recent + Documents" menu. + 2008-04-02 Matthew Barnes <mbarnes@redhat.com> * evolution-composer-entries.xml: diff --git a/ui/evolution-editor.xml b/ui/evolution-editor.xml index d16b8b5d29..e2310a6de8 100644 --- a/ui/evolution-editor.xml +++ b/ui/evolution-editor.xml @@ -41,6 +41,7 @@ <placeholder name="Attachments"> <menuitem name="InsertAttachments" verb="" _label="_Attachment..."/> </placeholder> + <placeholder f="" name="RecentDocsPlaceholder"/> </submenu> <submenu name="Options" _label="_Options"> diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog index e5e59a03e0..20bd302337 100644 --- a/widgets/misc/ChangeLog +++ b/widgets/misc/ChangeLog @@ -1,3 +1,15 @@ +2008-04-11 Suman Manjunath <msuman@novell.com> + + ** Fix for bug #517134 + + * e-attachment-bar.c: (destroy), (init): Related changes. + (e_attachment_bar_bonobo_ui_populate_with_recent): New API to populate + a bonoboUI menu with "Recent Documents". + (action_recent_cb), (e_attachment_bar_recent_action_new): New API to + obtain a new, pre-configured GtkRecentAction (which can be used as a + "Recent Documents" menu) + * e-attachment-bar.h: APIs' signatures + 2008-04-02 Matthew Barnes <mbarnes@redhat.com> * Makefile.am: diff --git a/widgets/misc/e-attachment-bar.c b/widgets/misc/e-attachment-bar.c index 33bff284f7..2e31810f32 100644 --- a/widgets/misc/e-attachment-bar.c +++ b/widgets/misc/e-attachment-bar.c @@ -28,6 +28,7 @@ #include <string.h> #include <gtk/gtk.h> +#include <gio/gio.h> #include <glade/glade.h> #include <gconf/gconf.h> #include <gconf/gconf-client.h> @@ -71,6 +72,9 @@ static GnomeIconListClass *parent_class = NULL; struct _EAttachmentBarPrivate { GtkWidget *attach; /* attachment file dialogue, if active */ + /* Recent documents. Use this widget directly when bonoboui is obsoleted */ + GtkWidget *recent; + gboolean batch_unref; GPtrArray *attachments; char *path; @@ -551,7 +555,6 @@ e_attachment_bar_get_selector(EAttachmentBar *bar) return &bar->priv->attach; } - /** * e_attachment_bar_get_selected: * @bar: an #EAttachmentBar object @@ -694,6 +697,9 @@ destroy (GtkObject *object) if (priv->attach) gtk_widget_destroy (priv->attach); + if (priv->recent) + gtk_widget_destroy (priv->recent); + if (priv->path) g_free (priv->path); @@ -969,6 +975,15 @@ init (EAttachmentBar *bar) priv->attach = NULL; priv->batch_unref = FALSE; priv->attachments = g_ptr_array_new (); + + priv->recent = gtk_recent_chooser_menu_new (); + gtk_recent_chooser_menu_set_show_numbers (GTK_RECENT_CHOOSER_MENU (priv->recent), TRUE); + gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (priv->recent), GTK_RECENT_SORT_MRU); + gtk_recent_chooser_set_show_not_found (GTK_RECENT_CHOOSER (priv->recent), FALSE); + gtk_recent_chooser_set_show_private (GTK_RECENT_CHOOSER (priv->recent), FALSE); + gtk_recent_chooser_set_show_icons (GTK_RECENT_CHOOSER (priv->recent), TRUE); + gtk_recent_chooser_set_show_tips (GTK_RECENT_CHOOSER (priv->recent), TRUE); + priv->path = NULL; bar->priv = priv; @@ -1228,3 +1243,145 @@ e_attachment_bar_attach_mime_part (EAttachmentBar *bar, CamelMimePart *part) add_from_mime_part (bar, part); } + +/* FIXME: Remove this API if nobody uses it */ +void +e_attachment_bar_bonobo_ui_populate_with_recent (BonoboUIComponent *uic, const char *path, + EAttachmentBar *bar, + BonoboUIVerbFn verb_cb, gpointer user_data) +{ + struct _EAttachmentBarPrivate *priv; + GList *items, *l; + gint limit, i; + GString *menuitems; + char *encoded_label, *label; + + g_return_if_fail (E_IS_ATTACHMENT_BAR (bar)); + + priv = bar->priv; + limit = gtk_recent_chooser_get_limit (GTK_RECENT_CHOOSER (priv->recent)); + items = gtk_recent_chooser_get_items (GTK_RECENT_CHOOSER (priv->recent)); + + menuitems = g_string_new ("<submenu"); + g_string_append (menuitems, " name=\"RecentDocsSubmenu\""); + g_string_append_printf (menuitems, " sensitive=\"%s\"", items ? "1" : "0"); + g_string_append_printf (menuitems, " label=\"%s\"", _("Recent Docu_ments")); + g_string_append (menuitems, ">\n"); + + for (l = g_list_first (items), i = 1; l && i <= limit; l = l->next, ++i) { + GtkRecentInfo *info = ((GtkRecentInfo *)(l->data)); + const gchar *info_dn = gtk_recent_info_get_display_name (info); + char *display_name, *u; + + /* escape _'s in the display name so that it doesn't become an underline in a GtkLabel */ + if ((u = strchr (info_dn, '_'))) { + int extra = 1; + char *d; + const char *s; + + while ((u = strchr (u + 1, '_'))) + extra++; + + d = display_name = g_alloca (strlen (info_dn) + extra + 1); + s = info_dn; + while (*s != '\0') { + if (*s == '_') + *d++ = '_'; + *d++ = *s++; + } + *d = '\0'; + } else + display_name = info_dn; + + /* Add menu item */ + label = g_strdup (display_name); + encoded_label = bonobo_ui_util_encode_str (label); + g_string_append_printf (menuitems, + " <menuitem name=\"Recent-%d\" verb=\"\" label=\"%s\"/>\n", + i, encoded_label); + g_free (encoded_label); + g_free (label); + } + + g_string_append (menuitems, "</submenu>\n"); + + bonobo_ui_component_set (uic, path, menuitems->str, NULL); + + g_string_free (menuitems, TRUE); + + /* Add uri prop */ + for (l = g_list_first (items), i = 1; l && i <= limit; l = l->next, ++i) { + GtkRecentInfo *info = ((GtkRecentInfo *)(l->data)); + const gchar *info_uri = gtk_recent_info_get_uri (info); + label = g_strdup_printf ("/commands/Recent-%d", i); + bonobo_ui_component_set_prop (uic, label, "uri", info_uri, NULL); + g_free (label); + } + + /* Add verb */ + for (l = g_list_first (items), i = 1; l && i <= limit; l = l->next, ++i) { + label = g_strdup_printf ("Recent-%d", i); + bonobo_ui_component_add_verb (uic, label, verb_cb, user_data); + g_free (label); + } + + for (l = g_list_first (items); l; l = l->next) + gtk_recent_info_unref ((GtkRecentInfo *)(l->data)); + g_list_free (items); +} + +static void +action_recent_cb (GtkAction *action, + EAttachmentBar *attachment_bar) +{ + GtkRecentChooser *chooser; + GFile *file; + gchar *uri; + + chooser = GTK_RECENT_CHOOSER (action); + + /* Wish: gtk_recent_chooser_get_current_file() */ + uri = gtk_recent_chooser_get_current_uri (chooser); + file = g_file_new_for_uri (uri); + g_free (uri); + + if (g_file_is_native (file)) + e_attachment_bar_attach ( + E_ATTACHMENT_BAR (attachment_bar), + g_file_get_path (file), "attachment"); + else + e_attachment_bar_attach_remote_file ( + E_ATTACHMENT_BAR (attachment_bar), + g_file_get_uri (file), "attachment"); + + g_object_unref (file); +} + +GtkAction * +e_attachment_bar_recent_action_new (EAttachmentBar *bar, + const gchar *action_name, + const gchar *action_label) +{ + GtkAction *action; + GtkRecentChooser *chooser; + + g_return_val_if_fail (E_IS_ATTACHMENT_BAR (bar), NULL); + + action = gtk_recent_action_new ( + action_name, action_label, NULL, NULL); + gtk_recent_action_set_show_numbers (GTK_RECENT_ACTION (action), TRUE); + + chooser = GTK_RECENT_CHOOSER (action); + gtk_recent_chooser_set_show_icons (chooser, TRUE); + gtk_recent_chooser_set_show_not_found (chooser, FALSE); + gtk_recent_chooser_set_show_private (chooser, FALSE); + gtk_recent_chooser_set_show_tips (chooser, TRUE); + gtk_recent_chooser_set_sort_type (chooser, GTK_RECENT_SORT_MRU); + + g_signal_connect ( + action, "item-activated", + G_CALLBACK (action_recent_cb), bar); + + return action; +} + diff --git a/widgets/misc/e-attachment-bar.h b/widgets/misc/e-attachment-bar.h index 84b1331b3b..ec9e9cc6e4 100644 --- a/widgets/misc/e-attachment-bar.h +++ b/widgets/misc/e-attachment-bar.h @@ -27,6 +27,9 @@ #include <libgnomeui/gnome-icon-list.h> +#include <bonobo/bonobo-ui-node.h> +#include <bonobo/bonobo-ui-util.h> + #include <camel/camel-multipart.h> #include "e-attachment.h" @@ -83,6 +86,14 @@ GSList *e_attachment_bar_get_selected (EAttachmentBar *bar); void e_attachment_bar_set_width(EAttachmentBar *bar, int bar_width); GSList * e_attachment_bar_get_all_attachments (EAttachmentBar *bar); void e_attachment_bar_create_attachment_cache (EAttachment *attachment); +void +e_attachment_bar_bonobo_ui_populate_with_recent (BonoboUIComponent *uic, const char *path, + EAttachmentBar *bar, + BonoboUIVerbFn verb_cb, gpointer user_data); +GtkAction * +e_attachment_bar_recent_action_new (EAttachmentBar *bar, + const gchar *action_name, + const gchar *action_label); #ifdef __cplusplus } |