ekiga r6425 - trunk/lib/engine/framework



Author: jpuydt
Date: Sun Jun 29 11:51:20 2008
New Revision: 6425
URL: http://svn.gnome.org/viewvc/ekiga?rev=6425&view=rev

Log:
Merge branch 'bugfixing'

Modified:
   trunk/lib/engine/framework/menu-builder.cpp
   trunk/lib/engine/framework/menu-builder.h

Modified: trunk/lib/engine/framework/menu-builder.cpp
==============================================================================
--- trunk/lib/engine/framework/menu-builder.cpp	(original)
+++ trunk/lib/engine/framework/menu-builder.cpp	Sun Jun 29 11:51:20 2008
@@ -69,3 +69,30 @@
 {
   return 0;
 }
+
+Ekiga::ShortMenuBuilder::ShortMenuBuilder (MenuBuilder &builder_)
+  : builder(builder_), active(true)
+{
+  /* nothing more */
+}
+
+void
+Ekiga::ShortMenuBuilder::add_action (const std::string icon,
+				     const std::string label,
+				     sigc::slot<void> callback)
+{
+  if (active)
+    builder.add_action (icon, label, callback);
+}
+
+void
+Ekiga::ShortMenuBuilder::add_separator ()
+{
+  active = false;
+}
+
+int
+Ekiga::ShortMenuBuilder::size () const
+{
+  return builder.size ();
+}

Modified: trunk/lib/engine/framework/menu-builder.h
==============================================================================
--- trunk/lib/engine/framework/menu-builder.h	(original)
+++ trunk/lib/engine/framework/menu-builder.h	Sun Jun 29 11:51:20 2008
@@ -88,6 +88,58 @@
     virtual int size () const;
   };
 
+  /** Short menu builder
+   *
+   * This object is in fact a filter for a MenuBuilder ; you sometimes don't
+   * want a long menu like this :
+   *  Action 1
+   *  Action 2
+   *  Separator
+   *  Action 3
+   *  Action 4
+   *  Action 5
+   *  Et caetera
+   * But would rather just have :
+   *  Action 1
+   *  Action 2
+   * since presumably only the actions before the separator are of interest.
+   *
+   * For example, you can do :
+   * <pre>
+   *   MyToolkitMenuType *menu = new MyToolkitMenuType (whatever);
+   *   MyMenuBuilder builder(menu);
+   *   Ekiga::ShortMenuBuilder shorter(builder);
+   *
+   *   toolkit_independent_object.populate_menu (shorter);
+   * </pre>
+   *
+   * now use builder->menu, which is toolkit-dependent!
+   *
+   * ! Notice !
+   * You better be sure the toolkit_independent_object will still live
+   * when using the obtained menu, or the user may trigger a now-dead
+   * action... for example it could be an object with "removed" &
+   * "updated" signals, and you watch those, which allow you to regenerate
+   * or discard the menu in due time.
+   */
+
+  class ShortMenuBuilder: public MenuBuilder
+  {
+    ShortMenuBuilder (MenuBuilder &builder);
+
+    void add_action (const std::string icon,
+		     const std::string label,
+		     sigc::slot<void> callback);
+
+    void add_separator ();
+
+    int size () const;
+
+  private:
+    MenuBuilder &builder;
+    bool active;
+  };
+
 /**
  * @}
  */



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