[gimp] app: add a menu of kelvin presets to GEGL properties with unit "kelvin"
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add a menu of kelvin presets to GEGL properties with unit "kelvin"
- Date: Sun, 1 Jun 2014 19:02:07 +0000 (UTC)
commit 65b46244c7157dbe55f1f9e4bcd6013728b3346b
Author: Michael Natterer <mitch gimp org>
Date: Sun Jun 1 20:58:21 2014 +0200
app: add a menu of kelvin presets to GEGL properties with unit "kelvin"
Values taken from http://en.wikipedia.org/wiki/Color_temperature
app/widgets/gimppropgui.c | 139 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 137 insertions(+), 2 deletions(-)
---
diff --git a/app/widgets/gimppropgui.c b/app/widgets/gimppropgui.c
index 46393d7..8021dd2 100644
--- a/app/widgets/gimppropgui.c
+++ b/app/widgets/gimppropgui.c
@@ -44,6 +44,7 @@
#include "gimppropgui.h"
#include "gimppropgui-constructors.h"
#include "gimppropwidgets.h"
+#include "gimpwidgets-utils.h"
#include "gimp-intl.h"
@@ -51,8 +52,10 @@
#define HAS_KEY(p,k,v) gimp_gegl_param_spec_has_key (p, k, v)
-static void gimp_prop_widget_new_seed_clicked (GtkButton *button,
- GtkAdjustment *adj);
+static GtkWidget * gimp_prop_kelvin_presets_new (GObject *config,
+ const gchar *property_name);
+static void gimp_prop_widget_new_seed_clicked (GtkButton *button,
+ GtkAdjustment *adj);
/* public functions */
@@ -187,6 +190,22 @@ gimp_prop_widget_new (GObject *config,
widget = hbox;
}
+ else if (HAS_KEY (pspec, "unit", "kelvin"))
+ {
+ GtkWidget *hbox;
+ GtkWidget *button;
+
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
+
+ gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
+ gtk_widget_show (widget);
+
+ button = gimp_prop_kelvin_presets_new (config, pspec->name);
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+ gtk_widget_show (button);
+
+ widget = hbox;
+ }
}
else if (G_IS_PARAM_SPEC_STRING (pspec))
{
@@ -359,6 +378,122 @@ gimp_prop_gui_new (GObject *config,
/* private functions */
static void
+gimp_prop_kelvin_presets_menu_position (GtkMenu *menu,
+ gint *x,
+ gint *y,
+ gboolean *push_in,
+ gpointer user_data)
+{
+ gimp_button_menu_position (user_data, menu, GTK_POS_LEFT, x, y);
+}
+
+static gboolean
+gimp_prop_kelvin_presets_button_press (GtkWidget *widget,
+ GdkEventButton *bevent,
+ GtkMenu *menu)
+{
+ if (bevent->type == GDK_BUTTON_PRESS)
+ {
+ gtk_menu_popup (menu,
+ NULL, NULL,
+ gimp_prop_kelvin_presets_menu_position, widget,
+ bevent->button, bevent->time);
+ }
+
+ return TRUE;
+}
+
+static void
+gimp_prop_kelvin_presets_activate (GtkWidget *widget,
+ GObject *config)
+{
+ const gchar *property_name;
+ gdouble *kelvin;
+
+ property_name = g_object_get_data (G_OBJECT (widget), "property-name");
+ kelvin = g_object_get_data (G_OBJECT (widget), "kelvin");
+
+ if (property_name && kelvin)
+ g_object_set (config, property_name, *kelvin, NULL);
+}
+
+static GtkWidget *
+gimp_prop_kelvin_presets_new (GObject *config,
+ const gchar *property_name)
+{
+ GtkWidget *button;
+ GtkWidget *menu;
+ gint i;
+
+ const struct
+ {
+ gdouble kelvin;
+ const gchar *label;
+ }
+ kelvin_presets[] =
+ {
+ { 1700, N_("1,700 K – Match flame") },
+ { 1850, N_("1,850 K – Candle flame, sunset/sunrise") },
+ { 3000, N_("3,000 K – Soft (or warm) white compact fluorescent lamps") },
+ { 3000, N_("3,300 K – Incandescent lamps") },
+ { 3200, N_("3,200 K – Studio lamps, photofloods, etc.") },
+ { 3350, N_("3,350 K – Studio \"CP\" light") },
+ { 4100, N_("4,100 K – Moonlight") },
+ { 5000, N_("5,000 K – D50") },
+ { 5000, N_("5,000 K – Cool white/daylight compact fluorescent lamps") },
+ { 5000, N_("5,000 K – Horizon daylight") },
+ { 5500, N_("5,500 K – D55") },
+ { 5500, N_("5,500 K – Vertical daylight, electronic flash") },
+ { 6200, N_("6,200 K – Xenon short-arc lamp") },
+ { 6500, N_("6,500 K – D65") },
+ { 6500, N_("6,500 K – Daylight, overcast") },
+ { 7500, N_("7,500 K – D75") },
+ { 9300, N_("9,300 K") }
+ };
+
+ button = gtk_button_new ();
+ gtk_widget_set_can_focus (button, FALSE);
+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+
+ gtk_button_set_image (GTK_BUTTON (button),
+ gtk_image_new_from_icon_name (GIMP_STOCK_MENU_LEFT,
+ GTK_ICON_SIZE_MENU));
+
+ menu = gtk_menu_new ();
+ gtk_menu_attach_to_widget (GTK_MENU (menu), button, NULL);
+
+ g_signal_connect (button, "button-press-event",
+ G_CALLBACK (gimp_prop_kelvin_presets_button_press),
+ menu);
+
+ for (i = 0; i < G_N_ELEMENTS (kelvin_presets); i++)
+ {
+ GtkWidget *item;
+ gdouble *kelvin;
+
+ item = gtk_menu_item_new_with_label (gettext (kelvin_presets[i].label));
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show (item);
+
+ g_object_set_data_full (G_OBJECT (item), "property-name",
+ g_strdup (property_name), (GDestroyNotify) g_free);
+
+ kelvin = g_new (gdouble, 1);
+ *kelvin = kelvin_presets[i].kelvin;
+
+ g_object_set_data_full (G_OBJECT (item), "kelvin",
+ kelvin, (GDestroyNotify) g_free);
+
+ g_signal_connect (item, "activate",
+ G_CALLBACK (gimp_prop_kelvin_presets_activate),
+ config);
+
+ }
+
+ return button;
+}
+
+static void
gimp_prop_widget_new_seed_clicked (GtkButton *button,
GtkAdjustment *adj)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]