[glom/maemo5] Added a Hildon::AppMenu
- From: Murray Cumming <murrayc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glom/maemo5] Added a Hildon::AppMenu
- Date: Mon, 7 Sep 2009 21:24:45 +0000 (UTC)
commit 702c4257acca68aab8bdce39fef03bc11a5366ff
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Sep 7 19:49:57 2009 +0200
Added a Hildon::AppMenu
glom/application.cc | 91 ++++++++++++--------
glom/application.h | 21 +++++-
glom/bakery/app_withdoc_gtk.cc | 30 ++++---
glom/bakery/app_withdoc_gtk.h | 2 +
glom/box_reports.cc | 2 +-
glom/frame_glom.cc | 45 ++++++----
glom/frame_glom.h | 2 +
glom/main.cc | 9 ++-
.../utility_widgets/canvas/canvas_image_movable.cc | 4 +-
glom/utility_widgets/entryglom.cc | 16 +---
glom/utility_widgets/entryglom.h | 1 -
glom/utility_widgets/textviewglom.cc | 8 +-
12 files changed, 143 insertions(+), 88 deletions(-)
---
diff --git a/glom/application.cc b/glom/application.cc
index a043190..acf84b2 100644
--- a/glom/application.cc
+++ b/glom/application.cc
@@ -42,7 +42,8 @@
#include <glibmm/i18n.h>
#ifdef GLOM_ENABLE_MAEMO
-#include <hildon/hildon-window.h>
+#include <hildon/hildon.h>
+#include <hildonmm/program.h>
#include <hildon-fmmm.h>
#endif // GLOM_ENABLE_MAEMO
@@ -60,28 +61,6 @@
#include <gtk/gtkuimanager.h>
-#ifdef GLOM_ENABLE_MAEMO
-namespace //anonymous namespace
-{
-
-HildonWindow* turn_gtk_window_into_hildon_window(GtkWindow* cobject)
-{
- GtkWidget* child = cobject->bin.child;
- g_assert(child);
-
- g_object_ref(G_OBJECT(child));
- gtk_container_remove(GTK_CONTAINER(cobject), child);
-
- GtkWidget* window = hildon_window_new();
- gtk_container_add(GTK_CONTAINER(window), child);
- g_object_unref(G_OBJECT(child));
-
- gtk_widget_destroy(GTK_WIDGET(cobject));
- return HILDON_WINDOW(window);
-}
-
-} //anonymous namespace
-#endif // GLOM_ENABLE_MAEMO
namespace Glom
{
@@ -108,7 +87,7 @@ App_Glom::App_Glom(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& bu
#endif // !GLOM_ENABLE_CLIENT_ONLY
m_show_sql_debug(false)
{
- // TODO: Wrap missing method in gtkmm
+ // TODO: Use the C++ method when we can use gtkmm 2.18:
gtk_window_set_icon_name(GTK_WINDOW(gobj()), "glom");
//Load widgets from glade file:
@@ -227,10 +206,7 @@ void App_Glom::init_layout()
//Add menu bar at the top:
//These were defined in init_uimanager().
-#ifdef GLOM_ENABLE_MAEMO
- //TODO: Use Hildon::AppMenu: Gtk::Menu* pMenu = static_cast<Gtk::Menu*>(m_refUIManager->get_widget("/Bakery_MainMenu"));
- //set_menu(*pMenu);
-#else
+#ifndef GLOM_ENABLE_MAEMO //Maemo uses Hildon::AppMenu instead.
Gtk::MenuBar* pMenuBar = static_cast<Gtk::MenuBar*>(m_refUIManager->get_widget("/Bakery_MainMenu"));
m_pBoxTop->pack_start(*pMenuBar, Gtk::PACK_SHRINK);
#endif
@@ -368,6 +344,13 @@ void App_Glom::init_menus_file()
void App_Glom::init_menus()
{
//There is no real menu on Maemo. We use HildonAppMenu instead.
+
+ m_appmenu_button_table.show();
+ m_appmenu_button_table.set_title(_("Table"));
+ m_maemo_appmenu.append(m_appmenu_button_table);
+
+ //set_app_menu(*appmenu); //TODO: Use this instead?
+ Hildon::Program::get_instance()->set_common_app_menu(m_maemo_appmenu);
}
#else
void App_Glom::init_menus()
@@ -2110,9 +2093,7 @@ void App_Glom::on_menu_file_save_as_example()
cancel_close_or_exit();
}
}
-#endif // !GLOM_ENABLE_CLIENT_ONLY
-#ifndef GLOM_ENABLE_CLIENT_ONLY
Glib::ustring App_Glom::ui_file_select_save(const Glib::ustring& old_file_uri) //override
{
//Reimplement this whole function, just so we can use our custom FileChooserDialog class:
@@ -2165,10 +2146,7 @@ Glib::ustring App_Glom::ui_file_select_save(const Glib::ustring& old_file_uri) /
m_ui_save_extra_newdb_title = Utils::title_from_string( filename ); //Start with something suitable.
fileChooser_SaveExtras->set_extra_newdb_title(m_ui_save_extra_newdb_title);
-
-#ifndef GLOM_ENABLE_CLIENT_ONLY
fileChooser_SaveExtras->set_extra_newdb_hosting_mode(m_ui_save_extra_newdb_hosting_mode);
-#endif // !GLOM_ENABLE_CLIENT_ONLY
}
@@ -2449,14 +2427,55 @@ void App_Glom::do_menu_developer_relationships(Gtk::Window& parent, const Glib::
{
m_pFrame->do_menu_developer_relationships(parent, table_name);
}
-#endif // !GLOM_ENABLE_CLIENT_ONLY
-#ifndef GLOM_ENABLE_CLIENT_ONLY
Document* App_Glom::on_connection_pool_get_document()
{
return dynamic_cast<Document*>(get_document());
}
-#endif
+#endif //GLOM_ENABLE_CLIENT_ONLY
+
+//overriden to show the current table name in the window's title:
+void App_Glom::update_window_title()
+{
+ //Set application's main window title:
+
+ Document* document = dynamic_cast<Document*>(get_document());
+ if(!document)
+ return;
+
+ if(!m_pFrame)
+ return;
+
+ //Show the table title:
+ const Glib::ustring table_name = m_pFrame->get_shown_table_name();
+ Glib::ustring table_label = document->get_table_title(table_name);
+ if(!table_label.empty())
+ {
+ #ifndef GLOM_ENABLE_CLIENT_ONLY
+ if(document->get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ table_label += " (" + table_name + ")"; //Show the table name as well, if in developer mode.
+ #endif // GLOM_ENABLE_CLIENT_ONLY
+ }
+ else //Use the table name if there is no table title.
+ table_label = table_name;
+
+ Glib::ustring strTitle = document->get_name() + ": " + table_label;
+
+ #ifndef GLOM_ENABLE_CLIENT_ONLY
+ //Indicate unsaved changes:
+ if(document->get_modified())
+ strTitle += " *";
+
+ //Indicate read-only files:
+ if(document->get_read_only())
+ strTitle += _(" (read-only)");
+ #endif //GLOM_ENABLE_CLIENT_ONLY
+
+ strTitle += " - " + m_strAppName;
+
+ set_title(strTitle);
+}
+
} //namespace Glom
diff --git a/glom/application.h b/glom/application.h
index 1cf34e0..89cc0b0 100644
--- a/glom/application.h
+++ b/glom/application.h
@@ -21,10 +21,23 @@
#ifndef HEADER_APP_GLOM
#define HEADER_APP_GLOM
+#include "config.h" // For GLOM_ENABLE_CLIENT_ONLY
+
+//TODO: Remove this when maemomm's gtkmm has been updated. 7th September 2009.
+#ifdef GLOM_ENABLE_MAEMO
+//Because earlier versions of gtkmm/enums.h did not include this, so
+//GTKMM_MAEMO_EXTENSIONS_ENABLED was not defined,
+//leading to a compiler error in hildonmm/button.h
+#include <gtkmmconfig.h>
+#include <gtkmm/enums.h>
+
+#include <hildonmm/app-menu.h>
+#include <hildonmm/button.h>
+#endif //GLOM_ENABLE_MAEMO
+
#include <glom/bakery/app_withdoc_gtk.h>
#include <glom/frame_glom.h>
-#include "config.h" // For GLOM_ENABLE_CLIENT_ONLY
//Avoid including the header here:
@@ -101,6 +114,7 @@ private:
virtual void init_create_document(); //override
virtual bool on_document_load(); //override.
virtual void on_document_close(); //override.
+ virtual void update_window_title(); //override.
#ifndef GLOM_ENABLE_MAEMO
virtual void init_menus_file(); //override.
@@ -181,6 +195,11 @@ private:
Glib::RefPtr<Gtk::ToggleAction> m_action_show_layout_toolbar;
#endif // !GLOM_ENABLE_CLIENT_ONLY
+#ifdef GLOM_ENABLE_MAEMO
+ Hildon::AppMenu m_maemo_appmenu;
+ Hildon::Button m_appmenu_button_table;
+#endif //GLOM_ENABLE_MAEMO
+
Glib::RefPtr<Gtk::ToggleAction> m_toggleaction_network_shared;
sigc::connection m_connection_toggleaction_network_shared;
diff --git a/glom/bakery/app_withdoc_gtk.cc b/glom/bakery/app_withdoc_gtk.cc
index ae247c1..8a6ff9d 100644
--- a/glom/bakery/app_withdoc_gtk.cc
+++ b/glom/bakery/app_withdoc_gtk.cc
@@ -33,6 +33,7 @@
#ifdef GLOM_ENABLE_MAEMO
#include <hildon-fmmm/file-chooser-dialog.h>
+#include <hildon/hildon-window.h>
#endif // GLOM_ENABLE_MAEMO
#include <glibmm/i18n-lib.h>
@@ -67,6 +68,11 @@ App_WithDoc_Gtk::App_WithDoc_Gtk(BaseObjectType* cobject, const Glib::ustring& a
{
init_app_name(appname);
+ #ifdef GLOM_ENABLE_MAEMO
+ //The .glade file needs to specify HildonWindow or features such as HildonAppMenu won't work.
+ g_assert(HILDON_IS_WINDOW(gobj()));
+ #endif //GLOM_ENABLE_MAEMO
+
#ifndef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
signal_hide().connect(sigc::mem_fun(*this, &App_WithDoc_Gtk::on_hide));
signal_delete_event().connect(sigc::mem_fun(*this, &App_WithDoc_Gtk::on_delete_event));
@@ -471,22 +477,22 @@ void App_WithDoc_Gtk::update_window_title()
{
//Set application's main window title:
- Glib::ustring strTitle = m_strAppName;
Document* pDoc = get_document();
- if(pDoc)
- {
- strTitle += " - " + pDoc->get_name();
+ if(!pDoc)
+ return;
- //Indicate unsaved changes:
- if(pDoc->get_modified())
- strTitle += " *";
+ Glib::ustring strTitle = m_strAppName;
+ strTitle += " - " + pDoc->get_name();
- //Indicate read-only files:
- if(pDoc->get_read_only())
- strTitle += _(" (read-only)");
+ //Indicate unsaved changes:
+ if(pDoc->get_modified())
+ strTitle += " *";
- set_title(strTitle);
- }
+ //Indicate read-only files:
+ if(pDoc->get_read_only())
+ strTitle += _(" (read-only)");
+
+ set_title(strTitle);
}
void App_WithDoc_Gtk::ui_warning(const Glib::ustring& text, const Glib::ustring& secondary_text)
diff --git a/glom/bakery/app_withdoc_gtk.h b/glom/bakery/app_withdoc_gtk.h
index 34ef551..c6734a2 100644
--- a/glom/bakery/app_withdoc_gtk.h
+++ b/glom/bakery/app_withdoc_gtk.h
@@ -56,6 +56,7 @@ class App_WithDoc_Gtk
#ifdef GLOM_ENABLE_MAEMO
public Hildon::Window //inherit virtually to share sigc::trackable.
#else
+ thisshouldneverbecompiled
public Gtk::Window //inherit virtually to share sigc::trackable.
#endif
{
@@ -63,6 +64,7 @@ public:
#ifdef GLOM_ENABLE_MAEMO
typedef Hildon::Window ParentWindow;
#else
+ breakifthishappens
typedef Gtk::Window ParentWindow;
#endif
diff --git a/glom/box_reports.cc b/glom/box_reports.cc
index 0d6bada..0419457 100644
--- a/glom/box_reports.cc
+++ b/glom/box_reports.cc
@@ -200,7 +200,7 @@ void Box_Reports::save_to_document()
get_document()->set_modified(true);
}
}
-#endif GLOM_ENABLE_CLIENT_ONLY
+#endif //GLOM_ENABLE_CLIENT_ONLY
void Box_Reports::on_adddel_changed(const Gtk::TreeModel::iterator& row, guint column)
{
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index 99cffad..5687374 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -1457,30 +1457,32 @@ void Frame_Glom::on_userlevel_changed(AppState::userlevels userlevel)
void Frame_Glom::show_table_title()
{
- if(get_document())
+ Document* document = dynamic_cast<Document*>(get_document());
+ if(!document)
+ return;
+
+ //Show the table title:
+ Glib::ustring table_label = document->get_table_title(m_table_name);
+ if(!table_label.empty())
{
- //Show the table title:
- Glib::ustring table_label = get_document()->get_table_title(m_table_name);
- if(!table_label.empty())
- {
- Document* document = dynamic_cast<Document*>(get_document());
- if(document)
- {
- if(document->get_userlevel() == AppState::USERLEVEL_DEVELOPER)
- table_label += " (" + m_table_name + ")"; //Show the table name as well, if in developer mode.
- }
- }
- else //Use the table name if there is no table title.
- table_label = m_table_name;
+ if(document->get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ table_label += " (" + m_table_name + ")"; //Show the table name as well, if in developer mode.
+ }
+ else //Use the table name if there is no table title.
+ table_label = m_table_name;
#ifdef GLOM_ENABLE_MAEMO
- // xx-large is too large on maemo, taking away too much (vertical)
- // screen estate
- m_pLabel_Table->set_markup("<b>" + table_label + "</b>");
+ //Show the system's human-readable title and the table title in
+ //the window's title bar:
+ Gtk::Window* app = get_app_window();
+ if(app)
+ app->set_title(document->get_name() + ": " + table_label);
+
+ // xx-large is too large on maemo, using far too much (vertical) space.
+ // We hide this anyway: m_pLabel_Table->set_markup("<b>" + table_label + "</b>");
#else
- m_pLabel_Table->set_markup("<b><span size=\"xx-large\">" + table_label + "</span></b>"); //Show the table title in large text, because it's very important to the user.
+ m_pLabel_Table->set_markup("<b><span size=\"xx-large\">" + table_label + "</span></b>"); //Show the table title in large text, because it's very important to the user.
#endif
- }
}
#ifndef GLOM_ENABLE_CLIENT_ONLY
@@ -2838,5 +2840,10 @@ bool Frame_Glom::get_viewing_details() const
return (m_Notebook_Data.get_current_view() == Notebook_Data::DATA_VIEW_Details);
}
+Glib::ustring Frame_Glom::get_shown_table_name() const
+{
+ return m_table_name;
+}
+
} //namespace Glom
diff --git a/glom/frame_glom.h b/glom/frame_glom.h
index 84032e1..a324fda 100644
--- a/glom/frame_glom.h
+++ b/glom/frame_glom.h
@@ -178,6 +178,8 @@ public:
///Whether we are viewing the details or list.
bool get_viewing_details() const;
+ Glib::ustring get_shown_table_name() const;
+
protected:
diff --git a/glom/main.cc b/glom/main.cc
index 6acd336..b7a8289 100644
--- a/glom/main.cc
+++ b/glom/main.cc
@@ -50,6 +50,7 @@
#ifdef GLOM_ENABLE_MAEMO
#include <hildonmm/init.h>
#include <hildonmm/note.h>
+#include <hildonmm/program.h>
#endif
#include <glom/application.h>
@@ -495,7 +496,13 @@ main(int argc, char* argv[])
pApp_Glom->set_command_line_args(argc, argv);
pApp_Glom->set_show_sql_debug(group.m_arg_debug_sql);
- bool test = pApp_Glom->init(input_uri); //Sets it up and shows it.
+ const bool test = pApp_Glom->init(input_uri); //Sets it up and shows it.
+
+ #ifdef GLOM_ENABLE_MAEMO
+ //TODO: What is this really for?
+ Hildon::Program::get_instance()->add_window(*pApp_Glom);
+ #endif
+
if(test) //The user could cancel the offer of a new or existing database.
Gtk::Main::run(*pApp_Glom); //Quit when the window is closed.
diff --git a/glom/utility_widgets/canvas/canvas_image_movable.cc b/glom/utility_widgets/canvas/canvas_image_movable.cc
index a7c5883..03d76cb 100644
--- a/glom/utility_widgets/canvas/canvas_image_movable.cc
+++ b/glom/utility_widgets/canvas/canvas_image_movable.cc
@@ -18,10 +18,12 @@
* Boston, MA 02111-1307, USA.
*/
+//We include this at the top to use a temporary GTKMM_MAEMO_EXTENSIONS_ENABLED-related fix.
+#include <glom/application.h> // For get_application().
+
#include "canvas_image_movable.h"
#include <goocanvasmm/canvas.h>
#include <gtkmm/stock.h>
-#include <glom/application.h> // For get_application().
#include <glom/utility_widgets/imageglom.h> //For ImageGlom::scale_keeping_ratio().
#include <iostream>
diff --git a/glom/utility_widgets/entryglom.cc b/glom/utility_widgets/entryglom.cc
index f8a5ef0..0d57c2d 100644
--- a/glom/utility_widgets/entryglom.cc
+++ b/glom/utility_widgets/entryglom.cc
@@ -67,7 +67,6 @@ void EntryGlom::init()
signal_focus_out_event().connect(sigc::mem_fun(*this, &EntryGlom::on_focus_out_event));
signal_activate().connect(sigc::mem_fun(*this, &EntryGlom::on_activate));
signal_changed().connect(sigc::mem_fun(*this, &EntryGlom::on_changed));
- signal_insert_text().connect(sigc::mem_fun(*this, &EntryGlom::on_insert_text));
#endif // !GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
}
@@ -115,12 +114,14 @@ void EntryGlom::check_for_change()
}
}
+#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
bool EntryGlom::on_focus_out_event(GdkEventFocus* event)
{
-#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
- bool result = Gtk::Entry::on_focus_out_event(event);
+ const bool result = Gtk::Entry::on_focus_out_event(event);
#else
- bool result = false;
+bool EntryGlom::on_focus_out_event(GdkEventFocus* /* event */)
+{
+ const bool result = false;
#endif // GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
//The user has finished editing.
@@ -151,13 +152,6 @@ void EntryGlom::on_changed()
#endif // GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
}
-void EntryGlom::on_insert_text(const Glib::ustring& text, int* position)
-{
-#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
- Gtk::Entry::on_insert_text(text, position);
-#endif // GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
-}
-
void EntryGlom::set_value(const Gnome::Gda::Value& value)
{
sharedptr<const LayoutItem_Field> layout_item = sharedptr<LayoutItem_Field>::cast_dynamic(get_layout_item());
diff --git a/glom/utility_widgets/entryglom.h b/glom/utility_widgets/entryglom.h
index f29a1e0..08eb9ca 100644
--- a/glom/utility_widgets/entryglom.h
+++ b/glom/utility_widgets/entryglom.h
@@ -67,7 +67,6 @@ private:
virtual void on_changed(); //From Gtk::Entry.
virtual void on_activate(); //From Gtk::Entry.
virtual bool on_focus_out_event(GdkEventFocus* event); //From Gtk::Widget
- virtual void on_insert_text(const Glib::ustring& text, int* position); //From Gtk::Editable
virtual void check_for_change();
diff --git a/glom/utility_widgets/textviewglom.cc b/glom/utility_widgets/textviewglom.cc
index 82e548d..0ef6815 100644
--- a/glom/utility_widgets/textviewglom.cc
+++ b/glom/utility_widgets/textviewglom.cc
@@ -108,16 +108,14 @@ void TextViewGlom::check_for_change()
}
}
-
+#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
bool TextViewGlom::on_textview_focus_out_event(GdkEventFocus* event)
{
- // TODO: Does the call below make sense even when compiled with
- // default signal handlers? This function is a normal signal handler in
- // any case.
-#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
//Call base class:
bool result = Gtk::ScrolledWindow::on_focus_out_event(event);
#else
+bool TextViewGlom::on_textview_focus_out_event(GdkEventFocus* /* event */)
+{
bool result = false;
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]