From 03c7cc02504e2d4db2272ca664d773186e2fdb31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1=D1?= =?UTF-8?q?=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Wed, 7 Dec 2011 18:03:30 +0400 Subject: [PATCH] Starting to get rid of gtk_dialog_run(), and more * Call AC_INIT() with different package name and tarball name * Get version from VCS instead of hard-coding it in configure.ac * Don't supply version to AM_INIT_AUTOMAKE * Use silent rules * Make a few GNUNET_FS_GTK_* AM variables to be used in .glade files * Add contrib/gnunet_fs_gtk_about_window.glade.in * GNUNET_GTK_display_about () doesn't take dialog name anymore (it should always be 'about_window' now) * GNUNET_GTK_get_new_builder () now passes the builder as a callback argument * about.c now implements most of the things that were previously done by GtkAboutDialog. --- configure.ac | 10 +- contrib/Makefile.am | 3 +- contrib/get_version.sh | 34 +++ contrib/gnunet_fs_gtk_about_window.glade.in | 364 +++++++++++++++++++++++++++ src/fs/gnunet-fs-gtk-about.c | 3 +- src/include/gnunet_gtk.h | 3 +- src/lib/about.c | 117 +++++++++- src/lib/glade.c | 2 +- src/peerinfo/gnunet-peerinfo-gtk-about.c | 3 +- 9 files changed, 527 insertions(+), 12 deletions(-) create mode 100644 contrib/get_version.sh create mode 100644 contrib/gnunet_fs_gtk_about_window.glade.in diff --git a/configure.ac b/configure.ac index 4e3e11a..cd64cf4 100644 --- a/configure.ac +++ b/configure.ac @@ -20,8 +20,8 @@ # Process this file with autoconf to produce a configure script. # AC_PREREQ(2.61) -AC_INIT([gnunet-gtk],[0.9.0],[bug-gnunet@gnu.org]) -AM_INIT_AUTOMAKE([gnunet-gtk], [0.9.0]) +AC_INIT([GNUnet GTK],m4_esyscmd([contrib/get_version.sh .version | tr -d '\n']),[bug-gnunet@gnu.org],[gnunet-gtk]) +AM_INIT_AUTOMAKE([silent-rules]) AM_CONFIG_HEADER(gnunet_gtk_config.h) AH_TOP([#define _GNU_SOURCE 1]) @@ -357,6 +357,11 @@ AC_DEFINE_DIR([PACKAGE_DATA], [datarootdir], [The directory for installing read- packagesrcdir=`cd $srcdir && pwd` AC_DEFINE_UNQUOTED(PACKAGE_SOURCE_DIR, "${packagesrcdir}", [source dir]) +AC_SUBST(GNUNET_FS_GTK_NAME, $PACKAGE_NAME, [name of the program]) +AC_SUBST(GNUNET_FS_GTK_VERSION3, $PACKAGE_VERSION, [version of the program]) +AC_SUBST(GNUNET_FS_GTK_YEARFROM, [2010], [year of the first release]) +AC_SUBST(GNUNET_FS_GTK_YEARTO, [$(date | sed -e 's/.* \([[[:digit:]]]\+\)$/\1/')], [year of the most current release]) + AC_OUTPUT([ Makefile contrib/Makefile @@ -373,4 +378,5 @@ po/Makefile.in po/Makefile gnunet-fs-gtk.desktop gnunet-setup.desktop +contrib/gnunet_fs_gtk_about_window.glade ]) diff --git a/contrib/Makefile.am b/contrib/Makefile.am index c79d3fd..606eeba 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -34,7 +34,8 @@ pkgdata_DATA = \ gnunet_peerinfo_gtk_main_window.glade \ gnunet_statistics_gtk_about_dialog.glade \ gnunet_statistics_gtk_main_window.glade \ - gnunet_setup_gtk_main_window.glade + gnunet_setup_gtk_main_window.glade \ + gnunet_fs_gtk_about_window.glade install-data-local: $(mkinstalldirs) $(DESTDIR)$(pkgpixdir) diff --git a/contrib/get_version.sh b/contrib/get_version.sh new file mode 100644 index 0000000..7c64dee --- /dev/null +++ b/contrib/get_version.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Gets the version number from VCS, or from the contents of the file $1 +version= +if test -f "$1" +then + version=$(cat $1) +fi +if test "x$version" = "x" -a -d "./.git" +then + version=$(git svn info | grep "Revision: [[:digit:]]\+" | sed -e 's/Revision: //') + if test "x$version" = "x" + then + version=$(git log -1 | grep 'commit [a-f0-9]\+' | sed -e 's/commit //') + if test ! "x$version" = "x" + then + version="git-$version" + fi + else + version="r$version" + fi +fi +if test "x$version" = "x" -a -d "./.svn" +then + version=$(svn info | grep "Revision: [[:digit:]]\+" | sed -e 's/Revision: //') + if test ! "x$version" = "x" + then + version="r$version" + fi +fi +if test "x$version" = "x" +then + version="unknown" +fi +echo $version diff --git a/contrib/gnunet_fs_gtk_about_window.glade.in b/contrib/gnunet_fs_gtk_about_window.glade.in new file mode 100644 index 0000000..f214ca9 --- /dev/null +++ b/contrib/gnunet_fs_gtk_about_window.glade.in @@ -0,0 +1,364 @@ + + + + + + False + True + True + + + + + + + True + False + 10 + + + True + False + gnunet_logo.png + + + False + True + 0 + + + + + True + False + @GNUNET_FS_GTK_NAME@ @GNUNET_FS_GTK_VERSION3@ + + + + + + + False + True + 1 + + + + + True + False + (C) @GNUNET_FS_GTK_YEARFROM@-@GNUNET_FS_GTK_YEARTO@ The GNUnet Project + + + False + True + 2 + + + + + True + False + <a href="https://gnunet.org/">GNUnet: GNU's Framework for Secure P2P Networking</a> + True + True + + + False + True + 3 + + + + + True + + + True + True + automatic + automatic + + + True + True + False + word + False + credits_authors_contents + False + + + + + + + True + False + Developed by + + + False + + + + + True + True + automatic + automatic + + + True + True + False + word + False + credits_docs_contents + False + + + + + 1 + + + + + True + False + Documented by + + + 1 + False + + + + + True + True + automatic + automatic + + + True + True + False + word + False + credits_trans_contents + False + + + + + 2 + + + + + True + False + Translated by + + + 2 + False + + + + + True + True + automatic + automatic + + + True + True + False + word + False + credits_art_contents + False + + + + + 3 + + + + + True + False + Artwork by + + + 3 + False + + + + + True + True + 4 + + + + + True + automatic + automatic + + + True + False + word + False + license_contents + False + + + + + True + True + 5 + + + + + True + False + 5 + True + + + Credits + True + True + True + False + + + + True + False + 0 + + + + + License + True + True + True + False + + + + True + False + 1 + + + + + gtk-close + True + True + True + False + True + + + + True + False + end + 2 + + + + + + + + False + False + end + 6 + + + + + + + Jakub 'jimmac' Steiner <jimmac@ximian.org> +Christian Muellner <chris@flop.de> +Alex Jones <alexrjones@ntlworld.com> +Nicklas Larsson <whybill@gmail.com> + + + + Juergen Appel <jappel@linux01.gwdg.de> +Krista Grothoff <krista@grothoff.org> +James Blackwell <jblack@linuxguru.net> +Ludovic Courtes <ludo@chbouib.org> +Nils Durner <durner@gnunet.org> +Renaldo Ferreira <rf@cs.purdue.edu> +Christian Grothoff <christian@grothoff.org> +Eric Haumant +Tzvetan Horozov <horozov@motorola.com> +Gerd Knorr <kraxel@bytesex.org> +Werner Koch <libgcrypt@g10code.com> +Uli Luckas <luckas@musoft.de> +Blake Matheny +Glenn McGrath +Hendrik Pagenhardt <Hendrik.Pagenhardt@gmx.net> +Ioana Patrascu <ioanapatrascu@yahoo.com> +Marko Raeihae +Paul Ruth <ruth@cs.purdue.edu> +Risto Saarelma +Antti Salonen +Tiberius Stef <tstef@cs.purdue.edu> +Tuomas Toivonen +Tomi Tukiainen +Kevin Vandersloot <kfv101@psu.edu> +Simo Viitanen +Larry Waldo +Igor Wronsky <iwronsky@users.sourceforge.net> +<january@hushmail.com> + + + Christian Grothoff <christian@grothoff.org> +Anders Carlsson <andersca@gnu.org> +Nils Durner <durner@gnunet.org> +Nicklas Larsson <whybill@gmail.com> +Milan Bouchet-Valat <nalimilan@club.fr> +Igor Wronsky <iwronsky@users.sourceforge.net> + + + + Di Ma +Jens Palsberg <palsberg@cs.ucla.edu> +Christian Grothoff <christian@grothoff.org> +Nils Durner <durner@gnunet.org> +Mathieu <mollo@bghflt.org> +Eric Haumant +milan@skoid.org +Hiroshi Yamauchi <yamauchi@cs.purdue.edu> +Adam Welc <welc@cs.purdue.edu> +Bogdan Carbunar <carbunar@cs.purdue.edu> +Steven Michael Murphy <murf@e-tools.com> +Phan Vinh Thinh <teppi82@gmail.com> +Daniel Nylander <po@danielnylander.se> + + + + License should be loaded here at runtime from the license file (no need to copy the whole GPL in here...). + + diff --git a/src/fs/gnunet-fs-gtk-about.c b/src/fs/gnunet-fs-gtk-about.c index 1ffdcca..4c7701b 100644 --- a/src/fs/gnunet-fs-gtk-about.c +++ b/src/fs/gnunet-fs-gtk-about.c @@ -34,8 +34,7 @@ void GNUNET_GTK_main_menu_help_about_activate_cb (GtkWidget * dummy, gpointer data) { - GNUNET_GTK_display_about ("gnunet_fs_gtk_about_dialog.glade", - "GNUNET_FS_GTK_about_dialog"); + GNUNET_GTK_display_about ("gnunet_fs_gtk_about_window.glade"); } diff --git a/src/include/gnunet_gtk.h b/src/include/gnunet_gtk.h index c567efb..a38e5d9 100644 --- a/src/include/gnunet_gtk.h +++ b/src/include/gnunet_gtk.h @@ -93,10 +93,9 @@ GNUNET_GTK_get_new_builder (const char *filename); * This displays an about dialog. * * @param dialogfile name of the glade file containing the dialog - * @param dialogname name of the about dialog in the file */ void -GNUNET_GTK_display_about (const char *dialogfile, const char *dialogname); +GNUNET_GTK_display_about (const char *dialogfile); diff --git a/src/lib/about.c b/src/lib/about.c index 095ce21..a41f6d0 100644 --- a/src/lib/about.c +++ b/src/lib/about.c @@ -26,6 +26,115 @@ */ #include "gnunet_gtk.h" +static void +destroy_about_dialog (GtkBuilder *builder) +{ + GtkWidget *ad; + ad = GTK_WIDGET (gtk_builder_get_object (builder, "about_window")); + gtk_widget_destroy (ad); + g_object_unref (G_OBJECT (builder)); +} + +static void +about_window_show_exclusively (GtkBuilder *builder, gchar *name) +{ + GtkWidget *about_credits_notebook; + GtkWidget *about_license_textview; + GtkWidget *about_license_scroller; + about_credits_notebook = GTK_WIDGET (gtk_builder_get_object (builder, "about_credits_notebook")); + about_license_textview = GTK_WIDGET (gtk_builder_get_object (builder, "about_license_textview")); + about_license_scroller = GTK_WIDGET (gtk_builder_get_object (builder, "about_license_scroller")); + if (name == NULL) + { + gtk_widget_hide (about_credits_notebook); + gtk_widget_hide (about_license_textview); + gtk_widget_hide (about_license_scroller); + } + else if (strcmp ("about_credits_notebook", name) == 0) + { + gtk_widget_show (about_credits_notebook); + gtk_widget_hide (about_license_textview); + gtk_widget_hide (about_license_scroller); + } + else if (strcmp ("about_license_textview", name) == 0) + { + gtk_widget_show (about_license_textview); + gtk_widget_show (about_license_scroller); + gtk_widget_hide (about_credits_notebook); + } +} + +G_MODULE_EXPORT gboolean +GNUNET_GTK_about_window_got_frame_event (GtkWindow *window, GdkEvent *event, + gpointer user_data) +{ + GtkBuilder *builder = GTK_BUILDER (user_data); + + switch (event->type) + { + case GDK_DELETE: + destroy_about_dialog (builder); + return TRUE; + break; + default: + return FALSE; + } +} + +G_MODULE_EXPORT void +GNUNET_GTK_about_window_realized (GtkWidget *widget, gpointer user_data) +{ + GtkBuilder *builder = GTK_BUILDER (user_data); + GtkTextBuffer *license_contents; + gchar *license = NULL; + license_contents = GTK_TEXT_BUFFER (gtk_builder_get_object (builder, "license_contents")); + if (g_file_get_contents ("COPYING", &license, NULL, NULL) && license != NULL) + { + gtk_text_buffer_set_text (license_contents, license, -1); + g_free (license); + } + about_window_show_exclusively (builder, NULL); +} + +G_MODULE_EXPORT void +GNUNET_GTK_about_close_button_clicked (GtkButton *widget, gpointer user_data) +{ + GtkBuilder *builder = GTK_BUILDER (user_data); + destroy_about_dialog (builder); +} + +G_MODULE_EXPORT gboolean +GNUNET_GTK_about_window_got_delete_event (GtkWidget *widget, GdkEvent *event, + gpointer user_data) +{ + GtkBuilder *builder = GTK_BUILDER (user_data); + destroy_about_dialog (builder); + return FALSE; +} + +G_MODULE_EXPORT gboolean +GNUNET_GTK_about_window_got_destroy_event (GtkWidget *widget, GdkEvent *event, + gpointer user_data) +{ + GtkBuilder *builder = GTK_BUILDER (user_data); + destroy_about_dialog (builder); + return FALSE; +} + +G_MODULE_EXPORT void +GNUNET_GTK_about_credits_button_clicked (GtkButton *widget, gpointer user_data) +{ + GtkBuilder *builder = GTK_BUILDER (user_data); + about_window_show_exclusively (builder, "about_credits_notebook"); +} + +G_MODULE_EXPORT void +GNUNET_GTK_about_license_button_clicked (GtkButton *widget, gpointer user_data) +{ + GtkBuilder *builder = GTK_BUILDER (user_data); + about_window_show_exclusively (builder, "about_license_textview"); +} + /** * This displays an about dialog. * @@ -33,7 +142,7 @@ * @param dialogname name of the about dialog in the file */ void -GNUNET_GTK_display_about (const char *dialogfile, const char *dialogname) +GNUNET_GTK_display_about (const char *dialogfile) { GtkBuilder *builder; GtkWidget *ad; @@ -41,10 +150,14 @@ GNUNET_GTK_display_about (const char *dialogfile, const char *dialogname) builder = GNUNET_GTK_get_new_builder (dialogfile); if (builder == NULL) return; - ad = GTK_WIDGET (gtk_builder_get_object (builder, dialogname)); + ad = GTK_WIDGET (gtk_builder_get_object (builder, "about_window")); + g_object_set_data (G_OBJECT (ad), "gnunet-gtk-builder", builder); + gtk_widget_show (ad); + /* gtk_dialog_run (GTK_DIALOG (ad)); gtk_widget_destroy (ad); g_object_unref (G_OBJECT (builder)); + */ } diff --git a/src/lib/glade.c b/src/lib/glade.c index 90c4649..4e5957c 100644 --- a/src/lib/glade.c +++ b/src/lib/glade.c @@ -84,7 +84,7 @@ GNUNET_GTK_get_new_builder (const char *filename) GNUNET_free (glade_path); return NULL; } - gtk_builder_connect_signals (ret, NULL); + gtk_builder_connect_signals (ret, ret); GNUNET_free (glade_path); return ret; } diff --git a/src/peerinfo/gnunet-peerinfo-gtk-about.c b/src/peerinfo/gnunet-peerinfo-gtk-about.c index 6899442..5eb9b40 100644 --- a/src/peerinfo/gnunet-peerinfo-gtk-about.c +++ b/src/peerinfo/gnunet-peerinfo-gtk-about.c @@ -35,8 +35,7 @@ void GNUNET_PEERINFO_GTK_main_menu_help_about_activate_cb (GtkWidget * dummy, gpointer data) { - GNUNET_GTK_display_about ("gnunet_peerinfo_gtk_about_dialog.glade", - "GNUNET_PEERINFO_GTK_about_dialog"); + GNUNET_GTK_display_about ("gnunet_peerinfo_gtk_about_window.glade"); } -- 1.7.4