aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2012-02-17 00:22:28 +0800
committerMilan Crha <mcrha@redhat.com>2012-02-17 00:23:07 +0800
commit83d001baa23d3cce1d983dbc7946a7c5375c05f2 (patch)
tree5c19dd40d965b35d2ca26a926e964946dcd91178 /shell
parentaeb3238ad0fc239a26a9b3708679bb677030063b (diff)
downloadgsoc2013-evolution-83d001baa23d3cce1d983dbc7946a7c5375c05f2.tar
gsoc2013-evolution-83d001baa23d3cce1d983dbc7946a7c5375c05f2.tar.gz
gsoc2013-evolution-83d001baa23d3cce1d983dbc7946a7c5375c05f2.tar.bz2
gsoc2013-evolution-83d001baa23d3cce1d983dbc7946a7c5375c05f2.tar.lz
gsoc2013-evolution-83d001baa23d3cce1d983dbc7946a7c5375c05f2.tar.xz
gsoc2013-evolution-83d001baa23d3cce1d983dbc7946a7c5375c05f2.tar.zst
gsoc2013-evolution-83d001baa23d3cce1d983dbc7946a7c5375c05f2.zip
Bug #320976 - Remember last New button choice in Calendar view
Diffstat (limited to 'shell')
-rw-r--r--shell/e-shell-backend.c93
-rw-r--r--shell/e-shell-backend.h5
-rw-r--r--shell/e-shell-window.c103
-rw-r--r--shell/e-shell-window.h5
4 files changed, 205 insertions, 1 deletions
diff --git a/shell/e-shell-backend.c b/shell/e-shell-backend.c
index fed85cd6e2..f4baca770f 100644
--- a/shell/e-shell-backend.c
+++ b/shell/e-shell-backend.c
@@ -58,13 +58,15 @@ struct _EShellBackendPrivate {
gchar *config_dir;
gchar *data_dir;
+ gchar *prefer_new_item;
guint started : 1;
};
enum {
PROP_0,
- PROP_BUSY
+ PROP_BUSY,
+ PROP_PREFER_NEW_ITEM
};
enum {
@@ -164,6 +166,30 @@ shell_backend_get_property (GObject *object,
value, e_shell_backend_is_busy (
E_SHELL_BACKEND (object)));
return;
+
+ case PROP_PREFER_NEW_ITEM:
+ g_value_set_string (
+ value,
+ e_shell_backend_get_prefer_new_item (
+ E_SHELL_BACKEND (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+shell_backend_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_PREFER_NEW_ITEM:
+ e_shell_backend_set_prefer_new_item (
+ E_SHELL_BACKEND (object),
+ g_value_get_string (value));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -181,6 +207,11 @@ shell_backend_dispose (GObject *object)
priv->shell_view_class = NULL;
}
+ if (priv->prefer_new_item) {
+ g_free (priv->prefer_new_item);
+ priv->prefer_new_item = NULL;
+ }
+
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (e_shell_backend_parent_class)->dispose (object);
}
@@ -253,6 +284,7 @@ e_shell_backend_class_init (EShellBackendClass *class)
object_class = G_OBJECT_CLASS (class);
object_class->constructor = shell_backend_constructor;
object_class->get_property = shell_backend_get_property;
+ object_class->set_property = shell_backend_set_property;
object_class->dispose = shell_backend_dispose;
object_class->finalize = shell_backend_finalize;
@@ -278,6 +310,21 @@ e_shell_backend_class_init (EShellBackendClass *class)
G_PARAM_READABLE));
/**
+ * EShellBackend:prefer-new-item
+ *
+ * Name of an item to prefer in New toolbar button; can be NULL
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_PREFER_NEW_ITEM,
+ g_param_spec_string (
+ "prefer-new-item",
+ "Prefer New Item",
+ "Name of an item to prefer in New toolbar button",
+ NULL,
+ G_PARAM_READWRITE));
+
+ /**
* EShellBackend::activity-added
* @shell_backend: the #EShellBackend that emitted the signal
* @activity: an #EActivity
@@ -455,6 +502,50 @@ e_shell_backend_is_busy (EShellBackend *shell_backend)
}
/**
+ * e_shell_backend_set_prefer_new_item:
+ * @shell_backend: an #EShellBackend
+ * @prefer_new_item: name of an item
+ *
+ * Sets name of a preferred item in New toolbar button. Use %NULL or
+ * an empty string for no preference.
+ *
+ * Since: 3.4
+ **/
+void
+e_shell_backend_set_prefer_new_item (EShellBackend *shell_backend,
+ const gchar *prefer_new_item)
+{
+ g_return_if_fail (shell_backend != NULL);
+ g_return_if_fail (E_IS_SHELL_BACKEND (shell_backend));
+
+ if (g_strcmp0 (shell_backend->priv->prefer_new_item, prefer_new_item) == 0)
+ return;
+
+ g_free (shell_backend->priv->prefer_new_item);
+ shell_backend->priv->prefer_new_item = g_strdup (prefer_new_item);
+
+ g_object_notify (G_OBJECT (shell_backend), "prefer-new-item");
+}
+
+/**
+ * e_shell_backend_get_prefer_new_item:
+ * @shell_backend: an #EShellBackend
+ *
+ * Returns: Name of a preferred item in New toolbar button, %NULL or
+ * an empty string for no preference.
+ *
+ * Since: 3.4
+ **/
+const gchar *
+e_shell_backend_get_prefer_new_item (EShellBackend *shell_backend)
+{
+ g_return_val_if_fail (shell_backend != NULL, NULL);
+ g_return_val_if_fail (E_IS_SHELL_BACKEND (shell_backend), NULL);
+
+ return shell_backend->priv->prefer_new_item;
+}
+
+/**
* e_shell_backend_cancel_all:
* @shell_backend: an #EShellBackend
*
diff --git a/shell/e-shell-backend.h b/shell/e-shell-backend.h
index ae600bac3d..759a3bdcb7 100644
--- a/shell/e-shell-backend.h
+++ b/shell/e-shell-backend.h
@@ -126,6 +126,11 @@ struct _EShell *e_shell_backend_get_shell (EShellBackend *shell_backend);
void e_shell_backend_add_activity (EShellBackend *shell_backend,
EActivity *activity);
gboolean e_shell_backend_is_busy (EShellBackend *shell_backend);
+void e_shell_backend_set_prefer_new_item
+ (EShellBackend *shell_backend,
+ const gchar *prefer_new_item);
+const gchar * e_shell_backend_get_prefer_new_item
+ (EShellBackend *shell_backend);
void e_shell_backend_cancel_all (EShellBackend *shell_backend);
void e_shell_backend_start (EShellBackend *shell_backend);
gboolean e_shell_backend_is_started (EShellBackend *shell_backend);
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index 19178f8292..a8b44e67db 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -81,6 +81,10 @@ shell_window_menubar_update_new_menu (EShellWindow *shell_window)
gtk_widget_show (widget);
}
+static void shell_window_backend_prefer_item_changed_cb (EShellBackend *backend,
+ GParamSpec *pspec,
+ EShellWindow *shell_window);
+
static void
shell_window_toolbar_update_new_menu (EShellWindow *shell_window,
GParamSpec *pspec,
@@ -91,6 +95,44 @@ shell_window_toolbar_update_new_menu (EShellWindow *shell_window,
/* Update the "New" menu tool button submenu. */
menu = e_shell_window_create_new_menu (shell_window);
gtk_menu_tool_button_set_menu (menu_tool_button, menu);
+
+ if (pspec && g_strcmp0 (pspec->name, "active-view") == 0) {
+ EShellView *shell_view;
+ EShellBackend *shell_backend;
+
+ shell_view = e_shell_window_peek_shell_view (shell_window,
+ e_shell_window_get_active_view (shell_window));
+ g_return_if_fail (shell_view != NULL);
+
+ shell_backend = e_shell_view_get_shell_backend (shell_view);
+
+ g_signal_handlers_disconnect_by_func (shell_backend,
+ shell_window_backend_prefer_item_changed_cb, shell_window);
+ g_signal_connect (shell_backend, "notify::prefer-new-item",
+ G_CALLBACK (shell_window_backend_prefer_item_changed_cb), shell_window);
+
+ shell_window_backend_prefer_item_changed_cb (shell_backend, NULL, shell_window);
+ }
+}
+
+static void
+shell_window_backend_prefer_item_changed_cb (EShellBackend *backend,
+ GParamSpec *pspec,
+ EShellWindow *shell_window)
+{
+ EShellView *shell_view;
+ EShellBackend *shell_backend;
+
+ shell_view = e_shell_window_peek_shell_view (shell_window,
+ e_shell_window_get_active_view (shell_window));
+ g_return_if_fail (shell_view != NULL);
+
+ shell_backend = e_shell_view_get_shell_backend (shell_view);
+ if (shell_backend != backend)
+ return;
+
+ e_shell_window_set_toolbar_new_prefer_item (shell_window,
+ e_shell_backend_get_prefer_new_item (shell_backend));
}
static void
@@ -456,6 +498,11 @@ shell_window_construct_toolbar (EShellWindow *shell_window)
G_CALLBACK (shell_window_toolbar_update_new_menu),
GTK_MENU_TOOL_BUTTON (item));
+ g_signal_connect_swapped (
+ item, "notify::prefer-item",
+ G_CALLBACK (shell_window_toolbar_update_new_menu),
+ shell_window);
+
gtk_box_pack_start (GTK_BOX (box), toolbar, TRUE, TRUE, 0);
toolbar = e_shell_window_get_managed_widget (
@@ -1503,6 +1550,62 @@ e_shell_window_set_toolbar_visible (EShellWindow *shell_window,
}
/**
+ * e_shell_window_set_toolbar_new_prefer_item:
+ * @shell_window: an #EShellWindow
+ * @prefer_item: prefer-item name to be set
+ *
+ * Sets prefer item on the New button for current view.
+ *
+ * Since: 3.4
+ **/
+void
+e_shell_window_set_toolbar_new_prefer_item (EShellWindow *shell_window,
+ const gchar *prefer_item)
+{
+ GtkWidget *toolbar;
+ GtkToolItem *item;
+
+ g_return_if_fail (shell_window != NULL);
+ g_return_if_fail (E_IS_SHELL_WINDOW (shell_window));
+
+ toolbar = e_shell_window_get_managed_widget (shell_window, "/main-toolbar");
+ g_return_if_fail (toolbar != NULL);
+
+ item = gtk_toolbar_get_nth_item (GTK_TOOLBAR (toolbar), 0);
+ g_return_if_fail (item != NULL);
+ g_return_if_fail (E_IS_MENU_TOOL_BUTTON (item));
+
+ e_menu_tool_button_set_prefer_item (E_MENU_TOOL_BUTTON (item), prefer_item);
+}
+
+/**
+ * e_shell_window_get_toolbar_new_prefer_item:
+ * @shell_window: an #EShellWindow
+ *
+ * Returns: name of preferred item on the New button for current view.
+ *
+ * Since: 3.4
+ **/
+const gchar *
+e_shell_window_get_toolbar_new_prefer_item (EShellWindow *shell_window)
+{
+ GtkWidget *toolbar;
+ GtkToolItem *item;
+
+ g_return_val_if_fail (shell_window != NULL, NULL);
+ g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), NULL);
+
+ toolbar = e_shell_window_get_managed_widget (shell_window, "/main-toolbar");
+ g_return_val_if_fail (toolbar != NULL, NULL);
+
+ item = gtk_toolbar_get_nth_item (GTK_TOOLBAR (toolbar), 0);
+ g_return_val_if_fail (item != NULL, NULL);
+ g_return_val_if_fail (E_IS_MENU_TOOL_BUTTON (item), NULL);
+
+ return e_menu_tool_button_get_prefer_item (E_MENU_TOOL_BUTTON (item));
+}
+
+/**
* e_shell_window_register_new_item_actions:
* @shell_window: an #EShellWindow
* @backend_name: name of an #EShellBackend
diff --git a/shell/e-shell-window.h b/shell/e-shell-window.h
index 25e039a0ab..366a2186c1 100644
--- a/shell/e-shell-window.h
+++ b/shell/e-shell-window.h
@@ -135,6 +135,11 @@ gboolean e_shell_window_get_toolbar_visible
void e_shell_window_set_toolbar_visible
(EShellWindow *shell_window,
gboolean toolbar_visible);
+void e_shell_window_set_toolbar_new_prefer_item
+ (EShellWindow *shell_window,
+ const gchar *prefer_item);
+const gchar * e_shell_window_get_toolbar_new_prefer_item
+ (EShellWindow *shell_window);
/* These should be called from the shell backend's window_created() handler. */