Connect to value_changed signal
2001-12-19 Bradford Hovinen <hovinen@ximian.com> * gconf-property-editor.c (gconf_peditor_new_float_range) (gconf_peditor_new_int_range): Connect to value_changed signal * capplet-util.c: Comment out most of this file * gconf-property-editor.c (gconf_peditor_new_int_range): Convert to ~_float_range (gconf_peditor_new_float_range): Add callbacks for conversion between widget's values and GConf values in the signature (peditor_float_range_widget_changed): Issue callback, if available, to convert from widget's values to GConf values (peditor_float_range_value_changed): Vice verca above (gconf_peditor_new_int_range, peditor_int_range_widget_changed) (peditor_int_range_value_changed): Implement. Copy from float versions
This commit is contained in:
parent
b8fd80b0a1
commit
3cacd8d820
4 changed files with 174 additions and 32 deletions
|
@ -1,3 +1,21 @@
|
||||||
|
2001-12-19 Bradford Hovinen <hovinen@ximian.com>
|
||||||
|
|
||||||
|
* gconf-property-editor.c (gconf_peditor_new_float_range)
|
||||||
|
(gconf_peditor_new_int_range): Connect to value_changed signal
|
||||||
|
|
||||||
|
* capplet-util.c: Comment out most of this file
|
||||||
|
|
||||||
|
* gconf-property-editor.c (gconf_peditor_new_int_range): Convert
|
||||||
|
to ~_float_range
|
||||||
|
(gconf_peditor_new_float_range): Add callbacks for conversion
|
||||||
|
between widget's values and GConf values in the signature
|
||||||
|
(peditor_float_range_widget_changed): Issue callback, if
|
||||||
|
available, to convert from widget's values to GConf values
|
||||||
|
(peditor_float_range_value_changed): Vice verca above
|
||||||
|
(gconf_peditor_new_int_range, peditor_int_range_widget_changed)
|
||||||
|
(peditor_int_range_value_changed): Implement. Copy from float
|
||||||
|
versions
|
||||||
|
|
||||||
2001-12-18 Bradford Hovinen <hovinen@ximian.com>
|
2001-12-18 Bradford Hovinen <hovinen@ximian.com>
|
||||||
|
|
||||||
* capplet-util.h: Don't #include bonobo*.h
|
* capplet-util.h: Don't #include bonobo*.h
|
||||||
|
|
|
@ -40,6 +40,8 @@ static SetupPropertyEditorsFn setup_property_editors_cb = NULL;
|
||||||
|
|
||||||
static GConfChangeSet *changeset;
|
static GConfChangeSet *changeset;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
/* apply_cb
|
/* apply_cb
|
||||||
*
|
*
|
||||||
* Callback issued when the user clicks "Apply" or "Ok". This function is
|
* Callback issued when the user clicks "Apply" or "Ok". This function is
|
||||||
|
@ -171,6 +173,8 @@ get_property_name (const gchar *binary)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/* setup_session_mgmt
|
/* setup_session_mgmt
|
||||||
*
|
*
|
||||||
* Make sure the capplet launches and applies its settings next time the user
|
* Make sure the capplet launches and applies its settings next time the user
|
||||||
|
@ -218,6 +222,8 @@ setup_session_mgmt (const gchar *binary_name)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
/* capplet_init -- see documentation in capplet-util.h
|
/* capplet_init -- see documentation in capplet-util.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -282,3 +288,5 @@ capplet_init (int argc,
|
||||||
gconf_change_set_unref (changeset);
|
gconf_change_set_unref (changeset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -529,34 +529,55 @@ gconf_peditor_new_select_radio (GConfChangeSet *changeset, gchar *key, GSList *r
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
peditor_int_range_value_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, GConfPropertyEditor *peditor)
|
peditor_float_range_value_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, GConfPropertyEditor *peditor)
|
||||||
{
|
{
|
||||||
GConfValue *value;
|
GConfValue *value;
|
||||||
GtkAdjustment *adjustment;
|
GtkAdjustment *adjustment;
|
||||||
|
GConfPEditorValueConvFn to_widget_cb;
|
||||||
|
gfloat value_f;
|
||||||
|
|
||||||
|
to_widget_cb = g_object_get_data (G_OBJECT (peditor), "to-widget-cb");
|
||||||
|
|
||||||
gconf_change_set_remove (peditor->p->changeset, peditor->p->key);
|
gconf_change_set_remove (peditor->p->changeset, peditor->p->key);
|
||||||
value = gconf_entry_get_value (entry);
|
value = gconf_entry_get_value (entry);
|
||||||
|
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
|
value_f = gconf_value_get_float (value);
|
||||||
|
|
||||||
|
if (to_widget_cb != NULL)
|
||||||
|
value_f = to_widget_cb (value_f);
|
||||||
|
|
||||||
adjustment = g_object_get_data (G_OBJECT (peditor), "adjustment");
|
adjustment = g_object_get_data (G_OBJECT (peditor), "adjustment");
|
||||||
gtk_adjustment_set_value (adjustment, gconf_value_get_int (value));
|
gtk_adjustment_set_value (adjustment, value_f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
peditor_int_range_widget_changed (GConfPropertyEditor *peditor, GtkAdjustment *adjustment)
|
peditor_float_range_widget_changed (GConfPropertyEditor *peditor, GtkAdjustment *adjustment)
|
||||||
{
|
{
|
||||||
GConfValue *value;
|
GConfValue *value;
|
||||||
|
gfloat value_f;
|
||||||
|
GConfPEditorValueConvFn from_widget_cb;
|
||||||
|
|
||||||
gconf_change_set_set_int (peditor->p->changeset, peditor->p->key,
|
from_widget_cb = g_object_get_data (G_OBJECT (peditor), "from-widget-cb");
|
||||||
gtk_adjustment_get_value (adjustment));
|
|
||||||
|
value_f = gtk_adjustment_get_value (adjustment);
|
||||||
|
|
||||||
|
if (from_widget_cb != NULL)
|
||||||
|
value_f = from_widget_cb (value_f);
|
||||||
|
|
||||||
|
gconf_change_set_set_float (peditor->p->changeset, peditor->p->key, value_f);
|
||||||
|
|
||||||
gconf_change_set_check_value (peditor->p->changeset, peditor->p->key, &value);
|
gconf_change_set_check_value (peditor->p->changeset, peditor->p->key, &value);
|
||||||
g_signal_emit (peditor, peditor_signals[VALUE_CHANGED], 0, peditor->p->key, value);
|
g_signal_emit (peditor, peditor_signals[VALUE_CHANGED], 0, peditor->p->key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
GObject *
|
GObject *
|
||||||
gconf_peditor_new_int_range (GConfChangeSet *changeset, gchar *key, GtkWidget *range)
|
gconf_peditor_new_float_range (GConfChangeSet *changeset,
|
||||||
|
gchar *key,
|
||||||
|
GtkWidget *range,
|
||||||
|
GConfPEditorValueConvFn to_widget_cb,
|
||||||
|
GConfPEditorValueConvFn from_widget_cb)
|
||||||
{
|
{
|
||||||
GObject *peditor;
|
GObject *peditor;
|
||||||
GConfClient *client;
|
GConfClient *client;
|
||||||
|
@ -564,6 +585,91 @@ gconf_peditor_new_int_range (GConfChangeSet *changeset, gchar *key, GtkWidget *r
|
||||||
GSList *item;
|
GSList *item;
|
||||||
GtkAdjustment *adjustment;
|
GtkAdjustment *adjustment;
|
||||||
|
|
||||||
|
peditor = g_object_new (gconf_property_editor_get_type (),
|
||||||
|
"key", key,
|
||||||
|
"callback", peditor_float_range_value_changed,
|
||||||
|
"changeset", changeset,
|
||||||
|
"object", range,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
adjustment = gtk_range_get_adjustment (GTK_RANGE (range));
|
||||||
|
g_object_set_data (peditor, "adjustment", adjustment);
|
||||||
|
g_object_set_data (peditor, "to-widget-cb", to_widget_cb);
|
||||||
|
g_object_set_data (peditor, "from-widget-cb", from_widget_cb);
|
||||||
|
|
||||||
|
g_signal_connect_swapped (G_OBJECT (adjustment), "value_changed",
|
||||||
|
(GCallback) peditor_float_range_widget_changed, peditor);
|
||||||
|
|
||||||
|
client = gconf_client_get_default ();
|
||||||
|
gconf_entry = gconf_client_get_entry (client, key, NULL, TRUE, NULL);
|
||||||
|
peditor_float_range_value_changed (client, 0, gconf_entry, GCONF_PROPERTY_EDITOR (peditor));
|
||||||
|
|
||||||
|
return peditor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME: These differ only trivially from the float versions; we should combine them */
|
||||||
|
|
||||||
|
static void
|
||||||
|
peditor_int_range_value_changed (GConfClient *client,
|
||||||
|
guint cnxn_id,
|
||||||
|
GConfEntry *entry,
|
||||||
|
GConfPropertyEditor *peditor)
|
||||||
|
{
|
||||||
|
GConfValue *value;
|
||||||
|
GtkAdjustment *adjustment;
|
||||||
|
GConfPEditorValueConvFn to_widget_cb;
|
||||||
|
gfloat value_i;
|
||||||
|
|
||||||
|
to_widget_cb = g_object_get_data (G_OBJECT (peditor), "to-widget-cb");
|
||||||
|
|
||||||
|
gconf_change_set_remove (peditor->p->changeset, peditor->p->key);
|
||||||
|
value = gconf_entry_get_value (entry);
|
||||||
|
|
||||||
|
if (value != NULL) {
|
||||||
|
value_i = gconf_value_get_int (value);
|
||||||
|
|
||||||
|
if (to_widget_cb != NULL)
|
||||||
|
value_i = to_widget_cb (value_i);
|
||||||
|
|
||||||
|
adjustment = g_object_get_data (G_OBJECT (peditor), "adjustment");
|
||||||
|
gtk_adjustment_set_value (adjustment, value_i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
peditor_int_range_widget_changed (GConfPropertyEditor *peditor,
|
||||||
|
GtkAdjustment *adjustment)
|
||||||
|
{
|
||||||
|
GConfValue *value;
|
||||||
|
gfloat value_i;
|
||||||
|
GConfPEditorValueConvFn from_widget_cb;
|
||||||
|
|
||||||
|
from_widget_cb = g_object_get_data (G_OBJECT (peditor), "from-widget-cb");
|
||||||
|
|
||||||
|
value_i = gtk_adjustment_get_value (adjustment);
|
||||||
|
|
||||||
|
if (from_widget_cb != NULL)
|
||||||
|
value_i = from_widget_cb (value_i);
|
||||||
|
|
||||||
|
gconf_change_set_set_int (peditor->p->changeset, peditor->p->key, value_i);
|
||||||
|
|
||||||
|
gconf_change_set_check_value (peditor->p->changeset, peditor->p->key, &value);
|
||||||
|
g_signal_emit (peditor, peditor_signals[VALUE_CHANGED], 0, peditor->p->key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
GObject *
|
||||||
|
gconf_peditor_new_int_range (GConfChangeSet *changeset,
|
||||||
|
gchar *key,
|
||||||
|
GtkWidget *range,
|
||||||
|
GConfPEditorValueConvFn to_widget_cb,
|
||||||
|
GConfPEditorValueConvFn from_widget_cb)
|
||||||
|
{
|
||||||
|
GObject *peditor;
|
||||||
|
GConfClient *client;
|
||||||
|
GConfEntry *gconf_entry;
|
||||||
|
GSList *item;
|
||||||
|
GtkAdjustment *adjustment;
|
||||||
|
|
||||||
peditor = g_object_new (gconf_property_editor_get_type (),
|
peditor = g_object_new (gconf_property_editor_get_type (),
|
||||||
"key", key,
|
"key", key,
|
||||||
"callback", peditor_int_range_value_changed,
|
"callback", peditor_int_range_value_changed,
|
||||||
|
@ -573,8 +679,10 @@ gconf_peditor_new_int_range (GConfChangeSet *changeset, gchar *key, GtkWidget *r
|
||||||
|
|
||||||
adjustment = gtk_range_get_adjustment (GTK_RANGE (range));
|
adjustment = gtk_range_get_adjustment (GTK_RANGE (range));
|
||||||
g_object_set_data (peditor, "adjustment", adjustment);
|
g_object_set_data (peditor, "adjustment", adjustment);
|
||||||
|
g_object_set_data (peditor, "to-widget-cb", to_widget_cb);
|
||||||
|
g_object_set_data (peditor, "from-widget-cb", from_widget_cb);
|
||||||
|
|
||||||
g_signal_connect_swapped (G_OBJECT (adjustment), "changed",
|
g_signal_connect_swapped (G_OBJECT (adjustment), "value_changed",
|
||||||
(GCallback) peditor_int_range_widget_changed, peditor);
|
(GCallback) peditor_int_range_widget_changed, peditor);
|
||||||
|
|
||||||
client = gconf_client_get_default ();
|
client = gconf_client_get_default ();
|
||||||
|
@ -600,4 +708,3 @@ gconf_peditor_widget_set_guard (GConfPropertyEditor *peditor, GtkWidget *widget)
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (peditor), "value-changed", (GCallback) guard_value_changed, widget);
|
g_signal_connect (G_OBJECT (peditor), "value-changed", (GCallback) guard_value_changed, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,8 @@ typedef struct _GConfPropertyEditor GConfPropertyEditor;
|
||||||
typedef struct _GConfPropertyEditorClass GConfPropertyEditorClass;
|
typedef struct _GConfPropertyEditorClass GConfPropertyEditorClass;
|
||||||
typedef struct _GConfPropertyEditorPrivate GConfPropertyEditorPrivate;
|
typedef struct _GConfPropertyEditorPrivate GConfPropertyEditorPrivate;
|
||||||
|
|
||||||
|
typedef gfloat (*GConfPEditorValueConvFn) (gfloat);
|
||||||
|
|
||||||
struct _GConfPropertyEditor
|
struct _GConfPropertyEditor
|
||||||
{
|
{
|
||||||
GObject parent;
|
GObject parent;
|
||||||
|
@ -54,32 +56,39 @@ struct _GConfPropertyEditorClass
|
||||||
|
|
||||||
GType gconf_property_editor_get_type (void);
|
GType gconf_property_editor_get_type (void);
|
||||||
|
|
||||||
const gchar *gconf_property_editor_get_key (GConfPropertyEditor *peditor);
|
const gchar *gconf_property_editor_get_key (GConfPropertyEditor *peditor);
|
||||||
|
|
||||||
GObject *gconf_peditor_new_boolean (GConfChangeSet *changeset,
|
GObject *gconf_peditor_new_boolean (GConfChangeSet *changeset,
|
||||||
gchar *key,
|
gchar *key,
|
||||||
GtkWidget *checkbox);
|
GtkWidget *checkbox);
|
||||||
GObject *gconf_peditor_new_string (GConfChangeSet *changeset,
|
GObject *gconf_peditor_new_string (GConfChangeSet *changeset,
|
||||||
gchar *key,
|
gchar *key,
|
||||||
GtkWidget *entry);
|
GtkWidget *entry);
|
||||||
GObject *gconf_peditor_new_filename (GConfChangeSet *changeset,
|
GObject *gconf_peditor_new_filename (GConfChangeSet *changeset,
|
||||||
gchar *key,
|
gchar *key,
|
||||||
GtkWidget *file_entry);
|
GtkWidget *file_entry);
|
||||||
GObject *gconf_peditor_new_color (GConfChangeSet *changeset,
|
GObject *gconf_peditor_new_color (GConfChangeSet *changeset,
|
||||||
gchar *key,
|
gchar *key,
|
||||||
GtkWidget *color_entry);
|
GtkWidget *color_entry);
|
||||||
GObject *gconf_peditor_new_select_menu (GConfChangeSet *changeset,
|
GObject *gconf_peditor_new_select_menu (GConfChangeSet *changeset,
|
||||||
gchar *key,
|
gchar *key,
|
||||||
GtkWidget *option_menu);
|
GtkWidget *option_menu);
|
||||||
GObject *gconf_peditor_new_select_radio (GConfChangeSet *changeset,
|
GObject *gconf_peditor_new_select_radio (GConfChangeSet *changeset,
|
||||||
gchar *key,
|
gchar *key,
|
||||||
GSList *radio_group);
|
GSList *radio_group);
|
||||||
GObject *gconf_peditor_new_int_range (GConfChangeSet *changeset,
|
GObject *gconf_peditor_new_float_range (GConfChangeSet *changeset,
|
||||||
gchar *key,
|
gchar *key,
|
||||||
GtkWidget *range);
|
GtkWidget *range,
|
||||||
|
GConfPEditorValueConvFn to_widget_cb,
|
||||||
|
GConfPEditorValueConvFn from_widget_cb);
|
||||||
|
GObject *gconf_peditor_new_int_range (GConfChangeSet *changeset,
|
||||||
|
gchar *key,
|
||||||
|
GtkWidget *range,
|
||||||
|
GConfPEditorValueConvFn to_widget_cb,
|
||||||
|
GConfPEditorValueConvFn from_widget_cb);
|
||||||
|
|
||||||
void gconf_peditor_widget_set_guard (GConfPropertyEditor *peditor,
|
void gconf_peditor_widget_set_guard (GConfPropertyEditor *peditor,
|
||||||
GtkWidget *widget);
|
GtkWidget *widget);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue