Commit 346a58c3 authored by Victor Ananjesky's avatar Victor Ananjesky

switch to GtkColorChooser in color widget for gtk3. remove --extra option for color dialogs

parent 5bc40060
......@@ -107,11 +107,17 @@ expand_action (gchar * cmd)
break;
case YAD_FIELD_COLOR:
{
#if !GTK_CHECK_VERSION(3,0,0)
GdkColor c;
GtkColorButton *cb = GTK_COLOR_BUTTON (g_slist_nth_data (fields, num));
gtk_color_button_get_color (cb, &c);
buf = get_color (&c, gtk_color_button_get_alpha (cb));
#else
GdkRGBA c;
GtkColorChooser *cb = GTK_COLOR_CHOOSER (g_slist_nth_data (fields, num));
gtk_color_chooser_get_rgba (cb, &c);
buf = get_color (&c);
#endif
arg = g_shell_quote (buf ? buf : "");
g_free (buf);
break;
......@@ -1256,11 +1262,17 @@ form_print_field (guint fn)
case YAD_FIELD_COLOR:
{
gchar *cs;
#if !GTK_CHECK_VERSION(3,0,0)
GdkColor c;
GtkColorButton *cb = GTK_COLOR_BUTTON (g_slist_nth_data (fields, fn));
gtk_color_button_get_color (cb, &c);
cs = get_color (&c, gtk_color_button_get_alpha (cb));
#else
GdkRGBA c;
GtkColorChooser *cb = GTK_COLOR_CHOOSER (g_slist_nth_data (fields, fn));
gtk_color_chooser_get_rgba (cb, &c);
cs = get_color (&c);
#endif
if (options.common_data.quoted_output)
{
buf = g_shell_quote (cs ? cs : "");
......
......@@ -1474,7 +1474,6 @@ yad_options_init (void)
options.color_data.use_palette = FALSE;
options.color_data.expand_palette = FALSE;
options.color_data.palette = NULL;
options.color_data.extra = FALSE;
options.color_data.alpha = FALSE;
options.color_data.mode = YAD_COLOR_HEX;
......
......@@ -198,9 +198,9 @@ get_color (GdkColor *c, guint64 alpha)
{
case YAD_COLOR_HEX:
if (options.color_data.alpha)
res = g_strdup_printf ("#%hXhXhXhX", c->red, c->green, c->blue, alpha / 256);
res = g_strdup_printf ("#%X%X%X%X", c->red & 0xFF, c->green & 0xFF, c->blue & 0xFF, (alpha / 256) & 0xFF);
else
res = g_strdup_printf ("#%hXhXhX", c->red, c->green, c->blue);
res = g_strdup_printf ("#%X%X%X", c->red & 0xFF, c->green & 0xFF, c->blue & 0xFF);
break;
case YAD_COLOR_RGB:
if (options.color_data.alpha)
......@@ -224,9 +224,9 @@ get_color (GdkRGBA *c)
{
case YAD_COLOR_HEX:
if (options.color_data.alpha)
res = g_strdup_printf ("#%hXhXhXhX", c->red * 255, c->green * 255, c->blue * 255, c->alpha * 255);
res = g_strdup_printf ("#%X%X%X%X", (int) (c->red * 255), (int) (c->green * 255), (int) (c->blue * 255), (int) (c->alpha * 255));
else
res = g_strdup_printf ("#%hXhXhX", c->red * 255, c->green * 255, c->blue * 255);
res = g_strdup_printf ("#%X%X%X", (int) (c->red * 255), (int) (c->green * 255), (int) (c->blue * 255));
break;
case YAD_COLOR_RGB:
res = gdk_rgba_to_string (c);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment