[glom/maemo5] Maemo: Use Hildon::FileChooserDialog for opening files.
- From: Murray Cumming <murrayc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glom/maemo5] Maemo: Use Hildon::FileChooserDialog for opening files.
- Date: Sat, 5 Sep 2009 13:41:28 +0000 (UTC)
commit 8df344342c8cc4e2a1fef849784611ecdfaed113
Author: Murray Cumming <murrayc murrayc com>
Date: Sat Sep 5 15:41:06 2009 +0200
Maemo: Use Hildon::FileChooserDialog for opening files.
* glom/application.[h|cc]: Remove unused (and unnecessary since the new
initial dialog) on_menu_file_open() and on_menu_file_close() overrides
and ui_file_select_open_with_browse().
* glom/dialog_existing_or_new.cc: on_select_clicked(): Use
Hildon::FileChooserDialog on Maemo.
* glom/bakery/app_withdoc_gtk.cc: Remove the uncommented undef of
GLOM_ENABLE_MAEMO - no more nasty hacks please. Instead comment-out
the set_menu() call with a TODO, leaving the rest of the maemo-specific
code working.
ChangeLog | 14 ++++
glom/application.cc | 124 -------------------------------------
glom/application.h | 2 -
glom/bakery/app_withdoc_gtk.cc | 35 ++++-------
glom/dialog_existing_or_new.cc | 20 +++++--
glom/utility_widgets/imageglom.cc | 1 +
6 files changed, 42 insertions(+), 154 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c8b9a30..585d133 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
2009-09-05 Murray Cumming <murrayc murrayc com>
+ Maemo: Use Hildon::FileChooserDialog for opening files.
+
+ * glom/application.[h|cc]: Remove unused (and unnecessary since the new
+ initial dialog) on_menu_file_open() and on_menu_file_close() overrides
+ and ui_file_select_open_with_browse().
+ * glom/dialog_existing_or_new.cc: on_select_clicked(): Use
+ Hildon::FileChooserDialog on Maemo.
+ * glom/bakery/app_withdoc_gtk.cc: Remove the uncommented undef of
+ GLOM_ENABLE_MAEMO - no more nasty hacks please. Instead comment-out
+ the set_menu() call with a TODO, leaving the rest of the maemo-specific
+ code working.
+
+2009-09-05 Murray Cumming <murrayc murrayc com>
+
Check for unsupported hosting modes.
* glom/application.[h|cc]:
diff --git a/glom/application.cc b/glom/application.cc
index 692ce60..2af14b9 100644
--- a/glom/application.cc
+++ b/glom/application.cc
@@ -785,40 +785,6 @@ void App_Glom::open_browsed_document(const EpcServiceInfo* server, const Glib::u
}
#endif // !G_OS_WIN32
-//We override this so we can show the custom FileChooserDialog with the Browse Network button:
-void App_Glom::on_menu_file_open()
-{
- //Display File Open dialog and respond to choice:
-
- //Bring document window to front, to make it clear which document is being changed:
- ui_bring_to_front();
-
- //Ask user to choose file to open:
- bool browsed = false;
-#ifndef G_OS_WIN32
- EpcServiceInfo* browsed_server = 0;
- Glib::ustring browsed_service_name;
- Glib::ustring file_uri = ui_file_select_open_with_browse(browsed, browsed_server, browsed_service_name);
-#else
- Glib::ustring file_uri = ui_file_select_open();
-#endif // !G_OS_WIN32
- if(!file_uri.empty() && !browsed)
- open_document(file_uri);
-#ifndef G_OS_WIN32
- else if(browsed)
- open_browsed_document(browsed_server, browsed_service_name);
-
- if(browsed_server)
- epc_service_info_unref(browsed_server);
-#endif // !G_OS_WIN32
-}
-
-void App_Glom::on_menu_file_close() //override
-{
- // Call the base class implementation:
- GlomBakery::App_WithDoc_Gtk::on_menu_file_close();
-}
-
#ifndef GLOM_ENABLE_CLIENT_ONLY
//Copied from bakery:
static bool uri_is_writable(const Glib::RefPtr<const Gio::File>& uri)
@@ -2133,85 +2099,6 @@ void App_Glom::on_menu_file_save_as_example()
}
#endif // !GLOM_ENABLE_CLIENT_ONLY
-#ifndef G_OS_WIN32
-//This is replaced (not overridden) so we can use our custom FileChooserDialog:
-Glib::ustring App_Glom::ui_file_select_open_with_browse(bool& browsed, EpcServiceInfo*& browsed_server, Glib::ustring& browsed_service_name, const Glib::ustring& starting_folder_uri)
-{
- g_return_val_if_fail(browsed_server == 0, "");
-
- //Initialize output parameter:
- browsed = false;
-
- Gtk::Window* pWindow = this;
-
-#ifdef GLOM_ENABLE_MAEMO
- //TODO: Put the browse button on the initial dialog for Maemo,
- //because Hildon::FileChooserDialog does not allow extra widgets.
- Hildon::FileChooserDialog fileChooser_Open(Gtk::FILE_CHOOSER_ACTION_OPEN);
-#else
- Gtk::FileChooserDialog fileChooser_Open(gettext("Open Document"), Gtk::FILE_CHOOSER_ACTION_OPEN);
- fileChooser_Open.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
- fileChooser_Open.add_button(("Browse Network"), GLOM_RESPONSE_BROWSE_NETWORK);
- fileChooser_Open.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
- fileChooser_Open.set_default_response(Gtk::RESPONSE_OK);
-#endif // GLOM_ENABLE_MAEMO
-
- if(pWindow)
- fileChooser_Open.set_transient_for(*pWindow);
-
- if(!starting_folder_uri.empty())
- fileChooser_Open.set_current_folder_uri(starting_folder_uri);
-
- const int response_id = fileChooser_Open.run();
- fileChooser_Open.hide();
- if((response_id != Gtk::RESPONSE_CANCEL) || (response_id != Gtk::RESPONSE_DELETE_EVENT))
- {
- if(response_id == GLOM_RESPONSE_BROWSE_NETWORK)
- {
- // Show Avahi's stock dialog for choosing a publisher service:
- AuiServiceDialog* dialog = AUI_SERVICE_DIALOG (aui_service_dialog_new(_("Choose a running Glom database"), GTK_WINDOW(gobj()),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_CONNECT, GTK_RESPONSE_ACCEPT,
- NULL));
-
- //Browse for the same service type as advertized in Glom::ConnectionPool:
- gchar* service_type = epc_service_type_new (EPC_PROTOCOL_HTTPS, "glom");
- aui_service_dialog_set_browse_service_types(dialog, service_type, NULL);
- g_free(service_type);
- service_type = NULL;
-
- //This is not needed because the type column is hidden when there is just one type:
- //aui_service_dialog_set_service_type_name(AUI_SERVICE_DIALOG (dialog), service_type, "Glom");
-
- const int response = gtk_dialog_run(GTK_DIALOG(dialog));
- if(response == GTK_RESPONSE_ACCEPT)
- {
- //Tell the caller that a networked document should be used instead:
- browsed = true;
-
- browsed_server = epc_service_info_new(
- aui_service_dialog_get_service_type(dialog),
- aui_service_dialog_get_host_name(dialog),
- aui_service_dialog_get_port(dialog),
- aui_service_dialog_get_txt_data(dialog) );
-
- const gchar *service_name = aui_service_dialog_get_service_name(dialog);
- browsed_service_name = service_name ? service_name : Glib::ustring();
- }
-
- gtk_widget_destroy(GTK_WIDGET(dialog));
- dialog = NULL;
- }
- else
- {
- return fileChooser_Open.get_uri();
- }
- }
-
- return Glib::ustring();
-}
-#endif // !G_OS_WIN32
-
#ifndef GLOM_ENABLE_CLIENT_ONLY
Glib::ustring App_Glom::ui_file_select_save(const Glib::ustring& old_file_uri) //override
{
@@ -2297,17 +2184,6 @@ Glib::ustring App_Glom::ui_file_select_save(const Glib::ustring& old_file_uri) /
{
try_again = false;
- //Work around bug #330680 "GtkFileChooserDialog is too small when shown a second time.":
- //(Commented-out because the workaround doesn't work)
- /*
- if(tried_once_already)
- {
- fileChooser_Save->set_default_size(-1, 600);
- }
- else
- tried_once_already = true;
- */
-
const int response_id = fileChooser_Save->run();
fileChooser_Save->hide();
if((response_id != Gtk::RESPONSE_CANCEL) && (response_id != Gtk::RESPONSE_DELETE_EVENT))
diff --git a/glom/application.h b/glom/application.h
index 635ea8d..d479c5d 100644
--- a/glom/application.h
+++ b/glom/application.h
@@ -147,8 +147,6 @@ private:
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 on_menu_file_open(); //overridden.
- virtual void on_menu_file_close(); //override.
virtual void document_history_add(const Glib::ustring& file_uri); //overridden.
virtual void new_instance(const Glib::ustring& uri = Glib::ustring()); //Override
diff --git a/glom/bakery/app_withdoc_gtk.cc b/glom/bakery/app_withdoc_gtk.cc
index cf2e43d..ae247c1 100644
--- a/glom/bakery/app_withdoc_gtk.cc
+++ b/glom/bakery/app_withdoc_gtk.cc
@@ -16,8 +16,6 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#include <config.h>
-
#include <glom/bakery/app_withdoc_gtk.h>
#include <glom/bakery/dialog_offersave.h>
//#include <libgnomevfsmm/utils.h> //For escape_path_string()
@@ -30,12 +28,16 @@
#include <gtkmm/aboutdialog.h>
#include <giomm.h>
#include <algorithm>
-#include <glibmm/i18n-lib.h>
-//#include <gtk/gtkfilesel.h>
+#include <config.h>
+#ifdef GLOM_ENABLE_MAEMO
+#include <hildon-fmmm/file-chooser-dialog.h>
+#endif // GLOM_ENABLE_MAEMO
-#undef GLOM_ENABLE_MAEMO
+#include <glibmm/i18n-lib.h>
+
+//#include <gtk/gtkfilesel.h>
namespace GlomBakery
{
@@ -119,9 +121,10 @@ void App_WithDoc_Gtk::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);
+#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
Gtk::MenuBar* pMenuBar = static_cast<Gtk::MenuBar*>(m_refUIManager->get_widget("/Bakery_MainMenu"));
m_pVBox->pack_start(*pMenuBar, Gtk::PACK_SHRINK);
@@ -491,7 +494,7 @@ void App_WithDoc_Gtk::ui_warning(const Glib::ustring& text, const Glib::ustring&
Gtk::Window* pWindow = this;
#ifdef GLOM_ENABLE_MAEMO
- Hildon::Note dialog(Hildon::NOTE_TYPE_INFORMATION, text, Gtk::Stock::DIALOG_WARNING);
+ Hildon::Note dialog(Hildon::NOTE_TYPE_INFORMATION, *pWindow, text);
#else
Gtk::MessageDialog dialog(App_WithDoc_Gtk::util_bold_message(text), true /* use markup */, Gtk::MESSAGE_WARNING);
dialog.set_secondary_text(secondary_text);
@@ -606,25 +609,11 @@ Glib::ustring App_WithDoc_Gtk::ui_file_select_save(const Glib::ustring& old_file
}
}
-
- //bool tried_once_already = false;
-
bool try_again = true;
while(try_again)
{
try_again = false;
- //Work around bug #330680 "GtkFileChooserDialog is too small when shown a second time.":
- //(Commented-out because the workaround doesn't work)
- /*
- if(tried_once_already)
- {
- fileChooser_Save.set_default_size(-1, 600);
- }
- else
- tried_once_already = true;
- */
-
const int response_id = fileChooser_Save.run();
fileChooser_Save.hide();
if(response_id != Gtk::RESPONSE_CANCEL)
diff --git a/glom/dialog_existing_or_new.cc b/glom/dialog_existing_or_new.cc
index 743f4fd..33a710b 100644
--- a/glom/dialog_existing_or_new.cc
+++ b/glom/dialog_existing_or_new.cc
@@ -30,6 +30,10 @@
#include <gtkmm/filechooserdialog.h>
#include <gtkmm/stock.h>
+#ifdef GLOM_ENABLE_MAEMO
+#include <hildon-fmmm/file-chooser-dialog.h>
+#endif // GLOM_ENABLE_MAEMO
+
#ifdef G_OS_WIN32
# include <glib/gwin32.h>
#else
@@ -907,19 +911,25 @@ void Dialog_ExistingOrNew::on_select_clicked()
if(action == OPEN_URI && iter == m_iter_existing_other)
{
+ #ifdef GLOM_ENABLE_MAEMO
+ Hildon::FileChooserDialog dialog(Gtk::FILE_CHOOSER_ACTION_OPEN);
+ #else
Gtk::FileChooserDialog dialog(*this, "Choose a glom file to open");
+ dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+ dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
+ dialog.set_default_response(Gtk::RESPONSE_OK);
+ #endif // GLOM_ENABLE_MAEMO
+
Gtk::FileFilter filter;
filter.add_mime_type("application/x-glom");
filter.set_name("Glom files");
dialog.add_filter(filter);
- dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
- dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT);
- //dialog.set_default_response(Gtk::RESPONSE_ACCEPT);
-
- if(dialog.run() == Gtk::RESPONSE_ACCEPT)
+ const int response_id = dialog.run();
+ if(response_id == Gtk::RESPONSE_OK)
{
m_chosen_uri = dialog.get_uri();
+ std::cout << "DEBUG: m_chosen_uri = " << m_chosen_uri << std::endl;
response(Gtk::RESPONSE_ACCEPT);
}
}
diff --git a/glom/utility_widgets/imageglom.cc b/glom/utility_widgets/imageglom.cc
index 4e90ac7..2092413 100644
--- a/glom/utility_widgets/imageglom.cc
+++ b/glom/utility_widgets/imageglom.cc
@@ -400,6 +400,7 @@ void ImageGlom::on_menupopup_activate_select_file()
if(m_read_only)
return;
+ //TODO: Use Hildon::FileChooser for Maemo.
Gtk::FileChooserDialog dialog(_("Choose Image"), Gtk::FILE_CHOOSER_ACTION_OPEN);
//Get image formats only:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]