[goffice] Revert "Dead kittens: GtkColorSelDialog -> GtkColorChooser."
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Revert "Dead kittens: GtkColorSelDialog -> GtkColorChooser."
- Date: Mon, 11 Mar 2013 15:23:34 +0000 (UTC)
commit 96cdf581e2d4d3c6231e44b560e0f4251b9a2be5
Author: Morten Welinder <terra gnome org>
Date: Mon Mar 11 11:22:44 2013 -0400
Revert "Dead kittens: GtkColorSelDialog -> GtkColorChooser."
This reverts commit 009d6d67403341a1e9a4769192d394be94b4ef73.
ChangeLog | 4 --
NEWS | 1 -
goffice/gtk/go-color-palette.c | 82 +++++++++++++-------------------------
goffice/gtk/go-color-selector.c | 83 +++++++++++++++------------------------
4 files changed, 61 insertions(+), 109 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3c912ca..8636da2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,5 @@
2013-03-10 Morten Welinder <terra gnome org>
- * goffice/gtk/go-color-palette.c: Avoid GtkColorSelDialog which is
- _gone_ from current gtk+. Use GtkColorChooserWidget instead.
- * goffice/gtk/go-color-selector.c: Ditto.
-
* goffice/math/go-regression.c: Bring a blunt clue bat to the
attention of gtk-doc.
* goffice/math/go-cspline.c: ditto.
diff --git a/NEWS b/NEWS
index e850b97..fe8429d 100644
--- a/NEWS
+++ b/NEWS
@@ -3,7 +3,6 @@ goffice 0.10.2:
Morten:
* Fix problems with cspline boxed type. [#695550]
* Fix gtk-doc problems --without-long-double. [#695550]
- * Switch from GtkColorSelDialog to GtkColorChooser.
--------------------------------------------------------------------------
goffice 0.10.1:
diff --git a/goffice/gtk/go-color-palette.c b/goffice/gtk/go-color-palette.c
index 5d9b7e3..b143b2d 100644
--- a/goffice/gtk/go-color-palette.c
+++ b/goffice/gtk/go-color-palette.c
@@ -48,7 +48,7 @@ struct _GOColorPalette {
gboolean allow_alpha;
/* only for custom colours */
- GtkWidget *swatches[GO_COLOR_GROUP_HISTORY_SIZE];
+ GtkWidget *swatches [GO_COLOR_GROUP_HISTORY_SIZE];
/* The table with our default color names */
GONamedColor const *default_set;
@@ -66,15 +66,13 @@ typedef struct {
#define COLOR_PREVIEW_WIDTH 12
#define COLOR_PREVIEW_HEIGHT 12
-#define CCW_KEY "GOColorPalette::ccw"
-
enum {
COLOR_CHANGED,
DISPLAY_CUSTOM_DIALOG,
LAST_SIGNAL
};
-GONamedColor const _default_color_set[] = {
+GONamedColor const default_color_set [] = {
{ GO_COLOR_FROM_RGBA (0x00, 0x00, 0x00, 0xff), N_("black")},
{ GO_COLOR_FROM_RGBA (0x99, 0x33, 0x00, 0xff), N_("light brown")},
{ GO_COLOR_FROM_RGBA (0x33, 0x33, 0x00, 0xff), N_("brown gold")},
@@ -149,52 +147,36 @@ static guint go_color_palette_signals [LAST_SIGNAL] = { 0, };
static GObjectClass *go_color_palette_parent_class;
static GtkWidget *
-create_color_sel (GtkWidget *parent_widget, GObject *action_proxy,
- GOColor c, GCallback handler, gboolean allow_alpha)
-{
- const char *title =
- g_object_get_data (G_OBJECT (action_proxy), "title");
- GtkWidget *toplevel = gtk_widget_get_toplevel (parent_widget);
- GtkWidget *dialog = gtk_dialog_new_with_buttons
- (title,
- (gtk_widget_is_toplevel (toplevel)
- ? GTK_WINDOW (toplevel)
- : NULL),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- NULL);
- GtkWidget *ccw = gtk_color_chooser_widget_new ();
- GtkWidget *dca = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+create_color_sel (GObject *action_proxy, GOColor c, GCallback handler, gboolean allow_alpha)
+{
+ char *title = g_object_get_data (G_OBJECT (action_proxy), "title");
+ GtkWidget *w = gtk_color_selection_dialog_new (title), *hb;
+ GtkColorSelectionDialog *dialog = GTK_COLOR_SELECTION_DIALOG (w);
+ GtkColorSelection *colorsel = GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_color_selection
(dialog));
GdkRGBA gdk;
- g_object_set_data (G_OBJECT (dialog), CCW_KEY, ccw);
-
- gtk_container_add (GTK_CONTAINER (dca), ccw);
-
- go_color_to_gdk_rgba (c, &gdk);
-
- g_object_set (G_OBJECT (ccw),
- "use-alpha", allow_alpha,
- "rgba", &gdk,
- "show-editor", TRUE,
- NULL);
+ g_object_get (G_OBJECT (w), "help-button", &hb, NULL);
+ gtk_widget_hide (hb);
+ gtk_color_selection_set_has_opacity_control (colorsel, allow_alpha);
+ gtk_color_selection_set_current_rgba (colorsel,
+ go_color_to_gdk_rgba (c, &gdk));
g_signal_connect_object (dialog,
"response", handler, action_proxy, 0);
/* require an explicit show _after_ the custom-dialog signal fires */
- return dialog;
+ return w;
}
static gboolean
-handle_color_sel (GtkDialog *dialog,
+handle_color_sel (GtkColorSelectionDialog *dialog,
gint response_id, GOColor *res)
{
if (response_id == GTK_RESPONSE_OK) {
- GtkColorChooser *chooser = g_object_get_data (G_OBJECT (dialog), CCW_KEY);
GdkRGBA gdk;
- gtk_color_chooser_get_rgba (chooser, &gdk);
+ GtkColorSelection *colorsel = GTK_COLOR_SELECTION
(gtk_color_selection_dialog_get_color_selection (dialog));
+
+ gtk_color_selection_get_current_rgba (colorsel, &gdk);
*res = GO_COLOR_FROM_GDK_RGBA (gdk);
}
/* destroy _before_ we emit */
@@ -395,7 +377,7 @@ go_color_palette_button_new (GOColorPalette *pal, GtkGrid *grid,
}
static void
-cb_combo_custom_response (GtkDialog *dialog,
+cb_combo_custom_response (GtkColorSelectionDialog *dialog,
gint response_id, GOColorPalette *pal)
{
GOColor c;
@@ -406,14 +388,11 @@ cb_combo_custom_response (GtkDialog *dialog,
static void
cb_combo_custom_clicked (GtkWidget *button, GOColorPalette *pal)
{
- GtkWidget *dialog = create_color_sel
- (button,
- G_OBJECT (pal), pal->selection,
- G_CALLBACK (cb_combo_custom_response),
- pal->allow_alpha);
+ GtkWidget *dialog = create_color_sel (G_OBJECT (pal), pal->selection,
+ G_CALLBACK (cb_combo_custom_response), pal->allow_alpha);
g_signal_emit (pal, go_color_palette_signals [DISPLAY_CUSTOM_DIALOG], 0,
dialog);
- gtk_widget_show_all (dialog);
+ gtk_widget_show (dialog);
}
void
@@ -551,7 +530,7 @@ go_color_palette_new (char const *no_color_label,
GOColorPalette *pal;
int const cols = 8;
int const rows = 6;
- GONamedColor const *color_names = _default_color_set;
+ GONamedColor const *color_names = default_color_set;
pal = g_object_new (GO_TYPE_COLOR_PALETTE, NULL);
@@ -665,7 +644,7 @@ cb_menu_color_activate (GtkWidget *button, GOMenuColor *menu)
color, FALSE, TRUE, FALSE);
}
static void
-cb_menu_custom_response (GtkDialog *dialog,
+cb_menu_custom_response (GtkColorSelectionDialog *dialog,
gint response_id, GOMenuColor *menu)
{
GOColor c;
@@ -679,14 +658,11 @@ cb_menu_custom_response (GtkDialog *dialog,
static void
cb_menu_custom_activate (GtkWidget *button, GOMenuColor *menu)
{
- GtkWidget *dialog = create_color_sel
- (button,
- G_OBJECT (menu), menu->selection,
- G_CALLBACK (cb_menu_custom_response),
- menu->allow_alpha);
- g_signal_emit (menu, go_menu_color_signals[DISPLAY_CUSTOM_DIALOG], 0,
+ GtkWidget *dialog = create_color_sel (G_OBJECT (menu), menu->selection,
+ G_CALLBACK (cb_menu_custom_response), menu->allow_alpha);
+ g_signal_emit (menu, go_menu_color_signals [DISPLAY_CUSTOM_DIALOG], 0,
dialog);
- gtk_widget_show_all (dialog);
+ gtk_widget_show (dialog);
}
/**
@@ -710,7 +686,7 @@ go_color_palette_make_menu (char const *no_color_label,
int cols = 8;
int rows = 6;
int col, row, pos, table_row = 0;
- GONamedColor const *color_names = _default_color_set;
+ GONamedColor const *color_names = default_color_set;
GtkWidget *w, *submenu;
submenu = g_object_new (go_menu_color_get_type (), NULL);
diff --git a/goffice/gtk/go-color-selector.c b/goffice/gtk/go-color-selector.c
index 93adb24..3951d0b 100644
--- a/goffice/gtk/go-color-selector.c
+++ b/goffice/gtk/go-color-selector.c
@@ -29,10 +29,7 @@
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
-#define COLOR_DIALOG_KEY "GOColorSelector::color-dialog"
-#define CCW_KEY "GOColorSelector::ccw"
-
-extern GONamedColor _default_color_set[];
+extern GONamedColor default_color_set [];
typedef struct {
int n_swatches;
@@ -56,8 +53,8 @@ get_index (int n_swatches, GOColorGroup *color_group, GOColor color)
int i = 0;
int index = -1;
- while (_default_color_set[i].name != NULL) {
- if (_default_color_set[i].color == color && index < 0) {
+ while (default_color_set[i].name != NULL) {
+ if (default_color_set[i].color == color && index < 0) {
index = i;
continue;
}
@@ -83,7 +80,7 @@ get_color (int n_swatches, GOColorGroup *color_group, int index)
index = 0;
if (index < n_swatches - GO_COLOR_GROUP_HISTORY_SIZE)
- return _default_color_set[index].color;
+ return default_color_set[index].color;
else
return color_group->history[index - (n_swatches - GO_COLOR_GROUP_HISTORY_SIZE)];
}
@@ -153,18 +150,20 @@ go_color_palette_render_func (cairo_t *cr,
}
static void
-cb_color_dialog_response (GtkDialog *color_dialog,
+cb_color_dialog_response (GtkColorSelectionDialog *color_dialog,
gint response,
GOSelector *selector)
{
- GtkColorChooser *chooser =
- g_object_get_data (G_OBJECT (color_dialog), CCW_KEY);
+ GtkWidget *color_selection;
+
+ color_selection = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG
(color_dialog));
if (response == GTK_RESPONSE_OK) {
GdkRGBA gdk_color;
GOColor color;
- gtk_color_chooser_get_rgba (chooser, &gdk_color);
+ gtk_color_selection_get_current_rgba (GTK_COLOR_SELECTION (color_selection),
+ &gdk_color);
color = GO_COLOR_FROM_GDK_RGBA (gdk_color);
if (!go_color_selector_set_color (selector, color))
@@ -172,59 +171,41 @@ cb_color_dialog_response (GtkDialog *color_dialog,
go_selector_activate (selector);
}
- g_object_set_data (G_OBJECT (selector), COLOR_DIALOG_KEY, NULL);
+ g_object_set_data (G_OBJECT (selector), "color-dialog", NULL);
}
static void
cb_combo_custom_activate (GOPalette *palette, GOSelector *selector)
{
GtkWidget *color_dialog;
- GtkWidget *ccw, *dca;
+ GtkWidget *color_selection;
GdkRGBA gdk_color;
+ GOColor color;
GOColorSelectorState *state = go_selector_get_user_data (selector);
- GOColor color = go_color_selector_get_color (selector, NULL);
- GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (selector));
-
- go_color_to_gdk_rgba (color, &gdk_color);
- color_dialog = g_object_get_data (G_OBJECT (selector), COLOR_DIALOG_KEY);
+ color_dialog = g_object_get_data (G_OBJECT (selector), "color-dialog");
if (color_dialog != NULL) {
- GtkColorChooser *chooser =
- g_object_get_data (G_OBJECT (color_dialog), CCW_KEY);
- gtk_color_chooser_set_rgba (chooser, &gdk_color);
+ color_selection = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG
(color_dialog));
+ color = go_color_selector_get_color (selector, NULL);
+ gtk_color_selection_set_current_rgba (GTK_COLOR_SELECTION (color_selection),
+ go_color_to_gdk_rgba (color, &gdk_color));
gtk_window_present (GTK_WINDOW (color_dialog));
return;
}
- color_dialog = gtk_dialog_new_with_buttons
- (_("Custom color..."),
- (gtk_widget_is_toplevel (toplevel)
- ? GTK_WINDOW (toplevel)
- : NULL),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- NULL);
- ccw = gtk_color_chooser_widget_new ();
- g_object_set_data (G_OBJECT (color_dialog), CCW_KEY, ccw);
- dca = gtk_dialog_get_content_area (GTK_DIALOG (color_dialog));
- gtk_container_add (GTK_CONTAINER (dca), ccw);
-
- g_object_set (G_OBJECT (ccw),
- "use-alpha", state->allow_alpha,
- "rgba", &gdk_color,
- "show-editor", TRUE,
- NULL);
-
- g_object_set_data_full (G_OBJECT (selector),
- COLOR_DIALOG_KEY, color_dialog,
- (GDestroyNotify)gtk_widget_destroy);
-
- g_signal_connect (color_dialog,
- "response", G_CALLBACK (cb_color_dialog_response),
- selector);
-
- gtk_widget_show_all (color_dialog);
+ color_dialog = gtk_color_selection_dialog_new (_("Custom color..."));
+ color_selection = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG
(color_dialog));
+ gtk_color_selection_set_has_opacity_control (GTK_COLOR_SELECTION (color_selection),
state->allow_alpha);
+ g_object_set_data_full (G_OBJECT (selector), "color-dialog", color_dialog,
+ (GDestroyNotify) gtk_widget_destroy);
+ color = go_color_selector_get_color (selector, NULL);
+ gtk_color_selection_set_current_rgba (GTK_COLOR_SELECTION (color_selection),
+ go_color_to_gdk_rgba (color, &gdk_color));
+ if (state->allow_alpha)
+ gtk_color_selection_set_current_alpha (GTK_COLOR_SELECTION (color_selection),
+ GO_COLOR_UINT_A (color) * 257);
+ g_signal_connect (color_dialog, "response", G_CALLBACK (cb_color_dialog_response), selector);
+ gtk_widget_show (color_dialog);
}
static void
@@ -306,7 +287,7 @@ go_selector_new_color (GOColor initial_color,
state->default_color = default_color;
state->allow_alpha = TRUE;
- while (_default_color_set[count].name != NULL) count ++;
+ while (default_color_set[count].name != NULL) count ++;
state->n_swatches = count + GO_COLOR_GROUP_HISTORY_SIZE;
state->color_group = go_color_group_fetch (group, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]