Commit fa336d28 authored by Soeren Sandmann's avatar Soeren Sandmann Committed by Søren Sandmann Pedersen

gtkradiotoolbutton.c gtkradiotoolbutton.h gtktoggletoolbutton.c

Mon Jun 30 01:20:19 2003  Soeren Sandmann  <sandmann@daimi.au.dk>

	* gtkradiotoolbutton.c
	* gtkradiotoolbutton.h
	* gtktoggletoolbutton.c
	* gtktoggletoolbutton.h
	* gtktoolbutton.c
	* gtktoolbutton.h
	* gtktoolitem.c
	* gtktoolitem.h
	* gtktoolbar.c
	* gtktoolbar.h
	* gtkseparatortoolitem.c
	* gtkseparatortoolitem.h

	New toolbar.
parent 8de17733
Mon Jun 30 01:20:19 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtkradiotoolbutton.c
* gtkradiotoolbutton.h
* gtktoggletoolbutton.c
* gtktoggletoolbutton.h
* gtktoolbutton.c
* gtktoolbutton.h
* gtktoolitem.c
* gtktoolitem.h
* gtktoolbar.c
* gtktoolbar.h
* gtkseparatortoolitem.c
* gtkseparatortoolitem.h
New toolbar.
2003-06-29 Matthias Clasen <maclas@gmx.de>
* gtk/gtkwidget.c (gtk_widget_class_init): Remove a duplicate parameter from docs, some more formatting
......
Mon Jun 30 01:20:19 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtkradiotoolbutton.c
* gtkradiotoolbutton.h
* gtktoggletoolbutton.c
* gtktoggletoolbutton.h
* gtktoolbutton.c
* gtktoolbutton.h
* gtktoolitem.c
* gtktoolitem.h
* gtktoolbar.c
* gtktoolbar.h
* gtkseparatortoolitem.c
* gtkseparatortoolitem.h
New toolbar.
2003-06-29 Matthias Clasen <maclas@gmx.de>
* gtk/gtkwidget.c (gtk_widget_class_init): Remove a duplicate parameter from docs, some more formatting
......
Mon Jun 30 01:20:19 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtkradiotoolbutton.c
* gtkradiotoolbutton.h
* gtktoggletoolbutton.c
* gtktoggletoolbutton.h
* gtktoolbutton.c
* gtktoolbutton.h
* gtktoolitem.c
* gtktoolitem.h
* gtktoolbar.c
* gtktoolbar.h
* gtkseparatortoolitem.c
* gtkseparatortoolitem.h
New toolbar.
2003-06-29 Matthias Clasen <maclas@gmx.de>
* gtk/gtkwidget.c (gtk_widget_class_init): Remove a duplicate parameter from docs, some more formatting
......
Mon Jun 30 01:20:19 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtkradiotoolbutton.c
* gtkradiotoolbutton.h
* gtktoggletoolbutton.c
* gtktoggletoolbutton.h
* gtktoolbutton.c
* gtktoolbutton.h
* gtktoolitem.c
* gtktoolitem.h
* gtktoolbar.c
* gtktoolbar.h
* gtkseparatortoolitem.c
* gtkseparatortoolitem.h
New toolbar.
2003-06-29 Matthias Clasen <maclas@gmx.de>
* gtk/gtkwidget.c (gtk_widget_class_init): Remove a duplicate parameter from docs, some more formatting
......
Mon Jun 30 01:20:19 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtkradiotoolbutton.c
* gtkradiotoolbutton.h
* gtktoggletoolbutton.c
* gtktoggletoolbutton.h
* gtktoolbutton.c
* gtktoolbutton.h
* gtktoolitem.c
* gtktoolitem.h
* gtktoolbar.c
* gtktoolbar.h
* gtkseparatortoolitem.c
* gtkseparatortoolitem.h
New toolbar.
2003-06-29 Matthias Clasen <maclas@gmx.de>
* gtk/gtkwidget.c (gtk_widget_class_init): Remove a duplicate parameter from docs, some more formatting
......
......@@ -94,28 +94,27 @@ gtk_public_h_sources = \
gtkalignment.h \
gtkarrow.h \
gtkaspectframe.h \
gtkbbox.h \
gtkbin.h \
gtkbindings.h \
gtkbbox.h \
gtkbox.h \
gtkbutton.h \
gtkcalendar.h \
gtkcelleditable.h \
gtkcellrenderer.h \
gtkcellrendererpixbuf.h \
gtkcellrenderertext.h \
gtkcellrenderertoggle.h \
gtkcheckbutton.h \
gtkcheckmenuitem.h \
gtkseparatormenuitem.h \
gtkclist.h \
gtkclipboard.h \
gtkclist.h \
gtkcolorsel.h \
gtkcolorseldialog.h \
gtkcombo.h \
gtkcontainer.h \
gtkctree.h \
gtkcurve.h \
gtkcellrenderer.h \
gtkcelleditable.h \
gtkcellrenderertext.h \
gtkcellrenderertoggle.h \
gtkcellrendererpixbuf.h \
gtkdebug.h \
gtkdialog.h \
gtkdnd.h \
......@@ -162,8 +161,8 @@ gtk_public_h_sources = \
gtkmessagedialog.h \
gtkmisc.h \
gtknotebook.h \
gtkoldeditable.h \
gtkobject.h \
gtkoldeditable.h \
gtkoptionmenu.h \
gtkpaned.h \
gtkpixmap.h \
......@@ -174,6 +173,7 @@ gtk_public_h_sources = \
gtkprogressbar.h \
gtkradiobutton.h \
gtkradiomenuitem.h \
gtkradiotoolbutton.h \
gtkrange.h \
gtkrc.h \
gtkruler.h \
......@@ -182,16 +182,19 @@ gtk_public_h_sources = \
gtkscrolledwindow.h \
gtkselection.h \
gtkseparator.h \
gtkseparatormenuitem.h \
gtkseparatortoolitem.h \
gtksettings.h \
gtksignal.h \
gtksizegroup.h \
gtksocket.h \
gtkspinbutton.h \
gtkstyle.h \
gtkstatusbar.h \
gtkstock.h \
gtkstyle.h \
gtktable.h \
gtktearoffmenuitem.h \
gtktext.h \
gtktextbuffer.h \
gtktextchild.h \
gtktextdisplay.h \
......@@ -201,10 +204,12 @@ gtk_public_h_sources = \
gtktexttag.h \
gtktexttagtable.h \
gtktextview.h \
gtktext.h \
gtktipsquery.h \
gtktogglebutton.h \
gtktoggletoolbutton.h \
gtktoolbar.h \
gtktoolbutton.h \
gtktoolitem.h \
gtktooltips.h \
gtktree.h \
gtktreednd.h \
......@@ -249,6 +254,12 @@ gtk_c_sources = \
gtkaccelgroup.c \
gtkaccelmap.c \
gtkaccellabel.c \
gtkradiotoolbutton.c \
gtktoggletoolbutton.c \
gtktoolbar.c \
gtktoolbutton.c \
gtkseparatortoolitem.c \
gtktoolitem.c \
gtkaccessible.c \
gtkadjustment.c \
gtkalignment.c \
......@@ -374,7 +385,6 @@ gtk_c_sources = \
gtkthemes.c \
gtktipsquery.c \
gtktogglebutton.c \
gtktoolbar.c \
gtktooltips.c \
gtktree.c \
gtktreeitem.c \
......
......@@ -29,6 +29,7 @@ BOOLEAN:OBJECT,UINT,FLAGS
BOOLEAN:OBJECT,INT,INT,UINT
BOOLEAN:OBJECT,STRING,STRING,BOXED
BOOLEAN:OBJECT,BOXED,BOXED
BOOLEAN:OBJECT,STRING,STRING
BOOLEAN:INT,INT
BOOLEAN:VOID
BOOLEAN:BOOLEAN
......
/* gtkradiotoolbutton.c
*
* Copyright (C) 2002 Anders Carlsson <andersca@codefactory.se>
* Copyright (C) 2002 James Henstridge <james@daa.com.au>
* Copyright (C) 2003 Soeren Sandmann <sandmann@daimi.au.dk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "gtkradiotoolbutton.h"
#include "gtkradiobutton.h"
#include "gtkintl.h"
static void gtk_radio_tool_button_init (GtkRadioToolButton *button);
static void gtk_radio_tool_button_class_init (GtkRadioToolButtonClass *klass);
GType
gtk_radio_tool_button_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo type_info =
{
sizeof (GtkRadioToolButtonClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gtk_radio_tool_button_class_init,
(GClassFinalizeFunc) NULL,
NULL,
sizeof (GtkRadioToolButton),
0, /* n_preallocs */
(GInstanceInitFunc) gtk_radio_tool_button_init
};
type = g_type_register_static (GTK_TYPE_TOGGLE_TOOL_BUTTON,
"GtkRadioToolButton", &type_info, 0);
}
return type;
}
static void
gtk_radio_tool_button_class_init (GtkRadioToolButtonClass *klass)
{
GtkToolButtonClass *toolbutton_class;
toolbutton_class = (GtkToolButtonClass *)klass;
toolbutton_class->button_type = GTK_TYPE_RADIO_BUTTON;
}
static void
gtk_radio_tool_button_init (GtkRadioToolButton *button)
{
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (GTK_TOOL_BUTTON (button)->button), FALSE);
}
GtkToolItem *
gtk_radio_tool_button_new (GSList *group)
{
GtkRadioToolButton *button;
button = g_object_new (GTK_TYPE_RADIO_TOOL_BUTTON,
NULL);
gtk_radio_tool_button_set_group (button, group);
return GTK_TOOL_ITEM (button);
}
GtkToolItem *
gtk_radio_tool_button_new_from_stock (GSList *group,
const gchar *stock_id)
{
GtkRadioToolButton *button;
g_return_val_if_fail (stock_id != NULL, NULL);
button = g_object_new (GTK_TYPE_RADIO_TOOL_BUTTON,
"stock_id", stock_id,
NULL);
gtk_radio_tool_button_set_group (button, group);
return GTK_TOOL_ITEM (button);
}
GtkToolItem *
gtk_radio_tool_button_new_from_widget (GtkWidget *group,
const gchar *stock_id)
{
GSList *list = NULL;
g_return_val_if_fail (GTK_IS_RADIO_TOOL_BUTTON (group), NULL);
if (group)
list = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (group));
return gtk_radio_tool_button_new_from_stock (list, stock_id);
}
GtkToolItem *
gtk_radio_tool_button_new_with_stock_from_widget (GtkWidget *group)
{
GSList *list = NULL;
g_return_val_if_fail (GTK_IS_RADIO_TOOL_BUTTON (group), NULL);
if (group)
list = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (group));
return gtk_radio_tool_button_new (list);
}
GSList *
gtk_radio_tool_button_get_group (GtkRadioToolButton *button)
{
g_return_val_if_fail (GTK_IS_RADIO_TOOL_BUTTON (button), NULL);
return gtk_radio_button_get_group (GTK_RADIO_BUTTON (GTK_TOOL_BUTTON (button)->button));
}
void
gtk_radio_tool_button_set_group (GtkRadioToolButton *button,
GSList *group)
{
g_return_if_fail (GTK_IS_RADIO_TOOL_BUTTON (button));
gtk_radio_button_set_group (GTK_RADIO_BUTTON (GTK_TOOL_BUTTON (button)->button), group);
}
/* gtkradiotoolbutton.h
*
* Copyright (C) 2002 Anders Carlsson <andersca@codefactory.se>
* Copyright (C) 2002 James Henstridge <james@daa.com.au>
* Copyright (C) 2003 Soeren Sandmann <sandmann@daimi.au.dk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GTK_RADIO_TOOL_BUTTON_H__
#define __GTK_RADIO_TOOL_BUTTON_H__
#include "gtktoggletoolbutton.h"
#define GTK_TYPE_RADIO_TOOL_BUTTON (gtk_radio_tool_button_get_type ())
#define GTK_RADIO_TOOL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RADIO_TOOL_BUTTON, GtkRadioToolButton))
#define GTK_RADIO_TOOL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RADIO_TOOL_BUTTON, GtkRadioToolButtonClass))
#define GTK_IS_RADIO_TOOL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RADIO_TOOL_BUTTON))
#define GTK_IS_RADIO_TOOL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GTK_TYPE_RADIO_TOOL_BUTTON))
#define GTK_RADIO_TOOL_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_RADIO_TOOL_BUTTON, GtkRadioToolButtonClass))
typedef struct _GtkRadioToolButton GtkRadioToolButton;
typedef struct _GtkRadioToolButtonClass GtkRadioToolButtonClass;
struct _GtkRadioToolButton
{
GtkToggleToolButton parent;
};
struct _GtkRadioToolButtonClass
{
GtkToggleToolButtonClass parent_class;
};
GType gtk_radio_tool_button_get_type (void) G_GNUC_CONST;
GtkToolItem *gtk_radio_tool_button_new (GSList *group);
GtkToolItem *gtk_radio_tool_button_new_from_stock (GSList *group,
const gchar *stock_id);
GtkToolItem *gtk_radio_tool_button_new_from_widget (GtkWidget *group,
const gchar *stock_id);
GtkToolItem *gtk_radio_tool_button_new_with_stock_from_widget (GtkWidget *group);
GSList * gtk_radio_tool_button_get_group (GtkRadioToolButton *button);
void gtk_radio_tool_button_set_group (GtkRadioToolButton *button,
GSList *group);
#endif /* __GTK_RADIO_TOOL_BUTTON_H__ */
/* gtkseparatortoolitem.c
*
* Copyright (C) 2002 Anders Carlsson <andersca@codefactory.se>
* Copyright (C) 2002 James Henstridge <james@daa.com.au>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "gtkseparatormenuitem.h"
#include "gtkseparatortoolitem.h"
#include "gtkintl.h"
static void gtk_separator_tool_item_class_init (GtkSeparatorToolItemClass*class);
static void gtk_separator_tool_item_add (GtkContainer *container,
GtkWidget *child);
static GObjectClass *parent_class = NULL;
GType
gtk_separator_tool_item_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo type_info =
{
sizeof (GtkSeparatorToolItemClass),
(GBaseInitFunc) 0,
(GBaseFinalizeFunc) 0,
(GClassInitFunc) gtk_separator_tool_item_class_init,
(GClassFinalizeFunc) 0,
NULL,
sizeof (GtkSeparatorToolItem),
0, /* n_preallocs */
(GInstanceInitFunc) NULL,
};
type = g_type_register_static (GTK_TYPE_TOOL_ITEM,
"GtkSeparatorToolItem", &type_info, 0);
}
return type;
}
static void
gtk_separator_tool_item_class_init (GtkSeparatorToolItemClass *class)
{
GtkContainerClass *container_class;
GtkToolItemClass *toolitem_class;
parent_class = g_type_class_peek_parent (class);
container_class = (GtkContainerClass *)class;
toolitem_class = (GtkToolItemClass *)class;
container_class->add = gtk_separator_tool_item_add;
}
static void
gtk_separator_tool_item_add (GtkContainer *container,
GtkWidget *child)
{
g_warning("attempt to add a child to an GtkSeparatorToolItem");
}
GtkToolItem *
gtk_separator_tool_item_new (void)
{
GtkToolItem *self;
self = g_object_new (GTK_TYPE_SEPARATOR_TOOL_ITEM,
NULL);
return self;
}
/* gtktoggletoolbutton.h
*
* Copyright (C) 2002 Anders Carlsson <andersca@codefactory.se>
* Copyright (C) 2002 James Henstridge <james@daa.com.au>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GTK_SEPARATOR_TOOL_ITEM_H__
#define __GTK_SEPARATOR_TOOL_ITEM_H__
#include "gtktoolitem.h"
#define GTK_TYPE_SEPARATOR_TOOL_ITEM (gtk_separator_tool_item_get_type ())
#define GTK_SEPARATOR_TOOL_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SEPARATOR_TOOL_ITEM, GtkSeparatorToolItem))
#define GTK_SEPARATOR_TOOL_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_SEPARATOR_TOOL_ITEM, GtkSeparatorToolItemClass))
#define GTK_IS_SEPARATOR_TOOL_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SEPARATOR_TOOL_ITEM))
#define GTK_IS_SEPARATOR_TOOL_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GTK_TYPE_SEPARATOR_TOOL_ITEM))
#define GTK_SEPARATOR_TOOL_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_SEPARATOR_TOOL_ITEM, GtkSeparatorToolItemClass))
typedef struct _GtkSeparatorToolItem GtkSeparatorToolItem;
typedef struct _GtkSeparatorToolItemClass GtkSeparatorToolItemClass;
struct _GtkSeparatorToolItem
{
GtkToolItem parent;
};
struct _GtkSeparatorToolItemClass
{
GtkToolItemClass parent_class;
};
GType gtk_separator_tool_item_get_type (void) G_GNUC_CONST;
GtkToolItem *gtk_separator_tool_item_new (void);
#endif /* __GTK_SEPARATOR_TOOL_ITEM_H__ */
/* gtktoggletoolbutton.c
*
* Copyright (C) 2002 Anders Carlsson <andersca@codefactory.se>
* Copyright (C) 2002 James Henstridge <james@daa.com.au>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "gtktoggletoolbutton.h"
#include "gtkcheckmenuitem.h"
#include "gtklabel.h"
#include "gtktogglebutton.h"
#include "gtkstock.h"
#include "gtkintl.h"
#define MENU_ID "gtk-toggle-tool-button-menu-id"
enum {
TOGGLED,
LAST_SIGNAL
};
static void gtk_toggle_tool_button_init (GtkToggleToolButton *button);
static void gtk_toggle_tool_button_class_init (GtkToggleToolButtonClass *klass);
static gboolean gtk_toggle_tool_button_create_menu_proxy (GtkToolItem *button);
static void button_toggled (GtkWidget *widget,
GtkToggleToolButton *button);
static void menu_item_activated (GtkWidget *widget,
GtkToggleToolButton *button);
static GObjectClass *parent_class = NULL;
static guint toggle_signals[LAST_SIGNAL] = { 0 };
GType
gtk_toggle_tool_button_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo type_info =
{
sizeof (GtkToggleToolButtonClass),
(GBaseInitFunc) 0,
(GBaseFinalizeFunc) 0,
(GClassInitFunc) gtk_toggle_tool_button_class_init,
(GClassFinalizeFunc) 0,
NULL,
sizeof (GtkToggleToolButton),
0, /* n_preallocs */
(GInstanceInitFunc) gtk_toggle_tool_button_init
};
type = g_type_register_static (GTK_TYPE_TOOL_BUTTON,
"GtkToggleToolButton", &type_info, 0);
}
return type;
}
static void
gtk_toggle_tool_button_class_init (GtkToggleToolButtonClass *klass)
{
GObjectClass *object_class;
GtkToolItemClass *toolitem_class;
GtkToolButtonClass *toolbutton_class;
parent_class = g_type_class_peek_parent (klass);
object_class = (GObjectClass *)klass;
toolitem_class = (GtkToolItemClass *)klass;
toolbutton_class = (GtkToolButtonClass *)klass;
toolitem_class->create_menu_proxy = gtk_toggle_tool_button_create_menu_proxy;
toolbutton_class->button_type = GTK_TYPE_TOGGLE_BUTTON;
toggle_signals[TOGGLED] =
g_signal_new ("toggled",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkToggleToolButtonClass, toggled),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
static void
gtk_toggle_tool_button_init (GtkToggleToolButton *button)
{
g_signal_connect_object (GTK_TOOL_BUTTON (button)->button, "toggled",
G_CALLBACK (button_toggled), button, 0);
}
static gboolean
gtk_toggle_tool_button_create_menu_proxy (GtkToolItem *item)
{
GtkToolButton *tool_button = GTK_TOOL_BUTTON (item);
GtkToggleToolButton *toggle_tool_button = GTK_TOGGLE_TOOL_BUTTON (item);
GtkWidget *menu_item = NULL;
GtkStockItem stock_item;
gboolean use_mnemonic = TRUE;
const char *label = "";
if (tool_button->label_widget && GTK_IS_LABEL (tool_button->label_widget))
label = gtk_label_get_label (GTK_LABEL (tool_button->label_widget));
else if (tool_button->label_text)
{
label = tool_button->label_text;
use_mnemonic = tool_button->use_underline;
}
else if (tool_button->stock_id && gtk_stock_lookup (tool_button->stock_id, &stock_item))
label = stock_item.label;
if (use_mnemonic)
menu_item = gtk_check_menu_item_new_with_mnemonic (label);
else
menu_item = gtk_check_menu_item_new_with_label (label);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
toggle_tool_button->active);
g_signal_connect_closure_by_id (menu_item,
g_signal_lookup ("activate", G_OBJECT_TYPE (menu_item)), 0,
g_cclosure_new_object (G_CALLBACK (menu_item_activated),
G_OBJECT (toggle_tool_button)),
FALSE);
gtk_tool_item_set_proxy_menu_item (item, MENU_ID, menu_item);
return TRUE;
}
/* There are two activatable widgets, a toggle button and a menu item.
*
* If a widget is activated and the state of the tool button is the same as
* the new state of the activated widget, then the other widget was the one
* that was activated by the user and updated the tool button's state.
*
* If the state of the tool button is not the same as the new state of the
* activated widget, then the activation was activated by the user, and the
* widget needs to make sure the tool button is updated before the other
* widget is activated. This will make sure the other widget a tool button
* in a state that matches its own new state.
*/
static void
menu_item_activated (GtkWidget *menu_item,
GtkToggleToolButton *toggle_tool_button)
{
GtkToolButton *tool_button = GTK_TOOL_BUTTON (toggle_tool_button);
gboolean menu_active = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menu_item));
if (toggle_tool_button->active != menu_active)
{
toggle_tool_button->active = menu_active;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tool_button->button),
toggle_tool_button->active);
g_signal_emit (G_OBJECT (toggle_tool_button), toggle_signals[TOGGLED], 0);
}
}
static void
button_toggled (GtkWidget *widget,
GtkToggleToolButton *toggle_tool_button)
{
gboolean toggle_active = GTK_TOGGLE_BUTTON (widget)->active;
if (toggle_tool_button->active != toggle_active)
{
GtkWidget *menu_item;