/* * Gets the properties of the widget. This is used for both displaying the * properties in the property editor, and also for saving the properties. */ static void gb_gnome_color_picker_get_properties (GtkWidget *widget, GbWidgetGetArgData * data) { gb_widget_output_bool (data, Dither, gnome_color_picker_get_dither (GNOME_COLOR_PICKER (widget))); gb_widget_output_bool (data, UseAlpha, gnome_color_picker_get_use_alpha (GNOME_COLOR_PICKER (widget))); gb_widget_output_translatable_string (data, Title, gnome_color_picker_get_title (GNOME_COLOR_PICKER (widget))); gb_widget_output_bool (data, FocusOnClick, gtk_button_get_focus_on_click (GTK_BUTTON (widget))); }
/* * Writes the source code needed to create this widget. * You have to output everything necessary to create the widget here, though * there are some convenience functions to help. */ static void gb_gnome_color_picker_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data) { if (data->create_widget) { source_add (data, " %s = gnome_color_picker_new ();\n", data->wname); } gb_widget_write_standard_source (widget, data); if (strcmp (gnome_color_picker_get_title (GNOME_COLOR_PICKER (widget)), dgettext (GLADE_LIBGNOMEUI_GETTEXT_PACKAGE, "Pick a color"))) { gboolean translatable, context; gchar *comments; glade_util_get_translation_properties (widget, Title, &translatable, &comments, &context); source_add_translator_comments (data, translatable, comments); source_add (data, " gnome_color_picker_set_title (GNOME_COLOR_PICKER (%s), %s);\n", data->wname, source_make_string_full (gnome_color_picker_get_title (GNOME_COLOR_PICKER (widget)), data->use_gettext && translatable, context)); } if (!gnome_color_picker_get_dither (GNOME_COLOR_PICKER (widget))) { source_add (data, " gnome_color_picker_set_dither (GNOME_COLOR_PICKER (%s), FALSE);\n", data->wname); } if (gnome_color_picker_get_use_alpha (GNOME_COLOR_PICKER (widget))) { source_add (data, " gnome_color_picker_set_use_alpha (GNOME_COLOR_PICKER (%s), TRUE);\n", data->wname); } if (!gtk_button_get_focus_on_click (GTK_BUTTON (widget))) { source_add (data, " gtk_button_set_focus_on_click (GTK_BUTTON (%s), FALSE);\n", data->wname); } }
/* Creates a color picker with the specified parameters */ static void create_cp (GtkWidget *table, int dither, int use_alpha, int left, int right, int top, int bottom) { GtkWidget *cp; cp = gnome_color_picker_new (); g_signal_connect (cp, "color_set", G_CALLBACK (color_set), NULL); gnome_color_picker_set_dither (GNOME_COLOR_PICKER (cp), dither); gnome_color_picker_set_use_alpha (GNOME_COLOR_PICKER (cp), use_alpha); gnome_color_picker_set_d (GNOME_COLOR_PICKER (cp), 1.0, 0.0, 1.0, 0.5); gtk_table_attach (GTK_TABLE (table), cp, left, right, top, bottom, 0, 0, 0, 0); gtk_widget_show (cp); }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_gnome_color_picker_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gboolean dither, use_alpha, focus_on_click; gchar *title; dither = gb_widget_input_bool (data, Dither); if (data->apply) gnome_color_picker_set_dither (GNOME_COLOR_PICKER (widget), dither); use_alpha = gb_widget_input_bool (data, UseAlpha); if (data->apply) gnome_color_picker_set_use_alpha (GNOME_COLOR_PICKER (widget), use_alpha); title = gb_widget_input_string (data, Title); if (data->apply) gnome_color_picker_set_title (GNOME_COLOR_PICKER (widget), title); focus_on_click = gb_widget_input_bool (data, FocusOnClick); if (data->apply) gtk_button_set_focus_on_click (GTK_BUTTON (widget), focus_on_click); }
static void cb_history_changed (GOColorPalette *pal) { int i; GdkRGBA gdk; GOColorGroup *group = pal->group; for (i = 0 ; i < GO_COLOR_GROUP_HISTORY_SIZE ; i++) gtk_widget_override_background_color (pal->swatches [i], GTK_STATE_FLAG_NORMAL, go_color_to_gdk_rgba (group->history[i], &gdk)); #if 0 if (next_swatch != NULL) { next_swatch->style->bg[GTK_STATE_NORMAL] = *new_color; gnome_color_picker_set_i16 (GNOME_COLOR_PICKER (pal->picker), new_color->red, new_color->green, new_color->blue, 0); } #endif }