[evolution-mapi] Migrate to GtkAction from EMPopup for Folder Size feature.
- From: Johnny Jacob <jjohnny src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-mapi] Migrate to GtkAction from EMPopup for Folder Size feature.
- Date: Mon, 14 Sep 2009 15:03:09 +0000 (UTC)
commit dfa96164190c7a6071ad45d8fe3d9e95c3362b5c
Author: Johnny Jacob <jjohnny novell com>
Date: Wed Sep 9 15:06:45 2009 +0530
Migrate to GtkAction from EMPopup for Folder Size feature.
.../exchange-mapi-account-settings.c | 129 +++++++++++++++-----
.../org-gnome-exchange-mapi.eplug.xml | 10 ++
2 files changed, 106 insertions(+), 33 deletions(-)
---
diff --git a/src/account-setup-eplugin/exchange-mapi-account-settings.c b/src/account-setup-eplugin/exchange-mapi-account-settings.c
index fb4fd83..e40e088 100644
--- a/src/account-setup-eplugin/exchange-mapi-account-settings.c
+++ b/src/account-setup-eplugin/exchange-mapi-account-settings.c
@@ -35,29 +35,36 @@
#include <libedataserver/e-xml-hash-utils.h>
#include <libedataserverui/e-passwords.h>
#include <libedataserver/e-account.h>
+#include <e-util/e-util.h>
#include <e-util/e-dialog-utils.h>
+#include <e-util/e-plugin-ui.h>
#include <exchange-mapi-folder.h>
#include <exchange-mapi-connection.h>
#include <exchange-mapi-utils.h>
+#include <shell/e-shell-sidebar.h>
+#include <shell/e-shell-view.h>
+#include <shell/e-shell-window.h>
+
#include <mail/mail-config.h>
-#include <mail/em-popup.h>
-#include <mail/em-menu.h>
-#include "mail/em-config.h"
+#include <mail/em-config.h>
+#include <mail/em-folder-tree.h>
#include "exchange-mapi-account-listener.h"
#define FOLDERSIZE_MENU_ITEM 0
+gboolean e_plugin_ui_init (GtkUIManager *ui_manager,
+ EShellView *shell_view);
+
static GMutex *folder_size_dialog_mutex = NULL;
#define FOLDERSIZE_LOCK_INIT() folder_size_dialog_mutex = g_mutex_new ()
#define FOLDERSIZE_LOCK() g_mutex_lock (folder_size_dialog_mutex)
#define FOLDERSIZE_UNLOCK() g_mutex_unlock (folder_size_dialog_mutex)
-void org_gnome_folder_size_display_popup (EPlugin *ep, EMPopupTargetFolder *t);
GtkWidget *org_gnome_exchange_mapi_settings (EPlugin *epl, EConfigHookItemFactoryData *data);
-void mapi_settings_run_folder_size_dialog (EPopup *ep, EPopupItem *p, gpointer data);
+void mapi_settings_run_folder_size_dialog (gpointer data);
enum {
COL_FOLDERSIZE_NAME = 0,
@@ -73,14 +80,6 @@ typedef struct
gboolean processing;
} FolderSizeDialogData;
-static EPopupItem popup_items[] = {
- { E_POPUP_ITEM, (gchar *) "50.emc.04",
- (gchar *) N_("_Folder size"),
- mapi_settings_run_folder_size_dialog,
- NULL, NULL,
- 0, EM_POPUP_FOLDER_STORE }
-};
-
static gboolean
mapi_settings_pbar_update (gpointer data)
{
@@ -170,7 +169,7 @@ mapi_settings_get_folder_size (gpointer data)
}
void
-mapi_settings_run_folder_size_dialog (EPopup *ep, EPopupItem *p, gpointer data)
+mapi_settings_run_folder_size_dialog (gpointer data)
{
GtkBox *content_area;
FolderSizeDialogData *dialog_data;
@@ -213,7 +212,63 @@ mapi_settings_run_folder_size_dialog (EPopup *ep, EPopupItem *p, gpointer data)
static void
folder_size_clicked (GtkButton *button, gpointer data)
{
- mapi_settings_run_folder_size_dialog (NULL, NULL, (gpointer) button);
+ mapi_settings_run_folder_size_dialog (NULL);
+}
+
+static void
+action_folder_size_cb (GtkAction *action,
+ EShellView *shell_view)
+{
+ EShellSidebar *shell_sidebar;
+ EMFolderTree *folder_tree;
+ const gchar *folder_uri;
+
+ /* Get hold of Folder Tree */
+ shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
+ g_object_get (shell_sidebar, "folder-tree", &folder_tree, NULL);
+ folder_uri = em_folder_tree_get_selected_uri (folder_tree);
+ g_object_unref (folder_tree);
+ g_return_if_fail (folder_uri != NULL);
+
+ if (g_str_has_prefix (folder_uri, "mapi://"))
+ mapi_settings_run_folder_size_dialog (NULL);
+}
+
+static void
+folder_size_actions_update_cb (EShellView *shell_view)
+{
+ EShellContent *shell_content;
+ EShellWindow *shell_window;
+ GtkActionGroup *action_group;
+ GtkUIManager *ui_manager;
+ GtkAction *folder_size_action;
+
+ EShellSidebar *shell_sidebar;
+ EMFolderTree *folder_tree;
+ const gchar *folder_uri;
+
+ shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
+ g_object_get (shell_sidebar, "folder-tree", &folder_tree, NULL);
+ folder_uri = em_folder_tree_get_selected_uri (folder_tree);
+ g_object_unref (folder_tree);
+ g_return_if_fail (folder_uri != NULL);
+
+ shell_content = e_shell_view_get_shell_content (shell_view);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ ui_manager = e_shell_window_get_ui_manager (shell_window);
+ action_group = e_lookup_action_group (ui_manager, "mail");
+
+ folder_size_action = gtk_action_group_get_action (action_group,
+ "mail-mapi-folder-size");
+
+ /* Enable / disable action entry */
+ /* TODO : Instead we should not show the action entry at all! */
+ if (g_str_has_prefix (folder_uri, "mapi://"))
+ gtk_action_set_sensitive (folder_size_action , TRUE);
+ else
+ gtk_action_set_sensitive (folder_size_action , FALSE);
+
}
/* used only in Account Editor */
@@ -278,29 +333,37 @@ org_gnome_exchange_mapi_settings (EPlugin *epl, EConfigHookItemFactoryData *data
return GTK_WIDGET (settings);
}
+static GtkActionEntry folder_size_entries[] = {
-static void
-popup_free (EPopup *ep, GSList *items, gpointer data)
-{
- g_slist_free (items);
-}
+ { "mail-mapi-folder-size",
+ NULL,
+ N_("Folder size"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ action_folder_size_cb }
+};
-void
-org_gnome_folder_size_display_popup (EPlugin *ep, EMPopupTargetFolder *t)
+gboolean
+e_plugin_ui_init (GtkUIManager *ui_manager,
+ EShellView *shell_view)
{
- EAccount *account;
- GSList *menus = NULL;
+ EShellWindow *shell_window;
+ GtkActionGroup *action_group;
- account = mail_config_get_account_by_source_url (t->uri);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ action_group = e_shell_window_get_action_group (shell_window, "mail");
- if (account == NULL)
- return;
+ /* Add actions to the "mail" action group. */
+ gtk_action_group_add_actions (action_group, folder_size_entries,
+ G_N_ELEMENTS (folder_size_entries),
+ shell_view);
- /* Show only for MAPI accounts */
- if (g_strrstr (t->uri,"mapi://")) {
- popup_items[FOLDERSIZE_MENU_ITEM].label = _(popup_items [FOLDERSIZE_MENU_ITEM].label);
- menus = g_slist_prepend (menus, &popup_items [FOLDERSIZE_MENU_ITEM]);
- }
+ /* Decide whether we want this option to be enabled or not */
+ g_signal_connect (shell_view, "update-actions",
+ G_CALLBACK (folder_size_actions_update_cb),
+ shell_view);
+
+ g_object_unref (action_group);
- e_popup_add_items (t->target.popup, menus, NULL, popup_free, account);
+ return TRUE;
}
diff --git a/src/account-setup-eplugin/org-gnome-exchange-mapi.eplug.xml b/src/account-setup-eplugin/org-gnome-exchange-mapi.eplug.xml
index d47e36b..a0fa53a 100644
--- a/src/account-setup-eplugin/org-gnome-exchange-mapi.eplug.xml
+++ b/src/account-setup-eplugin/org-gnome-exchange-mapi.eplug.xml
@@ -66,6 +66,16 @@
</group>
</hook>
+ <hook class="org.gnome.evolution.ui:1.0">
+ <ui-manager id="org.gnome.evolution.mail">
+ <popup name="mail-folder-popup">
+ <placeholder name="mail-folder-popup-actions">
+ <menuitem action="mail-mapi-folder-size"/>
+ </placeholder>
+ </popup>
+ </ui-manager>
+ </hook>
+
<hook class="org.gnome.evolution.mail.popup:1.0">
<menu id="org.gnome.evolution.mail.foldertree.popup" target="folder"
factory="org_gnome_folder_size_display_popup">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]