plug-ins: use g_object_bind_property() to set widgets sensitive

depending on toggle buttons instead of libgimpwidgets' "set_sensitive"
hack.
This commit is contained in:
Michael Natterer 2011-05-11 11:41:26 +02:00
parent 6d421f9d4d
commit 77b615e899
16 changed files with 105 additions and 80 deletions

View File

@ -379,6 +379,7 @@ displace_dialog (GimpDrawable *drawable)
1, 10, 0, 1, 2);
gtk_table_attach (GTK_TABLE (table), spinbutton, 1, 2, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (spinbutton);
g_signal_connect (adj, "value-changed",
G_CALLBACK (gimp_double_adjustment_update),
@ -387,24 +388,25 @@ displace_dialog (GimpDrawable *drawable)
G_CALLBACK (gimp_preview_invalidate),
preview);
gtk_widget_set_sensitive (spinbutton, dvals.do_x);
g_object_set_data (G_OBJECT (toggle_x), "set_sensitive", spinbutton);
gtk_widget_show (spinbutton);
g_object_bind_property (toggle_x, "active",
spinbutton, "sensitive",
G_BINDING_SYNC_CREATE);
combo = gimp_drawable_combo_box_new (displace_map_constrain, drawable);
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dvals.displace_map_x,
G_CALLBACK (gimp_int_combo_box_get_active),
&dvals.displace_map_x);
g_signal_connect_swapped (combo, "changed",
G_CALLBACK (gimp_preview_invalidate),
preview);
gtk_table_attach (GTK_TABLE (table), combo, 2, 3, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show (combo);
gtk_widget_set_sensitive (combo, dvals.do_x);
g_object_set_data (G_OBJECT (spinbutton), "set_sensitive", combo);
g_signal_connect_swapped (combo, "changed",
G_CALLBACK (gimp_preview_invalidate),
preview);
g_object_bind_property (toggle_x, "active",
combo, "sensitive",
G_BINDING_SYNC_CREATE);
/* Y Options */
toggle_y = gtk_check_button_new_with_mnemonic (_("_Y displacement:"));
@ -426,6 +428,7 @@ displace_dialog (GimpDrawable *drawable)
1, 10, 0, 1, 2);
gtk_table_attach (GTK_TABLE (table), spinbutton, 1, 2, 1, 2,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (spinbutton);
g_signal_connect (adj, "value-changed",
G_CALLBACK (gimp_double_adjustment_update),
@ -434,9 +437,9 @@ displace_dialog (GimpDrawable *drawable)
G_CALLBACK (gimp_preview_invalidate),
preview);
gtk_widget_set_sensitive (spinbutton, dvals.do_y);
g_object_set_data (G_OBJECT (toggle_y), "set_sensitive", spinbutton);
gtk_widget_show (spinbutton);
g_object_bind_property (toggle_y, "active",
spinbutton, "sensitive",
G_BINDING_SYNC_CREATE);
combo = gimp_drawable_combo_box_new (displace_map_constrain, drawable);
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dvals.displace_map_y,
@ -450,8 +453,9 @@ displace_dialog (GimpDrawable *drawable)
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show (combo);
gtk_widget_set_sensitive (combo, dvals.do_y);
g_object_set_data (G_OBJECT (spinbutton), "set_sensitive", combo);
g_object_bind_property (toggle_y, "active",
combo, "sensitive",
G_BINDING_SYNC_CREATE);
hbox = gtk_hbox_new (FALSE, 24);
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);

View File

@ -1210,11 +1210,10 @@ save_dialog (gint32 image_ID)
"you are trying to export only has one "
"layer."),
NULL);
gtk_widget_set_sensitive (frame, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (toggle)));
g_object_set_data (G_OBJECT (toggle), "set_sensitive", frame);
g_signal_connect (toggle, "toggled",
G_CALLBACK (gimp_toggle_button_sensitive_update),
NULL);
g_object_bind_property (toggle, "active",
frame, "sensitive",
G_BINDING_SYNC_CREATE);
gtk_widget_show (dialog);

View File

@ -533,8 +533,9 @@ save_dialog (gint32 image_ID)
G_CALLBACK (gtm_caption_callback),
NULL);
g_object_set_data (G_OBJECT (toggle), "set_sensitive", entry);
gtk_widget_set_sensitive (entry, gtmvals.caption);
g_object_bind_property (toggle, "active",
entry, "sensitive",
G_BINDING_SYNC_CREATE);
entry = gtk_entry_new ();
gtk_widget_set_size_request (entry, 200, -1);

