static void gtk_color_button_get_property (GObject *object, guint param_id, GValue *value, GParamSpec *pspec) { GtkColorButton *color_button = GTK_COLOR_BUTTON (object); GdkColor color; switch (param_id) { case PROP_USE_ALPHA: g_value_set_boolean (value, gtk_color_button_get_use_alpha (color_button)); break; case PROP_TITLE: g_value_set_string (value, gtk_color_button_get_title (color_button)); break; case PROP_COLOR: gtk_color_button_get_color (color_button, &color); g_value_set_boxed (value, &color); break; case PROP_ALPHA: g_value_set_uint (value, gtk_color_button_get_alpha (color_button)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; } }
void widget_colorbutton_save(variable *var) { FILE *outfile; GdkColor color; GList *element; gchar *act; gchar *filename = NULL; #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Entering.\n", __func__); #endif /* We'll use the output file filename if available */ act = attributeset_get_first(&element, var->Attributes, ATTR_OUTPUT); while (act) { if (strncasecmp(act, "file:", 5) == 0 && strlen(act) > 5) { filename = act + 5; break; } act = attributeset_get_next(&element, var->Attributes, ATTR_OUTPUT); } /* If we have a valid filename then open it and dump the * widget's data to it */ if (filename) { if ((outfile = fopen(filename, "w"))) { gtk_color_button_get_color(GTK_COLOR_BUTTON(var->Widget), &color); if (gtk_color_button_get_use_alpha(GTK_COLOR_BUTTON(var->Widget))) { fprintf(outfile, "#%02x%02x%02x|%u", (color.red + 257 / 2) / 257, (color.green + 257 / 2) / 257, (color.blue + 257 / 2) / 257, gtk_color_button_get_alpha(GTK_COLOR_BUTTON(var->Widget))); } else { fprintf(outfile, "#%02x%02x%02x", (color.red + 257 / 2) / 257, (color.green + 257 / 2) / 257, (color.blue + 257 / 2) / 257); } /* Close the file */ fclose(outfile); } else { fprintf(stderr, "%s(): Couldn't open '%s' for writing.\n", __func__, filename); } } else { fprintf(stderr, "%s(): No <output file> directive found.\n", __func__); } #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Exiting.\n", __func__); #endif }
int clip_GTK_COLORBUTTONGETUSEALPHA(ClipMachine * cm) { C_widget *cbtn = _fetch_cw_arg(cm); CHECKCWID(cbtn,GTK_IS_COLOR_BUTTON); _clip_retl(cm, gtk_color_button_get_use_alpha(GTK_COLOR_BUTTON(cbtn->widget))); return 0; err: return 1; }
static void gtk_color_button_get_property (GObject *object, guint param_id, GValue *value, GParamSpec *pspec) { GtkColorButton *button = GTK_COLOR_BUTTON (object); switch (param_id) { case PROP_USE_ALPHA: g_value_set_boolean (value, gtk_color_button_get_use_alpha (button)); break; case PROP_TITLE: g_value_set_string (value, gtk_color_button_get_title (button)); break; case PROP_COLOR: { GdkColor color; GdkRGBA rgba; gtk_color_button_get_rgba (button, &rgba); color.red = (guint16) (rgba.red * 65535 + 0.5); color.green = (guint16) (rgba.green * 65535 + 0.5); color.blue = (guint16) (rgba.blue * 65535 + 0.5); g_value_set_boxed (value, &color); } break; case PROP_ALPHA: g_value_set_uint (value, gtk_color_button_get_alpha (button)); break; case PROP_RGBA: { GdkRGBA rgba; gtk_color_button_get_rgba (button, &rgba); g_value_set_boxed (value, &rgba); } break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; } }
gchar *widget_colorbutton_envvar_construct(GtkWidget *widget) { GdkColor color; gchar envvar[32]; gchar *string; #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Entering.\n", __func__); #endif gtk_color_button_get_color(GTK_COLOR_BUTTON(widget), &color); #ifdef DEBUG_CONTENT fprintf(stderr, "%s(): color.red =#%04x rgb=%02x\n", __func__, color.red, (color.red + 257 / 2) / 257); fprintf(stderr, "%s(): color.green=#%04x rgb=%02x\n", __func__, color.green, (color.green + 257 / 2) / 257); fprintf(stderr, "%s(): color.blue =#%04x rgb=%02x\n", __func__, color.blue, (color.blue + 257 / 2) / 257); #endif if (gtk_color_button_get_use_alpha(GTK_COLOR_BUTTON(widget))) { sprintf(envvar, "#%02x%02x%02x|%u", (color.red + 257 / 2) / 257, (color.green + 257 / 2) / 257, (color.blue + 257 / 2) / 257, gtk_color_button_get_alpha(GTK_COLOR_BUTTON(widget))); } else { sprintf(envvar, "#%02x%02x%02x", (color.red + 257 / 2) / 257, (color.green + 257 / 2) / 257, (color.blue + 257 / 2) / 257); } string = g_strdup(envvar); #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Exiting.\n", __func__); #endif return string; }