Remove GtkToggleAction
This commit is contained in:
committed by
Benjamin Otte
parent
53ab8eb46d
commit
41f5d3b14c
@@ -5,7 +5,6 @@ deprecated_h_sources = \
|
||||
deprecated/gtkgradient.h \
|
||||
deprecated/gtkrecentaction.h \
|
||||
deprecated/gtksymboliccolor.h \
|
||||
deprecated/gtktoggleaction.h \
|
||||
deprecated/gtkuimanager.h
|
||||
|
||||
deprecated_private_h_sources = \
|
||||
@@ -19,5 +18,4 @@ deprecated_c_sources = \
|
||||
deprecated/gtkgradient.c \
|
||||
deprecated/gtkrecentaction.c \
|
||||
deprecated/gtksymboliccolor.c \
|
||||
deprecated/gtktoggleaction.c \
|
||||
deprecated/gtkuimanager.c
|
||||
|
||||
@@ -91,7 +91,6 @@
|
||||
#include "gtkactiongroup.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkicontheme.h"
|
||||
#include "gtktoggleaction.h"
|
||||
#include "gtkaccelmap.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkbuilderprivate.h"
|
||||
@@ -1283,7 +1282,7 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_gro
|
||||
|
||||
for (i = 0; i < n_entries; i++)
|
||||
{
|
||||
GtkToggleAction *action;
|
||||
GtkAction *action;
|
||||
const gchar *label;
|
||||
const gchar *tooltip;
|
||||
|
||||
@@ -1293,18 +1292,11 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_gro
|
||||
label = gtk_action_group_translate_string (action_group, entries[i].label);
|
||||
tooltip = gtk_action_group_translate_string (action_group, entries[i].tooltip);
|
||||
|
||||
action = gtk_toggle_action_new (entries[i].name,
|
||||
label,
|
||||
tooltip,
|
||||
NULL);
|
||||
|
||||
if (entries[i].stock_id)
|
||||
{
|
||||
g_object_set (action, "icon-name", entries[i].stock_id, NULL);
|
||||
}
|
||||
|
||||
gtk_toggle_action_set_active (action, entries[i].is_active);
|
||||
|
||||
if (entries[i].callback)
|
||||
{
|
||||
GClosure *closure;
|
||||
@@ -1417,9 +1409,6 @@ gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group
|
||||
if (i == 0)
|
||||
first_action = action;
|
||||
|
||||
if (value == entries[i].value)
|
||||
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
|
||||
|
||||
gtk_action_group_add_action_with_accel (action_group,
|
||||
GTK_ACTION (action),
|
||||
entries[i].accelerator);
|
||||
|
||||
@@ -1,401 +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 "gtkintl.h"
|
||||
#include "gtktoggleaction.h"
|
||||
#include "gtktoggletoolbutton.h"
|
||||
#include "gtktogglebutton.h"
|
||||
#include "gtkcheckmenuitem.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
|
||||
/**
|
||||
* SECTION:gtktoggleaction
|
||||
* @Short_description: An action which can be toggled between two states
|
||||
* @Title: GtkToggleAction
|
||||
*
|
||||
* A #GtkToggleAction corresponds roughly to a #GtkCheckMenuItem. It has an
|
||||
* “active” state specifying whether the action has been checked or not.
|
||||
*/
|
||||
|
||||
struct _GtkToggleActionPrivate
|
||||
{
|
||||
guint active : 1;
|
||||
guint draw_as_radio : 1;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOGGLED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_DRAW_AS_RADIO,
|
||||
PROP_ACTIVE
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkToggleAction, gtk_toggle_action, GTK_TYPE_ACTION)
|
||||
|
||||
static void gtk_toggle_action_activate (GtkAction *action);
|
||||
static void set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static GtkWidget *create_menu_item (GtkAction *action);
|
||||
|
||||
|
||||
static guint action_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static void
|
||||
gtk_toggle_action_class_init (GtkToggleActionClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GtkActionClass *action_class;
|
||||
|
||||
gobject_class = G_OBJECT_CLASS (klass);
|
||||
action_class = GTK_ACTION_CLASS (klass);
|
||||
|
||||
gobject_class->set_property = set_property;
|
||||
gobject_class->get_property = get_property;
|
||||
|
||||
action_class->activate = gtk_toggle_action_activate;
|
||||
|
||||
action_class->menu_item_type = GTK_TYPE_CHECK_MENU_ITEM;
|
||||
action_class->toolbar_item_type = GTK_TYPE_TOGGLE_TOOL_BUTTON;
|
||||
|
||||
action_class->create_menu_item = create_menu_item;
|
||||
|
||||
klass->toggled = NULL;
|
||||
|
||||
/**
|
||||
* GtkToggleAction:draw-as-radio:
|
||||
*
|
||||
* Whether the proxies for this action look like radio action proxies.
|
||||
*
|
||||
* This is an appearance property and thus only applies if
|
||||
* #GtkActivatable:use-action-appearance is %TRUE.
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
*/
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_DRAW_AS_RADIO,
|
||||
g_param_spec_boolean ("draw-as-radio",
|
||||
P_("Create the same proxies as a radio action"),
|
||||
P_("Whether the proxies for this action look like radio action proxies"),
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkToggleAction:active:
|
||||
*
|
||||
* Whether the toggle action should be active.
|
||||
*
|
||||
* Since: 2.10
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
*/
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_ACTIVE,
|
||||
g_param_spec_boolean ("active",
|
||||
P_("Active"),
|
||||
P_("Whether the toggle action should be active"),
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE));
|
||||
/**
|
||||
* GtkToggleAction::toggled:
|
||||
* @toggleaction: the object which received the signal.
|
||||
*
|
||||
* Should be connected if you wish to perform an action
|
||||
* whenever the #GtkToggleAction state is changed.
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
*/
|
||||
action_signals[TOGGLED] =
|
||||
g_signal_new (I_("toggled"),
|
||||
G_OBJECT_CLASS_TYPE (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GtkToggleActionClass, toggled),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_toggle_action_init (GtkToggleAction *action)
|
||||
{
|
||||
action->private_data = gtk_toggle_action_get_instance_private (action);
|
||||
action->private_data->active = FALSE;
|
||||
action->private_data->draw_as_radio = FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_toggle_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 the action, or %NULL
|
||||
* @stock_id: (allow-none): The stock icon to display in widgets representing
|
||||
* the action, or %NULL
|
||||
*
|
||||
* Creates a new #GtkToggleAction 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 #GtkToggleAction
|
||||
*
|
||||
* Since: 2.4
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
*/
|
||||
GtkToggleAction *
|
||||
gtk_toggle_action_new (const gchar *name,
|
||||
const gchar *label,
|
||||
const gchar *tooltip,
|
||||
const gchar *stock_id)
|
||||
{
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
return g_object_new (GTK_TYPE_TOGGLE_ACTION,
|
||||
"name", name,
|
||||
"label", label,
|
||||
"tooltip", tooltip,
|
||||
"stock-id", stock_id,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkToggleAction *action = GTK_TOGGLE_ACTION (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_DRAW_AS_RADIO:
|
||||
g_value_set_boolean (value, gtk_toggle_action_get_draw_as_radio (action));
|
||||
break;
|
||||
case PROP_ACTIVE:
|
||||
g_value_set_boolean (value, gtk_toggle_action_get_active (action));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkToggleAction *action = GTK_TOGGLE_ACTION (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_DRAW_AS_RADIO:
|
||||
gtk_toggle_action_set_draw_as_radio (action, g_value_get_boolean (value));
|
||||
break;
|
||||
case PROP_ACTIVE:
|
||||
gtk_toggle_action_set_active (action, g_value_get_boolean (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_toggle_action_activate (GtkAction *action)
|
||||
{
|
||||
GtkToggleAction *toggle_action;
|
||||
|
||||
g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
|
||||
|
||||
toggle_action = GTK_TOGGLE_ACTION (action);
|
||||
|
||||
toggle_action->private_data->active = !toggle_action->private_data->active;
|
||||
|
||||
g_object_notify (G_OBJECT (action), "active");
|
||||
|
||||
gtk_toggle_action_toggled (toggle_action);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_toggle_action_toggled:
|
||||
* @action: the action object
|
||||
*
|
||||
* Emits the “toggled” signal on the toggle action.
|
||||
*
|
||||
* Since: 2.4
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
*/
|
||||
void
|
||||
gtk_toggle_action_toggled (GtkToggleAction *action)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
|
||||
|
||||
g_signal_emit (action, action_signals[TOGGLED], 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_toggle_action_set_active:
|
||||
* @action: the action object
|
||||
* @is_active: whether the action should be checked or not
|
||||
*
|
||||
* Sets the checked state on the toggle action.
|
||||
*
|
||||
* Since: 2.4
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
*/
|
||||
void
|
||||
gtk_toggle_action_set_active (GtkToggleAction *action,
|
||||
gboolean is_active)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
|
||||
|
||||
is_active = is_active != FALSE;
|
||||
|
||||
if (action->private_data->active != is_active)
|
||||
_gtk_action_emit_activate (GTK_ACTION (action));
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_toggle_action_get_active:
|
||||
* @action: the action object
|
||||
*
|
||||
* Returns the checked state of the toggle action.
|
||||
*
|
||||
* Returns: the checked state of the toggle action
|
||||
*
|
||||
* Since: 2.4
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
*/
|
||||
gboolean
|
||||
gtk_toggle_action_get_active (GtkToggleAction *action)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_TOGGLE_ACTION (action), FALSE);
|
||||
|
||||
return action->private_data->active;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gtk_toggle_action_set_draw_as_radio:
|
||||
* @action: the action object
|
||||
* @draw_as_radio: whether the action should have proxies like a radio
|
||||
* action
|
||||
*
|
||||
* Sets whether the action should have proxies like a radio action.
|
||||
*
|
||||
* Since: 2.4
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
*/
|
||||
void
|
||||
gtk_toggle_action_set_draw_as_radio (GtkToggleAction *action,
|
||||
gboolean draw_as_radio)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
|
||||
|
||||
draw_as_radio = draw_as_radio != FALSE;
|
||||
|
||||
if (action->private_data->draw_as_radio != draw_as_radio)
|
||||
{
|
||||
action->private_data->draw_as_radio = draw_as_radio;
|
||||
|
||||
g_object_notify (G_OBJECT (action), "draw-as-radio");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_toggle_action_get_draw_as_radio:
|
||||
* @action: the action object
|
||||
*
|
||||
* Returns whether the action should have proxies like a radio action.
|
||||
*
|
||||
* Returns: whether the action should have proxies like a radio action.
|
||||
*
|
||||
* Since: 2.4
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
*/
|
||||
gboolean
|
||||
gtk_toggle_action_get_draw_as_radio (GtkToggleAction *action)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_TOGGLE_ACTION (action), FALSE);
|
||||
|
||||
return action->private_data->draw_as_radio;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
create_menu_item (GtkAction *action)
|
||||
{
|
||||
GtkToggleAction *toggle_action = GTK_TOGGLE_ACTION (action);
|
||||
|
||||
return g_object_new (GTK_TYPE_CHECK_MENU_ITEM,
|
||||
"draw-as-radio", toggle_action->private_data->draw_as_radio,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
/* Private */
|
||||
|
||||
/*
|
||||
* _gtk_toggle_action_set_active:
|
||||
* @toggle_action: a #GtkToggleAction
|
||||
* @is_active: whether the action is active or not
|
||||
*
|
||||
* Sets the #GtkToggleAction:active property directly. This function does
|
||||
* not emit signals or notifications: it is left to the caller to do so.
|
||||
*
|
||||
* Deprecated: 3.10
|
||||
*/
|
||||
void
|
||||
_gtk_toggle_action_set_active (GtkToggleAction *toggle_action,
|
||||
gboolean is_active)
|
||||
{
|
||||
GtkToggleActionPrivate *priv = toggle_action->private_data;
|
||||
|
||||
priv->active = is_active;
|
||||
}
|
||||
@@ -1,99 +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_TOGGLE_ACTION_H__
|
||||
#define __GTK_TOGGLE_ACTION_H__
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gtk/deprecated/gtkaction.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_TOGGLE_ACTION (gtk_toggle_action_get_type ())
|
||||
#define GTK_TOGGLE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TOGGLE_ACTION, GtkToggleAction))
|
||||
#define GTK_TOGGLE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TOGGLE_ACTION, GtkToggleActionClass))
|
||||
#define GTK_IS_TOGGLE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TOGGLE_ACTION))
|
||||
#define GTK_IS_TOGGLE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TOGGLE_ACTION))
|
||||
#define GTK_TOGGLE_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_TOGGLE_ACTION, GtkToggleActionClass))
|
||||
|
||||
typedef struct _GtkToggleAction GtkToggleAction;
|
||||
typedef struct _GtkToggleActionPrivate GtkToggleActionPrivate;
|
||||
typedef struct _GtkToggleActionClass GtkToggleActionClass;
|
||||
|
||||
struct _GtkToggleAction
|
||||
{
|
||||
GtkAction parent;
|
||||
|
||||
/*< private >*/
|
||||
GtkToggleActionPrivate *private_data;
|
||||
};
|
||||
|
||||
struct _GtkToggleActionClass
|
||||
{
|
||||
GtkActionClass parent_class;
|
||||
|
||||
void (* toggled) (GtkToggleAction *action);
|
||||
|
||||
/* 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_toggle_action_get_type (void) G_GNUC_CONST;
|
||||
GDK_DEPRECATED_IN_3_10
|
||||
GtkToggleAction *gtk_toggle_action_new (const gchar *name,
|
||||
const gchar *label,
|
||||
const gchar *tooltip,
|
||||
const gchar *stock_id);
|
||||
GDK_DEPRECATED_IN_3_10
|
||||
void gtk_toggle_action_toggled (GtkToggleAction *action);
|
||||
GDK_DEPRECATED_IN_3_10
|
||||
void gtk_toggle_action_set_active (GtkToggleAction *action,
|
||||
gboolean is_active);
|
||||
GDK_DEPRECATED_IN_3_10
|
||||
gboolean gtk_toggle_action_get_active (GtkToggleAction *action);
|
||||
GDK_DEPRECATED_IN_3_10
|
||||
void gtk_toggle_action_set_draw_as_radio (GtkToggleAction *action,
|
||||
gboolean draw_as_radio);
|
||||
GDK_DEPRECATED_IN_3_10
|
||||
gboolean gtk_toggle_action_get_draw_as_radio (GtkToggleAction *action);
|
||||
|
||||
/* private */
|
||||
void _gtk_toggle_action_set_active (GtkToggleAction *toggle_action,
|
||||
gboolean is_active);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_TOGGLE_ACTION_H__ */
|
||||
@@ -250,7 +250,6 @@
|
||||
#include <gtk/deprecated/gtkgradient.h>
|
||||
#include <gtk/deprecated/gtkrecentaction.h>
|
||||
#include <gtk/deprecated/gtksymboliccolor.h>
|
||||
#include <gtk/deprecated/gtktoggleaction.h>
|
||||
#include <gtk/deprecated/gtkuimanager.h>
|
||||
#endif /* GTK_DISABLE_DEPRECATED */
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "gtkcheckmenuitemprivate.h"
|
||||
#include "gtkmenuitemprivate.h"
|
||||
#include "gtkaccellabel.h"
|
||||
#include "deprecated/gtktoggleaction.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "gtklabel.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "deprecated/gtktoggleaction.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "a11y/gtktogglebuttonaccessible.h"
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
#include "gtktogglebutton.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkradiotoolbutton.h"
|
||||
#include "deprecated/gtktoggleaction.h"
|
||||
#include "deprecated/gtkactivatable.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
|
||||
@@ -82,22 +80,10 @@ static void menu_item_activated (GtkWidget *widget,
|
||||
GtkToggleToolButton *button);
|
||||
|
||||
|
||||
static void gtk_toggle_tool_button_activatable_interface_init (GtkActivatableIface *iface);
|
||||
static void gtk_toggle_tool_button_update (GtkActivatable *activatable,
|
||||
GtkAction *action,
|
||||
const gchar *property_name);
|
||||
static void gtk_toggle_tool_button_sync_action_properties (GtkActivatable *activatable,
|
||||
GtkAction *action);
|
||||
|
||||
static GtkActivatableIface *parent_activatable_iface;
|
||||
static guint toggle_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkToggleToolButton, gtk_toggle_tool_button, GTK_TYPE_TOOL_BUTTON,
|
||||
G_ADD_PRIVATE (GtkToggleToolButton)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
|
||||
gtk_toggle_tool_button_activatable_interface_init))
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
G_ADD_PRIVATE (GtkToggleToolButton));
|
||||
|
||||
static void
|
||||
gtk_toggle_tool_button_class_init (GtkToggleToolButtonClass *klass)
|
||||
@@ -322,61 +308,6 @@ button_toggled (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_toggle_tool_button_activatable_interface_init (GtkActivatableIface *iface)
|
||||
{
|
||||
parent_activatable_iface = g_type_interface_peek_parent (iface);
|
||||
iface->update = gtk_toggle_tool_button_update;
|
||||
iface->sync_action_properties = gtk_toggle_tool_button_sync_action_properties;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_toggle_tool_button_update (GtkActivatable *activatable,
|
||||
GtkAction *action,
|
||||
const gchar *property_name)
|
||||
{
|
||||
GtkToggleToolButton *button;
|
||||
|
||||
parent_activatable_iface->update (activatable, action, property_name);
|
||||
|
||||
button = GTK_TOGGLE_TOOL_BUTTON (activatable);
|
||||
|
||||
if (strcmp (property_name, "active") == 0)
|
||||
{
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
gtk_action_block_activate (action);
|
||||
gtk_toggle_tool_button_set_active (button, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
|
||||
gtk_action_unblock_activate (action);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_toggle_tool_button_sync_action_properties (GtkActivatable *activatable,
|
||||
GtkAction *action)
|
||||
{
|
||||
GtkToggleToolButton *button;
|
||||
gboolean is_toggle_action;
|
||||
|
||||
parent_activatable_iface->sync_action_properties (activatable, action);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
is_toggle_action = GTK_IS_TOGGLE_ACTION (action);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
|
||||
if (!is_toggle_action)
|
||||
return;
|
||||
|
||||
button = GTK_TOGGLE_TOOL_BUTTON (activatable);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
gtk_action_block_activate (action);
|
||||
gtk_toggle_tool_button_set_active (button, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
|
||||
gtk_action_unblock_activate (action);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gtk_toggle_tool_button_new:
|
||||
*
|
||||
|
||||
@@ -31,17 +31,6 @@ activate_action (GtkAction *action)
|
||||
g_message ("Action %s (type=%s) activated", name, typename);
|
||||
}
|
||||
|
||||
static void
|
||||
toggle_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)", name, typename,
|
||||
gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
recent_action (GtkAction *action)
|
||||
{
|
||||
@@ -58,9 +47,8 @@ recent_action (GtkAction *action)
|
||||
static void
|
||||
toggle_cnp_actions (GtkAction *action)
|
||||
{
|
||||
gboolean sensitive;
|
||||
gboolean sensitive = FALSE;
|
||||
|
||||
sensitive = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
|
||||
action = gtk_action_group_get_action (action_group, "cut");
|
||||
g_object_set (action, "sensitive", sensitive, NULL);
|
||||
action = gtk_action_group_get_action (action_group, "copy");
|
||||
@@ -122,16 +110,6 @@ static GtkActionEntry entries[] = {
|
||||
};
|
||||
static guint n_entries = G_N_ELEMENTS (entries);
|
||||
|
||||
static GtkToggleActionEntry toggle_entries[] = {
|
||||
{ "bold", NULL, "_Bold", "<control>B",
|
||||
"Change to bold face",
|
||||
G_CALLBACK (toggle_action), FALSE },
|
||||
{ "toggle-cnp", NULL, "Enable Cut/Copy/Paste", NULL,
|
||||
"Change the sensitivity of the cut, copy and paste actions",
|
||||
G_CALLBACK (toggle_cnp_actions), TRUE },
|
||||
};
|
||||
static guint n_toggle_entries = G_N_ELEMENTS (toggle_entries);
|
||||
|
||||
enum {
|
||||
JUSTIFY_LEFT,
|
||||
JUSTIFY_CENTER,
|
||||
@@ -378,9 +356,6 @@ main (int argc, char **argv)
|
||||
gtk_action_group_add_actions (action_group,
|
||||
entries, n_entries,
|
||||
NULL);
|
||||
gtk_action_group_add_toggle_actions (action_group,
|
||||
toggle_entries, n_toggle_entries,
|
||||
NULL);
|
||||
gtk_action_group_add_action_with_accel (action_group, action, NULL);
|
||||
|
||||
create_window (action_group);
|
||||
|
||||
@@ -142,17 +142,6 @@ activate_action (GtkAction *action)
|
||||
g_message ("Action %s (type=%s) activated", name, typename);
|
||||
}
|
||||
|
||||
static void
|
||||
toggle_action (GtkAction *action)
|
||||
{
|
||||
const gchar *name = gtk_action_get_name (action);
|
||||
const gchar *typename = G_OBJECT_TYPE_NAME (action);
|
||||
|
||||
g_message ("ToggleAction %s (type=%s) toggled (active=%d)", name, typename,
|
||||
gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
|
||||
}
|
||||
|
||||
|
||||
static GtkActionEntry entries[] = {
|
||||
{ "FileMenuAction", NULL, "_File" },
|
||||
{ "EditMenuAction", NULL, "_Edit" },
|
||||
@@ -173,12 +162,6 @@ static GtkActionEntry entries[] = {
|
||||
};
|
||||
static guint n_entries = G_N_ELEMENTS (entries);
|
||||
|
||||
static GtkToggleActionEntry toggle_entries[] = {
|
||||
{ "BoldAction", NULL, "_Bold", "<control>b", "Make it bold", G_CALLBACK (toggle_action),
|
||||
TRUE },
|
||||
};
|
||||
static guint n_toggle_entries = G_N_ELEMENTS (toggle_entries);
|
||||
|
||||
enum {
|
||||
JUSTIFY_LEFT,
|
||||
JUSTIFY_CENTER,
|
||||
@@ -560,10 +543,6 @@ main (int argc, char **argv)
|
||||
g_object_set (action, "hide_if_empty", FALSE, NULL);
|
||||
action = gtk_action_group_get_action (action_group, "EmptyMenu2Action");
|
||||
g_object_set (action, "hide_if_empty", TRUE, NULL);
|
||||
gtk_action_group_add_toggle_actions (action_group,
|
||||
toggle_entries, n_toggle_entries,
|
||||
NULL);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), -1, 400);
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
|
||||
|
||||
@@ -735,7 +735,6 @@ test_types (void)
|
||||
" <object class=\"GtkSpinButton\" id=\"spinbutton\"/>"
|
||||
" <object class=\"GtkStatusbar\" id=\"statusbar\"/>"
|
||||
" <object class=\"GtkTextView\" id=\"textview\"/>"
|
||||
" <object class=\"GtkToggleAction\" id=\"toggleaction\"/>"
|
||||
" <object class=\"GtkToggleButton\" id=\"togglebutton\"/>"
|
||||
" <object class=\"GtkToolbar\" id=\"toolbar\"/>"
|
||||
" <object class=\"GtkTreeStore\" id=\"treestore\"/>"
|
||||
|
||||
@@ -363,7 +363,6 @@ test_type (gconstpointer data)
|
||||
/* Deprecated, not getting fixed */
|
||||
if (g_str_equal (g_type_name (type), "GtkColorSelection") ||
|
||||
g_str_equal (g_type_name (type), "GtkNumerableIcon") ||
|
||||
g_str_equal (g_type_name (type), "GtkToggleAction") ||
|
||||
g_str_equal (g_type_name (type), "GtkUIManager"))
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user