mirror of https://github.com/GNOME/gimp.git
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:
parent
571cdd47ed
commit
82aa4084ab
|
@ -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,19 +657,35 @@ gimp_statusbar_new (GimpDisplayShell *shell)
|
|||
|
||||
statusbar = g_object_new (GIMP_TYPE_STATUSBAR, NULL);
|
||||
|
||||
statusbar->shell = 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);
|
||||
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 (statusbar->shell, "scaled",
|
||||
G_CALLBACK (gimp_statusbar_shell_scaled),
|
||||
statusbar, 0);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_statusbar_get_visible (GimpStatusbar *statusbar)
|
||||
{
|
||||
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue