[gnome-documents/gnome-3-16] mainWindow, utils: Prevent multiple about dialogs from opening



commit 7c2d0a4e0bd14139d3f4f179b3a14a75915c5707
Author: Alessandro Bono <shadow openaliasbox org>
Date:   Wed Feb 25 14:51:20 2015 +0100

    mainWindow, utils: Prevent multiple about dialogs from opening
    
    https://bugzilla.gnome.org/show_bug.cgi?id=745152

 po/POTFILES.in     |    1 +
 src/lib/gd-utils.c |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/lib/gd-utils.h |    3 +++
 src/mainWindow.js  |   34 ++--------------------------------
 4 files changed, 57 insertions(+), 32 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 2dc7240..fb4682a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -13,6 +13,7 @@ src/lib/gd-nav-bar.c
 src/lib/gd-pdf-loader.c
 src/lib/gd-places-bookmarks.c
 src/lib/gd-places-links.c
+src/lib/gd-utils.c
 src/mainToolbar.js
 src/mainWindow.js
 src/notifications.js
diff --git a/src/lib/gd-utils.c b/src/lib/gd-utils.c
index bbf10a7..2b4d2e1 100644
--- a/src/lib/gd-utils.c
+++ b/src/lib/gd-utils.c
@@ -19,9 +19,11 @@
  *
  */
 
+#include "config.h"
 #include "gd-utils.h"
 
 #include <gdk-pixbuf/gdk-pixbuf.h>
+#include <glib/gi18n.h>
 #include <string.h>
 #include <math.h>
 
@@ -384,3 +386,52 @@ gd_ev_view_find_changed (EvView *view,
                         ev_job_find_get_results (job),
                         page);
 }
+
+void
+gd_show_about_dialog (GtkWindow *parent,
+                      gboolean is_books)
+{
+  const char *artists[] = {
+    "Jakub Steiner <jimmac gmail com>",
+    NULL
+  };
+
+  const char *authors[] = {
+    "Cosimo Cecchi <cosimoc gnome org>",
+    "Florian Müllner <fmuellner gnome org>",
+    "William Jon McCann <william jon mccann gmail com>",
+    "Bastien Nocera <hadess hadess net>",
+    NULL
+  };
+
+  const char *program_name, *comments, *logo_icon_name, *website;
+
+  if(!is_books)
+    {
+      program_name = _("Documents");
+      comments = _("A document manager application");
+      logo_icon_name = "gnome-documents";
+      website = "https://wiki.gnome.org/Apps/Documents";;
+    }
+  else
+    {
+      program_name = _("Books");
+      comments = _("An e-books manager application");
+      logo_icon_name = "gnome-books";
+      website = "https://wiki.gnome.org/Apps/Books";;
+    }
+
+  gtk_show_about_dialog (parent,
+                         "artists", artists,
+                         "authors", authors,
+                         "translator-credits", _("translator-credits"),
+                         "program-name", program_name,
+                         "comments", comments,
+                         "logo-icon-name", logo_icon_name,
+                         "website", website,
+                         "copyright", "Copyright © 2011-2014 Red Hat, Inc.",
+                         "license-type", GTK_LICENSE_GPL_2_0,
+                         "version", PACKAGE_VERSION,
+                         "wrap-license", TRUE,
+                         NULL);
+}
diff --git a/src/lib/gd-utils.h b/src/lib/gd-utils.h
index d7a58c1..61053f2 100644
--- a/src/lib/gd-utils.h
+++ b/src/lib/gd-utils.h
@@ -48,5 +48,8 @@ void gd_ev_view_find_changed (EvView *view,
                               EvJobFind *job,
                               gint page);
 
+void gd_show_about_dialog (GtkWindow *parent,
+                           gboolean is_books);
+
 #endif /* __GD_UTILS_H__ */
                                   
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 1c4f80e..18fd429 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -19,6 +19,7 @@
  *
  */
 
+const GdPrivate = imports.gi.GdPrivate;
 const Gdk = imports.gi.Gdk;
 const GLib = imports.gi.GLib;
 const Gtk = imports.gi.Gtk;
@@ -27,7 +28,6 @@ const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 
 const Application = imports.application;
-const Config = imports.config;
 const Embed = imports.embed;
 const Selections = imports.selections;
 const Utils = imports.utils;
@@ -311,36 +311,6 @@ const MainWindow = new Lang.Class({
     },
 
     showAbout: function(isBooks) {
-        let aboutDialog = new Gtk.AboutDialog();
-
-        aboutDialog.artists = [ 'Jakub Steiner <jimmac gmail com>' ];
-        aboutDialog.authors = [ 'Cosimo Cecchi <cosimoc gnome org>',
-                                'Florian M' + String.fromCharCode(0x00FC) + 'llner <fmuellner gnome org>',
-                                'William Jon McCann <william jon mccann gmail com>',
-                                'Bastien Nocera <hadess hadess net>' ];
-        aboutDialog.translator_credits = _("translator-credits");
-        if (!isBooks) {
-            aboutDialog.program_name = _("Documents");
-            aboutDialog.comments = _("A document manager application");
-            aboutDialog.logo_icon_name = 'gnome-documents';
-            aboutDialog.website = 'https://wiki.gnome.org/Apps/Documents';
-        } else {
-            aboutDialog.program_name = _("Books");
-            aboutDialog.comments = _("An e-books manager application");
-            aboutDialog.logo_icon_name = 'gnome-books';
-            aboutDialog.website = 'https://wiki.gnome.org/Apps/Books';
-        }
-        aboutDialog.copyright = 'Copyright ' + String.fromCharCode(0x00A9) + ' 2011' + 
String.fromCharCode(0x2013) + '2014 Red Hat, Inc.';
-        aboutDialog.license_type = Gtk.License.GPL_2_0;
-        aboutDialog.version = Config.PACKAGE_VERSION;
-        aboutDialog.wrap_license = true;
-
-        aboutDialog.modal = true;
-        aboutDialog.transient_for = this.window;
-
-        aboutDialog.show();
-        aboutDialog.connect('response', function() {
-            aboutDialog.destroy();
-        });
+        GdPrivate.show_about_dialog(this.window, isBooks);
     }
 });


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]