Commit 2ce2cec3b0bdb58794ec0604dd19c9a54e47452c

  • avatar
  • ssam
  • Sat Aug 15 02:58:38 CEST 2009
[gsettings] Add property_class->bindable and ->unbindable_reason

Now we gray out the 'Connect to setting...' item if not bindable, and set the
tooltip to 'unbindable_reason'.
  
739739{
740740
741741 GladeWidgetAdaptor *adaptor, *prop_adaptor;
742 GtkWidget *popup_menu;
742 GtkWidget *popup_menu, *item;
743743 gchar *book = NULL;
744744 gint button;
745745 gint event_time;
751751
752752 popup_menu = gtk_menu_new ();
753753
754 /* Don't allow binding properties that it would be crazy to bind to, like packing ones */
755 if (!property->klass->packing)
756 glade_popup_append_item (popup_menu, NULL, _("Connect to setting..."), NULL,
757 TRUE, glade_popup_connect_property_to_setting_cb,
758 property);
754 item = glade_popup_append_item (popup_menu, NULL, _("Connect to setting..."), NULL,
755 TRUE, glade_popup_connect_property_to_setting_cb,
756 property);
757 if (!property->klass->bindable)
758 {
759 gtk_widget_set_sensitive (item, FALSE);
760 if (property->klass->unbindable_reason != NULL)
761 gtk_widget_set_tooltip_text (item, property->klass->unbindable_reason);
762 }
763
759764
760765 glade_popup_append_item (popup_menu, GTK_STOCK_CLEAR, _("Set default value"), NULL,
761766 TRUE, glade_popup_clear_property_cb, property);
  
101101 property_class->libglade_only = FALSE;
102102 property_class->libglade_unsupported = FALSE;
103103 property_class->parentless_widget = FALSE;
104 property_class->bindable = TRUE;
105 property_class->unbindable_reason = NULL;
104106
105107 /* Initialize them to the base version */
106108 property_class->version_since_major = GWA_VERSION_SINCE_MAJOR (handle);
16451645 klass->optional_default =
16461646 glade_xml_get_property_boolean (node, GLADE_TAG_OPTIONAL_DEFAULT,
16471647 klass->optional_default);
1648
1649 /* work out if this property is bindable, from the above info */
1650 if (klass->construct_only)
1651 {
1652 klass->bindable = FALSE;
1653 klass->unbindable_reason = _("Cannot connect this property to a setting, because "
1654 "it can only be set during the object's construction");
1655 }
1656 else if (klass->packing)
1657 {
1658 klass->bindable = FALSE;
1659 klass->unbindable_reason = ("Cannot connect this property to a setting, because it "
1660 "is a packing property.");
1661 }
1662 else if (klass->libglade_only)
1663 {
1664 klass->bindable = FALSE;
1665 klass->unbindable_reason = ("Cannot connect this property to a setting, because it "
1666 "is only available in libglade and libglade does not "
1667 "setting connections.");
1668 }
1669 else
1670 {
1671 klass->bindable = TRUE;
1672 klass->unbindable_reason = NULL;
1673 }
16481674
16491675 /* notify that we changed the property class */
16501676 klass->is_modified = TRUE;
  
177177 * in the project
178178 */
179179
180 guint bindable : 1; /* True if the property can be bound to a GSettings key.
181 */
182 gchar *unbindable_reason; /* If not bindable, this contains the reason. Used as a
183 * tooltip for the 'Connect to setting' menu item when it
184 * is insensitive.
185 */
186
180187 gdouble weight; /* This will determine the position of this property in
181188 * the editor.
182189 */
  
10861086 setting = glade_xml_get_property_string
10871087 (prop, GLADE_TAG_SETTING);
10881088
1089 glade_property_set_binding (property, setting);
1089 if (property->klass->bindable)
1090 glade_property_set_binding (property, setting);
10901091
10911092 translatable = glade_xml_get_property_boolean
10921093 (prop, GLADE_TAG_TRANSLATABLE, FALSE);
11621162 * bindings).
11631163 */
11641164 if (!(property->klass->save_always || property->save_always) &&
1165 !(/*FIXME: property->klass->bindable && */property->key != NULL) &&
1165 !(property->klass->bindable && property->key != NULL) &&
11661166 glade_property_original_default (property))
11671167 return;
11681168