diff options
author | Ryan Lortie <desrt@desrt.ca> | 2012-09-11 11:38:06 -0400 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2012-09-17 12:31:22 -0400 |
commit | dd143479fe85f16e4ea010a7b03d4365d9d9234e (patch) | |
tree | 6101e20075598591dcfa355c5c12f9c73b250937 /gtk/gtkmenubar.c | |
parent | 778aa7ade0107fa645ab1427132551d138c7334a (diff) | |
download | gtk+-dd143479fe85f16e4ea010a7b03d4365d9d9234e.tar.gz |
gtkmodelmenu: simplify logic, expose bind API
Make the main (and only) entry-point to gtkmodelmenu.c the now-public
gtk_menu_shell_bind_model().
Move the convenience constructors (gtk_menu_new_from_model() and
gtk_menu_bar_new_from_model()) to their proper files.
Remove the private header file.
Simplify the code a bit by making the initial populate part of the
bind() call.
https://bugzilla.gnome.org/show_bug.cgi?id=682831
Diffstat (limited to 'gtk/gtkmenubar.c')
-rw-r--r-- | gtk/gtkmenubar.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c index c4f7e9f0d6..b90e4b8921 100644 --- a/gtk/gtkmenubar.c +++ b/gtk/gtkmenubar.c @@ -1041,3 +1041,32 @@ gtk_menu_bar_set_child_pack_direction (GtkMenuBar *menubar, g_object_notify (G_OBJECT (menubar), "child-pack-direction"); } } + +/** + * gtk_menu_bar_new_from_model: + * @model: a #GMenuModel + * + * Creates a new #GtkMenuBar and populates it with menu items + * and submenus according to @model. + * + * The created menu items are connected to actions found in the + * #GtkApplicationWindow to which the menu bar belongs - typically + * by means of being contained within the #GtkApplicationWindows + * widget hierarchy. + * + * Returns: a new #GtkMenuBar + * + * Since: 3.4 + */ +GtkWidget * +gtk_menu_bar_new_from_model (GMenuModel *model) +{ + GtkWidget *menubar; + + g_return_val_if_fail (G_IS_MENU_MODEL (model), NULL); + + menubar = gtk_menu_bar_new (); + gtk_menu_shell_bind_model (GTK_MENU_SHELL (menubar), model, NULL, FALSE); + + return menubar; +} |