[gimp] Add gimp_statusbar_set_shell()
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Add gimp_statusbar_set_shell()
- Date: Tue, 29 Sep 2009 18:37:13 +0000 (UTC)
commit 82aa4084abd2b8d87bce345185aab9087fb27c8a
Author: Michael Natterer <mitch gimp org>
Date: Thu Sep 24 09:35:34 2009 +0200
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.
app/display/gimpstatusbar.c | 43 ++++++++++++++++++++++++++++++++++++-------
app/display/gimpstatusbar.h | 2 ++
2 files changed, 38 insertions(+), 7 deletions(-)
---
diff --git a/app/display/gimpstatusbar.c b/app/display/gimpstatusbar.c
index 99756d4..94c0288 100644
--- a/app/display/gimpstatusbar.c
+++ b/app/display/gimpstatusbar.c
@@ -105,6 +105,8 @@ static void gimp_statusbar_unit_changed (GimpUnitComboBox *combo,
GimpStatusbar *statusbar);
static void gimp_statusbar_scale_changed (GimpScaleComboBox *combo,
GimpStatusbar *statusbar);
+static void gimp_statusbar_scale_activated (GimpScaleComboBox *combo,
+ GimpStatusbar *statusbar);
static void gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
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),
statusbar);
+ g_signal_connect (statusbar->scale_combo, "entry-activated",
+ G_CALLBACK (gimp_statusbar_scale_activated),
+ statusbar);
+
/* put the label back into our hbox */
gtk_box_pack_start (GTK_BOX (hbox),
GTK_STATUSBAR (statusbar)->label, TRUE, TRUE, 1);
@@ -651,17 +657,33 @@ gimp_statusbar_new (GimpDisplayShell *shell)
statusbar = g_object_new (GIMP_TYPE_STATUSBAR, NULL);
+ gimp_statusbar_set_shell (statusbar, shell);
+
+ 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 (shell, "scaled",
+ g_signal_connect_object (statusbar->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);
}
gboolean
@@ -1391,6 +1413,13 @@ gimp_statusbar_scale_changed (GimpScaleComboBox *combo,
GIMP_ZOOM_FOCUS_BEST_GUESS);
}
+static void
+gimp_statusbar_scale_activated (GimpScaleComboBox *combo,
+ GimpStatusbar *statusbar)
+{
+ gtk_widget_grab_focus (statusbar->shell->canvas);
+}
+
static guint
gimp_statusbar_get_context_id (GimpStatusbar *statusbar,
const gchar *context)
diff --git a/app/display/gimpstatusbar.h b/app/display/gimpstatusbar.h
index 6582e24..bebc2ed 100644
--- a/app/display/gimpstatusbar.h
+++ b/app/display/gimpstatusbar.h
@@ -73,6 +73,8 @@ struct _GimpStatusbarClass
GType gimp_statusbar_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_statusbar_new (GimpDisplayShell *shell);
+void gimp_statusbar_set_shell (GimpStatusbar *statusbar,
+ GimpDisplayShell *shell);
gboolean gimp_statusbar_get_visible (GimpStatusbar *statusbar);
void gimp_statusbar_set_visible (GimpStatusbar *statusbar,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]