[gtkmm] MenuShell: Remove items().
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] MenuShell: Remove items().
- Date: Tue, 27 Jul 2010 12:53:06 +0000 (UTC)
commit c8e47b0db5505db0e10e74ce1d7286c2230958b5
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Jul 27 14:18:05 2010 +0200
MenuShell: Remove items().
* gtk/gtkmm/menu_elems.[h|cc]: Remove these files.
* gtk/src/menushell.[hg|ccg]: Remove the items() method and the list type and
helper classes that it uses, because GtkMenuShell::items is GSEALed.
ChangeLog | 8 ++
gtk/gtkmm/filelist.am | 2 -
gtk/gtkmm/menu_elems.cc | 286 -----------------------------------------------
gtk/gtkmm/menu_elems.h | 266 -------------------------------------------
gtk/src/menushell.ccg | 111 ++-----------------
gtk/src/menushell.hg | 32 +-----
6 files changed, 19 insertions(+), 686 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 297e320..84c73be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-07-27 Murray Cumming <murrayc murrayc com>
+
+ MenuShell: Remove items().
+
+ * gtk/gtkmm/menu_elems.[h|cc]: Remove these files.
+ * gtk/src/menushell.[hg|ccg]: Remove the items() method and the list type and
+ helper classes that it uses, because GtkMenuShell::items is GSEALed.
+
2010-07-15 Murray Cumming <murrayc murrayc com>
Remove RecentManager::get/set_limit() and the property.
diff --git a/gtk/gtkmm/filelist.am b/gtk/gtkmm/filelist.am
index 93e74af..1858cd4 100644
--- a/gtk/gtkmm/filelist.am
+++ b/gtk/gtkmm/filelist.am
@@ -11,7 +11,6 @@ gtkmm_files_extra_cc = \
comboboxentrytext.cc \
comboboxtext.cc \
listviewtext.cc \
- menu_elems.cc \
radiobuttongroup.cc \
selectiondata_private.cc \
stock.cc \
@@ -29,7 +28,6 @@ gtkmm_files_extra_h = \
comboboxentrytext.h \
comboboxtext.h \
listviewtext.h \
- menu_elems.h \
radiobuttongroup.h \
selectiondata_private.h \
stock.h \
diff --git a/gtk/src/menushell.ccg b/gtk/src/menushell.ccg
index 6ca9db1..0f3c676 100644
--- a/gtk/src/menushell.ccg
+++ b/gtk/src/menushell.ccg
@@ -29,7 +29,6 @@ namespace Gtk
MenuShell::MenuShell()
:
_CONSTRUCT_SPECIFIC(Gtk::Container, MenuShell),
- items_proxy_ (gobj()),
accel_window_ (0)
{}
@@ -37,14 +36,12 @@ MenuShell::MenuShell(const Glib::ConstructParams& construct_params)
:
Glib::ObjectBase(0),
Gtk::Container (construct_params),
- items_proxy_ (gobj()),
accel_window_ (0)
{}
MenuShell::MenuShell(GtkMenuShell* castitem)
:
Gtk::Container((GtkContainer*) castitem),
- items_proxy_ (gobj()),
accel_window_ (0)
{}
@@ -58,10 +55,17 @@ void MenuShell::accelerate(Window& window)
// after it has been accelerated.
accel_window_ = &window;
- const MenuList::iterator items_end = items().end();
+ typedef std::list<Gtk::Widget*> type_list_widgets;
+ type_list_widgets items = get_children();
+ const type_list_widgets::iterator items_end = items.end();
- for(MenuList::iterator iter = items().begin(); iter != items_end; ++iter)
- iter->accelerate(window);
+ for(type_list_widgets::iterator iter = items.begin(); iter != items_end; ++iter)
+ {
+ Gtk::Widget* widget = *iter;
+ Gtk::MenuItem* menuitem = dynamic_cast<MenuItem*>(widget);
+ if(menuitem)
+ menuitem->accelerate(window);
+ }
}
void MenuShell::accelerate(Widget& parent)
@@ -72,16 +76,6 @@ void MenuShell::accelerate(Widget& parent)
accelerate(*toplevel_window);
}
-MenuShell::MenuList& MenuShell::items()
-{
- return items_proxy_;
-}
-
-const MenuShell::MenuList& MenuShell::items() const
-{
- return items_proxy_;
-}
-
void MenuShell_Class::insert_vfunc_callback(GtkMenuShell* self, GtkWidget* child, int position)
{
try
@@ -107,90 +101,5 @@ void MenuShell_Class::insert_vfunc_callback(GtkMenuShell* self, GtkWidget* child
(*base->insert)(self, child, position);
}
-
-namespace Menu_Helpers
-{
-
-// List implementation:
-
-
-MenuList::iterator MenuList::insert(MenuList::iterator position, const Element& element)
-{
- const Glib::RefPtr<Gtk::MenuItem> item = element.get_child();
-
- g_return_val_if_fail(item != 0, position);
- g_return_val_if_fail(gparent() != 0, position);
-
- int pos = -1;
-
- if(position.node_)
- pos = g_list_position(glist(), position.node_);
-
- gtk_menu_shell_insert(gparent(), item->Widget::gobj(), pos);
-
- return --position;
-}
-
-void MenuList::remove(const_reference child)
-{
- const Widget& widget = child;
- remove(const_cast<Widget&>(widget));
-}
-
-void MenuList::remove(Widget& widget)
-{
- //This is the same as the standard implementation,
- //but we also unset the accel_label to avoid leaking its reference.
-
- //If it is a Bin, (actually we're looking for a MenuItem):
- if(GTK_IS_BIN(widget.gobj()))
- {
- //TODO: There is duplication here, with erase().
- //If the child's child is an AccelLabel then unset its accel widget:
- //This can't catch every possible AccelLabel in the hierarchy, but it
- //will catch the ones that we create in MenuItem::MenuItem() without
- //people being aware of it. People can take care of their own ones themselves.
- Gtk::AccelLabel* pAccelLabel = dynamic_cast<Gtk::AccelLabel*>(dynamic_cast<Gtk::Bin&>(widget).get_child());
- if(pAccelLabel) //If the child is an AccelLabel.
- {
- //The unset_accel_widget() method is not implemented in gtkmm until 2.4:
- gtk_accel_label_set_accel_widget(Glib::unwrap(pAccelLabel), 0);
- }
- }
-
- gtk_container_remove(GTK_CONTAINER(gparent_),
- (GtkWidget*)(widget.gobj()));
-}
-
-MenuList::iterator MenuList::erase(iterator position)
-{
- //Check that it is a valid iterator, to a real item:
- if ( !position.node_|| (position == end()) )
- return end();
-
- //Get an iterator the the next item, to return:
- iterator next = position;
- next++;
-
- GtkWidget* pChild = (GtkWidget*)(position->gobj());
- if(GTK_IS_BIN(pChild)) //A MenuItem is a Bin.
- {
- //If the child's child is an AccelLabel then unset it's accel widget:
- //This can't catch every possible AccelLabel in the hierarchy, but it
- //will catch the ones that we create in MenuItem::MenuItem() without
- //people being aware of it. People can take care of their own ones themselves.
- GtkWidget* pChildOfChild = (GtkWidget*)gtk_bin_get_child(GTK_BIN(pChild));
- if(GTK_IS_ACCEL_LABEL(pChildOfChild))
- gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(pChildOfChild), 0);
- }
-
- //Use GTK+ C function to remove it, by providing the GtkWidget*:
- gtk_container_remove( GTK_CONTAINER(gparent_), pChild );
-
- return next;
-}
-
-} // namespace Menu_Helpers
-
} // namespace Gtk
diff --git a/gtk/src/menushell.hg b/gtk/src/menushell.hg
index 8146637..21ef968 100644
--- a/gtk/src/menushell.hg
+++ b/gtk/src/menushell.hg
@@ -24,39 +24,16 @@ _PINCLUDE(gtkmm/menu.h)
_PINCLUDE(gtkmm/menubar.h)
_PINCLUDE(gtkmm/window.h)
-#m4 _PUSH(SECTION_CC_PRE_INCLUDES)
-//Allow us to set the struct fields.
-//TODO: We probably need to remove the STL-style children() API.
-#undef GSEAL_ENABLE
-#m4 _POP()
-
#include <gtkmm/container.h>
-#include <gtkmm/menu_elems.h>
+#include <gtkmm/menuitem.h>
#include <glibmm/helperlist.h>
namespace Gtk
{
class Menu;
-class MenuShell;
class Window;
-namespace Menu_Helpers
-{
-
-/*********************************************************************
-***** List properties
-*********************************************************************/
-
-#m4 include(list.m4)
- GP_LIST(MenuList,MenuShell,GtkMenuShell,MenuItem,children)
- GP_LIST_HELPER_NAMESPACE(Menu_Helpers)
- GP_LIST_ITER(Glib::List_Cpp_Iterator<GtkMenuItem, MenuItem>)
- virtual void remove(Widget& widget); //custom
- GP_LIST_END()
-
-} // namespace Menu_Helpers
-
/** The abstract base class for Gtk::Menu and Gtk::MenuBar.
* It is a container of Gtk::MenuItem objects arranged in a list which can be navigated, selected, and activated by the user to perform application functions.
@@ -74,9 +51,6 @@ class MenuShell : public Container
public:
_CUSTOM_DTOR()
- typedef Menu_Helpers::MenuList MenuList;
- friend class Menu_Helpers::MenuList;
-
_WRAP_METHOD(void append(MenuItem& menu_item), gtk_menu_shell_append)
_WRAP_METHOD(void prepend(MenuItem& menu_item), gtk_menu_shell_prepend)
_WRAP_METHOD(void insert(MenuItem& menu_item, int position), gtk_menu_shell_insert)
@@ -100,9 +74,6 @@ public:
_IGNORE_SIGNAL("cancel")
_IGNORE_SIGNAL("cycle-focus")
- MenuList& items();
- const MenuList& items() const;
-
/**
* Initializes menu accelerators.
* This method initializes the menu accelerators. Therefore an
@@ -160,7 +131,6 @@ dnl // Override GtkMenuItem::insert, in order to accelerate all menu items autom
_POP()
#m4end
- MenuList items_proxy_;
Gtk::Window* accel_window_;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]