2003-08-24 19:58:30 +00:00
|
|
|
/*
|
2008-07-01 22:57:50 +00:00
|
|
|
* GTK - The GIMP Toolkit
|
2003-08-24 19:58:30 +00:00
|
|
|
* Copyright (C) 1998, 1999 Red Hat, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This Library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2003-08-24 19:58:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Author: James Henstridge <james@daa.com.au>
|
|
|
|
*
|
|
|
|
* Modified by the GTK+ Team and others 2003. See the AUTHORS
|
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2003-08-24 19:58:30 +00:00
|
|
|
|
2013-06-28 15:27:19 +00:00
|
|
|
#define GDK_DISABLE_DEPRECATION_WARNINGS
|
|
|
|
|
2003-08-24 19:58:30 +00:00
|
|
|
#include "gtkradioaction.h"
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
#include "gtkradiomenuitem.h"
|
2003-08-29 19:50:55 +00:00
|
|
|
#include "gtktoggletoolbutton.h"
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
#include "gtkintl.h"
|
2005-03-22 02:14:55 +00:00
|
|
|
#include "gtkprivate.h"
|
2010-05-15 22:26:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:gtkradioaction
|
|
|
|
* @Short_description: An action of which only one in a group can be active
|
|
|
|
* @Title: GtkRadioAction
|
|
|
|
*
|
|
|
|
* A #GtkRadioAction is similar to #GtkRadioMenuItem. A number of radio
|
|
|
|
* actions can be linked together so that only one may be active at any
|
|
|
|
* one time.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2003-08-24 19:58:30 +00:00
|
|
|
struct _GtkRadioActionPrivate
|
|
|
|
{
|
|
|
|
GSList *group;
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
gint value;
|
2003-08-24 19:58:30 +00:00
|
|
|
};
|
|
|
|
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
CHANGED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2004-01-14 01:33:53 +00:00
|
|
|
PROP_VALUE,
|
2006-01-16 19:07:13 +00:00
|
|
|
PROP_GROUP,
|
|
|
|
PROP_CURRENT_VALUE
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void gtk_radio_action_finalize (GObject *object);
|
|
|
|
static void gtk_radio_action_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gtk_radio_action_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gtk_radio_action_activate (GtkAction *action);
|
2003-08-29 19:50:55 +00:00
|
|
|
static GtkWidget *create_menu_item (GtkAction *action);
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
|
2003-08-24 19:58:30 +00:00
|
|
|
|
2013-06-27 19:02:52 +00:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkRadioAction, gtk_radio_action, GTK_TYPE_TOGGLE_ACTION)
|
2003-08-24 19:58:30 +00:00
|
|
|
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
static guint radio_action_signals[LAST_SIGNAL] = { 0 };
|
2003-08-24 19:58:30 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_radio_action_class_init (GtkRadioActionClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GtkActionClass *action_class;
|
|
|
|
|
|
|
|
gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
action_class = GTK_ACTION_CLASS (klass);
|
|
|
|
|
|
|
|
gobject_class->finalize = gtk_radio_action_finalize;
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
gobject_class->set_property = gtk_radio_action_set_property;
|
|
|
|
gobject_class->get_property = gtk_radio_action_get_property;
|
2003-08-24 19:58:30 +00:00
|
|
|
|
|
|
|
action_class->activate = gtk_radio_action_activate;
|
|
|
|
|
2003-08-29 19:50:55 +00:00
|
|
|
action_class->create_menu_item = create_menu_item;
|
|
|
|
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
/**
|
|
|
|
* GtkRadioAction:value:
|
|
|
|
*
|
|
|
|
* The value is an arbitrary integer which can be used as a
|
|
|
|
* convenient way to determine which action in the group is
|
|
|
|
* currently active in an ::activate or ::changed signal handler.
|
|
|
|
* See gtk_radio_action_get_current_value() and #GtkRadioActionEntry
|
|
|
|
* for convenient ways to get and set this property.
|
|
|
|
*
|
|
|
|
* Since: 2.4
|
2013-06-28 15:27:19 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 3.10
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_VALUE,
|
|
|
|
g_param_spec_int ("value",
|
2004-01-16 23:10:05 +00:00
|
|
|
P_("The value"),
|
|
|
|
P_("The value returned by gtk_radio_action_get_current_value() when this action is the current action of its group."),
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
G_MININT,
|
|
|
|
G_MAXINT,
|
|
|
|
0,
|
2005-03-22 02:14:55 +00:00
|
|
|
GTK_PARAM_READWRITE));
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
|
2004-01-14 01:33:53 +00:00
|
|
|
/**
|
|
|
|
* GtkRadioAction:group:
|
|
|
|
*
|
|
|
|
* Sets a new group for a radio action.
|
|
|
|
*
|
|
|
|
* Since: 2.4
|
2013-06-28 15:27:19 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 3.10
|
2004-01-14 01:33:53 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_GROUP,
|
|
|
|
g_param_spec_object ("group",
|
2004-01-16 23:10:05 +00:00
|
|
|
P_("Group"),
|
2004-07-23 15:37:27 +00:00
|
|
|
P_("The radio action whose group this action belongs to."),
|
2004-01-14 01:33:53 +00:00
|
|
|
GTK_TYPE_RADIO_ACTION,
|
2005-03-22 02:14:55 +00:00
|
|
|
GTK_PARAM_WRITABLE));
|
2004-01-14 01:33:53 +00:00
|
|
|
|
2006-01-16 19:07:13 +00:00
|
|
|
/**
|
|
|
|
* GtkRadioAction:current-value:
|
|
|
|
*
|
|
|
|
* The value property of the currently active member of the group to which
|
|
|
|
* this action belongs.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
2013-06-28 15:27:19 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 3.10
|
2006-01-16 19:07:13 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_CURRENT_VALUE,
|
|
|
|
g_param_spec_int ("current-value",
|
|
|
|
P_("The current value"),
|
|
|
|
P_("The value property of the currently active member of the group to which this action belongs."),
|
|
|
|
G_MININT,
|
|
|
|
G_MAXINT,
|
|
|
|
0,
|
|
|
|
GTK_PARAM_READWRITE));
|
|
|
|
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
/**
|
|
|
|
* GtkRadioAction::changed:
|
|
|
|
* @action: the action on which the signal is emitted
|
|
|
|
* @current: the member of @action<!-- -->s group which has just been activated
|
|
|
|
*
|
|
|
|
* The ::changed signal is emitted on every member of a radio group when the
|
|
|
|
* active member is changed. The signal gets emitted after the ::activate signals
|
|
|
|
* for the previous and current active members.
|
|
|
|
*
|
|
|
|
* Since: 2.4
|
2013-06-28 15:27:19 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 3.10
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
*/
|
|
|
|
radio_action_signals[CHANGED] =
|
2005-09-01 05:11:46 +00:00
|
|
|
g_signal_new (I_("changed"),
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
G_OBJECT_CLASS_TYPE (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
|
|
|
|
G_STRUCT_OFFSET (GtkRadioActionClass, changed), NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1, GTK_TYPE_RADIO_ACTION);
|
2003-08-24 19:58:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_radio_action_init (GtkRadioAction *action)
|
|
|
|
{
|
2013-06-27 19:02:52 +00:00
|
|
|
action->private_data = gtk_radio_action_get_instance_private (action);
|
2003-08-24 19:58:30 +00:00
|
|
|
action->private_data->group = g_slist_prepend (NULL, action);
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
action->private_data->value = 0;
|
2009-01-25 23:54:27 +00:00
|
|
|
|
|
|
|
gtk_toggle_action_set_draw_as_radio (GTK_TOGGLE_ACTION (action), TRUE);
|
2003-08-24 19:58:30 +00:00
|
|
|
}
|
|
|
|
|
2004-01-07 21:54:33 +00:00
|
|
|
/**
|
|
|
|
* gtk_radio_action_new:
|
|
|
|
* @name: A unique name for the action
|
2011-01-18 09:12:38 +00:00
|
|
|
* @label: (allow-none): The label displayed in menu items and on buttons,
|
|
|
|
* or %NULL
|
2010-02-19 16:53:17 +00:00
|
|
|
* @tooltip: (allow-none): A tooltip for this action, or %NULL
|
2011-01-18 08:25:47 +00:00
|
|
|
* @stock_id: (allow-none): The stock icon to display in widgets representing
|
|
|
|
* this action, or %NULL
|
2007-09-09 20:18:24 +00:00
|
|
|
* @value: The value which gtk_radio_action_get_current_value() should
|
|
|
|
* return if this action is selected.
|
2004-01-07 21:54:33 +00:00
|
|
|
*
|
|
|
|
* Creates a new #GtkRadioAction object. To add the action to
|
|
|
|
* a #GtkActionGroup and set the accelerator for the action,
|
|
|
|
* call gtk_action_group_add_action_with_accel().
|
|
|
|
*
|
|
|
|
* Return value: a new #GtkRadioAction
|
|
|
|
*
|
|
|
|
* Since: 2.4
|
2013-06-28 15:27:19 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 3.10
|
2004-01-07 21:54:33 +00:00
|
|
|
*/
|
|
|
|
GtkRadioAction *
|
|
|
|
gtk_radio_action_new (const gchar *name,
|
|
|
|
const gchar *label,
|
|
|
|
const gchar *tooltip,
|
|
|
|
const gchar *stock_id,
|
|
|
|
gint value)
|
|
|
|
{
|
2007-09-09 20:18:24 +00:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
|
|
|
return g_object_new (GTK_TYPE_RADIO_ACTION,
|
2009-01-25 23:54:27 +00:00
|
|
|
"name", name,
|
|
|
|
"label", label,
|
|
|
|
"tooltip", tooltip,
|
|
|
|
"stock-id", stock_id,
|
|
|
|
"value", value,
|
|
|
|
NULL);
|
2004-01-07 21:54:33 +00:00
|
|
|
}
|
|
|
|
|
2003-08-24 19:58:30 +00:00
|
|
|
static void
|
|
|
|
gtk_radio_action_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GtkRadioAction *action;
|
|
|
|
GSList *tmp_list;
|
|
|
|
|
|
|
|
action = GTK_RADIO_ACTION (object);
|
|
|
|
|
|
|
|
action->private_data->group = g_slist_remove (action->private_data->group, action);
|
|
|
|
|
|
|
|
tmp_list = action->private_data->group;
|
|
|
|
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
GtkRadioAction *tmp_action = tmp_list->data;
|
|
|
|
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
tmp_action->private_data->group = action->private_data->group;
|
|
|
|
}
|
|
|
|
|
2006-05-02 23:56:43 +00:00
|
|
|
G_OBJECT_CLASS (gtk_radio_action_parent_class)->finalize (object);
|
2003-08-24 19:58:30 +00:00
|
|
|
}
|
|
|
|
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
static void
|
|
|
|
gtk_radio_action_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkRadioAction *radio_action;
|
|
|
|
|
|
|
|
radio_action = GTK_RADIO_ACTION (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_VALUE:
|
|
|
|
radio_action->private_data->value = g_value_get_int (value);
|
|
|
|
break;
|
2004-01-14 01:33:53 +00:00
|
|
|
case PROP_GROUP:
|
|
|
|
{
|
|
|
|
GtkRadioAction *arg;
|
|
|
|
GSList *slist = NULL;
|
|
|
|
|
|
|
|
if (G_VALUE_HOLDS_OBJECT (value))
|
|
|
|
{
|
|
|
|
arg = GTK_RADIO_ACTION (g_value_get_object (value));
|
|
|
|
if (arg)
|
|
|
|
slist = gtk_radio_action_get_group (arg);
|
|
|
|
gtk_radio_action_set_group (radio_action, slist);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2006-01-16 19:07:13 +00:00
|
|
|
case PROP_CURRENT_VALUE:
|
|
|
|
gtk_radio_action_set_current_value (radio_action,
|
|
|
|
g_value_get_int (value));
|
|
|
|
break;
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_radio_action_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkRadioAction *radio_action;
|
|
|
|
|
|
|
|
radio_action = GTK_RADIO_ACTION (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_VALUE:
|
|
|
|
g_value_set_int (value, radio_action->private_data->value);
|
|
|
|
break;
|
2006-01-16 19:07:13 +00:00
|
|
|
case PROP_CURRENT_VALUE:
|
|
|
|
g_value_set_int (value,
|
|
|
|
gtk_radio_action_get_current_value (radio_action));
|
|
|
|
break;
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-24 19:58:30 +00:00
|
|
|
static void
|
|
|
|
gtk_radio_action_activate (GtkAction *action)
|
|
|
|
{
|
|
|
|
GtkRadioAction *radio_action;
|
|
|
|
GtkToggleAction *toggle_action;
|
|
|
|
GtkToggleAction *tmp_action;
|
|
|
|
GSList *tmp_list;
|
2010-07-13 18:40:42 +00:00
|
|
|
gboolean active;
|
2003-08-24 19:58:30 +00:00
|
|
|
|
|
|
|
radio_action = GTK_RADIO_ACTION (action);
|
|
|
|
toggle_action = GTK_TOGGLE_ACTION (action);
|
|
|
|
|
2010-07-13 18:40:42 +00:00
|
|
|
active = gtk_toggle_action_get_active (toggle_action);
|
|
|
|
if (active)
|
2003-08-24 19:58:30 +00:00
|
|
|
{
|
|
|
|
tmp_list = radio_action->private_data->group;
|
|
|
|
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
tmp_action = tmp_list->data;
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
|
2010-07-13 18:40:42 +00:00
|
|
|
if (gtk_toggle_action_get_active (tmp_action) &&
|
|
|
|
(tmp_action != toggle_action))
|
2003-08-24 19:58:30 +00:00
|
|
|
{
|
2010-07-16 16:34:46 +00:00
|
|
|
_gtk_toggle_action_set_active (toggle_action, !active);
|
2009-01-23 15:15:28 +00:00
|
|
|
|
2003-08-24 19:58:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-02-26 02:33:42 +00:00
|
|
|
g_object_notify (G_OBJECT (action), "active");
|
2003-08-24 19:58:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-16 16:34:46 +00:00
|
|
|
_gtk_toggle_action_set_active (toggle_action, !active);
|
2009-01-23 15:15:28 +00:00
|
|
|
g_object_notify (G_OBJECT (action), "active");
|
2003-08-24 19:58:30 +00:00
|
|
|
|
|
|
|
tmp_list = radio_action->private_data->group;
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
tmp_action = tmp_list->data;
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
|
2010-07-13 18:40:42 +00:00
|
|
|
if (gtk_toggle_action_get_active (tmp_action) &&
|
|
|
|
(tmp_action != toggle_action))
|
2003-08-24 19:58:30 +00:00
|
|
|
{
|
2003-12-19 00:39:10 +00:00
|
|
|
_gtk_action_emit_activate (GTK_ACTION (tmp_action));
|
2003-08-24 19:58:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
|
|
|
|
tmp_list = radio_action->private_data->group;
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
tmp_action = tmp_list->data;
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
|
2006-01-16 19:07:13 +00:00
|
|
|
g_object_notify (G_OBJECT (tmp_action), "current-value");
|
|
|
|
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
g_signal_emit (tmp_action, radio_action_signals[CHANGED], 0, radio_action);
|
|
|
|
}
|
2003-08-24 19:58:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_toggle_action_toggled (toggle_action);
|
|
|
|
}
|
|
|
|
|
2003-08-29 19:50:55 +00:00
|
|
|
static GtkWidget *
|
|
|
|
create_menu_item (GtkAction *action)
|
|
|
|
{
|
|
|
|
return g_object_new (GTK_TYPE_CHECK_MENU_ITEM,
|
2005-03-26 05:49:15 +00:00
|
|
|
"draw-as-radio", TRUE,
|
2003-08-29 19:50:55 +00:00
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2003-08-24 19:58:30 +00:00
|
|
|
/**
|
|
|
|
* gtk_radio_action_get_group:
|
|
|
|
* @action: the action object
|
|
|
|
*
|
2005-03-15 16:33:43 +00:00
|
|
|
* Returns the list representing the radio group for this object.
|
|
|
|
* Note that the returned list is only valid until the next change
|
|
|
|
* to the group.
|
|
|
|
*
|
|
|
|
* A common way to set up a group of radio group is the following:
|
2014-01-27 19:55:18 +00:00
|
|
|
* |[<!-- language="C" -->
|
2005-03-15 16:33:43 +00:00
|
|
|
* GSList *group = NULL;
|
|
|
|
* GtkRadioAction *action;
|
|
|
|
*
|
2007-11-25 06:51:19 +00:00
|
|
|
* while (/* more actions to add */)
|
2005-03-15 16:33:43 +00:00
|
|
|
* {
|
|
|
|
* action = gtk_radio_action_new (...);
|
2005-04-30 03:49:06 +00:00
|
|
|
*
|
2005-03-15 16:33:43 +00:00
|
|
|
* gtk_radio_action_set_group (action, group);
|
|
|
|
* group = gtk_radio_action_get_group (action);
|
|
|
|
* }
|
2007-11-25 06:51:19 +00:00
|
|
|
* ]|
|
2003-08-24 19:58:30 +00:00
|
|
|
*
|
2010-05-06 21:30:03 +00:00
|
|
|
* Returns: (element-type GtkRadioAction) (transfer none): the list representing the radio group for this object
|
2003-08-24 19:58:30 +00:00
|
|
|
*
|
|
|
|
* Since: 2.4
|
2013-06-28 15:27:19 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 3.10
|
2003-08-24 19:58:30 +00:00
|
|
|
*/
|
|
|
|
GSList *
|
|
|
|
gtk_radio_action_get_group (GtkRadioAction *action)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_RADIO_ACTION (action), NULL);
|
|
|
|
|
|
|
|
return action->private_data->group;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_radio_action_set_group:
|
|
|
|
* @action: the action object
|
2013-12-06 22:53:41 +00:00
|
|
|
* @group: (element-type GtkRadioAction) (allow-none): a list representing a radio group, or %NULL
|
2003-08-24 19:58:30 +00:00
|
|
|
*
|
|
|
|
* Sets the radio group for the radio action object.
|
|
|
|
*
|
|
|
|
* Since: 2.4
|
2013-06-28 15:27:19 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 3.10
|
2003-08-24 19:58:30 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_radio_action_set_group (GtkRadioAction *action,
|
|
|
|
GSList *group)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_RADIO_ACTION (action));
|
|
|
|
g_return_if_fail (!g_slist_find (group, action));
|
|
|
|
|
|
|
|
if (action->private_data->group)
|
|
|
|
{
|
|
|
|
GSList *slist;
|
|
|
|
|
|
|
|
action->private_data->group = g_slist_remove (action->private_data->group, action);
|
|
|
|
|
|
|
|
for (slist = action->private_data->group; slist; slist = slist->next)
|
|
|
|
{
|
|
|
|
GtkRadioAction *tmp_action = slist->data;
|
|
|
|
|
|
|
|
tmp_action->private_data->group = action->private_data->group;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
action->private_data->group = g_slist_prepend (group, action);
|
|
|
|
|
|
|
|
if (group)
|
|
|
|
{
|
|
|
|
GSList *slist;
|
|
|
|
|
|
|
|
for (slist = action->private_data->group; slist; slist = slist->next)
|
|
|
|
{
|
|
|
|
GtkRadioAction *tmp_action = slist->data;
|
|
|
|
|
|
|
|
tmp_action->private_data->group = action->private_data->group;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
|
|
|
|
}
|
|
|
|
}
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
|
2010-05-19 19:12:49 +00:00
|
|
|
/**
|
|
|
|
* gtk_radio_action_join_group:
|
|
|
|
* @action: the action object
|
|
|
|
* @group_source: (allow-none): a radio action object whos group we are
|
|
|
|
* joining, or %NULL to remove the radio action from its group
|
|
|
|
*
|
|
|
|
* Joins a radio action object to the group of another radio action object.
|
|
|
|
*
|
|
|
|
* Use this in language bindings instead of the gtk_radio_action_get_group()
|
|
|
|
* and gtk_radio_action_set_group() methods
|
|
|
|
*
|
|
|
|
* A common way to set up a group of radio actions is the following:
|
2014-01-27 19:55:18 +00:00
|
|
|
* |[<!-- language="C" -->
|
2010-05-19 19:12:49 +00:00
|
|
|
* GtkRadioAction *action;
|
|
|
|
* GtkRadioAction *last_action;
|
|
|
|
*
|
|
|
|
* while (/* more actions to add */)
|
|
|
|
* {
|
|
|
|
* action = gtk_radio_action_new (...);
|
|
|
|
*
|
|
|
|
* gtk_radio_action_join_group (action, last_action);
|
|
|
|
* last_action = action;
|
|
|
|
* }
|
|
|
|
* ]|
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
2013-06-28 15:27:19 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 3.10
|
2010-05-19 19:12:49 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_radio_action_join_group (GtkRadioAction *action,
|
|
|
|
GtkRadioAction *group_source)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_RADIO_ACTION (action));
|
|
|
|
g_return_if_fail (group_source == NULL || GTK_IS_RADIO_ACTION (group_source));
|
|
|
|
|
|
|
|
if (group_source)
|
|
|
|
{
|
|
|
|
GSList *group;
|
|
|
|
group = gtk_radio_action_get_group (group_source);
|
|
|
|
|
|
|
|
if (!group)
|
|
|
|
{
|
|
|
|
/* if we are not already part of a group we need to set up a new one
|
|
|
|
and then get the newly created group */
|
|
|
|
gtk_radio_action_set_group (group_source, NULL);
|
|
|
|
group = gtk_radio_action_get_group (group_source);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_radio_action_set_group (action, group);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_radio_action_set_group (action, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
/**
|
|
|
|
* gtk_radio_action_get_current_value:
|
|
|
|
* @action: a #GtkRadioAction
|
|
|
|
*
|
2005-02-01 18:15:09 +00:00
|
|
|
* Obtains the value property of the currently active member of
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
* the group to which @action belongs.
|
|
|
|
*
|
|
|
|
* Return value: The value of the currently active group member
|
|
|
|
*
|
|
|
|
* Since: 2.4
|
2013-06-28 15:27:19 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 3.10
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
**/
|
|
|
|
gint
|
|
|
|
gtk_radio_action_get_current_value (GtkRadioAction *action)
|
|
|
|
{
|
|
|
|
GSList *slist;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_RADIO_ACTION (action), 0);
|
|
|
|
|
|
|
|
if (action->private_data->group)
|
|
|
|
{
|
|
|
|
for (slist = action->private_data->group; slist; slist = slist->next)
|
|
|
|
{
|
|
|
|
GtkToggleAction *toggle_action = slist->data;
|
|
|
|
|
2010-07-13 18:40:42 +00:00
|
|
|
if (gtk_toggle_action_get_active (toggle_action))
|
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
2003-08-27 22:22:28 +00:00
|
|
|
return GTK_RADIO_ACTION (toggle_action)->private_data->value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return action->private_data->value;
|
|
|
|
}
|
2005-03-20 07:01:23 +00:00
|
|
|
|
2006-01-16 19:07:13 +00:00
|
|
|
/**
|
|
|
|
* gtk_radio_action_set_current_value:
|
|
|
|
* @action: a #GtkRadioAction
|
|
|
|
* @current_value: the new value
|
|
|
|
*
|
|
|
|
* Sets the currently active group member to the member with value
|
|
|
|
* property @current_value.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
2013-06-28 15:27:19 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 3.10
|
2006-01-16 19:07:13 +00:00
|
|
|
**/
|
|
|
|
void
|
|
|
|
gtk_radio_action_set_current_value (GtkRadioAction *action,
|
|
|
|
gint current_value)
|
|
|
|
{
|
|
|
|
GSList *slist;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_RADIO_ACTION (action));
|
|
|
|
|
|
|
|
if (action->private_data->group)
|
|
|
|
{
|
|
|
|
for (slist = action->private_data->group; slist; slist = slist->next)
|
|
|
|
{
|
|
|
|
GtkRadioAction *radio_action = slist->data;
|
|
|
|
|
|
|
|
if (radio_action->private_data->value == current_value)
|
|
|
|
{
|
|
|
|
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (radio_action),
|
|
|
|
TRUE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action->private_data->value == current_value)
|
|
|
|
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
|
|
|
|
else
|
|
|
|
g_warning ("Radio group does not contain an action with value '%d'",
|
|
|
|
current_value);
|
|
|
|
}
|