diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2000-09-29 22:05:10 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2000-09-29 22:05:10 +0800 |
commit | 7d63b93c516dd80bfc703e92c1502e55ae3c1f97 (patch) | |
tree | e3db1a2c5489a69d1beb6c66ede9766550d3e937 /widgets | |
parent | 95412cfb1362752168923e5cd7e663cc6db5c4e8 (diff) | |
download | gsoc2013-evolution-7d63b93c516dd80bfc703e92c1502e55ae3c1f97.tar gsoc2013-evolution-7d63b93c516dd80bfc703e92c1502e55ae3c1f97.tar.gz gsoc2013-evolution-7d63b93c516dd80bfc703e92c1502e55ae3c1f97.tar.bz2 gsoc2013-evolution-7d63b93c516dd80bfc703e92c1502e55ae3c1f97.tar.lz gsoc2013-evolution-7d63b93c516dd80bfc703e92c1502e55ae3c1f97.tar.xz gsoc2013-evolution-7d63b93c516dd80bfc703e92c1502e55ae3c1f97.tar.zst gsoc2013-evolution-7d63b93c516dd80bfc703e92c1502e55ae3c1f97.zip |
Get the title bar for the folder view to use TigerT's pin icon for the
button when appropriate.
svn path=/trunk/; revision=5636
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/misc/ChangeLog | 14 | ||||
-rw-r--r-- | widgets/misc/e-title-bar.c | 221 | ||||
-rw-r--r-- | widgets/misc/e-title-bar.h | 30 |
3 files changed, 209 insertions, 56 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog index 1261de9ef8..a50bbd1dfd 100644 --- a/widgets/misc/ChangeLog +++ b/widgets/misc/ChangeLog @@ -1,3 +1,17 @@ +2000-09-29 Ettore Perazzoli <ettore@helixcode.com> + + * e-title-bar.c: New member `pin_gtk_pixmap' in + `ETitleBarPrivate'. Signal "close_button_clicked" renamed to + "button_clicked". Signal "title_button_press_event" renamed to + "label_button_press_event". + (init): Init new members. + (close_button_realize_cb): Create the pin pixmap. Call + `show_and_hide_pixmaps_according_to_mode()'. + (e_title_bar_show_close_button): Renamed to + `e_title_bar_show_button'. + (e_title_bar_get_button_mode): New. + (e_title_bar_set_button_mode): New. + 2000-09-23 Damon Chaplin <damon@helixcode.com> * e-calendar.c: use pixmaps instead of GtkArrows to look better. diff --git a/widgets/misc/e-title-bar.c b/widgets/misc/e-title-bar.c index 613df2dcde..8ca6885ccf 100644 --- a/widgets/misc/e-title-bar.c +++ b/widgets/misc/e-title-bar.c @@ -40,14 +40,16 @@ enum { - TITLE_BUTTON_PRESS_EVENT, - CLOSE_BUTTON_CLICKED, + LABEL_BUTTON_PRESS_EVENT, + BUTTON_CLICKED, LAST_SIGNAL }; static guint signals[LAST_SIGNAL] = { 0 }; -static char *close_button_xpm[] = { +/* The pixmaps. */ + +static char *close_xpm[] = { "12 12 2 1", " c none", ". c #000000000000", @@ -65,54 +67,152 @@ static char *close_button_xpm[] = { " " }; +static char *pin_xpm[] = { + "16 16 33 1", + " c None", + ". c #000000", + "+ c #74744D", + "@ c #B2B279", + "# c #6C6C46", + "$ c #CACA9C", + "% c #F4F4AD", + "& c #85855A", + "* c #B1B175", + "= c #9A9A66", + "- c #A9A98A", + "; c #B0B07B", + "> c #535353", + ", c #818181", + "' c #B7B7B7", + ") c #D8D8D8", + "! c #FFFFFF", + "~ c #EBEBA1", + "{ c #8A8A75", + "] c #9F9F76", + "^ c #9E9E75", + "/ c #8A8A66", + "( c #979770", + "_ c #6B6B46", + ": c #28281A", + "< c #505034", + "[ c #666645", + "} c #61614D", + "| c #818155", + "1 c #4A4A31", + "2 c #4D4D34", + "3 c #6C6C48", + "4 c #5D5D3E", + " ", + " ", + " ", + " . . ", + " .. .+. ", + " .@...#$. ", + " ......%&*=-;. ", + ".>,')!.~{]^/(. ", + " ......_:<[}|. ", + " .1...23. ", + " .. .4. ", + " . . ", + " ", + " ", + " ", + " " +}; + + #define PARENT_TYPE GTK_TYPE_FRAME static GtkFrameClass *parent_class = NULL; struct _ETitleBarPrivate { + ETitleBarButtonMode button_mode; GtkWidget *label; - GtkWidget *close_button; - GtkWidget *close_button_gtk_pixmap; + GtkWidget *button; + GtkWidget *close_gtk_pixmap; + GtkWidget *pin_gtk_pixmap; }; +/* Mode handling. We put both the close and pin GtkPixmaps into an hbox in the + button, and hide one of them according to the mode. */ + +static void +show_and_hide_pixmaps_according_to_mode (ETitleBar *title_bar) +{ + ETitleBarPrivate *priv; + + priv = title_bar->priv; + + if (priv->close_gtk_pixmap == NULL || priv->pin_gtk_pixmap == NULL) + return; + + switch (priv->button_mode) { + case E_TITLE_BAR_BUTTON_MODE_PIN: + gtk_widget_hide (priv->close_gtk_pixmap); + gtk_widget_show (priv->pin_gtk_pixmap); + break; + case E_TITLE_BAR_BUTTON_MODE_CLOSE: + gtk_widget_hide (priv->pin_gtk_pixmap); + gtk_widget_show (priv->close_gtk_pixmap); + break; + default: + g_assert_not_reached (); + } +} + + /* Child signal callbacks. */ static void -close_button_realize_cb (GtkWidget *widget, - gpointer data) +button_realize_cb (GtkWidget *widget, + gpointer data) { - GdkPixmap *close_button_pixmap; - GdkBitmap *close_button_mask; + GdkPixmap *close_pixmap; + GdkBitmap *close_mask; + GdkPixmap *pin_pixmap; + GdkBitmap *pin_mask; + GtkWidget *hbox; ETitleBar *title_bar; ETitleBarPrivate *priv; title_bar = E_TITLE_BAR (data); priv = title_bar->priv; - if (priv->close_button_gtk_pixmap != NULL) + if (priv->close_gtk_pixmap != NULL) return; - close_button_pixmap = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (priv->close_button)->window, - &close_button_mask, - NULL, close_button_xpm); - priv->close_button_gtk_pixmap = gtk_pixmap_new (close_button_pixmap, close_button_mask); + close_pixmap = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (priv->button)->window, + &close_mask, NULL, close_xpm); + priv->close_gtk_pixmap = gtk_pixmap_new (close_pixmap, close_mask); + + pin_pixmap = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (priv->button)->window, + &pin_mask, NULL, pin_xpm); + priv->pin_gtk_pixmap = gtk_pixmap_new (pin_pixmap, pin_mask); + + hbox = gtk_hbox_new (TRUE, 0); + gtk_widget_show (hbox); + gtk_box_pack_start (GTK_BOX (hbox), priv->pin_gtk_pixmap, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (hbox), priv->close_gtk_pixmap, TRUE, TRUE, 0); - gtk_container_add (GTK_CONTAINER (priv->close_button), priv->close_button_gtk_pixmap); - gtk_widget_show (priv->close_button_gtk_pixmap); + gtk_container_add (GTK_CONTAINER (priv->button), hbox); - gdk_pixmap_unref (close_button_pixmap); - gdk_bitmap_unref (close_button_mask); + gdk_pixmap_unref (close_pixmap); + gdk_bitmap_unref (close_mask); + gdk_pixmap_unref (pin_pixmap); + gdk_bitmap_unref (pin_mask); + + show_and_hide_pixmaps_according_to_mode (title_bar); } static void -close_button_clicked_cb (GtkButton *button, - gpointer data) +button_clicked_cb (GtkButton *button, + gpointer data) { ETitleBar *title_bar; title_bar = E_TITLE_BAR (data); - gtk_signal_emit (GTK_OBJECT (title_bar), signals[CLOSE_BUTTON_CLICKED]); + gtk_signal_emit (GTK_OBJECT (title_bar), signals[BUTTON_CLICKED]); } static void @@ -124,7 +224,7 @@ label_button_press_event_cb (GtkWidget *widget, title_bar = E_TITLE_BAR (data); - gtk_signal_emit (GTK_OBJECT (title_bar), signals[TITLE_BUTTON_PRESS_EVENT], event); + gtk_signal_emit (GTK_OBJECT (title_bar), signals[LABEL_BUTTON_PRESS_EVENT], event); } @@ -155,20 +255,20 @@ class_init (ETitleBarClass *klass) parent_class = gtk_type_class (gtk_frame_get_type ()); - signals[TITLE_BUTTON_PRESS_EVENT] = - gtk_signal_new ("title_button_press_event", + signals[LABEL_BUTTON_PRESS_EVENT] = + gtk_signal_new ("label_button_press_event", GTK_RUN_FIRST, object_class->type, - GTK_SIGNAL_OFFSET (ETitleBarClass, title_button_press_event), + GTK_SIGNAL_OFFSET (ETitleBarClass, label_button_press_event), gtk_marshal_NONE__POINTER, GTK_TYPE_NONE, 1, GTK_TYPE_GDK_EVENT); - signals[CLOSE_BUTTON_CLICKED] = - gtk_signal_new ("close_button_clicked", + signals[BUTTON_CLICKED] = + gtk_signal_new ("button_clicked", GTK_RUN_FIRST, object_class->type, - GTK_SIGNAL_OFFSET (ETitleBarClass, close_button_clicked), + GTK_SIGNAL_OFFSET (ETitleBarClass, button_clicked), gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); @@ -182,9 +282,11 @@ init (ETitleBar *title_bar) priv = g_new (ETitleBarPrivate, 1); - priv->label = NULL; - priv->close_button = NULL; - priv->close_button_gtk_pixmap = NULL; + priv->button_mode = E_TITLE_BAR_BUTTON_MODE_CLOSE; + priv->label = NULL; + priv->button = NULL; + priv->close_gtk_pixmap = NULL; + priv->pin_gtk_pixmap = NULL; title_bar->priv = priv; } @@ -206,23 +308,23 @@ e_title_bar_construct (ETitleBar *title_bar, gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5); gtk_widget_show (priv->label); - priv->close_button = gtk_button_new (); - GTK_WIDGET_UNSET_FLAGS (priv->close_button, GTK_CAN_FOCUS); - gtk_container_set_border_width (GTK_CONTAINER (priv->close_button), 1); - gtk_button_set_relief (GTK_BUTTON (priv->close_button), GTK_RELIEF_NONE); - gtk_widget_show (priv->close_button); + priv->button = gtk_button_new (); + GTK_WIDGET_UNSET_FLAGS (priv->button, GTK_CAN_FOCUS); + gtk_container_set_border_width (GTK_CONTAINER (priv->button), 1); + gtk_button_set_relief (GTK_BUTTON (priv->button), GTK_RELIEF_NONE); + gtk_widget_show (priv->button); hbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), priv->label, TRUE, TRUE, 2); - gtk_box_pack_start (GTK_BOX (hbox), priv->close_button, FALSE, TRUE, 1); + gtk_box_pack_start (GTK_BOX (hbox), priv->button, FALSE, TRUE, 1); gtk_widget_show (hbox); gtk_container_add (GTK_CONTAINER (title_bar), hbox); - gtk_signal_connect (GTK_OBJECT (priv->close_button), "realize", - GTK_SIGNAL_FUNC (close_button_realize_cb), title_bar); - gtk_signal_connect (GTK_OBJECT (priv->close_button), "clicked", - GTK_SIGNAL_FUNC (close_button_clicked_cb), title_bar); + gtk_signal_connect (GTK_OBJECT (priv->button), "realize", + GTK_SIGNAL_FUNC (button_realize_cb), title_bar); + gtk_signal_connect (GTK_OBJECT (priv->button), "clicked", + GTK_SIGNAL_FUNC (button_clicked_cb), title_bar); gtk_signal_connect (GTK_OBJECT (priv->label), "button_press_event", GTK_SIGNAL_FUNC (label_button_press_event_cb), title_bar); } @@ -251,8 +353,8 @@ e_title_bar_set_title (ETitleBar *title_bar, } void -e_title_bar_show_close_button (ETitleBar *title_bar, - gboolean show) +e_title_bar_show_button (ETitleBar *title_bar, + gboolean show) { ETitleBarPrivate *priv; @@ -262,9 +364,38 @@ e_title_bar_show_close_button (ETitleBar *title_bar, priv = title_bar->priv; if (show) - gtk_widget_show (priv->close_button); + gtk_widget_show (priv->button); else - gtk_widget_hide (priv->close_button); + gtk_widget_hide (priv->button); +} + +void +e_title_bar_set_button_mode (ETitleBar *title_bar, + ETitleBarButtonMode button_mode) +{ + ETitleBarPrivate *priv; + + g_return_if_fail (title_bar != NULL); + g_return_if_fail (E_IS_TITLE_BAR (title_bar)); + g_return_if_fail (button_mode == E_TITLE_BAR_BUTTON_MODE_CLOSE + || button_mode == E_TITLE_BAR_BUTTON_MODE_PIN); + + priv = title_bar->priv; + + if (priv->button_mode == button_mode) + return; + + priv->button_mode = button_mode; + show_and_hide_pixmaps_according_to_mode (title_bar); +} + +ETitleBarButtonMode +e_title_bar_get_button_mode (ETitleBar *title_bar) +{ + g_return_val_if_fail (title_bar != NULL, E_TITLE_BAR_BUTTON_MODE_CLOSE); + g_return_val_if_fail (E_IS_TITLE_BAR (title_bar), E_TITLE_BAR_BUTTON_MODE_CLOSE); + + return title_bar->priv->button_mode; } diff --git a/widgets/misc/e-title-bar.h b/widgets/misc/e-title-bar.h index ce7d23b07b..f91e76c889 100644 --- a/widgets/misc/e-title-bar.h +++ b/widgets/misc/e-title-bar.h @@ -42,6 +42,12 @@ extern "C" { #define E_IS_TITLE_BAR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_TITLE_BAR)) +enum _ETitleBarButtonMode { + E_TITLE_BAR_BUTTON_MODE_PIN, + E_TITLE_BAR_BUTTON_MODE_CLOSE +}; +typedef enum _ETitleBarButtonMode ETitleBarButtonMode; + typedef struct _ETitleBar ETitleBar; typedef struct _ETitleBarPrivate ETitleBarPrivate; typedef struct _ETitleBarClass ETitleBarClass; @@ -57,20 +63,22 @@ struct _ETitleBarClass { /* Signals. */ - void (* title_button_press_event) (ETitleBar *title_bar, GdkEventButton *event); - void (* close_button_clicked) (ETitleBar *title_bar); + void (* label_button_press_event) (ETitleBar *title_bar, GdkEventButton *event); + void (* button_clicked) (ETitleBar *title_bar); }; -GtkType e_title_bar_get_type (void); -void e_title_bar_construct (ETitleBar *title_bar, - const char *title); -GtkWidget *e_title_bar_new (const char *title); - -void e_title_bar_set_title (ETitleBar *title_bar, - const char *title); -void e_title_bar_show_close_button (ETitleBar *title_bar, - gboolean show); +GtkType e_title_bar_get_type (void); +void e_title_bar_construct (ETitleBar *title_bar, + const char *title); +GtkWidget *e_title_bar_new (const char *title); +void e_title_bar_set_title (ETitleBar *title_bar, + const char *title); +void e_title_bar_show_button (ETitleBar *title_bar, + gboolean show); +void e_title_bar_set_button_mode (ETitleBar *title_bar, + ETitleBarButtonMode button_mode); +ETitleBarButtonMode e_title_bar_get_button_mode (ETitleBar *title_bar); #ifdef __cplusplus } |