diff options
-rw-r--r-- | shell/ChangeLog | 18 | ||||
-rw-r--r-- | shell/e-shell-folder-title-bar.c | 110 | ||||
-rw-r--r-- | shell/e-shell-folder-title-bar.h | 3 | ||||
-rw-r--r-- | shell/e-shell-view.c | 13 |
4 files changed, 127 insertions, 17 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index 634668b681..e9db916d73 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,21 @@ +2000-07-22 Ettore Perazzoli <ettore@helixcode.com> + + * e-shell-view.c (e_shell_view_set_folder_bar_mode): Make the + title bar non-clickable when the folder tree is visible. + + * e-shell-folder-title-bar.c: New members `button_arrow' and + `clickable' in `EShellFolderTitleBarPrivate'. Renamed `label' + into `button_label'. Added `label'. + (init): Init them. + (e_shell_folder_title_bar_construct): Pass a pointer to the title + bar as the user data for the "realize" signal. Create `label'. + (title_button_box_realize_cb): Use the `button_arrow' member + instead of using `gtk_object_{set,get}_data()'. + (setup_style): Set the style for `label' too. + (e_shell_folder_title_bar_set_clickable): New. + (e_shell_folder_title_bar_set_title): Set both `label' and + `button_label'. + 2000-07-21 Ettore Perazzoli <ettore@helixcode.com> * e-shell-view.c (storage_set_view_box_button_release_event_cb): diff --git a/shell/e-shell-folder-title-bar.c b/shell/e-shell-folder-title-bar.c index 800e4d1074..447a991d02 100644 --- a/shell/e-shell-folder-title-bar.c +++ b/shell/e-shell-folder-title-bar.c @@ -42,9 +42,21 @@ struct _EShellFolderTitleBarPrivate { GdkPixbuf *icon; GtkWidget *icon_widget; + /* The hbox containing the button, the label and the icon on the right. */ GtkWidget *hbox; + + /* We have a label and a button. When the button is enabled, the label is hidden; + when the button is disable, only the label is visible. */ + + /* The label. */ GtkWidget *label; + + /* The button. */ GtkWidget *button; + GtkWidget *button_label; + GtkWidget *button_arrow; + + gboolean clickable; }; enum { @@ -141,16 +153,22 @@ static void title_button_box_realize_cb (GtkWidget *widget, void *data) { - GtkWidget *arrow_pixmap; + EShellFolderTitleBar *folder_title_bar; + EShellFolderTitleBarPrivate *priv; + GtkWidget *button_arrow; - if (gtk_object_get_data (GTK_OBJECT (widget), "e-shell-folder-title-bar-arrow") != NULL) + folder_title_bar = E_SHELL_FOLDER_TITLE_BAR (data); + priv = folder_title_bar->priv; + + if (priv->button_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); + button_arrow = create_icon_pixmap (widget); - gtk_object_set_data (GTK_OBJECT (widget), "e-shell-folder-title-bar-arrow", arrow_pixmap); + gtk_widget_show (button_arrow); + gtk_box_pack_start (GTK_BOX (widget), button_arrow, FALSE, TRUE, 2); + + priv->button_arrow = button_arrow; } @@ -211,8 +229,9 @@ setup_style (EShellFolderTitleBar *folder_title_bar) priv = folder_title_bar->priv; - endarken_and_connect_style_set_signal (priv->button); endarken_and_connect_style_set_signal (priv->label); + endarken_and_connect_style_set_signal (priv->button); + endarken_and_connect_style_set_signal (priv->button_label); endarken_and_connect_style_set_signal (GTK_WIDGET (folder_title_bar)); } @@ -321,11 +340,16 @@ init (EShellFolderTitleBar *shell_folder_title_bar) EShellFolderTitleBarPrivate *priv; priv = g_new (EShellFolderTitleBarPrivate, 1); - priv->icon = NULL; - priv->icon_widget = NULL; - priv->hbox = NULL; - priv->label = NULL; - priv->button = NULL; + + priv->icon = NULL; + priv->icon_widget = NULL; + priv->hbox = NULL; + priv->label = NULL; + priv->button_label = NULL; + priv->button = NULL; + priv->button_arrow = NULL; + + priv->clickable = TRUE; shell_folder_title_bar->priv = priv; } @@ -341,6 +365,7 @@ void e_shell_folder_title_bar_construct (EShellFolderTitleBar *folder_title_bar) { EShellFolderTitleBarPrivate *priv; + GtkRequisition button_requisition; GtkWidget *button_hbox; GtkWidget *widget; @@ -353,12 +378,16 @@ e_shell_folder_title_bar_construct (EShellFolderTitleBar *folder_title_bar) 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); + + priv->button_label = gtk_label_new (""); + gtk_misc_set_padding (GTK_MISC (priv->button_label), 5, 0); + gtk_misc_set_alignment (GTK_MISC (priv->button_label), 0.0, 0.5); + gtk_widget_show (priv->button_label); 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_SIGNAL_FUNC (title_button_box_realize_cb), folder_title_bar); + gtk_box_pack_start (GTK_BOX (button_hbox), priv->button_label, TRUE, TRUE, 0); gtk_widget_show (button_hbox); priv->button = gtk_toggle_button_new (); @@ -369,6 +398,7 @@ 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_widget_show (priv->hbox); @@ -381,6 +411,10 @@ e_shell_folder_title_bar_construct (EShellFolderTitleBar *folder_title_bar) setup_style (folder_title_bar); e_shell_folder_title_bar_set_title (folder_title_bar, NULL); + + /* KLUDGE */ + gtk_widget_size_request (priv->button, &button_requisition); + gtk_widget_set_usize (priv->label, button_requisition.width, button_requisition.height); } /** @@ -421,10 +455,13 @@ e_shell_folder_title_bar_set_title (EShellFolderTitleBar *folder_title_bar, priv = folder_title_bar->priv; - if (title == NULL) + if (title == NULL) { + gtk_label_set_text (GTK_LABEL (priv->button_label), _("(Untitled)")); gtk_label_set_text (GTK_LABEL (priv->label), _("(Untitled)")); - else + } else { + gtk_label_set_text (GTK_LABEL (priv->button_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)); @@ -455,6 +492,13 @@ e_shell_folder_title_bar_set_icon (EShellFolderTitleBar *folder_title_bar, } +/** + * e_shell_folder_title_bar_set_toggle_state: + * @folder_title_bar: + * @state: + * + * Set whether the title bar's button is in pressed state (TRUE) or not (FALSE). + **/ void e_shell_folder_title_bar_set_toggle_state (EShellFolderTitleBar *folder_title_bar, gboolean state) @@ -469,5 +513,37 @@ e_shell_folder_title_bar_set_toggle_state (EShellFolderTitleBar *folder_title_ba gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button), state); } +/** + * e_shell_folder_title_bar_set_clickable: + * @folder_title_bar: + * @clickable: + * + * Specify whether @folder_title_bar is clickable. If not, the arrow pixmap is not shown. + **/ +void +e_shell_folder_title_bar_set_clickable (EShellFolderTitleBar *folder_title_bar, + gboolean clickable) +{ + EShellFolderTitleBarPrivate *priv; + + g_return_if_fail (folder_title_bar != NULL); + g_return_if_fail (E_IS_SHELL_FOLDER_TITLE_BAR (folder_title_bar)); + + priv = folder_title_bar->priv; + + if ((priv->clickable && clickable) || (! priv->clickable && ! clickable)) + return; + + if (clickable) { + gtk_widget_show (priv->button); + gtk_widget_hide (priv->label); + } else { + gtk_widget_hide (priv->button); + gtk_widget_show (priv->label); + } + + priv->clickable = !! clickable; +} + E_MAKE_TYPE (e_shell_folder_title_bar, "EShellFolderTitleBar", EShellFolderTitleBar, class_init, init, PARENT_TYPE) diff --git a/shell/e-shell-folder-title-bar.h b/shell/e-shell-folder-title-bar.h index 86759c8270..c8bab9994c 100644 --- a/shell/e-shell-folder-title-bar.h +++ b/shell/e-shell-folder-title-bar.h @@ -64,12 +64,15 @@ struct _EShellFolderTitleBarClass { GtkType e_shell_folder_title_bar_get_type (void); void e_shell_folder_title_bar_construct (EShellFolderTitleBar *folder_title_bar); GtkWidget *e_shell_folder_title_bar_new (void); + void e_shell_folder_title_bar_set_title (EShellFolderTitleBar *folder_title_bar, const char *title); void e_shell_folder_title_bar_set_icon (EShellFolderTitleBar *folder_title_bar, const GdkPixbuf *icon); void e_shell_folder_title_bar_set_toggle_state (EShellFolderTitleBar *folder_title_bar, gboolean state); +void e_shell_folder_title_bar_set_clickable (EShellFolderTitleBar *folder_title_bar, + gboolean clickable); #ifdef __cplusplus } diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index bd36c0df07..38ba7d6487 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -1015,6 +1015,13 @@ e_shell_view_set_shortcut_bar_mode (EShellView *shell_view, gtk_signal_emit (GTK_OBJECT (shell_view), signals[SHORTCUT_BAR_MODE_CHANGED], mode); } +/** + * e_shell_view_set_folder_bar_mode: + * @shell_view: + * @mode: + * + * Set the visualization mode for the folder bar's subwindow. + **/ void e_shell_view_set_folder_bar_mode (EShellView *shell_view, EShellViewSubwindowMode mode) @@ -1036,6 +1043,9 @@ e_shell_view_set_folder_bar_mode (EShellView *shell_view, gtk_widget_show (priv->storage_set_view_box); e_paned_set_position (E_PANED (priv->view_hpaned), priv->view_hpaned_position); } + + e_shell_folder_title_bar_set_clickable (E_SHELL_FOLDER_TITLE_BAR (priv->view_title_bar), + FALSE); } else { if (GTK_WIDGET_VISIBLE (priv->storage_set_view_box)) { gtk_widget_hide (priv->storage_set_view_box); @@ -1043,6 +1053,9 @@ e_shell_view_set_folder_bar_mode (EShellView *shell_view, priv->view_hpaned_position = E_PANED (priv->view_hpaned)->child1_size; e_paned_set_position (E_PANED (priv->view_hpaned), 0); } + + e_shell_folder_title_bar_set_clickable (E_SHELL_FOLDER_TITLE_BAR (priv->view_title_bar), + TRUE); } priv->folder_bar_mode = mode; |