* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
-#include <config.h>
+#include "config.h"
#include "gtkaccellabel.h"
#include "gtkmarshalers.h"
#include "gtkradiomenuitem.h"
+#include "gtkactivatable.h"
#include "gtkprivate.h"
#include "gtkintl.h"
#include "gtkalias.h"
};
-static void gtk_radio_menu_item_class_init (GtkRadioMenuItemClass *klass);
-static void gtk_radio_menu_item_init (GtkRadioMenuItem *radio_menu_item);
static void gtk_radio_menu_item_destroy (GtkObject *object);
static void gtk_radio_menu_item_activate (GtkMenuItem *menu_item);
static void gtk_radio_menu_item_set_property (GObject *object,
GValue *value,
GParamSpec *pspec);
-static GtkCheckMenuItemClass *parent_class = NULL;
-
static guint group_changed_signal = 0;
-GType
-gtk_radio_menu_item_get_type (void)
-{
- static GType radio_menu_item_type = 0;
-
- if (!radio_menu_item_type)
- {
- static const GTypeInfo radio_menu_item_info =
- {
- sizeof (GtkRadioMenuItemClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) gtk_radio_menu_item_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GtkRadioMenuItem),
- 0, /* n_preallocs */
- (GInstanceInitFunc) gtk_radio_menu_item_init,
- };
-
- radio_menu_item_type =
- g_type_register_static (GTK_TYPE_CHECK_MENU_ITEM, I_("GtkRadioMenuItem"),
- &radio_menu_item_info, 0);
- }
-
- return radio_menu_item_type;
-}
+G_DEFINE_TYPE (GtkRadioMenuItem, gtk_radio_menu_item, GTK_TYPE_CHECK_MENU_ITEM)
GtkWidget*
gtk_radio_menu_item_new (GSList *group)
object_class = GTK_OBJECT_CLASS (klass);
menu_item_class = GTK_MENU_ITEM_CLASS (klass);
- parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = gtk_radio_menu_item_set_property;
gobject_class->get_property = gtk_radio_menu_item_get_property;
* Emitted when the group of radio menu items that a radio menu item belongs
* to changes. This is emitted when a radio menu item switches from
* being alone to being part of a group of 2 or more menu items, or
- * vice-versa, and when a buttton is moved from one group of 2 or
+ * vice-versa, and when a button is moved from one group of 2 or
* more menu items ton a different one, but not when the composition
* of the group that a menu item belongs to changes.
*
static void
gtk_radio_menu_item_destroy (GtkObject *object)
{
+ GtkRadioMenuItem *radio_menu_item = GTK_RADIO_MENU_ITEM (object);
GtkWidget *old_group_singleton = NULL;
- GtkRadioMenuItem *radio_menu_item;
GtkRadioMenuItem *tmp_menu_item;
GSList *tmp_list;
gboolean was_in_group;
- g_return_if_fail (GTK_IS_RADIO_MENU_ITEM (object));
-
- radio_menu_item = GTK_RADIO_MENU_ITEM (object);
-
was_in_group = radio_menu_item->group && radio_menu_item->group->next;
radio_menu_item->group = g_slist_remove (radio_menu_item->group,
g_signal_emit (old_group_singleton, group_changed_signal, 0);
if (was_in_group)
g_signal_emit (radio_menu_item, group_changed_signal, 0);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+
+ GTK_OBJECT_CLASS (gtk_radio_menu_item_parent_class)->destroy (object);
}
static void
gtk_radio_menu_item_activate (GtkMenuItem *menu_item)
{
- GtkRadioMenuItem *radio_menu_item;
- GtkCheckMenuItem *check_menu_item;
+ GtkRadioMenuItem *radio_menu_item = GTK_RADIO_MENU_ITEM (menu_item);
+ GtkCheckMenuItem *check_menu_item = GTK_CHECK_MENU_ITEM (menu_item);
GtkCheckMenuItem *tmp_menu_item;
+ GtkAction *action;
GSList *tmp_list;
gint toggled;
- g_return_if_fail (GTK_IS_RADIO_MENU_ITEM (menu_item));
+ action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (menu_item));
+ if (action && gtk_menu_item_get_submenu (menu_item) == NULL)
+ gtk_action_activate (action);
- radio_menu_item = GTK_RADIO_MENU_ITEM (menu_item);
- check_menu_item = GTK_CHECK_MENU_ITEM (menu_item);
toggled = FALSE;
if (check_menu_item->active)
}
if (toggled)
- gtk_check_menu_item_toggled (check_menu_item);
+ {
+ gtk_check_menu_item_toggled (check_menu_item);
+ }
gtk_widget_queue_draw (GTK_WIDGET (radio_menu_item));
}