[gimp/gtk3-port: 444/444] app: derive GimpStatusbar from GtkFrame not GtkStatusbar
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 444/444] app: derive GimpStatusbar from GtkFrame not GtkStatusbar
- Date: Sun, 13 May 2018 22:15:13 +0000 (UTC)
commit 8e0fbc0df0b6d8cf009f26fb4162e3cf053f27f8
Author: Michael Natterer <mitch gimp org>
Date: Sun May 13 20:36:22 2018 +0200
app: derive GimpStatusbar from GtkFrame not GtkStatusbar
we were not using a single GtkStatusBar features, it was only in the
way. Remove broken size allocation logic and simply set a minimum
height of 3em in CSS. Also ellipsize the label, long labels had funny
effects since changing the overall GimpDisplayShell packing to pure
GtkGrid.
app/display/gimpstatusbar.c | 152 ++++++++++++------------------------------
app/display/gimpstatusbar.h | 4 +-
themes/System/gimp.css | 18 +-----
3 files changed, 47 insertions(+), 127 deletions(-)
---
diff --git a/app/display/gimpstatusbar.c b/app/display/gimpstatusbar.c
index a1cef96..578654b 100644
--- a/app/display/gimpstatusbar.c
+++ b/app/display/gimpstatusbar.c
@@ -46,16 +46,16 @@
#include "gimp-intl.h"
-/* maximal width of the string holding the cursor-coordinates */
+/* maximal width of the string holding the cursor-coordinates */
#define CURSOR_LEN 256
-/* the spacing of the hbox */
+/* the spacing of the hbox */
#define HBOX_SPACING 1
-/* spacing between the icon and the statusbar label */
+/* spacing between the icon and the statusbar label */
#define ICON_SPACING 2
-/* timeout (in milliseconds) for temporary statusbar messages */
+/* timeout (in milliseconds) for temporary statusbar messages */
#define MESSAGE_TIMEOUT 8000
/* minimal interval (in microseconds) between progress updates */
@@ -81,9 +81,6 @@ static void gimp_statusbar_screen_changed (GtkWidget *widget,
GdkScreen *previous);
static void gimp_statusbar_style_updated (GtkWidget *widget);
-static void gimp_statusbar_hbox_style_updated (GtkWidget *widget,
- GimpStatusbar *statusbar);
-
static GimpProgress *
gimp_statusbar_progress_start (GimpProgress *progress,
gboolean cancellable,
@@ -152,7 +149,7 @@ static GdkPixbuf * gimp_statusbar_load_icon (GimpStatusbar *statusbar,
const gchar *icon_name);
-G_DEFINE_TYPE_WITH_CODE (GimpStatusbar, gimp_statusbar, GTK_TYPE_STATUSBAR,
+G_DEFINE_TYPE_WITH_CODE (GimpStatusbar, gimp_statusbar, GTK_TYPE_FRAME,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PROGRESS,
gimp_statusbar_progress_iface_init))
@@ -170,6 +167,8 @@ gimp_statusbar_class_init (GimpStatusbarClass *klass)
widget_class->screen_changed = gimp_statusbar_screen_changed;
widget_class->style_updated = gimp_statusbar_style_updated;
+
+ gtk_widget_class_set_css_name (widget_class, "statusbar");
}
static void
@@ -193,7 +192,12 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
GtkWidget *image;
GtkWidget *widget;
GimpUnitStore *store;
- GList *children;
+
+ gtk_frame_set_shadow_type (GTK_FRAME (statusbar), GTK_SHADOW_IN);
+
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, HBOX_SPACING);
+ gtk_container_add (GTK_CONTAINER (statusbar), hbox);
+ gtk_widget_show (hbox);
statusbar->shell = NULL;
statusbar->messages = NULL;
@@ -211,22 +215,9 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
statusbar->progress_active = FALSE;
statusbar->progress_shown = FALSE;
- /* remove the message label from the message area */
- hbox = gtk_statusbar_get_message_area (GTK_STATUSBAR (statusbar));
- gtk_box_set_spacing (GTK_BOX (hbox), HBOX_SPACING);
-
- children = gtk_container_get_children (GTK_CONTAINER (hbox));
- statusbar->label = g_object_ref (children->data);
- g_list_free (children);
-
- gtk_container_remove (GTK_CONTAINER (hbox), statusbar->label);
-
- g_signal_connect_after (hbox, "style-updated",
- G_CALLBACK (gimp_statusbar_hbox_style_updated),
- statusbar);
-
statusbar->cursor_label = gtk_label_new ("8888, 8888");
- gtk_box_pack_start (GTK_BOX (hbox), statusbar->cursor_label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), statusbar->cursor_label,
+ FALSE, FALSE, 0);
gtk_widget_show (statusbar->cursor_label);
store = gimp_unit_store_new (2);
@@ -235,7 +226,8 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
gtk_widget_set_can_focus (statusbar->unit_combo, FALSE);
g_object_set (statusbar->unit_combo, "focus-on-click", FALSE, NULL);
- gtk_box_pack_start (GTK_BOX (hbox), statusbar->unit_combo, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), statusbar->unit_combo,
+ FALSE, FALSE, 0);
gtk_widget_show (statusbar->unit_combo);
g_signal_connect (statusbar->unit_combo, "changed",
@@ -245,7 +237,8 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
statusbar->scale_combo = gimp_scale_combo_box_new ();
gtk_widget_set_can_focus (statusbar->scale_combo, FALSE);
g_object_set (statusbar->scale_combo, "focus-on-click", FALSE, NULL);
- gtk_box_pack_start (GTK_BOX (hbox), statusbar->scale_combo, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), statusbar->scale_combo,
+ FALSE, FALSE, 0);
gtk_widget_show (statusbar->scale_combo);
g_signal_connect (statusbar->scale_combo, "changed",
@@ -269,31 +262,38 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
gtk_widget_show (widget);
widget = gtk_event_box_new ();
- statusbar->horizontal_flip_icon = gtk_image_new_from_icon_name ("gimp-flip-horizontal",
- GTK_ICON_SIZE_MENU);
- gtk_container_add (GTK_CONTAINER (widget), statusbar->horizontal_flip_icon);
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 1);
+ gtk_widget_show (widget);
+
+ statusbar->horizontal_flip_icon =
+ gtk_image_new_from_icon_name ("gimp-flip-horizontal",
+ GTK_ICON_SIZE_MENU);
+ gtk_container_add (GTK_CONTAINER (widget), statusbar->horizontal_flip_icon);
+ gtk_widget_show (statusbar->horizontal_flip_icon);
+
g_signal_connect (widget, "button-press-event",
G_CALLBACK (gimp_statusbar_horiz_flip_pressed),
statusbar);
- gtk_widget_show (statusbar->horizontal_flip_icon);
- gtk_widget_show (widget);
widget = gtk_event_box_new ();
- statusbar->vertical_flip_icon = gtk_image_new_from_icon_name ("gimp-flip-vertical",
- GTK_ICON_SIZE_MENU);
- gtk_container_add (GTK_CONTAINER (widget), statusbar->vertical_flip_icon);
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 1);
+ gtk_widget_show (widget);
+
+ statusbar->vertical_flip_icon =
+ gtk_image_new_from_icon_name ("gimp-flip-vertical",
+ GTK_ICON_SIZE_MENU);
+ gtk_container_add (GTK_CONTAINER (widget), statusbar->vertical_flip_icon);
+ gtk_widget_show (statusbar->vertical_flip_icon);
+
g_signal_connect (widget, "button-press-event",
G_CALLBACK (gimp_statusbar_vert_flip_pressed),
statusbar);
- gtk_widget_show (statusbar->vertical_flip_icon);
- gtk_widget_show (widget);
- /* put the label back into the message area */
+ statusbar->label = gtk_label_new ("");
+ gtk_label_set_ellipsize (GTK_LABEL (statusbar->label), PANGO_ELLIPSIZE_END);
+ gtk_widget_set_halign (GTK_WIDGET (statusbar->label), GTK_ALIGN_START);
gtk_box_pack_start (GTK_BOX (hbox), statusbar->label, TRUE, TRUE, 1);
-
- g_object_unref (statusbar->label);
+ gtk_widget_show (statusbar->label);
g_signal_connect_after (statusbar->label, "draw",
G_CALLBACK (gimp_statusbar_label_draw),
@@ -303,7 +303,8 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
"show-text", TRUE,
"ellipsize", PANGO_ELLIPSIZE_END,
NULL);
- gtk_box_pack_start (GTK_BOX (hbox), statusbar->progressbar, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), statusbar->progressbar,
+ TRUE, TRUE, 0);
/* don't show the progress bar */
/* construct the cancel button's contents manually because we
@@ -315,8 +316,8 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
gtk_button_set_relief (GTK_BUTTON (statusbar->cancel_button),
GTK_RELIEF_NONE);
gtk_widget_set_sensitive (statusbar->cancel_button, FALSE);
- gtk_box_pack_end (GTK_BOX (hbox),
- statusbar->cancel_button, FALSE, FALSE, 0);
+ gtk_box_pack_end (GTK_BOX (hbox), statusbar->cancel_button,
+ FALSE, FALSE, 0);
/* don't show the cancel button */
hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
@@ -384,74 +385,9 @@ gimp_statusbar_style_updated (GtkWidget *widget)
{
GimpStatusbar *statusbar = GIMP_STATUSBAR (widget);
- GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
-
g_clear_pointer (&statusbar->icon_hash, g_hash_table_unref);
-}
-
-static void
-gimp_statusbar_hbox_style_updated (GtkWidget *widget,
- GimpStatusbar *statusbar)
-{
- GtkRequisition requisition;
- GtkRequisition child_requisition;
- gint width = 0;
- gint height;
-
- gtk_widget_get_preferred_size (widget, &requisition, NULL);
-
- height = requisition.height;
-
- /* also consider the children which can be invisible */
-
- if (statusbar->cursor_label)
- {
- gtk_widget_get_preferred_size (statusbar->cursor_label,
- &child_requisition, NULL);
- width += child_requisition.width;
- height = MAX (height, child_requisition.height);
- }
-
- if (statusbar->unit_combo)
- {
- gtk_widget_get_preferred_size (statusbar->unit_combo,
- &child_requisition, NULL);
- width += child_requisition.width;
- height = MAX (height, child_requisition.height);
- }
- if (statusbar->scale_combo)
- {
- gtk_widget_get_preferred_size (statusbar->scale_combo,
- &child_requisition, NULL);
- width += child_requisition.width;
- height = MAX (height, child_requisition.height);
- }
-
- if (statusbar->progressbar)
- {
- gtk_widget_get_preferred_size (statusbar->progressbar,
- &child_requisition, NULL);
- height = MAX (height, child_requisition.height);
- }
-
- if (statusbar->label)
- {
- gtk_widget_get_preferred_size (statusbar->label,
- &child_requisition, NULL);
- height = MAX (height, child_requisition.height);
- }
-
- if (statusbar->cancel_button)
- {
- gtk_widget_get_preferred_size (statusbar->cancel_button,
- &child_requisition, NULL);
- height = MAX (height, child_requisition.height);
- }
-
- width = MAX (requisition.width, width + 32);
-
- gtk_widget_set_size_request (widget, width, height);
+ GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
}
static GimpProgress *
diff --git a/app/display/gimpstatusbar.h b/app/display/gimpstatusbar.h
index 4e7a807..2407225 100644
--- a/app/display/gimpstatusbar.h
+++ b/app/display/gimpstatusbar.h
@@ -36,7 +36,7 @@ typedef struct _GimpStatusbarClass GimpStatusbarClass;
struct _GimpStatusbar
{
- GtkStatusbar parent_instance;
+ GtkFrame parent_instance;
GimpDisplayShell *shell;
@@ -73,7 +73,7 @@ struct _GimpStatusbar
struct _GimpStatusbarClass
{
- GtkStatusbarClass parent_class;
+ GtkFrameClass parent_class;
};
diff --git a/themes/System/gimp.css b/themes/System/gimp.css
index 9fa7401..5df271e 100644
--- a/themes/System/gimp.css
+++ b/themes/System/gimp.css
@@ -42,25 +42,9 @@ GimpDisplayShell button {
padding: 0 0 0 0;
}
-/* i hate the statusar
GimpDisplayShell statusbar {
- min-height: 0;
- min-width: 0;
- padding: 0 0 0 0;
-}
-
-GimpDisplayShell statusbar {
- min-height: 0;
- min-width: 0;
- padding: 0 0 0 0;
-}
-
-GimpDisplayShell statusbar {
- min-height: 0;
- min-width: 0;
- padding: 0 0 0 0;
+ min-height: 3em;
}
-*/
GimpDock {
font-size: smaller;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]