Commit 031685e9 authored by Murray Cumming's avatar Murray Cumming
Browse files

Maemo: Show Add Related buttons when showing portals on details.

* glom/application.[h|cc]: Removed unused on_menu_add_record().
* glom/mode_data/box_data_portal.[h|cc]: On Maemo, add a Hildon::Button
to the application's AppMenu on realize, removing it on unrealize.
Added a virtual do_add_record() that is called when the button is clicked.
* glom/mode_data/box_data_calendar_related.[h|cc]:
* glom/mode_data/box_data_list_related.[h|cc]: Added do_add_record()
overrides, though they are empty so far.
parent 2eba2353
2009-10-15 Murray Cumming <murrayc@murrayc.com>
Maemo: Show Add Related buttons when showing portals on details.
* glom/application.[h|cc]: Removed unused on_menu_add_record().
* glom/mode_data/box_data_portal.[h|cc]: On Maemo, add a Hildon::Button
to the application's AppMenu on realize, removing it on unrealize.
Added a virtual do_add_record() that is called when the button is clicked.
* glom/mode_data/box_data_calendar_related.[h|cc]:
* glom/mode_data/box_data_list_related.[h|cc]: Added do_add_record()
overrides, though they are empty so far.
2009-10-13 Murray Cumming <murrayc@murrayc.com>
 
