diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2003-11-11 05:21:47 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2003-11-11 05:21:47 +0800 |
commit | d40faeb22e27c8df9e8d626fcbea2efe1741d768 (patch) | |
tree | 509778f727256a431a87dd2f420e2f6d53ed7b94 | |
parent | 8648d27d3a1d02fe76e639f521241eae8fed679d (diff) | |
download | gsoc2013-evolution-d40faeb22e27c8df9e8d626fcbea2efe1741d768.tar.gz gsoc2013-evolution-d40faeb22e27c8df9e8d626fcbea2efe1741d768.tar.zst gsoc2013-evolution-d40faeb22e27c8df9e8d626fcbea2efe1741d768.zip |
New member "component_alias". (component_view_new): Get a new "alias" arg,
* e-shell-window.c (struct _ComponentView): New member
"component_alias".
(component_view_new): Get a new "alias" arg, set the member in the
struct accordingly.
(component_view_free): Free ->component_alias.
(setup_widgets): Pass the alias from the ComponentInfo to
e_component_view().
(switch_view): New utility function.
(sidebar_button_selected_callback): Use it.
(e_shell_window_switch_to_component): New public function.
(e_shell_window_new): Switch to the component whose id is in the
/apps/evolution/shell/view_defaults/component_id GConf key.
* apps_evolution_shell.schemas: Removed view_defaults/folder_path.
New key view_defaults/component_id.
* e-component-registry.c (component_info_free): Free ->alias.
(component_info_new): Get an "alias" arg and set the member
accordingly.
(query_components): Remove debugging messages. Get an
"evolution:component_alias" property from the component and set
the alias from that.
* e-component-registry.h (struct _EComponentInfo): New member
"alias".
svn path=/trunk/; revision=23265
-rw-r--r-- | shell/ChangeLog | 28 | ||||
-rw-r--r-- | shell/apps_evolution_shell.schemas | 8 | ||||
-rw-r--r-- | shell/e-component-registry.c | 14 | ||||
-rw-r--r-- | shell/e-component-registry.h | 2 | ||||
-rw-r--r-- | shell/e-shell-window.c | 100 | ||||
-rw-r--r-- | shell/e-shell-window.h | 3 |
6 files changed, 128 insertions, 27 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index 98165b812a..1a5a3110d6 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,31 @@ +2003-11-10 Ettore Perazzoli <ettore@ximian.com> + + * e-shell-window.c (struct _ComponentView): New member + "component_alias". + (component_view_new): Get a new "alias" arg, set the member in the + struct accordingly. + (component_view_free): Free ->component_alias. + (setup_widgets): Pass the alias from the ComponentInfo to + e_component_view(). + (switch_view): New utility function. + (sidebar_button_selected_callback): Use it. + (e_shell_window_switch_to_component): New public function. + (e_shell_window_new): Switch to the component whose id is in the + /apps/evolution/shell/view_defaults/component_id GConf key. + + * apps_evolution_shell.schemas: Removed view_defaults/folder_path. + New key view_defaults/component_id. + + * e-component-registry.c (component_info_free): Free ->alias. + (component_info_new): Get an "alias" arg and set the member + accordingly. + (query_components): Remove debugging messages. Get an + "evolution:component_alias" property from the component and set + the alias from that. + + * e-component-registry.h (struct _EComponentInfo): New member + "alias". + 2003-11-07 JP Rosevear <jpr@ximian.com> * Makefile.am: make sure the marshal header is in the sources too diff --git a/shell/apps_evolution_shell.schemas b/shell/apps_evolution_shell.schemas index d8ad7802d7..e58974edd2 100644 --- a/shell/apps_evolution_shell.schemas +++ b/shell/apps_evolution_shell.schemas @@ -213,13 +213,13 @@ </schema> <schema> - <key>/schemas/apps/evolution/shell/view_defaults/folder_path</key> - <applyto>/apps/evolution/shell/view_defaults/folder_path</applyto> + <key>/schemas/apps/evolution/shell/view_defaults/component_id</key> + <applyto>/apps/evolution/shell/view_defaults/component_id</applyto> <owner>evolution</owner> <type>string</type> <locale name="C"> - <default>/Summary</default> - <short>Path to the folder to be displayed by default</short> + <default>mail</default> + <short>ID or alias of the component to be shown by default at start-up.</short> </locale> </schema> diff --git a/shell/e-component-registry.c b/shell/e-component-registry.c index 66d23a2f35..474ed06576 100644 --- a/shell/e-component-registry.c +++ b/shell/e-component-registry.c @@ -53,6 +53,7 @@ struct _EComponentRegistryPrivate { static EComponentInfo * component_info_new (const char *id, + const char *alias, const char *button_label, int sort_order, GdkPixbuf *button_icon) @@ -60,6 +61,7 @@ component_info_new (const char *id, EComponentInfo *info = g_new0 (EComponentInfo, 1); info->id = g_strdup (id); + info->alias = g_strdup (alias); info->button_label = g_strdup (button_label); info->sort_order = sort_order; @@ -73,6 +75,7 @@ static void component_info_free (EComponentInfo *info) { g_free (info->id); + g_free (info->alias); g_free (info->button_label); if (info->iface != NULL) @@ -118,6 +121,7 @@ query_components (EComponentRegistry *registry) for (i = 0; i < info_list->_length; i++) { const char *id; const char *label; + const char *alias; const char *icon_name; const char *sort_order_string; GdkPixbuf *icon; @@ -125,18 +129,16 @@ query_components (EComponentRegistry *registry) id = info_list->_buffer[i].iid; label = bonobo_server_info_prop_lookup (& info_list->_buffer[i], "evolution:button_label", language_list); - if (label == NULL) { - g_print ("no label for %s\n", id); + if (label == NULL) label = g_strdup (_("Unknown")); - } + + alias = bonobo_server_info_prop_lookup (& info_list->_buffer[i], "evolution:component_alias", NULL); icon_name = bonobo_server_info_prop_lookup (& info_list->_buffer[i], "evolution:button_icon", NULL); if (icon_name == NULL) { icon = NULL; - g_print ("no icon for %s\n", id); } else { char *full_path = e_shell_get_icon_path (icon_name, TRUE); - g_print ("icon %s\n", full_path); icon = gdk_pixbuf_new_from_file (full_path, NULL); } @@ -148,7 +150,7 @@ query_components (EComponentRegistry *registry) sort_order = atoi (sort_order_string); registry->priv->infos = g_slist_prepend (registry->priv->infos, - component_info_new (id, label, sort_order, icon)); + component_info_new (id, alias, label, sort_order, icon)); if (icon != NULL) g_object_unref (icon); diff --git a/shell/e-component-registry.h b/shell/e-component-registry.h index bc72dd19c4..584d7aa209 100644 --- a/shell/e-component-registry.h +++ b/shell/e-component-registry.h @@ -61,6 +61,8 @@ struct _EComponentRegistryClass { struct _EComponentInfo { char *id; + char *alias; + /* NULL if not activated. */ GNOME_Evolution_Component iface; diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index 24a310cdb5..0e8dea989e 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -44,6 +44,8 @@ #include <bonobo/bonobo-ui-util.h> #include <bonobo/bonobo-widget.h> +#include <gconf/gconf-client.h> + #include <string.h> @@ -58,6 +60,7 @@ static GtkWindowClass *parent_class = NULL; struct _ComponentView { int button_id; char *component_id; + char *component_alias; GtkWidget *sidebar_widget; GtkWidget *view_widget; @@ -91,11 +94,12 @@ struct _EShellWindowPrivate { /* ComponentView handling. */ static ComponentView * -component_view_new (const char *id, int button_id) +component_view_new (const char *id, const char *alias, int button_id) { ComponentView *view = g_new0 (ComponentView, 1); view->component_id = g_strdup (id); + view->component_alias = g_strdup (alias); view->button_id = button_id; view->notebook_page_num = -1; @@ -106,6 +110,7 @@ static void component_view_free (ComponentView *view) { g_free (view->component_id); + g_free (view->component_alias); g_free (view); } @@ -141,9 +146,6 @@ component_view_activate (ComponentView *view) bonobo_control_frame_control_activate (sidebar_control_frame); } - -/* Utility functions. */ - static void init_view (EShellWindow *window, ComponentView *view) @@ -226,6 +228,34 @@ init_view (EShellWindow *window, bonobo_object_release_unref (component_iface, NULL); } +static void +switch_view (EShellWindow *window, ComponentView *component_view) +{ + EShellWindowPrivate *priv = window->priv; + GConfClient *gconf_client = gconf_client_get_default (); + + if (component_view->sidebar_widget == NULL) { + init_view (window, component_view); + } else { + if (priv->current_view != NULL) + component_view_deactivate (priv->current_view); + priv->current_view = component_view; + component_view_activate (component_view); + + gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->view_notebook), component_view->notebook_page_num); + gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->sidebar_notebook), component_view->notebook_page_num); + } + + gconf_client_set_string (gconf_client, "/apps/evolution/shell/view_defaults/component_id", + (component_view->component_alias != NULL + ? component_view->component_alias + : component_view->component_id), + NULL); + + g_object_unref (gconf_client); +} + + /* Callbacks. */ @@ -246,21 +276,11 @@ sidebar_button_selected_callback (ESidebar *sidebar, } if (component_view == NULL) { - g_warning ("Unknown component id %d", button_id); + g_warning ("Unknown component button id %d", button_id); return; } - if (component_view->sidebar_widget == NULL) { - init_view (window, component_view); - } else { - if (priv->current_view != NULL) - component_view_deactivate (priv->current_view); - priv->current_view = component_view; - component_view_activate (component_view); - - gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->view_notebook), component_view->notebook_page_num); - gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->sidebar_notebook), component_view->notebook_page_num); - } + switch_view (window, component_view); } @@ -298,7 +318,7 @@ setup_widgets (EShellWindow *window) button_id = 0; for (p = e_component_registry_peek_list (registry); p != NULL; p = p->next) { EComponentInfo *info = p->data; - ComponentView *view = component_view_new (info->id, button_id); + ComponentView *view = component_view_new (info->id, info->alias, button_id); window->priv->component_views = g_slist_prepend (window->priv->component_views, view); e_sidebar_add_button (E_SIDEBAR (priv->sidebar), info->button_label, info->button_icon, button_id); @@ -374,6 +394,8 @@ e_shell_window_new (EShell *shell) EShellWindow *window = g_object_new (e_shell_window_get_type (), NULL); EShellWindowPrivate *priv = window->priv; BonoboUIContainer *ui_container; + GConfClient *gconf_client; + char *default_component_id; if (bonobo_window_construct (BONOBO_WINDOW (window), bonobo_ui_container_new (), @@ -406,10 +428,54 @@ e_shell_window_new (EShell *shell) gtk_window_set_default_size (GTK_WINDOW (window), 640, 480); + gconf_client = gconf_client_get_default (); + default_component_id = gconf_client_get_string (gconf_client, + "/apps/evolution/shell/view_defaults/component_id", + NULL); + g_object_unref (gconf_client); + + if (default_component_id == NULL) { + e_shell_window_switch_to_component (window, "mail"); + } else { + e_shell_window_switch_to_component (window, default_component_id); + g_free (default_component_id); + } + return GTK_WIDGET (window); } +void +e_shell_window_switch_to_component (EShellWindow *window, const char *component_id) +{ + EShellWindowPrivate *priv = window->priv; + ComponentView *view = NULL; + GSList *p; + + g_return_if_fail (E_IS_SHELL_WINDOW (window)); + g_return_if_fail (component_id != NULL); + + for (p = priv->component_views; p != NULL; p = p->next) { + ComponentView *this_view = p->data; + + if (strcmp (this_view->component_id, component_id) == 0 + || (this_view->component_alias != NULL + && strcmp (this_view->component_alias, component_id) == 0)) + { + view = p->data; + break; + } + } + + if (view == NULL) { + g_warning ("Unknown component %s", component_id); + return; + } + + switch_view (window, view); +} + + EShell * e_shell_window_peek_shell (EShellWindow *window) { diff --git a/shell/e-shell-window.h b/shell/e-shell-window.h index f23ac67d31..1a012fe20a 100644 --- a/shell/e-shell-window.h +++ b/shell/e-shell-window.h @@ -54,6 +54,9 @@ GType e_shell_window_get_type (void); GtkWidget *e_shell_window_new (EShell *shell); +void e_shell_window_switch_to_component (EShellWindow *shell, + const char *component_id); + EShell *e_shell_window_peek_shell (EShellWindow *window); BonoboUIComponent *e_shell_window_peek_bonobo_ui_component (EShellWindow *window); |