[gtk+/refactor: 28/106] Use accessor functions to access GtkColorSelectionDialog
- From: Javier Jardón <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/refactor: 28/106] Use accessor functions to access GtkColorSelectionDialog
- Date: Tue, 13 Jul 2010 17:32:21 +0000 (UTC)
commit f2dd8b5961b84280046614d57f8f75abe54e6eef
Author: Javier Jardón <jjardon gnome org>
Date: Wed Jun 2 04:24:16 2010 +0200
Use accessor functions to access GtkColorSelectionDialog
demos/gtk-demo/colorsel.c | 6 ++++--
docs/tools/widgets.c | 4 +++-
examples/colorsel/colorsel.c | 4 +++-
gtk/gtkcolorbutton.c | 26 ++++++++++++++++++--------
tests/testgtk.c | 14 +++++++++++---
5 files changed, 39 insertions(+), 15 deletions(-)
---
diff --git a/demos/gtk-demo/colorsel.c b/demos/gtk-demo/colorsel.c
index db5d542..b4f5cb9 100644
--- a/demos/gtk-demo/colorsel.c
+++ b/demos/gtk-demo/colorsel.c
@@ -41,13 +41,15 @@ change_color_callback (GtkWidget *button,
{
GtkWidget *dialog;
GtkColorSelection *colorsel;
+ GtkColorSelectionDialog *selection_dialog;
gint response;
dialog = gtk_color_selection_dialog_new ("Changing color");
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
-
- colorsel = GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel);
+
+ selection_dialog = GTK_COLOR_SELECTION_DIALOG (dialog);
+ colorsel = GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_color_selection (selection_dialog));
gtk_color_selection_set_previous_color (colorsel, &color);
gtk_color_selection_set_current_color (colorsel, &color);
diff --git a/docs/tools/widgets.c b/docs/tools/widgets.c
index 226db88..000e232 100644
--- a/docs/tools/widgets.c
+++ b/docs/tools/widgets.c
@@ -612,10 +612,12 @@ create_colorsel (void)
WidgetInfo *info;
GtkWidget *widget;
GtkColorSelection *colorsel;
+ GtkColorSelectionDialog *selection_dialog;
GdkColor color;
widget = gtk_color_selection_dialog_new ("Color Selection Dialog");
- colorsel = GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (widget)->colorsel);
+ selection_dialog = GTK_COLOR_SELECTION_DIALOG (widget);
+ colorsel = GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_color_selection (selection_dialog));
color.red = 0x7979;
color.green = 0xdbdb;
diff --git a/examples/colorsel/colorsel.c b/examples/colorsel/colorsel.c
index 9d3671d..d5eb686 100644
--- a/examples/colorsel/colorsel.c
+++ b/examples/colorsel/colorsel.c
@@ -27,6 +27,7 @@ static gboolean area_event( GtkWidget *widget,
gint handled = FALSE;
gint response;
GtkColorSelection *colorsel;
+ GtkColorSelectionDialog *selection_dialog;
/* Check if we've received a button pressed event */
@@ -39,7 +40,8 @@ static gboolean area_event( GtkWidget *widget,
colorseldlg = gtk_color_selection_dialog_new ("Select background color");
/* Get the ColorSelection widget */
- colorsel = GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (colorseldlg)->colorsel);
+ selection_dialog = GTK_COLOR_SELECTION_DIALOG (colorseldlg);
+ colorsel = GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_colorsel (selection_dialog));
gtk_color_selection_set_previous_color (colorsel, &color);
gtk_color_selection_set_current_color (colorsel, &color);
diff --git a/gtk/gtkcolorbutton.c b/gtk/gtkcolorbutton.c
index 0f4e951..38db50d 100644
--- a/gtk/gtkcolorbutton.c
+++ b/gtk/gtkcolorbutton.c
@@ -653,8 +653,10 @@ dialog_ok_clicked (GtkWidget *widget,
{
GtkColorButton *color_button = GTK_COLOR_BUTTON (data);
GtkColorSelection *color_selection;
+ GtkColorSelectionDialog *selection_dialog;
- color_selection = GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (color_button->priv->cs_dialog)->colorsel);
+ selection_dialog = GTK_COLOR_SELECTION_DIALOG (color_button->priv->cs_dialog);
+ color_selection = GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_color_selection (selection_dialog));
gtk_color_selection_get_current_color (color_selection, &color_button->priv->color);
color_button->priv->alpha = gtk_color_selection_get_current_alpha (color_selection);
@@ -699,6 +701,7 @@ static void
gtk_color_button_clicked (GtkButton *button)
{
GtkColorButton *color_button = GTK_COLOR_BUTTON (button);
+ GtkColorSelection *color_selection;
GtkColorSelectionDialog *color_dialog;
/* if dialog already exists, make sure it's shown and raised */
@@ -706,6 +709,7 @@ gtk_color_button_clicked (GtkButton *button)
{
/* Create the dialog and connects its buttons */
GtkWidget *parent;
+ GtkWidget *ok_button, *cancel_button;
parent = gtk_widget_get_toplevel (GTK_WIDGET (color_button));
@@ -721,28 +725,34 @@ gtk_color_button_clicked (GtkButton *button)
gtk_window_set_modal (GTK_WINDOW (color_dialog),
gtk_window_get_modal (GTK_WINDOW (parent)));
}
+
+ g_object_get (color_dialog,
+ "ok-button", &ok_button,
+ "cancel-button", &cancel_button,
+ NULL);
- g_signal_connect (color_dialog->ok_button, "clicked",
+ g_signal_connect (ok_button, "clicked",
G_CALLBACK (dialog_ok_clicked), color_button);
- g_signal_connect (color_dialog->cancel_button, "clicked",
+ g_signal_connect (cancel_button, "clicked",
G_CALLBACK (dialog_cancel_clicked), color_button);
g_signal_connect (color_dialog, "destroy",
G_CALLBACK (dialog_destroy), color_button);
}
color_dialog = GTK_COLOR_SELECTION_DIALOG (color_button->priv->cs_dialog);
+ color_selection = GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_color_selection (color_dialog));
- gtk_color_selection_set_has_opacity_control (GTK_COLOR_SELECTION (color_dialog->colorsel),
+ gtk_color_selection_set_has_opacity_control (color_selection,
color_button->priv->use_alpha);
- gtk_color_selection_set_previous_color (GTK_COLOR_SELECTION (color_dialog->colorsel),
+ gtk_color_selection_set_previous_color (color_selection,
&color_button->priv->color);
- gtk_color_selection_set_previous_alpha (GTK_COLOR_SELECTION (color_dialog->colorsel),
+ gtk_color_selection_set_previous_alpha (color_selection,
color_button->priv->alpha);
- gtk_color_selection_set_current_color (GTK_COLOR_SELECTION (color_dialog->colorsel),
+ gtk_color_selection_set_current_color (color_selection,
&color_button->priv->color);
- gtk_color_selection_set_current_alpha (GTK_COLOR_SELECTION (color_dialog->colorsel),
+ gtk_color_selection_set_current_alpha (color_selection,
color_button->priv->alpha);
gtk_window_present (GTK_WINDOW (color_button->priv->cs_dialog));
diff --git a/tests/testgtk.c b/tests/testgtk.c
index b6a1b7a..b661be8 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -4137,12 +4137,15 @@ static void
cmw_color (GtkWidget *widget, GtkWidget *parent)
{
GtkWidget *csd;
+ GtkWidget *colorsel;
+ GtkWidget *ok_button, *cancel_button;
csd = gtk_color_selection_dialog_new ("This is a modal color selection dialog");
gtk_window_set_screen (GTK_WINDOW (csd), gtk_widget_get_screen (parent));
- gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (csd)->colorsel),
+ colorsel = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (csd));
+ gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION (colorsel),
TRUE);
/* Set as modal */
@@ -4154,9 +4157,14 @@ cmw_color (GtkWidget *widget, GtkWidget *parent)
g_signal_connect (csd, "destroy",
G_CALLBACK (cmw_destroy_cb), NULL);
- g_signal_connect_swapped (GTK_COLOR_SELECTION_DIALOG (csd)->ok_button,
+ g_object_get (csd,
+ "ok-button", &ok_button,
+ "cancel-button", &cancel_button,
+ NULL);
+
+ g_signal_connect_swapped (ok_button,
"clicked", G_CALLBACK (gtk_widget_destroy), csd);
- g_signal_connect_swapped (GTK_COLOR_SELECTION_DIALOG (csd)->cancel_button,
+ g_signal_connect_swapped (cancel_button,
"clicked", G_CALLBACK (gtk_widget_destroy), csd);
/* wait until destroy calls gtk_main_quit */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]