[dia] [gtk-deprecated] use accessors for GtkColorSelectionDialog
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] [gtk-deprecated] use accessors for GtkColorSelectionDialog
- Date: Sun, 2 Sep 2012 18:08:57 +0000 (UTC)
commit 5e8bc2a50e47bb3cfd2847277e4ce9d9b66d3bd7
Author: Hans Breuer <hans breuer org>
Date: Sun Aug 26 22:39:35 2012 +0200
[gtk-deprecated] use accessors for GtkColorSelectionDialog
app/color_area.c | 83 +++++++++++++++++++++++-------------------------
lib/diacolorselector.c | 28 ++++++++++------
2 files changed, 57 insertions(+), 54 deletions(-)
---
diff --git a/app/color_area.c b/app/color_area.c
index a4de1fe..4d2471a 100644
--- a/app/color_area.c
+++ b/app/color_area.c
@@ -306,6 +306,8 @@ color_area_edit (void)
Color col;
GtkWidget *window;
GdkColor color;
+ GtkColorSelectionDialog *csd;
+ GtkColorSelection *colorsel;
if (!color_select_active) {
stored_foreground = attributes_get_foreground();
@@ -320,71 +322,67 @@ color_area_edit (void)
edit_color = BACKGROUND;
}
- if (! color_select) {
+ if (color_select) {
+ window = color_select;
+ csd = GTK_COLOR_SELECTION_DIALOG (window);
+ colorsel = GTK_COLOR_SELECTION (
+ gtk_color_selection_dialog_get_color_selection (csd));
+
+ gtk_window_set_title(GTK_WINDOW(color_select),
+ edit_color==FOREGROUND?
+ _("Select foreground color"):
+ _("Select background color"));
+ if (! color_select_active) {
+ gtk_widget_show (color_select);
+ }
+ } else {
+ GtkButton *button;
+
window = color_select =
gtk_color_selection_dialog_new(edit_color==FOREGROUND?
_("Select foreground color"):
_("Select background color"));
+ csd = GTK_COLOR_SELECTION_DIALOG (window);
+ colorsel = GTK_COLOR_SELECTION (
+ gtk_color_selection_dialog_get_color_selection (csd));
+
color_select_active = 1;
- gtk_color_selection_set_has_opacity_control(
- GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (window)->colorsel),
- TRUE);
+ gtk_color_selection_set_has_opacity_control (colorsel, TRUE);
- gtk_color_selection_set_has_palette (
- GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_color_selection (
- GTK_COLOR_SELECTION_DIALOG (window))),
- TRUE);
+ gtk_color_selection_set_has_palette (colorsel, TRUE);
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
g_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK(color_selection_delete),
- window);
+ window);
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK(color_selection_destroy),
window);
- g_signal_connect (
- G_OBJECT (gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (window))),
- "color_changed",
- G_CALLBACK(color_selection_changed),
- window);
-
- g_signal_connect (
- G_OBJECT (GTK_COLOR_SELECTION_DIALOG (window)->ok_button),
- "clicked",
- G_CALLBACK(color_selection_ok),
- window);
+ g_signal_connect (G_OBJECT (colorsel),
+ "color_changed",
+ G_CALLBACK(color_selection_changed),
+ window);
- g_signal_connect (
- G_OBJECT (GTK_COLOR_SELECTION_DIALOG (window)->cancel_button),
- "clicked",
- G_CALLBACK(color_selection_cancel),
- window);
+ g_object_get (G_OBJECT (window), "ok-button", &button, NULL);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK(color_selection_ok),
+ window);
+ g_object_get (G_OBJECT (window), "cancel-button", &button, NULL);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK(color_selection_cancel),
+ window);
/* Make sure window is shown before setting its colors: */
- gtk_widget_show_now (color_select);
-
- } else {
- gtk_window_set_title(GTK_WINDOW(color_select),
- edit_color==FOREGROUND?
- _("Select foreground color"):
- _("Select background color"));
- if (! color_select_active) {
- gtk_widget_show (color_select);
- }
+ gtk_widget_show_now (color_select);
}
DIA_COLOR_TO_GDK(col, color);
- gtk_color_selection_set_current_color(
- GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_color_selection (
- GTK_COLOR_SELECTION_DIALOG (color_select))),
- &color);
- gtk_color_selection_set_current_alpha(
- GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (color_select)->colorsel),
- (guint)(col.alpha * 65535.0));
+ gtk_color_selection_set_current_color(colorsel, &color);
+ gtk_color_selection_set_current_alpha(colorsel, (guint)(col.alpha * 65535.0));
}
static gint
@@ -494,4 +492,3 @@ color_area_create (int width,
gtk_container_add(GTK_CONTAINER(event_box), color_area);
return event_box;
}
-
diff --git a/lib/diacolorselector.c b/lib/diacolorselector.c
index 6b979ae..791bde3 100644
--- a/lib/diacolorselector.c
+++ b/lib/diacolorselector.c
@@ -179,15 +179,14 @@ dia_color_selector_more_ok(GtkWidget *ok, gpointer userdata)
GdkColor gcol;
guint galpha;
gchar *entry;
+ GtkWidget *cs2 = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG(colorsel));
gtk_color_selection_get_current_color(
- GTK_COLOR_SELECTION(
- GTK_COLOR_SELECTION_DIALOG(colorsel)->colorsel),
+ GTK_COLOR_SELECTION(cs2),
&gcol);
galpha = gtk_color_selection_get_current_alpha(
- GTK_COLOR_SELECTION(
- GTK_COLOR_SELECTION_DIALOG(colorsel)->colorsel));
+ GTK_COLOR_SELECTION(cs2));
entry = g_strdup_printf("#%02X%02X%02X", gcol.red/256, gcol.green/256, gcol.blue/256);
dia_dynamic_menu_select_entry(cs->ddm, entry);
@@ -204,8 +203,9 @@ dia_color_selector_more_callback(GtkWidget *widget, gpointer userdata)
{
GtkColorSelectionDialog *dialog = GTK_COLOR_SELECTION_DIALOG (gtk_color_selection_dialog_new(_("Select color")));
DiaColorSelector *cs = DIACOLORSELECTOR(userdata);
- GtkColorSelection *colorsel = GTK_COLOR_SELECTION(dialog->colorsel);
+ GtkColorSelection *colorsel = GTK_COLOR_SELECTION(gtk_color_selection_dialog_get_color_selection (dialog));
GString *palette = g_string_new ("");
+ GtkWidget *button;
gchar *old_color = dia_dynamic_menu_get_entry(cs->ddm);
GtkWidget *parent;
@@ -269,13 +269,18 @@ dia_color_selector_more_callback(GtkWidget *widget, gpointer userdata)
gtk_color_selection_set_has_palette (colorsel, TRUE);
g_string_free (palette, TRUE);
g_free(old_color);
-
- gtk_widget_hide(dialog->help_button);
-
- g_signal_connect (G_OBJECT (dialog->ok_button), "clicked",
- G_CALLBACK (dia_color_selector_more_ok), dialog);
- g_signal_connect_swapped (G_OBJECT (dialog->cancel_button), "clicked",
+
+ g_object_get (G_OBJECT (dialog), "help-button", &button, NULL);
+ gtk_widget_hide(button);
+
+ g_object_get (G_OBJECT (dialog), "ok-button", &button, NULL);
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (dia_color_selector_more_ok), dialog);
+
+ g_object_get (G_OBJECT (dialog), "ok-button", &button, NULL);
+ g_signal_connect_swapped (G_OBJECT (button), "clicked",
G_CALLBACK(gtk_widget_destroy), G_OBJECT(dialog));
+
g_object_set_data(G_OBJECT(dialog), "dia-cs", cs);
gtk_widget_show(GTK_WIDGET(dialog));
@@ -302,6 +307,7 @@ dia_color_selector_menu_new (DiaColorSelector *cs)
g_signal_connect(G_OBJECT(otheritem), "activate",
G_CALLBACK(dia_color_selector_more_callback), cs);
gtk_widget_show(otheritem);
+
return ddm;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]