gimp r25804 - in trunk: . app/widgets
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r25804 - in trunk: . app/widgets
- Date: Mon, 26 May 2008 15:18:31 +0000 (UTC)
Author: neo
Date: Mon May 26 15:18:31 2008
New Revision: 25804
URL: http://svn.gnome.org/viewvc/gimp?rev=25804&view=rev
Log:
2008-05-26 Sven Neumann <sven gimp org>
* app/widgets/gimppropwidgets.[ch]: support for GimpScaleButton.
Modified:
trunk/ChangeLog
trunk/app/widgets/gimppropwidgets.c
trunk/app/widgets/gimppropwidgets.h
Modified: trunk/app/widgets/gimppropwidgets.c
==============================================================================
--- trunk/app/widgets/gimppropwidgets.c (original)
+++ trunk/app/widgets/gimppropwidgets.c Mon May 26 15:18:31 2008
@@ -40,6 +40,7 @@
#include "gimpcolorpanel.h"
#include "gimpdnd.h"
+#include "gimpscalebutton.h"
#include "gimpview.h"
#include "gimppropwidgets.h"
#include "gimpwidgets-constructors.h"
@@ -335,6 +336,120 @@
}
+/******************/
+/* scale button */
+/******************/
+
+static void gimp_prop_scale_button_callback (GtkWidget *widget,
+ GObject *config);
+static void gimp_prop_scale_button_notify (GObject *config,
+ GParamSpec *param_spec,
+ GtkWidget *button);
+
+/**
+ * gimp_prop_scale_button_new:
+ * @config: #GimpConfig object to which property is attached.
+ * @property_name: Name of gdouble property
+ *
+ * Creates a #GimpScaleButton to set and display the value of a
+ * gdouble property in a very space-efficient way.
+ *
+ * Return value: A new #GimpScaleButton widget.
+ *
+ * Since GIMP 2.6
+ */
+GtkWidget *
+gimp_prop_scale_button_new (GObject *config,
+ const gchar *property_name)
+{
+ GParamSpec *param_spec;
+ GtkWidget *button;
+ GtkObject *adj;
+ gdouble value;
+ gdouble lower;
+ gdouble upper;
+
+ param_spec = check_param_spec_w (config, property_name,
+ G_TYPE_PARAM_DOUBLE, G_STRFUNC);
+
+ if (! param_spec)
+ return NULL;
+
+ g_object_get (config,
+ param_spec->name, &value,
+ NULL);
+
+ lower = G_PARAM_SPEC_DOUBLE (param_spec)->minimum;
+ upper = G_PARAM_SPEC_DOUBLE (param_spec)->maximum;
+
+ button = gimp_scale_button_new ();
+
+ adj = gtk_adjustment_new (value, lower, upper, (upper - lower) / 10.0, 0, 0);
+ gtk_scale_button_set_adjustment (GTK_SCALE_BUTTON (button),
+ GTK_ADJUSTMENT (adj));
+
+ set_param_spec (G_OBJECT (button), button, param_spec);
+
+ g_signal_connect (button, "value-changed",
+ G_CALLBACK (gimp_prop_scale_button_callback),
+ config);
+
+ connect_notify (config, property_name,
+ G_CALLBACK (gimp_prop_scale_button_notify),
+ button);
+
+ return button;
+}
+
+static void
+gimp_prop_scale_button_callback (GtkWidget *button,
+ GObject *config)
+{
+ GParamSpec *param_spec;
+ gdouble value;
+
+ param_spec = get_param_spec (G_OBJECT (button));
+ if (! param_spec)
+ return;
+
+ value = gtk_scale_button_get_value (GTK_SCALE_BUTTON (button));
+
+ g_signal_handlers_block_by_func (config,
+ gimp_prop_scale_button_notify,
+ button);
+
+ g_object_set (config,
+ param_spec->name, &value,
+ NULL);
+
+ g_signal_handlers_unblock_by_func (config,
+ gimp_prop_scale_button_notify,
+ button);
+}
+
+static void
+gimp_prop_scale_button_notify (GObject *config,
+ GParamSpec *param_spec,
+ GtkWidget *button)
+{
+ gdouble value;
+
+ g_object_get (config,
+ param_spec->name, &value,
+ NULL);
+
+ g_signal_handlers_block_by_func (button,
+ gimp_prop_scale_button_callback,
+ config);
+
+ gtk_scale_button_set_value (GTK_SCALE_BUTTON (button), value);
+
+ g_signal_handlers_unblock_by_func (button,
+ gimp_prop_scale_button_callback,
+ config);
+}
+
+
/*************/
/* view */
/*************/
Modified: trunk/app/widgets/gimppropwidgets.h
==============================================================================
--- trunk/app/widgets/gimppropwidgets.h (original)
+++ trunk/app/widgets/gimppropwidgets.h Mon May 26 15:18:31 2008
@@ -50,6 +50,11 @@
GimpColorAreaType type);
+/* GParamDouble */
+GtkWidget * gimp_prop_scale_button_new (GObject *config,
+ const gchar *property_name);
+
+
/* GParamObject (GimpViewable) */
GtkWidget * gimp_prop_view_new (GObject *config,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]