View File

@ -3488,8 +3488,9 @@ save_dialog (void)
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
g_object_set_data (G_OBJECT (toggle), "set_sensitive", table);
gtk_widget_set_sensitive (table, psvals.preview);
g_object_bind_property (toggle, "active",
table, "sensitive",
G_BINDING_SYNC_CREATE);
spinbutton = gimp_spin_button_new (&adj, psvals.preview_size,
0, 1024, 1, 10, 0, 1, 0);

View File

@ -953,6 +953,7 @@ load_dialog (const gchar *filename,
/* Path Import */
toggle = gtk_check_button_new_with_mnemonic (_("Import _paths"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), load_vals.import);
gtk_table_attach (GTK_TABLE (table), toggle, 0, 2, 5, 6,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (toggle);
@ -962,28 +963,23 @@ load_dialog (const gchar *filename,
"can be used with the GIMP path tool"),
NULL);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), load_vals.import);
g_signal_connect (toggle, "toggled",
G_CALLBACK (gimp_toggle_button_update),
&load_vals.import);
g_signal_connect (toggle, "toggled",
G_CALLBACK (gimp_toggle_button_sensitive_update),
NULL);
toggle2 = gtk_check_button_new_with_mnemonic (_("Merge imported paths"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle2), load_vals.merge);
gtk_table_attach (GTK_TABLE (table), toggle2, 0, 2, 6, 7,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_set_sensitive (toggle2, load_vals.import);
gtk_widget_show (toggle2);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle2), load_vals.merge);
g_signal_connect (toggle2, "toggled",
G_CALLBACK (gimp_toggle_button_update),
&load_vals.merge);
g_object_set_data (G_OBJECT (toggle), "set_sensitive", toggle2);
g_object_bind_property (toggle, "active",
toggle2, "sensitive",
G_BINDING_SYNC_CREATE);
gtk_widget_show (dialog);

View File

@ -1255,8 +1255,9 @@ save_dialog (gint32 drawable_ID)
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
g_object_set_data (G_OBJECT (toggle), "set_sensitive", table);
gtk_widget_set_sensitive (table, xsvals.use_hot);
g_object_bind_property (toggle, "active",
table, "sensitive",
G_BINDING_SYNC_CREATE);
spinbutton = gimp_spin_button_new (&adj, xsvals.x_hot, 0,
gimp_drawable_width (drawable_ID) - 1,
@ -1308,8 +1309,9 @@ save_dialog (gint32 drawable_ID)
G_CALLBACK (mask_ext_entry_callback),
NULL);
g_object_set_data (G_OBJECT (toggle), "set_sensitive", entry);
gtk_widget_set_sensitive (entry, xsvals.write_mask);
g_object_bind_property (toggle, "active",
entry, "sensitive",
G_BINDING_SYNC_CREATE);
gtk_widget_set_sensitive (frame, gimp_drawable_has_alpha (drawable_ID));

View File

