diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2000-07-21 20:04:18 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2000-07-21 20:04:18 +0800 |
commit | c9090285feaeb5ad9223e256bb8b177093644e04 (patch) | |
tree | 74ec1cdb75012f20e64a47e183f754d563c94b4b /shell | |
parent | 3eed7c0e0eeb307d8e351f5e137f23764f493a9d (diff) | |
download | gsoc2013-evolution-c9090285feaeb5ad9223e256bb8b177093644e04.tar gsoc2013-evolution-c9090285feaeb5ad9223e256bb8b177093644e04.tar.gz gsoc2013-evolution-c9090285feaeb5ad9223e256bb8b177093644e04.tar.bz2 gsoc2013-evolution-c9090285feaeb5ad9223e256bb8b177093644e04.tar.lz gsoc2013-evolution-c9090285feaeb5ad9223e256bb8b177093644e04.tar.xz gsoc2013-evolution-c9090285feaeb5ad9223e256bb8b177093644e04.tar.zst gsoc2013-evolution-c9090285feaeb5ad9223e256bb8b177093644e04.zip |
First shot at the "click on the folder title, get the folder tree"
thingie. Needs love, but it's a start.
svn path=/trunk/; revision=4257
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ChangeLog | 22 | ||||
-rw-r--r-- | shell/e-shell-folder-title-bar.c | 109 | ||||
-rw-r--r-- | shell/e-shell-view.c | 135 |
3 files changed, 227 insertions, 39 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index 77bf3e66dd..74768dc8a2 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,5 +1,27 @@ 2000-07-21 Ettore Perazzoli <ettore@helixcode.com> + * e-shell-folder-title-bar.c (create_icon_pixmap): New. Create a + small arrow-shaped GtkPixmap. + (title_button_box_realize_cb): New. Callback for the "realize" + signal of the button's inner box. + + * e-shell-view.c (title_bar_clicked_cb): New function, callback + for the "title_clicked" signal of the title bar. + (setup_widgets): Connect it. + + * e-shell-view.c: New member `storage_set_title_bar' in + `EShellViewPrivate'. + (setup_storage_set_subwindow): Set it. + + * e-shell-folder-title-bar.c: Use a GtkLabel instead of an + EClippedLabel for the title. + (title_button_clicked_cb): New. + (e_shell_folder_title_bar_construct): Put the label into a button. + Connect the button's "clicked" signal to + `title_button_clicked_cb'. + +2000-07-21 Ettore Perazzoli <ettore@helixcode.com> + * evolution-shell-component.c (impl_ShellComponent_populate_folder_context_menu): If the pointer to the function to populate the folder context menu is NULL, don't diff --git a/shell/e-shell-folder-title-bar.c b/shell/e-shell-folder-title-bar.c index 1dd9d059cd..6078ecc59b 100644 --- a/shell/e-shell-folder-title-bar.c +++ b/shell/e-shell-folder-title-bar.c @@ -44,7 +44,6 @@ struct _EShellFolderTitleBarPrivate { GtkWidget *hbox; GtkWidget *label; - GtkWidget *button_hbox; GtkWidget *button; }; @@ -56,14 +55,26 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; +static char *arrow_xpm[] = { + "11 5 2 1", + " c none", + ". c #ffffffffffff", + " ......... ", + " ....... ", + " ..... ", + " ... ", + " . ", +}; + + /* Icon handling. */ static unsigned int rgb_from_gdk_color (GdkColor *color) { - return (((color->red >> 8) << 16) | - ((color->green >> 8) << 8) | - ((color->blue >> 8))); + return (((color->red >> 8) << 16) + | ((color->green >> 8) << 8) + | ((color->blue >> 8))); } static GdkPixmap * @@ -108,6 +119,41 @@ make_icon_pixmap (EShellFolderTitleBar *folder_title_bar, } +/* Icon pixmap. */ + +static GtkWidget * +create_icon_pixmap (GtkWidget *parent) +{ + GtkWidget *gtk_pixmap; + GdkPixmap *gdk_pixmap; + GdkBitmap *gdk_mask; + + gdk_pixmap = gdk_pixmap_create_from_xpm_d (parent->window, &gdk_mask, NULL, arrow_xpm); + gtk_pixmap = gtk_pixmap_new (gdk_pixmap, gdk_mask); + + gdk_pixmap_unref (gdk_pixmap); + gdk_bitmap_unref (gdk_mask); + + return gtk_pixmap; +} + +static void +title_button_box_realize_cb (GtkWidget *widget, + void *data) +{ + GtkWidget *arrow_pixmap; + + if (gtk_object_get_data (GTK_OBJECT (widget), "e-shell-folder-title-bar-arrow") != NULL) + return; + + arrow_pixmap = create_icon_pixmap (widget); + gtk_widget_show (arrow_pixmap); + gtk_box_pack_start (GTK_BOX (widget), arrow_pixmap, FALSE, TRUE, 2); + + gtk_object_set_data (GTK_OBJECT (widget), "e-shell-folder-title-bar-arrow", arrow_pixmap); +} + + /* Style handling. */ static void @@ -170,9 +216,8 @@ setup_style (EShellFolderTitleBar *folder_title_bar) } -/* Button signals. */ +/* Popup button callback. */ -#if 0 static void title_button_clicked_cb (GtkButton *button, void *data) @@ -180,10 +225,8 @@ title_button_clicked_cb (GtkButton *button, EShellFolderTitleBar *folder_title_bar; folder_title_bar = E_SHELL_FOLDER_TITLE_BAR (data); - gtk_signal_emit (GTK_OBJECT (folder_title_bar), signals[TITLE_CLICKED]); } -#endif /* GTkWidget methods. */ @@ -278,17 +321,23 @@ init (EShellFolderTitleBar *shell_folder_title_bar) priv->icon_widget = NULL; priv->hbox = NULL; priv->label = NULL; - priv->button_hbox = NULL; priv->button = NULL; shell_folder_title_bar->priv = priv; } +/** + * e_shell_folder_title_bar_construct: + * @folder_title_bar: + * + * Construct the folder title bar widget. + **/ void e_shell_folder_title_bar_construct (EShellFolderTitleBar *folder_title_bar) { EShellFolderTitleBarPrivate *priv; + GtkWidget *button_hbox; GtkWidget *widget; g_return_if_fail (folder_title_bar != NULL); @@ -297,29 +346,31 @@ e_shell_folder_title_bar_construct (EShellFolderTitleBar *folder_title_bar) priv = folder_title_bar->priv; widget = GTK_WIDGET (folder_title_bar); - priv->label = e_clipped_label_new (""); + priv->label = gtk_label_new (""); gtk_misc_set_padding (GTK_MISC (priv->label), 5, 0); gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5); gtk_widget_show (priv->label); -#if 0 + button_hbox = gtk_hbox_new (FALSE, 0); + gtk_signal_connect (GTK_OBJECT (button_hbox), "realize", + GTK_SIGNAL_FUNC (title_button_box_realize_cb), NULL); + gtk_box_pack_start (GTK_BOX (button_hbox), priv->label, TRUE, TRUE, 0); + gtk_widget_show (button_hbox); + priv->button = gtk_button_new (); gtk_button_set_relief (GTK_BUTTON (priv->button), GTK_RELIEF_NONE); - gtk_container_add (GTK_CONTAINER (priv->button), priv->label); + gtk_container_add (GTK_CONTAINER (priv->button), button_hbox); GTK_WIDGET_UNSET_FLAGS (priv->button, GTK_CAN_FOCUS); gtk_widget_show (priv->button); -#endif 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, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->button, FALSE, TRUE, 0); gtk_widget_show (priv->hbox); -#if 0 gtk_signal_connect (GTK_OBJECT (priv->button), "clicked", GTK_SIGNAL_FUNC (title_button_clicked_cb), folder_title_bar); -#endif gtk_container_add (GTK_CONTAINER (folder_title_bar), priv->hbox); @@ -328,6 +379,14 @@ e_shell_folder_title_bar_construct (EShellFolderTitleBar *folder_title_bar) e_shell_folder_title_bar_set_title (folder_title_bar, NULL); } +/** + * e_shell_folder_title_bar_new: + * @void: + * + * Create a new title bar widget. + * + * Return value: + **/ GtkWidget * e_shell_folder_title_bar_new (void) { @@ -340,6 +399,13 @@ e_shell_folder_title_bar_new (void) return GTK_WIDGET (new); } +/** + * e_shell_folder_title_bar_set_title: + * @folder_title_bar: + * @title: + * + * Set the title for the title bar. + **/ void e_shell_folder_title_bar_set_title (EShellFolderTitleBar *folder_title_bar, const char *title) @@ -352,14 +418,21 @@ e_shell_folder_title_bar_set_title (EShellFolderTitleBar *folder_title_bar, priv = folder_title_bar->priv; if (title == NULL) - e_clipped_label_set_text (E_CLIPPED_LABEL (priv->label), _("(Untitled)")); + gtk_label_set_text (GTK_LABEL (priv->label), _("(Untitled)")); else - e_clipped_label_set_text (E_CLIPPED_LABEL (priv->label), title); + gtk_label_set_text (GTK_LABEL (priv->label), title); /* FIXME: There seems to be a bug in EClippedLabel, this is just a workaround. */ gtk_widget_queue_draw (GTK_WIDGET (folder_title_bar)); } +/** + * e_shell_folder_title_bar_set_icon: + * @folder_title_bar: + * @icon: + * + * Set the name of the icon for the title bar. + **/ void e_shell_folder_title_bar_set_icon (EShellFolderTitleBar *folder_title_bar, const GdkPixbuf *icon) diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index 2b6f39bcee..8891013749 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -72,6 +72,7 @@ struct _EShellViewPrivate { GtkWidget *contents; GtkWidget *notebook; GtkWidget *shortcut_bar; + GtkWidget *storage_set_title_bar; GtkWidget *storage_set_view; GtkWidget *storage_set_view_box; @@ -136,6 +137,82 @@ bonobo_widget_is_dead (BonoboWidget *bonobo_widget) } +/* Folder bar pop-up handling. */ + +static void +storage_set_view_box_button_release_event_cb (GtkWidget *widget, + GdkEventButton *button_event, + void *data) +{ + EShellView *shell_view; + EShellViewPrivate *priv; + + shell_view = E_SHELL_VIEW (data); + priv = shell_view->priv; + + gdk_pointer_ungrab (GDK_CURRENT_TIME); + gtk_grab_remove (priv->storage_set_view_box); + + e_shell_view_set_folder_bar_mode (shell_view, E_SHELL_VIEW_SUBWINDOW_HIDDEN); + + gtk_signal_disconnect_by_func (GTK_OBJECT (priv->storage_set_view_box), + GTK_SIGNAL_FUNC (storage_set_view_box_button_release_event_cb), + shell_view); + gtk_signal_disconnect_by_func (GTK_OBJECT (priv->storage_set_view), + GTK_SIGNAL_FUNC (storage_set_view_box_button_release_event_cb), + shell_view); +} + +static void +storage_set_view_box_map_cb (GtkWidget *widget, + void *data) +{ + EShellView *shell_view; + EShellViewPrivate *priv; + + shell_view = E_SHELL_VIEW (data); + priv = shell_view->priv; + + if ((gdk_pointer_grab (widget->window, TRUE, + (GDK_BUTTON_PRESS_MASK + | GDK_BUTTON_RELEASE_MASK + | GDK_ENTER_NOTIFY_MASK + | GDK_LEAVE_NOTIFY_MASK + | GDK_POINTER_MOTION_MASK), + NULL, NULL, GDK_CURRENT_TIME) != 0)) { + g_warning ("%s -- pointer grab failed.", __FUNCTION__); + e_shell_view_set_folder_bar_mode (shell_view, E_SHELL_VIEW_SUBWINDOW_STICKY); + return; + } + + gtk_grab_add (widget); + gtk_signal_connect (GTK_OBJECT (widget), "button_release_event", + GTK_SIGNAL_FUNC (storage_set_view_box_button_release_event_cb), shell_view); + gtk_signal_connect (GTK_OBJECT (priv->storage_set_view), "button_release_event", + GTK_SIGNAL_FUNC (storage_set_view_box_button_release_event_cb), shell_view); +} + +static void +pop_up_folder_bar (EShellView *shell_view) +{ + EShellViewPrivate *priv; + + priv = shell_view->priv; + + priv->folder_bar_mode = E_SHELL_VIEW_SUBWINDOW_TRANSIENT; + + /* We need to show the storage set view box and do a pointer grab to catch the + mouse clicks. But until the box is shown, we cannot grab. So we connect to + the "map" signa; `storage_set_view_box_map_cb' will do the grab. */ + + gtk_signal_connect (GTK_OBJECT (priv->storage_set_view_box), "map", + GTK_SIGNAL_FUNC (storage_set_view_box_map_cb), shell_view); + gtk_widget_show (priv->storage_set_view_box); + + e_paned_set_position (E_PANED (priv->view_hpaned), priv->view_hpaned_position); +} + + /* Callbacks. */ /* Callback called when an icon on the shortcut bar gets clicked. */ @@ -180,6 +257,19 @@ storage_set_view_close_button_clicked_cb (ETitleBar *title_bar, e_shell_view_set_folder_bar_mode (shell_view, E_SHELL_VIEW_SUBWINDOW_HIDDEN); } +/* Callback called when the title bar button has been clicked. */ +static void +title_bar_clicked_cb (EShellFolderTitleBar *title_bar, + void *data) +{ + EShellView *shell_view; + + shell_view = E_SHELL_VIEW (data); + + if (e_shell_view_get_folder_bar_mode (shell_view) != E_SHELL_VIEW_SUBWINDOW_TRANSIENT) + pop_up_folder_bar (shell_view); +} + /* Widget setup. */ @@ -188,7 +278,6 @@ setup_storage_set_subwindow (EShellView *shell_view) { EShellViewPrivate *priv; GtkWidget *storage_set_view; - GtkWidget *title_bar; GtkWidget *vbox; GtkWidget *scrolled_window; @@ -205,17 +294,17 @@ setup_storage_set_subwindow (EShellView *shell_view) gtk_container_add (GTK_CONTAINER (scrolled_window), storage_set_view); vbox = gtk_vbox_new (FALSE, 0); - title_bar = e_title_bar_new (_("Folders")); + priv->storage_set_title_bar = e_title_bar_new (_("Folders")); - gtk_box_pack_start (GTK_BOX (vbox), title_bar, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), priv->storage_set_title_bar, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0); - gtk_signal_connect (GTK_OBJECT (title_bar), "close_button_clicked", + gtk_signal_connect (GTK_OBJECT (priv->storage_set_title_bar), "close_button_clicked", GTK_SIGNAL_FUNC (storage_set_view_close_button_clicked_cb), shell_view); gtk_widget_show (vbox); gtk_widget_show (storage_set_view); - gtk_widget_show (title_bar); + gtk_widget_show (priv->storage_set_title_bar); gtk_widget_show (scrolled_window); priv->storage_set_view_box = vbox; @@ -260,6 +349,8 @@ setup_widgets (EShellView *shell_view) gtk_container_set_border_width (GTK_CONTAINER (priv->view_vbox), 2); priv->view_title_bar = e_shell_folder_title_bar_new (); + gtk_signal_connect (GTK_OBJECT (priv->view_title_bar), "title_clicked", + GTK_SIGNAL_FUNC (title_bar_clicked_cb), shell_view); priv->view_hpaned = e_hpaned_new (); e_paned_add1 (E_PANED (priv->view_hpaned), priv->storage_set_view_box); @@ -415,26 +506,28 @@ init (EShellView *shell_view) priv = g_new (EShellViewPrivate, 1); - priv->shell = NULL; - priv->uih = NULL; - priv->uri = NULL; + priv->shell = NULL; + priv->uih = NULL; + priv->uri = NULL; + + priv->appbar = NULL; + priv->hpaned = NULL; + priv->view_hpaned = NULL; + priv->contents = NULL; + priv->notebook = NULL; - priv->appbar = NULL; - priv->hpaned = NULL; - priv->view_hpaned = NULL; - priv->contents = NULL; - priv->notebook = NULL; - priv->storage_set_view = NULL; - priv->storage_set_view_box = NULL; - priv->shortcut_bar = NULL; + priv->storage_set_title_bar = NULL; + priv->storage_set_view = NULL; + priv->storage_set_view_box = NULL; + priv->shortcut_bar = NULL; - priv->shortcut_bar_mode = E_SHELL_VIEW_SUBWINDOW_HIDDEN; - priv->folder_bar_mode = E_SHELL_VIEW_SUBWINDOW_HIDDEN; + priv->shortcut_bar_mode = E_SHELL_VIEW_SUBWINDOW_HIDDEN; + priv->folder_bar_mode = E_SHELL_VIEW_SUBWINDOW_HIDDEN; - priv->hpaned_position = 0; - priv->view_hpaned_position = 0; + priv->hpaned_position = 0; + priv->view_hpaned_position = 0; - priv->uri_to_control = g_hash_table_new (g_str_hash, g_str_equal); + priv->uri_to_control = g_hash_table_new (g_str_hash, g_str_equal); shell_view->priv = priv; } |