From 3757c78e835d01bddf89675e1c60a77020543338 Mon Sep 17 00:00:00 2001 From: Alan Fitton Date: Fri, 8 Apr 2011 23:00:13 +0000 Subject: install license and use it in about dialog if possible --- AUTHORS | 3 +++ configure.ac | 4 +++- redhat/transmission-remote-gtk.spec | 2 +- src/Makefile.am | 4 +++- src/dispatch.c | 7 +++---- src/http.c | 11 +++++++---- src/main.c | 2 -- src/session-get.c | 5 ++--- src/trg-about-window.c | 22 ++++++++++++++++++---- 9 files changed, 40 insertions(+), 20 deletions(-) diff --git a/AUTHORS b/AUTHORS index 38fd37c..22039bb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -12,3 +12,6 @@ translations kindly contributed by * Julian Held (German) * Youn sok Choi (Korean) + * Piotr (Polish) + * Y3AVD (Russian) + diff --git a/configure.ac b/configure.ac index 0228e6e..e4ac719 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ(2.63) -AC_INIT(transmission-remote-gtk, 0.3, alan@eth0.org.uk) +AC_INIT(transmission-remote-gtk, 0.4, alan@eth0.org.uk) AC_CONFIG_SRCDIR(src) AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) AM_INIT_AUTOMAKE([foreign]) @@ -27,7 +27,9 @@ case "$OSNAME" in esac trglocaledir='${prefix}/${DATADIRNAME}/locale' +trglicense='${docdir}/LICENSE.GPLv2' AC_SUBST(trglocaledir) +AC_SUBST(trglicense) GETTEXT_PACKAGE=AC_PACKAGE_NAME AC_SUBST(GETTEXT_PACKAGE) AC_DEFINE(GETTEXT_PACKAGE, "AC_PACKAGE_NAME", [foo]) diff --git a/redhat/transmission-remote-gtk.spec b/redhat/transmission-remote-gtk.spec index 5fb06ea..6bc9c9e 100644 --- a/redhat/transmission-remote-gtk.spec +++ b/redhat/transmission-remote-gtk.spec @@ -1,5 +1,5 @@ Name: transmission-remote-gtk -Version: 0.3 +Version: 0.4 Release: 1%{?dist:%{dist}} Summary: Remote control client for Transmission BitTorrent diff --git a/src/Makefile.am b/src/Makefile.am index 18efe16..466147e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,7 +23,7 @@ schemadir = @GCONF_SCHEMA_FILE_DIR@ schema_DATA = transmission-remote-gtk.schemas bin_PROGRAMS = transmission-remote-gtk -INCLUDES = --pedantic -Wall -I.. -O2 -DTRGLOCALEDIR=\""$(trglocaledir)"\" $(jsonglib_CFLAGS) $(gthread_CFLAGS) $(gtk_CFLAGS) $(gconf_CFLAGS) $(gio_CFLAGS) $(unique_CFLAGS) $(notify_CFLAGS) +INCLUDES = --pedantic -Wall -I.. -O2 -DTRGLICENSE=\""$(trglicense)"\" -DTRGLOCALEDIR=\""$(trglocaledir)"\" $(jsonglib_CFLAGS) $(gthread_CFLAGS) $(gtk_CFLAGS) $(gconf_CFLAGS) $(gio_CFLAGS) $(unique_CFLAGS) $(notify_CFLAGS) transmission_remote_gtk_SOURCES = main.c \ requests.c \ @@ -79,6 +79,8 @@ transmission_remote_gtk_LDFLAGS = -lm -lcurl $(jsonglib_LIBS) $(gtk_LIBS) $(gthr install-data-local: install-icons update-icon-cache GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) gconftool-2 --makefile-install-rule $(srcdir)/$(schema_DATA) + $(INSTALL_DATA) -D ../COPYING $(docdir)/LICENSE.GPLv2 + $(INSTALL_DATA) ../AUTHORS $(docdir)/AUTHORS gtk_update_icon_cache = gtk-update-icon-cache -f -t diff --git a/src/dispatch.c b/src/dispatch.c index aee8ce7..12ada88 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -79,7 +79,7 @@ static gpointer dispatch_async_threadfunc(gpointer ptr) struct dispatch_async_args *args = (struct dispatch_async_args *) ptr; int status; JsonObject *result = dispatch(args->client, args->req, &status); - if (args->callback != NULL) + if (args->callback) args->callback(result, status, args->data); g_free(args); return NULL; @@ -91,9 +91,8 @@ GThread *dispatch_async(trg_client * client, JsonNode * req, { GError *error = NULL; GThread *thread; - struct dispatch_async_args *args; + struct dispatch_async_args *args = g_new(struct dispatch_async_args, 1); - args = g_new(struct dispatch_async_args, 1); args->callback = callback; args->data = data; args->req = req; @@ -101,7 +100,7 @@ GThread *dispatch_async(trg_client * client, JsonNode * req, thread = g_thread_create(dispatch_async_threadfunc, args, FALSE, &error); - if (error != NULL) { + if (error) { g_printf("thread creation error: %s\n", error->message); g_error_free(error); g_free(args); diff --git a/src/http.c b/src/http.c index a2eba57..6e4e08b 100644 --- a/src/http.c +++ b/src/http.c @@ -30,6 +30,9 @@ #include "trg-client.h" #include "http.h" +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif static struct http_response *trg_http_perform_inner(trg_client * client, gchar * req, @@ -65,7 +68,7 @@ static struct http_response *trg_http_perform_inner(trg_client * tc, handle = curl_easy_init(); - curl_easy_setopt(handle, CURLOPT_USERAGENT, "trg"); + curl_easy_setopt(handle, CURLOPT_USERAGENT, PACKAGE_NAME); curl_easy_setopt(handle, CURLOPT_PASSWORD, tc->password); curl_easy_setopt(handle, CURLOPT_USERNAME, tc->username); curl_easy_setopt(handle, CURLOPT_URL, tc->url); @@ -86,7 +89,7 @@ static struct http_response *trg_http_perform_inner(trg_client * tc, } - if (tc->session_id != NULL) { + if (tc->session_id) { headers = curl_slist_append(headers, tc->session_id); curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); } @@ -137,10 +140,10 @@ static size_t header_callback(void *ptr, size_t size, size_t nmemb, char *header = (char *) (ptr); trg_client *client = (trg_client *) data; - if (g_str_has_prefix(header, "X-Transmission-Session-Id: ") == TRUE) { + if (g_str_has_prefix(header, "X-Transmission-Session-Id: ")) { char *nl; - if (client->session_id != NULL) + if (client->session_id) g_free(client->session_id); client->session_id = g_strdup(header); diff --git a/src/main.c b/src/main.c index e997424..9a5c627 100644 --- a/src/main.c +++ b/src/main.c @@ -94,8 +94,6 @@ int main(int argc, char *argv[]) bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); - textdomain(PACKAGE_NAME); - if ((withUnique = g_getenv("TRG_NOUNIQUE") == NULL)) app = unique_app_new_with_commands("org.eth0.uk.org.trg", NULL, "add", COMMAND_ADD, NULL); diff --git a/src/session-get.c b/src/session-get.c index 34e409b..dd4bfa1 100644 --- a/src/session-get.c +++ b/src/session-get.c @@ -64,11 +64,10 @@ gboolean session_get_port_forwarding_enabled(JsonObject * s) const gchar *session_get_blocklist_url(JsonObject * s) { - if (json_object_has_member(s, SGET_BLOCKLIST_URL)) { + if (json_object_has_member(s, SGET_BLOCKLIST_URL)) return json_object_get_string_member(s, SGET_BLOCKLIST_URL); - } else { + else return NULL; - } } gint64 session_get_blocklist_size(JsonObject * s) diff --git a/src/trg-about-window.c b/src/trg-about-window.c index 343354f..327d70b 100644 --- a/src/trg-about-window.c +++ b/src/trg-about-window.c @@ -33,6 +33,7 @@ GtkWidget *trg_about_window_new(GtkWindow * parent) { GtkWidget *dialog; GdkPixbuf *logo; + gchar *licenseText = NULL; const gchar *trgAuthors[] = { "Alan Fitton ", NULL }; @@ -50,6 +51,12 @@ GtkWidget *trg_about_window_new(GtkWindow * parent) g_object_unref(logo); } + if (g_file_get_contents(TRGLICENSE, &licenseText, NULL, NULL)) { + gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(dialog), licenseText); + } else { + gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(dialog), "GPL2"); + } + gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(dialog), PACKAGE_NAME); gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog), PACKAGE_VERSION); @@ -58,15 +65,22 @@ GtkWidget *trg_about_window_new(GtkWindow * parent) gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(dialog), _ ("A remote client to transmission-daemon.")); - gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(dialog), "GPL2"); + gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(dialog), "http://code.google.com/p/transmission-remote-gtk/"); gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(dialog), "http://code.google.com/p/transmission-remote-gtk/"); gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(dialog), trgAuthors); - /*gtk_about_dialog_set_documenters(GTK_ABOUT_DIALOG(dialog), documenters); - gtk_about_dialog_set_translator_credits(GTK_ABOUT_DIALOG(dialog), - "Translator #1\nTranslator #2"); */ + /*gtk_about_dialog_set_documenters(GTK_ABOUT_DIALOG(dialog), documenters);*/ + gtk_about_dialog_set_translator_credits(GTK_ABOUT_DIALOG(dialog), + "translations kindly contributed by\n\n" + "* Julian Held (German)\n" + "* Youn sok Choi (Korean)\n" + "* Piotr (Polish)\n" + "* Y3AVD (Russian)"); + + g_free(licenseText); + return dialog; } -- cgit v1.2.3