[gtkmm] Add Gtk::ModelButton, Gtk::PopoverMenu and enum Gtk::ButtonRole



commit e26d83079341d39e57d079e9d7957f3a4d86db0a
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Thu Apr 9 18:29:26 2015 +0200

    Add Gtk::ModelButton, Gtk::PopoverMenu and enum Gtk::ButtonRole
    
    * .gitignore: Add new generated files in gtk/gtkmm.
    * gtk/gtkmm.h: Add modelbutton.h and popovermenu.h.
    * gtk/src/filelist.am: Add modelbutton.hg and popovermenu.hg.
    * gtk/src/gtk_signals.defs: Regenerated.
    * tools/extra_defs_gen/generate_defs_gtk.cc: Add GTK_TYPE_MODEL_BUTTON and
    GTK_TYPE_POPOVER_MENU.
    * tools/m4/convert_gtk.m4: Add _CONV_ENUM(Gtk,ButtonRole).
    * gtk/src/modelbutton.[hg|ccg]:
    * gtk/src/popovermenu.[hg|ccg]: New files.

 .gitignore                                |    4 +
 gtk/gtkmm.h                               |    2 +
 gtk/src/filelist.am                       |    2 +
 gtk/src/gtk_signals.defs                  |  103 +++++++++++++++++++++++++++++
 gtk/src/modelbutton.ccg                   |   17 +++++
 gtk/src/modelbutton.hg                    |   78 ++++++++++++++++++++++
 gtk/src/popovermenu.ccg                   |   17 +++++
 gtk/src/popovermenu.hg                    |   68 +++++++++++++++++++
 tools/extra_defs_gen/generate_defs_gtk.cc |    3 +
 tools/m4/convert_gtk.m4                   |    1 +
 10 files changed, 295 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e9b2b5c..e8f48d5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -351,6 +351,8 @@ gtk/gtkmm/messagedialog.cc
 gtk/gtkmm/messagedialog.h
 gtk/gtkmm/misc.cc
 gtk/gtkmm/misc.h
+gtk/gtkmm/modelbutton.cc
+gtk/gtkmm/modelbutton.h
 gtk/gtkmm/notebook.cc
 gtk/gtkmm/notebook.h
 gtk/gtkmm/numerableicon.cc
@@ -375,6 +377,8 @@ gtk/gtkmm/plug.cc
 gtk/gtkmm/plug.h
 gtk/gtkmm/popover.cc
 gtk/gtkmm/popover.h
+gtk/gtkmm/popovermenu.cc
+gtk/gtkmm/popovermenu.h
 gtk/gtkmm/printcontext.cc
 gtk/gtkmm/printcontext.h
 gtk/gtkmm/printer.cc
diff --git a/gtk/gtkmm.h b/gtk/gtkmm.h
index 6a51913..c656130 100644
--- a/gtk/gtkmm.h
+++ b/gtk/gtkmm.h
@@ -209,6 +209,7 @@ extern const int gtkmm_micro_version;
 #include <gtkmm/menushell.h>
 #include <gtkmm/messagedialog.h>
 #include <gtkmm/misc.h>
+#include <gtkmm/modelbutton.h>
 #include <gtkmm/notebook.h>
 #include <gtkmm/numerableicon.h>
 #include <gtkmm/object.h>
@@ -222,6 +223,7 @@ extern const int gtkmm_micro_version;
 #include <gtkmm/papersize.h>
 #include <gtkmm/placessidebar.h>
 #include <gtkmm/popover.h>
+#include <gtkmm/popovermenu.h>
 #include <gtkmm/printcontext.h>
 #ifndef G_OS_WIN32
 # include <gtkmm/printer.h>
diff --git a/gtk/src/filelist.am b/gtk/src/filelist.am
index f80b986..ba40433 100644
--- a/gtk/src/filelist.am
+++ b/gtk/src/filelist.am
@@ -120,6 +120,7 @@ gtkmm_files_any_hg =                \
        menutoolbutton.hg       \
        messagedialog.hg        \
        misc.hg                 \
+       modelbutton.hg \
        notebook.hg             \
        offscreenwindow.hg      \
        orientable.hg           \
@@ -129,6 +130,7 @@ gtkmm_files_any_hg =                \
        papersize.hg            \
        placessidebar.hg        \
        popover.hg      \
+       popovermenu.hg  \
        printcontext.hg         \
        printoperation.hg       \
        printoperationpreview.hg\
diff --git a/gtk/src/gtk_signals.defs b/gtk/src/gtk_signals.defs
index 9cc0585..002f832 100644
--- a/gtk/src/gtk_signals.defs
+++ b/gtk/src/gtk_signals.defs
@@ -6286,6 +6286,80 @@
   (construct-only #f)
 )
 
