2008-07-01 22:57:50 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
1997-11-24 22:37:52 +00:00
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1997-11-24 22:37:52 +00:00
|
|
|
* 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
|
2000-07-26 11:33:08 +00:00
|
|
|
* Lesser General Public License for more details.
|
1997-11-24 22:37:52 +00:00
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1998-04-13 02:02:47 +00:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
1997-11-24 22:37:52 +00:00
|
|
|
*/
|
1999-02-24 07:37:18 +00:00
|
|
|
|
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:37:18 +00:00
|
|
|
* 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"
|
2010-10-19 00:01:31 +00:00
|
|
|
|
|
|
|
#include "gtktogglebutton.h"
|
|
|
|
|
|
|
|
#include "gtkbuttonprivate.h"
|
1997-11-24 22:37:52 +00:00
|
|
|
#include "gtklabel.h"
|
|
|
|
#include "gtkmain.h"
|
2001-11-17 23:28:51 +00:00
|
|
|
#include "gtkmarshalers.h"
|
2009-01-23 15:15:28 +00:00
|
|
|
#include "gtktoggleaction.h"
|
|
|
|
#include "gtkactivatable.h"
|
2005-03-22 02:14:55 +00:00
|
|
|
#include "gtkprivate.h"
|
2001-05-13 22:41:30 +00:00
|
|
|
#include "gtkintl.h"
|
2011-06-28 04:53:22 +00:00
|
|
|
#include "a11y/gtktogglebuttonaccessible.h"
|
2010-07-09 17:22:23 +00:00
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2011-04-17 23:24:56 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gtktogglebutton
|
|
|
|
* @Short_description: Create buttons which retain their state
|
|
|
|
* @Title: GtkToggleButton
|
|
|
|
* @See_also: #GtkButton, #GtkCheckButton, #GtkCheckMenuItem
|
|
|
|
*
|
|
|
|
* A #GtkToggleButton is a #GtkButton which will remain 'pressed-in' when
|
|
|
|
* clicked. Clicking again will cause the toggle button to return to its
|
|
|
|
* normal state.
|
|
|
|
*
|
|
|
|
* A toggle button is created by calling either gtk_toggle_button_new() or
|
|
|
|
* gtk_toggle_button_new_with_label(). If using the former, it is advisable to
|
|
|
|
* pack a widget, (such as a #GtkLabel and/or a #GtkPixmap), into the toggle
|
|
|
|
* button's container. (See #GtkButton for more information).
|
|
|
|
*
|
|
|
|
* The state of a #GtkToggleButton can be set specifically using
|
|
|
|
* gtk_toggle_button_set_active(), and retrieved using
|
|
|
|
* gtk_toggle_button_get_active().
|
|
|
|
*
|
|
|
|
* To simply switch the state of a toggle button, use gtk_toggle_button_toggled().
|
|
|
|
*
|
|
|
|
* <example>
|
|
|
|
* <title>Creating two #GtkToggleButton widgets.</title>
|
|
|
|
* <programlisting>
|
|
|
|
* void make_toggles (void) {
|
|
|
|
* GtkWidget *dialog, *toggle1, *toggle2;
|
|
|
|
*
|
|
|
|
* dialog = gtk_dialog_new (<!-- -->);
|
|
|
|
* toggle1 = gtk_toggle_button_new_with_label ("Hi, i'm a toggle button.");
|
|
|
|
*
|
|
|
|
* // Makes this toggle button invisible
|
|
|
|
* gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (toggle1), TRUE);
|
|
|
|
*
|
|
|
|
* g_signal_connect (toggle1, "toggled",
|
|
|
|
* G_CALLBACK (output_state), NULL);
|
|
|
|
* gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area),
|
|
|
|
* toggle1, FALSE, FALSE, 2);
|
|
|
|
*
|
|
|
|
* toggle2 = gtk_toggle_button_new_with_label ("Hi, i'm another toggle button.");
|
|
|
|
* gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (toggle2), FALSE);
|
|
|
|
* g_signal_connect (toggle2, "toggled",
|
|
|
|
* G_CALLBACK (output_state), NULL);
|
|
|
|
* gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area),
|
|
|
|
* toggle2, FALSE, FALSE, 2);
|
|
|
|
*
|
|
|
|
* gtk_widget_show_all (dialog);
|
|
|
|
* }
|
|
|
|
* </programlisting>
|
|
|
|
* </example>
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
#define DEFAULT_LEFT_POS 4
|
|
|
|
#define DEFAULT_TOP_POS 4
|
|
|
|
#define DEFAULT_SPACING 7
|
|
|
|
|
2010-10-19 16:18:02 +00:00
|
|
|
struct _GtkToggleButtonPrivate
|
|
|
|
{
|
|
|
|
guint active : 1;
|
|
|
|
guint draw_indicator : 1;
|
|
|
|
guint inconsistent : 1;
|
|
|
|
};
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
enum {
|
|
|
|
TOGGLED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
new function gtk_container_child_arg_set, similar to
Wed Jun 24 14:14:32 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c: new function gtk_container_child_arg_set, similar
to gtk_container_child_arg_setv, but takes a variable argument list.
new function gtk_container_get_child_arg_type, which is needed by
gtk_object_collect_args.
* gtk/gtkobject.c: changed prototype for gtk_object_collect_args, to
take a function pointer to figure the argument type.
adapted callers to pass gtk_object_get_arg_type.
* gtk/gtkwidget.c: adapted gtk_object_collect_args callers to pass
gtk_object_get_arg_type..
* gtk/gtkpacker.h:
* gtk/gtkpacker.c:
(gtk_packer_reorder_child): new function to change the packing order
of a child.
(gtk_packer_size_request):
(gtk_packer_size_allocate): take container->border_width into acount.
* gtk/gtkpacker.c: implemented widget arguments:
"GtkPacker::spacing", "GtkPacker::border_width", "GtkPacker::pad_x",
"GtkPacker::pad_y", "GtkPacker::ipad_x", "GtkPacker::ipad_y".
implemented child arguments:
"GtkPacker::side", "GtkPacker::anchor", "GtkPacker::expand",
"GtkPacker::fill_x", "GtkPacker::fill_y", "GtkPacker::use_default",
"GtkPacker::border_width", "GtkPacker::pad_x", "GtkPacker::pad_y",
"GtkPacker::ipad_x", "GtkPacker::ipad_y", "GtkPacker::position".
* gtk/gtkmisc.c (gtk_misc_set_arg): for padding args, set the padding,
not the alignment.
* gtk/gtkeventbox.h:
* gtk/gtkeventbox.c: GtkType and macro fixups.
* gtk/testgtk.c (entry_toggle_sensitive): new function to toggle
sensitivity of an entry.
* gtk/gtkstyle.c (gtk_style_new): support normal grey as default color
for insensitive base.
* gtk/gtkentry.c (gtk_entry_realize): set the window backgrounds
widget state dependent.
(gtk_entry_style_set): likewise.
(gtk_entry_state_changed): set background color on state changes.
(gtk_entry_draw_text): for non selected text, use state dependent
colors.
* gtk/gtktogglebutton.c: support for widget arguments
"GtkToggleButton::active" and "GtkToggleButton::draw_indicator".
1998-06-24 12:22:23 +00:00
|
|
|
enum {
|
2001-05-13 22:41:30 +00:00
|
|
|
PROP_0,
|
|
|
|
PROP_ACTIVE,
|
|
|
|
PROP_INCONSISTENT,
|
|
|
|
PROP_DRAW_INDICATOR
|
new function gtk_container_child_arg_set, similar to
Wed Jun 24 14:14:32 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c: new function gtk_container_child_arg_set, similar
to gtk_container_child_arg_setv, but takes a variable argument list.
new function gtk_container_get_child_arg_type, which is needed by
gtk_object_collect_args.
* gtk/gtkobject.c: changed prototype for gtk_object_collect_args, to
take a function pointer to figure the argument type.
adapted callers to pass gtk_object_get_arg_type.
* gtk/gtkwidget.c: adapted gtk_object_collect_args callers to pass
gtk_object_get_arg_type..
* gtk/gtkpacker.h:
* gtk/gtkpacker.c:
(gtk_packer_reorder_child): new function to change the packing order
of a child.
(gtk_packer_size_request):
(gtk_packer_size_allocate): take container->border_width into acount.
* gtk/gtkpacker.c: implemented widget arguments:
"GtkPacker::spacing", "GtkPacker::border_width", "GtkPacker::pad_x",
"GtkPacker::pad_y", "GtkPacker::ipad_x", "GtkPacker::ipad_y".
implemented child arguments:
"GtkPacker::side", "GtkPacker::anchor", "GtkPacker::expand",
"GtkPacker::fill_x", "GtkPacker::fill_y", "GtkPacker::use_default",
"GtkPacker::border_width", "GtkPacker::pad_x", "GtkPacker::pad_y",
"GtkPacker::ipad_x", "GtkPacker::ipad_y", "GtkPacker::position".
* gtk/gtkmisc.c (gtk_misc_set_arg): for padding args, set the padding,
not the alignment.
* gtk/gtkeventbox.h:
* gtk/gtkeventbox.c: GtkType and macro fixups.
* gtk/testgtk.c (entry_toggle_sensitive): new function to toggle
sensitivity of an entry.
* gtk/gtkstyle.c (gtk_style_new): support normal grey as default color
for insensitive base.
* gtk/gtkentry.c (gtk_entry_realize): set the window backgrounds
widget state dependent.
(gtk_entry_style_set): likewise.
(gtk_entry_state_changed): set background color on state changes.
(gtk_entry_draw_text): for non selected text, use state dependent
colors.
* gtk/gtktogglebutton.c: support for widget arguments
"GtkToggleButton::active" and "GtkToggleButton::draw_indicator".
1998-06-24 12:22:23 +00:00
|
|
|
};
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2010-09-07 22:23:04 +00:00
|
|
|
static gint gtk_toggle_button_draw (GtkWidget *widget,
|
|
|
|
cairo_t *cr);
|
2002-07-25 16:12:46 +00:00
|
|
|
static gboolean gtk_toggle_button_mnemonic_activate (GtkWidget *widget,
|
|
|
|
gboolean group_cycling);
|
2001-05-13 22:41:30 +00:00
|
|
|
static void gtk_toggle_button_pressed (GtkButton *button);
|
|
|
|
static void gtk_toggle_button_released (GtkButton *button);
|
|
|
|
static void gtk_toggle_button_clicked (GtkButton *button);
|
|
|
|
static void gtk_toggle_button_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gtk_toggle_button_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2001-08-25 23:11:46 +00:00
|
|
|
static void gtk_toggle_button_update_state (GtkButton *button);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
|
2009-01-23 15:15:28 +00:00
|
|
|
static void gtk_toggle_button_activatable_interface_init (GtkActivatableIface *iface);
|
2009-02-22 05:20:14 +00:00
|
|
|
static void gtk_toggle_button_update (GtkActivatable *activatable,
|
|
|
|
GtkAction *action,
|
|
|
|
const gchar *property_name);
|
|
|
|
static void gtk_toggle_button_sync_action_properties (GtkActivatable *activatable,
|
|
|
|
GtkAction *action);
|
2009-01-23 15:15:28 +00:00
|
|
|
|
|
|
|
static GtkActivatableIface *parent_activatable_iface;
|
|
|
|
static guint toggle_button_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkToggleButton, gtk_toggle_button, GTK_TYPE_BUTTON,
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
|
|
|
|
gtk_toggle_button_activatable_interface_init))
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_toggle_button_class_init (GtkToggleButtonClass *class)
|
|
|
|
{
|
2002-10-11 22:57:11 +00:00
|
|
|
GObjectClass *gobject_class;
|
1997-11-24 22:37:52 +00:00
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
GtkButtonClass *button_class;
|
|
|
|
|
2001-05-13 22:41:30 +00:00
|
|
|
gobject_class = G_OBJECT_CLASS (class);
|
1997-11-24 22:37:52 +00:00
|
|
|
widget_class = (GtkWidgetClass*) class;
|
|
|
|
button_class = (GtkButtonClass*) class;
|
|
|
|
|
2001-05-13 22:41:30 +00:00
|
|
|
gobject_class->set_property = gtk_toggle_button_set_property;
|
|
|
|
gobject_class->get_property = gtk_toggle_button_get_property;
|
1998-06-28 07:46:10 +00:00
|
|
|
|
2010-09-07 22:23:04 +00:00
|
|
|
widget_class->draw = gtk_toggle_button_draw;
|
2002-07-25 16:12:46 +00:00
|
|
|
widget_class->mnemonic_activate = gtk_toggle_button_mnemonic_activate;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
button_class->pressed = gtk_toggle_button_pressed;
|
|
|
|
button_class->released = gtk_toggle_button_released;
|
|
|
|
button_class->clicked = gtk_toggle_button_clicked;
|
2001-08-25 23:11:46 +00:00
|
|
|
button_class->enter = gtk_toggle_button_update_state;
|
|
|
|
button_class->leave = gtk_toggle_button_update_state;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
class->toggled = NULL;
|
doh, this was broken beyond believe.
Tue Dec 12 23:46:44 2000 Tim Janik <timj@gtk.org>
* gtk/stock-icons/Makefile.am: doh, this was broken beyond believe.
* gtk/gtkbox.c: change property types from (u)long to (u)int for
::position and ::padding.
* gtk/gtkcontainer.c: make ::border_width an INT property.
* gtk/gtkpacker.c: make ::position an INT property.
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_adjustment_changed):
guard against NULL h/v scrollbars, since this is used at construction
time.
* gtk/gtkclist.[hc]: nuked gtk_clist_construct(), implemented
internal gtk_clist_constructor().
* gtk/gtkctree.[hc]: nuked gtk_ctree_construct(), implemented
gtk_ctree_constructor().
* gtk/gtkprogressbar.c (gtk_progress_bar_class_init): property
::pulse_step should use ARG_PULSE_STEP, not ARG_FRACTION.
* docs/reference/Makefile.am: fun stuff, disabled docs generation
again, gtk-scan.c needs to introspec paramspecs, not GtkAgs.
* gtk/gtkwidget.[hc]:
removed gtk_widget_setv(), gtk_widget_getv(), gtk_widget_newv()
and gtk_widget_get().
(gtk_widget_new): use g_object_new_valist().
(gtk_widget_set): use g_object_set_valist().
* gtk/gtkobject.[hc]:
removed gtk_object_arg_get_info(), gtk_object_getv(),
gtk_object_query_args(), gtk_object_newv(),
gtk_object_class_add_signals(),
gtk_object_class_user_signal_new(),
gtk_object_class_user_signal_newv(),
gtk_object_arg_set(), gtk_object_arg_get(),
gtk_object_args_collect(),
gtk_object_default_construct(),
gtk_object_constructed(),
GTK_CONSTRUCTED and GTK_OBJECT_CONSTRUCTED().
removed nsignals, signals and n_args members from GtkObjectClass.
(gtk_object_new): use g_object_new_valist().
(gtk_object_set): use g_object_set_valist().
(gtk_object_get): use g_object_get_valist().
* gtk/gtkcompat.h: define gtk_object_default_construct().
* gtk/gtktypeutils.c (gtk_type_new): create constructed objects via
g_object_new().
* gtk/*.c: removed gtk_object_class_add_signals() from class_init()
fucntions, cleaned up method assignments (make sure your structures
are setup properly before calling out). removed all GTK_CONSTRUCTED
hacks ;)
2000-12-13 01:34:41 +00:00
|
|
|
|
2001-05-13 22:41:30 +00:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_ACTIVE,
|
|
|
|
g_param_spec_boolean ("active",
|
2004-01-16 23:10:05 +00:00
|
|
|
P_("Active"),
|
2010-08-10 08:23:49 +00:00
|
|
|
P_("If the toggle button should be pressed in"),
|
2001-05-13 22:41:30 +00:00
|
|
|
FALSE,
|
2005-03-22 02:14:55 +00:00
|
|
|
GTK_PARAM_READWRITE));
|
2001-05-13 22:41:30 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_INCONSISTENT,
|
|
|
|
g_param_spec_boolean ("inconsistent",
|
2004-01-16 23:10:05 +00:00
|
|
|
P_("Inconsistent"),
|
|
|
|
P_("If the toggle button is in an \"in between\" state"),
|
2001-05-13 22:41:30 +00:00
|
|
|
FALSE,
|
2005-03-22 02:14:55 +00:00
|
|
|
GTK_PARAM_READWRITE));
|
2001-05-13 22:41:30 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_DRAW_INDICATOR,
|
2005-03-09 06:15:13 +00:00
|
|
|
g_param_spec_boolean ("draw-indicator",
|
2004-01-16 23:10:05 +00:00
|
|
|
P_("Draw Indicator"),
|
|
|
|
P_("If the toggle part of the button is displayed"),
|
2001-05-13 22:41:30 +00:00
|
|
|
FALSE,
|
2005-03-22 02:14:55 +00:00
|
|
|
GTK_PARAM_READWRITE));
|
doh, this was broken beyond believe.
Tue Dec 12 23:46:44 2000 Tim Janik <timj@gtk.org>
* gtk/stock-icons/Makefile.am: doh, this was broken beyond believe.
* gtk/gtkbox.c: change property types from (u)long to (u)int for
::position and ::padding.
* gtk/gtkcontainer.c: make ::border_width an INT property.
* gtk/gtkpacker.c: make ::position an INT property.
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_adjustment_changed):
guard against NULL h/v scrollbars, since this is used at construction
time.
* gtk/gtkclist.[hc]: nuked gtk_clist_construct(), implemented
internal gtk_clist_constructor().
* gtk/gtkctree.[hc]: nuked gtk_ctree_construct(), implemented
gtk_ctree_constructor().
* gtk/gtkprogressbar.c (gtk_progress_bar_class_init): property
::pulse_step should use ARG_PULSE_STEP, not ARG_FRACTION.
* docs/reference/Makefile.am: fun stuff, disabled docs generation
again, gtk-scan.c needs to introspec paramspecs, not GtkAgs.
* gtk/gtkwidget.[hc]:
removed gtk_widget_setv(), gtk_widget_getv(), gtk_widget_newv()
and gtk_widget_get().
(gtk_widget_new): use g_object_new_valist().
(gtk_widget_set): use g_object_set_valist().
* gtk/gtkobject.[hc]:
removed gtk_object_arg_get_info(), gtk_object_getv(),
gtk_object_query_args(), gtk_object_newv(),
gtk_object_class_add_signals(),
gtk_object_class_user_signal_new(),
gtk_object_class_user_signal_newv(),
gtk_object_arg_set(), gtk_object_arg_get(),
gtk_object_args_collect(),
gtk_object_default_construct(),
gtk_object_constructed(),
GTK_CONSTRUCTED and GTK_OBJECT_CONSTRUCTED().
removed nsignals, signals and n_args members from GtkObjectClass.
(gtk_object_new): use g_object_new_valist().
(gtk_object_set): use g_object_set_valist().
(gtk_object_get): use g_object_get_valist().
* gtk/gtkcompat.h: define gtk_object_default_construct().
* gtk/gtktypeutils.c (gtk_type_new): create constructed objects via
g_object_new().
* gtk/*.c: removed gtk_object_class_add_signals() from class_init()
fucntions, cleaned up method assignments (make sure your structures
are setup properly before calling out). removed all GTK_CONSTRUCTED
hacks ;)
2000-12-13 01:34:41 +00:00
|
|
|
|
2011-04-17 23:24:56 +00:00
|
|
|
/**
|
|
|
|
* GtkToggleButton::toggled:
|
|
|
|
* @togglebutton: the object which received the signal.
|
|
|
|
*
|
|
|
|
* Should be connected if you wish to perform an action whenever the
|
|
|
|
* #GtkToggleButton's state is changed.
|
|
|
|
*/
|
doh, this was broken beyond believe.
Tue Dec 12 23:46:44 2000 Tim Janik <timj@gtk.org>
* gtk/stock-icons/Makefile.am: doh, this was broken beyond believe.
* gtk/gtkbox.c: change property types from (u)long to (u)int for
::position and ::padding.
* gtk/gtkcontainer.c: make ::border_width an INT property.
* gtk/gtkpacker.c: make ::position an INT property.
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_adjustment_changed):
guard against NULL h/v scrollbars, since this is used at construction
time.
* gtk/gtkclist.[hc]: nuked gtk_clist_construct(), implemented
internal gtk_clist_constructor().
* gtk/gtkctree.[hc]: nuked gtk_ctree_construct(), implemented
gtk_ctree_constructor().
* gtk/gtkprogressbar.c (gtk_progress_bar_class_init): property
::pulse_step should use ARG_PULSE_STEP, not ARG_FRACTION.
* docs/reference/Makefile.am: fun stuff, disabled docs generation
again, gtk-scan.c needs to introspec paramspecs, not GtkAgs.
* gtk/gtkwidget.[hc]:
removed gtk_widget_setv(), gtk_widget_getv(), gtk_widget_newv()
and gtk_widget_get().
(gtk_widget_new): use g_object_new_valist().
(gtk_widget_set): use g_object_set_valist().
* gtk/gtkobject.[hc]:
removed gtk_object_arg_get_info(), gtk_object_getv(),
gtk_object_query_args(), gtk_object_newv(),
gtk_object_class_add_signals(),
gtk_object_class_user_signal_new(),
gtk_object_class_user_signal_newv(),
gtk_object_arg_set(), gtk_object_arg_get(),
gtk_object_args_collect(),
gtk_object_default_construct(),
gtk_object_constructed(),
GTK_CONSTRUCTED and GTK_OBJECT_CONSTRUCTED().
removed nsignals, signals and n_args members from GtkObjectClass.
(gtk_object_new): use g_object_new_valist().
(gtk_object_set): use g_object_set_valist().
(gtk_object_get): use g_object_get_valist().
* gtk/gtkcompat.h: define gtk_object_default_construct().
* gtk/gtktypeutils.c (gtk_type_new): create constructed objects via
g_object_new().
* gtk/*.c: removed gtk_object_class_add_signals() from class_init()
fucntions, cleaned up method assignments (make sure your structures
are setup properly before calling out). removed all GTK_CONSTRUCTED
hacks ;)
2000-12-13 01:34:41 +00:00
|
|
|
toggle_button_signals[TOGGLED] =
|
2005-09-01 05:11:46 +00:00
|
|
|
g_signal_new (I_("toggled"),
|
2002-10-11 22:57:11 +00:00
|
|
|
G_OBJECT_CLASS_TYPE (gobject_class),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GtkToggleButtonClass, toggled),
|
|
|
|
NULL, NULL,
|
|
|
|
_gtk_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
2010-10-19 16:18:02 +00:00
|
|
|
|
|
|
|
g_type_class_add_private (class, sizeof (GtkToggleButtonPrivate));
|
2011-06-28 04:53:22 +00:00
|
|
|
|
|
|
|
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_toggle_button_init (GtkToggleButton *toggle_button)
|
|
|
|
{
|
2010-10-19 16:18:02 +00:00
|
|
|
GtkToggleButtonPrivate *priv;
|
|
|
|
|
|
|
|
toggle_button->priv = G_TYPE_INSTANCE_GET_PRIVATE (toggle_button,
|
|
|
|
GTK_TYPE_TOGGLE_BUTTON,
|
|
|
|
GtkToggleButtonPrivate);
|
|
|
|
priv = toggle_button->priv;
|
|
|
|
|
|
|
|
priv->active = FALSE;
|
|
|
|
priv->draw_indicator = FALSE;
|
2010-10-19 00:01:31 +00:00
|
|
|
GTK_BUTTON (toggle_button)->priv->depress_on_activate = TRUE;
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
2009-02-22 05:20:14 +00:00
|
|
|
static void
|
|
|
|
gtk_toggle_button_activatable_interface_init (GtkActivatableIface *iface)
|
2009-01-23 15:15:28 +00:00
|
|
|
{
|
|
|
|
parent_activatable_iface = g_type_interface_peek_parent (iface);
|
2009-02-22 05:20:14 +00:00
|
|
|
iface->update = gtk_toggle_button_update;
|
|
|
|
iface->sync_action_properties = gtk_toggle_button_sync_action_properties;
|
2009-01-23 15:15:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-02-22 05:20:14 +00:00
|
|
|
gtk_toggle_button_update (GtkActivatable *activatable,
|
|
|
|
GtkAction *action,
|
|
|
|
const gchar *property_name)
|
2009-01-23 15:15:28 +00:00
|
|
|
{
|
|
|
|
GtkToggleButton *button;
|
|
|
|
|
|
|
|
parent_activatable_iface->update (activatable, action, property_name);
|
|
|
|
|
|
|
|
button = GTK_TOGGLE_BUTTON (activatable);
|
|
|
|
|
|
|
|
if (strcmp (property_name, "active") == 0)
|
|
|
|
{
|
|
|
|
gtk_action_block_activate (action);
|
|
|
|
gtk_toggle_button_set_active (button, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
|
|
|
|
gtk_action_unblock_activate (action);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-02-22 05:20:14 +00:00
|
|
|
gtk_toggle_button_sync_action_properties (GtkActivatable *activatable,
|
|
|
|
GtkAction *action)
|
2009-01-23 15:15:28 +00:00
|
|
|
{
|
|
|
|
GtkToggleButton *button;
|
|
|
|
|
2009-02-22 05:20:14 +00:00
|
|
|
parent_activatable_iface->sync_action_properties (activatable, action);
|
2009-01-23 15:15:28 +00:00
|
|
|
|
2009-02-07 03:17:43 +00:00
|
|
|
if (!GTK_IS_TOGGLE_ACTION (action))
|
2009-01-23 15:15:28 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
button = GTK_TOGGLE_BUTTON (activatable);
|
|
|
|
|
|
|
|
gtk_action_block_activate (action);
|
|
|
|
gtk_toggle_button_set_active (button, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
|
|
|
|
gtk_action_unblock_activate (action);
|
|
|
|
}
|
|
|
|
|
2011-04-17 23:24:56 +00:00
|
|
|
/**
|
|
|
|
* gtk_toggle_button_new:
|
|
|
|
*
|
|
|
|
* Creates a new toggle button. A widget should be packed into the button, as in gtk_button_new().
|
|
|
|
*
|
|
|
|
* Returns: a new toggle button.
|
|
|
|
*/
|
1997-11-24 22:37:52 +00:00
|
|
|
GtkWidget*
|
1998-05-03 22:41:32 +00:00
|
|
|
gtk_toggle_button_new (void)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2002-10-11 22:57:11 +00:00
|
|
|
return g_object_new (GTK_TYPE_TOGGLE_BUTTON, NULL);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
2011-04-17 23:24:56 +00:00
|
|
|
/**
|
|
|
|
* gtk_toggle_button_new_with_label:
|
|
|
|
* @label: a string containing the message to be placed in the toggle button.
|
|
|
|
*
|
|
|
|
* Creates a new toggle button with a text label.
|
|
|
|
*
|
|
|
|
* Returns: a new toggle button.
|
|
|
|
*/
|
1997-11-24 22:37:52 +00:00
|
|
|
GtkWidget*
|
|
|
|
gtk_toggle_button_new_with_label (const gchar *label)
|
|
|
|
{
|
2001-08-27 01:05:07 +00:00
|
|
|
return g_object_new (GTK_TYPE_TOGGLE_BUTTON, "label", label, NULL);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
2001-06-05 18:22:30 +00:00
|
|
|
/**
|
|
|
|
* gtk_toggle_button_new_with_mnemonic:
|
|
|
|
* @label: the text of the button, with an underscore in front of the
|
|
|
|
* mnemonic character
|
|
|
|
*
|
|
|
|
* Creates a new #GtkToggleButton containing a label. The label
|
|
|
|
* will be created using gtk_label_new_with_mnemonic(), so underscores
|
|
|
|
* in @label indicate the mnemonic for the button.
|
2011-09-26 00:58:59 +00:00
|
|
|
*
|
|
|
|
* Returns: a new #GtkToggleButton
|
|
|
|
*/
|
2001-06-05 18:22:30 +00:00
|
|
|
GtkWidget*
|
|
|
|
gtk_toggle_button_new_with_mnemonic (const gchar *label)
|
|
|
|
{
|
2005-03-26 05:49:15 +00:00
|
|
|
return g_object_new (GTK_TYPE_TOGGLE_BUTTON,
|
|
|
|
"label", label,
|
|
|
|
"use-underline", TRUE,
|
|
|
|
NULL);
|
2001-06-05 18:22:30 +00:00
|
|
|
}
|
|
|
|
|
new function gtk_container_child_arg_set, similar to
Wed Jun 24 14:14:32 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c: new function gtk_container_child_arg_set, similar
to gtk_container_child_arg_setv, but takes a variable argument list.
new function gtk_container_get_child_arg_type, which is needed by
gtk_object_collect_args.
* gtk/gtkobject.c: changed prototype for gtk_object_collect_args, to
take a function pointer to figure the argument type.
adapted callers to pass gtk_object_get_arg_type.
* gtk/gtkwidget.c: adapted gtk_object_collect_args callers to pass
gtk_object_get_arg_type..
* gtk/gtkpacker.h:
* gtk/gtkpacker.c:
(gtk_packer_reorder_child): new function to change the packing order
of a child.
(gtk_packer_size_request):
(gtk_packer_size_allocate): take container->border_width into acount.
* gtk/gtkpacker.c: implemented widget arguments:
"GtkPacker::spacing", "GtkPacker::border_width", "GtkPacker::pad_x",
"GtkPacker::pad_y", "GtkPacker::ipad_x", "GtkPacker::ipad_y".
implemented child arguments:
"GtkPacker::side", "GtkPacker::anchor", "GtkPacker::expand",
"GtkPacker::fill_x", "GtkPacker::fill_y", "GtkPacker::use_default",
"GtkPacker::border_width", "GtkPacker::pad_x", "GtkPacker::pad_y",
"GtkPacker::ipad_x", "GtkPacker::ipad_y", "GtkPacker::position".
* gtk/gtkmisc.c (gtk_misc_set_arg): for padding args, set the padding,
not the alignment.
* gtk/gtkeventbox.h:
* gtk/gtkeventbox.c: GtkType and macro fixups.
* gtk/testgtk.c (entry_toggle_sensitive): new function to toggle
sensitivity of an entry.
* gtk/gtkstyle.c (gtk_style_new): support normal grey as default color
for insensitive base.
* gtk/gtkentry.c (gtk_entry_realize): set the window backgrounds
widget state dependent.
(gtk_entry_style_set): likewise.
(gtk_entry_state_changed): set background color on state changes.
(gtk_entry_draw_text): for non selected text, use state dependent
colors.
* gtk/gtktogglebutton.c: support for widget arguments
"GtkToggleButton::active" and "GtkToggleButton::draw_indicator".
1998-06-24 12:22:23 +00:00
|
|
|
static void
|
2001-05-13 22:41:30 +00:00
|
|
|
gtk_toggle_button_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
new function gtk_container_child_arg_set, similar to
Wed Jun 24 14:14:32 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c: new function gtk_container_child_arg_set, similar
to gtk_container_child_arg_setv, but takes a variable argument list.
new function gtk_container_get_child_arg_type, which is needed by
gtk_object_collect_args.
* gtk/gtkobject.c: changed prototype for gtk_object_collect_args, to
take a function pointer to figure the argument type.
adapted callers to pass gtk_object_get_arg_type.
* gtk/gtkwidget.c: adapted gtk_object_collect_args callers to pass
gtk_object_get_arg_type..
* gtk/gtkpacker.h:
* gtk/gtkpacker.c:
(gtk_packer_reorder_child): new function to change the packing order
of a child.
(gtk_packer_size_request):
(gtk_packer_size_allocate): take container->border_width into acount.
* gtk/gtkpacker.c: implemented widget arguments:
"GtkPacker::spacing", "GtkPacker::border_width", "GtkPacker::pad_x",
"GtkPacker::pad_y", "GtkPacker::ipad_x", "GtkPacker::ipad_y".
implemented child arguments:
"GtkPacker::side", "GtkPacker::anchor", "GtkPacker::expand",
"GtkPacker::fill_x", "GtkPacker::fill_y", "GtkPacker::use_default",
"GtkPacker::border_width", "GtkPacker::pad_x", "GtkPacker::pad_y",
"GtkPacker::ipad_x", "GtkPacker::ipad_y", "GtkPacker::position".
* gtk/gtkmisc.c (gtk_misc_set_arg): for padding args, set the padding,
not the alignment.
* gtk/gtkeventbox.h:
* gtk/gtkeventbox.c: GtkType and macro fixups.
* gtk/testgtk.c (entry_toggle_sensitive): new function to toggle
sensitivity of an entry.
* gtk/gtkstyle.c (gtk_style_new): support normal grey as default color
for insensitive base.
* gtk/gtkentry.c (gtk_entry_realize): set the window backgrounds
widget state dependent.
(gtk_entry_style_set): likewise.
(gtk_entry_state_changed): set background color on state changes.
(gtk_entry_draw_text): for non selected text, use state dependent
colors.
* gtk/gtktogglebutton.c: support for widget arguments
"GtkToggleButton::active" and "GtkToggleButton::draw_indicator".
1998-06-24 12:22:23 +00:00
|
|
|
{
|
|
|
|
GtkToggleButton *tb;
|
|
|
|
|
|
|
|
tb = GTK_TOGGLE_BUTTON (object);
|
|
|
|
|
2001-05-13 22:41:30 +00:00
|
|
|
switch (prop_id)
|
new function gtk_container_child_arg_set, similar to
Wed Jun 24 14:14:32 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c: new function gtk_container_child_arg_set, similar
to gtk_container_child_arg_setv, but takes a variable argument list.
new function gtk_container_get_child_arg_type, which is needed by
gtk_object_collect_args.
* gtk/gtkobject.c: changed prototype for gtk_object_collect_args, to
take a function pointer to figure the argument type.
adapted callers to pass gtk_object_get_arg_type.
* gtk/gtkwidget.c: adapted gtk_object_collect_args callers to pass
gtk_object_get_arg_type..
* gtk/gtkpacker.h:
* gtk/gtkpacker.c:
(gtk_packer_reorder_child): new function to change the packing order
of a child.
(gtk_packer_size_request):
(gtk_packer_size_allocate): take container->border_width into acount.
* gtk/gtkpacker.c: implemented widget arguments:
"GtkPacker::spacing", "GtkPacker::border_width", "GtkPacker::pad_x",
"GtkPacker::pad_y", "GtkPacker::ipad_x", "GtkPacker::ipad_y".
implemented child arguments:
"GtkPacker::side", "GtkPacker::anchor", "GtkPacker::expand",
"GtkPacker::fill_x", "GtkPacker::fill_y", "GtkPacker::use_default",
"GtkPacker::border_width", "GtkPacker::pad_x", "GtkPacker::pad_y",
"GtkPacker::ipad_x", "GtkPacker::ipad_y", "GtkPacker::position".
* gtk/gtkmisc.c (gtk_misc_set_arg): for padding args, set the padding,
not the alignment.
* gtk/gtkeventbox.h:
* gtk/gtkeventbox.c: GtkType and macro fixups.
* gtk/testgtk.c (entry_toggle_sensitive): new function to toggle
sensitivity of an entry.
* gtk/gtkstyle.c (gtk_style_new): support normal grey as default color
for insensitive base.
* gtk/gtkentry.c (gtk_entry_realize): set the window backgrounds
widget state dependent.
(gtk_entry_style_set): likewise.
(gtk_entry_state_changed): set background color on state changes.
(gtk_entry_draw_text): for non selected text, use state dependent
colors.
* gtk/gtktogglebutton.c: support for widget arguments
"GtkToggleButton::active" and "GtkToggleButton::draw_indicator".
1998-06-24 12:22:23 +00:00
|
|
|
{
|
2001-05-13 22:41:30 +00:00
|
|
|
case PROP_ACTIVE:
|
|
|
|
gtk_toggle_button_set_active (tb, g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
case PROP_INCONSISTENT:
|
|
|
|
gtk_toggle_button_set_inconsistent (tb, g_value_get_boolean (value));
|
new function gtk_container_child_arg_set, similar to
Wed Jun 24 14:14:32 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c: new function gtk_container_child_arg_set, similar
to gtk_container_child_arg_setv, but takes a variable argument list.
new function gtk_container_get_child_arg_type, which is needed by
gtk_object_collect_args.
* gtk/gtkobject.c: changed prototype for gtk_object_collect_args, to
take a function pointer to figure the argument type.
adapted callers to pass gtk_object_get_arg_type.
* gtk/gtkwidget.c: adapted gtk_object_collect_args callers to pass
gtk_object_get_arg_type..
* gtk/gtkpacker.h:
* gtk/gtkpacker.c:
(gtk_packer_reorder_child): new function to change the packing order
of a child.
(gtk_packer_size_request):
(gtk_packer_size_allocate): take container->border_width into acount.
* gtk/gtkpacker.c: implemented widget arguments:
"GtkPacker::spacing", "GtkPacker::border_width", "GtkPacker::pad_x",
"GtkPacker::pad_y", "GtkPacker::ipad_x", "GtkPacker::ipad_y".
implemented child arguments:
"GtkPacker::side", "GtkPacker::anchor", "GtkPacker::expand",
"GtkPacker::fill_x", "GtkPacker::fill_y", "GtkPacker::use_default",
"GtkPacker::border_width", "GtkPacker::pad_x", "GtkPacker::pad_y",
"GtkPacker::ipad_x", "GtkPacker::ipad_y", "GtkPacker::position".
* gtk/gtkmisc.c (gtk_misc_set_arg): for padding args, set the padding,
not the alignment.
* gtk/gtkeventbox.h:
* gtk/gtkeventbox.c: GtkType and macro fixups.
* gtk/testgtk.c (entry_toggle_sensitive): new function to toggle
sensitivity of an entry.
* gtk/gtkstyle.c (gtk_style_new): support normal grey as default color
for insensitive base.
* gtk/gtkentry.c (gtk_entry_realize): set the window backgrounds
widget state dependent.
(gtk_entry_style_set): likewise.
(gtk_entry_state_changed): set background color on state changes.
(gtk_entry_draw_text): for non selected text, use state dependent
colors.
* gtk/gtktogglebutton.c: support for widget arguments
"GtkToggleButton::active" and "GtkToggleButton::draw_indicator".
1998-06-24 12:22:23 +00:00
|
|
|
break;
|
2001-05-13 22:41:30 +00:00
|
|
|
case PROP_DRAW_INDICATOR:
|
|
|
|
gtk_toggle_button_set_mode (tb, g_value_get_boolean (value));
|
new function gtk_container_child_arg_set, similar to
Wed Jun 24 14:14:32 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c: new function gtk_container_child_arg_set, similar
to gtk_container_child_arg_setv, but takes a variable argument list.
new function gtk_container_get_child_arg_type, which is needed by
gtk_object_collect_args.
* gtk/gtkobject.c: changed prototype for gtk_object_collect_args, to
take a function pointer to figure the argument type.
adapted callers to pass gtk_object_get_arg_type.
* gtk/gtkwidget.c: adapted gtk_object_collect_args callers to pass
gtk_object_get_arg_type..
* gtk/gtkpacker.h:
* gtk/gtkpacker.c:
(gtk_packer_reorder_child): new function to change the packing order
of a child.
(gtk_packer_size_request):
(gtk_packer_size_allocate): take container->border_width into acount.
* gtk/gtkpacker.c: implemented widget arguments:
"GtkPacker::spacing", "GtkPacker::border_width", "GtkPacker::pad_x",
"GtkPacker::pad_y", "GtkPacker::ipad_x", "GtkPacker::ipad_y".
implemented child arguments:
"GtkPacker::side", "GtkPacker::anchor", "GtkPacker::expand",
"GtkPacker::fill_x", "GtkPacker::fill_y", "GtkPacker::use_default",
"GtkPacker::border_width", "GtkPacker::pad_x", "GtkPacker::pad_y",
"GtkPacker::ipad_x", "GtkPacker::ipad_y", "GtkPacker::position".
* gtk/gtkmisc.c (gtk_misc_set_arg): for padding args, set the padding,
not the alignment.
* gtk/gtkeventbox.h:
* gtk/gtkeventbox.c: GtkType and macro fixups.
* gtk/testgtk.c (entry_toggle_sensitive): new function to toggle
sensitivity of an entry.
* gtk/gtkstyle.c (gtk_style_new): support normal grey as default color
for insensitive base.
* gtk/gtkentry.c (gtk_entry_realize): set the window backgrounds
widget state dependent.
(gtk_entry_style_set): likewise.
(gtk_entry_state_changed): set background color on state changes.
(gtk_entry_draw_text): for non selected text, use state dependent
colors.
* gtk/gtktogglebutton.c: support for widget arguments
"GtkToggleButton::active" and "GtkToggleButton::draw_indicator".
1998-06-24 12:22:23 +00:00
|
|
|
break;
|
|
|
|
default:
|
2008-01-06 03:28:40 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
new function gtk_container_child_arg_set, similar to
Wed Jun 24 14:14:32 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c: new function gtk_container_child_arg_set, similar
to gtk_container_child_arg_setv, but takes a variable argument list.
new function gtk_container_get_child_arg_type, which is needed by
gtk_object_collect_args.
* gtk/gtkobject.c: changed prototype for gtk_object_collect_args, to
take a function pointer to figure the argument type.
adapted callers to pass gtk_object_get_arg_type.
* gtk/gtkwidget.c: adapted gtk_object_collect_args callers to pass
gtk_object_get_arg_type..
* gtk/gtkpacker.h:
* gtk/gtkpacker.c:
(gtk_packer_reorder_child): new function to change the packing order
of a child.
(gtk_packer_size_request):
(gtk_packer_size_allocate): take container->border_width into acount.
* gtk/gtkpacker.c: implemented widget arguments:
"GtkPacker::spacing", "GtkPacker::border_width", "GtkPacker::pad_x",
"GtkPacker::pad_y", "GtkPacker::ipad_x", "GtkPacker::ipad_y".
implemented child arguments:
"GtkPacker::side", "GtkPacker::anchor", "GtkPacker::expand",
"GtkPacker::fill_x", "GtkPacker::fill_y", "GtkPacker::use_default",
"GtkPacker::border_width", "GtkPacker::pad_x", "GtkPacker::pad_y",
"GtkPacker::ipad_x", "GtkPacker::ipad_y", "GtkPacker::position".
* gtk/gtkmisc.c (gtk_misc_set_arg): for padding args, set the padding,
not the alignment.
* gtk/gtkeventbox.h:
* gtk/gtkeventbox.c: GtkType and macro fixups.
* gtk/testgtk.c (entry_toggle_sensitive): new function to toggle
sensitivity of an entry.
* gtk/gtkstyle.c (gtk_style_new): support normal grey as default color
for insensitive base.
* gtk/gtkentry.c (gtk_entry_realize): set the window backgrounds
widget state dependent.
(gtk_entry_style_set): likewise.
(gtk_entry_state_changed): set background color on state changes.
(gtk_entry_draw_text): for non selected text, use state dependent
colors.
* gtk/gtktogglebutton.c: support for widget arguments
"GtkToggleButton::active" and "GtkToggleButton::draw_indicator".
1998-06-24 12:22:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-05-13 22:41:30 +00:00
|
|
|
gtk_toggle_button_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
new function gtk_container_child_arg_set, similar to
Wed Jun 24 14:14:32 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c: new function gtk_container_child_arg_set, similar
to gtk_container_child_arg_setv, but takes a variable argument list.
new function gtk_container_get_child_arg_type, which is needed by
gtk_object_collect_args.
* gtk/gtkobject.c: changed prototype for gtk_object_collect_args, to
take a function pointer to figure the argument type.
adapted callers to pass gtk_object_get_arg_type.
* gtk/gtkwidget.c: adapted gtk_object_collect_args callers to pass
gtk_object_get_arg_type..
* gtk/gtkpacker.h:
* gtk/gtkpacker.c:
(gtk_packer_reorder_child): new function to change the packing order
of a child.
(gtk_packer_size_request):
(gtk_packer_size_allocate): take container->border_width into acount.
* gtk/gtkpacker.c: implemented widget arguments:
"GtkPacker::spacing", "GtkPacker::border_width", "GtkPacker::pad_x",
"GtkPacker::pad_y", "GtkPacker::ipad_x", "GtkPacker::ipad_y".
implemented child arguments:
"GtkPacker::side", "GtkPacker::anchor", "GtkPacker::expand",
"GtkPacker::fill_x", "GtkPacker::fill_y", "GtkPacker::use_default",
"GtkPacker::border_width", "GtkPacker::pad_x", "GtkPacker::pad_y",
"GtkPacker::ipad_x", "GtkPacker::ipad_y", "GtkPacker::position".
* gtk/gtkmisc.c (gtk_misc_set_arg): for padding args, set the padding,
not the alignment.
* gtk/gtkeventbox.h:
* gtk/gtkeventbox.c: GtkType and macro fixups.
* gtk/testgtk.c (entry_toggle_sensitive): new function to toggle
sensitivity of an entry.
* gtk/gtkstyle.c (gtk_style_new): support normal grey as default color
for insensitive base.
* gtk/gtkentry.c (gtk_entry_realize): set the window backgrounds
widget state dependent.
(gtk_entry_style_set): likewise.
(gtk_entry_state_changed): set background color on state changes.
(gtk_entry_draw_text): for non selected text, use state dependent
colors.
* gtk/gtktogglebutton.c: support for widget arguments
"GtkToggleButton::active" and "GtkToggleButton::draw_indicator".
1998-06-24 12:22:23 +00:00
|
|
|
{
|
2010-10-19 16:18:02 +00:00
|
|
|
GtkToggleButton *tb = GTK_TOGGLE_BUTTON (object);
|
|
|
|
GtkToggleButtonPrivate *priv = tb->priv;
|
new function gtk_container_child_arg_set, similar to
Wed Jun 24 14:14:32 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c: new function gtk_container_child_arg_set, similar
to gtk_container_child_arg_setv, but takes a variable argument list.
new function gtk_container_get_child_arg_type, which is needed by
gtk_object_collect_args.
* gtk/gtkobject.c: changed prototype for gtk_object_collect_args, to
take a function pointer to figure the argument type.
adapted callers to pass gtk_object_get_arg_type.
* gtk/gtkwidget.c: adapted gtk_object_collect_args callers to pass
gtk_object_get_arg_type..
* gtk/gtkpacker.h:
* gtk/gtkpacker.c:
(gtk_packer_reorder_child): new function to change the packing order
of a child.
(gtk_packer_size_request):
(gtk_packer_size_allocate): take container->border_width into acount.
* gtk/gtkpacker.c: implemented widget arguments:
"GtkPacker::spacing", "GtkPacker::border_width", "GtkPacker::pad_x",
"GtkPacker::pad_y", "GtkPacker::ipad_x", "GtkPacker::ipad_y".
implemented child arguments:
"GtkPacker::side", "GtkPacker::anchor", "GtkPacker::expand",
"GtkPacker::fill_x", "GtkPacker::fill_y", "GtkPacker::use_default",
"GtkPacker::border_width", "GtkPacker::pad_x", "GtkPacker::pad_y",
"GtkPacker::ipad_x", "GtkPacker::ipad_y", "GtkPacker::position".
* gtk/gtkmisc.c (gtk_misc_set_arg): for padding args, set the padding,
not the alignment.
* gtk/gtkeventbox.h:
* gtk/gtkeventbox.c: GtkType and macro fixups.
* gtk/testgtk.c (entry_toggle_sensitive): new function to toggle
sensitivity of an entry.
* gtk/gtkstyle.c (gtk_style_new): support normal grey as default color
for insensitive base.
* gtk/gtkentry.c (gtk_entry_realize): set the window backgrounds
widget state dependent.
(gtk_entry_style_set): likewise.
(gtk_entry_state_changed): set background color on state changes.
(gtk_entry_draw_text): for non selected text, use state dependent
colors.
* gtk/gtktogglebutton.c: support for widget arguments
"GtkToggleButton::active" and "GtkToggleButton::draw_indicator".
1998-06-24 12:22:23 +00:00
|
|
|
|
2001-05-13 22:41:30 +00:00
|
|
|
switch (prop_id)
|
new function gtk_container_child_arg_set, similar to
Wed Jun 24 14:14:32 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c: new function gtk_container_child_arg_set, similar
to gtk_container_child_arg_setv, but takes a variable argument list.
new function gtk_container_get_child_arg_type, which is needed by
gtk_object_collect_args.
* gtk/gtkobject.c: changed prototype for gtk_object_collect_args, to
take a function pointer to figure the argument type.
adapted callers to pass gtk_object_get_arg_type.
* gtk/gtkwidget.c: adapted gtk_object_collect_args callers to pass
gtk_object_get_arg_type..
* gtk/gtkpacker.h:
* gtk/gtkpacker.c:
(gtk_packer_reorder_child): new function to change the packing order
of a child.
(gtk_packer_size_request):
(gtk_packer_size_allocate): take container->border_width into acount.
* gtk/gtkpacker.c: implemented widget arguments:
"GtkPacker::spacing", "GtkPacker::border_width", "GtkPacker::pad_x",
"GtkPacker::pad_y", "GtkPacker::ipad_x", "GtkPacker::ipad_y".
implemented child arguments:
"GtkPacker::side", "GtkPacker::anchor", "GtkPacker::expand",
"GtkPacker::fill_x", "GtkPacker::fill_y", "GtkPacker::use_default",
"GtkPacker::border_width", "GtkPacker::pad_x", "GtkPacker::pad_y",
"GtkPacker::ipad_x", "GtkPacker::ipad_y", "GtkPacker::position".
* gtk/gtkmisc.c (gtk_misc_set_arg): for padding args, set the padding,
not the alignment.
* gtk/gtkeventbox.h:
* gtk/gtkeventbox.c: GtkType and macro fixups.
* gtk/testgtk.c (entry_toggle_sensitive): new function to toggle
sensitivity of an entry.
* gtk/gtkstyle.c (gtk_style_new): support normal grey as default color
for insensitive base.
* gtk/gtkentry.c (gtk_entry_realize): set the window backgrounds
widget state dependent.
(gtk_entry_style_set): likewise.
(gtk_entry_state_changed): set background color on state changes.
(gtk_entry_draw_text): for non selected text, use state dependent
colors.
* gtk/gtktogglebutton.c: support for widget arguments
"GtkToggleButton::active" and "GtkToggleButton::draw_indicator".
1998-06-24 12:22:23 +00:00
|
|
|
{
|
2001-05-13 22:41:30 +00:00
|
|
|
case PROP_ACTIVE:
|
2010-10-19 16:18:02 +00:00
|
|
|
g_value_set_boolean (value, priv->active);
|
2001-05-13 22:41:30 +00:00
|
|
|
break;
|
|
|
|
case PROP_INCONSISTENT:
|
2010-10-19 16:18:02 +00:00
|
|
|
g_value_set_boolean (value, priv->inconsistent);
|
new function gtk_container_child_arg_set, similar to
Wed Jun 24 14:14:32 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c: new function gtk_container_child_arg_set, similar
to gtk_container_child_arg_setv, but takes a variable argument list.
new function gtk_container_get_child_arg_type, which is needed by
gtk_object_collect_args.
* gtk/gtkobject.c: changed prototype for gtk_object_collect_args, to
take a function pointer to figure the argument type.
adapted callers to pass gtk_object_get_arg_type.
* gtk/gtkwidget.c: adapted gtk_object_collect_args callers to pass
gtk_object_get_arg_type..
* gtk/gtkpacker.h:
* gtk/gtkpacker.c:
(gtk_packer_reorder_child): new function to change the packing order
of a child.
(gtk_packer_size_request):
(gtk_packer_size_allocate): take container->border_width into acount.
* gtk/gtkpacker.c: implemented widget arguments:
"GtkPacker::spacing", "GtkPacker::border_width", "GtkPacker::pad_x",
"GtkPacker::pad_y", "GtkPacker::ipad_x", "GtkPacker::ipad_y".
implemented child arguments:
"GtkPacker::side", "GtkPacker::anchor", "GtkPacker::expand",
"GtkPacker::fill_x", "GtkPacker::fill_y", "GtkPacker::use_default",
"GtkPacker::border_width", "GtkPacker::pad_x", "GtkPacker::pad_y",
"GtkPacker::ipad_x", "GtkPacker::ipad_y", "GtkPacker::position".
* gtk/gtkmisc.c (gtk_misc_set_arg): for padding args, set the padding,
not the alignment.
* gtk/gtkeventbox.h:
* gtk/gtkeventbox.c: GtkType and macro fixups.
* gtk/testgtk.c (entry_toggle_sensitive): new function to toggle
sensitivity of an entry.
* gtk/gtkstyle.c (gtk_style_new): support normal grey as default color
for insensitive base.
* gtk/gtkentry.c (gtk_entry_realize): set the window backgrounds
widget state dependent.
(gtk_entry_style_set): likewise.
(gtk_entry_state_changed): set background color on state changes.
(gtk_entry_draw_text): for non selected text, use state dependent
colors.
* gtk/gtktogglebutton.c: support for widget arguments
"GtkToggleButton::active" and "GtkToggleButton::draw_indicator".
1998-06-24 12:22:23 +00:00
|
|
|
break;
|
2001-05-13 22:41:30 +00:00
|
|
|
case PROP_DRAW_INDICATOR:
|
2010-10-19 16:18:02 +00:00
|
|
|
g_value_set_boolean (value, priv->draw_indicator);
|
new function gtk_container_child_arg_set, similar to
Wed Jun 24 14:14:32 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c: new function gtk_container_child_arg_set, similar
to gtk_container_child_arg_setv, but takes a variable argument list.
new function gtk_container_get_child_arg_type, which is needed by
gtk_object_collect_args.
* gtk/gtkobject.c: changed prototype for gtk_object_collect_args, to
take a function pointer to figure the argument type.
adapted callers to pass gtk_object_get_arg_type.
* gtk/gtkwidget.c: adapted gtk_object_collect_args callers to pass
gtk_object_get_arg_type..
* gtk/gtkpacker.h:
* gtk/gtkpacker.c:
(gtk_packer_reorder_child): new function to change the packing order
of a child.
(gtk_packer_size_request):
(gtk_packer_size_allocate): take container->border_width into acount.
* gtk/gtkpacker.c: implemented widget arguments:
"GtkPacker::spacing", "GtkPacker::border_width", "GtkPacker::pad_x",
"GtkPacker::pad_y", "GtkPacker::ipad_x", "GtkPacker::ipad_y".
implemented child arguments:
"GtkPacker::side", "GtkPacker::anchor", "GtkPacker::expand",
"GtkPacker::fill_x", "GtkPacker::fill_y", "GtkPacker::use_default",
"GtkPacker::border_width", "GtkPacker::pad_x", "GtkPacker::pad_y",
"GtkPacker::ipad_x", "GtkPacker::ipad_y", "GtkPacker::position".
* gtk/gtkmisc.c (gtk_misc_set_arg): for padding args, set the padding,
not the alignment.
* gtk/gtkeventbox.h:
* gtk/gtkeventbox.c: GtkType and macro fixups.
* gtk/testgtk.c (entry_toggle_sensitive): new function to toggle
sensitivity of an entry.
* gtk/gtkstyle.c (gtk_style_new): support normal grey as default color
for insensitive base.
* gtk/gtkentry.c (gtk_entry_realize): set the window backgrounds
widget state dependent.
(gtk_entry_style_set): likewise.
(gtk_entry_state_changed): set background color on state changes.
(gtk_entry_draw_text): for non selected text, use state dependent
colors.
* gtk/gtktogglebutton.c: support for widget arguments
"GtkToggleButton::active" and "GtkToggleButton::draw_indicator".
1998-06-24 12:22:23 +00:00
|
|
|
break;
|
|
|
|
default:
|
2001-05-13 22:41:30 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
new function gtk_container_child_arg_set, similar to
Wed Jun 24 14:14:32 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c: new function gtk_container_child_arg_set, similar
to gtk_container_child_arg_setv, but takes a variable argument list.
new function gtk_container_get_child_arg_type, which is needed by
gtk_object_collect_args.
* gtk/gtkobject.c: changed prototype for gtk_object_collect_args, to
take a function pointer to figure the argument type.
adapted callers to pass gtk_object_get_arg_type.
* gtk/gtkwidget.c: adapted gtk_object_collect_args callers to pass
gtk_object_get_arg_type..
* gtk/gtkpacker.h:
* gtk/gtkpacker.c:
(gtk_packer_reorder_child): new function to change the packing order
of a child.
(gtk_packer_size_request):
(gtk_packer_size_allocate): take container->border_width into acount.
* gtk/gtkpacker.c: implemented widget arguments:
"GtkPacker::spacing", "GtkPacker::border_width", "GtkPacker::pad_x",
"GtkPacker::pad_y", "GtkPacker::ipad_x", "GtkPacker::ipad_y".
implemented child arguments:
"GtkPacker::side", "GtkPacker::anchor", "GtkPacker::expand",
"GtkPacker::fill_x", "GtkPacker::fill_y", "GtkPacker::use_default",
"GtkPacker::border_width", "GtkPacker::pad_x", "GtkPacker::pad_y",
"GtkPacker::ipad_x", "GtkPacker::ipad_y", "GtkPacker::position".
* gtk/gtkmisc.c (gtk_misc_set_arg): for padding args, set the padding,
not the alignment.
* gtk/gtkeventbox.h:
* gtk/gtkeventbox.c: GtkType and macro fixups.
* gtk/testgtk.c (entry_toggle_sensitive): new function to toggle
sensitivity of an entry.
* gtk/gtkstyle.c (gtk_style_new): support normal grey as default color
for insensitive base.
* gtk/gtkentry.c (gtk_entry_realize): set the window backgrounds
widget state dependent.
(gtk_entry_style_set): likewise.
(gtk_entry_state_changed): set background color on state changes.
(gtk_entry_draw_text): for non selected text, use state dependent
colors.
* gtk/gtktogglebutton.c: support for widget arguments
"GtkToggleButton::active" and "GtkToggleButton::draw_indicator".
1998-06-24 12:22:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-01 12:34:21 +00:00
|
|
|
/**
|
|
|
|
* gtk_toggle_button_set_mode:
|
|
|
|
* @toggle_button: a #GtkToggleButton
|
|
|
|
* @draw_indicator: if %TRUE, draw the button as a separate indicator
|
|
|
|
* and label; if %FALSE, draw the button like a normal button
|
|
|
|
*
|
|
|
|
* Sets whether the button is displayed as a separate indicator and label.
|
|
|
|
* You can call this function on a checkbutton or a radiobutton with
|
|
|
|
* @draw_indicator = %FALSE to make the button look like a normal button
|
|
|
|
*
|
2005-01-24 17:42:58 +00:00
|
|
|
* This function only affects instances of classes like #GtkCheckButton
|
2002-09-01 12:34:21 +00:00
|
|
|
* and #GtkRadioButton that derive from #GtkToggleButton,
|
|
|
|
* not instances of #GtkToggleButton itself.
|
|
|
|
*/
|
1997-11-24 22:37:52 +00:00
|
|
|
void
|
|
|
|
gtk_toggle_button_set_mode (GtkToggleButton *toggle_button,
|
1999-01-11 18:49:54 +00:00
|
|
|
gboolean draw_indicator)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2010-10-19 16:18:02 +00:00
|
|
|
GtkToggleButtonPrivate *priv;
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button));
|
|
|
|
|
2010-10-19 16:18:02 +00:00
|
|
|
priv = toggle_button->priv;
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
draw_indicator = draw_indicator ? TRUE : FALSE;
|
|
|
|
|
2010-10-19 16:18:02 +00:00
|
|
|
if (priv->draw_indicator != draw_indicator)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2010-11-19 18:56:25 +00:00
|
|
|
GtkStyleContext *context;
|
|
|
|
|
2010-10-19 16:18:02 +00:00
|
|
|
priv->draw_indicator = draw_indicator;
|
2010-10-19 00:01:31 +00:00
|
|
|
GTK_BUTTON (toggle_button)->priv->depress_on_activate = !draw_indicator;
|
|
|
|
|
2010-03-01 06:47:38 +00:00
|
|
|
if (gtk_widget_get_visible (GTK_WIDGET (toggle_button)))
|
1997-11-24 22:37:52 +00:00
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (toggle_button));
|
2001-05-13 22:41:30 +00:00
|
|
|
|
2005-03-26 05:49:15 +00:00
|
|
|
g_object_notify (G_OBJECT (toggle_button), "draw-indicator");
|
2010-11-19 18:56:25 +00:00
|
|
|
|
|
|
|
/* Make toggle buttons conditionally have the "button"
|
|
|
|
* class depending on draw_indicator.
|
|
|
|
*/
|
|
|
|
context = gtk_widget_get_style_context (GTK_WIDGET (toggle_button));
|
|
|
|
|
|
|
|
if (draw_indicator)
|
|
|
|
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BUTTON);
|
|
|
|
else
|
|
|
|
gtk_style_context_add_class (context, GTK_STYLE_CLASS_BUTTON);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-24 15:34:48 +00:00
|
|
|
/**
|
|
|
|
* gtk_toggle_button_get_mode:
|
|
|
|
* @toggle_button: a #GtkToggleButton
|
|
|
|
*
|
|
|
|
* Retrieves whether the button is displayed as a separate indicator
|
|
|
|
* and label. See gtk_toggle_button_set_mode().
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the togglebutton is drawn as a separate indicator
|
|
|
|
* and label.
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gtk_toggle_button_get_mode (GtkToggleButton *toggle_button)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button), FALSE);
|
|
|
|
|
2010-10-19 16:18:02 +00:00
|
|
|
return toggle_button->priv->draw_indicator;
|
2001-06-24 15:34:48 +00:00
|
|
|
}
|
1999-01-21 00:37:48 +00:00
|
|
|
|
2011-04-17 23:24:56 +00:00
|
|
|
/**
|
|
|
|
* gtk_toggle_button_set_active:
|
|
|
|
* @toggle_button: a #GtkToggleButton.
|
|
|
|
* @is_active: %TRUE or %FALSE.
|
|
|
|
*
|
|
|
|
* Sets the status of the toggle button. Set to %TRUE if you want the
|
|
|
|
* GtkToggleButton to be 'pressed in', and %FALSE to raise it.
|
|
|
|
* This action causes the toggled signal to be emitted.
|
|
|
|
*/
|
1997-11-24 22:37:52 +00:00
|
|
|
void
|
1999-01-11 18:49:54 +00:00
|
|
|
gtk_toggle_button_set_active (GtkToggleButton *toggle_button,
|
|
|
|
gboolean is_active)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2010-10-19 16:18:02 +00:00
|
|
|
GtkToggleButtonPrivate *priv;
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button));
|
|
|
|
|
2010-10-19 16:18:02 +00:00
|
|
|
priv = toggle_button->priv;
|
|
|
|
|
2001-05-13 22:41:30 +00:00
|
|
|
is_active = is_active != FALSE;
|
1999-01-11 18:49:54 +00:00
|
|
|
|
2010-10-19 16:18:02 +00:00
|
|
|
if (priv->active != is_active)
|
1997-11-24 22:37:52 +00:00
|
|
|
gtk_button_clicked (GTK_BUTTON (toggle_button));
|
|
|
|
}
|
|
|
|
|
2010-10-19 16:21:56 +00:00
|
|
|
void
|
|
|
|
_gtk_toggle_button_set_active (GtkToggleButton *toggle_button,
|
|
|
|
gboolean is_active)
|
|
|
|
{
|
2010-10-19 16:18:02 +00:00
|
|
|
toggle_button->priv->active = is_active;
|
2010-10-19 16:21:56 +00:00
|
|
|
}
|
|
|
|
|
2011-04-17 23:24:56 +00:00
|
|
|
/**
|
|
|
|
* gtk_toggle_button_get_active:
|
|
|
|
* @toggle_button: a #GtkToggleButton.
|
|
|
|
*
|
|
|
|
* Queries a #GtkToggleButton and returns its current state. Returns %TRUE if
|
|
|
|
* the toggle button is pressed in and %FALSE if it is raised.
|
|
|
|
*
|
|
|
|
* Returns: a #gboolean value.
|
|
|
|
*/
|
1999-01-21 00:37:48 +00:00
|
|
|
gboolean
|
|
|
|
gtk_toggle_button_get_active (GtkToggleButton *toggle_button)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button), FALSE);
|
|
|
|
|
2010-10-19 16:18:02 +00:00
|
|
|
return toggle_button->priv->active;
|
1999-01-21 00:37:48 +00:00
|
|
|
}
|
|
|
|
|
2011-04-17 23:24:56 +00:00
|
|
|
/**
|
|
|
|
* gtk_toggle_button_toggled:
|
|
|
|
* @toggle_button: a #GtkToggleButton.
|
|
|
|
*
|
|
|
|
* Emits the #GtkToggleButton::toggled signal on the
|
|
|
|
* #GtkToggleButton. There is no good reason for an
|
|
|
|
* application ever to call this function.
|
|
|
|
*/
|
1997-11-24 22:37:52 +00:00
|
|
|
void
|
|
|
|
gtk_toggle_button_toggled (GtkToggleButton *toggle_button)
|
|
|
|
{
|
1999-01-11 18:49:54 +00:00
|
|
|
g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button));
|
|
|
|
|
2002-10-11 22:57:11 +00:00
|
|
|
g_signal_emit (toggle_button, toggle_button_signals[TOGGLED], 0);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
2001-02-19 22:25:30 +00:00
|
|
|
/**
|
|
|
|
* gtk_toggle_button_set_inconsistent:
|
|
|
|
* @toggle_button: a #GtkToggleButton
|
|
|
|
* @setting: %TRUE if state is inconsistent
|
|
|
|
*
|
|
|
|
* If the user has selected a range of elements (such as some text or
|
|
|
|
* spreadsheet cells) that are affected by a toggle button, and the
|
|
|
|
* current values in that range are inconsistent, you may want to
|
|
|
|
* display the toggle in an "in between" state. This function turns on
|
|
|
|
* "in between" display. Normally you would turn off the inconsistent
|
|
|
|
* state again if the user toggles the toggle button. This has to be
|
|
|
|
* done manually, gtk_toggle_button_set_inconsistent() only affects
|
|
|
|
* visual appearance, it doesn't affect the semantics of the button.
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gtk_toggle_button_set_inconsistent (GtkToggleButton *toggle_button,
|
|
|
|
gboolean setting)
|
|
|
|
{
|
2010-10-19 16:18:02 +00:00
|
|
|
GtkToggleButtonPrivate *priv;
|
|
|
|
|
2001-02-19 22:25:30 +00:00
|
|
|
g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button));
|
2010-10-19 16:18:02 +00:00
|
|
|
|
|
|
|
priv = toggle_button->priv;
|
|
|
|
|
2001-02-19 22:25:30 +00:00
|
|
|
setting = setting != FALSE;
|
|
|
|
|
2010-10-19 16:18:02 +00:00
|
|
|
if (setting != priv->inconsistent)
|
2001-02-19 22:25:30 +00:00
|
|
|
{
|
2010-10-19 16:18:02 +00:00
|
|
|
priv->inconsistent = setting;
|
|
|
|
|
2001-08-25 23:11:46 +00:00
|
|
|
gtk_toggle_button_update_state (GTK_BUTTON (toggle_button));
|
2001-02-19 22:25:30 +00:00
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (toggle_button));
|
2001-05-13 22:41:30 +00:00
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (toggle_button), "inconsistent");
|
2001-02-19 22:25:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_toggle_button_get_inconsistent:
|
|
|
|
* @toggle_button: a #GtkToggleButton
|
|
|
|
*
|
|
|
|
* Gets the value set by gtk_toggle_button_set_inconsistent().
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the button is displayed as inconsistent, %FALSE otherwise
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gtk_toggle_button_get_inconsistent (GtkToggleButton *toggle_button)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button), FALSE);
|
|
|
|
|
2010-10-19 16:18:02 +00:00
|
|
|
return toggle_button->priv->inconsistent;
|
2001-02-19 22:25:30 +00:00
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2001-12-04 03:27:30 +00:00
|
|
|
static gint
|
2010-09-07 22:23:04 +00:00
|
|
|
gtk_toggle_button_draw (GtkWidget *widget,
|
|
|
|
cairo_t *cr)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2010-10-19 16:18:02 +00:00
|
|
|
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (widget);
|
|
|
|
GtkToggleButtonPrivate *priv = toggle_button->priv;
|
2010-09-07 22:23:04 +00:00
|
|
|
GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
|
|
|
|
GtkButton *button = GTK_BUTTON (widget);
|
2011-01-10 01:26:28 +00:00
|
|
|
GtkStateType state;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2011-01-10 01:26:28 +00:00
|
|
|
state = gtk_widget_get_state_flags (widget);
|
2010-10-19 16:18:02 +00:00
|
|
|
|
|
|
|
if (priv->inconsistent)
|
2011-01-10 01:26:28 +00:00
|
|
|
state |= GTK_STATE_FLAG_INCONSISTENT;
|
|
|
|
else if (button->priv->depressed)
|
|
|
|
state |= GTK_STATE_FLAG_ACTIVE;
|
2010-09-07 22:23:04 +00:00
|
|
|
|
|
|
|
_gtk_button_paint (button, cr,
|
|
|
|
gtk_widget_get_allocated_width (widget),
|
|
|
|
gtk_widget_get_allocated_height (widget),
|
2011-01-10 01:26:28 +00:00
|
|
|
state);
|
2010-09-07 22:23:04 +00:00
|
|
|
|
|
|
|
if (child)
|
|
|
|
gtk_container_propagate_draw (GTK_CONTAINER (widget), child, cr);
|
|
|
|
|
2001-12-03 22:11:40 +00:00
|
|
|
return FALSE;
|
1999-01-12 15:12:14 +00:00
|
|
|
}
|
|
|
|
|
2002-07-25 16:12:46 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_toggle_button_mnemonic_activate (GtkWidget *widget,
|
|
|
|
gboolean group_cycling)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* We override the standard implementation in
|
|
|
|
* gtk_widget_real_mnemonic_activate() in order to focus the widget even
|
|
|
|
* if there is no mnemonic conflict.
|
|
|
|
*/
|
2010-01-04 03:56:11 +00:00
|
|
|
if (gtk_widget_get_can_focus (widget))
|
2002-07-25 16:12:46 +00:00
|
|
|
gtk_widget_grab_focus (widget);
|
|
|
|
|
|
|
|
if (!group_cycling)
|
|
|
|
gtk_widget_activate (widget);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
static void
|
|
|
|
gtk_toggle_button_pressed (GtkButton *button)
|
|
|
|
{
|
2010-10-19 00:01:31 +00:00
|
|
|
button->priv->button_down = TRUE;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2001-08-25 23:11:46 +00:00
|
|
|
gtk_toggle_button_update_state (button);
|
2002-02-22 13:34:28 +00:00
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (button));
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_toggle_button_released (GtkButton *button)
|
|
|
|
{
|
2010-10-19 00:01:31 +00:00
|
|
|
if (button->priv->button_down)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2010-10-19 00:01:31 +00:00
|
|
|
button->priv->button_down = FALSE;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2010-10-19 00:01:31 +00:00
|
|
|
if (button->priv->in_button)
|
2001-08-25 23:11:46 +00:00
|
|
|
gtk_button_clicked (button);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2001-08-25 23:11:46 +00:00
|
|
|
gtk_toggle_button_update_state (button);
|
2002-02-22 13:34:28 +00:00
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (button));
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_toggle_button_clicked (GtkButton *button)
|
|
|
|
{
|
2001-08-25 23:11:46 +00:00
|
|
|
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (button);
|
2010-10-19 16:18:02 +00:00
|
|
|
GtkToggleButtonPrivate *priv = toggle_button->priv;
|
|
|
|
|
|
|
|
priv->active = !priv->active;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
gtk_toggle_button_toggled (toggle_button);
|
|
|
|
|
2001-08-25 23:11:46 +00:00
|
|
|
gtk_toggle_button_update_state (button);
|
2001-05-13 22:41:30 +00:00
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (toggle_button), "active");
|
2009-01-23 15:15:28 +00:00
|
|
|
|
2009-01-27 14:59:53 +00:00
|
|
|
if (GTK_BUTTON_CLASS (gtk_toggle_button_parent_class)->clicked)
|
|
|
|
GTK_BUTTON_CLASS (gtk_toggle_button_parent_class)->clicked (button);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
2001-08-25 23:11:46 +00:00
|
|
|
static void
|
|
|
|
gtk_toggle_button_update_state (GtkButton *button)
|
|
|
|
{
|
|
|
|
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (button);
|
2010-10-19 16:18:02 +00:00
|
|
|
GtkToggleButtonPrivate *priv = toggle_button->priv;
|
2006-03-09 18:48:38 +00:00
|
|
|
gboolean depressed, touchscreen;
|
2010-10-31 13:45:19 +00:00
|
|
|
GtkStateFlags new_state = 0;
|
2001-08-25 23:11:46 +00:00
|
|
|
|
2006-03-09 18:48:38 +00:00
|
|
|
g_object_get (gtk_widget_get_settings (GTK_WIDGET (button)),
|
|
|
|
"gtk-touchscreen-mode", &touchscreen,
|
|
|
|
NULL);
|
|
|
|
|
2011-01-23 17:04:41 +00:00
|
|
|
new_state = gtk_widget_get_state_flags (GTK_WIDGET (button)) &
|
|
|
|
~(GTK_STATE_FLAG_INCONSISTENT |
|
|
|
|
GTK_STATE_FLAG_PRELIGHT |
|
|
|
|
GTK_STATE_FLAG_ACTIVE);
|
|
|
|
|
2010-10-31 13:45:19 +00:00
|
|
|
if (priv->inconsistent)
|
|
|
|
new_state |= GTK_STATE_FLAG_INCONSISTENT;
|
|
|
|
|
2010-10-19 16:18:02 +00:00
|
|
|
if (priv->inconsistent)
|
2001-08-25 23:11:46 +00:00
|
|
|
depressed = FALSE;
|
2010-10-19 00:01:31 +00:00
|
|
|
else if (button->priv->in_button && button->priv->button_down)
|
2002-02-23 20:47:03 +00:00
|
|
|
depressed = TRUE;
|
2001-08-25 23:11:46 +00:00
|
|
|
else
|
2010-10-19 16:18:02 +00:00
|
|
|
depressed = priv->active;
|
|
|
|
|
2010-10-19 00:01:31 +00:00
|
|
|
if (!touchscreen && button->priv->in_button && (!button->priv->button_down || priv->draw_indicator))
|
2010-10-31 13:45:19 +00:00
|
|
|
new_state |= GTK_STATE_FLAG_PRELIGHT;
|
2010-11-24 01:10:28 +00:00
|
|
|
|
|
|
|
if (depressed)
|
2010-10-31 13:45:19 +00:00
|
|
|
new_state |= GTK_STATE_FLAG_ACTIVE;
|
2001-08-25 23:11:46 +00:00
|
|
|
|
2010-10-31 13:45:19 +00:00
|
|
|
_gtk_button_set_depressed (button, depressed);
|
|
|
|
gtk_widget_set_state_flags (GTK_WIDGET (toggle_button), new_state, TRUE);
|
2001-08-25 23:11:46 +00:00
|
|
|
}
|