@ -1010,11 +1010,14 @@ create_selection_tab (GtkWidget *notebook,
G_CALLBACK (gimp_int_adjustment_update),
&filmvals.film_height);
g_object_set_data (G_OBJECT (toggle), "inverse_sensitive", spinbutton);
g_object_set_data
(G_OBJECT (spinbutton), "inverse_sensitive",
/* FIXME: eeeeeek */
g_list_nth_data (gtk_container_get_children (GTK_CONTAINER (table)), 1));
g_object_bind_property (toggle, "active",
spinbutton, "sensitive",
G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
g_object_bind_property (toggle, "active",
/* FIXME: eeeeeek */
g_list_nth_data (gtk_container_get_children (GTK_CONTAINER (table)), 1), "sensitive",
G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
filmvals.keep_height);

View File

@ -1044,8 +1044,9 @@ iwarp_animate_dialog (GtkWidget *dialog,
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
g_object_set_data (G_OBJECT (button), "set_sensitive", table);
gtk_widget_set_sensitive (table, do_animate);
g_object_bind_property (button, "active",
table, "sensitive",
G_BINDING_SYNC_CREATE);
scale_data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("Number of _frames:"), SCALE_WIDTH, 0,
@ -1196,8 +1197,9 @@ iwarp_settings_dialog (GtkWidget *dialog,
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
g_object_set_data (G_OBJECT (button), "set_sensitive", table);
gtk_widget_set_sensitive (table, iwarp_vals.do_supersample);
g_object_bind_property (button, "active",
table, "sensitive",
G_BINDING_SYNC_CREATE);
scale_data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("Ma_x depth:"), SCALE_WIDTH, 5,

View File

@ -858,8 +858,9 @@ oilify_dialog (GimpDrawable *drawable)
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show (combo);
gtk_widget_set_sensitive (combo, ovals.use_mask_size_map);
g_object_set_data (G_OBJECT (toggle), "set_sensitive", combo);
g_object_bind_property (toggle, "active",
combo, "sensitive",
G_BINDING_SYNC_CREATE);
/*
* Exponent scale
@ -910,8 +911,9 @@ oilify_dialog (GimpDrawable *drawable)
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show (combo);
gtk_widget_set_sensitive (combo, ovals.use_exponent_map);
g_object_set_data (G_OBJECT (toggle), "set_sensitive", combo);
g_object_bind_property (toggle, "active",
combo, "sensitive",
G_BINDING_SYNC_CREATE);
/*
* Intensity algorithm check button

View File

@ -592,8 +592,9 @@ ripple_dialog (GimpDrawable *drawable)
GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
gtk_widget_show (frame);
g_object_set_data (G_OBJECT (toggle), "inverse_sensitive", frame);
gimp_toggle_button_sensitive_update (GTK_TOGGLE_BUTTON (toggle));
g_object_bind_property (toggle, "active",
frame, "sensitive",
G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
g_signal_connect_swapped (wrap, "toggled",
G_CALLBACK (gimp_preview_invalidate),

View File

@ -1168,12 +1168,14 @@ shoot_dialog (GdkScreen **screen)
gtk_box_pack_start (GTK_BOX (hbox), toggle, TRUE, TRUE, 24);
gtk_widget_show (toggle);
g_object_set_data (G_OBJECT (button), "set_sensitive", toggle);
g_signal_connect (toggle, "toggled",
G_CALLBACK (gimp_toggle_button_update),
&shootvals.decorate);
g_object_bind_property (button, "active",
toggle, "sensitive",
G_BINDING_SYNC_CREATE);
#endif /* HAVE_X11_XMU_WINUTIL_H */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
@ -1206,13 +1208,14 @@ shoot_dialog (GdkScreen **screen)
gtk_box_pack_start (GTK_BOX (hbox), toggle, TRUE, TRUE, 24);
gtk_widget_show (toggle);
gtk_widget_set_sensitive (toggle, FALSE);
g_object_set_data (G_OBJECT (button), "set_sensitive", toggle);
g_signal_connect (toggle, "toggled",
G_CALLBACK (gimp_toggle_button_update),
&shootvals.show_cursor);
g_object_bind_property (button, "active",
toggle, "sensitive",
G_BINDING_SYNC_CREATE);
#endif
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),

View File

@ -408,14 +408,14 @@ open_dialog (void)
color_button, TRUE, TRUE, 0);
gtk_widget_show (color_button);
gtk_widget_set_sensitive (color_button,
p.params.background_type == BACKGROUND_TYPE_COLOR);
g_object_set_data (G_OBJECT (button), "set_sensitive", color_button);
g_signal_connect (color_button, "color-changed",
G_CALLBACK (gimp_color_button_get_color),
&p.params.background_color);
g_object_bind_property (button, "active",
color_button, "sensitive",
G_BINDING_SYNC_CREATE);
gtk_widget_show (dialog);
p.run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);

View File

