diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ChangeLog | 20 | ||||
-rw-r--r-- | shell/e-shell-view.c | 2 | ||||
-rw-r--r-- | shell/e-storage-set-view.c | 118 | ||||
-rw-r--r-- | shell/evolution-shell-component-client.c | 39 | ||||
-rw-r--r-- | shell/evolution-shell-component-client.h | 5 |
5 files changed, 179 insertions, 5 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index 1af4a5002f..0f57b511f2 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,4 +1,22 @@ -2000-07-20 Ettore Perazzoli <ettore@helixcode.com> +2000-07-21 Ettore Perazzoli <ettore@helixcode.com> + + * e-storage-set-view.c (popup_folder_menu): New. Create a + BonoboUIHandler-managed pop-up menu, let the component fill it in + with `::populate_folder_context_menu', and display it. Then + destroy it with the associated BonoboUIHandler. + (handle_right_button_selection): New. + (handle_left_button_selection): New. This pops up the right-click + menu. + (button_release_event): Use them. + (init): Set the `GTK_BUTTON_SELECTS' flag for button #3's actions. + + * evolution-shell-component-client.c + (evolution_shell_component_client_populate_folder_context_menu): + New. + (evolution_shell_component_client_async_create_folder): Added + preconditions. + + * e-shell-view.c (e_shell_view_save_settings): Add missing cast. * evolution-shell-component.c: New member `populate_folder_context_menu' in diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index fcd5b54843..2b6f39bcee 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -1013,7 +1013,7 @@ e_shell_view_save_settings (EShellView *shell_view, SET (int, "FolderBarMode", e_shell_view_get_folder_bar_mode (shell_view)) SET (int, "ShortcutBarMode", e_shell_view_get_shortcut_bar_mode (shell_view)); SET (int, "HPanedPosition", e_paned_get_position (E_PANED (priv->hpaned))); - SET (int, "ViewHPanedPosition", e_paned_get_position (priv->view_hpaned)); + SET (int, "ViewHPanedPosition", e_paned_get_position (E_PANED (priv->view_hpaned))); uri = e_shell_view_get_current_uri (shell_view); if (uri != NULL) { diff --git a/shell/e-storage-set-view.c b/shell/e-storage-set-view.c index 88e70e4f78..ea7eb938ee 100644 --- a/shell/e-storage-set-view.c +++ b/shell/e-storage-set-view.c @@ -211,6 +211,82 @@ get_pixmap_and_mask_for_folder (EStorageSetView *storage_set_view, } +/* Folder context menu. */ +/* FIXME: This should be moved somewhere else, so that also the sortcut code + can share it. */ + +static void +folder_context_menu_activate_cb (BonoboUIHandler *uih, + void *data, + const char *path) +{ + EStorageSetView *storage_set_view; + EStorageSetViewPrivate *priv; + + storage_set_view = E_STORAGE_SET_VIEW (data); + priv = storage_set_view->priv; + + gtk_signal_emit (GTK_OBJECT (storage_set_view), signals[FOLDER_SELECTED], + priv->selected_row_path); + + /* Make sure we don't restore the previously selected row after the + menu is popped down. */ + priv->selected_row_path_before_click = NULL; +} + +static void +populate_folder_context_menu_with_common_items (EStorageSetView *storage_set_view, + BonoboUIHandler *uih) +{ + bonobo_ui_handler_menu_new_item (uih, "/Activate", + _("_View"), _("View the selected folder"), + 0, BONOBO_UI_HANDLER_PIXMAP_NONE, + NULL, 0, 0, + folder_context_menu_activate_cb, + storage_set_view); +} + +static void +popup_folder_menu (EStorageSetView *storage_set_view, + GdkEventButton *event) +{ + EvolutionShellComponentClient *handler; + EStorageSetViewPrivate *priv; + EFolderTypeRegistry *folder_type_registry; + BonoboUIHandler *uih; + EFolder *folder; + + priv = storage_set_view->priv; + + uih = bonobo_ui_handler_new (); + bonobo_ui_handler_create_popup_menu (uih); + + folder = e_storage_set_get_folder (priv->storage_set, priv->selected_row_path); + if (folder == NULL) { + /* Uh!? */ + return; + } + + folder_type_registry = e_storage_set_get_folder_type_registry (priv->storage_set); + g_assert (folder_type_registry != NULL); + + handler = e_folder_type_registry_get_handler_for_type (folder_type_registry, + e_folder_get_type_string (folder)); + g_assert (handler != NULL); + + evolution_shell_component_client_populate_folder_context_menu (handler, + uih, + e_folder_get_physical_uri (folder), + e_folder_get_type_string (folder)); + + populate_folder_context_menu_with_common_items (storage_set_view, uih); + + bonobo_ui_handler_do_popup_menu (uih); + + bonobo_object_unref (BONOBO_OBJECT (uih)); +} + + /* GtkObject methods. */ static void @@ -313,6 +389,36 @@ motion_notify_event (GtkWidget *widget, return TRUE; } +static void +handle_left_button_selection (EStorageSetView *storage_set_view, + GtkWidget *widget, + GdkEventButton *event) +{ + EStorageSetViewPrivate *priv; + + priv = storage_set_view->priv; + + gtk_signal_emit (GTK_OBJECT (widget), signals[FOLDER_SELECTED], + priv->selected_row_path); + priv->selected_row_path = NULL; +} + +static void +handle_right_button_selection (EStorageSetView *storage_set_view, + GtkWidget *widget, + GdkEventButton *event) +{ + EStorageSetViewPrivate *priv; + + priv = storage_set_view->priv; + + popup_folder_menu (storage_set_view, event); + + if (priv->selected_row_path_before_click != NULL) + e_storage_set_view_set_current_folder (storage_set_view, + priv->selected_row_path_before_click); +} + static int button_release_event (GtkWidget *widget, GdkEventButton *event) @@ -332,9 +438,10 @@ button_release_event (GtkWidget *widget, gdk_flush (); if (priv->selected_row_path != NULL) { - gtk_signal_emit (GTK_OBJECT (widget), signals[FOLDER_SELECTED], - priv->selected_row_path); - priv->selected_row_path = NULL; + if (priv->drag_button == 1) + handle_left_button_selection (storage_set_view, widget, event); + else + handle_right_button_selection (storage_set_view, widget, event); } } @@ -643,6 +750,7 @@ static void init (EStorageSetView *storage_set_view) { EStorageSetViewPrivate *priv; + GtkCList *clist; /* Avoid GtkCTree's broken focusing behavior. FIXME: Other ways? */ GTK_WIDGET_UNSET_FLAGS (storage_set_view, GTK_CAN_FOCUS); @@ -660,6 +768,10 @@ init (EStorageSetView *storage_set_view) priv->button_y = 0; storage_set_view->priv = priv; + + /* Set up the right mouse button so that it also selects. */ + clist = GTK_CLIST (storage_set_view); + clist->button_actions[2] |= GTK_BUTTON_SELECTS; } diff --git a/shell/evolution-shell-component-client.c b/shell/evolution-shell-component-client.c index b61fa1a351..3a7ba57bbd 100644 --- a/shell/evolution-shell-component-client.c +++ b/shell/evolution-shell-component-client.c @@ -477,6 +477,12 @@ evolution_shell_component_client_async_create_folder (EvolutionShellComponentCli Evolution_ShellComponent corba_shell_component; CORBA_Environment ev; + g_return_if_fail (shell_component_client != NULL); + g_return_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client)); + g_return_if_fail (physical_uri != NULL); + g_return_if_fail (type != NULL); + g_return_if_fail (callback != NULL); + priv = shell_component_client->priv; if (priv->callback != NULL) { @@ -507,6 +513,39 @@ evolution_shell_component_client_async_remove_folder (EvolutionShellComponentCli EvolutionShellComponentClientCallback callback, void *data) { + /* FIXME to do. */ +} + +void +evolution_shell_component_client_populate_folder_context_menu (EvolutionShellComponentClient *shell_component_client, + BonoboUIHandler *uih, + const char *physical_uri, + const char *type) +{ + Bonobo_UIHandler corba_uih; + EvolutionShellComponentClientPrivate *priv; + Evolution_ShellComponent corba_shell_component; + CORBA_Environment ev; + + g_return_if_fail (shell_component_client != NULL); + g_return_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client)); + g_return_if_fail (physical_uri != NULL); + g_return_if_fail (type != NULL); + + priv = shell_component_client->priv; + + CORBA_exception_init (&ev); + + corba_shell_component = bonobo_object_corba_objref (BONOBO_OBJECT (shell_component_client)); + corba_uih = bonobo_object_corba_objref (BONOBO_OBJECT (uih)); + + Evolution_ShellComponent_populate_folder_context_menu (corba_shell_component, + corba_uih, + physical_uri, + type, + &ev); + + CORBA_exception_free (&ev); } diff --git a/shell/evolution-shell-component-client.h b/shell/evolution-shell-component-client.h index d128ee54ab..b591997126 100644 --- a/shell/evolution-shell-component-client.h +++ b/shell/evolution-shell-component-client.h @@ -88,6 +88,11 @@ void evolution_shell_component_client_async_remove_folder (EvolutionShellCompo EvolutionShellComponentClientCallback callback, void *data); +void evolution_shell_component_client_populate_folder_context_menu (EvolutionShellComponentClient *shell_component_client, + BonoboUIHandler *uih, + const char *physical_uri, + const char *type); + #ifdef cplusplus } #endif /* cplusplus */ |