Re: [gtkmm] StockMenuElems with submenu not possible?



Murray Cumming wrote:
On Mon, 2002-10-21 at 11:51, Christof Petig wrote:

Recently one of the glade-- users managed to create a stock menu item with a submenu. (actually it was "help" IIRC)

But StockMenuElem lacks a ctor with a submenu argument. Do I guess right that simply nobody ever tried to use such a thing, before?

Should I provide a patch or are there any reasons for not having

StockMenuElem::StockMenuElem(const Gtk::StockID& stock_id, [const AccelKey& key,] Gtk::Menu& submenu);


A patch would be welcome. But we need it before Wednesday. And please be
sure to test the new API in one of the examples - maybe
example/book/menus.


here it is. Not in time for "before Wednesday" but a hard disk crash costed me some time (and the fact that I managed to electrically destroy the new hd :-( ).

   Christof
? stock.patch
? docs/FAQ/index.html
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkmm-root/base/ChangeLog,v
retrieving revision 1.548
diff -u -r1.548 ChangeLog
--- ChangeLog	23 Oct 2002 01:49:54 -0000	1.548
+++ ChangeLog	23 Oct 2002 15:53:02 -0000
@@ -1,3 +1,9 @@
+2002-10-23  Christof Petig  <christof petig-baender de>
+
+	* gtk/gtkmm/menu_elems.*: provide constructors for a StockMenuElems
+	with a submenu
+	* examples/book/menus/main_menu/examplewindow.*: test it
+
 2002-10-23  Daniel Elstner  <daniel elstner gmx net>
 
 	* glib/glibmm/property.h: Don't use extern "C" for callback
Index: examples/book/menus/main_menu/examplewindow.cc
===================================================================
RCS file: /cvs/gnome/gtkmm-root/examples/book/menus/main_menu/examplewindow.cc,v
retrieving revision 1.2
diff -u -r1.2 examplewindow.cc
--- examples/book/menus/main_menu/examplewindow.cc	19 Jul 2002 15:58:52 -0000	1.2
+++ examples/book/menus/main_menu/examplewindow.cc	23 Oct 2002 15:53:02 -0000
@@ -57,10 +57,19 @@
     menulist.push_back( Gtk::Menu_Helpers::MenuElem("_Paste",
       SigC::slot(*this, &ExampleWindow::on_menu_others) ) );
   }
+  
+  //Help menu: (exercise stock items)
+  {
+    Gtk::Menu::MenuList& menulist = m_Menu_Help.items();
+    
+    menulist.push_back( Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-cdrom"),
+      SigC::slot(*this, &ExampleWindow::on_menu_others) ) );
+  }
 
   //Add the menus to the MenuBar:
   m_MenuBar.items().push_back( Gtk::Menu_Helpers::MenuElem("_File", m_Menu_File) );
   m_MenuBar.items().push_back( Gtk::Menu_Helpers::MenuElem("_Edit", m_Menu_Edit) );
+  m_MenuBar.items().push_back( Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-help"), m_Menu_Help) );
 
   //Add the MenuBar to the window:
   m_Box.pack_start(m_MenuBar, Gtk::PACK_SHRINK);
Index: examples/book/menus/main_menu/examplewindow.h
===================================================================
RCS file: /cvs/gnome/gtkmm-root/examples/book/menus/main_menu/examplewindow.h,v
retrieving revision 1.1
diff -u -r1.1 examplewindow.h
--- examples/book/menus/main_menu/examplewindow.h	13 Jul 2002 15:58:34 -0000	1.1
+++ examples/book/menus/main_menu/examplewindow.h	23 Oct 2002 15:53:02 -0000
@@ -41,6 +41,7 @@
   Gtk::MenuBar m_MenuBar;
   Gtk::Menu m_Menu_File, m_Menu_Edit;
   Gtk::Menu m_Menu_File_New; //submenu.
+  Gtk::Menu m_Menu_Help;
 };
 
 #endif //GTKMM_EXAMPLEWINDOW_H
Index: gtk/gtkmm/menu_elems.cc
===================================================================
RCS file: /cvs/gnome/gtkmm-root/gtk-build/menu_elems.cc,v
retrieving revision 1.14
diff -u -r1.14 menu_elems.cc
--- gtk/gtkmm/menu_elems.cc	11 Oct 2002 18:05:49 -0000	1.14
+++ gtk/gtkmm/menu_elems.cc	23 Oct 2002 15:53:03 -0000
@@ -174,6 +174,24 @@
   child_->show();
 }
 
+StockMenuElem::StockMenuElem(const Gtk::StockID& stock_id,
+                             Gtk::Menu& submenu)
+{
+  child_ = manage(new ImageMenuItem(stock_id));
+  child_->set_submenu(submenu);
+  child_->show();
+}
+
+StockMenuElem::StockMenuElem(const Gtk::StockID& stock_id,
+                             const AccelKey& accel_key,
+                             Gtk::Menu& submenu)
+{
+  child_ = manage(new ImageMenuItem(stock_id));
+  set_accel_key(accel_key);
+  child_->set_submenu(submenu);
+  child_->show();
+}
+
 CheckMenuElem::CheckMenuElem(CheckMenuItem& child)
 : Element(child)
 {}
Index: gtk/gtkmm/menu_elems.h
===================================================================
RCS file: /cvs/gnome/gtkmm-root/gtk-build/menu_elems.h,v
retrieving revision 1.11
diff -u -r1.11 menu_elems.h
--- gtk/gtkmm/menu_elems.h	11 Oct 2002 18:05:49 -0000	1.11
+++ gtk/gtkmm/menu_elems.h	23 Oct 2002 15:53:03 -0000
@@ -173,6 +173,22 @@
   StockMenuElem(const Gtk::StockID& stock_id,
                 const AccelKey& key,
                 const CallSlot& slot = CallSlot());
+
+  /** Create a non-accelerated MenuItem from a stock item with a submenu
+   * @param stock_id The ID of the stock item
+   * @param submenu The sub menu
+   */
+  StockMenuElem(const Gtk::StockID& stock_id,
+                Gtk::Menu& submenu);
+
+  /** Create an accelerated MenuItem from a stock item with a submenu
+   * @param stock_id The ID of the stock item
+   * @param key The accelerator key combination
+   * @param submenu The sub menu
+   */
+  StockMenuElem(const Gtk::StockID& stock_id,
+                const AccelKey& key,
+                Gtk::Menu& submenu);
 };
 
 class CheckMenuElem : public Element


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]