Commit 2565b35d authored by Murray Cumming's avatar Murray Cumming
Browse files

Rename Application to AppWindow.

Rename Application to AppWindow and rename the Bakery::App* classes
appropriately too. This is a preparation for using Gtk::Application.
parent 7791d023
2012-02-09 Murray Cumming <murrayc@murrayc.com>
Rename Application to AppWindow.
Rename Application to AppWindow and rename the Bakery::App* classes
appropriately too. This is a preparation for using Gtk::Application.
2012-02-09 Murray Cumming <murrayc@murrayc.com>
Print Layout: Print Preview: Avoid warnings when there are no records yet.
......
......@@ -67,8 +67,8 @@ glom_canvas_files = \
glom/utility_widgets/canvas/canvas_text_movable.h
glom_source_files = \
glom/application.cc \
glom/application.h \
glom/appwindow.cc \
glom/appwindow.h \
glom/base_db.cc \
glom/base_db.h \
glom/base_db_table.cc \
......@@ -109,12 +109,12 @@ glom_source_files = \
glom/window_boxholder.cc \
glom/window_boxholder.h \
glom/onlineglom_strings.cc \
glom/bakery/app.cc \
glom/bakery/app.h \
glom/bakery/app_withdoc.cc \
glom/bakery/app_withdoc.h \
glom/bakery/app_withdoc_gtk.cc \
glom/bakery/app_withdoc_gtk.h \
glom/bakery/appwindow.cc \
glom/bakery/appwindow.h \
glom/bakery/appwindow_withdoc.cc \
glom/bakery/appwindow_withdoc.h \
glom/bakery/appwindow_withdoc_gtk.cc \
glom/bakery/appwindow_withdoc_gtk.h \
glom/bakery/busy_cursor.cc \
glom/bakery/busy_cursor.h \
glom/bakery/dialog_offersave.cc \
......
This diff is collapsed.
/* Glom
*
* Copyright (C) 2001-2004 Murray Cumming
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef GLOM_APPLICATION_H
#define GLOM_APPLICATION_H
#include "config.h" // For GLOM_ENABLE_CLIENT_ONLY
#include <glom/bakery/app_withdoc_gtk.h>
#include <glom/frame_glom.h>
#include <glom/show_progress_message.h>
#include <glom/infobar_progress_creating.h>
#include <gtkmm/aboutdialog.h>
#include <gtkmm/messagedialog.h>
//Avoid including the header here:
extern "C"
{
typedef struct AvahiStringList AvahiStringList;
typedef struct _EpcServiceInfo EpcServiceInfo;
}
namespace Glom
{
class Window_Translations;
class Application : public GlomBakery::App_WithDoc_Gtk
{
public:
static const char* glade_id;
static const bool glade_developer;
Application(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder);
virtual ~Application();
virtual bool init(const Glib::ustring& document_uri = Glib::ustring()); //override
/**
* @param restore Whether @a document_uri is a .tar.gz backup file to restore.
*/
bool init(const Glib::ustring& document_uri, bool restore);
//virtual void statusbar_set_text(const Glib::ustring& strText);
//virtual void statusbar_clear();
/// Get the UIManager so we can merge new menus in.
Glib::RefPtr<Gtk::UIManager> get_ui_manager();
/** Changes the mode to Data mode, as if the user had selected the Data Mode menu item.
*/
void set_mode_data();
void set_mode_find();
/** Show in the UI whether the database is shared on the network.
*/
void update_network_shared_ui();
#ifndef GLOM_ENABLE_CLIENT_ONLY
void add_developer_action(const Glib::RefPtr<Gtk::Action>& refAction);
void remove_developer_action(const Glib::RefPtr<Gtk::Action>& refAction);
/** Show in the UI whether the document is in developer or operator mode.
*/
void update_userlevel_ui();
#endif // !GLOM_ENABLE_CLIENT_ONLY
/** Enable/disable UI elements depending on whether a table is loaded.
*/
void update_table_sensitive_ui();
AppState::userlevels get_userlevel() const;
void fill_menu_tables();
void fill_menu_reports(const Glib::ustring& table_name);
void fill_menu_print_layouts(const Glib::ustring& table_name);
#ifndef GLOM_ENABLE_CLIENT_ONLY
void do_menu_developer_fields(Gtk::Window& parent, const Glib::ustring table_name);
void do_menu_developer_relationships(Gtk::Window& parent, const Glib::ustring table_name);
void do_print_layout(const Glib::ustring& print_layout_name, bool preview = false, Gtk::Window* transient_for = 0);
bool do_restore_backup(const Glib::ustring& backup_uri);
#endif //GLOM_ENABLE_CLIENT_ONLY
///Whether to show the generated SQL queries on stdout, for debugging.
bool get_show_sql_debug() const;
///Whether to show the generated SQL queries on stdout, for debugging.
void set_show_sql_debug(bool val = true);
///Whether to automatically shutdown the database server when Glom crashes.
void set_stop_auto_server_shutdown(bool val = true);
void show_table_details(const Glib::ustring& table_name, const Gnome::Gda::Value& primary_key_value);
void show_table_list(const Glib::ustring& table_name);
/** Print the named report for the current table.
*/
void print_report(const Glib::ustring& report_name);
/** Print the current layout for the current table.
*/
void print_layout();
/** Offer the user the UI to add a new record,
*/
void start_new_record();
void set_progress_message(const Glib::ustring& message);
void pulse_progress_message();
void clear_progress_message();
/** Set the locale used for original text of titles. This
* must usually be stored in the document.
* Ideally, it would be English.
*/
static void set_original_locale(const Glib::ustring& locale);
static Glib::ustring get_original_locale();
static bool get_current_locale_not_original();
/** Set the locale used for titles, to test translations.
* Usually the current locale is just the locale at startup.
*/
static void set_current_locale(const Glib::ustring& locale);
/** Get the locale used by this program when it was started,
* or the locale set by set_current_locale().
*/
static Glib::ustring get_current_locale();
static Application* get_application();
protected:
virtual void ui_warning_load_failed(int failure_code = 0); //Override.
private:
virtual void init_layout(); //override.
virtual void init_menus(); //override.
virtual void init_toolbars(); //override
virtual void init_create_document(); //override
virtual bool on_document_load(); //override.
virtual void on_document_close(); //override.
virtual void update_window_title(); //override.
virtual void init_menus_file(); //override.
bool offer_new_or_existing();
void on_menu_help_contents();
/** Check that the file's hosting mode is supported by this build and
* tell the user if necessary.
*/
bool check_document_hosting_mode_is_supported(Document* document);
#ifndef GLOM_ENABLE_CLIENT_ONLY
void existing_or_new_new();
void on_menu_file_toggle_share();
void on_menu_developer_developer();
void on_menu_developer_operator();
void on_menu_file_save_as_example();
void on_menu_developer_changelanguage();
void on_menu_developer_translations();
void on_menu_developer_active_platform_normal();
void on_menu_developer_active_platform_maemo();
void on_menu_developer_export_backup();
void on_menu_developer_restore_backup();
void on_menu_developer_enable_layout_drag_and_drop ();
void on_window_translations_hide();
virtual Glib::ustring ui_file_select_save(const Glib::ustring& old_file_uri); //overridden.
void on_userlevel_changed(AppState::userlevels userlevel);
Document* on_connection_pool_get_document();
bool recreate_database_from_example(bool& user_cancelled); //return indicates success.
bool recreate_database_from_backup(const Glib::ustring& backup_uri, bool& user_cancelled); //return indicates success.
void on_recreate_database_progress();
void stop_self_hosting_of_document_database();
void on_connection_avahi_begin();
void on_connection_avahi_progress();
void on_connection_avahi_done();
#endif // !GLOM_ENABLE_CLIENT_ONLY
void on_menu_help_about();
void on_about_close();
#ifndef G_OS_WIN32
/** Offer a file chooser dialog, with a Browse Network button.
* @param browsed This will be set to true if the user chose a networked glom instance to open.
* @browsed_server This will be filled with the server details if browsed was set to true.
*/
Glib::ustring ui_file_select_open_with_browse(bool& browsed, EpcServiceInfo*& browsed_server, Glib::ustring& browsed_service_name, const Glib::ustring& starting_folder_uri = Glib::ustring());
#endif // !G_OS_WIN32
virtual void document_history_add(const Glib::ustring& file_uri); //overridden.
virtual void new_instance(const Glib::ustring& uri = Glib::ustring()); //Override
void on_connection_close_progress();
void on_connection_save_backup_progress();
void on_connection_convert_backup_progress();
#ifndef G_OS_WIN32
void open_browsed_document(const EpcServiceInfo* server, const Glib::ustring& service_name);
#endif // !G_OS_WIN32
typedef GlomBakery::App_WithDoc_Gtk type_base;
//Widgets:
Glib::RefPtr<Gtk::ActionGroup> m_refActionGroup_Others;
typedef std::list< Glib::RefPtr<Gtk::Action> > type_listActions;
type_listActions m_listDeveloperActions; //Only enabled when in developer mode.
type_listActions m_listTableSensitiveActions; // Only enabled when a table is loaded.
Glib::RefPtr<Gtk::Action> m_action_mode_find;
#ifndef GLOM_ENABLE_CLIENT_ONLY
Glib::RefPtr<Gtk::Action> m_action_developer_users;
Glib::RefPtr<Gtk::RadioAction> m_action_menu_developer_developer, m_action_menu_developer_operator;
Glib::RefPtr<Gtk::ToggleAction> m_action_enable_layout_drag_and_drop ;
#endif // !GLOM_ENABLE_CLIENT_ONLY
Glib::RefPtr<Gtk::ToggleAction> m_toggleaction_network_shared;
sigc::connection m_connection_toggleaction_network_shared;
Gtk::Box* m_pBoxTop;
Frame_Glom* m_pFrame;
bool m_bAboutShown;
Gtk::AboutDialog* m_pAbout; //About box.
Infobar_ProgressCreating* m_infobar_progress;
std::string m_progress_collate_key;
#ifndef GLOM_ENABLE_CLIENT_ONLY
Window_Translations* m_window_translations;
#endif // !GLOM_ENABLE_CLIENT_ONLY
Glib::RefPtr<Gtk::ActionGroup> m_refHelpActionGroup;
Glib::RefPtr<Gtk::ActionGroup> m_refNavTablesActionGroup, m_refNavReportsActionGroup, m_refNavPrintLayoutsActionGroup;
type_listActions m_listNavTableActions, m_listNavReportActions, m_listNavPrintLayoutActions;
Gtk::UIManager::ui_merge_id m_menu_tables_ui_merge_id, m_menu_reports_ui_merge_id, m_menu_print_layouts_ui_merge_id;
#ifndef GLOM_ENABLE_CLIENT_ONLY
//Set these before calling offer_saveas() (which uses ui_file_select_save()), and clear it afterwards.
bool m_ui_save_extra_showextras;
Glib::ustring m_ui_save_extra_title;
Glib::ustring m_ui_save_extra_message;
Glib::ustring m_ui_save_extra_newdb_title;
Document::HostingMode m_ui_save_extra_newdb_hosting_mode;
Gtk::MessageDialog* m_avahi_progress_dialog;
#endif // !GLOM_ENABLE_CLIENT_ONLY
// This is set to the URI of an example file that is loaded to be able to
// prevent adding it into the recently used resources in
// document_history_add().
Glib::ustring m_example_uri;
//A temporary store for the username/password if
//we already asked for them when getting the document over the network,
//so we can use them again when connecting directly to the database:
Glib::ustring m_temp_username, m_temp_password;
bool m_show_sql_debug;
static Glib::ustring m_current_locale, m_original_locale;
};
Glib::ustring item_get_title(const sharedptr<const TranslatableItem>& item);
Glib::ustring item_get_title_or_name(const sharedptr<const TranslatableItem>& item);
} //namespace Glom
#endif // GLOM_APPLICATION_H
/*
* Copyright 2000 Murray Cumming
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <glom/bakery/app.h>
#include <algorithm>
namespace GlomBakery
{
//Initialize static member data:
Glib::ustring App::m_strVersion;
bool App::m_bOperationCancelled = false;
Glib::ustring App::m_strCommandLine_0;
Glib::ustring App::m_strAppName;
App::App(const Glib::ustring& appname)
{
init_app_name(appname);
}
App::~App()
{
}
void App::init_app_name(const Glib::ustring& appname) //static
{
m_strAppName = appname;
}
void App::init()
{
//set_wmclass(m_strAppName, m_strTitle); //The docs say "Don't use this".
init_ui_manager();
init_menus();
init_toolbars();
//on_document_load(); //Show the document (even if it is empty).
}
void App::init_ui_manager()
{
}
void App::init_menus()
{
init_menus_file();
init_menus_edit();
//create_menus(m_menu_UI_Infos);
//install_menu_hints();
//Override this to add more menus.
}
void App::init_toolbars()
{
}
void App::on_menu_file_new()
{
new_instance();
}
void App::on_menu_file_close()
{
ui_hide();
}
void App::on_menu_edit_cut()
{
on_menu_edit_copy();
on_menu_edit_clear();
}
void App::on_menu_edit_copy()
{
}
void App::on_menu_edit_paste()
{
}
void App::on_menu_edit_clear()
{
}
Glib::ustring App::get_version() const
{
return m_strVersion;
}
void App::set_operation_cancelled(bool bVal /* = true */)
{
m_bOperationCancelled = bVal;
}
bool App::get_operation_cancelled()
{
return m_bOperationCancelled;
}
void App::set_command_line_args(int argc, char **&argv)
{
if( (argc > 0) && argv[0])
m_strCommandLine_0 = (char*)argv[0];
}
App::type_signal_hide App::ui_signal_hide()
{
return m_signal_hide;
}
} //namespace
/*
* Copyright 2000 Murray Cumming
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef GLOM_BAKERY_APP_H
#define GLOM_BAKERY_APP_H
#include <glibmm/object.h>
#include <vector>
namespace GlomBakery
{
/** Bakery's Main Window.
* This is an abstract class. You must use a class such as App_Gtk, which implements
* the ui_* methods for a particular GUI toolkit.
*
* Features:
* - Override methods to add/change menus/toolbars/statusbar.
* - Default is basic File, Edit, Help menus and toolbar icons.
*
*
* TODO:
* - Command-line args - wrap popt?
* - Session Management - need Command-line args.
*
*/
class App : virtual public Glib::ObjectBase
{
public:
//The constructor has a default argument so that there is a default constructor,
//so that derived classes do not need to call a specific constructor. This is
//a virtual base class so they would otherwise need to do that.
///Don't forget to call init() too.
App(const Glib::ustring& appname = Glib::ustring());
virtual ~App();
virtual void init(); //Sets it up and shows it.
virtual Glib::ustring get_version() const;
static void set_command_line_args(int argc, char** &argv); //Needed for session management.
typedef sigc::signal<void> type_signal_hide;
type_signal_hide ui_signal_hide();
protected:
static void init_app_name(const Glib::ustring& appname);
/** Builds the intial ui string, with placeholders.
* This allows us to merge in actual menus and toolbars in the other init_*() methods.
*/
virtual void init_ui_manager();
/** Override this to add more menus or different menus.
*/
virtual void init_menus();
/** Call this from init_menus() to add the standard file menu
*/
virtual void init_menus_file() = 0;
/** Call this from init_menus() to add the standard edit menu
*/
virtual void init_menus_edit() = 0;
virtual void init_toolbars();
virtual void new_instance(const Glib::ustring& uri = Glib::ustring()) = 0; //Must override in order to new() the derived document class.
// virtual void close_window() = 0;
// virtual void bring_to_front() = 0;
//Signal handlers:
public: // We can not take function pointers of these methods in a
// derived class, if they are protected - for instance, with sigc::mem_fun()
//Menus:
virtual void on_menu_file_new();
virtual void on_menu_file_close();
//Edit menu handlers overriden in App_WithDoc:
virtual void on_menu_edit_cut();
virtual void on_menu_edit_copy();
virtual void on_menu_edit_paste();
virtual void on_menu_edit_clear();
virtual void on_menu_help_about() = 0;
protected:
//GUI abstractions:
virtual void ui_hide() = 0;
virtual void ui_bring_to_front() = 0;
//operation_cancelled:
//e.g. A File|Open tries to save existing data,
//but this needs to be cancelled if the save failed.
static void set_operation_cancelled(bool bVal = true);
static bool get_operation_cancelled();
//Member data:
//'About Box'/WM Class information:
static Glib::ustring m_strAppName;
static Glib::ustring m_strVersion;
//Instances
static bool m_bOperationCancelled; //see set/get_operation_cancelled().
//Command line args:
static Glib::ustring m_strCommandLine_0;
type_signal_hide m_signal_hide;
};