]> Pileus Git - ~andy/gtk/commitdiff
Create a private header to access some GtkButton variables
authorJavier Jardón <jjardon@gnome.org>
Tue, 19 Oct 2010 00:01:31 +0000 (02:01 +0200)
committerJavier Jardón <jjardon@gnome.org>
Fri, 19 Nov 2010 05:15:26 +0000 (06:15 +0100)
gtk/Makefile.am
gtk/gtkbutton.c
gtk/gtkbuttonprivate.h [new file with mode: 0644]
gtk/gtkcheckbutton.c
gtk/gtkradiobutton.c
gtk/gtktogglebutton.c

index 36c02ce09c89b6caac86bb7312ec632ba17d5c86..dae90cdc61d77b1cd5feca176b688fe1e588e741 100644 (file)
@@ -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 \
index c341ccb0ad845bc18d7d9eb4779463dc0bcbf025..8fd97ad2e58a77ec4dc5bbaf4e1bb62bfde8233b 100644 (file)
  */
 
 #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"
 #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 (file)
index 0000000..b6007cd
--- /dev/null
@@ -0,0 +1,55 @@
+/* GTK - The GIMP Toolkit
+ *
+ * Copyright (C) 2010 Javier Jardón
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#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__ */
index 9a9b3441f91b86283b15ead3e9e9c7cea2e89118..f07ecf1282eeb78d9f3fa4a2ba3250a230d53b97 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "gtkcheckbutton.h"
 
+#include "gtkbuttonprivate.h"
 #include "gtklabel.h"
 
 #include "gtkprivate.h"
@@ -452,9 +453,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;
index b412044eb225e5f8fa0b7d44b058f5a0d05c4743..e22adf68a7ee19f875fa736edfb35b036831ede8 100644 (file)
  */
 
 #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_set_active (GTK_TOGGLE_BUTTON (radio_button), 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);
 
@@ -814,14 +817,14 @@ 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;
           _gtk_toggle_button_set_active (toggle_button,
                                          !gtk_toggle_button_get_active (toggle_button));
-         new_state = (button->in_button ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL);
+         new_state = (button->priv->in_button ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL);
        }
     }
   else
@@ -843,12 +846,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 (gtk_toggle_button_get_inconsistent (toggle_button))
     depressed = FALSE;
-  else if (button->in_button && button->button_down)
+  else if (button->priv->in_button && button->priv->button_down)
     depressed = !gtk_toggle_button_get_active (toggle_button);
   else
     depressed = gtk_toggle_button_get_active (toggle_button);
@@ -923,9 +926,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;
index a60ffebae3fd789a13ec6d821d3fa84edbad2e32..a4979b3fa47bf3ae6ea96dff44c2c0f0092e7f17 100644 (file)
  */
 
 #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"
@@ -164,7 +167,7 @@ gtk_toggle_button_init (GtkToggleButton *toggle_button)
 
   priv->active = FALSE;
   priv->draw_indicator = FALSE;
-  GTK_BUTTON (toggle_button)->depress_on_activate = TRUE;
+  GTK_BUTTON (toggle_button)->priv->depress_on_activate = TRUE;
 }
 
 static void
@@ -327,8 +330,8 @@ gtk_toggle_button_set_mode (GtkToggleButton *toggle_button,
   if (priv->draw_indicator != draw_indicator)
     {
       priv->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));
 
@@ -468,7 +471,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),
@@ -503,7 +506,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));
@@ -512,11 +515,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);
@@ -556,12 +559,12 @@ gtk_toggle_button_update_state (GtkButton *button)
 
   if (priv->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 = priv->active;
 
-  if (!touchscreen && button->in_button && (!button->button_down || priv->draw_indicator))
+  if (!touchscreen && button->priv->in_button && (!button->priv->button_down || priv->draw_indicator))
     new_state = GTK_STATE_PRELIGHT;
   else
     new_state = depressed ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL;