[gnome-photos] Add a GtkAboutDialog



commit ef3bb644298652a1763216f89118637acc13d501
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Aug 16 00:22:41 2012 +0200

    Add a GtkAboutDialog
    
    The ARTISTS and AUTHORS are used for populating the respective fields.
    We want to credit and thank everybody who has contributed.

 Makefile.am               |    2 +-
 src/Makefile.am           |   31 +++++++++++++++++++++++++
 src/photos-application.c  |   10 +------
 src/photos-generate-about |   54 +++++++++++++++++++++++++++++++++++++++++++++
 src/photos-main-window.c  |   30 +++++++++++++++++++++++++
 src/photos-main-window.h  |    2 +
 6 files changed, 120 insertions(+), 9 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 7358cfb..103d4d8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = data src po
+SUBDIRS = . data src po
 
 INTLTOOL_FILES = \
 	intltool-extract.in \
diff --git a/src/Makefile.am b/src/Makefile.am
index 9400a96..cc8ff3c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,8 @@
 bin_PROGRAMS = gnome-photos
 
 gnome_photos_built_sources = \
+	photos-about-data.c \
+	photos-about-data.h \
 	photos-enums.c \
 	photos-enums.h \
 	photos-marshalers.c \
@@ -99,6 +101,7 @@ BUILT_SOURCES = \
 EXTRA_DIST = \
 	photos-enums.c.template \
 	photos-enums.h.template \
+	photos-generate-about.sh \
 	photos-marshalers.list \
 	$(null)
 
@@ -137,14 +140,42 @@ if MAINTAINER_MODE
 
 CLEANFILES = \
 	$(gnome_photos_built_sources) \
+	stamp-photos-about-data.h \
 	stamp-photos-enums.h \
 	stamp-photos-marshalers.h \
+	xgen-ac \
+	xgen-ah \
 	xgen-etbc \
 	xgen-etbh \
 	xgen-tmc \
 	xgen-tmh \
 	$(NULL)
 
+photos-about-data.h: stamp-photos-about-data.h
+	@true
+
+stamp-photos-about-data.h: $(top_srcdir)/ARTISTS $(top_srcdir)/AUTHORS
+	$(AM_V_GEN) ( \
+		cd $(srcdir) \
+		&& ( ./photos-generate-about \
+			--header $(top_srcdir) \
+                   ) >> xgen-ah \
+		&& ( cmp -s xgen-ah photos-about-data.h || cp xgen-ah photos-about-data.h ) \
+		&& rm -f xgen-ah \
+		&& echo timestamp > $(@F) \
+	)
+
+photos-about-data.c: $(top_srcdir)/ARTISTS $(top_srcdir)/AUTHORS
+	$(AM_V_GEN) ( \
+		cd $(srcdir) \
+		&& echo "#include \"photos-about-data.h\"" > xgen-ac \
+		&& ( ./photos-generate-about \
+			--body $(top_srcdir) \
+                   ) >> xgen-ac \
+		&& ( cmp -s xgen-ac photos-about-data.c || cp xgen-ac photos-about-data.c ) \
+		&& rm -f xgen-ac \
+	)
+
 photos-enums.h: stamp-photos-enums.h
 	@true
 
diff --git a/src/photos-application.c b/src/photos-application.c
index 118bc00..ff56f8e 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -43,12 +43,6 @@ G_DEFINE_TYPE (PhotosApplication, photos_application, GTK_TYPE_APPLICATION)
 
 
 static void
-photos_application_about (GSimpleAction *simple, GVariant *parameter, gpointer user_data)
-{
-}
-
-
-static void
 photos_application_can_fullscreen_changed (PhotosModeController *mode_cntrlr, gpointer user_data)
 {
   PhotosApplication *self = PHOTOS_APPLICATION (user_data);
@@ -112,10 +106,11 @@ photos_application_startup (GApplication *application)
   settings = gtk_settings_get_default ();
   g_object_set (settings, "gtk-application-prefer-dark-theme", TRUE, NULL);
 
+  priv->main_window = photos_main_window_new (GTK_APPLICATION (self));
   priv->mode_cntrlr = photos_mode_controller_new ();
 
   action = g_simple_action_new ("about", NULL);
-  g_signal_connect (action, "activate", G_CALLBACK (photos_application_about), self);
+  g_signal_connect_swapped (action, "activate", G_CALLBACK (photos_main_window_show_about), priv->main_window);
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (action));
   g_object_unref (action);
 
@@ -144,7 +139,6 @@ photos_application_startup (GApplication *application)
 
   gtk_application_set_app_menu (GTK_APPLICATION (self), G_MENU_MODEL (menu));
 
-  priv->main_window = photos_main_window_new (GTK_APPLICATION (self));
   photos_mode_controller_set_window_mode (priv->mode_cntrlr, PHOTOS_WINDOW_MODE_OVERVIEW);
 }
 
diff --git a/src/photos-generate-about b/src/photos-generate-about
new file mode 100755
index 0000000..e5fda33
--- /dev/null
+++ b/src/photos-generate-about
@@ -0,0 +1,54 @@
+#!/bin/sh
+#
+# Photos - access, organize and share your photos on GNOME
+# Copyright  2012 Red Hat, Inc.
+#
+# 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., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+
+
+[[ "$1" = "--header" ]] &&
+    echo "#ifndef PHOTOS_ABOUT_DATA_H" &&
+    echo "#define PHOTOS_ABOUT_DATA_H" &&
+    echo "#include <glib.h>" &&
+    echo "G_BEGIN_DECLS" &&
+    echo "extern const gchar *PHOTOS_ARTISTS[];" &&
+    echo "extern const gchar *PHOTOS_AUTHORS[];" &&
+    echo "G_END_DECLS" &&
+    echo "#endif" &&
+    exit
+
+echo "const gchar *PHOTOS_ARTISTS[] = {"
+while read line; do
+    [[ $(echo "$line" | cut -c1) = "#" ]] &&
+        continue
+    [[ ${#line} -eq 0 ]] &&
+        continue
+    echo "  \"$line\","
+done < $2/ARTISTS
+echo "  NULL"
+echo "};"
+
+echo "const gchar *PHOTOS_AUTHORS[] = {"
+while read line; do
+    [[ $(echo "$line" | cut -c1) = "#" ]] &&
+        continue
+    [[ ${#line} -eq 0 ]] &&
+        continue
+    echo "  \"$line\","
+done < $2/AUTHORS
+echo "  NULL"
+echo "};"
diff --git a/src/photos-main-window.c b/src/photos-main-window.c
index 75952c0..3ad4712 100644
--- a/src/photos-main-window.c
+++ b/src/photos-main-window.c
@@ -26,6 +26,7 @@
 #include <glib.h>
 #include <glib/gi18n.h>
 
+#include "photos-about-data.h"
 #include "photos-embed.h"
 #include "photos-main-window.h"
 #include "photos-mode-controller.h"
@@ -318,3 +319,32 @@ photos_main_window_new (GtkApplication *application)
                        "window-position", GTK_WIN_POS_CENTER,
                        NULL);
 }
+
+
+void
+photos_main_window_show_about (PhotosMainWindow *self)
+{
+  GtkWidget *about_dialog;
+
+  about_dialog = gtk_about_dialog_new ();
+  gtk_window_set_modal (GTK_WINDOW (about_dialog), TRUE);
+  gtk_window_set_transient_for (GTK_WINDOW (about_dialog), GTK_WINDOW (self));
+
+  gtk_about_dialog_set_artists (GTK_ABOUT_DIALOG (about_dialog), PHOTOS_ARTISTS);
+  gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG (about_dialog), PHOTOS_AUTHORS);
+  gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG (about_dialog),
+                                 _("Access, organize and share your photos on GNOME"));
+  gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG (about_dialog), "Copyright  2012 Red Hat, Inc.");
+  gtk_about_dialog_set_license_type (GTK_ABOUT_DIALOG (about_dialog), GTK_LICENSE_GPL_2_0);
+  gtk_about_dialog_set_logo_icon_name (GTK_ABOUT_DIALOG (about_dialog), PACKAGE_TARNAME);
+  gtk_about_dialog_set_program_name (GTK_ABOUT_DIALOG (about_dialog), _(PACKAGE_NAME));
+  gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (about_dialog), _(PACKAGE_VERSION));
+  gtk_about_dialog_set_website (GTK_ABOUT_DIALOG (about_dialog), PACKAGE_URL);
+  gtk_about_dialog_set_wrap_license (GTK_ABOUT_DIALOG (about_dialog), TRUE);
+
+  /* Translators: Put your names here */
+  gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG (about_dialog), _("translator-credits"));
+
+  gtk_widget_show (about_dialog);
+  g_signal_connect (about_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+}
diff --git a/src/photos-main-window.h b/src/photos-main-window.h
index 32f7e9b..6115a69 100644
--- a/src/photos-main-window.h
+++ b/src/photos-main-window.h
@@ -66,6 +66,8 @@ GType                  photos_main_window_get_type               (void) G_GNUC_C
 
 GtkWidget             *photos_main_window_new                    (GtkApplication *application);
 
+void                   photos_main_window_show_about             (PhotosMainWindow *self);
+
 G_END_DECLS
 
 #endif /* PHOTOS_MAIN_WINDOW_H */



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