[gtk+/refactor: 3/3] Create a private header to access some GtkButton variables
- From: Javier Jardón <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/refactor: 3/3] Create a private header to access some GtkButton variables
- Date: Tue, 19 Oct 2010 01:47:32 +0000 (UTC)
commit 3774dda4d5e29c4be2c3edd4dc7cfbae56419d04
Author: Javier Jardón <jjardon gnome org>
Date: Tue Oct 19 02:01:31 2010 +0200
Create a private header to access some GtkButton variables
gtk/Makefile.am | 1 +
gtk/gtkbutton.c | 37 ++++---------------------------------
gtk/gtkbuttonprivate.h | 38 ++++++++++++++++++++++++++++++++++++++
gtk/gtkcheckbutton.c | 7 ++++---
gtk/gtkradiobutton.c | 19 +++++++++++--------
gtk/gtktogglebutton.c | 25 ++++++++++++++-----------
6 files changed, 72 insertions(+), 55 deletions(-)
---
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 4943fb5..a73f75f 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -351,6 +351,7 @@ gtk_semi_private_h_sources = \
# GTK+ header files that don't get installed
gtk_private_h_sources = \
+ gtkbuttonprivate.h \
gtkquery.h \
gtksearchengine.h \
gtksearchenginesimple.h \
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 330515f..5012571 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -39,9 +39,12 @@
*/
#include "config.h"
+
+#include "gtkbutton.h"
+#include "gtkbuttonprivate.h"
+
#include <string.h>
#include "gtkalignment.h"
-#include "gtkbutton.h"
#include "gtklabel.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
@@ -56,38 +59,6 @@
#include "gtkintl.h"
-struct _GtkButtonPrivate
-{
- GtkAction *action;
- GtkPositionType image_position;
- GtkWidget *image;
-
- GdkDevice *grab_keyboard;
- GdkWindow *event_window;
-
- gchar *label_text;
-
- gfloat xalign;
- gfloat yalign;
-
- guint activate_timeout;
- guint32 grab_time;
-
- guint align_set : 1;
- guint button_down : 1;
- guint constructed : 1;
- guint depressed : 1;
- guint depress_on_activate : 1;
- guint focus_on_click : 1;
- guint image_is_stock : 1;
- guint in_button : 1;
- guint relief : 2;
- guint use_action_appearance : 1;
- guint use_stock : 1;
- guint use_underline : 1;
-};
-
-
static const GtkBorder default_default_border = { 1, 1, 1, 1 };
static const GtkBorder default_default_outside_border = { 0, 0, 0, 0 };
static const GtkBorder default_inner_border = { 1, 1, 1, 1 };
diff --git a/gtk/gtkbuttonprivate.h b/gtk/gtkbuttonprivate.h
new file mode 100644
index 0000000..38fa337
--- /dev/null
+++ b/gtk/gtkbuttonprivate.h
@@ -0,0 +1,38 @@
+
+#ifndef __GTK_BUTTON_PRIVATE_H__
+#define __GTK_BUTTON_PRIVATE_H__
+
+#include "gtkaction.h"
+
+struct _GtkButtonPrivate
+{
+ GtkAction *action;
+ GtkPositionType image_position;
+ GtkWidget *image;
+
+ GdkDevice *grab_keyboard;
+ GdkWindow *event_window;
+
+ gchar *label_text;
+
+ gfloat xalign;
+ gfloat yalign;
+
+ guint activate_timeout;
+ guint32 grab_time;
+
+ guint align_set : 1;
+ guint button_down : 1;
+ guint constructed : 1;
+ guint depressed : 1;
+ guint depress_on_activate : 1;
+ guint focus_on_click : 1;
+ guint image_is_stock : 1;
+ guint in_button : 1;
+ guint relief : 2;
+ guint use_action_appearance : 1;
+ guint use_stock : 1;
+ guint use_underline : 1;
+};
+
+#endif /* __GTK_BUTTON_PRIVATE_H__ */
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index a54c9ae..4135a87 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -28,6 +28,7 @@
#include "gtkcheckbutton.h"
+#include "gtkbuttonprivate.h"
#include "gtklabel.h"
#include "gtkprivate.h"
@@ -90,7 +91,7 @@ gtk_check_button_init (GtkCheckButton *check_button)
gtk_widget_set_has_window (GTK_WIDGET (check_button), FALSE);
gtk_widget_set_receives_default (GTK_WIDGET (check_button), FALSE);
GTK_TOGGLE_BUTTON (check_button)->draw_indicator = TRUE;
- GTK_BUTTON (check_button)->depress_on_activate = FALSE;
+ GTK_BUTTON (check_button)->priv->depress_on_activate = FALSE;
}
GtkWidget*
@@ -402,9 +403,9 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
else
shadow_type = GTK_SHADOW_OUT;
- if (button->activate_timeout || (button->button_down && button->in_button))
+ if (button->priv->activate_timeout || (button->priv->button_down && button->priv->in_button))
state_type = GTK_STATE_ACTIVE;
- else if (button->in_button)
+ else if (button->priv->in_button)
state_type = GTK_STATE_PRELIGHT;
else if (!gtk_widget_is_sensitive (widget))
state_type = GTK_STATE_INSENSITIVE;
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c
index d760d4f..00c8fc9 100644
--- a/gtk/gtkradiobutton.c
+++ b/gtk/gtkradiobutton.c
@@ -25,9 +25,12 @@
*/
#include "config.h"
+
+#include "gtkradiobutton.h"
+
+#include "gtkbuttonprivate.h"
#include "gtklabel.h"
#include "gtkmarshalers.h"
-#include "gtkradiobutton.h"
#include "gtkprivate.h"
#include "gtkintl.h"
@@ -209,7 +212,7 @@ gtk_radio_button_init (GtkRadioButton *radio_button)
GTK_TOGGLE_BUTTON (radio_button)->active = TRUE;
- GTK_BUTTON (radio_button)->depress_on_activate = FALSE;
+ GTK_BUTTON (radio_button)->priv->depress_on_activate = FALSE;
priv->group = g_slist_prepend (NULL, radio_button);
@@ -813,13 +816,13 @@ gtk_radio_button_clicked (GtkButton *button)
if (!tmp_button)
{
- new_state = (button->in_button ? GTK_STATE_PRELIGHT : GTK_STATE_ACTIVE);
+ new_state = (button->priv->in_button ? GTK_STATE_PRELIGHT : GTK_STATE_ACTIVE);
}
else
{
toggled = TRUE;
toggle_button->active = !toggle_button->active;
- new_state = (button->in_button ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL);
+ new_state = (button->priv->in_button ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL);
}
}
else
@@ -840,12 +843,12 @@ gtk_radio_button_clicked (GtkButton *button)
}
}
- new_state = (button->in_button ? GTK_STATE_PRELIGHT : GTK_STATE_ACTIVE);
+ new_state = (button->priv->in_button ? GTK_STATE_PRELIGHT : GTK_STATE_ACTIVE);
}
if (toggle_button->inconsistent)
depressed = FALSE;
- else if (button->in_button && button->button_down)
+ else if (button->priv->in_button && button->priv->button_down)
depressed = !toggle_button->active;
else
depressed = toggle_button->active;
@@ -920,9 +923,9 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
else
shadow_type = GTK_SHADOW_OUT;
- if (button->activate_timeout || (button->button_down && button->in_button))
+ if (button->priv->activate_timeout || (button->priv->button_down && button->priv->in_button))
state_type = GTK_STATE_ACTIVE;
- else if (button->in_button)
+ else if (button->priv->in_button)
state_type = GTK_STATE_PRELIGHT;
else if (!gtk_widget_is_sensitive (widget))
state_type = GTK_STATE_INSENSITIVE;
diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c
index e1a3c16..c44d65a 100644
--- a/gtk/gtktogglebutton.c
+++ b/gtk/gtktogglebutton.c
@@ -25,10 +25,13 @@
*/
#include "config.h"
+
+#include "gtktogglebutton.h"
+
+#include "gtkbuttonprivate.h"
#include "gtklabel.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
-#include "gtktogglebutton.h"
#include "gtktoggleaction.h"
#include "gtkactivatable.h"
#include "gtkprivate.h"
@@ -148,7 +151,7 @@ gtk_toggle_button_init (GtkToggleButton *toggle_button)
{
toggle_button->active = FALSE;
toggle_button->draw_indicator = FALSE;
- GTK_BUTTON (toggle_button)->depress_on_activate = TRUE;
+ GTK_BUTTON (toggle_button)->priv->depress_on_activate = TRUE;
}
static void
@@ -308,8 +311,8 @@ gtk_toggle_button_set_mode (GtkToggleButton *toggle_button,
if (toggle_button->draw_indicator != draw_indicator)
{
toggle_button->draw_indicator = draw_indicator;
- GTK_BUTTON (toggle_button)->depress_on_activate = !draw_indicator;
-
+ GTK_BUTTON (toggle_button)->priv->depress_on_activate = !draw_indicator;
+
if (gtk_widget_get_visible (GTK_WIDGET (toggle_button)))
gtk_widget_queue_resize (GTK_WIDGET (toggle_button));
@@ -433,7 +436,7 @@ gtk_toggle_button_draw (GtkWidget *widget,
shadow_type = GTK_SHADOW_ETCHED_IN;
}
else
- shadow_type = button->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
+ shadow_type = button->priv->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
_gtk_button_paint (button, cr,
gtk_widget_get_allocated_width (widget),
@@ -468,7 +471,7 @@ gtk_toggle_button_mnemonic_activate (GtkWidget *widget,
static void
gtk_toggle_button_pressed (GtkButton *button)
{
- button->button_down = TRUE;
+ button->priv->button_down = TRUE;
gtk_toggle_button_update_state (button);
gtk_widget_queue_draw (GTK_WIDGET (button));
@@ -477,11 +480,11 @@ gtk_toggle_button_pressed (GtkButton *button)
static void
gtk_toggle_button_released (GtkButton *button)
{
- if (button->button_down)
+ if (button->priv->button_down)
{
- button->button_down = FALSE;
+ button->priv->button_down = FALSE;
- if (button->in_button)
+ if (button->priv->in_button)
gtk_button_clicked (button);
gtk_toggle_button_update_state (button);
@@ -518,12 +521,12 @@ gtk_toggle_button_update_state (GtkButton *button)
if (toggle_button->inconsistent)
depressed = FALSE;
- else if (button->in_button && button->button_down)
+ else if (button->priv->in_button && button->priv->button_down)
depressed = TRUE;
else
depressed = toggle_button->active;
- if (!touchscreen && button->in_button && (!button->button_down || toggle_button->draw_indicator))
+ if (!touchscreen && button->priv->in_button && (!button->priv->button_down || toggle_button->draw_indicator))
new_state = GTK_STATE_PRELIGHT;
else
new_state = depressed ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]