+;; From GtkModelButton
+
+(define-property role
+  (of-object "GtkModelButton")
+  (prop-type "GParamEnum")
+  (docs "The role of this button")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
+(define-property icon
+  (of-object "GtkModelButton")
+  (prop-type "GParamObject")
+  (docs "The icon")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
+(define-property text
+  (of-object "GtkModelButton")
+  (prop-type "GParamString")
+  (docs "The text")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
+(define-property active
+  (of-object "GtkModelButton")
+  (prop-type "GParamBoolean")
+  (docs "Active")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
+(define-property menu-name
+  (of-object "GtkModelButton")
+  (prop-type "GParamString")
+  (docs "The name of the menu to open")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
+(define-property inverted
+  (of-object "GtkModelButton")
+  (prop-type "GParamBoolean")
+  (docs "Whether the menu is a parent")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
+(define-property centered
+  (of-object "GtkModelButton")
+  (prop-type "GParamBoolean")
+  (docs "Whether to center the contents")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
+(define-property iconic
+  (of-object "GtkModelButton")
+  (prop-type "GParamBoolean")
+  (docs "Whether to prefer the icon over text")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
 ;; From GtkNotebook
 
 (define-signal switch-page
@@ -6821,6 +6895,17 @@
   (construct-only #f)
 )
 
+;; From GtkPopoverMenu
+
+(define-property visible-submenu
+  (of-object "GtkPopoverMenu")
+  (prop-type "GParamString")
+  (docs "The name of the visible submenu")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
 ;; From GtkPrinter
 
 (define-signal details-acquired
@@ -13196,6 +13281,24 @@
   (construct-only #f)
 )
 
+(define-child-property submenu
+  (of-object "GtkPopoverMenu")
+  (prop-type "GParamString")
+  (docs "The name of the submenu")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
+(define-child-property position
+  (of-object "GtkPopoverMenu")
+  (prop-type "GParamInt")
+  (docs "The index of the child in the parent")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
 (define-child-property name
   (of-object "GtkStack")
   (prop-type "GParamString")
diff --git a/gtk/src/modelbutton.ccg b/gtk/src/modelbutton.ccg
new file mode 100644
index 0000000..8eaff97
--- /dev/null
+++ b/gtk/src/modelbutton.ccg
@@ -0,0 +1,17 @@
+/* Copyright (C) 2015 The gtkmm Development Team
+ *
+ * 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.1 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtk/gtk.h>
diff --git a/gtk/src/modelbutton.hg b/gtk/src/modelbutton.hg
new file mode 100644
index 0000000..e6a2a87
--- /dev/null
+++ b/gtk/src/modelbutton.hg
@@ -0,0 +1,78 @@
+/* Copyright (C) 2015 The gtkmm Development Team
+ *
+ * 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.1 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtkmm/button.h>
+#include <giomm/icon.h>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(gtkmm/private/button_p.h)
+
+namespace Gtk
+{
+_WRAP_ENUM(ButtonRole, GtkButtonRole)
+
+/** A button that uses a Gio::Action as model.
+ *
+ * ModelButton is a button class that can use a Gio::Action as its model.
+ * In contrast to ToggleButton or RadioButton, which can also
+ * be backed by a Gio::Action via Actionable::property_action_name(),
+ * ModelButton will adapt its appearance according to the kind of
+ * action it is backed by, and appear either as a plain, check or radio button.
+ *
+ * Model buttons are used with popovers from a menu model bound to the popover.
+ * They can also be used manually in a PopoverMenu.
+ *
+ * When the action is specified via Actionable::property_action_name()
+ * and Actionable::property_action_target(), the role of the button
+ * (i.e. whether it is a plain, check or radio button) is determined by
+ * the type of the action and doesn't have to be explicitly specified
+ * with property_role().
+ *
+ * The content of the button is specified by property_text() and property_icon().
+ *
+ * The appearance of model buttons can be influenced with
+ * property_centered() and property_iconic().
+ *
+ * Model buttons have built-in support for submenus in PopoverMenu.
+ * To make a ModelButton that opens a submenu when activated, set
+ * property_menu_name(). To make a button that goes
+ * back to the parent menu, you should set property_inverted()
+ * to place the submenu indicator at the opposite side.
+ *
+ * @newin{3,18}
+ *
+ * @ingroup Widgets
+ */
+class ModelButton : public Button
+{
+  _CLASS_GTKOBJECT(ModelButton, GtkModelButton, GTK_MODEL_BUTTON, Gtk::Button, GtkButton)
+
+public:
+  _CTOR_DEFAULT
+
+  _WRAP_PROPERTY("role", ButtonRole)
+  _WRAP_PROPERTY("icon", Gio::Icon)
+  _WRAP_PROPERTY("text", Glib::ustring)
+  _WRAP_PROPERTY("active", bool)
+  _WRAP_PROPERTY("menu-name", Glib::ustring)
+  _WRAP_PROPERTY("inverted", bool)
+  _WRAP_PROPERTY("centered", bool)
+  _WRAP_PROPERTY("iconic", bool)
+
+  // ModelButton has no methods, signals, child properties nor vfuncs.
+};
+
+} //namespace Gtk
diff --git a/gtk/src/popovermenu.ccg b/gtk/src/popovermenu.ccg
new file mode 100644
index 0000000..8eaff97
--- /dev/null
+++ b/gtk/src/popovermenu.ccg
@@ -0,0 +1,17 @@
+/* Copyright (C) 2015 The gtkmm Development Team
+ *
+ * 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.1 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtk/gtk.h>
diff --git a/gtk/src/popovermenu.hg b/gtk/src/popovermenu.hg
new file mode 100644
index 0000000..aab0e9d
--- /dev/null
+++ b/gtk/src/popovermenu.hg
@@ -0,0 +1,68 @@
+/* Copyright (C) 2015 The gtkmm Development Team
+ *
+ * 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.1 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtkmm/popover.h>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(gtkmm/private/popover_p.h)
+
+namespace Gtk
+{
+/** A Popover to use as a menu.
+ *
+ * PopoverMenu is a subclass of Popover that treats its
+ * childen like menus and allows switching between them. It is
+ * meant to be used primarily together with ModelButton, but
+ * any widget can be used, such as SpinButton or Scale.
+ * In this respect, PopoverMenu is more flexible than popovers
+ * that are created from a Gio::MenuModel.
+ *
+ * To add a child as a submenu, set the child_property_submenu()
+ * to the name of the submenu. To let the user open
+ * this submenu, add a ModelButton whose ModelButton::property_menu_name()
+ * is set to the name you've given to the submenu.
+ *
+ * By convention, the first child of a submenu should be a ModelButton
+ * to switch back to the parent menu. Such a button should use
+ * ModelButton::property_inverted() and ModelButton::property_centered()
+ * to achieve a title-like appearance and place the submenu indicator
+ * at the opposite side. To switch back to the main menu, use "main"
+ * as the menu name.
+ *
+ * @newin{3,18}
+ *
+ * @ingroup Widgets
+ * @ingroup Containers
+ * @ingroup Menus
+ */
+class PopoverMenu : public Popover
+{
+  _CLASS_GTKOBJECT(PopoverMenu, GtkPopoverMenu, GTK_POPOVER_MENU, Gtk::Popover, GtkPopover)
+
+public:
+  _CTOR_DEFAULT
+
+  _WRAP_METHOD(void open_submenu(const Glib::ustring& name), gtk_popover_menu_open_submenu)
+
+  _WRAP_PROPERTY("visible-submenu", Glib::ustring)
+
+  _WRAP_CHILD_PROPERTY("submenu", Glib::ustring)
+  _WRAP_CHILD_PROPERTY("position", int)
+
+  // PopoverMenu has no signals nor vfuncs.
+};
+
+} //namespace Gtk
diff --git a/tools/extra_defs_gen/generate_defs_gtk.cc b/tools/extra_defs_gen/generate_defs_gtk.cc
index 638a17c..efdcb25 100644
--- a/tools/extra_defs_gen/generate_defs_gtk.cc
+++ b/tools/extra_defs_gen/generate_defs_gtk.cc
@@ -156,6 +156,7 @@ int main(int argc, char** argv)
             << get_defs( GTK_TYPE_MENU_TOOL_BUTTON )
             << get_defs( GTK_TYPE_MESSAGE_DIALOG )
             << get_defs( GTK_TYPE_MISC )
+            << get_defs( GTK_TYPE_MODEL_BUTTON )
             << get_defs( GTK_TYPE_NOTEBOOK )
             << get_defs( GTK_TYPE_NUMERABLE_ICON )
             << get_defs( GTK_TYPE_OFFSCREEN_WINDOW )
@@ -167,6 +168,7 @@ int main(int argc, char** argv)
             << get_defs( GTK_TYPE_PLUG )
 #endif
             << get_defs( GTK_TYPE_POPOVER )
+            << get_defs( GTK_TYPE_POPOVER_MENU )
 #if !defined(G_OS_WIN32) 
             << get_defs( GTK_TYPE_PRINTER )
             << get_defs( GTK_TYPE_PRINT_JOB )
@@ -260,6 +262,7 @@ int main(int argc, char** argv)
             << get_child_properties( GTK_TYPE_LIST_BOX )
             << get_child_properties( GTK_TYPE_MENU_SHELL )
             << get_child_properties( GTK_TYPE_NOTEBOOK )
+            << get_child_properties( GTK_TYPE_POPOVER_MENU )
 #ifdef GDK_WINDOWING_X11
             << get_child_properties( GTK_TYPE_SOCKET )
 #endif
diff --git a/tools/m4/convert_gtk.m4 b/tools/m4/convert_gtk.m4
index e65a0c8..371daaf 100644
--- a/tools/m4/convert_gtk.m4
+++ b/tools/m4/convert_gtk.m4
@@ -70,6 +70,7 @@ _CONV_ENUM(Gtk,Align)
 _CONV_ENUM(Gtk,ArrowType)
 _CONV_ENUM(Gtk,AttachOptions)
 _CONV_ENUM(Gtk,ButtonBoxStyle)
+_CONV_ENUM(Gtk,ButtonRole)
 _CONV_ENUM(Gtk,ButtonsType)
 _CONV_ENUM(Gtk,CalendarDisplayOptions)
 _CONV_ENUM(Gtk,CellRendererMode)


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