Commit 3bd93e5b authored by Matthias Clasen's avatar Matthias Clasen

Remove GtkItem

With the demise of GtkList and GtkTree, it has GtkMenuItem as sole
derived class, and is not really adding any value as a separate class.
Its few useful features have been merged into GtkMenuItem.

Bug 629104
parent 72ac2175
......@@ -369,7 +369,6 @@ that is, GUI components such as #GtkButton or #GtkTextView.
<title>Abstract Base Classes</title>
<xi:include href="xml/gtkbin.xml" />
<xi:include href="xml/gtkcontainer.xml" />
<xi:include href="xml/gtkitem.xml" />
<xi:include href="xml/gtkmenushell.xml" />
<xi:include href="xml/gtkmisc.xml" />
<xi:include href="xml/gtkobject.xml" />
......
......@@ -1832,24 +1832,6 @@ GTK_INVISIBLE_GET_CLASS
gtk_invisible_get_type
</SECTION>
<SECTION>
<FILE>gtkitem</FILE>
<TITLE>GtkItem</TITLE>
GtkItem
gtk_item_select
gtk_item_deselect
gtk_item_toggle
<SUBSECTION Standard>
GTK_ITEM
GTK_IS_ITEM
GTK_TYPE_ITEM
GTK_ITEM_CLASS
GTK_IS_ITEM_CLASS
GTK_ITEM_GET_CLASS
<SUBSECTION Private>
gtk_item_get_type
</SECTION>
<SECTION>
<FILE>gtklabel</FILE>
<TITLE>GtkLabel</TITLE>
......
<!-- ##### SECTION Title ##### -->
GtkItem
<!-- ##### SECTION Short_Description ##### -->
Abstract base class for GtkMenuItem, GtkListItem and GtkTreeItem
<!-- ##### SECTION Long_Description ##### -->
<para>
The #GtkItem widget is an abstract base class for #GtkMenuItem, #GtkListItem
and #GtkTreeItem.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### STRUCT GtkItem ##### -->
<para>
The #GtkItem-struct struct contains private data only, and
should be accessed using the functions below.
</para>
<!-- ##### SIGNAL GtkItem::deselect ##### -->
<para>
Emitted when the item is deselected.
</para>
@item: the object which received the signal.
<!-- ##### SIGNAL GtkItem::select ##### -->
<para>
Emitted when the item is selected.
</para>
@item: the object which received the signal.
<!-- ##### SIGNAL GtkItem::toggle ##### -->
<para>
Emitted when the item is toggled.
</para>
@item: the object which received the signal.
<!-- ##### FUNCTION gtk_item_select ##### -->
<para>
Emits the "select" signal on the given item.
</para>
@item: a #GtkItem.
<!-- ##### FUNCTION gtk_item_deselect ##### -->
<para>
Emits the "deselect" signal on the given item.
</para>
@item: a #GtkItem.
<!-- ##### FUNCTION gtk_item_toggle ##### -->
<para>
Emits the "toggle" signal on the given item.
</para>
@item: a #GtkItem.
......@@ -230,7 +230,6 @@ gtk_public_h_sources = \
gtkimmulticontext.h \
gtkinfobar.h \
gtkinvisible.h \
gtkitem.h \
gtklabel.h \
gtklayout.h \
gtklinkbutton.h \
......@@ -497,7 +496,6 @@ gtk_base_c_sources = \
gtkimmulticontext.c \
gtkinfobar.c \
gtkinvisible.c \
gtkitem.c \
gtkkeyhash.c \
gtklabel.c \
gtklayout.c \
......
......@@ -113,7 +113,6 @@
#include <gtk/gtkimmulticontext.h>
#include <gtk/gtkinfobar.h>
#include <gtk/gtkinvisible.h>
#include <gtk/gtkitem.h>
#include <gtk/gtklabel.h>
#include <gtk/gtklayout.h>
#include <gtk/gtklinkbutton.h>
......
......@@ -1732,15 +1732,6 @@ gtk_invisible_set_screen
#endif
#endif
#if IN_HEADER(__GTK_ITEM_H__)
#if IN_FILE(__GTK_ITEM_C__)
gtk_item_deselect
gtk_item_get_type G_GNUC_CONST
gtk_item_select
gtk_item_toggle
#endif
#endif
#if IN_HEADER(__GTK_LABEL_H__)
#if IN_FILE(__GTK_LABEL_C__)
gtk_label_get_angle
......
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. 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"
#include "gtkitem.h"
#include "gtkmarshalers.h"
#include "gtkintl.h"
enum {
SELECT,
DESELECT,
TOGGLE,
LAST_SIGNAL
};
static void gtk_item_realize (GtkWidget *widget);
static gint gtk_item_enter (GtkWidget *widget,
GdkEventCrossing *event);
static gint gtk_item_leave (GtkWidget *widget,
GdkEventCrossing *event);
static guint item_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_ABSTRACT_TYPE (GtkItem, gtk_item, GTK_TYPE_BIN)
static void
gtk_item_class_init (GtkItemClass *class)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
widget_class->realize = gtk_item_realize;
widget_class->enter_notify_event = gtk_item_enter;
widget_class->leave_notify_event = gtk_item_leave;
class->select = NULL;
class->deselect = NULL;
class->toggle = NULL;
item_signals[SELECT] =
g_signal_new (I_("select"),
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkItemClass, select),
NULL, NULL,
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
item_signals[DESELECT] =
g_signal_new (I_("deselect"),
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkItemClass, deselect),
NULL, NULL,
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
item_signals[TOGGLE] =
g_signal_new (I_("toggle"),
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkItemClass, toggle),
NULL, NULL,
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
widget_class->activate_signal = item_signals[TOGGLE];
}
static void
gtk_item_init (GtkItem *item)
{
gtk_widget_set_has_window (GTK_WIDGET (item), TRUE);
}
void
gtk_item_select (GtkItem *item)
{
g_signal_emit (item, item_signals[SELECT], 0);
}
void
gtk_item_deselect (GtkItem *item)
{
g_signal_emit (item, item_signals[DESELECT], 0);
}
void
gtk_item_toggle (GtkItem *item)
{
g_signal_emit (item, item_signals[TOGGLE], 0);
}
static void
gtk_item_realize (GtkWidget *widget)
{
GtkAllocation allocation;
GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gtk_widget_set_realized (widget, TRUE);
gtk_widget_get_allocation (widget, &allocation);
attributes.x = allocation.x;
attributes.y = allocation.y;
attributes.width = allocation.width;
attributes.height = allocation.height;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
attributes.event_mask = (gtk_widget_get_events (widget) |
GDK_EXPOSURE_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_POINTER_MOTION_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
gtk_widget_set_window (widget, window);
gdk_window_set_user_data (window, widget);
gtk_widget_style_attach (widget);
gtk_style_set_background (gtk_widget_get_style (widget), window, GTK_STATE_NORMAL);
gdk_window_set_back_pixmap (window, NULL, TRUE);
}
static gint
gtk_item_enter (GtkWidget *widget,
GdkEventCrossing *event)
{
g_return_val_if_fail (GTK_IS_ITEM (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
return gtk_widget_event (gtk_widget_get_parent (widget), (GdkEvent *) event);
}
static gint
gtk_item_leave (GtkWidget *widget,
GdkEventCrossing *event)
{
g_return_val_if_fail (GTK_IS_ITEM (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
return gtk_widget_event (gtk_widget_get_parent (widget), (GdkEvent*) event);
}
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. 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/.
*/
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#ifndef __GTK_ITEM_H__
#define __GTK_ITEM_H__
#include <gtk/gtkbin.h>
G_BEGIN_DECLS
#define GTK_TYPE_ITEM (gtk_item_get_type ())
#define GTK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ITEM, GtkItem))
#define GTK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ITEM, GtkItemClass))
#define GTK_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ITEM))
#define GTK_IS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ITEM))
#define GTK_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ITEM, GtkItemClass))
typedef struct _GtkItem GtkItem;
typedef struct _GtkItemClass GtkItemClass;
struct _GtkItem
{
GtkBin bin;
};
struct _GtkItemClass
{
GtkBinClass parent_class;
void (* select) (GtkItem *item);
void (* deselect) (GtkItem *item);
void (* toggle) (GtkItem *item);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
GType gtk_item_get_type (void) G_GNUC_CONST;
void gtk_item_select (GtkItem *item);
void gtk_item_deselect (GtkItem *item);
void gtk_item_toggle (GtkItem *item);
G_END_DECLS
#endif /* __GTK_ITEM_H__ */
......@@ -51,6 +51,8 @@ enum {
ACTIVATE_ITEM,
TOGGLE_SIZE_REQUEST,
TOGGLE_SIZE_ALLOCATE,
SELECT,
DESELECT,
LAST_SIGNAL
};
......@@ -84,6 +86,10 @@ static void gtk_menu_item_realize (GtkWidget *widget);
static void gtk_menu_item_unrealize (GtkWidget *widget);
static void gtk_menu_item_map (GtkWidget *widget);
static void gtk_menu_item_unmap (GtkWidget *widget);
static gboolean gtk_menu_item_enter (GtkWidget *widget,
GdkEventCrossing *event);
static gboolean gtk_menu_item_leave (GtkWidget *widget,
GdkEventCrossing *event);
static void gtk_menu_item_paint (GtkWidget *widget,
GdkRectangle *area);
static gint gtk_menu_item_expose (GtkWidget *widget,
......@@ -92,8 +98,8 @@ static void gtk_menu_item_parent_set (GtkWidget *widget,
GtkWidget *previous_parent);
static void gtk_real_menu_item_select (GtkItem *item);
static void gtk_real_menu_item_deselect (GtkItem *item);
static void gtk_real_menu_item_select (GtkMenuItem *item);
static void gtk_real_menu_item_deselect (GtkMenuItem *item);
static void gtk_real_menu_item_activate (GtkMenuItem *item);
static void gtk_real_menu_item_activate_item (GtkMenuItem *item);
static void gtk_real_menu_item_toggle_size_request (GtkMenuItem *menu_item,
......@@ -162,7 +168,7 @@ static guint menu_item_signals[LAST_SIGNAL] = { 0 };
static GtkBuildableIface *parent_buildable_iface;
G_DEFINE_TYPE_WITH_CODE (GtkMenuItem, gtk_menu_item, GTK_TYPE_ITEM,
G_DEFINE_TYPE_WITH_CODE (GtkMenuItem, gtk_menu_item, GTK_TYPE_BIN,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
gtk_menu_item_buildable_interface_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
......@@ -180,7 +186,6 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
GtkItemClass *item_class = GTK_ITEM_CLASS (klass);
gobject_class->dispose = gtk_menu_item_dispose;
gobject_class->set_property = gtk_menu_item_set_property;
......@@ -194,6 +199,8 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
widget_class->unrealize = gtk_menu_item_unrealize;
widget_class->map = gtk_menu_item_map;
widget_class->unmap = gtk_menu_item_unmap;
widget_class->enter_notify_event = gtk_menu_item_enter;
widget_class->leave_notify_event = gtk_menu_item_leave;
widget_class->show_all = gtk_menu_item_show_all;
widget_class->hide_all = gtk_menu_item_hide_all;
widget_class->mnemonic_activate = gtk_menu_item_mnemonic_activate;
......@@ -202,15 +209,14 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
container_class->forall = gtk_menu_item_forall;
item_class->select = gtk_real_menu_item_select;
item_class->deselect = gtk_real_menu_item_deselect;
klass->activate = gtk_real_menu_item_activate;
klass->activate_item = gtk_real_menu_item_activate_item;
klass->toggle_size_request = gtk_real_menu_item_toggle_size_request;
klass->toggle_size_allocate = gtk_real_menu_item_toggle_size_allocate;
klass->set_label = gtk_real_menu_item_set_label;
klass->get_label = gtk_real_menu_item_get_label;
klass->select = gtk_real_menu_item_select;
klass->deselect = gtk_real_menu_item_deselect;
klass->hide_on_activate = TRUE;
......@@ -253,6 +259,24 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
G_TYPE_NONE, 1,
G_TYPE_INT);
menu_item_signals[SELECT] =
g_signal_new (I_("select"),
G_OBJECT_CLASS_TYPE (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkMenuItemClass, select),
NULL, NULL,
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
menu_item_signals[DESELECT] =
g_signal_new (I_("deselect"),
G_OBJECT_CLASS_TYPE (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkMenuItemClass, deselect),
NULL, NULL,
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* GtkMenuItem:right-justified:
*
......@@ -955,8 +979,6 @@ gtk_menu_item_get_height_for_width (GtkSizeRequest *request,
*natural_size = nat_height;
}
static void
gtk_menu_item_buildable_interface_init (GtkBuildableIface *iface)
{
......@@ -1230,7 +1252,7 @@ gtk_menu_item_select (GtkMenuItem *menu_item)
g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
gtk_item_select (GTK_ITEM (menu_item));
g_signal_emit (menu_item, menu_item_signals[SELECT], 0);
/* Enable themeing of the parent menu item depending on whether
* something is selected in its submenu
......@@ -1252,7 +1274,7 @@ gtk_menu_item_deselect (GtkMenuItem *menu_item)
g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
gtk_item_deselect (GTK_ITEM (menu_item));
g_signal_emit (menu_item, menu_item_signals[DESELECT], 0);
/* Enable themeing of the parent menu item depending on whether
* something is selected in its submenu
......@@ -1466,6 +1488,24 @@ gtk_menu_item_unmap (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_menu_item_parent_class)->unmap (widget);
}
static gboolean
gtk_menu_item_enter (GtkWidget *widget,
GdkEventCrossing *event)
{
g_return_val_if_fail (event != NULL, FALSE);
return gtk_widget_event (gtk_widget_get_parent (widget), (GdkEvent *) event);
}
static gboolean
gtk_menu_item_leave (GtkWidget *widget,
GdkEventCrossing *event)
{
g_return_val_if_fail (event != NULL, FALSE);
return gtk_widget_event (gtk_widget_get_parent (widget), (GdkEvent*) event);
}
static void
gtk_menu_item_paint (GtkWidget *widget,
GdkRectangle *area)
......@@ -1598,16 +1638,11 @@ gtk_menu_item_expose (GtkWidget *widget,
}
static void
gtk_real_menu_item_select (GtkItem *item)
gtk_real_menu_item_select (GtkMenuItem *menu_item)
{
GtkMenuItem *menu_item;
gboolean touchscreen_mode;
g_return_if_fail (GTK_IS_MENU_ITEM (item));
menu_item = GTK_MENU_ITEM (item);
g_object_get (gtk_widget_get_settings (GTK_WIDGET (item)),
g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_item)),
"gtk-touchscreen-mode", &touchscreen_mode,
NULL);
......@@ -1624,14 +1659,8 @@ gtk_real_menu_item_select (GtkItem *item)
}
static void
gtk_real_menu_item_deselect (GtkItem *item)
gtk_real_menu_item_deselect (GtkMenuItem *menu_item)
{
GtkMenuItem *menu_item;
g_return_if_fail (GTK_IS_MENU_ITEM (item));
menu_item = GTK_MENU_ITEM (item);
if (menu_item->submenu)
_gtk_menu_item_popdown_submenu (GTK_WIDGET (menu_item));
......
......@@ -31,8 +31,7 @@
#ifndef __GTK_MENU_ITEM_H__
#define __GTK_MENU_ITEM_H__
#include <gtk/gtkitem.h>
#include <gtk/gtkbin.h>
G_BEGIN_DECLS
......@@ -50,7 +49,7 @@ typedef struct _GtkMenuItemClass GtkMenuItemClass;
struct _GtkMenuItem
{
GtkItem item;
GtkBin bin;
GtkWidget *GSEAL (submenu);
GdkWindow *GSEAL (event_window);
......@@ -70,7 +69,7 @@ struct _GtkMenuItem
struct _GtkMenuItemClass
{
GtkItemClass parent_class;
GtkBinClass parent_class;
/* If the following flag is true, then we should always hide
* the menu when the MenuItem is activated. Otherwise, the
......@@ -90,9 +89,14 @@ struct _GtkMenuItemClass
const gchar *label);
G_CONST_RETURN gchar *(* get_label) (GtkMenuItem *menu_item);
void (* select) (GtkMenuItem *menu_item);
void (* deselect) (GtkMenuItem *menu_item);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
......
......@@ -1079,7 +1079,7 @@ gtk_menu_shell_remove (GtkContainer *container,
if (widget == menu_shell->active_menu_item)
{
gtk_item_deselect (GTK_ITEM (menu_shell->active_menu_item));
g_signal_emit_by_name (menu_shell->active_menu_item, "deselect");
menu_shell->active_menu_item = NULL;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment