derive GimpStatusbar from GtkStatusbar. Use the normal statusbar label for

2008-03-27  Sven Neumann  <sven@gimp.org>

	* app/display/gimpstatusbar.[ch]: derive GimpStatusbar from
	GtkStatusbar. Use the normal statusbar label for statusbar
	messages and only show the progressbar when progress is active.

	* app/display/gimpdisplayshell.c (gimp_display_shell_new): removed
	spacing from the main vertical box.

svn path=/trunk/; revision=25257
This commit is contained in:
Sven Neumann
2008-03-27 10:43:55 +00:00
committed by Sven Neumann
parent afc6fc11ed
commit 81c46c382b
4 changed files with 67 additions and 34 deletions

View File

@ -1,3 +1,12 @@
2008-03-27 Sven Neumann <sven@gimp.org>
* app/display/gimpstatusbar.[ch]: derive GimpStatusbar from
GtkStatusbar. Use the normal statusbar label for statusbar
messages and only show the progressbar when progress is active.
* app/display/gimpdisplayshell.c (gimp_display_shell_new): removed
spacing from the main vertical box.
2008-03-27 Sven Neumann <sven@gimp.org> 2008-03-27 Sven Neumann <sven@gimp.org>
* plug-ins/common/dicom.c (dicom_loader): cosmetic changes. * plug-ins/common/dicom.c (dicom_loader): cosmetic changes.

View File

@ -865,7 +865,7 @@ gimp_display_shell_new (GimpDisplay *display,
/* the vbox containing all widgets */ /* the vbox containing all widgets */
main_vbox = gtk_vbox_new (FALSE, 1); main_vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (shell), main_vbox); gtk_container_add (GTK_CONTAINER (shell), main_vbox);
#ifndef GDK_WINDOWING_QUARTZ #ifndef GDK_WINDOWING_QUARTZ

View File

@ -118,7 +118,7 @@ static gchar * gimp_statusbar_vprintf (const gchar *format,
va_list args); va_list args);
G_DEFINE_TYPE_WITH_CODE (GimpStatusbar, gimp_statusbar, GTK_TYPE_HBOX, G_DEFINE_TYPE_WITH_CODE (GimpStatusbar, gimp_statusbar, GTK_TYPE_STATUSBAR,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PROGRESS, G_IMPLEMENT_INTERFACE (GIMP_TYPE_PROGRESS,
gimp_statusbar_progress_iface_init)) gimp_statusbar_progress_iface_init))
@ -155,7 +155,7 @@ gimp_statusbar_progress_iface_init (GimpProgressInterface *iface)
static void static void
gimp_statusbar_init (GimpStatusbar *statusbar) gimp_statusbar_init (GimpStatusbar *statusbar)
{ {
GtkBox *box = GTK_BOX (statusbar); GtkWidget *hbox;
GimpUnitStore *store; GimpUnitStore *store;
statusbar->shell = NULL; statusbar->shell = NULL;
@ -173,18 +173,17 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
statusbar->progress_active = FALSE; statusbar->progress_active = FALSE;
statusbar->progress_shown = FALSE; statusbar->progress_shown = FALSE;
box->spacing = 2; /* remove the label and insert a hbox */
box->homogeneous = FALSE; gtk_container_remove (GTK_CONTAINER (GTK_STATUSBAR (statusbar)->frame),
g_object_ref (GTK_STATUSBAR (statusbar)->label));
statusbar->cursor_frame = gtk_hbox_new (FALSE, 0); hbox = gtk_hbox_new (FALSE, 1);
gtk_box_pack_start (box, statusbar->cursor_frame, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (GTK_STATUSBAR (statusbar)->frame), hbox);
gtk_box_reorder_child (box, statusbar->cursor_frame, 0); gtk_widget_show (hbox);
gtk_widget_show (statusbar->cursor_frame);
statusbar->cursor_label = gtk_label_new ("0, 0"); statusbar->cursor_label = gtk_label_new ("0, 0");
gtk_misc_set_alignment (GTK_MISC (statusbar->cursor_label), 0.5, 0.5); gtk_misc_set_alignment (GTK_MISC (statusbar->cursor_label), 0.5, 0.5);
gtk_container_add (GTK_CONTAINER (statusbar->cursor_frame), gtk_box_pack_start (GTK_BOX (hbox), statusbar->cursor_label, FALSE, FALSE, 0);
statusbar->cursor_label);
gtk_widget_show (statusbar->cursor_label); gtk_widget_show (statusbar->cursor_label);
store = gimp_unit_store_new (2); store = gimp_unit_store_new (2);
@ -193,8 +192,7 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
GTK_WIDGET_UNSET_FLAGS (statusbar->unit_combo, GTK_CAN_FOCUS); GTK_WIDGET_UNSET_FLAGS (statusbar->unit_combo, GTK_CAN_FOCUS);
g_object_set (statusbar->unit_combo, "focus-on-click", FALSE, NULL); g_object_set (statusbar->unit_combo, "focus-on-click", FALSE, NULL);
gtk_container_add (GTK_CONTAINER (statusbar->cursor_frame), gtk_box_pack_start (GTK_BOX (hbox), statusbar->unit_combo, FALSE, FALSE, 0);
statusbar->unit_combo);
gtk_widget_show (statusbar->unit_combo); gtk_widget_show (statusbar->unit_combo);
g_signal_connect (statusbar->unit_combo, "changed", g_signal_connect (statusbar->unit_combo, "changed",
@ -204,13 +202,18 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
statusbar->scale_combo = gimp_scale_combo_box_new (); statusbar->scale_combo = gimp_scale_combo_box_new ();
GTK_WIDGET_UNSET_FLAGS (statusbar->scale_combo, GTK_CAN_FOCUS); GTK_WIDGET_UNSET_FLAGS (statusbar->scale_combo, GTK_CAN_FOCUS);
g_object_set (statusbar->scale_combo, "focus-on-click", FALSE, NULL); g_object_set (statusbar->scale_combo, "focus-on-click", FALSE, NULL);
gtk_box_pack_start (box, 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); gtk_widget_show (statusbar->scale_combo);
g_signal_connect (statusbar->scale_combo, "changed", g_signal_connect (statusbar->scale_combo, "changed",
G_CALLBACK (gimp_statusbar_scale_changed), G_CALLBACK (gimp_statusbar_scale_changed),
statusbar); statusbar);
/* put the label back into our hbox */
gtk_box_pack_start (GTK_BOX (hbox),
GTK_STATUSBAR (statusbar)->label, TRUE, TRUE, 0);
g_object_unref (GTK_STATUSBAR (statusbar)->label);
statusbar->progressbar = gtk_progress_bar_new (); statusbar->progressbar = gtk_progress_bar_new ();
gtk_progress_bar_set_ellipsize (GTK_PROGRESS_BAR (statusbar->progressbar), gtk_progress_bar_set_ellipsize (GTK_PROGRESS_BAR (statusbar->progressbar),
PANGO_ELLIPSIZE_END); PANGO_ELLIPSIZE_END);
@ -218,8 +221,8 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
"text-xalign", 0.0, "text-xalign", 0.0,
"text-yalign", 0.5, "text-yalign", 0.5,
NULL); NULL);
gtk_box_pack_start (box, statusbar->progressbar, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), statusbar->progressbar, TRUE, TRUE, 0);
gtk_widget_show (statusbar->progressbar); /* don't show the progress bar */
g_signal_connect_after (statusbar->progressbar, "style-set", g_signal_connect_after (statusbar->progressbar, "style-set",
G_CALLBACK (gimp_statusbar_progress_style_set), G_CALLBACK (gimp_statusbar_progress_style_set),
@ -230,8 +233,10 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
statusbar->cancel_button = gtk_button_new_with_label (_("Cancel")); statusbar->cancel_button = gtk_button_new_with_label (_("Cancel"));
gtk_widget_set_sensitive (statusbar->cancel_button, FALSE); gtk_widget_set_sensitive (statusbar->cancel_button, FALSE);
gtk_box_pack_start (box, statusbar->cancel_button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox),
statusbar->cancel_button, FALSE, FALSE, 0);
GTK_WIDGET_UNSET_FLAGS (statusbar->cancel_button, GTK_CAN_FOCUS); GTK_WIDGET_UNSET_FLAGS (statusbar->cancel_button, GTK_CAN_FOCUS);
/* don't show the cancel button */
g_signal_connect (statusbar->cancel_button, "clicked", g_signal_connect (statusbar->cancel_button, "clicked",
G_CALLBACK (gimp_statusbar_progress_canceled), G_CALLBACK (gimp_statusbar_progress_canceled),
@ -281,9 +286,6 @@ gimp_statusbar_size_request (GtkWidget *widget,
/* also consider the children which can be invisible */ /* also consider the children which can be invisible */
gtk_widget_size_request (statusbar->cursor_frame, &child_requisition);
requisition->height = MAX (requisition->height, child_requisition.height);
gtk_widget_size_request (statusbar->unit_combo, &child_requisition); gtk_widget_size_request (statusbar->unit_combo, &child_requisition);
requisition->height = MAX (requisition->height, child_requisition.height); requisition->height = MAX (requisition->height, child_requisition.height);
@ -302,6 +304,9 @@ gimp_statusbar_progress_start (GimpProgress *progress,
{ {
GtkWidget *bar = statusbar->progressbar; GtkWidget *bar = statusbar->progressbar;
statusbar->progress_active = TRUE;
statusbar->progress_value = 0.0;
gimp_statusbar_push (statusbar, "progress", "%s", message); gimp_statusbar_push (statusbar, "progress", "%s", message);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (bar), 0.0); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (bar), 0.0);
gtk_widget_set_sensitive (statusbar->cancel_button, cancelable); gtk_widget_set_sensitive (statusbar->cancel_button, cancelable);
@ -309,8 +314,13 @@ gimp_statusbar_progress_start (GimpProgress *progress,
if (cancelable) if (cancelable)
gtk_widget_show (statusbar->cancel_button); gtk_widget_show (statusbar->cancel_button);
statusbar->progress_active = TRUE; gtk_widget_show (statusbar->progressbar);
statusbar->progress_value = 0.0; gtk_widget_hide (GTK_STATUSBAR (statusbar)->label);
/* This call is needed so that the progress bar is drawn in the
* correct place. Probably due a bug in GTK+.
*/
gtk_container_resize_children (GTK_CONTAINER (GTK_STATUSBAR (statusbar)->frame));
if (! GTK_WIDGET_VISIBLE (statusbar)) if (! GTK_WIDGET_VISIBLE (statusbar))
{ {
@ -345,7 +355,11 @@ gimp_statusbar_progress_end (GimpProgress *progress)
statusbar->progress_active = FALSE; statusbar->progress_active = FALSE;
statusbar->progress_value = 0.0; statusbar->progress_value = 0.0;
gtk_widget_hide (bar);
gtk_widget_show (GTK_STATUSBAR (statusbar)->label);
gimp_statusbar_pop (statusbar, "progress"); gimp_statusbar_pop (statusbar, "progress");
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (bar), 0.0); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (bar), 0.0);
gtk_widget_set_sensitive (statusbar->cancel_button, FALSE); gtk_widget_set_sensitive (statusbar->cancel_button, FALSE);
gtk_widget_hide (statusbar->cancel_button); gtk_widget_hide (statusbar->cancel_button);
@ -459,6 +473,16 @@ gimp_statusbar_progress_canceled (GtkWidget *button,
gimp_progress_cancel (GIMP_PROGRESS (statusbar)); gimp_progress_cancel (GIMP_PROGRESS (statusbar));
} }
static void
gimp_statusbar_set_text (GimpStatusbar *statusbar,
const gchar *text)
{
if (statusbar->progress_active)
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (statusbar->progressbar), text);
else
gtk_label_set_text (GTK_LABEL (GTK_STATUSBAR (statusbar)->label), text);
}
static void static void
gimp_statusbar_update (GimpStatusbar *statusbar) gimp_statusbar_update (GimpStatusbar *statusbar)
{ {
@ -484,14 +508,13 @@ gimp_statusbar_update (GimpStatusbar *statusbar)
if (text && statusbar->temp_timeout_id) if (text && statusbar->temp_timeout_id)
{ {
gchar *temp = g_strconcat (statusbar->temp_spaces, text, NULL); gchar *temp = g_strconcat (statusbar->temp_spaces, text, NULL);
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (statusbar->progressbar),
temp); gimp_statusbar_set_text (statusbar, temp);
g_free (temp); g_free (temp);
} }
else else
{ {
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (statusbar->progressbar), gimp_statusbar_set_text (statusbar, text ? text : "");
text ? text : "");
} }
} }
@ -564,7 +587,7 @@ gimp_statusbar_empty (GimpStatusbar *statusbar)
{ {
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar)); g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
gtk_widget_hide (statusbar->cursor_frame); gtk_widget_hide (statusbar->cursor_label);
gtk_widget_hide (statusbar->unit_combo); gtk_widget_hide (statusbar->unit_combo);
gtk_widget_hide (statusbar->scale_combo); gtk_widget_hide (statusbar->scale_combo);
} }
@ -574,7 +597,7 @@ gimp_statusbar_fill (GimpStatusbar *statusbar)
{ {
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar)); g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
gtk_widget_show (statusbar->cursor_frame); gtk_widget_show (statusbar->cursor_label);
gtk_widget_show (statusbar->unit_combo); gtk_widget_show (statusbar->unit_combo);
gtk_widget_show (statusbar->scale_combo); gtk_widget_show (statusbar->scale_combo);
} }
@ -1122,6 +1145,7 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
static PangoLayout *layout = NULL; static PangoLayout *layout = NULL;
GimpImage *image = shell->display->image; GimpImage *image = shell->display->image;
GtkWidget *parent;
GtkTreeModel *model; GtkTreeModel *model;
const gchar *text; const gchar *text;
gint image_width; gint image_width;
@ -1199,14 +1223,15 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
/* find out how many pixels the label's parent frame is bigger than /* find out how many pixels the label's parent frame is bigger than
* the label itself * the label itself
*/ */
diff = (statusbar->cursor_frame->allocation.width - parent = gtk_widget_get_parent (statusbar->cursor_label);
diff = (parent->allocation.width -
statusbar->cursor_label->allocation.width); statusbar->cursor_label->allocation.width);
gtk_widget_set_size_request (statusbar->cursor_label, width, -1); gtk_widget_set_size_request (statusbar->cursor_label, width, -1);
/* don't resize if this is a new display */ /* don't resize if this is a new display */
if (diff) if (diff)
gtk_widget_set_size_request (statusbar->cursor_frame, width + diff, -1); gtk_widget_set_size_request (parent, width + diff, -1);
gimp_statusbar_clear_cursor (statusbar); gimp_statusbar_clear_cursor (statusbar);
} }

View File

@ -19,7 +19,7 @@
#ifndef __GIMP_STATUSBAR_H__ #ifndef __GIMP_STATUSBAR_H__
#define __GIMP_STATUSBAR_H__ #define __GIMP_STATUSBAR_H__
#include <gtk/gtkhbox.h> #include <gtk/gtkstatusbar.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@ -38,7 +38,7 @@ typedef struct _GimpStatusbarClass GimpStatusbarClass;
struct _GimpStatusbar struct _GimpStatusbar
{ {
GtkHBox parent_instance; GtkStatusbar parent_instance;
GimpDisplayShell *shell; GimpDisplayShell *shell;
@ -53,7 +53,6 @@ struct _GimpStatusbar
gchar cursor_format_str[CURSOR_FORMAT_LENGTH]; gchar cursor_format_str[CURSOR_FORMAT_LENGTH];
gchar length_format_str[CURSOR_FORMAT_LENGTH]; gchar length_format_str[CURSOR_FORMAT_LENGTH];
GtkWidget *cursor_frame;
GtkWidget *cursor_label; GtkWidget *cursor_label;
GtkWidget *unit_combo; GtkWidget *unit_combo;
GtkWidget *scale_combo; GtkWidget *scale_combo;
@ -67,7 +66,7 @@ struct _GimpStatusbar
struct _GimpStatusbarClass struct _GimpStatusbarClass
{ {
GtkHBoxClass parent_class; GtkStatusbarClass parent_class;
}; };