Add gimp_statusbar_set_shell()

Reconnect signals when a new shell is set; reorganize internal code to
not set up permanent connections to one specific shell.
This commit is contained in:
Michael Natterer
2009-09-24 09:35:34 +02:00
parent 571cdd47ed
commit 82aa4084ab
2 changed files with 40 additions and 9 deletions

View File

@ -105,6 +105,8 @@ static void gimp_statusbar_unit_changed (GimpUnitComboBox *combo,
GimpStatusbar *statusbar); GimpStatusbar *statusbar);
static void gimp_statusbar_scale_changed (GimpScaleComboBox *combo, static void gimp_statusbar_scale_changed (GimpScaleComboBox *combo,
GimpStatusbar *statusbar); GimpStatusbar *statusbar);
static void gimp_statusbar_scale_activated (GimpScaleComboBox *combo,
GimpStatusbar *statusbar);
static void gimp_statusbar_shell_scaled (GimpDisplayShell *shell, static void gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
GimpStatusbar *statusbar); GimpStatusbar *statusbar);
static guint gimp_statusbar_get_context_id (GimpStatusbar *statusbar, static guint gimp_statusbar_get_context_id (GimpStatusbar *statusbar,
@ -207,6 +209,10 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
G_CALLBACK (gimp_statusbar_scale_changed), G_CALLBACK (gimp_statusbar_scale_changed),
statusbar); statusbar);
g_signal_connect (statusbar->scale_combo, "entry-activated",
G_CALLBACK (gimp_statusbar_scale_activated),
statusbar);
/* put the label back into our hbox */ /* put the label back into our hbox */
gtk_box_pack_start (GTK_BOX (hbox), gtk_box_pack_start (GTK_BOX (hbox),
GTK_STATUSBAR (statusbar)->label, TRUE, TRUE, 1); GTK_STATUSBAR (statusbar)->label, TRUE, TRUE, 1);
@ -651,19 +657,35 @@ gimp_statusbar_new (GimpDisplayShell *shell)
statusbar = g_object_new (GIMP_TYPE_STATUSBAR, NULL); statusbar = g_object_new (GIMP_TYPE_STATUSBAR, NULL);
statusbar->shell = shell; gimp_statusbar_set_shell (statusbar, shell);
g_signal_connect_object (shell, "scaled",
G_CALLBACK (gimp_statusbar_shell_scaled),
statusbar, 0);
g_signal_connect_object (statusbar->scale_combo, "entry-activated",
G_CALLBACK (gtk_widget_grab_focus),
shell->canvas, G_CONNECT_SWAPPED);
return GTK_WIDGET (statusbar); return GTK_WIDGET (statusbar);
} }
void
gimp_statusbar_set_shell (GimpStatusbar *statusbar,
GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (shell == statusbar->shell)
return;
if (statusbar->shell)
{
g_signal_handlers_disconnect_by_func (statusbar->shell,
gimp_statusbar_shell_scaled,
statusbar);
}
statusbar->shell = shell;
g_signal_connect_object (statusbar->shell, "scaled",
G_CALLBACK (gimp_statusbar_shell_scaled),
statusbar, 0);
}
gboolean gboolean
gimp_statusbar_get_visible (GimpStatusbar *statusbar) gimp_statusbar_get_visible (GimpStatusbar *statusbar)
{ {
@ -1391,6 +1413,13 @@ gimp_statusbar_scale_changed (GimpScaleComboBox *combo,
GIMP_ZOOM_FOCUS_BEST_GUESS); GIMP_ZOOM_FOCUS_BEST_GUESS);
} }
static void
gimp_statusbar_scale_activated (GimpScaleComboBox *combo,
GimpStatusbar *statusbar)
{
gtk_widget_grab_focus (statusbar->shell->canvas);
}
static guint static guint
gimp_statusbar_get_context_id (GimpStatusbar *statusbar, gimp_statusbar_get_context_id (GimpStatusbar *statusbar,
const gchar *context) const gchar *context)

View File

@ -73,6 +73,8 @@ struct _GimpStatusbarClass
GType gimp_statusbar_get_type (void) G_GNUC_CONST; GType gimp_statusbar_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_statusbar_new (GimpDisplayShell *shell); GtkWidget * gimp_statusbar_new (GimpDisplayShell *shell);
void gimp_statusbar_set_shell (GimpStatusbar *statusbar,
GimpDisplayShell *shell);
gboolean gimp_statusbar_get_visible (GimpStatusbar *statusbar); gboolean gimp_statusbar_get_visible (GimpStatusbar *statusbar);
void gimp_statusbar_set_visible (GimpStatusbar *statusbar, void gimp_statusbar_set_visible (GimpStatusbar *statusbar,