summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alan Fitton <ajf@eth0.org.uk>2011-10-17 17:33:24 +0000
committerGravatar Alan Fitton <ajf@eth0.org.uk>2011-10-17 17:33:24 +0000
commite22247a39463313f818f9e1b3e67feac35d658a1 (patch)
tree7f8bbe8123990fa76a4ce05a26fb6211a9023841
parent87083e6d97914dc08cad22cd099af31aece32ff6 (diff)
win32 second instance crashes seem to be in json parser with empty lists, not sure why though. changed what's passed to an object and it now works. change window title to "Transmission Remote" (nicer, especially on Windows).
-rw-r--r--configure.ac2
-rw-r--r--redhat/transmission-remote-gtk.spec2
-rw-r--r--src/installer.nsi2
-rw-r--r--src/main.c67
-rw-r--r--src/trg-main-window.c3
5 files changed, 45 insertions, 31 deletions
diff --git a/configure.ac b/configure.ac
index be86932..1bd6950 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
AC_PREREQ(2.63)
-AC_INIT(transmission-remote-gtk, 0.7.1, alan@eth0.org.uk)
+AC_INIT(transmission-remote-gtk, 0.7.2, alan@eth0.org.uk)
AC_CONFIG_SRCDIR(src)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AM_INIT_AUTOMAKE([foreign])
diff --git a/redhat/transmission-remote-gtk.spec b/redhat/transmission-remote-gtk.spec
index 13f2b52..a8dbe19 100644
--- a/redhat/transmission-remote-gtk.spec
+++ b/redhat/transmission-remote-gtk.spec
@@ -1,5 +1,5 @@
Name: transmission-remote-gtk
-Version: 0.7.1
+Version: 0.7.2
Release: 1%{?dist:%{dist}}
Summary: Remote control client for Transmission BitTorrent
diff --git a/src/installer.nsi b/src/installer.nsi
index 628a7b4..733fcdf 100644
--- a/src/installer.nsi
+++ b/src/installer.nsi
@@ -10,7 +10,7 @@ Name "Transmission Remote GTK"
; The file to write
!ifndef REV
-OutFile "transmission-remote-gtk-0.7.1-installer.exe"
+OutFile "transmission-remote-gtk-0.7.2-installer.exe"
!else
OutFile "transmission-remote-gtk-${REV}-installer.exe"
!endif
diff --git a/src/main.c b/src/main.c
index dc8874f..13e98d2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -42,7 +42,7 @@
#define TRG_LIBUNIQUE_DOMAIN "uk.org.eth0.trg"
#define TRG_MAILSLOT_NAME "\\\\.\\mailslot\\TransmissionRemoteGTK" //Name given to the Mailslot
-#define MAILSLOT_BUFFER_SIZE 1024*64
+#define MAILSLOT_BUFFER_SIZE 1024*32
#ifdef HAVE_LIBUNIQUE
@@ -90,6 +90,7 @@ message_received_cb(UniqueApp * app G_GNUC_UNUSED,
struct trg_mailslot_recv_args {
TrgMainWindow *win;
gchar **uris;
+ gboolean present;
};
/* to be queued into the glib main loop with g_idle_add() */
@@ -97,14 +98,13 @@ struct trg_mailslot_recv_args {
static gboolean mailslot_recv_args(gpointer data) {
struct trg_mailslot_recv_args *args = (struct trg_mailslot_recv_args*) data;
- if (args->uris[0])
+ if (args->uris)
trg_add_from_filename(args->win, args->uris);
- else
- g_free(args->uris);
- gtk_window_deiconify(GTK_WINDOW(args->win));
- gtk_window_present(GTK_WINDOW(args->win));
- gtk_window_activate_focus(GTK_WINDOW(args->win));
+ if (args->present) {
+ gtk_window_deiconify(GTK_WINDOW(args->win));
+ gtk_window_present(GTK_WINDOW(args->win));
+ }
g_free(args);
@@ -139,35 +139,40 @@ static gpointer mailslot_recv_thread(gpointer data) {
if ((!bResult) || (0 == cbBytes)) {
g_error("Mailslot error from client: %d", GetLastError());
- CloseHandle(hMailslot);
- return NULL; //Error
+ break;
}
parser = json_parser_new();
if (json_parser_load_from_data(parser, szBuffer, cbBytes, NULL)) {
JsonNode *node = json_parser_get_root(parser);
- JsonArray *array = json_node_get_array(node);
- GList *arrayList = json_array_get_elements(array);
+ JsonObject *obj = json_node_get_object(node);
struct trg_mailslot_recv_args *args =
- g_new(struct trg_mailslot_recv_args, 1);
- guint arrayLength = arrayList ? g_list_length(arrayList) : 0;
- int i = 0;
- GList *li;
+ g_new0(struct trg_mailslot_recv_args, 1);
- args->uris = g_new0(gchar*, arrayLength+1);
+ args->present = json_object_has_member(obj, "present") && json_object_get_boolean_member(obj, "present");
+ args->win = win;
- for (li = arrayList; li; li = g_list_next(li)) {
- const gchar *liStr = json_node_get_string((JsonNode*) li->data);
- args->uris[i++] = g_strdup(liStr);
- }
+ if (json_object_has_member(obj, "args")) {
+ JsonArray *array = json_node_get_array(node);
+ GList *arrayList = json_array_get_elements(array);
+ if (arrayList) {
+ guint arrayLength = g_list_length(arrayList);
+ int i = 0;
+ GList *li;
- if (arrayList)
- g_list_free(arrayList);
+ args->uris = g_new0(gchar*, arrayLength+1);
- json_node_free(node);
+ for (li = arrayList; li; li = g_list_next(li)) {
+ const gchar *liStr = json_node_get_string((JsonNode*) li->data);
+ args->uris[i++] = g_strdup(liStr);
+ }
- args->win = win;
+ g_list_free(arrayList);
+ }
+ }
+
+ json_node_free(node);
g_idle_add(mailslot_recv_args, args);
}
@@ -181,7 +186,8 @@ static gpointer mailslot_recv_thread(gpointer data) {
static int winunique_send_message(HANDLE h, gchar **args) {
DWORD cbBytes;
- JsonNode *node = json_node_new(JSON_NODE_ARRAY);
+ JsonNode *node = json_node_new(JSON_NODE_OBJECT);
+ JsonObject *obj = json_object_new();
JsonArray *array = json_array_new();
JsonGenerator *generator;
gchar *msg;
@@ -190,10 +196,15 @@ static int winunique_send_message(HANDLE h, gchar **args) {
if (args) {
for (i = 0; args[i]; i++)
json_array_add_string_element(array, args[i]);
+
+ json_object_set_array_member(obj, "args", array);
+
g_strfreev(args);
}
- json_node_take_array(node, array);
+ json_object_set_boolean_member(obj, "present", TRUE);
+
+ json_node_take_object(node, obj);
generator = json_generator_new();
json_generator_set_root(generator, node);
@@ -219,7 +230,9 @@ static int winunique_send_message(HANDLE h, gchar **args) {
static gboolean should_be_minimised(int argc, char *argv[]) {
int i;
for (i = 1; i < argc; i++)
- if (!g_strcmp0(argv[i], "-m") || !g_strcmp0(argv[i], "--minimized"))
+ if (!g_strcmp0(argv[i], "-m")
+ || !g_strcmp0(argv[i], "--minimized")
+ || !g_strcmp0(argv[i], "/m"))
return TRUE;
return FALSE;
diff --git a/src/trg-main-window.c b/src/trg-main-window.c
index 63a81b1..124f915 100644
--- a/src/trg-main-window.c
+++ b/src/trg-main-window.c
@@ -1915,8 +1915,9 @@ static GObject *trg_main_window_constructor(GType type,
if (priv->icon)
gtk_window_set_default_icon(priv->icon);
- gtk_window_set_title(GTK_WINDOW(self), PACKAGE_NAME);
+ gtk_window_set_title(GTK_WINDOW(self), _("Transmission Remote"));
gtk_window_set_default_size(GTK_WINDOW(self), 1000, 600);
+
g_signal_connect(G_OBJECT(self), "delete-event",
G_CALLBACK(delete_event), NULL);
g_signal_connect(G_OBJECT(self), "destroy", G_CALLBACK(destroy_window),