Updating branch refs/heads/master to 6bdfbdf87e4ac5ffd528b6daafd9755acfe04415 (commit) from ff0faf3c3250b4e56598aec891109d96f3aece7a (commit)
commit 6bdfbdf87e4ac5ffd528b6daafd9755acfe04415 Author: Matthew Brush <mbr...@codebrainz.ca> Date: Mon Oct 3 03:56:58 2011 -0700 Revert "Drop usage of the GtkStatusbar." This reverts commit 185821ae262235222f7ef1d3a86dc0ea2b19bbd9. mousepad/mousepad-statusbar.c | 54 +++++++++++++++++----------------------- mousepad/mousepad-statusbar.h | 2 - mousepad/mousepad-window.c | 17 +++++++++++- 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/mousepad/mousepad-statusbar.c b/mousepad/mousepad-statusbar.c index dc4503f..0321c3e 100644 --- a/mousepad/mousepad-statusbar.c +++ b/mousepad/mousepad-statusbar.c @@ -39,20 +39,19 @@ enum struct _MousepadStatusbarClass { - GtkHBoxClass __parent__; + GtkStatusbarClass __parent__; }; struct _MousepadStatusbar { - GtkHBox __parent__; + GtkStatusbar __parent__; /* whether overwrite is enabled */ - guint overwrite_enabled : 1; + guint overwrite_enabled : 1; /* extra labels in the statusbar */ - GtkWidget *tooltip; - GtkWidget *position; - GtkWidget *overwrite; + GtkWidget *position; + GtkWidget *overwrite; }; @@ -61,7 +60,7 @@ static guint statusbar_signals[LAST_SIGNAL]; -G_DEFINE_TYPE (MousepadStatusbar, mousepad_statusbar, GTK_TYPE_HBOX); +G_DEFINE_TYPE (MousepadStatusbar, mousepad_statusbar, GTK_TYPE_STATUSBAR); @@ -94,38 +93,41 @@ mousepad_statusbar_class_init (MousepadStatusbarClass *klass) static void mousepad_statusbar_init (MousepadStatusbar *statusbar) { - GtkWidget *ebox, *separator; + GtkWidget *ebox, *box, *separator; + GtkStatusbar *bar = GTK_STATUSBAR (statusbar); /* init statusbar */ - gtk_box_set_spacing (GTK_BOX (statusbar), 6); - gtk_container_set_border_width (GTK_CONTAINER (statusbar), 2); + gtk_statusbar_set_has_resize_grip (bar, TRUE); - /* tooltip label */ - statusbar->tooltip = gtk_label_new (NULL); - gtk_misc_set_alignment (GTK_MISC (statusbar->tooltip), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (statusbar), statusbar->tooltip, TRUE, TRUE, 0); - gtk_label_set_ellipsize (GTK_LABEL (statusbar->tooltip), PANGO_ELLIPSIZE_END); - gtk_label_set_single_line_mode (GTK_LABEL (statusbar->tooltip), TRUE); - gtk_widget_show (statusbar->tooltip); + /* create a new horizontal box */ + box = gtk_hbox_new (FALSE, 8); + gtk_widget_show (box); + + /* reorder the gtk statusbar */ + g_object_ref (G_OBJECT (bar->label)); + gtk_container_remove (GTK_CONTAINER (bar->frame), bar->label); + gtk_container_add (GTK_CONTAINER (bar->frame), box); + gtk_box_pack_start (GTK_BOX (box), bar->label, TRUE, TRUE, 0); + g_object_unref (G_OBJECT (bar->label)); /* separator */ separator = gtk_vseparator_new (); - gtk_box_pack_start (GTK_BOX (statusbar), separator, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, 0); gtk_widget_show (separator); /* line and column numbers */ statusbar->position = gtk_label_new (NULL); - gtk_box_pack_start (GTK_BOX (statusbar), statusbar->position, FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (box), statusbar->position, FALSE, TRUE, 0); gtk_widget_show (statusbar->position); /* separator */ separator = gtk_vseparator_new (); - gtk_box_pack_start (GTK_BOX (statusbar), separator, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, 0); gtk_widget_show (separator); /* overwrite event box */ ebox = gtk_event_box_new (); - gtk_box_pack_start (GTK_BOX (statusbar), ebox, FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (box), ebox, FALSE, TRUE, 0); gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE); mousepad_widget_set_tooltip_text (ebox, _("Toggle the overwrite mode")); g_signal_connect (G_OBJECT (ebox), "button-press-event", G_CALLBACK (mousepad_statusbar_overwrite_clicked), statusbar); @@ -193,13 +195,3 @@ mousepad_statusbar_set_overwrite (MousepadStatusbar *statusbar, statusbar->overwrite_enabled = overwrite; } - - - -void -mousepad_statusbar_set_tooltip (MousepadStatusbar *statusbar, - const gchar *tooltip) -{ - mousepad_return_if_fail (MOUSEPAD_IS_STATUSBAR (statusbar)); - gtk_label_set_text (GTK_LABEL (statusbar->tooltip), tooltip); -} diff --git a/mousepad/mousepad-statusbar.h b/mousepad/mousepad-statusbar.h index 0a4fcf1..c44b54e 100644 --- a/mousepad/mousepad-statusbar.h +++ b/mousepad/mousepad-statusbar.h @@ -41,8 +41,6 @@ void mousepad_statusbar_set_cursor_position (MousepadStatusbar *statusba void mousepad_statusbar_set_overwrite (MousepadStatusbar *statusbar, gboolean overwrite); -void mousepad_statusbar_set_tooltip (MousepadStatusbar *statusbar, - const gchar *tooltip); G_END_DECLS #endif /* !__MOUSEPAD_STATUSBAR_H__ */ diff --git a/mousepad/mousepad-window.c b/mousepad/mousepad-window.c index a434867..b84ab6c 100644 --- a/mousepad/mousepad-window.c +++ b/mousepad/mousepad-window.c @@ -820,7 +820,9 @@ mousepad_window_menu_item_selected (GtkWidget *menu_item, { GtkAction *action; gchar *tooltip; + gint id; + /* we can only display tooltips if we have a statusbar */ if (G_LIKELY (window->statusbar != NULL)) { /* get the action from the menu item */ @@ -836,7 +838,11 @@ mousepad_window_menu_item_selected (GtkWidget *menu_item, if (G_LIKELY (tooltip != NULL)) { - mousepad_statusbar_set_tooltip (MOUSEPAD_STATUSBAR (window->statusbar), tooltip); + /* show the tooltip */ + id = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->statusbar), "tooltip"); + gtk_statusbar_push (GTK_STATUSBAR (window->statusbar), id, tooltip); + + /* cleanup */ g_free (tooltip); } } @@ -849,8 +855,15 @@ static void mousepad_window_menu_item_deselected (GtkWidget *menu_item, MousepadWindow *window) { + gint id; + + /* we can only undisplay tooltips if we have a statusbar */ if (G_LIKELY (window->statusbar != NULL)) - mousepad_statusbar_set_tooltip (MOUSEPAD_STATUSBAR (window->statusbar), NULL); + { + /* drop the last tooltip from the statusbar */ + id = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->statusbar), "tooltip"); + gtk_statusbar_pop (GTK_STATUSBAR (window->statusbar), id); + } } _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits