Commit 57f41a7e authored by Tristan Van Berkom's avatar Tristan Van Berkom

- made some members properties - added glade_property_set (property, ...)


* src/glade-property.[ch]:
  - made some members properties
  - added glade_property_set (property, ...) convenience function
  - Added set_tooltip & tooltip changed signal
  - Added insensitive property.

* src/glade-property-class.h: Clarified comment

* src/glade-property-class.c: Properties that are native to GtkWidget go in
  the "common" tab by default (unless overridden by the xml file).

* src/glade-editor.[ch]: Now we watch property sensitivity and tooltip status

* src/glade-gtk.c: The beginnings of stock buttons.
parent e07fc567
2005-07-29 Tristan Van Berkom <tvb@gnome.org>
* src/glade-property.[ch]:
- made some members properties
- added glade_property_set (property, ...) convenience function
- Added set_tooltip & tooltip changed signal
- Added insensitive property.
* src/glade-property-class.h: Clarified comment
* src/glade-property-class.c: Properties that are native to GtkWidget go in
the "common" tab by default (unless overridden by the xml file).
* src/glade-editor.[ch]: Now we watch property sensitivity and tooltip status
* src/glade-gtk.c: The beginnings of stock buttons.
2005-07-28 Tristan Van Berkom <tvb@gnome.org> 2005-07-28 Tristan Van Berkom <tvb@gnome.org>
* src/glade-app.c: Fixed a few compile warnings and fixed signal emmission to * src/glade-app.c: Fixed a few compile warnings and fixed signal emmission to
......
...@@ -47,6 +47,9 @@ ...@@ -47,6 +47,9 @@
static GtkNotebookClass *parent_class = NULL; static GtkNotebookClass *parent_class = NULL;
static GdkColor *insensitive_colour = NULL;
static GdkColor *normal_colour = NULL;
static void glade_editor_property_load (GladeEditorProperty *property, GladeWidget *widget); static void glade_editor_property_load (GladeEditorProperty *property, GladeWidget *widget);
static void glade_editor_property_load_flags (GladeEditorProperty *property); static void glade_editor_property_load_flags (GladeEditorProperty *property);
...@@ -322,7 +325,7 @@ glade_editor_property_changed_enabled (GtkWidget *button, ...@@ -322,7 +325,7 @@ glade_editor_property_changed_enabled (GtkWidget *button,
state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
gtk_widget_set_sensitive (spin, state); gtk_widget_set_sensitive (spin, state);
property = g_object_get_data (G_OBJECT (button), "user_data"); property = g_object_get_data (G_OBJECT (button), "user_data");
property->property->enabled = state; glade_property_set_enabled (property->property, state);
} }
static void static void
...@@ -1059,22 +1062,34 @@ glade_editor_create_input_unichar (GladeEditorProperty *property) ...@@ -1059,22 +1062,34 @@ glade_editor_create_input_unichar (GladeEditorProperty *property)
* Returns: * Returns:
*/ */
GtkWidget * GtkWidget *
glade_editor_create_item_label (GladePropertyClass *class) glade_editor_create_item_label (GladeEditorProperty *property)
{ {
GtkWidget *eventbox; GtkWidget *eventbox;
GtkWidget *label; GtkWidget *label;
gchar *text; gchar *text;
text = g_strdup_printf ("%s :", class->name); g_return_val_if_fail (GLADE_IS_EDITOR_PROPERTY (property), NULL);
g_return_val_if_fail (property->class != NULL, NULL);
text = g_strdup_printf ("%s :", property->class->name);
label = gtk_label_new (text); label = gtk_label_new (text);
g_free (text); g_free (text);
if (insensitive_colour == NULL)
insensitive_colour =
&(GTK_WIDGET
(label)->style->text[GTK_STATE_INSENSITIVE]);
if (normal_colour == NULL)
normal_colour =
&(GTK_WIDGET
(label)->style->text[GTK_STATE_NORMAL]);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.0); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.0);
/* we need to wrap the label in an event box to add tooltips */ /* we need to wrap the label in an event box to add tooltips */
eventbox = gtk_event_box_new (); eventbox = gtk_event_box_new ();
gtk_container_add (GTK_CONTAINER (eventbox), label); gtk_container_add (GTK_CONTAINER (eventbox), label);
glade_util_widget_set_tooltip (eventbox, class->tooltip);
return eventbox; return eventbox;
} }
...@@ -1082,8 +1097,6 @@ glade_editor_create_item_label (GladePropertyClass *class) ...@@ -1082,8 +1097,6 @@ glade_editor_create_item_label (GladePropertyClass *class)
static void static void
glade_editor_table_attach (GtkWidget *table, GtkWidget *child, gint pos, gint row) glade_editor_table_attach (GtkWidget *table, GtkWidget *child, gint pos, gint row)
{ {
/* gtk_table_attach_defaults (GTK_TABLE (table), child, */
/* pos, pos+1, row, row +1); */
gtk_table_attach (GTK_TABLE (table), child, gtk_table_attach (GTK_TABLE (table), child,
pos, pos+1, row, row +1, pos, pos+1, row, row +1,
pos ? GTK_EXPAND | GTK_FILL : GTK_FILL, pos ? GTK_EXPAND | GTK_FILL : GTK_FILL,
...@@ -1097,7 +1110,6 @@ glade_editor_append_item_real (GladeEditorTable *table, ...@@ -1097,7 +1110,6 @@ glade_editor_append_item_real (GladeEditorTable *table,
GladeEditorProperty *property) GladeEditorProperty *property)
{ {
GladePropertyClass *class; GladePropertyClass *class;
GtkWidget *label;
GtkWidget *input = NULL; GtkWidget *input = NULL;
g_return_val_if_fail (GLADE_IS_EDITOR_TABLE (table), NULL); g_return_val_if_fail (GLADE_IS_EDITOR_TABLE (table), NULL);
...@@ -1134,9 +1146,9 @@ glade_editor_append_item_real (GladeEditorTable *table, ...@@ -1134,9 +1146,9 @@ glade_editor_append_item_real (GladeEditorTable *table,
return gtk_label_new ("Implement me !"); return gtk_label_new ("Implement me !");
} }
label = glade_editor_create_item_label (class); property->item_label = glade_editor_create_item_label (property);
glade_editor_table_attach (table->table_widget, label, 0, table->rows); glade_editor_table_attach (table->table_widget, property->item_label, 0, table->rows);
glade_editor_table_attach (table->table_widget, input, 1, table->rows); glade_editor_table_attach (table->table_widget, input, 1, table->rows);
table->rows++; table->rows++;
...@@ -1191,21 +1203,17 @@ glade_editor_table_append_name_field (GladeEditorTable *table) ...@@ -1191,21 +1203,17 @@ glade_editor_table_append_name_field (GladeEditorTable *table)
static void static void
glade_editor_table_append_class_field (GladeEditorTable *table) glade_editor_table_append_class_field (GladeEditorTable *table)
{ {
GtkWidget *gtk_table;
GtkWidget *label; GtkWidget *label;
GtkWidget *entry; GtkWidget *class_label;
gtk_table = table->table_widget;
/* Class */ /* Class */
label = gtk_label_new (_("Class :")); label = gtk_label_new (_("Class :"));
class_label = gtk_label_new (table->glade_widget_class->name);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.0); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.0);
entry = gtk_entry_new (); gtk_misc_set_alignment (GTK_MISC (class_label), 0.0, 0.0);
gtk_entry_set_text (GTK_ENTRY (entry), table->glade_widget_class->name);
gtk_editable_set_editable (GTK_EDITABLE (entry), FALSE);
glade_editor_table_attach (gtk_table, label, 0, table->rows); glade_editor_table_attach (table->table_widget, label, 0, table->rows);
glade_editor_table_attach (gtk_table, entry, 1, table->rows); glade_editor_table_attach (table->table_widget, class_label, 1, table->rows);
table->rows++; table->rows++;
} }
...@@ -1450,15 +1458,37 @@ glade_editor_load_widget_class (GladeEditor *editor, GladeWidgetClass *class) ...@@ -1450,15 +1458,37 @@ glade_editor_load_widget_class (GladeEditor *editor, GladeWidgetClass *class)
} }
/* ============================ Load properties ============================ */ /* ============================ Load properties ============================ */
static void
glade_editor_tooltip_cb (GladeProperty *property,
const gchar *tooltip,
GladeEditorProperty *editor_prop)
{
glade_util_widget_set_tooltip (editor_prop->input, tooltip);
glade_util_widget_set_tooltip (editor_prop->item_label, tooltip);
}
static void static void
glade_editor_property_set_tooltips (GladeEditorProperty *property) glade_editor_property_set_tooltips (GladeEditorProperty *property)
{ {
gchar *tooltip;
g_return_if_fail (property != NULL); g_return_if_fail (property != NULL);
g_return_if_fail (GLADE_IS_PROPERTY (property->property)); g_return_if_fail (GLADE_IS_PROPERTY (property->property));
g_return_if_fail (property->input != NULL); g_return_if_fail (property->input != NULL);
glade_util_widget_set_tooltip (property->input, property->property->class->tooltip); if (property->tooltip_id > 0)
g_signal_handler_disconnect (G_OBJECT (property->tooltip_prop),
property->tooltip_id);
property->tooltip_prop = property->property;
property->tooltip_id =
g_signal_connect (G_OBJECT (property->property),
"tooltip-changed",
G_CALLBACK (glade_editor_tooltip_cb),
property);
tooltip = (gchar *)glade_property_get_tooltip (property->property);
glade_util_widget_set_tooltip (property->input, tooltip);
glade_util_widget_set_tooltip (property->item_label, tooltip);
return; return;
} }
...@@ -1498,9 +1528,10 @@ glade_editor_property_load_integer (GladeEditorProperty *property) ...@@ -1498,9 +1528,10 @@ glade_editor_property_load_integer (GladeEditorProperty *property)
g_return_if_fail (GTK_IS_SPIN_BUTTON (spin)); g_return_if_fail (GTK_IS_SPIN_BUTTON (spin));
g_return_if_fail (GTK_IS_CHECK_BUTTON (button)); g_return_if_fail (GTK_IS_CHECK_BUTTON (button));
gtk_widget_set_sensitive (GTK_WIDGET (spin), property->property->enabled); gtk_widget_set_sensitive (GTK_WIDGET (spin),
glade_property_get_enabled (property->property));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
property->property->enabled); glade_property_get_enabled (property->property));
g_object_set_data (G_OBJECT (button), "user_data", property); g_object_set_data (G_OBJECT (button), "user_data", property);
} else { } else {
spin = property->input; spin = property->input;
...@@ -1527,7 +1558,6 @@ glade_editor_property_load_integer (GladeEditorProperty *property) ...@@ -1527,7 +1558,6 @@ glade_editor_property_load_integer (GladeEditorProperty *property)
g_type_name(class->pspec->value_type)); g_type_name(class->pspec->value_type));
gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), val); gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), val);
g_object_set_data (G_OBJECT (spin), "user_data", property); g_object_set_data (G_OBJECT (spin), "user_data", property);
} }
...@@ -1689,10 +1719,24 @@ glade_editor_property_load_unichar (GladeEditorProperty *property) ...@@ -1689,10 +1719,24 @@ glade_editor_property_load_unichar (GladeEditorProperty *property)
g_object_set_data (G_OBJECT (property->input), "user_data", property); g_object_set_data (G_OBJECT (property->input), "user_data", property);
} }
static void
glade_editor_sensitivity_cb (GladeProperty *property,
GParamSpec *pspec,
GladeEditorProperty *editor_prop)
{
gboolean sensitive = glade_property_get_sensitive (editor_prop->property);
gtk_widget_modify_fg
(GTK_WIDGET (editor_prop->item_label),
GTK_STATE_NORMAL,
sensitive ? normal_colour : insensitive_colour);
gtk_widget_set_sensitive (editor_prop->input, sensitive);
}
static void static void
glade_editor_property_load (GladeEditorProperty *property, GladeWidget *widget) glade_editor_property_load (GladeEditorProperty *property, GladeWidget *widget)
{ {
GladePropertyClass *class; GladePropertyClass *class;
gboolean sensitive;
g_return_if_fail (GLADE_IS_EDITOR_PROPERTY (property)); g_return_if_fail (GLADE_IS_EDITOR_PROPERTY (property));
g_return_if_fail (GLADE_IS_PROPERTY_CLASS (property->class)); g_return_if_fail (GLADE_IS_PROPERTY_CLASS (property->class));
...@@ -1700,7 +1744,8 @@ glade_editor_property_load (GladeEditorProperty *property, GladeWidget *widget) ...@@ -1700,7 +1744,8 @@ glade_editor_property_load (GladeEditorProperty *property, GladeWidget *widget)
class = property->class; class = property->class;
/* Load the property */ /* Load the property */
if ((property->property = glade_widget_get_property (widget, class->id)) == NULL) if ((property->property =
glade_widget_get_property (widget, class->id)) == NULL)
{ {
g_critical ("Couldnt find property of class %s on widget of class %s\n", g_critical ("Couldnt find property of class %s on widget of class %s\n",
class->id, widget->widget_class->name); class->id, widget->widget_class->name);
...@@ -1732,6 +1777,26 @@ glade_editor_property_load (GladeEditorProperty *property, GladeWidget *widget) ...@@ -1732,6 +1777,26 @@ glade_editor_property_load (GladeEditorProperty *property, GladeWidget *widget)
g_warning ("%s : type %s not implemented (%s)\n", G_GNUC_FUNCTION, g_warning ("%s : type %s not implemented (%s)\n", G_GNUC_FUNCTION,
class->name, g_type_name (class->pspec->value_type)); class->name, g_type_name (class->pspec->value_type));
/* Set insensitive and hook cb here XXX */
if (property->sensitive_id > 0)
g_signal_handler_disconnect (property->sensitive_prop,
property->sensitive_id);
property->sensitive_prop = property->property;
property->sensitive_id =
g_signal_connect (G_OBJECT (property->property),
"notify::sensitive",
G_CALLBACK (glade_editor_sensitivity_cb),
property);
sensitive = glade_property_get_sensitive (property->property);
gtk_widget_modify_fg
(GTK_WIDGET (property->item_label),
GTK_STATE_NORMAL,
sensitive ? normal_colour : insensitive_colour);
gtk_widget_set_sensitive (property->input, sensitive);
glade_editor_property_set_tooltips (property); glade_editor_property_set_tooltips (property);
property->property->loading = FALSE; property->property->loading = FALSE;
......
...@@ -177,6 +177,14 @@ struct _GladeEditorProperty ...@@ -177,6 +177,14 @@ struct _GladeEditorProperty
gboolean from_query_dialog; /* If this input is part of a query dialog gboolean from_query_dialog; /* If this input is part of a query dialog
* this is TRUE. * this is TRUE.
*/ */
gulong tooltip_id; /* signal connection id for tooltip changes */
GladeProperty *tooltip_prop; /* the last object this was connected to */
gulong sensitive_id; /* signal connection id for sensitivity changes */
GladeProperty *sensitive_prop; /* the last object this was connected to */
GtkWidget *item_label; /* Keep a hold of this for tooltips */
}; };
LIBGLADEUI_API GType glade_editor_get_type (void); LIBGLADEUI_API GType glade_editor_get_type (void);
......
...@@ -49,6 +49,7 @@ glade_gtk_stock_get_type (void) ...@@ -49,6 +49,7 @@ glade_gtk_stock_get_type (void)
{ {
static GType etype = 0; static GType etype = 0;
if (etype == 0) { if (etype == 0) {
static const GEnumValue values[] = { static const GEnumValue values[] = {
{ 0, "None", "glade-none" }, { 0, "None", "glade-none" },
{ 1, "Ok", "gtk-ok" }, { 1, "Ok", "gtk-ok" },
...@@ -842,74 +843,39 @@ void GLADEGTK_API ...@@ -842,74 +843,39 @@ void GLADEGTK_API
glade_gtk_button_set_stock (GObject *object, GValue *value) glade_gtk_button_set_stock (GObject *object, GValue *value)
{ {
GladeWidget *glade_widget; GladeWidget *glade_widget;
GtkWidget *button;
GtkStockItem item;
GladeProperty *property; GladeProperty *property;
GladeProperty *text;
GEnumClass *eclass; GEnumClass *eclass;
guint i; guint i;
gint val; gint val;
glade_widget = glade_widget_get_from_gobject (object);
g_return_if_fail (GTK_IS_BUTTON (object));
g_return_if_fail (glade_widget != NULL);
val = g_value_get_enum (value); val = g_value_get_enum (value);
if (val == GPOINTER_TO_INT (g_object_get_data (object, "stock"))) if (val == GPOINTER_TO_INT (g_object_get_data (object, "stock")))
return; return;
button = GTK_WIDGET (object);
g_return_if_fail (GTK_IS_BUTTON (button));
glade_widget = glade_widget_get_from_gobject (button);
g_return_if_fail (glade_widget != NULL); g_return_if_fail (glade_widget != NULL);
property = glade_widget_get_property (glade_widget, "stock"); property = glade_widget_get_property (glade_widget, "stock");
text = glade_widget_get_property (glade_widget, "label");
eclass = g_type_class_ref (property->class->pspec->value_type); eclass = g_type_class_ref (property->class->pspec->value_type);
g_return_if_fail (property != NULL);
g_return_if_fail (text != NULL);
for (i = 0; i < eclass->n_values; i++) for (i = 0; i < eclass->n_values; i++)
{
if (val == eclass->values[i].value) if (val == eclass->values[i].value)
break; break;
if (i >= eclass->n_values) {
g_type_class_unref (eclass);
return;
} }
g_return_if_fail (i < eclass->n_values); property = glade_widget_get_property (glade_widget, "use-stock");
glade_property_set (property, TRUE);
gtk_container_remove (GTK_CONTAINER (button),
GTK_BIN (button)->child);
if (!gtk_stock_lookup (eclass->values[i].value_nick, &item))
{
GtkWidget *label;
if (g_value_get_boolean (
glade_widget_get_property (
glade_widget, "use-underline")->value))
label = gtk_label_new_with_mnemonic (g_value_get_string (text->value));
else
label = gtk_label_new (g_value_get_string (text->value));
gtk_container_add (GTK_CONTAINER (button), label);
gtk_widget_show_all (button);
}
else
{
GtkWidget *label;
GtkWidget *image;
GtkWidget *hbox;
hbox = gtk_hbox_new (FALSE, 1);
label = gtk_label_new_with_mnemonic (item.label);
image = gtk_image_new_from_stock (eclass->values[i].value_nick,
GTK_ICON_SIZE_BUTTON);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), property = glade_widget_get_property (glade_widget, "label");
button); glade_property_set (property, eclass->values[i].value_nick);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); glade_property_set_sensitive (property, FALSE, "Jolly rancher");
gtk_box_pack_end (GTK_BOX (hbox), label, TRUE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (button), hbox);
gtk_widget_show_all (button);
}
g_type_class_unref (eclass); g_type_class_unref (eclass);
g_object_set_data (object, "stock", GINT_TO_POINTER (val)); g_object_set_data (object, "stock", GINT_TO_POINTER (val));
......
...@@ -539,9 +539,11 @@ glade_property_class_make_gvalue_from_string (GladePropertyClass *property_class ...@@ -539,9 +539,11 @@ glade_property_class_make_gvalue_from_string (GladePropertyClass *property_class
GladePropertyClass * GladePropertyClass *
glade_property_class_new_from_spec (GParamSpec *spec) glade_property_class_new_from_spec (GParamSpec *spec)
{ {
GObjectClass *gtk_widget_class;
GladePropertyClass *property_class; GladePropertyClass *property_class;
g_return_val_if_fail (spec != NULL, NULL); g_return_val_if_fail (spec != NULL, NULL);
gtk_widget_class = g_type_class_ref (GTK_TYPE_WIDGET);
property_class = glade_property_class_new (); property_class = glade_property_class_new ();
...@@ -554,6 +556,15 @@ glade_property_class_new_from_spec (GParamSpec *spec) ...@@ -554,6 +556,15 @@ glade_property_class_new_from_spec (GParamSpec *spec)
property_class->id = g_strdup (spec->name); property_class->id = g_strdup (spec->name);
property_class->name = g_strdup (g_param_spec_get_nick (spec)); property_class->name = g_strdup (g_param_spec_get_nick (spec));
/* If its on the GtkWidgetClass, it goes in "common"
* (unless stipulated otherwise in the xml file)
*/
if (g_object_class_find_property (gtk_widget_class,
g_param_spec_get_name (spec)) != NULL)
property_class->common = TRUE;
if (!property_class->id || !property_class->name) if (!property_class->id || !property_class->name)
{ {
g_warning ("Failed to create property class from spec"); g_warning ("Failed to create property class from spec");
...@@ -567,6 +578,7 @@ glade_property_class_new_from_spec (GParamSpec *spec) ...@@ -567,6 +578,7 @@ glade_property_class_new_from_spec (GParamSpec *spec)
lblError: lblError:
glade_property_class_free (property_class); glade_property_class_free (property_class);
g_type_class_unref (gtk_widget_class);
return NULL; return NULL;
} }
......
...@@ -98,10 +98,8 @@ struct _GladePropertyClass ...@@ -98,10 +98,8 @@ struct _GladePropertyClass
gchar *name; /* The name of the property. Like "Label" or "X Pad" gchar *name; /* The name of the property. Like "Label" or "X Pad"
* this is a translatable string * this is a translatable string
*/ */
gchar *tooltip; /* The tooltip. Currently unimplemented. Not sure if gchar *tooltip; /* The default tooltip for the property editor rows.
* it should go here
*/ */
GValue *def; /* The default value for this property */ GValue *def; /* The default value for this property */
GValue *orig_def; /* If def is overridden by a xml file, GValue *orig_def; /* If def is overridden by a xml file,
......
...@@ -20,10 +20,16 @@ ...@@ -20,10 +20,16 @@
* Chema Celorio <chema@celorio.com> * Chema Celorio <chema@celorio.com>
*/ */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> /* for atoi and atof */ #include <stdlib.h> /* for atoi and atof */
#include <string.h> #include <string.h>
#include <glib/gi18n-lib.h>
#include "glade.h" #include "glade.h"
#include "glade-widget.h" #include "glade-widget.h"
#include "glade-property.h" #include "glade-property.h"
...@@ -39,9 +45,20 @@ ...@@ -39,9 +45,20 @@
enum enum
{ {
VALUE_CHANGED, VALUE_CHANGED,
TOOLTIP_CHANGED,
LAST_SIGNAL LAST_SIGNAL
}; };
enum
{
PROP_0,
PROP_ENABLED,
PROP_SENSITIVE,
PROP_I18N_TRANSLATABLE,
PROP_I18N_HAS_CONTEXT,
PROP_I18N_COMMENT
};
static guint glade_property_signals[LAST_SIGNAL] = { 0 }; static guint glade_property_signals[LAST_SIGNAL] = { 0 };
static GObjectClass* parent_class = NULL; static GObjectClass* parent_class = NULL;
...@@ -130,6 +147,14 @@ glade_property_set_value_impl (GladeProperty *property, const GValue *value) ...@@ -130,6 +147,14 @@ glade_property_set_value_impl (GladeProperty *property, const GValue *value)
} }
static void
glade_property_get_value_impl (GladeProperty *property, GValue *value)
{
g_value_init (value, property->class->pspec->value_type);
g_value_copy (property->value, value);
}
static void static void
glade_property_sync_impl (GladeProperty *property) glade_property_sync_impl (GladeProperty *property)
{ {
...@@ -273,70 +298,81 @@ glade_property_write_impl (GladeProperty *property, ...@@ -273,70 +298,81 @@ glade_property_write_impl (GladeProperty *property,
return TRUE; return TRUE;
} }
/* Parameters for translatable properties. */
static void
glade_property_i18n_set_comment_impl (GladeProperty *property,
const gchar *str)
{
if (property->i18n_comment)
g_free (property->i18n_comment);
property->i18n_comment = g_strdup (str); static G_CONST_RETURN gchar *
} glade_property_get_tooltip_impl (GladeProperty *property)
static const gchar *
glade_property_i18n_get_comment_impl (GladeProperty *property)
{ {
return property->i18n_comment; gchar *tooltip = NULL;
if (property->sensitive == FALSE)
tooltip = property->insensitive_tooltip;
else
tooltip = property->class->tooltip;
return tooltip;
} }
/*******************************************************************************
GObjectClass & Object Construction
*******************************************************************************/
static void static void
glade_property_i18n_set_translatable_impl (GladeProperty *property, glade_property_set_real_property (GObject *object,
gboolean translatable) guint prop_id,
const GValue *value,
GParamSpec *pspec)
{ {
property->i18n_translatable = translatable; GladeProperty *property = GLADE_PROPERTY (object);
}
static gboolean switch (prop_id)
glade_property_i18n_get_translatable_impl (GladeProperty *property) {
{ case PROP_ENABLED:
return property->i18n_translatable; glade_property_set_enabled (property, g_value_get_boolean (value));
break;
case PROP_I18N_TRANSLATABLE:
glade_property_i18n_set_translatable (property, g_value_get_boolean (value));
break;
case PROP_I18N_HAS_CONTEXT:
glade_property_i18n_set_has_context (property, g_value_get_boolean (value));
break;
case PROP_I18N_COMMENT:
glade_property_i18n_set_comment (property, g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
} }
static void static void
glade_property_i18n_set_has_context_impl (GladeProperty *property, glade_property_get_real_property (GObject *object,
gboolean has_context) guint prop_id,
{ GValue *value,
property->i18n_has_context = has_context; GParamSpec *pspec)
}
static gboolean
glade_property_i18n_get_has_context_impl (GladeProperty *property)
{ {
return property->i18n_has_context; GladeProperty *property = GLADE_PROPERTY (object);
}
static void switch (prop_id)
glade_property_set_sensitive_impl (GladeProperty *property,
gboolean sensitive)
{
if (property->sensitive != sensitive)
{ {
GladeEditor *editor = glade_default_app_get_editor (); case PROP_ENABLED:
g_value_set_boolean (value, glade_property_get_enabled (property));
property->sensitive = sensitive; break;
case PROP_SENSITIVE:
/* Reload editor if this widget is selected */ g_value_set_boolean (value, glade_property_get_sensitive (property));
if (editor->loaded_widget == property->widget) break;
glade_editor_refresh (editor); case PROP_I18N_TRANSLATABLE:
g_value_set_boolean (value, glade_property_i18n_get_translatable (property));
break;
case PROP_I18N_HAS_CONTEXT:
g_value_set_boolean (value, glade_property_i18n_get_has_context (property));
break;
case PROP_I18N_COMMENT:
g_value_set_string (value, glade_property_i18n_get_comment (property));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
} }