forked from AuroraMiddleware/gtk
Remove GtkRadioAction
This commit is contained in:
parent
bc7206d70f
commit
53ab8eb46d
@ -2414,28 +2414,6 @@ GtkProgressBarPrivate
|
||||
gtk_progress_bar_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkradioaction</FILE>
|
||||
<TITLE>GtkRadioAction</TITLE>
|
||||
GtkRadioAction
|
||||
gtk_radio_action_new
|
||||
gtk_radio_action_get_group
|
||||
gtk_radio_action_set_group
|
||||
gtk_radio_action_join_group
|
||||
gtk_radio_action_get_current_value
|
||||
gtk_radio_action_set_current_value
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_RADIO_ACTION
|
||||
GTK_RADIO_ACTION
|
||||
GTK_RADIO_ACTION_CLASS
|
||||
GTK_IS_RADIO_ACTION
|
||||
GTK_IS_RADIO_ACTION_CLASS
|
||||
GTK_RADIO_ACTION_GET_CLASS
|
||||
<SUBSECTION Private>
|
||||
gtk_radio_action_get_type
|
||||
GtkRadioActionPrivate
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkradiobutton</FILE>
|
||||
<TITLE>GtkRadioButton</TITLE>
|
||||
|
@ -3,7 +3,6 @@ deprecated_h_sources = \
|
||||
deprecated/gtkaction.h \
|
||||
deprecated/gtkactiongroup.h \
|
||||
deprecated/gtkgradient.h \
|
||||
deprecated/gtkradioaction.h \
|
||||
deprecated/gtkrecentaction.h \
|
||||
deprecated/gtksymboliccolor.h \
|
||||
deprecated/gtktoggleaction.h \
|
||||
@ -18,7 +17,6 @@ deprecated_c_sources = \
|
||||
deprecated/gtkaction.c \
|
||||
deprecated/gtkactiongroup.c \
|
||||
deprecated/gtkgradient.c \
|
||||
deprecated/gtkradioaction.c \
|
||||
deprecated/gtkrecentaction.c \
|
||||
deprecated/gtksymboliccolor.c \
|
||||
deprecated/gtktoggleaction.c \
|
||||
|
@ -92,7 +92,6 @@
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkicontheme.h"
|
||||
#include "gtktoggleaction.h"
|
||||
#include "gtkradioaction.h"
|
||||
#include "gtkaccelmap.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkbuilderprivate.h"
|
||||
@ -1394,13 +1393,13 @@ gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group
|
||||
*/
|
||||
guint i;
|
||||
GSList *group = NULL;
|
||||
GtkRadioAction *first_action = NULL;
|
||||
GtkAction *first_action = NULL;
|
||||
|
||||
g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
|
||||
|
||||
for (i = 0; i < n_entries; i++)
|
||||
{
|
||||
GtkRadioAction *action;
|
||||
GtkAction *action;
|
||||
const gchar *label;
|
||||
const gchar *tooltip;
|
||||
|
||||
@ -1410,12 +1409,6 @@ gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group
|
||||
label = gtk_action_group_translate_string (action_group, entries[i].label);
|
||||
tooltip = gtk_action_group_translate_string (action_group, entries[i].tooltip);
|
||||
|
||||
action = gtk_radio_action_new (entries[i].name,
|
||||
label,
|
||||
tooltip,
|
||||
NULL,
|
||||
entries[i].value);
|
||||
|
||||
if (entries[i].stock_id)
|
||||
{
|
||||
g_object_set (action, "icon-name", entries[i].stock_id, NULL);
|
||||
@ -1424,9 +1417,6 @@ gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group
|
||||
if (i == 0)
|
||||
first_action = action;
|
||||
|
||||
gtk_radio_action_set_group (action, group);
|
||||
group = gtk_radio_action_get_group (action);
|
||||
|
||||
if (value == entries[i].value)
|
||||
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
|
||||
|
||||
|
@ -1,614 +0,0 @@
|
||||
/*
|
||||
* GTK - The GIMP Toolkit
|
||||
* 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
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define GDK_DISABLE_DEPRECATION_WARNINGS
|
||||
|
||||
#include "gtkradioaction.h"
|
||||
#include "gtkradiomenuitem.h"
|
||||
#include "gtktoggletoolbutton.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
struct _GtkRadioActionPrivate
|
||||
{
|
||||
GSList *group;
|
||||
gint value;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_VALUE,
|
||||
PROP_GROUP,
|
||||
PROP_CURRENT_VALUE
|
||||
};
|
||||
|
||||
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);
|
||||
static GtkWidget *create_menu_item (GtkAction *action);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkRadioAction, gtk_radio_action, GTK_TYPE_TOGGLE_ACTION)
|
||||
|
||||
static guint radio_action_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
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;
|
||||
gobject_class->set_property = gtk_radio_action_set_property;
|
||||
gobject_class->get_property = gtk_radio_action_get_property;
|
||||
|
||||
action_class->activate = gtk_radio_action_activate;
|
||||
|
||||
action_class->create_menu_item = create_menu_item;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
*/
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_VALUE,
|
||||
g_param_spec_int ("value",
|
||||
P_("The value"),
|
||||
P_("The value returned by gtk_radio_action_get_current_value() when this action is the current action of its group."),
|
||||
G_MININT,
|
||||
G_MAXINT,
|
||||
0,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkRadioAction:group:
|
||||
*
|
||||
* Sets a new group for a radio action.
|
||||
*
|
||||
* Since: 2.4
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
*/
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_GROUP,
|
||||
g_param_spec_object ("group",
|
||||
P_("Group"),
|
||||
P_("The radio action whose group this action belongs to."),
|
||||
GTK_TYPE_RADIO_ACTION,
|
||||
GTK_PARAM_WRITABLE));
|
||||
|
||||
/**
|
||||
* GtkRadioAction:current-value:
|
||||
*
|
||||
* The value property of the currently active member of the group to which
|
||||
* this action belongs.
|
||||
*
|
||||
* Since: 2.10
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
*/
|
||||
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));
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
*/
|
||||
radio_action_signals[CHANGED] =
|
||||
g_signal_new (I_("changed"),
|
||||
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);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_radio_action_init (GtkRadioAction *action)
|
||||
{
|
||||
action->private_data = gtk_radio_action_get_instance_private (action);
|
||||
action->private_data->group = g_slist_prepend (NULL, action);
|
||||
action->private_data->value = 0;
|
||||
|
||||
gtk_toggle_action_set_draw_as_radio (GTK_TOGGLE_ACTION (action), TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @tooltip: (allow-none): A tooltip for 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.
|
||||
*
|
||||
* 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().
|
||||
*
|
||||
* Returns: a new #GtkRadioAction
|
||||
*
|
||||
* Since: 2.4
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
*/
|
||||
GtkRadioAction *
|
||||
gtk_radio_action_new (const gchar *name,
|
||||
const gchar *label,
|
||||
const gchar *tooltip,
|
||||
const gchar *stock_id,
|
||||
gint value)
|
||||
{
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
return g_object_new (GTK_TYPE_RADIO_ACTION,
|
||||
"name", name,
|
||||
"label", label,
|
||||
"tooltip", tooltip,
|
||||
"stock-id", stock_id,
|
||||
"value", value,
|
||||
NULL);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (gtk_radio_action_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
case PROP_CURRENT_VALUE:
|
||||
gtk_radio_action_set_current_value (radio_action,
|
||||
g_value_get_int (value));
|
||||
break;
|
||||
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;
|
||||
case PROP_CURRENT_VALUE:
|
||||
g_value_set_int (value,
|
||||
gtk_radio_action_get_current_value (radio_action));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_radio_action_activate (GtkAction *action)
|
||||
{
|
||||
GtkRadioAction *radio_action;
|
||||
GtkToggleAction *toggle_action;
|
||||
GtkToggleAction *tmp_action;
|
||||
GSList *tmp_list;
|
||||
gboolean active;
|
||||
|
||||
radio_action = GTK_RADIO_ACTION (action);
|
||||
toggle_action = GTK_TOGGLE_ACTION (action);
|
||||
|
||||
active = gtk_toggle_action_get_active (toggle_action);
|
||||
if (active)
|
||||
{
|
||||
tmp_list = radio_action->private_data->group;
|
||||
|
||||
while (tmp_list)
|
||||
{
|
||||
tmp_action = tmp_list->data;
|
||||
tmp_list = tmp_list->next;
|
||||
|
||||
if (gtk_toggle_action_get_active (tmp_action) &&
|
||||
(tmp_action != toggle_action))
|
||||
{
|
||||
_gtk_toggle_action_set_active (toggle_action, !active);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_object_notify (G_OBJECT (action), "active");
|
||||
}
|
||||
else
|
||||
{
|
||||
_gtk_toggle_action_set_active (toggle_action, !active);
|
||||
g_object_notify (G_OBJECT (action), "active");
|
||||
|
||||
tmp_list = radio_action->private_data->group;
|
||||
while (tmp_list)
|
||||
{
|
||||
tmp_action = tmp_list->data;
|
||||
tmp_list = tmp_list->next;
|
||||
|
||||
if (gtk_toggle_action_get_active (tmp_action) &&
|
||||
(tmp_action != toggle_action))
|
||||
{
|
||||
_gtk_action_emit_activate (GTK_ACTION (tmp_action));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tmp_list = radio_action->private_data->group;
|
||||
while (tmp_list)
|
||||
{
|
||||
tmp_action = tmp_list->data;
|
||||
tmp_list = tmp_list->next;
|
||||
|
||||
g_object_notify (G_OBJECT (tmp_action), "current-value");
|
||||
|
||||
g_signal_emit (tmp_action, radio_action_signals[CHANGED], 0, radio_action);
|
||||
}
|
||||
}
|
||||
|
||||
gtk_toggle_action_toggled (toggle_action);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
create_menu_item (GtkAction *action)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_CHECK_MENU_ITEM,
|
||||
"draw-as-radio", TRUE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_radio_action_get_group:
|
||||
* @action: the action object
|
||||
*
|
||||
* 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:
|
||||
* |[<!-- language="C" -->
|
||||
* GSList *group = NULL;
|
||||
* GtkRadioAction *action;
|
||||
*
|
||||
* while ( ...more actions to add... /)
|
||||
* {
|
||||
* action = gtk_radio_action_new (...);
|
||||
*
|
||||
* gtk_radio_action_set_group (action, group);
|
||||
* group = gtk_radio_action_get_group (action);
|
||||
* }
|
||||
* ]|
|
||||
*
|
||||
* Returns: (element-type GtkRadioAction) (transfer none): the list representing the radio group for this object
|
||||
*
|
||||
* Since: 2.4
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
*/
|
||||
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
|
||||
* @group: (element-type GtkRadioAction) (allow-none): a list representing a radio group, or %NULL
|
||||
*
|
||||
* Sets the radio group for the radio action object.
|
||||
*
|
||||
* Since: 2.4
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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:
|
||||
* |[<!-- language="C" -->
|
||||
* 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
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_radio_action_get_current_value:
|
||||
* @action: a #GtkRadioAction
|
||||
*
|
||||
* Obtains the value property of the currently active member of
|
||||
* the group to which @action belongs.
|
||||
*
|
||||
* Returns: The value of the currently active group member
|
||||
*
|
||||
* Since: 2.4
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
**/
|
||||
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;
|
||||
|
||||
if (gtk_toggle_action_get_active (toggle_action))
|
||||
return GTK_RADIO_ACTION (toggle_action)->private_data->value;
|
||||
}
|
||||
}
|
||||
|
||||
return action->private_data->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
**/
|
||||
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);
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
/*
|
||||
* GTK - The GIMP Toolkit
|
||||
* 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
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_RADIO_ACTION_H__
|
||||
#define __GTK_RADIO_ACTION_H__
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gtk/deprecated/gtktoggleaction.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_RADIO_ACTION (gtk_radio_action_get_type ())
|
||||
#define GTK_RADIO_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RADIO_ACTION, GtkRadioAction))
|
||||
#define GTK_RADIO_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RADIO_ACTION, GtkRadioActionClass))
|
||||
#define GTK_IS_RADIO_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RADIO_ACTION))
|
||||
#define GTK_IS_RADIO_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RADIO_ACTION))
|
||||
#define GTK_RADIO_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_RADIO_ACTION, GtkRadioActionClass))
|
||||
|
||||
typedef struct _GtkRadioAction GtkRadioAction;
|
||||
typedef struct _GtkRadioActionPrivate GtkRadioActionPrivate;
|
||||
typedef struct _GtkRadioActionClass GtkRadioActionClass;
|
||||
|
||||
struct _GtkRadioAction
|
||||
{
|
||||
GtkToggleAction parent;
|
||||
|
||||
/*< private >*/
|
||||
GtkRadioActionPrivate *private_data;
|
||||
};
|
||||
|
||||
struct _GtkRadioActionClass
|
||||
{
|
||||
GtkToggleActionClass parent_class;
|
||||
|
||||
void (* changed) (GtkRadioAction *action, GtkRadioAction *current);
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved4) (void);
|
||||
};
|
||||
|
||||
GDK_DEPRECATED_IN_3_10
|
||||
GType gtk_radio_action_get_type (void) G_GNUC_CONST;
|
||||
GDK_DEPRECATED_IN_3_10
|
||||
GtkRadioAction *gtk_radio_action_new (const gchar *name,
|
||||
const gchar *label,
|
||||
const gchar *tooltip,
|
||||
const gchar *stock_id,
|
||||
gint value);
|
||||
GDK_DEPRECATED_IN_3_10
|
||||
GSList *gtk_radio_action_get_group (GtkRadioAction *action);
|
||||
GDK_DEPRECATED_IN_3_10
|
||||
void gtk_radio_action_set_group (GtkRadioAction *action,
|
||||
GSList *group);
|
||||
GDK_DEPRECATED_IN_3_10
|
||||
void gtk_radio_action_join_group (GtkRadioAction *action,
|
||||
GtkRadioAction *group_source);
|
||||
GDK_DEPRECATED_IN_3_10
|
||||
gint gtk_radio_action_get_current_value (GtkRadioAction *action);
|
||||
GDK_DEPRECATED_IN_3_10
|
||||
void gtk_radio_action_set_current_value (GtkRadioAction *action,
|
||||
gint current_value);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_RADIO_ACTION_H__ */
|
@ -248,7 +248,6 @@
|
||||
#include <gtk/deprecated/gtkaction.h>
|
||||
#include <gtk/deprecated/gtkactiongroup.h>
|
||||
#include <gtk/deprecated/gtkgradient.h>
|
||||
#include <gtk/deprecated/gtkradioaction.h>
|
||||
#include <gtk/deprecated/gtkrecentaction.h>
|
||||
#include <gtk/deprecated/gtksymboliccolor.h>
|
||||
#include <gtk/deprecated/gtktoggleaction.h>
|
||||
|
@ -42,17 +42,6 @@ toggle_action (GtkAction *action)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
radio_action (GtkAction *action)
|
||||
{
|
||||
const gchar *name = gtk_action_get_name (action);
|
||||
const gchar *typename = G_OBJECT_TYPE_NAME (action);
|
||||
|
||||
g_message ("Action %s (type=%s) activated (active=%d) (value %d)", name, typename,
|
||||
gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)),
|
||||
gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action)));
|
||||
}
|
||||
|
||||
static void
|
||||
recent_action (GtkAction *action)
|
||||
{
|
||||
@ -92,20 +81,6 @@ show_accel_dialog (GtkAction *action)
|
||||
g_message ("Sorry, accel dialog not available");
|
||||
}
|
||||
|
||||
static void
|
||||
toolbar_style (GtkAction *action)
|
||||
{
|
||||
GtkToolbarStyle style;
|
||||
|
||||
g_return_if_fail (toolbar != NULL);
|
||||
|
||||
radio_action (action);
|
||||
|
||||
style = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
|
||||
|
||||
gtk_toolbar_set_style (toolbar, style);
|
||||
}
|
||||
|
||||
static void
|
||||
toolbar_size_small (GtkAction *action)
|
||||
{
|
||||
@ -164,26 +139,6 @@ enum {
|
||||
JUSTIFY_FILL
|
||||
};
|
||||
|
||||
static GtkRadioActionEntry justify_entries[] = {
|
||||
{ "justify-left", GTK_STOCK_JUSTIFY_LEFT, "_Left", "<control>L",
|
||||
"Left justify the text", JUSTIFY_LEFT },
|
||||
{ "justify-center", GTK_STOCK_JUSTIFY_CENTER, "C_enter", "<control>E",
|
||||
"Center justify the text", JUSTIFY_CENTER },
|
||||
{ "justify-right", GTK_STOCK_JUSTIFY_RIGHT, "_Right", "<control>R",
|
||||
"Right justify the text", JUSTIFY_RIGHT },
|
||||
{ "justify-fill", GTK_STOCK_JUSTIFY_FILL, "_Fill", "<control>J",
|
||||
"Fill justify the text", JUSTIFY_FILL }
|
||||
};
|
||||
static guint n_justify_entries = G_N_ELEMENTS (justify_entries);
|
||||
|
||||
static GtkRadioActionEntry toolbar_entries[] = {
|
||||
{ "toolbar-icons", NULL, "Icons", NULL, NULL, GTK_TOOLBAR_ICONS },
|
||||
{ "toolbar-text", NULL, "Text", NULL, NULL, GTK_TOOLBAR_TEXT },
|
||||
{ "toolbar-both", NULL, "Both", NULL, NULL, GTK_TOOLBAR_BOTH },
|
||||
{ "toolbar-both-horiz", NULL, "Both Horizontal", NULL, NULL, GTK_TOOLBAR_BOTH_HORIZ }
|
||||
};
|
||||
static guint n_toolbar_entries = G_N_ELEMENTS (toolbar_entries);
|
||||
|
||||
/* XML description of the menus for the test app. The parser understands
|
||||
* a subset of the Bonobo UI XML format, and uses GMarkup for parsing */
|
||||
static const gchar *ui_info =
|
||||
@ -426,14 +381,6 @@ main (int argc, char **argv)
|
||||
gtk_action_group_add_toggle_actions (action_group,
|
||||
toggle_entries, n_toggle_entries,
|
||||
NULL);
|
||||
gtk_action_group_add_radio_actions (action_group,
|
||||
justify_entries, n_justify_entries,
|
||||
JUSTIFY_LEFT,
|
||||
G_CALLBACK (radio_action), NULL);
|
||||
gtk_action_group_add_radio_actions (action_group,
|
||||
toolbar_entries, n_toolbar_entries,
|
||||
GTK_TOOLBAR_BOTH,
|
||||
G_CALLBACK (toolbar_style), NULL);
|
||||
gtk_action_group_add_action_with_accel (action_group, action, NULL);
|
||||
|
||||
create_window (action_group);
|
||||
|
@ -153,16 +153,6 @@ toggle_action (GtkAction *action)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
radio_action_changed (GtkAction *action, GtkRadioAction *current)
|
||||
{
|
||||
g_message ("RadioAction %s (type=%s) activated (active=%d) (value %d)",
|
||||
gtk_action_get_name (GTK_ACTION (current)),
|
||||
G_OBJECT_TYPE_NAME (GTK_ACTION (current)),
|
||||
gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current)),
|
||||
gtk_radio_action_get_current_value (current));
|
||||
}
|
||||
|
||||
static GtkActionEntry entries[] = {
|
||||
{ "FileMenuAction", NULL, "_File" },
|
||||
{ "EditMenuAction", NULL, "_Edit" },
|
||||
@ -196,18 +186,6 @@ enum {
|
||||
JUSTIFY_FILL
|
||||
};
|
||||
|
||||
static GtkRadioActionEntry radio_entries[] = {
|
||||
{ "justify-left", GTK_STOCK_JUSTIFY_LEFT, NULL, "<control>L",
|
||||
"Left justify the text", JUSTIFY_LEFT },
|
||||
{ "justify-center", GTK_STOCK_JUSTIFY_CENTER, NULL, "<super>E",
|
||||
"Center justify the text", JUSTIFY_CENTER },
|
||||
{ "justify-right", GTK_STOCK_JUSTIFY_RIGHT, NULL, "<hyper>R",
|
||||
"Right justify the text", JUSTIFY_RIGHT },
|
||||
{ "justify-fill", GTK_STOCK_JUSTIFY_FILL, NULL, "<super><hyper>J",
|
||||
"Fill justify the text", JUSTIFY_FILL },
|
||||
};
|
||||
static guint n_radio_entries = G_N_ELEMENTS (radio_entries);
|
||||
|
||||
static void
|
||||
add_widget (GtkUIManager *merge,
|
||||
GtkWidget *widget,
|
||||
@ -585,10 +563,6 @@ main (int argc, char **argv)
|
||||
gtk_action_group_add_toggle_actions (action_group,
|
||||
toggle_entries, n_toggle_entries,
|
||||
NULL);
|
||||
gtk_action_group_add_radio_actions (action_group,
|
||||
radio_entries, n_radio_entries,
|
||||
JUSTIFY_RIGHT,
|
||||
G_CALLBACK (radio_action_changed), NULL);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), -1, 400);
|
||||
|
@ -362,21 +362,9 @@ test_type (gconstpointer data)
|
||||
|
||||
/* Deprecated, not getting fixed */
|
||||
if (g_str_equal (g_type_name (type), "GtkColorSelection") ||
|
||||
g_str_equal (g_type_name (type), "GtkHPaned") ||
|
||||
g_str_equal (g_type_name (type), "GtkVPaned") ||
|
||||
g_str_equal (g_type_name (type), "GtkHScale") ||
|
||||
g_str_equal (g_type_name (type), "GtkVScale") ||
|
||||
g_str_equal (g_type_name (type), "GtkHScrollbar") ||
|
||||
g_str_equal (g_type_name (type), "GtkVScrollbar") ||
|
||||
g_str_equal (g_type_name (type), "GtkHSeparator") ||
|
||||
g_str_equal (g_type_name (type), "GtkVSeparator") ||
|
||||
g_str_equal (g_type_name (type), "GtkVBox") ||
|
||||
g_str_equal (g_type_name (type), "GtkArrow") ||
|
||||
g_str_equal (g_type_name (type), "GtkNumerableIcon") ||
|
||||
g_str_equal (g_type_name (type), "GtkRadioAction") ||
|
||||
g_str_equal (g_type_name (type), "GtkToggleAction") ||
|
||||
g_str_equal (g_type_name (type), "GtkUIManager") ||
|
||||
g_str_equal (g_type_name (type), "GtkImageMenuItem"))
|
||||
g_str_equal (g_type_name (type), "GtkUIManager"))
|
||||
return;
|
||||
|
||||
/* These can't be freely constructed/destroyed */
|
||||
|
Loading…
Reference in New Issue
Block a user