Maemo: Add a Add Record to the App Menu and remove it from the List View.
......
......@@ -367,10 +367,6 @@ static void add_button_to_appmenu(Hildon::AppMenu& appmenu, const Glib::ustring&
appmenu.append(*button);
}
void App_Glom::on_menu_add_record()
{
}
void App_Glom::init_menus()
{
//There is no real menu on Maemo. We use HildonAppMenu instead.
......@@ -1294,10 +1290,18 @@ void App_Glom::update_userlevel_ui()
}
#endif // !GLOM_ENABLE_CLIENT_ONLY
#ifndef GLOM_ENABLE_MAEMO
Glib::RefPtr<Gtk::UIManager> App_Glom::get_ui_manager()
{
return m_refUIManager;
}
#else
Hildon::AppMenu* App_Glom::get_maemo_appmenu()
{
return &m_maemo_appmenu;
}
#endif //GLOM_ENABLE_MAEMO
bool App_Glom::offer_new_or_existing()
{
......
......@@ -65,7 +65,11 @@ public:
//virtual void statusbar_clear();
/// Get the UIManager so we can merge new menus in.
#ifndef GLOM_ENABLE_MAEMO
Glib::RefPtr<Gtk::UIManager> get_ui_manager();
#else
Hildon::AppMenu* get_maemo_appmenu();
#endif //GLOM_ENABLE_MAEMO
/** Changes the mode to Data mode, as if the user had selected the Data Mode menu item.
*/
......@@ -125,8 +129,6 @@ private:
#ifndef GLOM_ENABLE_MAEMO
void on_menu_help_contents();
#else
void on_menu_add_record();
#endif //GLOM_ENABLE_MAEMO
/** Check that the file's hosting mode is supported by this build and
......
......@@ -338,7 +338,7 @@ void Frame_Glom::set_mode_widget(Gtk::Widget& widget)
App_Glom* pApp = dynamic_cast<App_Glom*>(get_app_window());
if(pApp)
{
Glib::RefPtr<Gtk::UIManager> ui_manager = pApp->get_ui_manager();
//Glib::RefPtr<Gtk::UIManager> ui_manager = pApp->get_ui_manager();
Notebook_Glom* notebook_current = dynamic_cast<Notebook_Glom*>(m_pBox_Mode->get_child());
if(notebook_current)
......
......@@ -625,7 +625,13 @@ void Box_Data_Calendar_Related::set_primary_key_value(const Gtk::TreeModel::iter
{
//TODO
}
#ifdef GLOM_ENABLE_MAEMO
void Box_Data_Calendar_Related::do_add_record()
{
std::cerr << "Box_Data_Calendar_Related::do_add_record(): TODO: Unimplemented." << std::endl;
}
#endif //GLOM_ENABLE_MAEMO
......
......@@ -110,6 +110,12 @@ private:
typedef std::map<Glib::Date, type_list_vectors> type_map_values;
type_map_values m_map_values;
mutable int m_query_column_date_field;
private:
#ifdef GLOM_ENABLE_MAEMO
virtual void do_add_record(); //override
#endif
};
} //namespace Glom
......
......@@ -241,7 +241,8 @@ bool Box_Data_List_Related::on_script_button_idle(const Gnome::Gda::Value& prima
void Box_Data_List_Related::on_adddel_record_added(const Gtk::TreeModel::iterator& row, const Gnome::Gda::Value& primary_key_value)
{
//Note that on_record_added() would only be called on the AddDel itself, so we need ot handle this AddDel signal.
//Note that on_record_added() would only be called on the AddDel itself,
//so we need to handle this AddDel signal.
//primary_key_value is a new autogenerated or human-entered key for the row.
//It has already been added to the database.
......@@ -490,6 +491,11 @@ void Box_Data_List_Related::create_layout_add_group(const sharedptr<LayoutGroup>
}
}
#ifdef GLOM_ENABLE_MAEMO
void Box_Data_List_Related::do_add_record()
{
m_AddDel.start_new_record();
}
#endif //GLOM_ENABLE_MAEMO
} //namespace Glom
......@@ -87,6 +87,12 @@ protected:
//Member widgets:
mutable DbAddDel_WithButtons m_AddDel; //mutable because its get_ methods aren't const.
private:
#ifdef GLOM_ENABLE_MAEMO
virtual void do_add_record(); //override
#endif
};
} //namespace Glom
......
......@@ -23,12 +23,16 @@
#include <glom/glade_utils.h>
#include <glom/frame_glom.h> //For show_ok_dialog()
#include <glom/utils_ui.h> //For bold_message()).
#include <glom/application.h>
#include <glibmm/i18n.h>
namespace Glom
{
Box_Data_Portal::Box_Data_Portal()
#ifdef GLOM_ENABLE_MAEMO
: m_maemo_appmenubutton_add(Gtk::Hildon::SIZE_AUTO, Hildon::BUTTON_ARRANGEMENT_VERTICAL)
#endif
{
set_size_request(400, -1); //An arbitrary default.
......@@ -48,8 +52,67 @@ Box_Data_Portal::Box_Data_Portal()
add(m_Frame);
m_layout_name = "list_portal"; //Replaced by derived classes.
#ifdef GLOM_ENABLE_MAEMO
#ifndef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
signal_realize().connect(sigc::mem_fun(*this, &Box_Data_Portal::on_realize));
signal_unrealize().connect(sigc::mem_fun(*this, &Box_Data_Portal::on_unrealize));
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
m_maemo_appmenubutton_add.signal_clicked().connect(
sigc::mem_fun(*this, &Box_Data_Portal::on_maemo_appmenubutton_add));
#endif //GLOM_ENABLE_MAEMO
}
void Box_Data_Portal::on_maemo_appmenubutton_add()
{
do_add_record();
}
#ifdef GLOM_ENABLE_MAEMO
void Box_Data_Portal::on_realize()
{
// Add an Add Related Something button to the application's AppMenu.
// This will be removed when the portal is hidden.
//TODO: Use the ustring compose thingy. murrayc.
//TODO: Allow the designer to specify a singluar form for tables (and portals),
//so we can say Add Related Something instead of Somethings: Add Related.
const Glib::ustring title =
Glib::ustring::compose(_("%1: Add Related"), get_title());
m_maemo_appmenubutton_add.set_title(title);
m_maemo_appmenubutton_add.set_value(_("Add related record"));
App_Glom* app = App_Glom::get_application();
g_assert(app);
if(app)
{
Hildon::AppMenu* appmenu = app->get_maemo_appmenu();
g_assert(appmenu);
if(appmenu)
{
m_maemo_appmenubutton_add.show();
appmenu->append(m_maemo_appmenubutton_add);
}
}
}
void Box_Data_Portal::on_unrealize()
{
// Remove the AppMenu button when the portal is no longer shown:
App_Glom* app = App_Glom::get_application();
g_assert(app);
if(app)
{
Hildon::AppMenu* appmenu = app->get_maemo_appmenu();
g_assert(appmenu);
if(appmenu)
{
m_maemo_appmenubutton_add.hide();
Gtk::Container* container = appmenu;
container->remove(m_maemo_appmenubutton_add);
}
}
}
#endif //GLOM_ENABLE_MAEMO
bool Box_Data_Portal::init_db_details(const sharedptr<const LayoutItem_Portal>& portal, bool show_title)
{
......@@ -58,10 +121,25 @@ bool Box_Data_Portal::init_db_details(const sharedptr<const LayoutItem_Portal>&
Glib::ustring parent_table;
if(m_portal)
parent_table = m_portal->get_from_table();
return init_db_details(parent_table, show_title);
}
Glib::ustring Box_Data_Portal::get_title() const
{
//TODO: This same code is in box_data_related_list.cc. Remove the duplication.
Glib::ustring relationship_title;
if(m_portal && m_portal->get_has_relationship_name())
relationship_title = m_portal->get_title_used(Glib::ustring() /* parent title - not relevant */);
else
{
//Note to translators: This text is shown instead of a table title, when the table has not yet been chosen.
relationship_title = _("Undefined Table");
}
return relationship_title;
}
//TODO: Is this base class implemenation actually called by anything?
bool Box_Data_Portal::init_db_details(const Glib::ustring& parent_table, bool show_title)
{
......@@ -76,17 +154,7 @@ bool Box_Data_Portal::init_db_details(const Glib::ustring& parent_table, bool sh
if(show_title)
{
//TODO: This same code is in box_data_related_list.cc. Remove the duplication.
Glib::ustring relationship_title;
if(m_portal && m_portal->get_has_relationship_name())
relationship_title = m_portal->get_title_used(Glib::ustring() /* parent title - not relevant */);
else
{
//Note to translators: This text is shown instead of a table title, when the table has not yet been chosen.
relationship_title = _("Undefined Table");
}
m_Label.set_markup(Utils::bold_message(relationship_title));
m_Label.set_markup(Utils::bold_message( get_title() ));
m_Label.show();
m_Alignment.set_padding(Utils::DEFAULT_SPACING_SMALL /* top */, 0, Utils::DEFAULT_SPACING_LARGE /* left */, 0);
......
......@@ -26,6 +26,11 @@
#include "box_data_manyrecords.h"
#include <glom/utility_widgets/layoutwidgetbase.h>
#ifdef GLOM_ENABLE_MAEMO
#include <hildonmm/button.h>
#endif
namespace Glom
{
......@@ -88,6 +93,8 @@ protected:
protected:
virtual Document::type_list_layout_groups create_layout_get_layout(); //override.
Glib::ustring get_title() const;
Gtk::Frame m_Frame;
Gtk::Alignment m_Alignment;
Gtk::Label m_Label;
......@@ -98,6 +105,21 @@ protected:
Gnome::Gda::Value m_key_value;
type_signal_portal_record_changed m_signal_portal_record_changed;
private:
#ifdef GLOM_ENABLE_MAEMO
void on_realize();
void on_unrealize();
void on_maemo_appmenubutton_add();
/** Create a new (related) record.
*/
virtual void do_add_record() = 0;
//Each related-records portal adds its own Add Something button
//to the application's AppMenu when the portal is visible.
Hildon::Button m_maemo_appmenubutton_add;
#endif //GLOM_ENABLE_MAEMO
};
} //namespace Glom
......
......@@ -95,9 +95,10 @@ private:
virtual void on_remove(Gtk::Widget* child);
//Do extra drawing:
virtual void on_realize();
virtual void on_unrealize();
virtual bool on_expose_event(GdkEventExpose* event);
//Virtual method overrides:
void on_realize();
void on_unrealize();
bool on_expose_event(GdkEventExpose* event);
protected:
int get_column_height(guint start_widget, guint widget_count, int& total_width) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment