[glom] gmenu: AddDel: Replace UIManager.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] gmenu: AddDel: Replace UIManager.
- Date: Wed, 25 Sep 2013 08:15:21 +0000 (UTC)
commit f204d46bafd6d38d89f3eee2cfbbef4369cdbb8d
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Sep 16 20:50:25 2013 +0200
gmenu: AddDel: Replace UIManager.
glom/mode_data/db_adddel/db_adddel.cc | 2 +-
glom/mode_data/db_adddel/db_adddel.h | 1 -
glom/utility_widgets/adddel/adddel.cc | 61 ++++++++++++++++++++-------------
glom/utility_widgets/adddel/adddel.h | 6 ++--
4 files changed, 41 insertions(+), 29 deletions(-)
---
diff --git a/glom/mode_data/db_adddel/db_adddel.cc b/glom/mode_data/db_adddel/db_adddel.cc
index 6b985af..867d4b5 100644
--- a/glom/mode_data/db_adddel/db_adddel.cc
+++ b/glom/mode_data/db_adddel/db_adddel.cc
@@ -258,7 +258,7 @@ void DbAddDel::setup_menu(Gtk::Widget* /* widget */)
//TODO: add_accel_group(builder->get_accel_group());
- Glib::ustring ui_info =
+ const Glib::ustring ui_info =
"<interface>"
" <menu id='ContextMenu'>"
" <section>"
diff --git a/glom/mode_data/db_adddel/db_adddel.h b/glom/mode_data/db_adddel/db_adddel.h
index ddbbe95..3c4d7b9 100644
--- a/glom/mode_data/db_adddel/db_adddel.h
+++ b/glom/mode_data/db_adddel/db_adddel.h
@@ -25,7 +25,6 @@
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/treeview.h>
#include <gtkmm/liststore.h>
-#include <gtkmm/builder.h>
#include <libglom/data_structure/layout/layoutitem_field.h>
#include <glom/mode_data/datawidget/treemodel_db.h>
#include <libglom/document/document.h>
diff --git a/glom/utility_widgets/adddel/adddel.cc b/glom/utility_widgets/adddel/adddel.cc
index 943589c..c39cd98 100644
--- a/glom/utility_widgets/adddel/adddel.cc
+++ b/glom/utility_widgets/adddel/adddel.cc
@@ -29,6 +29,8 @@
#include <glom/dialog_invalid_data.h>
#include <glom/utils_ui.h>
#include <libglom/utils.h>
+#include <gtkmm/builder.h>
+#include <giomm/menu.h>
//#include <glom/bakery/app_gtk.h>
#include <iostream> //For debug output.
@@ -228,37 +230,43 @@ void AddDel::on_MenuPopup_activate_Delete()
void AddDel::setup_menu(Gtk::Widget* /* widget */)
{
- m_refActionGroup = Gtk::ActionGroup::create();
- m_refActionGroup->add(Gtk::Action::create("ContextMenu", "Context Menu") );
+ m_refActionGroup = Gio::SimpleActionGroup::create();
- m_refContextEdit = Gtk::Action::create("ContextEdit", _("_Edit"));
- m_refActionGroup->add(m_refContextEdit,
- sigc::mem_fun(*this, &AddDel::on_MenuPopup_activate_Edit) );
+ m_refContextEdit = m_refActionGroup->add_action("edit",
+ sigc::mem_fun(*this, &AddDel::on_MenuPopup_activate_Edit) );
if(get_allow_user_actions())
{
- m_refContextDelete = Gtk::Action::create("ContextDelete", _("_Delete"));
- m_refActionGroup->add(m_refContextDelete,
+ m_refContextDelete = m_refActionGroup->add_action("delete",
sigc::mem_fun(*this, &AddDel::on_MenuPopup_activate_Delete) );
}
- m_refUIManager = Gtk::UIManager::create();
-
- m_refUIManager->insert_action_group(m_refActionGroup);
-
- //TODO: add_accel_group(m_refUIManager->get_accel_group());
+ insert_action_group("context", m_refActionGroup);
+
+
+ Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create();
+
+ //TODO: add_accel_group(builder->get_accel_group());
+
+ const Glib::ustring ui_info =
+ "<interface>"
+ " <menu id='ContextMenu'>"
+ " <section>"
+ " <item>"
+ " <attribute name='label' translatable='yes'>_Edit</attribute>"
+ " <attribute name='action'>context.edit</attribute>"
+ " </item>"
+ " <item>"
+ " <attribute name='label' translatable='yes'>_Delete</attribute>"
+ " <attribute name='action'>context.delete</attribute>"
+ " </item>"
+ " </section>"
+ " </menu>"
+ "</interface>";
try
{
- Glib::ustring ui_info =
- "<ui>"
- " <popup name='ContextMenu'>"
- " <menuitem action='ContextEdit'/>"
- " <menuitem action='ContextDelete'/>"
- " </popup>"
- "</ui>";
-
- m_refUIManager->add_ui_from_string(ui_info);
+ builder->add_from_string(ui_info);
}
catch(const Glib::Error& ex)
{
@@ -266,9 +274,14 @@ void AddDel::setup_menu(Gtk::Widget* /* widget */)
}
//Get the menu:
- m_pMenuPopup = dynamic_cast<Gtk::Menu*>( m_refUIManager->get_widget("/ContextMenu") );
- if(!m_pMenuPopup)
- g_warning("menu not found");
+ Glib::RefPtr<Glib::Object> object =
+ builder->get_object("ContextMenu");
+ Glib::RefPtr<Gio::Menu> gmenu =
+ Glib::RefPtr<Gio::Menu>::cast_dynamic(object);
+ if(!gmenu)
+ g_warning("GMenu not found");
+
+ m_pMenuPopup = new Gtk::Menu(gmenu);
}
bool AddDel::on_button_press_event_Popup(GdkEventButton *event)
diff --git a/glom/utility_widgets/adddel/adddel.h b/glom/utility_widgets/adddel/adddel.h
index c3bf214..e080eb2 100644
--- a/glom/utility_widgets/adddel/adddel.h
+++ b/glom/utility_widgets/adddel/adddel.h
@@ -28,6 +28,7 @@
#include <gtkmm/box.h>
#include <gtkmm/liststore.h>
#include <gtkmm/uimanager.h>
+#include <giomm/simpleactiongroup.h>
#include <vector>
#include <map>
@@ -295,9 +296,8 @@ protected:
Glib::ustring m_strTextActiveCell; //value before the change
Gtk::Menu* m_pMenuPopup;
- Glib::RefPtr<Gtk::ActionGroup> m_refActionGroup;
- Glib::RefPtr<Gtk::UIManager> m_refUIManager;
- Glib::RefPtr<Gtk::Action> m_refContextEdit, m_refContextDelete;
+ Glib::RefPtr<Gio::SimpleActionGroup> m_refActionGroup;
+ Glib::RefPtr<Gio::SimpleAction> m_refContextEdit, m_refContextDelete;
bool m_auto_add;
bool m_allow_add;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]