[gparted] Replace gnome-open with gtk_show_uri (#600046)
- From: Curtis Gedak <gedakc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gparted] Replace gnome-open with gtk_show_uri (#600046)
- Date: Tue, 3 Nov 2009 17:30:45 +0000 (UTC)
commit c2d19a8ab4eb9e8a9875a7bd7dd0802b9f8303b2
Author: Curtis Gedak <gedakc gmail com>
Date: Tue Nov 3 10:27:35 2009 -0700
Replace gnome-open with gtk_show_uri (#600046)
This change was performed to align with a GNOME goal:
http://live.gnome.org/GnomeGoals/RemoveGnomeOpenGnomeHelp
For backwards compatibility, the gnome-open command is used
when gtkmm < 2.14.0.
configure.in | 6 ++++
include/Win_GParted.h | 2 +-
src/Win_GParted.cc | 69 +++++++++++++++++++++---------------------------
3 files changed, 37 insertions(+), 40 deletions(-)
---
diff --git a/configure.in b/configure.in
index 69244e0..b18feca 100644
--- a/configure.in
+++ b/configure.in
@@ -90,6 +90,12 @@ AC_SUBST(GTKMM_LIBS)
AC_SUBST(GTKMM_CFLAGS)
+dnl GTKMM 2.14 needed for gtk_show_uri()
+PKG_CHECK_EXISTS(gtkmm-2.4 >= 2.14.0,
+ [AC_DEFINE(HAVE_GTK_SHOW_URI, 1, [Define to 1 if you have gtk_show_uri])],
+ [])
+
+
dnl======================
dnl check whether to build documentation - Gnome-Doc-Utils
dnl======================
diff --git a/include/Win_GParted.h b/include/Win_GParted.h
index db9ad2e..915ad29 100644
--- a/include/Win_GParted.h
+++ b/include/Win_GParted.h
@@ -141,7 +141,7 @@ private:
void menu_view_harddisk_info();
void menu_view_operations();
void show_disklabel_unrecognized( Glib::ustring device_name );
- void show_help_dialog (const char *link_id);
+ void show_help_dialog( const Glib::ustring & filename, const Glib::ustring & link_id );
void menu_help_contents();
void menu_help_about();
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 99a33f1..3733e10 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -1202,48 +1202,39 @@ void Win_GParted::show_disklabel_unrecognized ( Glib::ustring device_name )
dialog .run() ;
}
-void Win_GParted::show_help_dialog (const char *link_id /* For context sensitive help */)
+void Win_GParted::show_help_dialog( const Glib::ustring & filename /* E.g., gparted */
+ , const Glib::ustring & link_id /* For context sensitive help */
+ )
{
-/* Original concept for show_help_dialog is from file-roller project
- * gtk-utils.c revision 1967, Tue Aug 7 06:18:42 2007 UTC
- * See http://fileroller.sourceforge.net/
- *
- * Modified to work with GParted by Curtis Gedak :-)
- */
- GError *err = NULL;
- char *command;
- const char *lang;
- char *uri = NULL;
- int i;
- GdkScreen *gscreen;
-
- const char * const * langs = g_get_language_names ();
-
- for (i = 0; langs[i]; i++) {
- lang = langs[i];
- if (strchr (lang, '.')) {
- continue;
- }
+ GError *error = NULL ;
+ GdkScreen *gscreen = NULL ;
- uri = g_build_filename( GPARTED_DATADIR,
- "/gnome/help/gparted/",
- lang,
- "/gparted.xml",
- NULL );
-
- if (g_file_test (uri, G_FILE_TEST_EXISTS)) {
- break;
- }
- }
-
- if (link_id) {
- command = g_strconcat ("gnome-open ghelp://", uri, "?", link_id, NULL);
- } else {
- command = g_strconcat ("gnome-open ghelp://", uri, NULL);
+ Glib::ustring uri = "ghelp:" + filename ;
+ if (link_id .size() > 0 ) {
+ uri = uri + "?" + link_id ;
}
- gscreen = gdk_screen_get_default();
- gdk_spawn_command_line_on_screen (gscreen, command, &err);
+ gscreen = gdk_screen_get_default() ;
+
+#ifdef HAVE_GTK_SHOW_URI
+ gtk_show_uri( gscreen, uri .c_str(), gtk_get_current_event_time(), &error ) ;
+#else
+ Glib::ustring command = "gnome-open " + uri ;
+ gdk_spawn_command_line_on_screen( gscreen, command .c_str(), &error ) ;
+#endif
+
+ if ( error != NULL )
+ {
+ Gtk::MessageDialog dialog( *this
+ , _( "Unable to open GParted Manual help file." )
+ , false
+ , Gtk::MESSAGE_ERROR
+ , Gtk::BUTTONS_OK
+ , true
+ ) ;
+ dialog .set_secondary_text( error ->message ) ;
+ dialog .run() ;
+ }
}
void Win_GParted::menu_help_contents()
@@ -1265,7 +1256,7 @@ void Win_GParted::menu_help_contents()
dialog .run() ;
#else
//GParted was configured without --disable-doc
- show_help_dialog( NULL);
+ show_help_dialog( "gparted", "" );
#endif
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]