Author: akv
Date: 2013-05-05 01:09:42 +0200 (Sun, 05 May 2013)
New Revision: 4383
Modified:
branches/4175-enfuse/src/gtk-helper.c
branches/4175-enfuse/src/gtk-helper.h
Log:
Added rs_spinbox_new() for easy spinner creation.
Modified: branches/4175-enfuse/src/gtk-helper.c
===================================================================
--- branches/4175-enfuse/src/gtk-helper.c 2013-05-04 15:06:28 UTC (rev
4382)
+++ branches/4175-enfuse/src/gtk-helper.c 2013-05-04 23:09:42 UTC (rev
4383)
@@ -861,3 +861,35 @@
return hbox;
}
+
+static gboolean
+spinbox_changed(GtkAdjustment *adj, const gchar *conf_key)
+{
+ const gdouble value = (gdouble) adj->value;
+ rs_conf_set_double(conf_key, value);
+ return(FALSE);
+}
+
+
+GtkWidget *
+rs_spinbox_new(const gchar *text, const gchar *conf_key, gint
conf_key_default, gdouble lower, gdouble upper, gdouble step, gdouble page)
+{
+ gdouble value = conf_key_default;
+
+ if (!rs_conf_get_double(conf_key, &value))
+ value = conf_key_default;
+
+ GtkWidget *hbox = gtk_hbox_new(FALSE, 0);
+ GtkWidget *label = gtk_label_new(text);
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+ GtkWidget *adj = gtk_adjustment_new((gdouble) value, lower, upper, step,
page, 0.0);
+ g_signal_connect(adj, "value_changed", G_CALLBACK(spinbox_changed),
(gpointer) conf_key);
+ GtkWidget *spinbutton;
+ if (step < 1.0)
+ spinbutton = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 1, 1);
+ else
+ spinbutton = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 1, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, TRUE, 0);
+ return hbox;
+}
Modified: branches/4175-enfuse/src/gtk-helper.h
===================================================================
--- branches/4175-enfuse/src/gtk-helper.h 2013-05-04 15:06:28 UTC (rev
4382)
+++ branches/4175-enfuse/src/gtk-helper.h 2013-05-04 23:09:42 UTC (rev
4383)
@@ -93,3 +93,4 @@
extern RSColorSpace* rs_get_display_profile(GtkWidget *widget);
extern GtkWidget * rs_combobox_new(const gchar *text, GtkListStore *store,
const gchar *conf_key);
+extern GtkWidget * rs_spinbox_new(const gchar *text, const gchar *conf_key,
gint conf_key_default, gdouble lower, gdouble upper, gdouble step, gdouble
page);
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit