ekiga r6479 - in trunk: . lib/engine/framework
- From: jpuydt svn gnome org
- To: svn-commits-list gnome org
- Subject: ekiga r6479 - in trunk: . lib/engine/framework
- Date: Mon, 21 Jul 2008 20:24:06 +0000 (UTC)
Author: jpuydt
Date: Mon Jul 21 20:24:06 2008
New Revision: 6479
URL: http://svn.gnome.org/viewvc/ekiga?rev=6479&view=rev
Log:
Moved ShortMenuBuilder out into menu-builder-tools, and added TriggerMenuBuilder
Added:
trunk/lib/engine/framework/menu-builder-tools.cpp
- copied, changed from r6478, /trunk/lib/engine/framework/menu-builder.cpp
trunk/lib/engine/framework/menu-builder-tools.h
- copied, changed from r6478, /trunk/lib/engine/framework/menu-builder.h
Modified:
trunk/ChangeLog
trunk/lib/engine/framework/Makefile.am
trunk/lib/engine/framework/menu-builder.cpp
trunk/lib/engine/framework/menu-builder.h
Modified: trunk/lib/engine/framework/Makefile.am
==============================================================================
--- trunk/lib/engine/framework/Makefile.am (original)
+++ trunk/lib/engine/framework/Makefile.am Mon Jul 21 20:24:06 2008
@@ -22,9 +22,11 @@
$(framework_dir)/gmconf-bridge.cpp \
$(framework_dir)/map-key-reference-iterator.h \
$(framework_dir)/map-key-const-reference-iterator.h \
- $(framework_dir)/menu-builder.h \
$(framework_dir)/runtime.h \
+ $(framework_dir)/menu-builder.h \
$(framework_dir)/menu-builder.cpp \
+ $(framework_dir)/menu-builder-tools.h \
+ $(framework_dir)/menu-builder-tools.cpp \
$(framework_dir)/form-builder.cpp \
$(framework_dir)/form-dumper.cpp \
$(framework_dir)/form-request-simple.cpp \
Copied: trunk/lib/engine/framework/menu-builder-tools.cpp (from r6478, /trunk/lib/engine/framework/menu-builder.cpp)
==============================================================================
--- /trunk/lib/engine/framework/menu-builder.cpp (original)
+++ trunk/lib/engine/framework/menu-builder-tools.cpp Mon Jul 21 20:24:06 2008
@@ -1,7 +1,7 @@
/*
* Ekiga -- A VoIP and Video-Conferencing application
- * Copyright (C) 2000-2007 Damien Sandras
+ * Copyright (C) 2000-2008 Damien Sandras
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -25,74 +25,74 @@
/*
- * menu-builder.cpp - description
+ * menu-builder-tools.cpp - description
* ------------------------------------------
- * begin : written in 2007 by Julien Puydt
+ * begin : written in 2008 by Julien Puydt
* copyright : (c) 2007 by Julien Puydt
- * description : implementation of the interface of a menu builder
+ * description : implementation of tools to build menus
*
*/
-#include "menu-builder.h"
+#include "menu-builder-tools.h"
-Ekiga::MenuBuilder::~MenuBuilder ()
+Ekiga::ShortMenuBuilder::ShortMenuBuilder (MenuBuilder &builder_)
+ : builder(builder_), active(true)
{
- // nothing
+ /* nothing more */
}
-
void
-Ekiga::MenuBuilder::add_action (const std::string /*icon*/,
- const std::string /*label*/,
- sigc::slot<void> /*callback*/)
+Ekiga::ShortMenuBuilder::add_action (const std::string icon,
+ const std::string label,
+ sigc::slot<void> callback)
{
- // nothing
+ if (active)
+ builder.add_action (icon, label, callback);
}
-
void
-Ekiga::MenuBuilder::add_separator ()
+Ekiga::ShortMenuBuilder::add_separator ()
{
- // nothing
+ active = false;
}
-
-bool
-Ekiga::MenuBuilder::empty () const
+int
+Ekiga::ShortMenuBuilder::size () const
{
- return (size () == 0);
+ return builder.size ();
}
-int
-Ekiga::MenuBuilder::size () const
-{
- return 0;
-}
-Ekiga::ShortMenuBuilder::ShortMenuBuilder (MenuBuilder &builder_)
- : builder(builder_), active(true)
+Ekiga::TriggerMenuBuilder::TriggerMenuBuilder ()
+ : 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);
+Ekiga::TriggerMenuBuilder::add_action (const std::string /*icon*/,
+ const std::string /*label*/,
+ sigc::slot<void> callback)
+{
+ if (active) {
+
+ active = false;
+ callback ();
+ }
}
void
-Ekiga::ShortMenuBuilder::add_separator ()
+Ekiga::TriggerMenuBuilder::add_separator ()
{
- active = false;
+ /* nothing */
}
int
-Ekiga::ShortMenuBuilder::size () const
+Ekiga::TriggerMenuBuilder::size () const
{
- return builder.size ();
+ if (active)
+ return 0;
+ else
+ return 1;
}
Copied: trunk/lib/engine/framework/menu-builder-tools.h (from r6478, /trunk/lib/engine/framework/menu-builder.h)
==============================================================================
--- /trunk/lib/engine/framework/menu-builder.h (original)
+++ trunk/lib/engine/framework/menu-builder-tools.h Mon Jul 21 20:24:06 2008
@@ -1,7 +1,7 @@
/*
* Ekiga -- A VoIP and Video-Conferencing application
- * Copyright (C) 2000-2007 Damien Sandras
+ * Copyright (C) 2000-2008 Damien Sandras
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -25,69 +25,21 @@
/*
- * menu-builder.h - description
+ * menu-builder-tools.h - description
* ------------------------------------------
- * begin : written in 2007 by Julien Puydt
+ * begin : written in 2008 by Julien Puydt
* copyright : (c) 2007 by Julien Puydt
- * description : declaration of the interface of a menu builder
+ * description : declaration of tools to build menus
*
*/
-#ifndef __MENU_BUILDER_H__
-#define __MENU_BUILDER_H__
-
-#include <string>
-#include <sigc++/sigc++.h>
+#ifndef __MENU_BUILDER_TOOLS_H__
+#define __MENU_BUILDER_TOOLS_H__
+#include "menu-builder.h"
namespace Ekiga
{
-
-/**
- * @defgroup actions Actions
- * @{
- */
-
- /** Menu builder.
- *
- * This object serves to make objects toolkit-independent: an object can
- * add actions to a MenuBuilder, and the specific implementation will
- * take care of the GUI.
- * For example you can do in your GUI:
- * <pre>
- * MyToolkitMenuType *menu = new MyToolkitMenuType(whatever);
- * MyMenuBuilder builder(menu);
- *
- * toolkit_independent_object.populate_menu (builder);
- * </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 MenuBuilder
- {
- public:
-
- virtual ~MenuBuilder ();
-
- virtual void add_action (const std::string icon,
- const std::string label,
- sigc::slot<void> callback);
-
- virtual void add_separator ();
-
- virtual bool empty () const;
-
- virtual int size () const;
- };
-
/** Short menu builder
*
* This object is in fact a filter for a MenuBuilder ; you sometimes don't
@@ -125,7 +77,7 @@
class ShortMenuBuilder: public MenuBuilder
{
- ShortMenuBuilder (MenuBuilder &builder);
+ ShortMenuBuilder (MenuBuilder& builder);
void add_action (const std::string icon,
const std::string label,
@@ -136,13 +88,40 @@
int size () const;
private:
- MenuBuilder &builder;
+ MenuBuilder& builder;
bool active;
};
-/**
- * @}
- */
+ /** Trigger menu builder
+ *
+ * This menu builder doesn't really build a menu : it just makes it
+ * look like it does, but it just triggers the first action given to it.
+ * The goal is to make it easy to add a default action on an object : the
+ * first one in its populated menu.
+ *
+ * For example, you can do :
+ * <pre>
+ * TriggerMenuBuilder builder;
+ *
+ * object->populate_menu (builder);
+ * </pre>
+
+ */
+ class TriggerMenuBuilder: public MenuBuilder
+ {
+ TriggerMenuBuilder ();
+
+ void add_action (const std::string icon,
+ const std::string label,
+ sigc::slot<void> callback);
+
+ void add_separator ();
+
+ int size () const;
+
+ private:
+ bool active;
+ };
};
Modified: trunk/lib/engine/framework/menu-builder.cpp
==============================================================================
--- trunk/lib/engine/framework/menu-builder.cpp (original)
+++ trunk/lib/engine/framework/menu-builder.cpp Mon Jul 21 20:24:06 2008
@@ -69,30 +69,3 @@
{
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 Mon Jul 21 20:24:06 2008
@@ -88,58 +88,6 @@
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]