diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ChangeLog | 52 | ||||
-rw-r--r-- | shell/Evolution-Shell.idl | 3 | ||||
-rw-r--r-- | shell/Evolution-Shortcuts.idl | 51 | ||||
-rw-r--r-- | shell/Evolution.idl | 1 | ||||
-rw-r--r-- | shell/Makefile.am | 3 | ||||
-rw-r--r-- | shell/e-corba-shortcuts.c | 317 | ||||
-rw-r--r-- | shell/e-corba-shortcuts.h | 67 | ||||
-rw-r--r-- | shell/e-shell-folder-title-bar.c | 32 | ||||
-rw-r--r-- | shell/e-shell.c | 106 | ||||
-rw-r--r-- | shell/e-shortcuts-view.c | 45 | ||||
-rw-r--r-- | shell/e-storage-set-view.c | 8 | ||||
-rw-r--r-- | shell/evolution-shell-client.c | 80 | ||||
-rw-r--r-- | shell/evolution-shell-client.h | 3 | ||||
-rw-r--r-- | shell/evolution-shell-component.c | 2 | ||||
-rw-r--r-- | shell/evolution-test-component.c | 58 |
15 files changed, 734 insertions, 94 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index 1f62afe776..e9e5551161 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,55 @@ +2001-08-04 Ettore Perazzoli <ettore@ximian.com> + + * e-shell-folder-title-bar.c (e_shell_folder_title_bar_construct): + Add some padding to the label so that the title doesn't move + around when you switch between pop-up and non-pop-up folder bar. + Also, change all the GtkLabels to be GtkClippedLabels instead. + (e_shell_folder_title_bar_set_title): Updated to use + EClippedLabels instead of GtkLabels. + (e_shell_folder_title_bar_set_folder_bar_label): Likewise. + + * e-shell.c (impl_Shell__get_displayName): New, implementation for + the `displayName' attribute. + + * Evolution-Shell.idl: Added readonly attribute `displayName' to + get the canonicalized X11 display name for the shell. + + * e-shell.c (e_shell_construct): Ooops. Return + `E_SHELL_CONSTRUCT_RESULT_CANNOTREGISTER' if the OAF registration + fails, not `E_SHELL_CONSTRUCT_RESULT_GENERICERROR'. + + * e-shortcuts-view.c (rename_group_cb): Get the toplevel from the + shortcuts view, not the widget. + (rename_shortcut_cb): Likewise. + (show_new_group_dialog): Changed to use `e_request_string()'. + + * evolution-test-component.c: Add the %FALSE value for the + `user_creatable' field in the `folder_types' entry. + + * evolution-shell-client.c: New member `shortcuts_interface' in + `EvolutionShellClientPrivate'. + (destroy): Unref it if not CORBA_OBJECT_NIL. + (init): Init to CORBA_OBJECT_NIL. + (query_shell_interface): New helper function to query an interface + on the shell and spit out warnings if it fails. + (evolution_shell_client_construct): Use it to query the ::Activity + interface. Also query the ::Shortcuts interface and set the + `shortcuts_interface' member to point to it. + + * e-shell.c: New member `corba_shortcuts' in `EShellPrivate'. + (init): Init to NULL. + (setup_shortcuts_interface): Helper function to add the + ::Shortcuts CORBA interface to the shell. + (e_shell_construct): Call it. + + * e-corba-shortcuts.c, e-corba-shortcuts.h: New objects + implementing the `Evolution::Shortcuts' CORBA interface. + + * Evolution-Shortcuts.idl: New interface for accessing the + shortcuts in the shell. + + * e-shell.c (e_shell_get_config_db): Moved down. + 2001-08-03 Christopher James Lahey <clahey@ximian.com> * e-storage-set-view.c (tree_drag_data_received): Some paths here diff --git a/shell/Evolution-Shell.idl b/shell/Evolution-Shell.idl index 86d54741c9..387fef7249 100644 --- a/shell/Evolution-Shell.idl +++ b/shell/Evolution-Shell.idl @@ -25,6 +25,9 @@ module Evolution { typedef sequence<string> FolderTypeNameList; + /* The X display name. */ + readonly attribute string displayName; + /** * getComponentByType: * @type: name of a valid folder type diff --git a/shell/Evolution-Shortcuts.idl b/shell/Evolution-Shortcuts.idl new file mode 100644 index 0000000000..7ffb55a164 --- /dev/null +++ b/shell/Evolution-Shortcuts.idl @@ -0,0 +1,51 @@ +/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Interface for the Evolution shortcuts. + * + * Authors: + * Ettore Perazzoli <ettore@ximian.com> + * + * Copyright (C) 2001 Ximian, Inc. + */ + +#include <Bonobo.idl> + +module GNOME { +module Evolution { + + interface Shortcuts : Bonobo::Unknown { + + struct Shortcut { + string uri; + string name; + string type; + }; + typedef sequence <Shortcut> ShortcutList; + + struct Group { + string name; + ShortcutList shortcuts; + }; + typedef sequence<Group> GroupList; + + exception NotFound {}; + + readonly attribute GroupList groups; // FIXME: Could be non-readonly + + void add (in short group_num, in short position, in Shortcut shortcut) + raises (NotFound); + void remove (in short group_num, in short item_num) + raises (NotFound); + Shortcut get (in short group_num, in short item_num) + raises (NotFound); + + void addGroup (in short position, in string name); + void removeGroup (in short group_num) + raises (NotFound); + Group getGroup (in short group_num) + raises (NotFound); + + }; + +}; +}; diff --git a/shell/Evolution.idl b/shell/Evolution.idl index 79ae7b143a..f653d8244f 100644 --- a/shell/Evolution.idl +++ b/shell/Evolution.idl @@ -17,6 +17,7 @@ #include <Evolution-ShellComponentDnd.idl> #include <Evolution-Offline.idl> #include <Evolution-ShellView.idl> +#include <Evolution-Shortcuts.idl> #include <Evolution-Storage.idl> #include <Evolution-StorageSetView.idl> #include <Evolution-Shell.idl> diff --git a/shell/Makefile.am b/shell/Makefile.am index 2b5f318b7e..19fa11e45f 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -26,6 +26,7 @@ IDLS = \ Evolution-ShellComponent.idl \ Evolution-ShellComponentDnd.idl \ Evolution-ShellView.idl \ + Evolution-Shortcuts.idl \ Evolution-Storage.idl \ Evolution-StorageSetView.idl \ Evolution.idl @@ -95,6 +96,8 @@ evolution_SOURCES = \ e-activity-handler.h \ e-component-registry.c \ e-component-registry.h \ + e-corba-shortcuts.c \ + e-corba-shortcuts.h \ e-corba-storage-registry.c \ e-corba-storage-registry.h \ e-corba-storage.c \ diff --git a/shell/e-corba-shortcuts.c b/shell/e-corba-shortcuts.c new file mode 100644 index 0000000000..20458f587a --- /dev/null +++ b/shell/e-corba-shortcuts.c @@ -0,0 +1,317 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-corba-shortcuts.c + * + * Copyright (C) 2001 Ximian, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Ettore Perazzoli <ettore@ximian.com> + */ + +/* FIXME: Doesn't throw exceptions properly. */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "e-corba-shortcuts.h" + +#include "e-util/e-corba-utils.h" + +#include <gal/util/e-util.h> + + +#define PARENT_TYPE bonobo_x_object_get_type () +static BonoboXObjectClass *parent_class = NULL; + +struct _ECorbaShortcutsPrivate { + EShortcuts *shortcuts; +}; + + +/* Utility functions. */ + +static const char * +string_from_corba (CORBA_char *corba_string) +{ + if (corba_string[0] == '\0') + return NULL; + + return corba_string; +} + +static void +shortcut_list_to_corba (const GSList *shortcut_list, + GNOME_Evolution_Shortcuts_ShortcutList *shortcut_list_return) +{ + GNOME_Evolution_Shortcuts_Shortcut *buffer; + const GSList *p; + int num_shortcuts; + int i; + + num_shortcuts = g_slist_length ((GSList *) shortcut_list); /* safe cast, GLib sucks */ + + shortcut_list_return->_maximum = num_shortcuts; + shortcut_list_return->_length = num_shortcuts; + + buffer = CORBA_sequence_GNOME_Evolution_Shortcuts_Shortcut_allocbuf (num_shortcuts); + shortcut_list_return->_buffer = buffer; + + for (p = shortcut_list, i = 0; p != NULL; p = p->next, i++) { + const EShortcutItem *item; + + item = (const EShortcutItem *) p->data; + + buffer[i].uri = CORBA_string_dup (e_safe_corba_string (item->uri)); + buffer[i].name = CORBA_string_dup (e_safe_corba_string (item->name)); + buffer[i].type = CORBA_string_dup (e_safe_corba_string (item->type)); + } +} + + +/* GtkObject methods. */ + +static void +impl_destroy (GtkObject *object) +{ + ECorbaShortcuts *corba_shortcuts; + ECorbaShortcutsPrivate *priv; + + corba_shortcuts = E_CORBA_SHORTCUTS (object); + priv = corba_shortcuts->priv; + + gtk_object_unref (GTK_OBJECT (priv->shortcuts)); + + g_free (priv); + + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + + +static void +impl_add (PortableServer_Servant servant, + const CORBA_short group_num, + const CORBA_short position, + const GNOME_Evolution_Shortcuts_Shortcut *shortcut, + CORBA_Environment *ev) +{ + ECorbaShortcuts *corba_shortcuts; + ECorbaShortcutsPrivate *priv; + + corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant)); + priv = corba_shortcuts->priv; + + e_shortcuts_add_shortcut (priv->shortcuts, group_num, position, + string_from_corba (shortcut->uri), + string_from_corba (shortcut->name), + 0, + string_from_corba (shortcut->type)); +} + +static void +impl_remove (PortableServer_Servant servant, + const CORBA_short group_num, + const CORBA_short item_num, + CORBA_Environment *ev) +{ + ECorbaShortcuts *corba_shortcuts; + ECorbaShortcutsPrivate *priv; + + corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant)); + priv = corba_shortcuts->priv; + + e_shortcuts_remove_shortcut (priv->shortcuts, group_num, item_num); +} + +static GNOME_Evolution_Shortcuts_Shortcut * +impl_get (PortableServer_Servant servant, + const CORBA_short group_num, + const CORBA_short item_num, + CORBA_Environment *ev) +{ + ECorbaShortcuts *corba_shortcuts; + ECorbaShortcutsPrivate *priv; + GNOME_Evolution_Shortcuts_Shortcut *retval; + const EShortcutItem *item; + + corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant)); + priv = corba_shortcuts->priv; + + item = e_shortcuts_get_shortcut (priv->shortcuts, group_num, item_num); + if (item == NULL) { + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_GNOME_Evolution_Shortcuts_NotFound, NULL); + return NULL; + } + + retval = GNOME_Evolution_Shortcuts_Shortcut__alloc (); + retval->uri = CORBA_string_dup (e_safe_corba_string (item->uri)); + retval->name = CORBA_string_dup (e_safe_corba_string (item->name)); + retval->type = CORBA_string_dup (e_safe_corba_string (item->type)); + + return retval; +} + +static void +impl_addGroup (PortableServer_Servant servant, + const CORBA_short position, + const CORBA_char *name, + CORBA_Environment *ev) +{ + ECorbaShortcuts *corba_shortcuts; + ECorbaShortcutsPrivate *priv; + + corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant)); + priv = corba_shortcuts->priv; + + e_shortcuts_add_group (priv->shortcuts, position, name); +} + +static void +impl_removeGroup (PortableServer_Servant servant, + const CORBA_short group_num, + CORBA_Environment *ev) +{ + ECorbaShortcuts *corba_shortcuts; + ECorbaShortcutsPrivate *priv; + + corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant)); + priv = corba_shortcuts->priv; + + e_shortcuts_remove_group (priv->shortcuts, group_num); +} + +static GNOME_Evolution_Shortcuts_Group * +impl_getGroup (PortableServer_Servant servant, + const CORBA_short group_num, + CORBA_Environment *ev) +{ + ECorbaShortcuts *corba_shortcuts; + ECorbaShortcutsPrivate *priv; + GNOME_Evolution_Shortcuts_Group *group; + const GSList *list; + + corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant)); + priv = corba_shortcuts->priv; + + list = e_shortcuts_get_shortcuts_in_group (priv->shortcuts, group_num); + + group = GNOME_Evolution_Shortcuts_Group__alloc (); + + group->name = CORBA_string_dup (e_shortcuts_get_group_title (priv->shortcuts, group_num)); + + shortcut_list_to_corba (list, & group->shortcuts); + + return group; +} + +static CORBA_sequence_GNOME_Evolution_Shortcuts_Group * +impl__get_groups (PortableServer_Servant servant, + CORBA_Environment *ev) +{ + GNOME_Evolution_Shortcuts_GroupList *list; + ECorbaShortcuts *corba_shortcuts; + ECorbaShortcutsPrivate *priv; + GSList *group_titles; + const GSList *p; + int i; + + corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant)); + priv = corba_shortcuts->priv; + + list = GNOME_Evolution_Shortcuts_GroupList__alloc (); + list->_length = e_shortcuts_get_num_groups (priv->shortcuts); + list->_maximum = list->_length; + list->_buffer = CORBA_sequence_GNOME_Evolution_Shortcuts_Group_allocbuf (list->_maximum); + + CORBA_sequence_set_release (list, TRUE); + + group_titles = e_shortcuts_get_group_titles (priv->shortcuts); + for (p = group_titles, i = 0; p != NULL; p = p->next, i ++) { + char *group_title; + const GSList *shortcuts; + + group_title = (char *) p->data; + + shortcuts = e_shortcuts_get_shortcuts_in_group (priv->shortcuts, i); + + list->_buffer[i].name = CORBA_string_dup (group_title); + shortcut_list_to_corba (shortcuts, &list->_buffer[i].shortcuts); + + g_free (group_title); + } + + g_slist_free (group_titles); + + return list; +} + + +static void +class_init (GtkObjectClass *object_class) +{ + ECorbaShortcutsClass *corba_shortcuts_class; + POA_GNOME_Evolution_Shortcuts__epv *epv; + + parent_class = gtk_type_class (PARENT_TYPE); + + object_class->destroy = impl_destroy; + + corba_shortcuts_class = E_CORBA_SHORTCUTS_CLASS (object_class); + + epv = & corba_shortcuts_class->epv; + epv->add = impl_add; + epv->remove = impl_remove; + epv->get = impl_get; + epv->addGroup = impl_addGroup; + epv->removeGroup = impl_removeGroup; + epv->getGroup = impl_getGroup; + epv->_get_groups = impl__get_groups; +} + +static void +init (ECorbaShortcuts *corba_shortcuts) +{ + ECorbaShortcutsPrivate *priv; + + priv = g_new (ECorbaShortcutsPrivate, 1); + priv->shortcuts = NULL; + + corba_shortcuts->priv = priv; +} + + +ECorbaShortcuts * +e_corba_shortcuts_new (EShortcuts *shortcuts) +{ + ECorbaShortcuts *corba_shortcuts; + + g_return_val_if_fail (shortcuts != NULL, NULL); + g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), NULL); + + corba_shortcuts = gtk_type_new (e_corba_shortcuts_get_type ()); + + gtk_object_ref (GTK_OBJECT (shortcuts)); + corba_shortcuts->priv->shortcuts = shortcuts; + + return corba_shortcuts; +} + + +E_MAKE_X_TYPE (e_corba_shortcuts, "ECorbaShortcuts", ECorbaShortcuts, + class_init, init, PARENT_TYPE, + POA_GNOME_Evolution_Shortcuts__init, + GTK_STRUCT_OFFSET (ECorbaShortcutsClass, epv)) diff --git a/shell/e-corba-shortcuts.h b/shell/e-corba-shortcuts.h new file mode 100644 index 0000000000..f46ac2ed6d --- /dev/null +++ b/shell/e-corba-shortcuts.h @@ -0,0 +1,67 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-corba-shortcuts.h + * + * Copyright (C) 2001 Ximian, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Ettore Perazzoli <ettore@ximian.com> + */ + +#ifndef _E_CORBA_SHORTCUTS_H_ +#define _E_CORBA_SHORTCUTS_H_ + +#include "e-shortcuts.h" + +#include <bonobo/bonobo-xobject.h> + +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus */ + +#define E_TYPE_CORBA_SHORTCUTS (e_corba_shortcuts_get_type ()) +#define E_CORBA_SHORTCUTS(obj) (GTK_CHECK_CAST ((obj), E_TYPE_CORBA_SHORTCUTS, ECorbaShortcuts)) +#define E_CORBA_SHORTCUTS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_CORBA_SHORTCUTS, ECorbaShortcutsClass)) +#define E_IS_CORBA_SHORTCUTS(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_CORBA_SHORTCUTS)) +#define E_IS_CORBA_SHORTCUTS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_CORBA_SHORTCUTS)) + + +typedef struct _ECorbaShortcuts ECorbaShortcuts; +typedef struct _ECorbaShortcutsPrivate ECorbaShortcutsPrivate; +typedef struct _ECorbaShortcutsClass ECorbaShortcutsClass; + +struct _ECorbaShortcuts { + BonoboXObject parent; + + ECorbaShortcutsPrivate *priv; +}; + +struct _ECorbaShortcutsClass { + BonoboXObjectClass parent_class; + + POA_GNOME_Evolution_Shortcuts__epv epv; +}; + + +GtkType e_corba_shortcuts_get_type (void); +ECorbaShortcuts *e_corba_shortcuts_new (EShortcuts *shortcuts); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _E_CORBA_SHORTCUTS_H_ */ diff --git a/shell/e-shell-folder-title-bar.c b/shell/e-shell-folder-title-bar.c index d69d8d0884..3d43a1e417 100644 --- a/shell/e-shell-folder-title-bar.c +++ b/shell/e-shell-folder-title-bar.c @@ -379,15 +379,15 @@ e_shell_folder_title_bar_construct (EShellFolderTitleBar *folder_title_bar) priv = folder_title_bar->priv; widget = GTK_WIDGET (folder_title_bar); - priv->label = gtk_label_new (""); + priv->label = e_clipped_label_new (""); gtk_misc_set_padding (GTK_MISC (priv->label), 5, 0); gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5); - priv->folder_bar_label = gtk_label_new (""); + priv->folder_bar_label = e_clipped_label_new (""); gtk_misc_set_alignment (GTK_MISC (priv->folder_bar_label), 1.0, 0.5); gtk_widget_show (priv->folder_bar_label); - priv->button_label = gtk_label_new (""); + priv->button_label = e_clipped_label_new (""); gtk_misc_set_padding (GTK_MISC (priv->button_label), 2, 0); gtk_misc_set_alignment (GTK_MISC (priv->button_label), 0.0, 0.5); gtk_widget_show (priv->button_label); @@ -406,9 +406,17 @@ e_shell_folder_title_bar_construct (EShellFolderTitleBar *folder_title_bar) priv->hbox = gtk_hbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (priv->hbox), 2); - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->label, FALSE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->button, FALSE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->folder_bar_label, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->label, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->button, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->folder_bar_label, FALSE, TRUE, 0); + + /* Make the label have a border as large as the button's. + FIXME: This is really hackish. The hardcoded numbers should be OK + as the padding is hardcoded in GtkButton too (see CHILD_SPACING in + gtkbutton.c). */ + gtk_misc_set_padding (GTK_MISC (priv->label), + GTK_WIDGET (priv->button)->style->klass->xthickness + 3, + GTK_WIDGET (priv->button)->style->klass->ythickness + 1); gtk_widget_show (priv->hbox); @@ -466,11 +474,11 @@ e_shell_folder_title_bar_set_title (EShellFolderTitleBar *folder_title_bar, priv = folder_title_bar->priv; if (title == NULL) { - gtk_label_set_text (GTK_LABEL (priv->button_label), _("(Untitled)")); - gtk_label_set_text (GTK_LABEL (priv->label), _("(Untitled)")); + e_clipped_label_set_text (E_CLIPPED_LABEL (priv->button_label), _("(Untitled)")); + e_clipped_label_set_text (E_CLIPPED_LABEL (priv->label), _("(Untitled)")); } else { - gtk_label_set_text (GTK_LABEL (priv->button_label), title); - gtk_label_set_text (GTK_LABEL (priv->label), title); + e_clipped_label_set_text (E_CLIPPED_LABEL (priv->button_label), title); + e_clipped_label_set_text (E_CLIPPED_LABEL (priv->label), title); } /* FIXME: There seems to be a bug in EClippedLabel, this is just a workaround. */ @@ -497,9 +505,9 @@ e_shell_folder_title_bar_set_folder_bar_label (EShellFolderTitleBar *folder_titl priv = folder_title_bar->priv; if (text == NULL) - gtk_label_set_text (GTK_LABEL (priv->folder_bar_label), ""); + e_clipped_label_set_text (E_CLIPPED_LABEL (priv->folder_bar_label), ""); else - gtk_label_set_text (GTK_LABEL (priv->folder_bar_label), text); + e_clipped_label_set_text (E_CLIPPED_LABEL (priv->folder_bar_label), text); /* FIXME: Might want to set the styles somewhere in here too, black text on grey background isn't the best combination */ diff --git a/shell/e-shell.c b/shell/e-shell.c index fb128c6081..0d3043d302 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -32,6 +32,10 @@ #include <libgnome/gnome-i18n.h> #include <libgnome/gnome-util.h> +/* (For the displayName stuff.) */ +#include <gdk/gdkprivate.h> +#include <X11/Xlib.h> + #include <bonobo/bonobo-exception.h> #include <bonobo/bonobo-moniker-util.h> @@ -42,6 +46,7 @@ #include "e-activity-handler.h" #include "e-component-registry.h" +#include "e-corba-shortcuts.h" #include "e-corba-storage-registry.h" #include "e-folder-type-registry.h" #include "e-local-storage.h" @@ -83,11 +88,15 @@ struct _EShellPrivate { EComponentRegistry *component_registry; + /* ::StorageRegistry interface handler. */ ECorbaStorageRegistry *corba_storage_registry; /* <aggregate> */ /* ::Activity interface handler. */ EActivityHandler *activity_handler; /* <aggregate> */ + /* ::Shortcuts interface handler. */ + ECorbaShortcuts *corba_shortcuts; /* <aggregate> */ + /* This object handles going off-line. If the pointer is not NULL, it means we have a going-off-line process in progress. */ EShellOfflineHandler *offline_handler; @@ -119,14 +128,6 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -Bonobo_ConfigDatabase -e_shell_get_config_db (EShell *shell) -{ - g_return_val_if_fail (shell != NULL, CORBA_OBJECT_NIL); - - return shell->priv->db; -} - /* Callback for the folder selection dialog. */ @@ -187,6 +188,23 @@ folder_selection_dialog_folder_selected_cb (EShellFolderSelectionDialog *folder_ /* CORBA interface implementation. */ +static CORBA_char * +impl_Shell__get_displayName (PortableServer_Servant servant, + CORBA_Environment *ev) +{ + char *display_string; + CORBA_char *retval; + + display_string = DisplayString (gdk_display); + if (display_string == NULL) + return CORBA_string_dup (""); + + retval = CORBA_string_dup (display_string); + XFree (display_string); + + return retval; +} + static GNOME_Evolution_ShellComponent impl_Shell_getComponentByType (PortableServer_Servant servant, const CORBA_char *type, @@ -405,12 +423,30 @@ setup_activity_interface (EShell *shell) activity_handler = e_activity_handler_new (); - bonobo_object_add_interface (BONOBO_OBJECT (shell), - BONOBO_OBJECT (activity_handler)); + bonobo_object_add_interface (BONOBO_OBJECT (shell), BONOBO_OBJECT (activity_handler)); priv->activity_handler = activity_handler; } +/* Set up the ::Shortcuts interface. */ + +static void +setup_shortcuts_interface (EShell *shell) +{ + ECorbaShortcuts *corba_shortcuts; + EShellPrivate *priv; + + priv = shell->priv; + + g_assert (priv->shortcuts != NULL); + + corba_shortcuts = e_corba_shortcuts_new (priv->shortcuts); + + bonobo_object_add_interface (BONOBO_OBJECT (shell), BONOBO_OBJECT (corba_shortcuts)); + priv->corba_shortcuts = corba_shortcuts; +} + + /* Initialization of the storages. */ static gboolean @@ -694,6 +730,7 @@ destroy (GtkObject *object) /* No unreffing for these as they are aggregate. */ /* bonobo_object_unref (BONOBO_OBJECT (priv->corba_storage_registry)); */ /* bonobo_object_unref (BONOBO_OBJECT (priv->activity_handler)); */ + /* bonobo_object_unref (BONOBO_OBJECT (priv->corba_shortcuts)); */ /* FIXME. Maybe we should do something special here. */ if (priv->offline_handler != NULL) @@ -740,6 +777,7 @@ class_init (EShellClass *klass) gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); epv = & klass->epv; + epv->_get_displayName = impl_Shell__get_displayName; epv->getComponentByType = impl_Shell_getComponentByType; epv->createNewView = impl_Shell_createNewView; epv->handleURI = impl_Shell_handleURI; @@ -768,6 +806,7 @@ init (EShell *shell) priv->uri_schema_registry = NULL; priv->corba_storage_registry = NULL; priv->activity_handler = NULL; + priv->corba_shortcuts = NULL; priv->offline_handler = NULL; priv->crash_type_names = NULL; priv->line_status = E_SHELL_LINE_STATUS_ONLINE; @@ -843,7 +882,7 @@ e_shell_construct (EShell *shell, corba_object = bonobo_object_corba_objref (BONOBO_OBJECT (shell)); if (oaf_active_server_register (iid, corba_object) != OAF_REG_SUCCESS) { CORBA_exception_free (&ev); - return E_SHELL_CONSTRUCT_RESULT_GENERICERROR; + return E_SHELL_CONSTRUCT_RESULT_CANNOTREGISTER; } if (! show_splash) { @@ -861,6 +900,19 @@ e_shell_construct (EShell *shell, else setup_components (shell, NULL); + /* Set up the shortcuts. */ + + shortcut_path = g_concat_dir_and_file (local_directory, "shortcuts.xml"); + priv->shortcuts = e_shortcuts_new (priv->storage_set, + priv->folder_type_registry, + shortcut_path); + g_assert (priv->shortcuts != NULL); + + if (e_shortcuts_get_num_groups (priv->shortcuts) == 0) + e_shortcuts_add_default_group (priv->shortcuts); + + g_free (shortcut_path); + /* The local storage depends on the component registry. */ setup_local_storage (shell); @@ -868,25 +920,19 @@ e_shell_construct (EShell *shell, the components, as they might want to use it. */ setup_activity_interface (shell); - /* Now that we have a local storage and an ::Activity interface, we can - tell the components we are here. */ + /* Set up the shortcuts interface. This has to be done after the + shortcuts are actually initialized. */ + + setup_shortcuts_interface (shell); + + /* Now that we have a local storage and all the interfaces set up, we + can tell the components we are here. */ set_owner_on_components (shell); /* Run the intelligent importers to find see if any data needs importing. */ intelligent_importer_init (); - shortcut_path = g_concat_dir_and_file (local_directory, "shortcuts.xml"); - priv->shortcuts = e_shortcuts_new (priv->storage_set, - priv->folder_type_registry, - shortcut_path); - g_assert (priv->shortcuts != NULL); - - if (e_shortcuts_get_num_groups (priv->shortcuts) == 0) - e_shortcuts_add_default_group (priv->shortcuts); - - g_free (shortcut_path); - if (show_splash) gtk_widget_destroy (splash); @@ -1239,8 +1285,7 @@ e_shell_restore_from_settings (EShell *shell) priv = shell->priv; - num_views = bonobo_config_get_long_with_default (priv->db, - "/Shell/Views/NumberOfViews", 0, NULL); + num_views = bonobo_config_get_long_with_default (priv->db, "/Shell/Views/NumberOfViews", 0, NULL); if (num_views == 0) return FALSE; @@ -1500,6 +1545,15 @@ e_shell_go_online (EShell *shell, } +Bonobo_ConfigDatabase +e_shell_get_config_db (EShell *shell) +{ + g_return_val_if_fail (shell != NULL, CORBA_OBJECT_NIL); + + return shell->priv->db; +} + + void e_shell_unregister_all (EShell *shell) { diff --git a/shell/e-shortcuts-view.c b/shell/e-shortcuts-view.c index a1de0689ce..2d9956ebce 100644 --- a/shell/e-shortcuts-view.c +++ b/shell/e-shortcuts-view.c @@ -130,46 +130,20 @@ show_new_group_dialog (EShortcutsView *view) GtkWidget *label; GtkWidget *entry; GtkWidget *box; - const char *group_name; + char *group_name; int button_num; - dialog = gnome_dialog_new (_("Create new shortcut group"), - GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL); + group_name = e_request_string (GTK_WIDGET (gtk_widget_get_toplevel (GTK_WIDGET (view))), + _("Create new shortcut group"), + _("Group name:"), + NULL); - label = gtk_label_new (_("Group name:")); - gtk_widget_show (label); - - entry = gtk_entry_new (); - gtk_widget_show (entry); - - box = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_widget_show (box); - - gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (box), entry, TRUE, TRUE, 0); - - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), box, FALSE, TRUE, 0); - - gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view)))); - gnome_dialog_set_default (GNOME_DIALOG (dialog), 0); - - gtk_widget_grab_focus (entry); - gnome_dialog_editable_enters (GNOME_DIALOG (dialog), GTK_EDITABLE (entry)); - - gtk_widget_show (dialog); - - button_num = gnome_dialog_run (GNOME_DIALOG (dialog)); - if (button_num == -1) - return; - if (button_num != 0) { - gtk_widget_destroy (dialog); + if (group_name == NULL) return; - } - group_name = gtk_entry_get_text (GTK_ENTRY (entry)); e_shortcuts_add_group (view->priv->shortcuts, -1, group_name); - gtk_widget_destroy (dialog); + g_free (group_name); } @@ -291,7 +265,7 @@ rename_group_cb (GtkWidget *widget, old_name = e_shortcuts_get_group_title (shortcuts, menu_data->group_num); - new_name = e_request_string (GTK_WINDOW (gtk_widget_get_toplevel (widget)), + new_name = e_request_string (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (shortcuts_view))), _("Rename Shortcut Group"), _("Rename selected shortcut group to:"), old_name); @@ -452,7 +426,7 @@ rename_shortcut_cb (GtkWidget *widget, shortcut_item = e_shortcuts_get_shortcut (shortcuts, menu_data->group_num, menu_data->item_num); - new_name = e_request_string (GTK_WINDOW (gtk_widget_get_toplevel (widget)), + new_name = e_request_string (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (shortcuts_view))), _("Rename shortcut"), _("Rename selected shortcut to:"), shortcut_item->name); @@ -460,7 +434,6 @@ rename_shortcut_cb (GtkWidget *widget, if (new_name == NULL) return; - e_shortcuts_update_shortcut (shortcuts, menu_data->group_num, menu_data->item_num, shortcut_item->uri, new_name, shortcut_item->unread_count, shortcut_item->type); g_free (new_name); diff --git a/shell/e-storage-set-view.c b/shell/e-storage-set-view.c index 223ed21a28..347e1d87ab 100644 --- a/shell/e-storage-set-view.c +++ b/shell/e-storage-set-view.c @@ -908,6 +908,7 @@ tree_drag_begin (ETree *etree, storage_set_view = E_STORAGE_SET_VIEW (etree); priv = storage_set_view->priv; + g_print ("%s -- %d\n", __FUNCTION__, row); priv->selected_row_path = e_tree_memory_node_get_data (E_TREE_MEMORY(priv->etree_model), path); g_assert (priv->drag_corba_source_interface == CORBA_OBJECT_NIL); @@ -1129,6 +1130,9 @@ tree_drag_motion (ETree *tree, storage_set_view = E_STORAGE_SET_VIEW (tree); priv = storage_set_view->priv; + g_print ("%s -- row %d x %d y %d\n", __FUNCTION__, row, x, y); + path = e_tree_node_at_row (E_TREE (storage_set_view), row); + component_client = get_component_at_node (storage_set_view, path); if (component_client == NULL) return FALSE; @@ -1137,8 +1141,6 @@ tree_drag_motion (ETree *tree, if (dnd_type == NULL) return FALSE; - g_print ("drag_motion %s\n", dnd_type); - if (strcmp (dnd_type, EVOLUTION_PATH_TARGET_TYPE) == 0) return handle_evolution_path_drag_motion (storage_set_view, path, context, time); @@ -1154,6 +1156,8 @@ tree_drag_motion (ETree *tree, folder = get_folder_at_node (storage_set_view, path); + g_print ("drag_motion %s -- %s\n", dnd_type, e_folder_get_name (folder)); + can_handle = GNOME_Evolution_ShellComponentDnd_DestinationFolder_handleMotion (destination_folder_interface, e_folder_get_physical_uri (folder), &corba_context, diff --git a/shell/evolution-shell-client.c b/shell/evolution-shell-client.c index ff737de4c5..f3aaf036d7 100644 --- a/shell/evolution-shell-client.c +++ b/shell/evolution-shell-client.c @@ -36,6 +36,7 @@ struct _EvolutionShellClientPrivate { GNOME_Evolution_Activity activity_interface; + GNOME_Evolution_Shortcuts shortcuts_interface; }; #define PARENT_TYPE bonobo_object_client_get_type () @@ -56,6 +57,38 @@ struct _FolderSelectionListenerServant { }; typedef struct _FolderSelectionListenerServant FolderSelectionListenerServant; + +/* Helper functions. */ + +static CORBA_Object +query_shell_interface (EvolutionShellClient *shell_client, + const char *interface_name) +{ + CORBA_Environment ev; + CORBA_Object interface_object; + EvolutionShellClientPrivate *priv; + + priv = shell_client->priv; + + CORBA_exception_init (&ev); + + interface_object = Bonobo_Unknown_queryInterface (bonobo_object_corba_objref (BONOBO_OBJECT (shell_client)), + interface_name, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("EvolutionShellClient: Error querying interface %s on %p -- %s", + interface_name, shell_client, ev._repo_id); + interface_object = CORBA_OBJECT_NIL; + } else if (CORBA_Object_is_nil (interface_object, &ev)) { + g_warning ("No interface %s for ShellClient %p", interface_name, shell_client); + } + + CORBA_exception_free (&ev); + + return interface_object; +} + + static void impl_FolderSelectionListener_selected (PortableServer_Servant servant, const CORBA_char *uri, @@ -238,6 +271,15 @@ destroy (GtkObject *object) CORBA_Object_release (priv->activity_interface, &ev); } + if (priv->shortcuts_interface != CORBA_OBJECT_NIL) { + Bonobo_Unknown_unref (priv->shortcuts_interface, &ev); + if (ev._major != CORBA_NO_EXCEPTION) + g_warning ("EvolutionShellClient::destroy: " + "Error unreffing the ::Shortcuts interface -- %s\n", + ev._repo_id); + CORBA_Object_release (priv->shortcuts_interface, &ev); + } + CORBA_exception_free (&ev); g_free (priv); @@ -264,7 +306,8 @@ init (EvolutionShellClient *shell_client) EvolutionShellClientPrivate *priv; priv = g_new (EvolutionShellClientPrivate, 1); - priv->activity_interface = CORBA_OBJECT_NIL; + priv->activity_interface = CORBA_OBJECT_NIL; + priv->shortcuts_interface = CORBA_OBJECT_NIL; shell_client->priv = priv; } @@ -281,7 +324,6 @@ void evolution_shell_client_construct (EvolutionShellClient *shell_client, GNOME_Evolution_Shell corba_shell) { - CORBA_Environment ev; EvolutionShellClientPrivate *priv; g_return_if_fail (shell_client != NULL); @@ -290,22 +332,11 @@ evolution_shell_client_construct (EvolutionShellClient *shell_client, bonobo_object_construct (BONOBO_OBJECT (shell_client), (CORBA_Object) corba_shell); - CORBA_exception_init (&ev); - priv = shell_client->priv; g_return_if_fail (priv->activity_interface == CORBA_OBJECT_NIL); - priv->activity_interface = Bonobo_Unknown_queryInterface (bonobo_object_corba_objref (BONOBO_OBJECT (shell_client)), - "IDL:GNOME/Evolution/Activity:1.0", - &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("EvolutionShellClient: Error querying interface ::Activity -- %s", ev._repo_id); - priv->activity_interface = CORBA_OBJECT_NIL; - } else if (CORBA_Object_is_nil (priv->activity_interface, &ev)) { - g_warning ("No ::Activity interface for ShellClient %p", shell_client); - } - - CORBA_exception_free (&ev); + priv->activity_interface = query_shell_interface (shell_client, "IDL:GNOME/Evolution/Activity:1.0"); + priv->shortcuts_interface = query_shell_interface (shell_client, "IDL:GNOME/Evolution/Shortcuts:1.0"); } /** @@ -384,6 +415,25 @@ evolution_shell_client_get_activity_interface (EvolutionShellClient *shell_clien return shell_client->priv->activity_interface; } +/** + * evolution_shell_client_get_activity_interface: + * @shell_client: An EvolutionShellClient object + * + * Get the GNOME::Evolution::Shortcuts for the shell associated to + * @shell_client. + * + * Return value: A CORBA Object represeting the GNOME::Evolution::Shortcuts + * interface. + **/ +GNOME_Evolution_Shortcuts +evolution_shell_client_get_shortcuts_interface (EvolutionShellClient *shell_client) +{ + g_return_val_if_fail (shell_client != NULL, CORBA_OBJECT_NIL); + g_return_val_if_fail (EVOLUTION_IS_SHELL_CLIENT (shell_client), CORBA_OBJECT_NIL); + + return shell_client->priv->shortcuts_interface; +} + /** * evolution_shell_client_get_local_storage: diff --git a/shell/evolution-shell-client.h b/shell/evolution-shell-client.h index f770d39c84..ac23fb98e9 100644 --- a/shell/evolution-shell-client.h +++ b/shell/evolution-shell-client.h @@ -67,7 +67,8 @@ void evolution_shell_client_user_select_folder (EvolutionShe char **uri_return, char **physical_uri_return); -GNOME_Evolution_Activity evolution_shell_client_get_activity_interface (EvolutionShellClient *shell_client); +GNOME_Evolution_Activity evolution_shell_client_get_activity_interface (EvolutionShellClient *shell_client); +GNOME_Evolution_Shortcuts evolution_shell_client_get_shortcuts_interface (EvolutionShellClient *shell_client); GNOME_Evolution_Storage evolution_shell_client_get_local_storage (EvolutionShellClient *shell_client); diff --git a/shell/evolution-shell-component.c b/shell/evolution-shell-component.c index 8bf0f68f10..bd7421c19c 100644 --- a/shell/evolution-shell-component.c +++ b/shell/evolution-shell-component.c @@ -682,4 +682,4 @@ evolution_shell_component_get_owner (EvolutionShellComponent *shell_component) E_MAKE_X_TYPE (evolution_shell_component, "EvolutionShellComponent", EvolutionShellComponent, class_init, init, PARENT_TYPE, POA_GNOME_Evolution_ShellComponent__init, - GTK_STRUCT_OFFSET (EvolutionShellComponentClass, epv)); + GTK_STRUCT_OFFSET (EvolutionShellComponentClass, epv)) diff --git a/shell/evolution-test-component.c b/shell/evolution-test-component.c index e1d2354a7b..4d70525c40 100644 --- a/shell/evolution-test-component.c +++ b/shell/evolution-test-component.c @@ -40,7 +40,7 @@ #define COMPONENT_ID "OAFIID:GNOME_Evolution_TestComponent_ShellComponent" static const EvolutionShellComponentFolderType folder_types[] = { - { "test", "/usr/share/pixmaps/gnome-money.png", NULL, NULL }, + { "test", "/usr/share/pixmaps/gnome-money.png", FALSE, NULL, NULL }, { NULL } }; @@ -52,6 +52,60 @@ static int timeout_id = 0; static int progress = -1; +/* Test the ::Shortcut interface. */ + +static void +spit_out_shortcuts (EvolutionShellClient *shell_client) +{ + GNOME_Evolution_Shortcuts shortcuts_interface; + GNOME_Evolution_Shortcuts_GroupList *groups; + CORBA_Environment ev; + int i, j; + + g_print ("** Getting shortcuts from the shell:\n"); + + CORBA_exception_init (&ev); + + shortcuts_interface = evolution_shell_client_get_shortcuts_interface (shell_client); + if (CORBA_Object_is_nil (shortcuts_interface, &ev)) { + g_warning ("No ::Shortcut interface on the shell"); + CORBA_exception_free (&ev); + return; + } + + groups = GNOME_Evolution_Shortcuts__get_groups (shortcuts_interface, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("Exception getting the groups: %s", ev._repo_id); + CORBA_exception_free (&ev); + return; + } + + for (i = 0; i < groups->_length; i ++) { + GNOME_Evolution_Shortcuts_Group *group; + GNOME_Evolution_Shortcuts_ShortcutList *shortcuts; + + group = groups->_buffer + i; + shortcuts = &group->shortcuts; + + g_print ("\tGROUP: %s\n", group->name); + + for (j = 0; j < shortcuts->_length; j ++) { + GNOME_Evolution_Shortcuts_Shortcut *shortcut; + + shortcut = shortcuts->_buffer + j; + + g_print ("\t\tName: %s\n", shortcut->name); + g_print ("\t\t\tType: %s\n", shortcut->type); + g_print ("\t\t\tURI: %s\n", shortcut->uri); + } + } + + g_print ("** Done\n\n"); + + CORBA_exception_free (&ev); +} + + /* Callbacks. */ static void @@ -196,6 +250,8 @@ owner_set_callback (EvolutionShellComponent *shell_component, if (evolution_shell_client_get_activity_interface (parent_shell) == CORBA_OBJECT_NIL) g_warning ("Shell doesn't have a ::Activity interface -- weird!"); + + spit_out_shortcuts (shell_client); } static int |