From 52d683e48cf1103a9806da95c72abce2db3ae1f4 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 7 Sep 2008 04:02:27 +0000 Subject: Progress update: - Contacts module mostly working now. - View and search UI not yet working. - Still refining shell design. svn path=/branches/kill-bonobo/; revision=36268 --- shell/Makefile.am | 2 + shell/e-shell-content.c | 3 +- shell/e-shell-module.c | 9 ++ shell/e-shell-module.h | 2 + shell/e-shell-sidebar.c | 46 +++------ shell/e-shell-sidebar.h | 1 - shell/e-shell-switcher.c | 215 ++++++++++++++++++++++++++------------- shell/e-shell-switcher.h | 3 + shell/e-shell-view.c | 78 +++++++++++++- shell/e-shell-view.h | 4 +- shell/e-shell-window-actions.c | 132 ++++++++++++++++++++++-- shell/e-shell-window-actions.h | 10 ++ shell/e-shell-window-private.c | 14 +-- shell/e-shell-window-private.h | 9 +- shell/e-shell-window.c | 26 +++++ shell/test/e-test-shell-module.c | 2 + 16 files changed, 429 insertions(+), 127 deletions(-) (limited to 'shell') diff --git a/shell/Makefile.am b/shell/Makefile.am index 7bedc4e46d..c593548b6d 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -3,6 +3,7 @@ SUBDIRS = . test endif INCLUDES = \ + -I$(top_srcdir)/e-util \ -I$(top_srcdir)/widgets \ -I$(top_srcdir)/widgets/menus \ -I$(top_srcdir)/widgets/misc \ @@ -15,6 +16,7 @@ INCLUDES = \ -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ -DEVOLUTION_HELPDIR=\""$(evolutionhelpdir)"\" \ -DEVOLUTION_MODULEDIR=\""$(moduledir)"\" \ + -DEVOLUTION_RULEDIR=\""$(ruledir)"\" \ -DEVOLUTION_UIDIR=\""$(evolutionuidir)"\" \ -DEVOLUTION_TOOLSDIR=\""$(privlibexecdir)"\" \ -DPREFIX=\""$(prefix)"\" \ diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c index 22b2bc8af8..6671e5505e 100644 --- a/shell/e-shell-content.c +++ b/shell/e-shell-content.c @@ -94,7 +94,8 @@ shell_content_size_allocate (GtkWidget *widget, gtk_widget_size_allocate (child, &child_allocation); child_allocation.y += child_requisition.height; - child_allocation.height = allocation->height - child_allocation.y; + child_allocation.height = + allocation->height - child_requisition.height; child = gtk_bin_get_child (GTK_BIN (widget)); if (child != NULL) diff --git a/shell/e-shell-module.c b/shell/e-shell-module.c index ed8d2411f1..75dbc3756f 100644 --- a/shell/e-shell-module.c +++ b/shell/e-shell-module.c @@ -303,6 +303,14 @@ e_shell_module_get_filename (EShellModule *shell_module) return shell_module->priv->filename; } +const gchar * +e_shell_module_get_searches (EShellModule *shell_module) +{ + g_return_val_if_fail (E_IS_SHELL_MODULE (shell_module), NULL); + + return shell_module->priv->info.searches; +} + EShell * e_shell_module_get_shell (EShellModule *shell_module) { @@ -361,6 +369,7 @@ e_shell_module_set_info (EShellModule *shell_module, module_info->aliases = g_intern_string (info->aliases); module_info->schemes = g_intern_string (info->schemes); + module_info->searches = g_intern_string (info->searches); module_info->sort_order = info->sort_order; module_info->is_busy = info->is_busy; diff --git a/shell/e-shell-module.h b/shell/e-shell-module.h index d643d94527..7e2722f210 100644 --- a/shell/e-shell-module.h +++ b/shell/e-shell-module.h @@ -53,6 +53,7 @@ struct _EShellModuleInfo { const gchar *name; const gchar *aliases; /* colon-separated list */ const gchar *schemes; /* colon-separated list */ + const gchar *searches; /* built-in search rules */ gint sort_order; gboolean (*is_busy) (EShellModule *shell_module); @@ -75,6 +76,7 @@ gint e_shell_module_compare (EShellModule *shell_module_a, EShellModule *shell_module_b); const gchar * e_shell_module_get_data_dir (EShellModule *shell_module); const gchar * e_shell_module_get_filename (EShellModule *shell_module); +const gchar * e_shell_module_get_searches (EShellModule *shell_module); EShell * e_shell_module_get_shell (EShellModule *shell_module); gboolean e_shell_module_is_busy (EShellModule *shell_module); gboolean e_shell_module_shutdown (EShellModule *shell_module); diff --git a/shell/e-shell-sidebar.c b/shell/e-shell-sidebar.c index 30917fd25c..32b31a83c9 100644 --- a/shell/e-shell-sidebar.c +++ b/shell/e-shell-sidebar.c @@ -29,7 +29,6 @@ struct _EShellSidebarPrivate { GtkWidget *image; GtkWidget *primary_label; GtkWidget *secondary_label; - GtkSizeGroup *size_group; gchar *primary_text; gchar *secondary_text; }; @@ -45,9 +44,9 @@ static gpointer parent_class; static void shell_sidebar_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) + guint property_id, + const GValue *value, + GParamSpec *pspec) { switch (property_id) { case PROP_ICON_NAME: @@ -74,9 +73,9 @@ shell_sidebar_set_property (GObject *object, static void shell_sidebar_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) + guint property_id, + GValue *value, + GParamSpec *pspec) { switch (property_id) { case PROP_ICON_NAME: @@ -108,11 +107,6 @@ shell_sidebar_dispose (GObject *object) priv = E_SHELL_SIDEBAR_GET_PRIVATE (object); - if (priv->size_group != NULL) { - g_object_unref (priv->size_group); - priv->size_group = NULL; - } - if (priv->event_box != NULL) { g_object_unref (priv->event_box); priv->event_box = NULL; @@ -175,7 +169,7 @@ shell_sidebar_size_request (GtkWidget *widget, static void shell_sidebar_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) + GtkAllocation *allocation) { EShellSidebarPrivate *priv; GtkAllocation child_allocation; @@ -197,7 +191,8 @@ shell_sidebar_size_allocate (GtkWidget *widget, gtk_widget_size_allocate (child, &child_allocation); child_allocation.y += child_requisition.height; - child_allocation.height = allocation->height - child_allocation.y; + child_allocation.height = + allocation->height - child_requisition.height; child = gtk_bin_get_child (GTK_BIN (widget)); if (child != NULL) @@ -206,7 +201,7 @@ shell_sidebar_size_allocate (GtkWidget *widget, static void shell_sidebar_remove (GtkContainer *container, - GtkWidget *widget) + GtkWidget *widget) { EShellSidebarPrivate *priv; @@ -226,9 +221,9 @@ shell_sidebar_remove (GtkContainer *container, static void shell_sidebar_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) + gboolean include_internals, + GtkCallback callback, + gpointer callback_data) { EShellSidebarPrivate *priv; @@ -306,7 +301,6 @@ shell_sidebar_init (EShellSidebar *shell_sidebar) GtkStyle *style; GtkWidget *container; GtkWidget *widget; - GtkSizeGroup *size_group; const GdkColor *color; shell_sidebar->priv = E_SHELL_SIDEBAR_GET_PRIVATE (shell_sidebar); @@ -349,10 +343,6 @@ shell_sidebar_init (EShellSidebar *shell_sidebar) gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); shell_sidebar->priv->secondary_label = g_object_ref (widget); gtk_widget_show (widget); - - size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL); - gtk_size_group_add_widget (size_group, shell_sidebar->priv->event_box); - shell_sidebar->priv->size_group = size_group; } GType @@ -461,7 +451,7 @@ e_shell_sidebar_get_secondary_text (EShellSidebar *shell_sidebar) void e_shell_sidebar_set_secondary_text (EShellSidebar *shell_sidebar, - const gchar *secondary_text) + const gchar *secondary_text) { GtkLabel *label; gchar *markup; @@ -482,11 +472,3 @@ e_shell_sidebar_set_secondary_text (EShellSidebar *shell_sidebar, gtk_widget_queue_resize (GTK_WIDGET (shell_sidebar)); g_object_notify (G_OBJECT (shell_sidebar), "secondary-text"); } - -GtkSizeGroup * -e_shell_sidebar_get_size_group (EShellSidebar *shell_sidebar) -{ - g_return_val_if_fail (E_IS_SHELL_SIDEBAR (shell_sidebar), NULL); - - return shell_sidebar->priv->size_group; -} diff --git a/shell/e-shell-sidebar.h b/shell/e-shell-sidebar.h index d674339ef7..70777b80fd 100644 --- a/shell/e-shell-sidebar.h +++ b/shell/e-shell-sidebar.h @@ -72,7 +72,6 @@ const gchar * e_shell_sidebar_get_secondary_text void e_shell_sidebar_set_secondary_text (EShellSidebar *shell_sidebar, const gchar *secondary_text); -GtkSizeGroup * e_shell_sidebar_get_size_group (EShellSidebar *shell_sidebar); G_END_DECLS diff --git a/shell/e-shell-switcher.c b/shell/e-shell-switcher.c index bfcae011bc..f9cf1810b7 100644 --- a/shell/e-shell-switcher.c +++ b/shell/e-shell-switcher.c @@ -33,11 +33,13 @@ struct _EShellSwitcherPrivate { GtkToolbarStyle style; GtkSettings *settings; gulong settings_handler_id; + gboolean toolbar_visible; }; enum { PROP_0, - PROP_TOOLBAR_STYLE + PROP_TOOLBAR_STYLE, + PROP_TOOLBAR_VISIBLE }; enum { @@ -48,21 +50,25 @@ enum { static gpointer parent_class; static guint signals[LAST_SIGNAL]; -static void -switcher_layout_actions (EShellSwitcher *switcher) +static gint +shell_switcher_layout_actions (EShellSwitcher *switcher) { - GtkAllocation *allocation = & GTK_WIDGET (switcher)->allocation; - gboolean icons_only; + GtkAllocation *allocation; int num_btns = g_list_length (switcher->priv->proxies), btns_per_row; GList **rows, *p; - int row_number; - int max_width = 0, max_height = 0; - int row_last; - int x, y; - int i; + gboolean icons_only; + gint row_number; + gint max_width = 0; + gint max_height = 0; + gint row_last; + gint x, y; + gint i; + + allocation = >K_WIDGET (switcher)->allocation; + y = allocation->y + allocation->height; if (num_btns == 0) - return; + return allocation->height; icons_only = (switcher->priv->style == GTK_TOOLBAR_ICONS); @@ -111,11 +117,11 @@ switcher_layout_actions (EShellSwitcher *switcher) row_last = row_number; /* Layout the buttons. */ - y = allocation->y; for (i = 0; i < row_last + 1; i++) { int len, extra_width; x = H_PADDING + allocation->x; + y -= max_height; len = g_list_length (rows[i]); if (!icons_only) extra_width = (allocation->width - (len * max_width ) - (len * H_PADDING)) / len; @@ -134,16 +140,18 @@ switcher_layout_actions (EShellSwitcher *switcher) x += child_allocation.width + H_PADDING; } - y += max_height + V_PADDING; + y -= V_PADDING; } for (i = 0; i <= row_last; i ++) g_list_free (rows [i]); g_free (rows); + + return y - allocation->y; } static void -switcher_toolbar_style_changed_cb (EShellSwitcher *switcher) +shell_switcher_toolbar_style_changed_cb (EShellSwitcher *switcher) { if (!switcher->priv->style_set) { switcher->priv->style_set = TRUE; @@ -152,10 +160,10 @@ switcher_toolbar_style_changed_cb (EShellSwitcher *switcher) } static void -switcher_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) +shell_switcher_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) { switch (property_id) { case PROP_TOOLBAR_STYLE: @@ -163,16 +171,22 @@ switcher_set_property (GObject *object, E_SHELL_SWITCHER (object), g_value_get_enum (value)); return; + + case PROP_TOOLBAR_VISIBLE: + e_shell_switcher_set_visible ( + E_SHELL_SWITCHER (object), + g_value_get_boolean (value)); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } static void -switcher_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) +shell_switcher_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { switch (property_id) { case PROP_TOOLBAR_STYLE: @@ -180,13 +194,19 @@ switcher_get_property (GObject *object, value, e_shell_switcher_get_style ( E_SHELL_SWITCHER (object))); return; + + case PROP_TOOLBAR_VISIBLE: + g_value_set_boolean ( + value, e_shell_switcher_get_visible ( + E_SHELL_SWITCHER (object))); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } static void -switcher_dispose (GObject *object) +shell_switcher_dispose (GObject *object) { EShellSwitcherPrivate *priv; @@ -202,10 +222,11 @@ switcher_dispose (GObject *object) } static void -switcher_size_request (GtkWidget *widget, - GtkRequisition *requisition) +shell_switcher_size_request (GtkWidget *widget, + GtkRequisition *requisition) { EShellSwitcherPrivate *priv; + GtkWidget *child; GList *iter; priv = E_SHELL_SWITCHER_GET_PRIVATE (widget); @@ -213,6 +234,13 @@ switcher_size_request (GtkWidget *widget, requisition->width = 0; requisition->height = 0; + child = gtk_bin_get_child (GTK_BIN (widget)); + if (child != NULL) + gtk_widget_size_request (child, requisition); + + if (!priv->toolbar_visible) + return; + for (iter = priv->proxies; iter != NULL; iter = iter->next) { GtkWidget *widget = iter->data; GtkRequisition child_requisition; @@ -229,21 +257,36 @@ switcher_size_request (GtkWidget *widget, } static void -switcher_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) +shell_switcher_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) { - EShellSwitcherPrivate *priv; + EShellSwitcher *switcher; + GtkAllocation child_allocation; + GtkWidget *child; + gint height; - priv = E_SHELL_SWITCHER_GET_PRIVATE (widget); + switcher = E_SHELL_SWITCHER (widget); widget->allocation = *allocation; - switcher_layout_actions (E_SHELL_SWITCHER (widget)); + if (switcher->priv->toolbar_visible) + height = shell_switcher_layout_actions (switcher); + else + height = allocation->height; + + child_allocation.x = allocation->x; + child_allocation.y = allocation->y; + child_allocation.width = allocation->width; + child_allocation.height = height; + + child = gtk_bin_get_child (GTK_BIN (widget)); + if (child != NULL) + gtk_widget_size_allocate (child, &child_allocation); } static void -switcher_screen_changed (GtkWidget *widget, - GdkScreen *previous_screen) +shell_switcher_screen_changed (GtkWidget *widget, + GdkScreen *previous_screen) { EShellSwitcherPrivate *priv; GtkSettings *settings; @@ -268,16 +311,17 @@ switcher_screen_changed (GtkWidget *widget, priv->settings = g_object_ref (settings); priv->settings_handler_id = g_signal_connect_swapped ( settings, "notify::gtk-toolbar-style", - G_CALLBACK (switcher_toolbar_style_changed_cb), widget); + G_CALLBACK (shell_switcher_toolbar_style_changed_cb), + widget); } else priv->settings = NULL; - switcher_toolbar_style_changed_cb (E_SHELL_SWITCHER (widget)); + shell_switcher_toolbar_style_changed_cb (E_SHELL_SWITCHER (widget)); } static void -switcher_remove (GtkContainer *container, - GtkWidget *widget) +shell_switcher_remove (GtkContainer *container, + GtkWidget *widget) { EShellSwitcherPrivate *priv; GList *link; @@ -301,10 +345,10 @@ switcher_remove (GtkContainer *container, } static void -switcher_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) +shell_switcher_forall (GtkContainer *container, + gboolean include_internals, + GtkCallback callback, + gpointer callback_data) { EShellSwitcherPrivate *priv; @@ -320,8 +364,8 @@ switcher_forall (GtkContainer *container, } static void -switcher_style_changed (EShellSwitcher *switcher, - GtkToolbarStyle style) +shell_switcher_style_changed (EShellSwitcher *switcher, + GtkToolbarStyle style) { if (switcher->priv->style == style) return; @@ -337,33 +381,31 @@ switcher_style_changed (EShellSwitcher *switcher, } static GtkIconSize -switcher_get_icon_size (GtkToolShell *shell) +shell_switcher_get_icon_size (GtkToolShell *shell) { return GTK_ICON_SIZE_LARGE_TOOLBAR; } static GtkOrientation -switcher_get_orientation (GtkToolShell *shell) +shell_switcher_get_orientation (GtkToolShell *shell) { return GTK_ORIENTATION_HORIZONTAL; } static GtkToolbarStyle -switcher_get_style (GtkToolShell *shell) +shell_switcher_get_style (GtkToolShell *shell) { return e_shell_switcher_get_style (E_SHELL_SWITCHER (shell)); } static GtkReliefStyle -switcher_get_relief_style (GtkToolShell *shell) +shell_switcher_get_relief_style (GtkToolShell *shell) { - /* XXX GTK+ 2.13.6 discards this value. - * http://bugzilla.gnome.org/show_bug.cgi?id=549943 */ return GTK_RELIEF_NORMAL; } static void -switcher_class_init (EShellSwitcherClass *class) +shell_switcher_class_init (EShellSwitcherClass *class) { GObjectClass *object_class; GtkWidgetClass *widget_class; @@ -373,20 +415,20 @@ switcher_class_init (EShellSwitcherClass *class) g_type_class_add_private (class, sizeof (EShellSwitcherPrivate)); object_class = G_OBJECT_CLASS (class); - object_class->set_property = switcher_set_property; - object_class->get_property = switcher_get_property; - object_class->dispose = switcher_dispose; + object_class->set_property = shell_switcher_set_property; + object_class->get_property = shell_switcher_get_property; + object_class->dispose = shell_switcher_dispose; widget_class = GTK_WIDGET_CLASS (class); - widget_class->size_request = switcher_size_request; - widget_class->size_allocate = switcher_size_allocate; - widget_class->screen_changed = switcher_screen_changed; + widget_class->size_request = shell_switcher_size_request; + widget_class->size_allocate = shell_switcher_size_allocate; + widget_class->screen_changed = shell_switcher_screen_changed; container_class = GTK_CONTAINER_CLASS (class); - container_class->remove = switcher_remove; - container_class->forall = switcher_forall; + container_class->remove = shell_switcher_remove; + container_class->forall = shell_switcher_forall; - class->style_changed = switcher_style_changed; + class->style_changed = shell_switcher_style_changed; g_object_class_install_property ( object_class, @@ -400,6 +442,17 @@ switcher_class_init (EShellSwitcherClass *class) G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + g_object_class_install_property ( + object_class, + PROP_TOOLBAR_VISIBLE, + g_param_spec_boolean ( + "toolbar-visible", + NULL, + NULL, + TRUE, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT)); + signals[STYLE_CHANGED] = g_signal_new ( "style-changed", G_OBJECT_CLASS_TYPE (class), @@ -412,7 +465,7 @@ switcher_class_init (EShellSwitcherClass *class) } static void -switcher_init (EShellSwitcher *switcher) +shell_switcher_init (EShellSwitcher *switcher) { switcher->priv = E_SHELL_SWITCHER_GET_PRIVATE (switcher); @@ -420,12 +473,12 @@ switcher_init (EShellSwitcher *switcher) } static void -switcher_tool_shell_iface_init (GtkToolShellIface *iface) +shell_switcher_tool_shell_iface_init (GtkToolShellIface *iface) { - iface->get_icon_size = switcher_get_icon_size; - iface->get_orientation = switcher_get_orientation; - iface->get_style = switcher_get_style; - iface->get_relief_style = switcher_get_relief_style; + iface->get_icon_size = shell_switcher_get_icon_size; + iface->get_orientation = shell_switcher_get_orientation; + iface->get_style = shell_switcher_get_style; + iface->get_relief_style = shell_switcher_get_relief_style; } GType @@ -438,17 +491,17 @@ e_shell_switcher_get_type (void) sizeof (EShellSwitcherClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, - (GClassInitFunc) switcher_class_init, + (GClassInitFunc) shell_switcher_class_init, (GClassFinalizeFunc) NULL, NULL, /* class_data */ sizeof (EShellSwitcher), 0, /* n_preallocs */ - (GInstanceInitFunc) switcher_init, + (GInstanceInitFunc) shell_switcher_init, NULL /* value_table */ }; static const GInterfaceInfo tool_shell_info = { - (GInterfaceInitFunc) switcher_tool_shell_iface_init, + (GInterfaceInitFunc) shell_switcher_tool_shell_iface_init, (GInterfaceFinalizeFunc) NULL, NULL /* interface_data */ }; @@ -502,7 +555,7 @@ e_shell_switcher_get_style (EShellSwitcher *switcher) void e_shell_switcher_set_style (EShellSwitcher *switcher, - GtkToolbarStyle style) + GtkToolbarStyle style) { g_return_if_fail (E_IS_SHELL_SWITCHER (switcher)); @@ -535,3 +588,29 @@ e_shell_switcher_unset_style (EShellSwitcher *switcher) switcher->priv->style_set = FALSE; } + +gboolean +e_shell_switcher_get_visible (EShellSwitcher *switcher) +{ + g_return_val_if_fail (E_IS_SHELL_SWITCHER (switcher), FALSE); + + return switcher->priv->toolbar_visible; +} + +void +e_shell_switcher_set_visible (EShellSwitcher *switcher, + gboolean visible) +{ + GList *iter; + + g_return_if_fail (E_IS_SHELL_SWITCHER (switcher)); + + switcher->priv->toolbar_visible = visible; + + for (iter = switcher->priv->proxies; iter != NULL; iter = iter->next) + g_object_set (iter->data, "visible", visible, NULL); + + gtk_widget_queue_resize (GTK_WIDGET (switcher)); + + g_object_notify (G_OBJECT (switcher), "toolbar-visible"); +} diff --git a/shell/e-shell-switcher.h b/shell/e-shell-switcher.h index 6d2995f99a..67201279d2 100644 --- a/shell/e-shell-switcher.h +++ b/shell/e-shell-switcher.h @@ -70,6 +70,9 @@ GtkToolbarStyle e_shell_switcher_get_style (EShellSwitcher *switcher); void e_shell_switcher_set_style (EShellSwitcher *switcher, GtkToolbarStyle style); void e_shell_switcher_unset_style (EShellSwitcher *switcher); +gboolean e_shell_switcher_get_visible (EShellSwitcher *switcher); +void e_shell_switcher_set_visible (EShellSwitcher *switcher, + gboolean visible); G_END_DECLS diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index 2cb2ec9f3c..7620cb92a7 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -23,9 +23,12 @@ #include #include -#include +#include +#include +#include #include +#include #include #include #include @@ -62,6 +65,70 @@ enum { static gpointer parent_class; static gulong signals[LAST_SIGNAL]; +static void +shell_view_setup_search_context (EShellView *shell_view) +{ + RuleContext *context; + EShellViewClass *class; + EShellModule *shell_module; + FilterRule *rule; + FilterPart *part; + GtkWidget *widget; + gchar *system_filename; + gchar *user_filename; + + class = E_SHELL_VIEW_GET_CLASS (shell_view); + shell_module = E_SHELL_MODULE (class->type_module); + + /* The filename for built-in searches is specified in a + * module's EShellModuleInfo. All built-in search rules + * live in the same directory. */ + system_filename = g_build_filename ( + EVOLUTION_RULEDIR, + e_shell_module_get_searches (shell_module), NULL); + + /* The filename for custom saved searches is always of + * the form "$(shell_module_data_dir)/searches.xml". */ + user_filename = g_build_filename ( + e_shell_module_get_data_dir (shell_module), + "searches.xml", NULL); + + context = rule_context_new (); + rule_context_add_part_set ( + context, "partset", FILTER_TYPE_PART, + rule_context_add_part, rule_context_next_part); + rule_context_add_rule_set ( + context, "ruleset", FILTER_TYPE_RULE, + rule_context_add_rule, rule_context_next_rule); + rule_context_load (context, system_filename, user_filename); + + /* XXX Not sure why this is necessary. */ + g_object_set_data_full ( + G_OBJECT (context), "system", system_filename, g_free); + g_object_set_data_full ( + G_OBJECT (context), "user", user_filename, g_free); + + /* XXX I don't really understand what this does. */ + rule = filter_rule_new (); + part = rule_context_next_part (context, NULL); + if (part == NULL) + g_warning ( + "Could not load %s search; no parts.", + class->type_module->name); + else + filter_rule_add_part (rule, filter_part_clone (part)); + + g_free (system_filename); + g_free (user_filename); + + /* Hand the context off to the search bar. */ + widget = e_shell_view_get_content_widget (shell_view); + widget = e_shell_content_get_search_bar (E_SHELL_CONTENT (widget)); + e_search_bar_set_context (E_SEARCH_BAR (widget), context); + + g_object_unref (context); +} + static void shell_view_set_page_num (EShellView *shell_view, gint page_num) @@ -205,15 +272,19 @@ static void shell_view_constructed (GObject *object) { EShellViewClass *class; + EShellView *shell_view; GtkWidget *sidebar; + shell_view = E_SHELL_VIEW (object); class = E_SHELL_VIEW_GET_CLASS (object); - sidebar = e_shell_view_get_sidebar_widget (E_SHELL_VIEW (object)); + sidebar = e_shell_view_get_sidebar_widget (shell_view); e_shell_sidebar_set_icon_name ( E_SHELL_SIDEBAR (sidebar), class->icon_name); e_shell_sidebar_set_primary_text ( E_SHELL_SIDEBAR (sidebar), class->label); + shell_view_setup_search_context (shell_view); + /* XXX GObjectClass doesn't implement constructed(), so we will. * Then subclasses won't have to check the function pointer * before chaining up. @@ -369,6 +440,9 @@ e_shell_view_set_title (EShellView *shell_view, { g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); + if (title == NULL) + title = E_SHELL_VIEW_GET_CLASS (shell_view)->label; + g_free (shell_view->priv->title); shell_view->priv->title = g_strdup (title); diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h index a13efcf4b4..5deeac0f31 100644 --- a/shell/e-shell-view.h +++ b/shell/e-shell-view.h @@ -92,8 +92,8 @@ void e_shell_view_set_view_instance (EShellView *shell_view, EShellWindow * e_shell_view_get_window (EShellView *shell_view); gboolean e_shell_view_is_selected (EShellView *shell_view); gint e_shell_view_get_page_num (EShellView *shell_view); -GtkWidget * e_shell_view_get_content_widget (EShellView *shell_view); -GtkWidget * e_shell_view_get_sidebar_widget (EShellView *shell_view); +GtkWidget * e_shell_view_get_content_widget (EShellView *shell_view); +GtkWidget * e_shell_view_get_sidebar_widget (EShellView *shell_view); GtkWidget * e_shell_view_get_taskbar_widget (EShellView *shell_view); void e_shell_view_changed (EShellView *shell_view); diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c index 44d82e8bbe..9983d77f36 100644 --- a/shell/e-shell-window-actions.c +++ b/shell/e-shell-window-actions.c @@ -22,10 +22,10 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -858,6 +858,77 @@ action_quit_cb (GtkAction *action, e_shell_quit (shell); } +static void +action_search_advanced_cb (GtkAction *action, + EShellWindow *shell_window) +{ +} + +static void +action_search_clear_cb (GtkAction *action, + EShellWindow *shell_window) +{ + EShellView *shell_view; + GtkWidget *widget; + const gchar *view_name; + + /* Dig up the search bar. */ + view_name = e_shell_window_get_current_view (shell_window); + shell_view = e_shell_window_get_view (shell_window, view_name); + widget = e_shell_view_get_content_widget (shell_view); + widget = e_shell_content_get_search_bar (E_SHELL_CONTENT (widget)); + + e_search_bar_set_search_text (E_SEARCH_BAR (widget), NULL); +} + +static void +action_search_edit_cb (GtkAction *action, + EShellWindow *shell_window) +{ + EShellView *shell_view; + RuleContext *context; + RuleEditor *editor; + GtkWidget *widget; + const gchar *filename; + const gchar *view_name; + + /* Dig up the search bar. */ + view_name = e_shell_window_get_current_view (shell_window); + shell_view = e_shell_window_get_view (shell_window, view_name); + widget = e_shell_view_get_content_widget (shell_view); + widget = e_shell_content_get_search_bar (E_SHELL_CONTENT (widget)); + + context = e_search_bar_get_context (E_SEARCH_BAR (widget)); + g_return_if_fail (context != NULL); + + /* XXX I don't know why the RuleContext can't just store + * system and user file names properly. Fix this? */ + filename = g_object_get_data (G_OBJECT (context), "user"); + g_return_if_fail (filename != NULL); + + editor = rule_editor_new ( + context, FILTER_SOURCE_INCOMING, _("Searches")); + gtk_window_set_title (GTK_WINDOW (editor), _("Searches")); + + if (gtk_dialog_run (GTK_DIALOG (editor)) == GTK_RESPONSE_OK) + rule_context_save (context, filename); + + gtk_widget_destroy (GTK_WIDGET (editor)); +} + +static void +action_search_execute_cb (GtkAction *action, + EShellWindow *shell_window) +{ + gtk_action_set_sensitive (action, FALSE); +} + +static void +action_search_save_cb (GtkAction *action, + EShellWindow *shell_window) +{ +} + static void action_send_receive_cb (GtkAction *action, EShellWindow *shell_window) @@ -910,12 +981,12 @@ static void action_show_switcher_cb (GtkToggleAction *action, EShellWindow *shell_window) { - GtkWidget *widget; + EShellSwitcher *switcher; gboolean active; - widget = shell_window->priv->switcher; + switcher = E_SHELL_SWITCHER (shell_window->priv->switcher); active = gtk_toggle_action_get_active (action); - g_object_set (widget, "visible", active, NULL); + e_shell_switcher_set_visible (switcher, active); } static void @@ -1102,6 +1173,41 @@ static GtkActionEntry shell_entries[] = { N_("Exit the program"), G_CALLBACK (action_quit_cb) }, + { "search-advanced", + NULL, + N_("_Advanced Search..."), + NULL, + N_("Construct a more advanced search"), + G_CALLBACK (action_search_advanced_cb) }, + + { "search-clear", + GTK_STOCK_CLEAR, + NULL, + "q", + N_("Clear the current search parameters"), + G_CALLBACK (action_search_clear_cb) }, + + { "search-edit", + NULL, + N_("_Edit Saved Searches..."), + NULL, + N_("Manage your saved searches"), + G_CALLBACK (action_search_edit_cb) }, + + { "search-execute", + GTK_STOCK_FIND, + N_("_Find Now"), + NULL, + N_("Execute the current search parameters"), + G_CALLBACK (action_search_execute_cb) }, + + { "search-save", + NULL, + N_("_Save Search..."), + NULL, + N_("Save the current search parameters"), + G_CALLBACK (action_search_save_cb) }, + { "send-receive", "mail-send-receive", N_("Send / _Receive"), @@ -1534,6 +1640,7 @@ e_shell_window_create_shell_view_actions (EShellWindow *shell_window) EShellViewClass *class; GtkRadioAction *action; const gchar *view_name; + gchar *accelerator; gchar *action_name; gchar *tooltip; @@ -1588,8 +1695,14 @@ e_shell_window_create_shell_view_actions (EShellWindow *shell_window) gtk_radio_action_set_group (action, group); group = gtk_radio_action_get_group (action); - gtk_action_group_add_action ( - action_group, GTK_ACTION (action)); + /* The first nine views have accelerators Ctrl+(1-9). */ + if (ii < 9) + accelerator = g_strdup_printf ("%d", ii + 1); + else + accelerator = g_strdup (""); + + gtk_action_group_add_action_with_accel ( + action_group, GTK_ACTION (action), accelerator); e_shell_switcher_add_action (switcher, GTK_ACTION (action)); @@ -1599,6 +1712,7 @@ e_shell_window_create_shell_view_actions (EShellWindow *shell_window) action_name, action_name, GTK_UI_MANAGER_AUTO, FALSE); + g_free (accelerator); g_free (action_name); g_free (tooltip); diff --git a/shell/e-shell-window-actions.h b/shell/e-shell-window-actions.h index f1f9b8a554..2e3595f0f7 100644 --- a/shell/e-shell-window-actions.h +++ b/shell/e-shell-window-actions.h @@ -56,6 +56,16 @@ E_SHELL_WINDOW_ACTION ((window), "quick-reference") #define E_SHELL_WINDOW_ACTION_QUIT(window) \ E_SHELL_WINDOW_ACTION ((window), "quit") +#define E_SHELL_WINDOW_ACTION_SEARCH_ADVANCED(window) \ + E_SHELL_WINDOW_ACTION ((window), "search-advanced") +#define E_SHELL_WINDOW_ACTION_SEARCH_CLEAR(window) \ + E_SHELL_WINDOW_ACTION ((window), "search-clear") +#define E_SHELL_WINDOW_ACTION_SEARCH_EDIT(window) \ + E_SHELL_WINDOW_ACTION ((window), "search-edit") +#define E_SHELL_WINDOW_ACTION_SEARCH_EXECUTE(window) \ + E_SHELL_WINDOW_ACTION ((window), "search-execute") +#define E_SHELL_WINDOW_ACTION_SEARCH_SAVE(window) \ + E_SHELL_WINDOW_ACTION ((window), "search-save") #define E_SHELL_WINDOW_ACTION_SEND_RECEIVE(window) \ E_SHELL_WINDOW_ACTION ((window), "send-receive") #define E_SHELL_WINDOW_ACTION_SHOW_SIDEBAR(window) \ diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c index 5d0a8d3bee..8224ee901a 100644 --- a/shell/e-shell-window-private.c +++ b/shell/e-shell-window-private.c @@ -287,31 +287,27 @@ e_shell_window_private_init (EShellWindow *shell_window) container = priv->content_pane; - widget = gtk_vbox_new (FALSE, 6); + widget = e_shell_switcher_new (); gtk_paned_pack1 (GTK_PANED (container), widget, TRUE, FALSE); + priv->switcher = g_object_ref (widget); gtk_widget_show (widget); widget = gtk_notebook_new (); gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE); gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE); - gtk_paned_pack2 (GTK_PANED (container), widget, TRUE, FALSE); + gtk_paned_pack2 (GTK_PANED (container), widget, TRUE, TRUE); priv->content_notebook = g_object_ref (widget); gtk_widget_show (widget); - container = gtk_paned_get_child1 (GTK_PANED (priv->content_pane)); + container = priv->switcher; widget = gtk_notebook_new (); gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE); gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE); - gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (container), widget); priv->sidebar_notebook = g_object_ref (widget); gtk_widget_show (widget); - widget = e_shell_switcher_new (); - gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); - priv->switcher = g_object_ref (widget); - gtk_widget_show (widget); - container = priv->status_area; widget = e_online_button_new (); diff --git a/shell/e-shell-window-private.h b/shell/e-shell-window-private.h index 81bf254c61..161bb17e0b 100644 --- a/shell/e-shell-window-private.h +++ b/shell/e-shell-window-private.h @@ -25,15 +25,18 @@ #include +#include +#include +#include +#include + #include +#include #include #include #include #include -#include -#include - #define E_SHELL_WINDOW_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ ((obj), E_TYPE_SHELL_WINDOW, EShellWindowPrivate)) diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index c53867b527..8d2e3c1180 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -40,6 +40,27 @@ enum { static gpointer parent_class; +static void +shell_window_update_title (EShellWindow *shell_window) +{ + EShellView *shell_view; + const gchar *view_title; + const gchar *view_name; + gchar *window_title; + + view_name = e_shell_window_get_current_view (shell_window); + shell_view = e_shell_window_get_view (shell_window, view_name); + view_title = e_shell_view_get_title (shell_view); + + if (!e_shell_view_is_selected (shell_view)) + return; + + /* Translators: This is used for the main window title. */ + window_title = g_strdup_printf (_("%s - Evolution"), view_title); + gtk_window_set_title (GTK_WINDOW (shell_window), window_title); + g_free (window_title); +} + static EShellView * shell_window_new_view (EShellWindow *shell_window, GType shell_view_type, @@ -78,6 +99,10 @@ shell_window_new_view (EShellWindow *shell_window, widget = e_shell_view_get_taskbar_widget (shell_view); gtk_notebook_append_page (notebook, widget, NULL); + g_signal_connect_swapped ( + shell_view, "notify::title", + G_CALLBACK (shell_window_update_title), shell_window); + return shell_view; } @@ -473,6 +498,7 @@ e_shell_window_set_current_view (EShellWindow *shell_window, shell_window->priv->current_view = view_name; g_object_notify (G_OBJECT (shell_window), "current-view"); + shell_window_update_title (shell_window); e_shell_window_update_gal_view_menu (shell_window); /* Notify all loaded views. */ diff --git a/shell/test/e-test-shell-module.c b/shell/test/e-test-shell-module.c index 2aec01a444..b09e589d74 100644 --- a/shell/test/e-test-shell-module.c +++ b/shell/test/e-test-shell-module.c @@ -29,6 +29,7 @@ #define MODULE_NAME "test" #define MODULE_ALIASES "monkey" #define MODULE_SCHEMES "" +#define MODULE_SEARCHES NULL #define MODULE_SORT_ORDER 100 /* Module Entry Point */ @@ -131,6 +132,7 @@ static EShellModuleInfo module_info = { MODULE_NAME, MODULE_ALIASES, MODULE_SCHEMES, + MODULE_SEARCHES, MODULE_SORT_ORDER, /* Methods */ -- cgit v1.2.3