@ -506,8 +506,9 @@ tileit_dialog (void)
GTK_FILL | GTK_SHRINK , GTK_FILL, 0, 0);
gtk_widget_show (label);
gtk_widget_set_sensitive (label, FALSE);
g_object_set_data (G_OBJECT (toggle), "set_sensitive", label);
g_object_bind_property (toggle, "active",
label, "sensitive",
G_BINDING_SYNC_CREATE);
spinbutton = gimp_spin_button_new (&adj, 2, 1, 6, 1, 1, 0, 1, 0);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinbutton);
@ -521,8 +522,9 @@ tileit_dialog (void)
exp_call.r_adj = adj;
gtk_widget_set_sensitive (spinbutton, FALSE);
g_object_set_data (G_OBJECT (label), "set_sensitive", spinbutton);
g_object_bind_property (toggle, "active",
spinbutton, "sensitive",
G_BINDING_SYNC_CREATE);
label = gtk_label_new_with_mnemonic (_("Col_umn:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
@ -530,8 +532,9 @@ tileit_dialog (void)
gtk_table_attach (GTK_TABLE (table), label, 1, 2, 3, 4,
GTK_FILL , GTK_FILL, 0, 0);
gtk_widget_set_sensitive (label, FALSE);
g_object_set_data (G_OBJECT (spinbutton), "set_sensitive", label);
g_object_bind_property (toggle, "active",
label, "sensitive",
G_BINDING_SYNC_CREATE);
spinbutton = gimp_spin_button_new (&adj, 2, 1, 6, 1, 1, 0, 1, 0);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinbutton);
@ -545,8 +548,9 @@ tileit_dialog (void)
exp_call.c_adj = adj;
gtk_widget_set_sensitive (spinbutton, FALSE);
g_object_set_data (G_OBJECT (label), "set_sensitive", spinbutton);
g_object_bind_property (toggle, "active",
spinbutton, "sensitive",
G_BINDING_SYNC_CREATE);
g_object_set_data (G_OBJECT (toggle), "gimp-item-data",
GINT_TO_POINTER (EXPLICIT));
@ -565,8 +569,9 @@ tileit_dialog (void)
exp_call.applybut = button;
gtk_widget_set_sensitive (button, FALSE);
g_object_set_data (G_OBJECT (spinbutton), "set_sensitive", button);
g_object_bind_property (toggle, "active",
spinbutton, "sensitive",
G_BINDING_SYNC_CREATE);
/* Widget for selecting the Opacity */

View File

@ -2836,12 +2836,14 @@ dlg_make_page_settings (GFlareDialog *dlg,
gtk_container_add (GTK_CONTAINER (frame), asup_table);
gtk_widget_show (asup_table);
gtk_widget_set_sensitive (asup_table, pvals.use_asupsample);
g_object_set_data (G_OBJECT (button), "set_sensitive", asup_table);
g_signal_connect (button, "toggled",
G_CALLBACK (gimp_toggle_button_update),
&pvals.use_asupsample);
g_object_bind_property (button, "active",
asup_table, "sensitive",
G_BINDING_SYNC_CREATE);
adj = gimp_scale_entry_new (GTK_TABLE (asup_table), 0, 0,
_("_Max depth:"), -1, 4,
pvals.asupsample_max_depth,
@ -3921,8 +3923,9 @@ ed_make_page_sflare (GFlareEditor *ed,
gtk_box_pack_start (GTK_BOX (polygon_hbox), entry, FALSE, FALSE, 0);
gtk_widget_show (entry);
gtk_widget_set_sensitive (entry, gflare->sflare_shape == GF_POLYGON);
g_object_set_data (G_OBJECT (toggle), "set_sensitive", entry);
g_object_bind_property (toggle, "active",
entry, "sensitive",
G_BINDING_SYNC_CREATE);
/*
* Random Seed Entry

View File

@ -825,8 +825,9 @@ create_bump_page (void)
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
gtk_widget_set_sensitive (table, mapvals.bump_mapped);
g_object_set_data (G_OBJECT (toggle), "set_sensitive", table);
g_object_bind_property (toggle, "active",
table, "sensitive",
G_BINDING_SYNC_CREATE);
combo = gimp_drawable_combo_box_new (bumpmap_constrain, NULL);
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), mapvals.bumpmap_id,
@ -916,8 +917,9 @@ create_environment_page (void)
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
gtk_widget_set_sensitive (table, mapvals.env_mapped);
g_object_set_data (G_OBJECT (toggle), "set_sensitive", table);
g_object_bind_property (toggle, "active",
table, "sensitive",
G_BINDING_SYNC_CREATE);
combo = gimp_drawable_combo_box_new (envmap_constrain, NULL);
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), mapvals.envmap_id,

View File

@ -519,8 +519,9 @@ create_options_page (void)
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
gtk_widget_set_sensitive (table, mapvals.antialiasing);
g_object_set_data (G_OBJECT (toggle), "set_sensitive", table);
g_object_bind_property (toggle, "active",
table, "sensitive",
G_BINDING_SYNC_CREATE);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("_Depth:"), 0, 0,