]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkradioaction.c
entrycompletion: Don't reconnect signals all the time
[~andy/gtk] / gtk / gtkradioaction.c
index ac31219393acb4a70649d25358e70e714a1e3686..4a5aaa786f1e27d340bd2fa8485529cc56a78bf3 100644 (file)
@@ -14,9 +14,7 @@
  * Library General Public License for more details.
  *
  * You should have received a copy of the GNU Library General Public
- * License along with the Gnome Library; see the file COPYING.LIB.  If not,
- * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 /*
@@ -32,7 +30,6 @@
 
 #include "gtkradioaction.h"
 #include "gtkradiomenuitem.h"
-#include "gtktoggleactionprivate.h"
 #include "gtktoggletoolbutton.h"
 #include "gtkintl.h"
 #include "gtkprivate.h"
@@ -48,8 +45,6 @@
  */
 
 
-#define GTK_RADIO_ACTION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_RADIO_ACTION, GtkRadioActionPrivate))
-
 struct _GtkRadioActionPrivate 
 {
   GSList *group;
@@ -183,7 +178,10 @@ gtk_radio_action_class_init (GtkRadioActionClass *klass)
 static void
 gtk_radio_action_init (GtkRadioAction *action)
 {
-  action->private_data = GTK_RADIO_ACTION_GET_PRIVATE (action);
+  action->private_data = G_TYPE_INSTANCE_GET_PRIVATE (action,
+                                                      GTK_TYPE_RADIO_ACTION,
+                                                      GtkRadioActionPrivate);
+
   action->private_data->group = g_slist_prepend (NULL, action);
   action->private_data->value = 0;
 
@@ -193,10 +191,11 @@ gtk_radio_action_init (GtkRadioAction *action)
 /**
  * gtk_radio_action_new:
  * @name: A unique name for the action
- * @label: (allow-none): The label displayed in menu items and on buttons, or %NULL
+ * @label: (allow-none): The label displayed in menu items and on buttons,
+ *   or %NULL
  * @tooltip: (allow-none): A tooltip for this action, or %NULL
- * @stock_id: The stock icon to display in widgets representing this
- *   action, or %NULL
+ * @stock_id: (allow-none): The stock icon to display in widgets representing
+ *   this action, or %NULL
  * @value: The value which gtk_radio_action_get_current_value() should
  *   return if this action is selected.
  *
@@ -320,11 +319,13 @@ gtk_radio_action_activate (GtkAction *action)
   GtkToggleAction *toggle_action;
   GtkToggleAction *tmp_action;
   GSList *tmp_list;
+  gboolean active;
 
   radio_action = GTK_RADIO_ACTION (action);
   toggle_action = GTK_TOGGLE_ACTION (action);
 
-  if (toggle_action->private_data->active)
+  active = gtk_toggle_action_get_active (toggle_action);
+  if (active)
     {
       tmp_list = radio_action->private_data->group;
 
@@ -333,9 +334,10 @@ gtk_radio_action_activate (GtkAction *action)
          tmp_action = tmp_list->data;
          tmp_list = tmp_list->next;
 
-         if (tmp_action->private_data->active && (tmp_action != toggle_action)) 
+         if (gtk_toggle_action_get_active (tmp_action) &&
+              (tmp_action != toggle_action))
            {
-             toggle_action->private_data->active = !toggle_action->private_data->active;
+              _gtk_toggle_action_set_active (toggle_action, !active);
 
              break;
            }
@@ -344,7 +346,7 @@ gtk_radio_action_activate (GtkAction *action)
     }
   else
     {
-      toggle_action->private_data->active = !toggle_action->private_data->active;
+      _gtk_toggle_action_set_active (toggle_action, !active);
       g_object_notify (G_OBJECT (action), "active");
 
       tmp_list = radio_action->private_data->group;
@@ -353,7 +355,8 @@ gtk_radio_action_activate (GtkAction *action)
          tmp_action = tmp_list->data;
          tmp_list = tmp_list->next;
 
-         if (tmp_action->private_data->active && (tmp_action != toggle_action))
+          if (gtk_toggle_action_get_active (tmp_action) &&
+              (tmp_action != toggle_action))
            {
              _gtk_action_emit_activate (GTK_ACTION (tmp_action));
              break;
@@ -545,7 +548,7 @@ gtk_radio_action_get_current_value (GtkRadioAction *action)
        {
          GtkToggleAction *toggle_action = slist->data;
 
-         if (toggle_action->private_data->active)
+         if (gtk_toggle_action_get_active (toggle_action))
            return GTK_RADIO_ACTION (toggle_action)->private_data->value;
        }
     }