summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bencode.c236
-rw-r--r--src/bencode.h26
-rw-r--r--src/hig.c68
-rw-r--r--src/hig.h52
-rw-r--r--src/json.c45
-rw-r--r--src/json.h4
-rw-r--r--src/main.c326
-rw-r--r--src/protocol-constants.h26
-rw-r--r--src/remote-exec.c240
-rw-r--r--src/remote-exec.h6
-rw-r--r--src/requests.c57
-rw-r--r--src/requests.h4
-rw-r--r--src/session-get.c26
-rw-r--r--src/session-get.h10
-rw-r--r--src/torrent.c345
-rw-r--r--src/torrent.h53
-rw-r--r--src/trg-about-window.c46
-rw-r--r--src/trg-about-window.h2
-rw-r--r--src/trg-cell-renderer-epoch.c90
-rw-r--r--src/trg-cell-renderer-epoch.h2
-rw-r--r--src/trg-cell-renderer-eta.c74
-rw-r--r--src/trg-cell-renderer-eta.h2
-rw-r--r--src/trg-cell-renderer-numgteqthan.c128
-rw-r--r--src/trg-cell-renderer-numgteqthan.h2
-rw-r--r--src/trg-cell-renderer-priority.c68
-rw-r--r--src/trg-cell-renderer-priority.h2
-rw-r--r--src/trg-cell-renderer-ratio.c68
-rw-r--r--src/trg-cell-renderer-ratio.h2
-rw-r--r--src/trg-cell-renderer-size.c66
-rw-r--r--src/trg-cell-renderer-size.h2
-rw-r--r--src/trg-cell-renderer-speed.c70
-rw-r--r--src/trg-cell-renderer-speed.h2
-rw-r--r--src/trg-client.c344
-rw-r--r--src/trg-client.h95
-rw-r--r--src/trg-destination-combo.c418
-rw-r--r--src/trg-destination-combo.h13
-rw-r--r--src/trg-file-parser.c158
-rw-r--r--src/trg-file-parser.h2
-rw-r--r--src/trg-files-model.c106
-rw-r--r--src/trg-files-model.h4
-rw-r--r--src/trg-files-tree-view.c157
-rw-r--r--src/trg-files-tree-view.h6
-rw-r--r--src/trg-general-panel.c145
-rw-r--r--src/trg-general-panel.h7
-rw-r--r--src/trg-json-widgets.c120
-rw-r--r--src/trg-json-widgets.h43
-rw-r--r--src/trg-main-window.c28
-rw-r--r--src/trg-main-window.h9
-rw-r--r--src/trg-menu-bar.c579
-rw-r--r--src/trg-menu-bar.h17
-rw-r--r--src/trg-model.c42
-rw-r--r--src/trg-model.h6
-rw-r--r--src/trg-peers-model.c185
-rw-r--r--src/trg-peers-model.h7
-rw-r--r--src/trg-peers-tree-view.c21
-rw-r--r--src/trg-peers-tree-view.h5
-rw-r--r--src/trg-persistent-tree-view.c306
-rw-r--r--src/trg-persistent-tree-view.h38
-rw-r--r--src/trg-preferences-dialog.c687
-rw-r--r--src/trg-preferences-dialog.h12
-rw-r--r--src/trg-prefs.c367
-rw-r--r--src/trg-prefs.h109
-rw-r--r--src/trg-remote-prefs-dialog.c447
-rw-r--r--src/trg-remote-prefs-dialog.h8
-rw-r--r--src/trg-sortable-filtered-model.c207
-rw-r--r--src/trg-sortable-filtered-model.h24
-rw-r--r--src/trg-state-selector.c554
-rw-r--r--src/trg-state-selector.h13
-rw-r--r--src/trg-stats-dialog.c204
-rw-r--r--src/trg-stats-dialog.h4
-rw-r--r--src/trg-status-bar.c83
-rw-r--r--src/trg-status-bar.h17
-rw-r--r--src/trg-toolbar.c282
-rw-r--r--src/trg-toolbar.h6
-rw-r--r--src/trg-torrent-add-dialog.c825
-rw-r--r--src/trg-torrent-add-dialog.h6
-rw-r--r--src/trg-torrent-add-url-dialog.c78
-rw-r--r--src/trg-torrent-add-url-dialog.h5
-rw-r--r--src/trg-torrent-graph.c294
-rw-r--r--src/trg-torrent-graph.h4
-rw-r--r--src/trg-torrent-model.c657
-rw-r--r--src/trg-torrent-model.h30
-rw-r--r--src/trg-torrent-move-dialog.c226
-rw-r--r--src/trg-torrent-move-dialog.h8
-rw-r--r--src/trg-torrent-props-dialog.c242
-rw-r--r--src/trg-torrent-props-dialog.h8
-rw-r--r--src/trg-torrent-tree-view.c143
-rw-r--r--src/trg-torrent-tree-view.h5
-rw-r--r--src/trg-trackers-model.c135
-rw-r--r--src/trg-trackers-model.h14
-rw-r--r--src/trg-trackers-tree-view.c253
-rw-r--r--src/trg-trackers-tree-view.h8
-rw-r--r--src/trg-tree-view.c489
-rw-r--r--src/trg-tree-view.h23
-rw-r--r--src/util.c259
-rw-r--r--src/util.h18
96 files changed, 6370 insertions, 5395 deletions
diff --git a/src/bencode.c b/src/bencode.c
index c9c9b6a..c6eb9e0 100644
--- a/src/bencode.c
+++ b/src/bencode.c
@@ -24,8 +24,8 @@
* into the public domain as well).
*/
-#include <stdlib.h> /* malloc() realloc() free() strtoll() */
-#include <string.h> /* memset() */
+#include <stdlib.h> /* malloc() realloc() free() strtoll() */
+#include <string.h> /* memset() */
#include <ctype.h>
#include <glib.h>
@@ -36,7 +36,7 @@ static be_node *be_alloc(be_type type)
{
be_node *ret = g_malloc0(sizeof(be_node));
if (ret)
- ret->type = type;
+ ret->type = type;
return ret;
}
@@ -53,7 +53,7 @@ gint64 be_str_len(be_node * node)
{
gint64 ret = 0;
if (node->val.s)
- memcpy(&ret, node->val.s - sizeof(ret), sizeof(ret));
+ memcpy(&ret, node->val.s - sizeof(ret), sizeof(ret));
return ret;
}
@@ -66,30 +66,30 @@ static char *_be_decode_str(const char **data, gint64 * data_len)
/* slen is signed, so negative values get rejected */
if (sllen < 0)
- return ret;
+ return ret;
/* reject attempts to allocate large values that overflow the
* size_t type which is used with malloc()
*/
if (sizeof(gint64) != sizeof(long))
- if (sllen != slen)
- return ret;
+ if (sllen != slen)
+ return ret;
/* make sure we have enough data left */
if (sllen > *data_len - 1)
- return ret;
+ return ret;
/* switch from signed to unsigned so we don't overflow below */
len = slen;
if (**data == ':') {
- char *_ret = g_malloc(sizeof(sllen) + len + 1);
- memcpy(_ret, &sllen, sizeof(sllen));
- ret = _ret + sizeof(sllen);
- memcpy(ret, *data + 1, len);
- ret[len] = '\0';
- *data += len + 1;
- *data_len -= len + 1;
+ char *_ret = g_malloc(sizeof(sllen) + len + 1);
+ memcpy(_ret, &sllen, sizeof(sllen));
+ ret = _ret + sizeof(sllen);
+ memcpy(ret, *data + 1, len);
+ ret[len] = '\0';
+ *data += len + 1;
+ *data_len -= len + 1;
}
return ret;
}
@@ -100,71 +100,71 @@ static be_node *_be_decode(const char **data, gint64 * data_len)
char dc;
if (!*data_len)
- return ret;
+ return ret;
dc = **data;
if (dc == 'l') {
- unsigned int i = 0;
-
- ret = be_alloc(BE_LIST);
-
- --(*data_len);
- ++(*data);
- while (**data != 'e') {
- ret->val.l =
- g_realloc(ret->val.l, (i + 2) * sizeof(*ret->val.l));
- ret->val.l[i] = _be_decode(data, data_len);
- if (!ret->val.l[i])
- break;
- ++i;
- }
- --(*data_len);
- ++(*data);
-
- if (i > 0)
- ret->val.l[i] = NULL;
-
- return ret;
+ unsigned int i = 0;
+
+ ret = be_alloc(BE_LIST);
+
+ --(*data_len);
+ ++(*data);
+ while (**data != 'e') {
+ ret->val.l =
+ g_realloc(ret->val.l, (i + 2) * sizeof(*ret->val.l));
+ ret->val.l[i] = _be_decode(data, data_len);
+ if (!ret->val.l[i])
+ break;
+ ++i;
+ }
+ --(*data_len);
+ ++(*data);
+
+ if (i > 0)
+ ret->val.l[i] = NULL;
+
+ return ret;
} else if (dc == 'd') {
- unsigned int i = 0;
-
- ret = be_alloc(BE_DICT);
-
- --(*data_len);
- ++(*data);
- while (**data != 'e') {
- ret->val.d =
- g_realloc(ret->val.d, (i + 2) * sizeof(*ret->val.d));
- ret->val.d[i].key = _be_decode_str(data, data_len);
- ret->val.d[i].val = _be_decode(data, data_len);
- if (!ret->val.l[i])
- break;
- ++i;
- }
- --(*data_len);
- ++(*data);
-
- if (i > 0)
- ret->val.d[i].val = NULL;
-
- return ret;
+ unsigned int i = 0;
+
+ ret = be_alloc(BE_DICT);
+
+ --(*data_len);
+ ++(*data);
+ while (**data != 'e') {
+ ret->val.d =
+ g_realloc(ret->val.d, (i + 2) * sizeof(*ret->val.d));
+ ret->val.d[i].key = _be_decode_str(data, data_len);
+ ret->val.d[i].val = _be_decode(data, data_len);
+ if (!ret->val.l[i])
+ break;
+ ++i;
+ }
+ --(*data_len);
+ ++(*data);
+
+ if (i > 0)
+ ret->val.d[i].val = NULL;
+
+ return ret;
} else if (dc == 'i') {
- ret = be_alloc(BE_INT);
+ ret = be_alloc(BE_INT);
- --(*data_len);
- ++(*data);
- ret->val.i = _be_decode_int(data, data_len);
- if (**data != 'e')
- return NULL;
- --(*data_len);
- ++(*data);
+ --(*data_len);
+ ++(*data);
+ ret->val.i = _be_decode_int(data, data_len);
+ if (**data != 'e')
+ return NULL;
+ --(*data_len);
+ ++(*data);
- return ret;
+ return ret;
} else if (isdigit(dc)) {
- ret = be_alloc(BE_STR);
+ ret = be_alloc(BE_STR);
- ret->val.s = _be_decode_str(data, data_len);
- return ret;
+ ret->val.s = _be_decode_str(data, data_len);
+ return ret;
}
return ret;
@@ -183,46 +183,46 @@ be_node *be_decode(const char *data)
int be_validate_node(be_node * node, int type)
{
if (!node || node->type != type)
- return 1;
+ return 1;
else
- return 0;
+ return 0;
}
static inline void _be_free_str(char *str)
{
if (str)
- g_free(str - sizeof(gint64));
+ g_free(str - sizeof(gint64));
}
void be_free(be_node * node)
{
switch (node->type) {
case BE_STR:
- _be_free_str(node->val.s);
- break;
+ _be_free_str(node->val.s);
+ break;
case BE_INT:
- break;
+ break;
case BE_LIST:{
- unsigned int i;
- if (node->val.l) {
- for (i = 0; node->val.l[i]; ++i)
- be_free(node->val.l[i]);
- g_free(node->val.l);
- }
- break;
- }
+ unsigned int i;
+ if (node->val.l) {
+ for (i = 0; node->val.l[i]; ++i)
+ be_free(node->val.l[i]);
+ g_free(node->val.l);
+ }
+ break;
+ }
case BE_DICT:{
- unsigned int i;
- for (i = 0; node->val.d[i].val; ++i) {
- _be_free_str(node->val.d[i].key);
- be_free(node->val.d[i].val);
- }
- g_free(node->val.d);
- break;
- }
+ unsigned int i;
+ for (i = 0; node->val.d[i].val; ++i) {
+ _be_free_str(node->val.d[i].key);
+ be_free(node->val.d[i].val);
+ }
+ g_free(node->val.d);
+ break;
+ }
}
g_free(node);
}
@@ -231,11 +231,11 @@ be_node *be_dict_find(be_node * node, char *key, int type)
{
int i;
for (i = 0; node->val.d[i].val; ++i) {
- if (!strcmp(node->val.d[i].key, key)) {
- be_node *cn = node->val.d[i].val;
- if (type < 0 || cn->type == type)
- return node->val.d[i].val;
- }
+ if (!strcmp(node->val.d[i].key, key)) {
+ be_node *cn = node->val.d[i].val;
+ if (type < 0 || cn->type == type)
+ return node->val.d[i].val;
+ }
}
return NULL;
}
@@ -247,7 +247,7 @@ be_node *be_dict_find(be_node * node, char *key, int type)
static void _be_dump_indent(ssize_t indent)
{
while (indent-- > 0)
- printf(" ");
+ printf(" ");
}
static void _be_dump(be_node * node, ssize_t indent)
@@ -259,35 +259,35 @@ static void _be_dump(be_node * node, ssize_t indent)
switch (node->type) {
case BE_STR:
- printf("str = %s (len = %lli)\n", node->val.s, be_str_len(node));
- break;
+ printf("str = %s (len = %lli)\n", node->val.s, be_str_len(node));
+ break;
case BE_INT:
- printf("int = %lli\n", node->val.i);
- break;
+ printf("int = %lli\n", node->val.i);
+ break;
case BE_LIST:
- puts("list [");
+ puts("list [");
- for (i = 0; node->val.l[i]; ++i)
- _be_dump(node->val.l[i], indent + 1);
+ for (i = 0; node->val.l[i]; ++i)
+ _be_dump(node->val.l[i], indent + 1);
- _be_dump_indent(indent);
- puts("]");
- break;
+ _be_dump_indent(indent);
+ puts("]");
+ break;
case BE_DICT:
- puts("dict {");
+ puts("dict {");
- for (i = 0; node->val.d[i].val; ++i) {
- _be_dump_indent(indent + 1);
- printf("%s => ", node->val.d[i].key);
- _be_dump(node->val.d[i].val, -(indent + 1));
- }
+ for (i = 0; node->val.d[i].val; ++i) {
+ _be_dump_indent(indent + 1);
+ printf("%s => ", node->val.d[i].key);
+ _be_dump(node->val.d[i].val, -(indent + 1));
+ }
- _be_dump_indent(indent);
- puts("}");
- break;
+ _be_dump_indent(indent);
+ puts("}");
+ break;
}
}
diff --git a/src/bencode.h b/src/bencode.h
index 71760e0..344fc4f 100644
--- a/src/bencode.h
+++ b/src/bencode.h
@@ -24,10 +24,10 @@ extern "C" {
#endif
typedef enum {
- BE_STR,
- BE_INT,
- BE_LIST,
- BE_DICT
+ BE_STR,
+ BE_INT,
+ BE_LIST,
+ BE_DICT
} be_type;
struct be_dict;
@@ -38,18 +38,18 @@ extern "C" {
*/
typedef struct be_dict {
- char *key;
- struct be_node *val;
+ char *key;
+ struct be_node *val;
} be_dict;
typedef struct be_node {
- be_type type;
- union {
- char *s;
- gint64 i;
- struct be_node **l;
- struct be_dict *d;
- } val;
+ be_type type;
+ union {
+ char *s;
+ gint64 i;
+ struct be_node **l;
+ struct be_dict *d;
+ } val;
} be_node;
extern gint64 be_str_len(be_node * node);
diff --git a/src/hig.c b/src/hig.c
index 453a53b..3c0586f 100644
--- a/src/hig.c
+++ b/src/hig.c
@@ -34,7 +34,7 @@ void hig_workarea_add_section_divider(GtkWidget * t, int *row)
void
hig_workarea_add_section_title_widget(GtkWidget * t,
- int *row, GtkWidget * w)
+ int *row, GtkWidget * w)
{
gtk_table_attach(GTK_TABLE(t), w, 0, 2, *row, *row + 1, ~0, 0, 0, 0);
++*row;
@@ -42,7 +42,7 @@ hig_workarea_add_section_title_widget(GtkWidget * t,
void
hig_workarea_add_section_title(GtkWidget * t,
- int *row, const char *section_title)
+ int *row, const char *section_title)
{
char buf[512];
GtkWidget *l;
@@ -66,9 +66,9 @@ static GtkWidget *rowNew(GtkWidget * w)
/* lhs widget */
if (GTK_IS_MISC(w))
- gtk_misc_set_alignment(GTK_MISC(w), 0.0f, 0.5f);
+ gtk_misc_set_alignment(GTK_MISC(w), 0.0f, 0.5f);
if (GTK_IS_LABEL(w))
- gtk_label_set_use_markup(GTK_LABEL(w), TRUE);
+ gtk_label_set_use_markup(GTK_LABEL(w), TRUE);
gtk_box_pack_start(GTK_BOX(h), w, TRUE, TRUE, 0);
return h;
@@ -79,7 +79,7 @@ void hig_workarea_add_wide_control(GtkWidget * t, int *row, GtkWidget * w)
GtkWidget *r = rowNew(w);
gtk_table_attach(GTK_TABLE(t), r, 0, 2, *row, *row + 1, GTK_FILL,
- 0, 0, 0);
+ 0, 0, 0);
++*row;
}
@@ -89,16 +89,16 @@ hig_workarea_add_wide_tall_control(GtkWidget * t, int *row, GtkWidget * w)
GtkWidget *r = rowNew(w);
gtk_table_attach(GTK_TABLE(t), r, 0, 2, *row, *row + 1,
- GTK_EXPAND | GTK_SHRINK | GTK_FILL,
- GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
+ GTK_EXPAND | GTK_SHRINK | GTK_FILL,
+ GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
++*row;
}
GtkWidget *hig_workarea_add_wide_checkbutton(GtkWidget * t,
- int *row,
- const char *mnemonic_string,
- gboolean is_active)
+ int *row,
+ const char *mnemonic_string,
+ gboolean is_active)
{
GtkWidget *w = gtk_check_button_new_with_mnemonic(mnemonic_string);
@@ -112,11 +112,11 @@ void hig_workarea_add_label_w(GtkWidget * t, int row, GtkWidget * l)
GtkWidget *w = rowNew(l);
gtk_table_attach(GTK_TABLE(t), w, 0, 1, row, row + 1, GTK_FILL,
- GTK_FILL, 0, 0);
+ GTK_FILL, 0, 0);
}
GtkWidget *hig_workarea_add_label(GtkWidget * t,
- int row, const char *mnemonic_string)
+ int row, const char *mnemonic_string)
{
GtkWidget *l = gtk_label_new_with_mnemonic(mnemonic_string);
@@ -128,42 +128,42 @@ static void
hig_workarea_add_tall_control(GtkWidget * t, int row, GtkWidget * control)
{
if (GTK_IS_MISC(control))
- gtk_misc_set_alignment(GTK_MISC(control), 0.0f, 0.5f);
+ gtk_misc_set_alignment(GTK_MISC(control), 0.0f, 0.5f);
gtk_table_attach(GTK_TABLE(t), control,
- 1, 2, row, row + 1,
- GTK_EXPAND | GTK_SHRINK | GTK_FILL,
- GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
+ 1, 2, row, row + 1,
+ GTK_EXPAND | GTK_SHRINK | GTK_FILL,
+ GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
}
void hig_workarea_add_control(GtkWidget * t, int row, GtkWidget * control)
{
if (GTK_IS_MISC(control))
- gtk_misc_set_alignment(GTK_MISC(control), 0.0f, 0.5f);
+ gtk_misc_set_alignment(GTK_MISC(control), 0.0f, 0.5f);
gtk_table_attach(GTK_TABLE(t), control,
- 1, 2, row, row + 1,
- GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0, 0);
+ 1, 2, row, row + 1,
+ GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0, 0);
}
void
hig_workarea_add_row_w(GtkWidget * t,
- int *row,
- GtkWidget * label,
- GtkWidget * control, GtkWidget * mnemonic)
+ int *row,
+ GtkWidget * label,
+ GtkWidget * control, GtkWidget * mnemonic)
{
hig_workarea_add_label_w(t, *row, label);
hig_workarea_add_control(t, *row, control);
if (GTK_IS_LABEL(label))
- gtk_label_set_mnemonic_widget(GTK_LABEL(label),
- mnemonic ? mnemonic : control);
+ gtk_label_set_mnemonic_widget(GTK_LABEL(label),
+ mnemonic ? mnemonic : control);
++*row;
}
GtkWidget *hig_workarea_add_row(GtkWidget * t,
- int *row,
- const char *mnemonic_string,
- GtkWidget * control, GtkWidget * mnemonic)
+ int *row,
+ const char *mnemonic_string,
+ GtkWidget * control, GtkWidget * mnemonic)
{
GtkWidget *l = gtk_label_new_with_mnemonic(mnemonic_string);
@@ -172,10 +172,10 @@ GtkWidget *hig_workarea_add_row(GtkWidget * t,
}
GtkWidget *hig_workarea_add_tall_row(GtkWidget * table,
- int *row,
- const char *mnemonic_string,
- GtkWidget * control,
- GtkWidget * mnemonic)
+ int *row,
+ const char *mnemonic_string,
+ GtkWidget * control,
+ GtkWidget * mnemonic)
{
GtkWidget *l = gtk_label_new_with_mnemonic(mnemonic_string);
GtkWidget *h = gtk_hbox_new(FALSE, 0);
@@ -187,8 +187,8 @@ GtkWidget *hig_workarea_add_tall_row(GtkWidget * table,
hig_workarea_add_tall_control(table, *row, control);
if (GTK_IS_LABEL(l))
- gtk_label_set_mnemonic_widget(GTK_LABEL(l),
- mnemonic ? mnemonic : control);
+ gtk_label_set_mnemonic_widget(GTK_LABEL(l),
+ mnemonic ? mnemonic : control);
++*row;
return l;
@@ -201,7 +201,7 @@ void hig_workarea_finish(GtkWidget * t, int *row)
void
hig_message_dialog_set_text(GtkMessageDialog * dialog,
- const char *primary, const char *secondary)
+ const char *primary, const char *secondary)
{
gtk_message_dialog_set_markup(dialog, primary);
gtk_message_dialog_format_secondary_text(dialog, "%s", secondary);
diff --git a/src/hig.h b/src/hig.h
index 63a6b76..186e66a 100644
--- a/src/hig.h
+++ b/src/hig.h
@@ -25,55 +25,55 @@ GtkWidget *hig_workarea_create(void);
void hig_workarea_add_section_divider(GtkWidget * table, int *row);
void hig_workarea_add_section_title_widget(GtkWidget * t,
- int *row, GtkWidget * w);
+ int *row, GtkWidget * w);
void hig_workarea_add_section_title(GtkWidget * table,
- int *row, const char *section_title);
+ int *row, const char *section_title);
void hig_workarea_add_wide_tall_control(GtkWidget * table,
- int *row, GtkWidget * w);
+ int *row, GtkWidget * w);
void hig_workarea_add_wide_control(GtkWidget * table,
- int *row, GtkWidget * w);
+ int *row, GtkWidget * w);
GtkWidget *hig_workarea_add_wide_checkbutton(GtkWidget * table,
- int *row,
- const char *mnemonic_string,
- gboolean is_active);
+ int *row,
+ const char *mnemonic_string,
+ gboolean is_active);
GtkWidget *hig_workarea_add_label(GtkWidget * table,
- int row, const char *mnemonic_string);
+ int row, const char *mnemonic_string);
void hig_workarea_add_label_w(GtkWidget * table,
- int row, GtkWidget * label_widget);
+ int row, GtkWidget * label_widget);
void hig_workarea_add_control(GtkWidget * table,
- int row, GtkWidget * control);
+ int row, GtkWidget * control);
GtkWidget *hig_workarea_add_tall_row(GtkWidget * table,
- int *row,
- const char *mnemonic_string,
- GtkWidget * control,
- GtkWidget *
- mnemonic_or_null_for_control);
+ int *row,
+ const char *mnemonic_string,
+ GtkWidget * control,
+ GtkWidget *
+ mnemonic_or_null_for_control);
GtkWidget *hig_workarea_add_row(GtkWidget * table,
- int *row,
- const char *mnemonic_string,
- GtkWidget * control,
- GtkWidget * mnemonic_or_null_for_control);
+ int *row,
+ const char *mnemonic_string,
+ GtkWidget * control,
+ GtkWidget * mnemonic_or_null_for_control);
void hig_workarea_add_row_w(GtkWidget * table,
- int *row,
- GtkWidget * label,
- GtkWidget * control,
- GtkWidget * mnemonic_or_null_for_control);
+ int *row,
+ GtkWidget * label,
+ GtkWidget * control,
+ GtkWidget * mnemonic_or_null_for_control);
void hig_workarea_finish(GtkWidget * table, int *row);
void hig_message_dialog_set_text(GtkMessageDialog * dialog,
- const char *primary,
- const char *secondary);
+ const char *primary,
+ const char *secondary);
enum {
GUI_PAD_SMALL = 3,
@@ -82,4 +82,4 @@ enum {
GUI_PAD_LARGE = 12
};
-#endif /* __HIG_H__ */
+#endif /* __HIG_H__ */
diff --git a/src/json.c b/src/json.c
index 71ae0e4..806ab3e 100644
--- a/src/json.c
+++ b/src/json.c
@@ -44,8 +44,7 @@ gchar *trg_serialize(JsonNode * req)
return response;
}
-JsonObject *trg_deserialize(trg_response * response,
- GError ** error)
+JsonObject *trg_deserialize(trg_response * response, GError ** error)
{
JsonParser *parser;
JsonNode *root;
@@ -53,30 +52,30 @@ JsonObject *trg_deserialize(trg_response * response,
parser = json_parser_new();
json_parser_load_from_data(parser, response->raw, response->size,
- error);
+ error);
if (*error == NULL) {
- root = json_parser_get_root(parser);
+ root = json_parser_get_root(parser);
#ifdef DEBUG
- if (g_getenv("TRG_SHOW_INCOMING") != NULL) {
- g_debug("<=(INcoming)<=: %s", response->raw);
- } else if (g_getenv("TRG_SHOW_INCOMING_PRETTY") != NULL) {
- JsonGenerator *pg;
- gsize len;
- gchar *pgdata;
-
- pg = json_generator_new();
- g_object_set(pg, "pretty", TRUE, NULL);
- json_generator_set_root(pg, root);
-
- pgdata = json_generator_to_data(pg, &len);
- g_debug("<=(incoming)<=:\n%s\n", pgdata);
- g_free(pgdata);
-
- g_object_unref(pg);
- }
+ if (g_getenv("TRG_SHOW_INCOMING") != NULL) {
+ g_debug("<=(INcoming)<=: %s", response->raw);
+ } else if (g_getenv("TRG_SHOW_INCOMING_PRETTY") != NULL) {
+ JsonGenerator *pg;
+ gsize len;
+ gchar *pgdata;
+
+ pg = json_generator_new();
+ g_object_set(pg, "pretty", TRUE, NULL);
+ json_generator_set_root(pg, root);
+
+ pgdata = json_generator_to_data(pg, &len);
+ g_debug("<=(incoming)<=:\n%s\n", pgdata);
+ g_free(pgdata);
+
+ g_object_unref(pg);
+ }
#endif
- ret = json_node_get_object(root);
- json_object_ref(ret);
+ ret = json_node_get_object(root);
+ json_object_ref(ret);
}
g_object_unref(parser);
diff --git a/src/json.h b/src/json.h
index 62237f8..232728a 100644
--- a/src/json.h
+++ b/src/json.h
@@ -26,8 +26,8 @@
#include "trg-client.h"
gchar *trg_serialize(JsonNode * req);
-JsonObject *trg_deserialize(trg_response *response, GError ** error);
+JsonObject *trg_deserialize(trg_response * response, GError ** error);
JsonObject *get_arguments(JsonObject * req);
JsonObject *node_get_arguments(JsonNode * req);
-#endif /* JSON_H_ */
+#endif /* JSON_H_ */
diff --git a/src/main.c b/src/main.c
index f79d3ed..61efb68 100644
--- a/src/main.c
+++ b/src/main.c
@@ -50,7 +50,7 @@
*/
#define TRG_LIBUNIQUE_DOMAIN "uk.org.eth0.trg"
-#define TRG_MAILSLOT_NAME "\\\\.\\mailslot\\TransmissionRemoteGTK" //Name given to the Mailslot
+#define TRG_MAILSLOT_NAME "\\\\.\\mailslot\\TransmissionRemoteGTK" //Name given to the Mailslot
#define MAILSLOT_BUFFER_SIZE 1024*32
#ifdef HAVE_LIBUNIQUE
@@ -62,9 +62,9 @@ enum {
static UniqueResponse
message_received_cb(UniqueApp * app G_GNUC_UNUSED,
- gint command,
- UniqueMessageData * message,
- guint time_, gpointer user_data)
+ gint command,
+ UniqueMessageData * message,
+ guint time_, gpointer user_data)
{
TrgMainWindow *win;
UniqueResponse res;
@@ -73,22 +73,22 @@ message_received_cb(UniqueApp * app G_GNUC_UNUSED,
win = TRG_MAIN_WINDOW(user_data);
switch (command) {
- case UNIQUE_ACTIVATE:
- gtk_window_set_screen(GTK_WINDOW(user_data),
- unique_message_data_get_screen(message));
- gtk_window_present_with_time(GTK_WINDOW(user_data), time_);
- res = UNIQUE_RESPONSE_OK;
- break;
- case COMMAND_ADD:
- uris = unique_message_data_get_uris(message);
- res =
- trg_add_from_filename(win,
- uris) ? UNIQUE_RESPONSE_OK :
- UNIQUE_RESPONSE_FAIL;
- break;
- default:
- res = UNIQUE_RESPONSE_OK;
- break;
+ case UNIQUE_ACTIVATE:
+ gtk_window_set_screen(GTK_WINDOW(user_data),
+ unique_message_data_get_screen(message));
+ gtk_window_present_with_time(GTK_WINDOW(user_data), time_);
+ res = UNIQUE_RESPONSE_OK;
+ break;
+ case COMMAND_ADD:
+ uris = unique_message_data_get_uris(message);
+ res =
+ trg_add_from_filename(win,
+ uris) ? UNIQUE_RESPONSE_OK :
+ UNIQUE_RESPONSE_FAIL;
+ break;
+ default:
+ res = UNIQUE_RESPONSE_OK;
+ break;
}
return res;
@@ -104,23 +104,26 @@ struct trg_mailslot_recv_args {
/* to be queued into the glib main loop with g_idle_add() */
-static gboolean mailslot_recv_args(gpointer data) {
- struct trg_mailslot_recv_args *args = (struct trg_mailslot_recv_args*) data;
+static gboolean mailslot_recv_args(gpointer data)
+{
+ struct trg_mailslot_recv_args *args =
+ (struct trg_mailslot_recv_args *) data;
if (args->present) {
- gtk_window_deiconify(GTK_WINDOW(args->win));
- gtk_window_present(GTK_WINDOW(args->win));
+ gtk_window_deiconify(GTK_WINDOW(args->win));
+ gtk_window_present(GTK_WINDOW(args->win));
}
if (args->uris)
- trg_add_from_filename(args->win, args->uris);
+ trg_add_from_filename(args->win, args->uris);
g_free(args);
return FALSE;
}
-static gpointer mailslot_recv_thread(gpointer data) {
+static gpointer mailslot_recv_thread(gpointer data)
+{
TrgMainWindow *win = TRG_MAIN_WINDOW(data);
JsonParser *parser;
char szBuffer[MAILSLOT_BUFFER_SIZE];
@@ -128,73 +131,77 @@ static gpointer mailslot_recv_thread(gpointer data) {
DWORD cbBytes;
BOOL bResult;
- hMailslot = CreateMailslot(TRG_MAILSLOT_NAME, // mailslot name
- MAILSLOT_BUFFER_SIZE, // input buffer size
- MAILSLOT_WAIT_FOREVER, // no timeout
- NULL); // default security attribute
+ hMailslot = CreateMailslot(TRG_MAILSLOT_NAME, // mailslot name
+ MAILSLOT_BUFFER_SIZE, // input buffer size
+ MAILSLOT_WAIT_FOREVER, // no timeout
+ NULL); // default security attribute
if (INVALID_HANDLE_VALUE == hMailslot) {
- g_error(
- "\nError occurred while creating the mailslot: %d", GetLastError());
- return NULL; //Error
+ g_error("\nError occurred while creating the mailslot: %d",
+ GetLastError());
+ return NULL; //Error
}
while (1) {
- bResult = ReadFile(hMailslot, // handle to mailslot
- szBuffer, // buffer to receive data
- sizeof(szBuffer), // size of buffer
- &cbBytes, // number of bytes read
- NULL); // not overlapped I/O
+ bResult = ReadFile(hMailslot, // handle to mailslot
+ szBuffer, // buffer to receive data
+ sizeof(szBuffer), // size of buffer
+ &cbBytes, // number of bytes read
+ NULL); // not overlapped I/O
- if ((!bResult) || (0 == cbBytes)) {
- g_error("Mailslot error from client: %d", GetLastError());
- break;
- }
+ if ((!bResult) || (0 == cbBytes)) {
+ g_error("Mailslot error from client: %d", GetLastError());
+ break;
+ }
- parser = json_parser_new();
+ parser = json_parser_new();
- if (json_parser_load_from_data(parser, szBuffer, cbBytes, NULL)) {
- JsonNode *node = json_parser_get_root(parser);
- JsonObject *obj = json_node_get_object(node);
- struct trg_mailslot_recv_args *args =
- g_new0(struct trg_mailslot_recv_args, 1);
+ if (json_parser_load_from_data(parser, szBuffer, cbBytes, NULL)) {
+ JsonNode *node = json_parser_get_root(parser);
+ JsonObject *obj = json_node_get_object(node);
+ struct trg_mailslot_recv_args *args =
+ g_new0(struct trg_mailslot_recv_args, 1);
- args->present = json_object_has_member(obj, "present") && json_object_get_boolean_member(obj, "present");
- args->win = win;
+ args->present = json_object_has_member(obj, "present")
+ && json_object_get_boolean_member(obj, "present");
+ args->win = win;
- if (json_object_has_member(obj, "args")) {
- JsonArray *array = json_object_get_array_member(obj, "args");
- GList *arrayList = json_array_get_elements(array);
+ if (json_object_has_member(obj, "args")) {
+ JsonArray *array =
+ json_object_get_array_member(obj, "args");
+ GList *arrayList = json_array_get_elements(array);
- if (arrayList) {
- guint arrayLength = g_list_length(arrayList);
- guint i = 0;
- GList *li;
+ if (arrayList) {
+ guint arrayLength = g_list_length(arrayList);
+ guint i = 0;
+ GList *li;
- args->uris = g_new0(gchar*, arrayLength+1);
+ args->uris = g_new0(gchar *, arrayLength + 1);
- 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);
- }
+ 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);
+ }
- g_list_free(arrayList);
- }
- }
+ g_list_free(arrayList);
+ }
+ }
- json_node_free(node);
+ json_node_free(node);
- g_idle_add(mailslot_recv_args, args);
- }
+ g_idle_add(mailslot_recv_args, args);
+ }
- g_object_unref(parser);
+ g_object_unref(parser);
}
CloseHandle(hMailslot);
- return NULL; //Success
+ return NULL; //Success
}
-static int mailslot_send_message(HANDLE h, gchar **args) {
+static int mailslot_send_message(HANDLE h, gchar ** args)
+{
DWORD cbBytes;
JsonNode *node = json_node_new(JSON_NODE_OBJECT);
JsonObject *obj = json_object_new();
@@ -204,14 +211,14 @@ static int mailslot_send_message(HANDLE h, gchar **args) {
int i;
if (args) {
- for (i = 0; args[i]; i++)
- json_array_add_string_element(array, args[i]);
+ for (i = 0; args[i]; i++)
+ json_array_add_string_element(array, args[i]);
- json_object_set_array_member(obj, "args", array);
+ json_object_set_array_member(obj, "args", array);
- g_strfreev(args);
+ g_strfreev(args);
} else {
- json_object_set_boolean_member(obj, "present", TRUE);
+ json_object_set_boolean_member(obj, "present", TRUE);
}
json_node_take_object(node, obj);
@@ -223,11 +230,11 @@ static int mailslot_send_message(HANDLE h, gchar **args) {
json_node_free(node);
g_object_unref(generator);
- WriteFile(h, // handle to mailslot
- msg, // buffer to write from
- strlen(msg) + 1, // number of bytes to write, include the NULL
- &cbBytes, // number of bytes written
- NULL);
+ WriteFile(h, // handle to mailslot
+ msg, // buffer to write from
+ strlen(msg) + 1, // number of bytes to write, include the NULL
+ &cbBytes, // number of bytes written
+ NULL);
CloseHandle(h);
g_free(msg);
@@ -237,52 +244,55 @@ static int mailslot_send_message(HANDLE h, gchar **args) {
#endif
-static gboolean is_minimised_arg(gchar *arg)
+static gboolean is_minimised_arg(gchar * arg)
{
return !g_strcmp0(arg, "-m")
- || !g_strcmp0(arg, "--minimized")
- || !g_strcmp0(arg, "/m");
+ || !g_strcmp0(arg, "--minimized")
+ || !g_strcmp0(arg, "/m");
}
-static gboolean should_be_minimised(int argc, char *argv[]) {
+static gboolean should_be_minimised(int argc, char *argv[])
+{
int i;
for (i = 1; i < argc; i++)
- if (is_minimised_arg(argv[i]))
- return TRUE;
+ if (is_minimised_arg(argv[i]))
+ return TRUE;
return FALSE;
}
-static gchar **convert_args(int argc, char *argv[]) {
+static gchar **convert_args(int argc, char *argv[])
+{
gchar *cwd = g_get_current_dir();
gchar **files = NULL;
if (argc > 1) {
- GSList *list = NULL;
- int i;
-
- for (i = 1; i < argc; i++) {
- if (is_minimised_arg(argv[i])) {
- continue;
- } else if (!is_url(argv[i]) && !is_magnet(argv[i])
- && g_file_test(argv[i], G_FILE_TEST_IS_REGULAR)
- && !g_path_is_absolute(argv[i])) {
- list = g_slist_append(list,
- g_build_path(G_DIR_SEPARATOR_S, cwd, argv[i], NULL));
- } else {
- list = g_slist_append(list, g_strdup(argv[i]));
- }
- }
-
- if (list) {
- GSList *li;
- files = g_new0(gchar*, g_slist_length(list)+1);
- i = 0;
- for (li = list; li; li = g_slist_next(li)) {
- files[i++] = li->data;
- }
- g_slist_free(list);
- }
+ GSList *list = NULL;
+ int i;
+
+ for (i = 1; i < argc; i++) {
+ if (is_minimised_arg(argv[i])) {
+ continue;
+ } else if (!is_url(argv[i]) && !is_magnet(argv[i])
+ && g_file_test(argv[i], G_FILE_TEST_IS_REGULAR)
+ && !g_path_is_absolute(argv[i])) {
+ list = g_slist_append(list,
+ g_build_path(G_DIR_SEPARATOR_S, cwd,
+ argv[i], NULL));
+ } else {
+ list = g_slist_append(list, g_strdup(argv[i]));
+ }
+ }
+
+ if (list) {
+ GSList *li;
+ files = g_new0(gchar *, g_slist_length(list) + 1);
+ i = 0;
+ for (li = list; li; li = g_slist_next(li)) {
+ files[i++] = li->data;
+ }
+ g_slist_free(list);
+ }
}
g_free(cwd);
@@ -290,7 +300,8 @@ static gchar **convert_args(int argc, char *argv[]) {
return files;
}
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
int returnValue = EXIT_SUCCESS;
TrgMainWindow *window;
TrgClient *client;
@@ -304,7 +315,7 @@ int main(int argc, char *argv[]) {
HANDLE hMailSlot;
#endif
#ifdef TRG_MEMPROFILE
- GMemVTable gmvt = {malloc,realloc,free,calloc,malloc,realloc};
+ GMemVTable gmvt = { malloc, realloc, free, calloc, malloc, realloc };
g_mem_set_vtable(&gmvt);
g_mem_set_vtable(glib_mem_profiler_table);
g_mem_profile();
@@ -318,7 +329,7 @@ int main(int argc, char *argv[]) {
#ifdef WIN32
moddir = g_win32_get_package_installation_directory_of_module(NULL);
localedir = g_build_path(G_DIR_SEPARATOR_S, moddir, "share", "locale",
- NULL);
+ NULL);
g_free(moddir);
bindtextdomain(GETTEXT_PACKAGE, localedir);
g_free(localedir);
@@ -332,67 +343,68 @@ int main(int argc, char *argv[]) {
#ifdef HAVE_LIBUNIQUE
if (withUnique)
- app = unique_app_new_with_commands(TRG_LIBUNIQUE_DOMAIN, NULL,
- "add", COMMAND_ADD, NULL);
+ app = unique_app_new_with_commands(TRG_LIBUNIQUE_DOMAIN, NULL,
+ "add", COMMAND_ADD, NULL);
if (withUnique && unique_app_is_running(app)) {
- UniqueCommand command;
- UniqueResponse response;
- UniqueMessageData *message;
-
- if (args) {
- command = COMMAND_ADD;
- message = unique_message_data_new();
- unique_message_data_set_uris(message, args);
- g_strfreev(args);
- } else {
- command = UNIQUE_ACTIVATE;
- message = NULL;
- }
-
- response = unique_app_send_message(app, command, message);
- unique_message_data_free(message);
-
- if (response != UNIQUE_RESPONSE_OK)
- returnValue = EXIT_FAILURE;
+ UniqueCommand command;
+ UniqueResponse response;
+ UniqueMessageData *message;
+
+ if (args) {
+ command = COMMAND_ADD;
+ message = unique_message_data_new();
+ unique_message_data_set_uris(message, args);
+ g_strfreev(args);
+ } else {
+ command = UNIQUE_ACTIVATE;
+ message = NULL;
+ }
+
+ response = unique_app_send_message(app, command, message);
+ unique_message_data_free(message);
+
+ if (response != UNIQUE_RESPONSE_OK)
+ returnValue = EXIT_FAILURE;
} else {
#elif WIN32
- hMailSlot = CreateFile(TRG_MAILSLOT_NAME, // mailslot name
- GENERIC_WRITE, // mailslot write only
- FILE_SHARE_READ, // required for mailslots
- NULL, // default security attributes
- OPEN_EXISTING, // opens existing mailslot
- FILE_ATTRIBUTE_NORMAL, // normal attributes
- NULL); // no template file
+ hMailSlot = CreateFile(TRG_MAILSLOT_NAME, // mailslot name
+ GENERIC_WRITE, // mailslot write only
+ FILE_SHARE_READ, // required for mailslots
+ NULL, // default security attributes
+ OPEN_EXISTING, // opens existing mailslot
+ FILE_ATTRIBUTE_NORMAL, // normal attributes
+ NULL); // no template file
if (INVALID_HANDLE_VALUE != hMailSlot) {
- returnValue = mailslot_send_message(hMailSlot, args);
+ returnValue = mailslot_send_message(hMailSlot, args);
} else {
#endif
- client = trg_client_new();
+ client = trg_client_new();
- curl_global_init(CURL_GLOBAL_ALL);
+ curl_global_init(CURL_GLOBAL_ALL);
- window = trg_main_window_new(client, should_be_minimised(argc, argv));
+ window =
+ trg_main_window_new(client, should_be_minimised(argc, argv));
#ifdef HAVE_LIBUNIQUE
- if (withUnique) {
- g_signal_connect(app, "message-received",
- G_CALLBACK(message_received_cb), window);
- }
+ if (withUnique) {
+ g_signal_connect(app, "message-received",
+ G_CALLBACK(message_received_cb), window);
+ }
#elif WIN32
- g_thread_create(mailslot_recv_thread, window, FALSE, NULL);
+ g_thread_create(mailslot_recv_thread, window, FALSE, NULL);
#endif
- auto_connect_if_required(window, args);
- gtk_main();
+ auto_connect_if_required(window, args);
+ gtk_main();
- curl_global_cleanup();
+ curl_global_cleanup();
#ifdef HAVE_LIBUNIQUE
}
if (withUnique)
- g_object_unref(app);
+ g_object_unref(app);
#elif WIN32
}
#endif
diff --git a/src/protocol-constants.h b/src/protocol-constants.h
index 96a7376..3eb9d69 100644
--- a/src/protocol-constants.h
+++ b/src/protocol-constants.h
@@ -33,7 +33,7 @@
/* torrents */
#define FIELD_RECENTLY_ACTIVE "recently-active"
-#define FIELD_TORRENTS "torrents" /* parent node */
+#define FIELD_TORRENTS "torrents" /* parent node */
#define FIELD_REMOVED "removed"
#define FIELD_ANNOUNCE_URL "announceUrl"
#define FIELD_LEFT_UNTIL_DONE "leftUntilDone"
@@ -171,21 +171,19 @@ typedef enum {
OLD_STATUS_PAUSED = 16
} trg_old_status;
-typedef enum
-{
- TR_STATUS_STOPPED = 0, /* Torrent is stopped */
- TR_STATUS_CHECK_WAIT = 1, /* Queued to check files */
- TR_STATUS_CHECK = 2, /* Checking files */
- TR_STATUS_DOWNLOAD_WAIT = 3, /* Queued to download */
- TR_STATUS_DOWNLOAD = 4, /* Downloading */
- TR_STATUS_SEED_WAIT = 5, /* Queued to seed */
- TR_STATUS_SEED = 6 /* Seeding */
-}
-tr_torrent_activity;
+typedef enum {
+ TR_STATUS_STOPPED = 0, /* Torrent is stopped */
+ TR_STATUS_CHECK_WAIT = 1, /* Queued to check files */
+ TR_STATUS_CHECK = 2, /* Checking files */
+ TR_STATUS_DOWNLOAD_WAIT = 3, /* Queued to download */
+ TR_STATUS_DOWNLOAD = 4, /* Downloading */
+ TR_STATUS_SEED_WAIT = 5, /* Queued to seed */
+ TR_STATUS_SEED = 6 /* Seeding */
+} tr_torrent_activity;
enum {
TR_PRI_LOW = -1,
- TR_PRI_NORMAL = 0, /* since NORMAL is 0, memset initializes nicely */
+ TR_PRI_NORMAL = 0, /* since NORMAL is 0, memset initializes nicely */
TR_PRI_HIGH = 1
};
@@ -193,4 +191,4 @@ enum {
#define TFILE_BYTES_COMPLETED "bytesCompleted"
#define TFILE_NAME "name"
-#endif /* PROTOCOL_CONSTANTS_H_ */
+#endif /* PROTOCOL_CONSTANTS_H_ */
diff --git a/src/remote-exec.c b/src/remote-exec.c
index c3e1a74..3f665bc 100644
--- a/src/remote-exec.c
+++ b/src/remote-exec.c
@@ -38,20 +38,21 @@
*/
static const char json_exceptions[] = { 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84,
- 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90,
- 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c,
- 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8,
- 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4,
- 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0,
- 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc,
- 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
- 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4,
- 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0,
- 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc,
- 0xfd, 0xfe, 0xff, '\0' /* g_strescape() expects a NUL-terminated string */
+ 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90,
+ 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c,
+ 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8,
+ 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4,
+ 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0,
+ 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc,
+ 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
+ 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4,
+ 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0,
+ 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc,
+ 0xfd, 0xfe, 0xff, '\0' /* g_strescape() expects a NUL-terminated string */
};
-static gchar *dump_json_value(JsonNode * node) {
+static gchar *dump_json_value(JsonNode * node)
+{
GValue value = { 0, };
GString *buffer;
@@ -61,31 +62,33 @@ static gchar *dump_json_value(JsonNode * node) {
switch (G_VALUE_TYPE(&value)) {
case G_TYPE_INT64:
- g_string_append_printf(buffer, "%" G_GINT64_FORMAT,
- g_value_get_int64(&value));
- break;
- case G_TYPE_STRING: {
- gchar *tmp;
-
- tmp = g_strescape(g_value_get_string(&value), json_exceptions);
- g_string_append(buffer, tmp);
-
- g_free(tmp);
- }
- break;
- case G_TYPE_DOUBLE: {
- gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
-
- g_string_append(buffer,
- g_ascii_dtostr(buf, sizeof(buf), g_value_get_double(&value)));
- }
- break;
+ g_string_append_printf(buffer, "%" G_GINT64_FORMAT,
+ g_value_get_int64(&value));
+ break;
+ case G_TYPE_STRING:{
+ gchar *tmp;
+
+ tmp = g_strescape(g_value_get_string(&value), json_exceptions);
+ g_string_append(buffer, tmp);
+
+ g_free(tmp);
+ }
+ break;
+ case G_TYPE_DOUBLE:{
+ gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
+
+ g_string_append(buffer,
+ g_ascii_dtostr(buf, sizeof(buf),
+ g_value_get_double(&value)));
+ }
+ break;
case G_TYPE_BOOLEAN:
- g_string_append_printf(buffer, "%s",
- g_value_get_boolean(&value) ? "true" : "false");
- break;
+ g_string_append_printf(buffer, "%s",
+ g_value_get_boolean(&value) ? "true" :
+ "false");
+ break;
default:
- break;
+ break;
}
g_value_unset(&value);
@@ -93,8 +96,9 @@ static gchar *dump_json_value(JsonNode * node) {
return g_string_free(buffer, FALSE);
}
-gchar *build_remote_exec_cmd(TrgClient *tc, GtkTreeModel *model, GList *selection,
- const gchar * input) {
+gchar *build_remote_exec_cmd(TrgClient * tc, GtkTreeModel * model,
+ GList * selection, const gchar * input)
+{
TrgPrefs *prefs = trg_client_get_prefs(tc);
JsonObject *session = trg_client_get_session(tc);
JsonObject *profile = trg_prefs_get_connection(prefs);
@@ -105,7 +109,7 @@ gchar *build_remote_exec_cmd(TrgClient *tc, GtkTreeModel *model, GList *selectio
JsonNode *replacement;
if (!profile)
- return NULL;
+ return NULL;
work = g_strdup(input);
regex = g_regex_new("%{([A-Za-z\\-]+)}(?:\\[(.*)\\])?", 0, 0, NULL);
@@ -113,86 +117,86 @@ gchar *build_remote_exec_cmd(TrgClient *tc, GtkTreeModel *model, GList *selectio
g_regex_match_full(regex, input, -1, 0, 0, &match_info, NULL);
if (match_info) {
- while (g_match_info_matches(match_info)) {
- whole = g_match_info_fetch(match_info, 0);
- wholeEscaped = g_regex_escape_string(whole, -1);
- id = g_match_info_fetch(match_info, 1);
- repeater = g_match_info_fetch(match_info, 2);
-
- replacerx = g_regex_new(wholeEscaped, 0, 0, NULL);
- valuestr = NULL;
-
- if (profile && json_object_has_member(profile, id)) {
- replacement = json_object_get_member(profile, id);
- if (JSON_NODE_HOLDS_VALUE(replacement))
- valuestr = dump_json_value(replacement);
- } else if (session && json_object_has_member(session, id)) {
- replacement = json_object_get_member(session, id);
- if (JSON_NODE_HOLDS_VALUE(replacement))
- valuestr = dump_json_value(replacement);
- } else {
- GString *gs = g_string_new ("");
- GList *li;
- GtkTreeIter iter;
- JsonObject *json;
- gchar *piece;
-
- for (li = selection; li; li = g_list_next(li)) {
- piece = NULL;
- gtk_tree_model_get_iter(model, &iter, (GtkTreePath*)li->data);
- gtk_tree_model_get(model, &iter, TORRENT_COLUMN_JSON, &json, -1);
- if (json_object_has_member(json, id)) {
- replacement = json_object_get_member(json, id);
- if (JSON_NODE_HOLDS_VALUE(replacement)) {
- piece = dump_json_value(replacement);
- }
- }
-
- if (!piece) {
- if (!g_strcmp0(id, "full-dir")) {
- piece = torrent_get_full_dir(json);
- } else if (!g_strcmp0(id, "full-path")) {
- piece = torrent_get_full_path(json);
- }
- }
-
- if (piece) {
- g_string_append(gs, piece);
- g_free(piece);
- }
-
- if (!repeater)
- break;
-
- if (piece && li != g_list_last(selection))
- g_string_append(gs, repeater);
- }
-
- if (gs->len > 0)
- valuestr = g_string_free (gs, FALSE);
- else
- g_string_free(gs, TRUE);
- }
-
- if (valuestr)
- {
- tmp
- = g_regex_replace(replacerx, work, -1, 0, valuestr, 0,
- NULL);
- g_free(work);
- work = tmp;
- g_free(valuestr);
- }
-
- g_regex_unref(replacerx);
- g_free(whole);
- g_free(repeater);
- g_free(wholeEscaped);
- g_free(id);
- g_match_info_next(match_info, NULL);
- }
-
- g_match_info_free(match_info);
+ while (g_match_info_matches(match_info)) {
+ whole = g_match_info_fetch(match_info, 0);
+ wholeEscaped = g_regex_escape_string(whole, -1);
+ id = g_match_info_fetch(match_info, 1);
+ repeater = g_match_info_fetch(match_info, 2);
+
+ replacerx = g_regex_new(wholeEscaped, 0, 0, NULL);
+ valuestr = NULL;
+
+ if (profile && json_object_has_member(profile, id)) {
+ replacement = json_object_get_member(profile, id);
+ if (JSON_NODE_HOLDS_VALUE(replacement))
+ valuestr = dump_json_value(replacement);
+ } else if (session && json_object_has_member(session, id)) {
+ replacement = json_object_get_member(session, id);
+ if (JSON_NODE_HOLDS_VALUE(replacement))
+ valuestr = dump_json_value(replacement);
+ } else {
+ GString *gs = g_string_new("");
+ GList *li;
+ GtkTreeIter iter;
+ JsonObject *json;
+ gchar *piece;
+
+ for (li = selection; li; li = g_list_next(li)) {
+ piece = NULL;
+ gtk_tree_model_get_iter(model, &iter,
+ (GtkTreePath *) li->data);
+ gtk_tree_model_get(model, &iter, TORRENT_COLUMN_JSON,
+ &json, -1);
+ if (json_object_has_member(json, id)) {
+ replacement = json_object_get_member(json, id);
+ if (JSON_NODE_HOLDS_VALUE(replacement)) {
+ piece = dump_json_value(replacement);
+ }
+ }
+
+ if (!piece) {
+ if (!g_strcmp0(id, "full-dir")) {
+ piece = torrent_get_full_dir(json);
+ } else if (!g_strcmp0(id, "full-path")) {
+ piece = torrent_get_full_path(json);
+ }
+ }
+
+ if (piece) {
+ g_string_append(gs, piece);
+ g_free(piece);
+ }
+
+ if (!repeater)
+ break;
+
+ if (piece && li != g_list_last(selection))
+ g_string_append(gs, repeater);
+ }
+
+ if (gs->len > 0)
+ valuestr = g_string_free(gs, FALSE);
+ else
+ g_string_free(gs, TRUE);
+ }
+
+ if (valuestr) {
+ tmp = g_regex_replace(replacerx, work, -1, 0, valuestr, 0,
+ NULL);
+ g_free(work);
+ work = tmp;
+ g_free(valuestr);
+ }
+
+ g_regex_unref(replacerx);
+ g_free(whole);
+ g_free(repeater);
+ g_free(wholeEscaped);
+ g_free(id);
+ g_match_info_next(match_info, NULL);
+ }
+
+ g_match_info_free(match_info);
}
g_regex_unref(regex);
diff --git a/src/remote-exec.h b/src/remote-exec.h
index 4f8c52e..6014531 100644
--- a/src/remote-exec.h
+++ b/src/remote-exec.h
@@ -20,7 +20,7 @@
#ifndef REMOTE_EXEC_H_
#define REMOTE_EXEC_H_
-gchar *build_remote_exec_cmd(TrgClient *tc, GtkTreeModel *model, GList *selection,
- const gchar * input);
+gchar *build_remote_exec_cmd(TrgClient * tc, GtkTreeModel * model,
+ GList * selection, const gchar * input);
-#endif /* REMOTE_EXEC_H_ */
+#endif /* REMOTE_EXEC_H_ */
diff --git a/src/requests.c b/src/requests.c
index 0e17fb3..babb48c 100644
--- a/src/requests.c
+++ b/src/requests.c
@@ -40,8 +40,8 @@ JsonNode *generic_request(gchar * method, JsonArray * ids)
JsonNode *root = base_request(method);
if (ids)
- json_object_set_array_member(node_get_arguments(root),
- PARAM_IDS, ids);
+ json_object_set_array_member(node_get_arguments(root),
+ PARAM_IDS, ids);
return root;
}
@@ -67,7 +67,7 @@ JsonNode *session_get(void)
}
JsonNode *torrent_set_location(JsonArray * array, gchar * location,
- gboolean move)
+ gboolean move)
{
JsonNode *req = generic_request(METHOD_TORRENT_SET_LOCATION, array);
JsonObject *args = node_get_arguments(req);
@@ -137,7 +137,7 @@ JsonNode *torrent_remove(JsonArray * array, gboolean removeData)
JsonObject *args = node_get_arguments(root);
json_object_set_array_member(args, PARAM_IDS, array);
json_object_set_boolean_member(args, PARAM_DELETE_LOCAL_DATA,
- removeData);
+ removeData);
return root;
}
@@ -148,12 +148,12 @@ JsonNode *torrent_get(gint64 id)
JsonArray *fields = json_array_new();
if (id == TORRENT_GET_TAG_MODE_UPDATE) {
- json_object_set_string_member(args, PARAM_IDS,
- FIELD_RECENTLY_ACTIVE);
+ json_object_set_string_member(args, PARAM_IDS,
+ FIELD_RECENTLY_ACTIVE);
} else if (id >= 0) {
- JsonArray *ids = json_array_new();
- json_array_add_int_element(ids, id);
- json_object_set_array_member(args, PARAM_IDS, ids);
+ JsonArray *ids = json_array_new();
+ json_array_add_int_element(ids, id);
+ json_object_set_array_member(args, PARAM_IDS, ids);
}
json_array_add_string_element(fields, FIELD_ETA);
@@ -164,7 +164,7 @@ JsonNode *torrent_get(gint64 id)
json_array_add_string_element(fields, FIELD_PEERS_GETTING_FROM_US);
json_array_add_string_element(fields, FIELD_PEERS_CONNECTED);
/*json_array_add_string_element(fields, FIELD_HAVEVALID);
- json_array_add_string_element(fields, FIELD_HAVEUNCHECKED);*/
+ json_array_add_string_element(fields, FIELD_HAVEUNCHECKED); */
json_array_add_string_element(fields, FIELD_RATEUPLOAD);
json_array_add_string_element(fields, FIELD_RATEDOWNLOAD);
json_array_add_string_element(fields, FIELD_STATUS);
@@ -223,32 +223,33 @@ JsonNode *torrent_add(gchar * target, gint flags)
gboolean isUri = isMagnet || is_url(target);
gchar *encodedFile;
- if (!isUri && !g_file_test(target, G_FILE_TEST_IS_REGULAR))
- {
- g_message("file \"%s\" does not exist.", target);
- return NULL;
+ if (!isUri && !g_file_test(target, G_FILE_TEST_IS_REGULAR)) {
+ g_message("file \"%s\" does not exist.", target);
+ return NULL;
}
root = base_request(METHOD_TORRENT_ADD);
args = node_get_arguments(root);
if (isUri) {
- json_object_set_string_member(args, PARAM_FILENAME, target);
+ json_object_set_string_member(args, PARAM_FILENAME, target);
} else {
- encodedFile = trg_base64encode(target);
- if (encodedFile) {
- json_object_set_string_member(args, PARAM_METAINFO, encodedFile);
- g_free(encodedFile);
- } else {
- g_error("unable to base64 encode file \"%s\".", target);
- return NULL;
- }
+ encodedFile = trg_base64encode(target);
+ if (encodedFile) {
+ json_object_set_string_member(args, PARAM_METAINFO,
+ encodedFile);
+ g_free(encodedFile);
+ } else {
+ g_error("unable to base64 encode file \"%s\".", target);
+ return NULL;
+ }
}
- json_object_set_boolean_member(args, PARAM_PAUSED, (flags & TORRENT_ADD_FLAG_PAUSED));
+ json_object_set_boolean_member(args, PARAM_PAUSED,
+ (flags & TORRENT_ADD_FLAG_PAUSED));
if ((flags & TORRENT_ADD_FLAG_DELETE))
- g_unlink(target);
+ g_unlink(target);
return root;
}
@@ -272,8 +273,8 @@ void request_set_tag(JsonNode * req, gint64 tag)
void request_set_tag_from_ids(JsonNode * req, JsonArray * ids)
{
gint64 id =
- json_array_get_length(ids) == 1 ? json_array_get_int_element(ids,
- 0) :
- -1;
+ json_array_get_length(ids) == 1 ? json_array_get_int_element(ids,
+ 0) :
+ -1;
request_set_tag(req, id);
}
diff --git a/src/requests.h b/src/requests.h
index 4d08a88..2a59324 100644
--- a/src/requests.h
+++ b/src/requests.h
@@ -37,7 +37,7 @@ JsonNode *torrent_remove(JsonArray * array, int removeData);
JsonNode *torrent_add(gchar * filename, gint flags);
JsonNode *torrent_add_url(const gchar * url, gboolean paused);
JsonNode *torrent_set_location(JsonArray * array, gchar * location,
- gboolean move);
+ gboolean move);
JsonNode *blocklist_update(void);
JsonNode *port_test(void);
JsonNode *session_stats(void);
@@ -50,4 +50,4 @@ JsonNode *torrent_start_now(JsonArray * array);
void request_set_tag(JsonNode * req, gint64 tag);
void request_set_tag_from_ids(JsonNode * req, JsonArray * ids);
-#endif /* REQUESTS_H_ */
+#endif /* REQUESTS_H_ */
diff --git a/src/session-get.c b/src/session-get.c
index 4bb37b2..b9b54bb 100644
--- a/src/session-get.c
+++ b/src/session-get.c
@@ -26,17 +26,17 @@
/* Just some functions to get fields out of a session-get response. */
-const gchar *session_get_version_string(JsonObject *s)
+const gchar *session_get_version_string(JsonObject * s)
{
return json_object_get_string_member(s, SGET_VERSION);
}
-int session_get_version(JsonObject *s, float *version)
+int session_get_version(JsonObject * s, float *version)
{
return sscanf(session_get_version_string(s), "%g", version);
}
-gint64 session_get_download_dir_free_space(JsonObject *s)
+gint64 session_get_download_dir_free_space(JsonObject * s)
{
return json_object_get_int_member(s, SGET_DOWNLOAD_DIR_FREE_SPACE);
}
@@ -64,7 +64,7 @@ const gchar *session_get_download_dir(JsonObject * s)
gboolean session_get_peer_port_random(JsonObject * s)
{
return json_object_get_boolean_member(s,
- SGET_PEER_PORT_RANDOM_ON_START);
+ SGET_PEER_PORT_RANDOM_ON_START);
}
gint64 session_get_peer_port(JsonObject * s)
@@ -80,9 +80,9 @@ 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))
- return json_object_get_string_member(s, SGET_BLOCKLIST_URL);
+ return json_object_get_string_member(s, SGET_BLOCKLIST_URL);
else
- return NULL;
+ return NULL;
}
gint64 session_get_blocklist_size(JsonObject * s)
@@ -143,21 +143,21 @@ gint64 session_get_seed_queue_size(JsonObject * s)
const gchar *session_get_torrent_done_filename(JsonObject * s)
{
return json_object_get_string_member(s,
- SGET_SCRIPT_TORRENT_DONE_FILENAME);
+ SGET_SCRIPT_TORRENT_DONE_FILENAME);
}
gboolean session_get_torrent_done_enabled(JsonObject * s)
{
return json_object_get_boolean_member(s,
- SGET_SCRIPT_TORRENT_DONE_ENABLED);
+ SGET_SCRIPT_TORRENT_DONE_ENABLED);
}
gint64 session_get_cache_size_mb(JsonObject * s)
{
if (json_object_has_member(s, SGET_CACHE_SIZE_MB))
- return json_object_get_int_member(s, SGET_CACHE_SIZE_MB);
+ return json_object_get_int_member(s, SGET_CACHE_SIZE_MB);
else
- return -1;
+ return -1;
}
gdouble session_get_seed_ratio_limit(JsonObject * s)
@@ -173,7 +173,7 @@ gboolean session_get_start_added_torrents(JsonObject * s)
gboolean session_get_trash_original_torrent_files(JsonObject * s)
{
return json_object_get_boolean_member(s,
- SGET_TRASH_ORIGINAL_TORRENT_FILES);
+ SGET_TRASH_ORIGINAL_TORRENT_FILES);
}
gboolean session_get_speed_limit_up_enabled(JsonObject * s)
@@ -199,7 +199,7 @@ gint64 session_get_speed_limit_up(JsonObject * s)
gboolean session_get_speed_limit_down_enabled(JsonObject * s)
{
return json_object_get_boolean_member(s,
- SGET_SPEED_LIMIT_DOWN_ENABLED);
+ SGET_SPEED_LIMIT_DOWN_ENABLED);
}
gint64 session_get_speed_limit_down(JsonObject * s)
@@ -207,7 +207,7 @@ gint64 session_get_speed_limit_down(JsonObject * s)
return json_object_get_int_member(s, SGET_SPEED_LIMIT_DOWN);
}
-gboolean session_get_dht_enabled(JsonObject *s)
+gboolean session_get_dht_enabled(JsonObject * s)
{
return json_object_get_boolean_member(s, SGET_DHT_ENABLED);
}
diff --git a/src/session-get.h b/src/session-get.h
index c43cb59..4822cd7 100644
--- a/src/session-get.h
+++ b/src/session-get.h
@@ -73,8 +73,8 @@
const gchar *session_get_torrent_done_filename(JsonObject * s);
gboolean session_get_torrent_done_enabled(JsonObject * s);
gint64 session_get_cache_size_mb(JsonObject * s);
-const gchar *session_get_version_string(JsonObject *s);
-int session_get_version(JsonObject *s, float *version);
+const gchar *session_get_version_string(JsonObject * s);
+int session_get_version(JsonObject * s, float *version);
gboolean session_get_pex_enabled(JsonObject * s);
gboolean session_get_lpd_enabled(JsonObject * s);
const gchar *session_get_download_dir(JsonObject * s);
@@ -103,7 +103,7 @@ gint64 session_get_download_queue_size(JsonObject * s);
gboolean session_get_seed_queue_enabled(JsonObject * s);
gint64 session_get_seed_queue_size(JsonObject * s);
gint64 session_get_rpc_version(JsonObject * s);
-gint64 session_get_download_dir_free_space(JsonObject *s);
-gboolean session_get_dht_enabled(JsonObject *s);
+gint64 session_get_download_dir_free_space(JsonObject * s);
+gboolean session_get_dht_enabled(JsonObject * s);
-#endif /* SESSION_GET_H_ */
+#endif /* SESSION_GET_H_ */
diff --git a/src/torrent.c b/src/torrent.c
index 10f2dde..bf70f45 100644
--- a/src/torrent.c
+++ b/src/torrent.c
@@ -68,13 +68,14 @@ const gchar *torrent_get_download_dir(JsonObject * t)
return json_object_get_string_member(t, FIELD_DOWNLOAD_DIR);
}
-gdouble torrent_get_metadata_percent_complete(JsonObject *t)
+gdouble torrent_get_metadata_percent_complete(JsonObject * t)
{
- JsonNode *node = json_object_get_member(t, FIELD_METADATAPERCENTCOMPLETE);
+ JsonNode *node =
+ json_object_get_member(t, FIELD_METADATAPERCENTCOMPLETE);
if (node)
- return json_double_to_progress(node);
+ return json_double_to_progress(node);
else
- return 100.0;
+ return 100.0;
}
const gchar *torrent_get_name(JsonObject * t)
@@ -152,7 +153,7 @@ gint64 torrent_get_eta(JsonObject * t)
return json_object_get_int_member(t, FIELD_ETA);
}
-gint64 torrent_get_downloaded(JsonObject *t)
+gint64 torrent_get_downloaded(JsonObject * t)
{
return json_object_get_int_member(t, FIELD_DOWNLOADEDEVER);
}
@@ -189,88 +190,93 @@ gboolean torrent_get_is_private(JsonObject * t)
gdouble torrent_get_percent_done(JsonObject * t)
{
- return json_double_to_progress(json_object_get_member(t, FIELD_PERCENTDONE));
+ return
+ json_double_to_progress(json_object_get_member
+ (t, FIELD_PERCENTDONE));
}
gdouble torrent_get_recheck_progress(JsonObject * t)
{
- return json_double_to_progress(json_object_get_member(t, FIELD_RECHECK_PROGRESS));
+ return
+ json_double_to_progress(json_object_get_member
+ (t, FIELD_RECHECK_PROGRESS));
}
-gint64 torrent_get_activity_date(JsonObject *t)
+gint64 torrent_get_activity_date(JsonObject * t)
{
return json_object_get_int_member(t, FIELD_ACTIVITY_DATE);
}
-guint32 torrent_get_flags(JsonObject * t, gint64 rpcv, gint64 status, gint64 downRate, gint64 upRate)
+guint32 torrent_get_flags(JsonObject * t, gint64 rpcv, gint64 status,
+ gint64 downRate, gint64 upRate)
{
guint32 flags = 0;
if (torrent_get_is_finished(t) == TRUE)
- flags |= TORRENT_FLAG_COMPLETE;
+ flags |= TORRENT_FLAG_COMPLETE;
else
- flags |= TORRENT_FLAG_INCOMPLETE;
+ flags |= TORRENT_FLAG_INCOMPLETE;
if (rpcv >= NEW_STATUS_RPC_VERSION) {
- switch (status) {
- case TR_STATUS_STOPPED:
- flags |= TORRENT_FLAG_PAUSED;
- break;
- case TR_STATUS_CHECK_WAIT:
- flags |= TORRENT_FLAG_WAITING_CHECK;
- flags |= TORRENT_FLAG_CHECKING_ANY;
- break;
- case TR_STATUS_CHECK:
- flags |= TORRENT_FLAG_CHECKING;
- flags |= TORRENT_FLAG_CHECKING_ANY;
- break;
- case TR_STATUS_DOWNLOAD_WAIT:
- flags |= TORRENT_FLAG_DOWNLOADING_WAIT;
- flags |= TORRENT_FLAG_QUEUED;
- break;
- case TR_STATUS_DOWNLOAD:
- if (!(flags & TORRENT_FLAG_COMPLETE))
- flags |= TORRENT_FLAG_DOWNLOADING;
-
- //if (torrent_get_metadata_percent_complete(t) < 100)
- // flags |= TORRENT_FLAG_DOWNLOADING_METADATA;
-
- flags |= TORRENT_FLAG_ACTIVE;
- break;
- case TR_STATUS_SEED_WAIT:
- flags |= TORRENT_FLAG_SEEDING_WAIT;
- break;
- case TR_STATUS_SEED:
- flags |= TORRENT_FLAG_SEEDING;
- if (torrent_get_peers_getting_from_us(t))
- flags |= TORRENT_FLAG_ACTIVE;
- break;
- }
+ switch (status) {
+ case TR_STATUS_STOPPED:
+ flags |= TORRENT_FLAG_PAUSED;
+ break;
+ case TR_STATUS_CHECK_WAIT:
+ flags |= TORRENT_FLAG_WAITING_CHECK;
+ flags |= TORRENT_FLAG_CHECKING_ANY;
+ break;
+ case TR_STATUS_CHECK:
+ flags |= TORRENT_FLAG_CHECKING;
+ flags |= TORRENT_FLAG_CHECKING_ANY;
+ break;
+ case TR_STATUS_DOWNLOAD_WAIT:
+ flags |= TORRENT_FLAG_DOWNLOADING_WAIT;
+ flags |= TORRENT_FLAG_QUEUED;
+ break;
+ case TR_STATUS_DOWNLOAD:
+ if (!(flags & TORRENT_FLAG_COMPLETE))
+ flags |= TORRENT_FLAG_DOWNLOADING;
+
+ //if (torrent_get_metadata_percent_complete(t) < 100)
+ // flags |= TORRENT_FLAG_DOWNLOADING_METADATA;
+
+ flags |= TORRENT_FLAG_ACTIVE;
+ break;
+ case TR_STATUS_SEED_WAIT:
+ flags |= TORRENT_FLAG_SEEDING_WAIT;
+ break;
+ case TR_STATUS_SEED:
+ flags |= TORRENT_FLAG_SEEDING;
+ if (torrent_get_peers_getting_from_us(t))
+ flags |= TORRENT_FLAG_ACTIVE;
+ break;
+ }
} else {
- switch (status) {
- case OLD_STATUS_DOWNLOADING:
- flags |= TORRENT_FLAG_DOWNLOADING;
- break;
- case OLD_STATUS_PAUSED:
- flags |= TORRENT_FLAG_PAUSED;
- break;
- case OLD_STATUS_SEEDING:
- flags |= TORRENT_FLAG_SEEDING;
- break;
- case OLD_STATUS_CHECKING:
- flags |= TORRENT_FLAG_CHECKING;
- break;
- case OLD_STATUS_WAITING_TO_CHECK:
- flags |= TORRENT_FLAG_WAITING_CHECK;
- flags |= TORRENT_FLAG_CHECKING;
- break;
- }
- if (downRate > 0 || upRate > 0)
- flags |= TORRENT_FLAG_ACTIVE;
+ switch (status) {
+ case OLD_STATUS_DOWNLOADING:
+ flags |= TORRENT_FLAG_DOWNLOADING;
+ break;
+ case OLD_STATUS_PAUSED:
+ flags |= TORRENT_FLAG_PAUSED;
+ break;
+ case OLD_STATUS_SEEDING:
+ flags |= TORRENT_FLAG_SEEDING;
+ break;
+ case OLD_STATUS_CHECKING:
+ flags |= TORRENT_FLAG_CHECKING;
+ break;
+ case OLD_STATUS_WAITING_TO_CHECK:
+ flags |= TORRENT_FLAG_WAITING_CHECK;
+ flags |= TORRENT_FLAG_CHECKING;
+ break;
+ }
+ if (downRate > 0 || upRate > 0)
+ flags |= TORRENT_FLAG_ACTIVE;
}
if (strlen(torrent_get_errorstr(t)) > 0)
- flags |= TORRENT_FLAG_ERROR;
+ flags |= TORRENT_FLAG_ERROR;
return flags;
}
@@ -278,19 +284,19 @@ guint32 torrent_get_flags(JsonObject * t, gint64 rpcv, gint64 status, gint64 dow
gchar *torrent_get_status_icon(gint64 rpcv, guint flags)
{
if (flags & TORRENT_FLAG_ERROR)
- return g_strdup(GTK_STOCK_DIALOG_WARNING);
+ return g_strdup(GTK_STOCK_DIALOG_WARNING);
//else if (flags & TORRENT_FLAG_DOWNLOADING_METADATA)
// return g_strdup(GTK_STOCK_FIND);
else if (flags & TORRENT_FLAG_DOWNLOADING)
- return g_strdup(GTK_STOCK_GO_DOWN);
+ return g_strdup(GTK_STOCK_GO_DOWN);
else if (flags & TORRENT_FLAG_PAUSED)
- return g_strdup(GTK_STOCK_MEDIA_PAUSE);
+ return g_strdup(GTK_STOCK_MEDIA_PAUSE);
else if (flags & TORRENT_FLAG_SEEDING)
- return g_strdup(GTK_STOCK_GO_UP);
+ return g_strdup(GTK_STOCK_GO_UP);
else if (flags & TORRENT_FLAG_CHECKING)
- return g_strdup(GTK_STOCK_REFRESH);
+ return g_strdup(GTK_STOCK_REFRESH);
else
- return g_strdup(GTK_STOCK_DIALOG_QUESTION);
+ return g_strdup(GTK_STOCK_DIALOG_QUESTION);
}
gint64 torrent_get_done_date(JsonObject * t)
@@ -305,45 +311,42 @@ const gchar *torrent_get_errorstr(JsonObject * t)
gchar *torrent_get_status_string(gint64 rpcv, gint64 value, guint flags)
{
- if (rpcv >= NEW_STATUS_RPC_VERSION)
- {
- switch (value) {
- case TR_STATUS_DOWNLOAD:
- /*if (flags & TORRENT_FLAG_DOWNLOADING_METADATA)
- return g_strdup(_("Metadata Downloading"));
- else*/
- return g_strdup(_("Downloading"));
- case TR_STATUS_DOWNLOAD_WAIT:
- return g_strdup(_("Queued download"));
- case TR_STATUS_CHECK_WAIT:
- return g_strdup(_("Waiting To Check"));
- case TR_STATUS_CHECK:
- return g_strdup(_("Checking"));
- case TR_STATUS_SEED_WAIT:
- return g_strdup(_("Queued seed"));
- case TR_STATUS_SEED:
- return g_strdup(_("Seeding"));
- case TR_STATUS_STOPPED:
- return g_strdup(_("Paused"));
- }
- }
- else
- {
- switch (value) {
- case OLD_STATUS_DOWNLOADING:
- /*if (flags & TORRENT_FLAG_DOWNLOADING_METADATA)
- return g_strdup(_("Metadata Downloading"));
- else*/
- return g_strdup(_("Downloading"));
- case OLD_STATUS_PAUSED:
- return g_strdup(_("Paused"));
- case OLD_STATUS_SEEDING:
- return g_strdup(_("Seeding"));
- case OLD_STATUS_CHECKING:
- return g_strdup(_("Checking"));
- case OLD_STATUS_WAITING_TO_CHECK:
- return g_strdup(_("Waiting To Check"));
- }
+ if (rpcv >= NEW_STATUS_RPC_VERSION) {
+ switch (value) {
+ case TR_STATUS_DOWNLOAD:
+ /*if (flags & TORRENT_FLAG_DOWNLOADING_METADATA)
+ return g_strdup(_("Metadata Downloading"));
+ else */
+ return g_strdup(_("Downloading"));
+ case TR_STATUS_DOWNLOAD_WAIT:
+ return g_strdup(_("Queued download"));
+ case TR_STATUS_CHECK_WAIT:
+ return g_strdup(_("Waiting To Check"));
+ case TR_STATUS_CHECK:
+ return g_strdup(_("Checking"));
+ case TR_STATUS_SEED_WAIT:
+ return g_strdup(_("Queued seed"));
+ case TR_STATUS_SEED:
+ return g_strdup(_("Seeding"));
+ case TR_STATUS_STOPPED:
+ return g_strdup(_("Paused"));
+ }
+ } else {
+ switch (value) {
+ case OLD_STATUS_DOWNLOADING:
+ /*if (flags & TORRENT_FLAG_DOWNLOADING_METADATA)
+ return g_strdup(_("Metadata Downloading"));
+ else */
+ return g_strdup(_("Downloading"));
+ case OLD_STATUS_PAUSED:
+ return g_strdup(_("Paused"));
+ case OLD_STATUS_SEEDING:
+ return g_strdup(_("Seeding"));
+ case OLD_STATUS_CHECKING:
+ return g_strdup(_("Checking"));
+ case OLD_STATUS_WAITING_TO_CHECK:
+ return g_strdup(_("Waiting To Check"));
+ }
}
//g_warning("Unknown status: %ld", value);
@@ -359,16 +362,16 @@ gboolean torrent_has_tracker(JsonObject * t, GRegex * rx, gchar * search)
trackers = json_array_get_elements(torrent_get_tracker_stats(t));
for (li = trackers; li; li = g_list_next(li)) {
- JsonObject *tracker = json_node_get_object((JsonNode *) li->data);
- const gchar *trackerAnnounce = tracker_stats_get_announce(tracker);
- gchar *trackerAnnounceHost =
- trg_gregex_get_first(rx, trackerAnnounce);
- int cmpResult = g_strcmp0(trackerAnnounceHost, search);
- g_free(trackerAnnounceHost);
- if (!cmpResult) {
- ret = TRUE;
- break;
- }
+ JsonObject *tracker = json_node_get_object((JsonNode *) li->data);
+ const gchar *trackerAnnounce = tracker_stats_get_announce(tracker);
+ gchar *trackerAnnounceHost =
+ trg_gregex_get_first(rx, trackerAnnounce);
+ int cmpResult = g_strcmp0(trackerAnnounceHost, search);
+ g_free(trackerAnnounceHost);
+ if (!cmpResult) {
+ ret = TRUE;
+ break;
+ }
}
g_list_free(trackers);
@@ -394,9 +397,9 @@ const gchar *tracker_stats_get_scrape(JsonObject * t)
JsonArray *get_torrents_removed(JsonObject * response)
{
if (G_UNLIKELY(json_object_has_member(response, FIELD_REMOVED)))
- return json_object_get_array_member(response, FIELD_REMOVED);
+ return json_object_get_array_member(response, FIELD_REMOVED);
else
- return NULL;
+ return NULL;
}
JsonArray *get_torrents(JsonObject * response)
@@ -411,27 +414,27 @@ JsonArray *torrent_get_files(JsonObject * args)
return json_object_get_array_member(args, FIELD_FILES);
}
-gint64 torrent_get_peers_connected(JsonObject *args)
+gint64 torrent_get_peers_connected(JsonObject * args)
{
return json_object_get_int_member(args, FIELD_PEERS_CONNECTED);
}
-gint64 torrent_get_peers_sending_to_us(JsonObject *args)
+gint64 torrent_get_peers_sending_to_us(JsonObject * args)
{
return json_object_get_int_member(args, FIELD_PEERS_SENDING_TO_US);
}
-gint64 torrent_get_peers_getting_from_us(JsonObject *args)
+gint64 torrent_get_peers_getting_from_us(JsonObject * args)
{
return json_object_get_int_member(args, FIELD_PEERS_GETTING_FROM_US);
}
-gint64 torrent_get_queue_position(JsonObject *args)
+gint64 torrent_get_queue_position(JsonObject * args)
{
if (json_object_has_member(args, FIELD_QUEUE_POSITION))
- return json_object_get_int_member(args, FIELD_QUEUE_POSITION);
+ return json_object_get_int_member(args, FIELD_QUEUE_POSITION);
else
- return -1;
+ return -1;
}
/* tracker stats */
@@ -446,54 +449,56 @@ gint64 tracker_stats_get_tier(JsonObject * t)
return json_object_get_int_member(t, FIELD_TIER);
}
-gint64 tracker_stats_get_last_announce_peer_count(JsonObject *t)
+gint64 tracker_stats_get_last_announce_peer_count(JsonObject * t)
{
return json_object_get_int_member(t, FIELD_LAST_ANNOUNCE_PEER_COUNT);
}
-gint64 tracker_stats_get_last_announce_time(JsonObject *t)
+gint64 tracker_stats_get_last_announce_time(JsonObject * t)
{
return json_object_get_int_member(t, FIELD_LAST_ANNOUNCE_TIME);
}
-gint64 tracker_stats_get_last_scrape_time(JsonObject *t)
+gint64 tracker_stats_get_last_scrape_time(JsonObject * t)
{
return json_object_get_int_member(t, FIELD_LAST_SCRAPE_TIME);
}
-gint64 tracker_stats_get_seeder_count(JsonObject *t)
+gint64 tracker_stats_get_seeder_count(JsonObject * t)
{
return json_object_get_int_member(t, FIELD_SEEDERCOUNT);
}
-gint64 tracker_stats_get_leecher_count(JsonObject *t)
+gint64 tracker_stats_get_leecher_count(JsonObject * t)
{
return json_object_get_int_member(t, FIELD_LEECHERCOUNT);
}
-gint64 tracker_stats_get_download_count(JsonObject *t)
+gint64 tracker_stats_get_download_count(JsonObject * t)
{
return json_object_get_int_member(t, FIELD_DOWNLOADCOUNT);
}
-const gchar *tracker_stats_get_announce_result(JsonObject *t)
+const gchar *tracker_stats_get_announce_result(JsonObject * t)
{
return json_object_get_string_member(t, FIELD_LAST_ANNOUNCE_RESULT);
}
-const gchar *tracker_stats_get_host(JsonObject *t)
+const gchar *tracker_stats_get_host(JsonObject * t)
{
return json_object_get_string_member(t, FIELD_HOST);
}
-gchar *torrent_get_full_path(JsonObject *obj)
+gchar *torrent_get_full_path(JsonObject * obj)
{
- const gchar *location = json_object_get_string_member(obj, FIELD_DOWNLOAD_DIR);
+ const gchar *location =
+ json_object_get_string_member(obj, FIELD_DOWNLOAD_DIR);
const gchar *name = json_object_get_string_member(obj, FIELD_NAME);
return g_strdup_printf("%s/%s", location, name);
}
-gchar *torrent_get_full_dir(JsonObject * obj) {
+gchar *torrent_get_full_dir(JsonObject * obj)
+{
gchar *containing_path, *name, *delim;
const gchar *location;
JsonArray *files = torrent_get_files(obj);
@@ -503,11 +508,11 @@ gchar *torrent_get_full_dir(JsonObject * obj) {
firstFile = json_array_get_object_element(files, 0);
name = g_strdup(json_object_get_string_member(firstFile, TFILE_NAME));
- if ( (delim = g_strstr_len(name,-1,"/")) ) {
- *delim = '\0';
- containing_path = g_strdup_printf("%s/%s",location,name);
+ if ((delim = g_strstr_len(name, -1, "/"))) {
+ *delim = '\0';
+ containing_path = g_strdup_printf("%s/%s", location, name);
} else {
- containing_path = g_strdup(location);
+ containing_path = g_strdup(location);
}
g_free(name);
@@ -516,77 +521,87 @@ gchar *torrent_get_full_dir(JsonObject * obj) {
/* peers */
-const gchar *peer_get_address(JsonObject * p) {
+const gchar *peer_get_address(JsonObject * p)
+{
return json_object_get_string_member(p, TPEER_ADDRESS);
}
-const gchar *peer_get_flagstr(JsonObject * p) {
+const gchar *peer_get_flagstr(JsonObject * p)
+{
return json_object_get_string_member(p, TPEER_FLAGSTR);
}
-const gchar *peer_get_client_name(JsonObject * p) {
+const gchar *peer_get_client_name(JsonObject * p)
+{
return json_object_get_string_member(p, TPEER_CLIENT_NAME);
}
-gboolean peer_get_is_encrypted(JsonObject * p) {
+gboolean peer_get_is_encrypted(JsonObject * p)
+{
return json_object_get_boolean_member(p, TPEER_IS_ENCRYPTED);
}
-gboolean peer_get_is_uploading_to(JsonObject * p) {
+gboolean peer_get_is_uploading_to(JsonObject * p)
+{
return json_object_get_boolean_member(p, TPEER_IS_UPLOADING_TO);
}
-gboolean peer_get_is_downloading_from(JsonObject * p) {
+gboolean peer_get_is_downloading_from(JsonObject * p)
+{
return json_object_get_boolean_member(p, TPEER_IS_DOWNLOADING_FROM);
}
-gdouble peer_get_progress(JsonObject * p) {
- return json_double_to_progress(json_object_get_member(p, TPEER_PROGRESS));
+gdouble peer_get_progress(JsonObject * p)
+{
+ return
+ json_double_to_progress(json_object_get_member(p, TPEER_PROGRESS));
}
-gint64 peer_get_rate_to_client(JsonObject * p) {
+gint64 peer_get_rate_to_client(JsonObject * p)
+{
return json_object_get_int_member(p, TPEER_RATE_TO_CLIENT);
}
-gint64 peer_get_rate_to_peer(JsonObject * p) {
+gint64 peer_get_rate_to_peer(JsonObject * p)
+{
return json_object_get_int_member(p, TPEER_RATE_TO_PEER);
}
-gint64 peerfrom_get_pex(JsonObject *pf)
+gint64 peerfrom_get_pex(JsonObject * pf)
{
return json_object_get_int_member(pf, TPEERFROM_FROMPEX);
}
-gint64 peerfrom_get_dht(JsonObject *pf)
+gint64 peerfrom_get_dht(JsonObject * pf)
{
return json_object_get_int_member(pf, TPEERFROM_FROMDHT);
}
-gint64 peerfrom_get_trackers(JsonObject *pf)
+gint64 peerfrom_get_trackers(JsonObject * pf)
{
return json_object_get_int_member(pf, TPEERFROM_FROMTRACKERS);
}
-gint64 peerfrom_get_ltep(JsonObject *pf)
+gint64 peerfrom_get_ltep(JsonObject * pf)
{
return json_object_get_int_member(pf, TPEERFROM_FROMLTEP);
}
-gint64 peerfrom_get_resume(JsonObject *pf)
+gint64 peerfrom_get_resume(JsonObject * pf)
{
return json_object_get_int_member(pf, TPEERFROM_FROMRESUME);
}
-gint64 peerfrom_get_incoming(JsonObject *pf)
+gint64 peerfrom_get_incoming(JsonObject * pf)
{
return json_object_get_int_member(pf, TPEERFROM_FROMINCOMING);
}
-gint64 peerfrom_get_lpd(JsonObject *pf)
+gint64 peerfrom_get_lpd(JsonObject * pf)
{
return json_object_has_member(pf, TPEERFROM_FROMLPD) ?
- json_object_get_int_member(pf, TPEERFROM_FROMLPD) : -1;
+ json_object_get_int_member(pf, TPEERFROM_FROMLPD) : -1;
}
/* files */
@@ -595,10 +610,10 @@ gdouble file_get_progress(JsonObject * f)
{
gint64 length = file_get_length(f);
if (length > 0) {
- return ((gdouble) file_get_bytes_completed(f) /
- (gdouble) length) * 100.0;
+ return ((gdouble) file_get_bytes_completed(f) /
+ (gdouble) length) * 100.0;
} else {
- return 0.0;
+ return 0.0;
}
}
diff --git a/src/torrent.h b/src/torrent.h
index 8543f89..93bb920 100644
--- a/src/torrent.h
+++ b/src/torrent.h
@@ -41,8 +41,8 @@
#define FILTER_FLAG_TRACKER (1 << 14)
#define FILTER_FLAG_DIR (1 << 15)
-#define TORRENT_ADD_FLAG_PAUSED (1 << 0) /* 0x01 */
-#define TORRENT_ADD_FLAG_DELETE (1 << 1) /* 0x02 */
+#define TORRENT_ADD_FLAG_PAUSED (1 << 0) /* 0x01 */
+#define TORRENT_ADD_FLAG_DELETE (1 << 1) /* 0x02 */
gint64 torrent_get_size(JsonObject * t);
const gchar *torrent_get_name(JsonObject * t);
@@ -58,7 +58,8 @@ gint64 torrent_get_have_valid(JsonObject * t);
gint64 torrent_get_status(JsonObject * t);
gchar *torrent_get_status_string(gint64 rpcv, gint64 value, guint flags);
gchar *torrent_get_status_icon(gint64 rpcv, guint flags);
-guint32 torrent_get_flags(JsonObject * t, gint64 rpcv, gint64 status, gint64 downRate, gint64 upRate);
+guint32 torrent_get_flags(JsonObject * t, gint64 rpcv, gint64 status,
+ gint64 downRate, gint64 upRate);
JsonArray *torrent_get_peers(JsonObject * t);
JsonObject *torrent_get_peersfrom(JsonObject * t);
JsonArray *torrent_get_tracker_stats(JsonObject * t);
@@ -66,9 +67,9 @@ JsonArray *torrent_get_wanted(JsonObject * t);
JsonArray *torrent_get_priorities(JsonObject * t);
gint64 torrent_get_id(JsonObject * t);
JsonArray *torrent_get_files(JsonObject * args);
-gint64 torrent_get_peers_getting_from_us(JsonObject *args);
-gint64 torrent_get_peers_sending_to_us(JsonObject *args);
-gint64 torrent_get_peers_connected(JsonObject *args);
+gint64 torrent_get_peers_getting_from_us(JsonObject * args);
+gint64 torrent_get_peers_sending_to_us(JsonObject * args);
+gint64 torrent_get_peers_connected(JsonObject * args);
gdouble torrent_get_percent_done(JsonObject * t);
gdouble torrent_get_recheck_progress(JsonObject * t);
gint64 torrent_get_left_until_done(JsonObject * t);
@@ -86,11 +87,11 @@ gdouble torrent_get_seed_ratio_limit(JsonObject * t);
gint64 torrent_get_seed_ratio_mode(JsonObject * t);
gint64 torrent_get_peer_limit(JsonObject * t);
gboolean torrent_has_tracker(JsonObject * t, GRegex * rx, gchar * search);
-gint64 torrent_get_queue_position(JsonObject *args);
-gint64 torrent_get_activity_date(JsonObject *t);
+gint64 torrent_get_queue_position(JsonObject * args);
+gint64 torrent_get_activity_date(JsonObject * t);
gchar *torrent_get_full_dir(JsonObject * obj);
-gchar *torrent_get_full_path(JsonObject *obj);
-gdouble torrent_get_metadata_percent_complete(JsonObject *t);
+gchar *torrent_get_full_path(JsonObject * obj);
+gdouble torrent_get_metadata_percent_complete(JsonObject * t);
/* outer response object */
@@ -103,14 +104,14 @@ const gchar *tracker_stats_get_announce(JsonObject * t);
const gchar *tracker_stats_get_scrape(JsonObject * t);
gint64 tracker_stats_get_tier(JsonObject * t);
gint64 tracker_stats_get_id(JsonObject * t);
-gint64 tracker_stats_get_last_announce_peer_count(JsonObject *t);
-gint64 tracker_stats_get_last_announce_time(JsonObject *t);
-gint64 tracker_stats_get_seeder_count(JsonObject *t);
-gint64 tracker_stats_get_leecher_count(JsonObject *t);
-gint64 tracker_stats_get_download_count(JsonObject *t);
-const gchar *tracker_stats_get_announce_result(JsonObject *t);
-const gchar *tracker_stats_get_host(JsonObject *t);
-gint64 tracker_stats_get_last_scrape_time(JsonObject *t);
+gint64 tracker_stats_get_last_announce_peer_count(JsonObject * t);
+gint64 tracker_stats_get_last_announce_time(JsonObject * t);
+gint64 tracker_stats_get_seeder_count(JsonObject * t);
+gint64 tracker_stats_get_leecher_count(JsonObject * t);
+gint64 tracker_stats_get_download_count(JsonObject * t);
+const gchar *tracker_stats_get_announce_result(JsonObject * t);
+const gchar *tracker_stats_get_host(JsonObject * t);
+gint64 tracker_stats_get_last_scrape_time(JsonObject * t);
/* files */
@@ -131,11 +132,11 @@ gint64 peer_get_rate_to_peer(JsonObject * p);
gboolean peer_get_is_uploading_to(JsonObject * p);
gboolean peer_get_is_downloading_from(JsonObject * p);
-gint64 peerfrom_get_pex(JsonObject *pf);
-gint64 peerfrom_get_dht(JsonObject *pf);
-gint64 peerfrom_get_trackers(JsonObject *pf);
-gint64 peerfrom_get_ltep(JsonObject *pf);
-gint64 peerfrom_get_resume(JsonObject *pf);
-gint64 peerfrom_get_incoming(JsonObject *pf);
-gint64 peerfrom_get_lpd(JsonObject *pf);
-#endif /* TORRENT_H_ */
+gint64 peerfrom_get_pex(JsonObject * pf);
+gint64 peerfrom_get_dht(JsonObject * pf);
+gint64 peerfrom_get_trackers(JsonObject * pf);
+gint64 peerfrom_get_ltep(JsonObject * pf);
+gint64 peerfrom_get_resume(JsonObject * pf);
+gint64 peerfrom_get_incoming(JsonObject * pf);
+gint64 peerfrom_get_lpd(JsonObject * pf);
+#endif /* TORRENT_H_ */
diff --git a/src/trg-about-window.c b/src/trg-about-window.c
index 8cb645e..e5dc383 100644
--- a/src/trg-about-window.c
+++ b/src/trg-about-window.c
@@ -37,7 +37,8 @@ GtkWidget *trg_about_window_new(GtkWindow * parent)
gchar *licenseFile;
#ifdef WIN32
- gchar *moddir = g_win32_get_package_installation_directory_of_module(NULL);
+ gchar *moddir =
+ g_win32_get_package_installation_directory_of_module(NULL);
licenseFile = g_build_filename(moddir, "COPYING.TXT", NULL);
g_free(moddir);
#else
@@ -49,45 +50,46 @@ GtkWidget *trg_about_window_new(GtkWindow * parent)
gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
logo =
- gtk_icon_theme_load_icon(gtk_icon_theme_get_default(),
- PACKAGE_NAME, 48,
- GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
+ gtk_icon_theme_load_icon(gtk_icon_theme_get_default(),
+ PACKAGE_NAME, 48,
+ GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
if (logo != NULL) {
- gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(dialog), logo);
- g_object_unref(logo);
+ gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(dialog), logo);
+ g_object_unref(logo);
}
if (g_file_get_contents(licenseFile, &licenseText, NULL, NULL)) {
- gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(dialog),
- licenseText);
+ 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_license(GTK_ABOUT_DIALOG(dialog), "GPL2");
}
- gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(dialog), PACKAGE_NAME);
+ gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(dialog),
+ PACKAGE_NAME);
gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog),
- PACKAGE_VERSION);
+ PACKAGE_VERSION);
gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(dialog),
- "(C) 2011 Alan Fitton");
+ "(C) 2011 Alan Fitton");
gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(dialog),
- _
- ("A remote client to transmission-daemon."));
+ _
+ ("A remote client to transmission-daemon."));
gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(dialog),
- "http://code.google.com/p/transmission-remote-gtk/");
+ "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/");
+ "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),
- "translations kindly contributed by\n\n"
- "* Julian Held (German)\n"
- "* Youn sok Choi (Korean)\n"
- "* Piotr (Polish)\n"
- "* Y3AVD (Russian)\n"
- "* ROR191 (Ukranian)\n"
+ "translations kindly contributed by\n\n"
+ "* Julian Held (German)\n"
+ "* Youn sok Choi (Korean)\n"
+ "* Piotr (Polish)\n"
+ "* Y3AVD (Russian)\n"
+ "* ROR191 (Ukranian)\n"
"* aspidzent (Spanish)");
g_free(licenseFile);
diff --git a/src/trg-about-window.h b/src/trg-about-window.h
index 8fbd132..621ccfc 100644
--- a/src/trg-about-window.h
+++ b/src/trg-about-window.h
@@ -24,4 +24,4 @@
GtkWidget *trg_about_window_new(GtkWindow * parent);
-#endif /* ABOUT_WINDOW_H_ */
+#endif /* ABOUT_WINDOW_H_ */
diff --git a/src/trg-cell-renderer-epoch.c b/src/trg-cell-renderer-epoch.c
index 5b05f09..c440c3a 100644
--- a/src/trg-cell-renderer-epoch.c
+++ b/src/trg-cell-renderer-epoch.c
@@ -30,7 +30,7 @@ enum {
};
G_DEFINE_TYPE(TrgCellRendererEpoch, trg_cell_renderer_epoch,
- GTK_TYPE_CELL_RENDERER_TEXT)
+ GTK_TYPE_CELL_RENDERER_TEXT)
#define TRG_CELL_RENDERER_EPOCH_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_CELL_RENDERER_EPOCH, TrgCellRendererEpochPrivate))
typedef struct _TrgCellRendererEpochPrivate TrgCellRendererEpochPrivate;
@@ -41,52 +41,52 @@ struct _TrgCellRendererEpochPrivate {
static void
trg_cell_renderer_epoch_get_property(GObject * object, guint property_id,
- GValue * value, GParamSpec * pspec)
+ GValue * value, GParamSpec * pspec)
{
TrgCellRendererEpochPrivate *priv =
- TRG_CELL_RENDERER_EPOCH_GET_PRIVATE(object);
+ TRG_CELL_RENDERER_EPOCH_GET_PRIVATE(object);
switch (property_id) {
case PROP_EPOCH_VALUE:
- g_value_set_int64(value, priv->epoch_value);
- break;
+ g_value_set_int64(value, priv->epoch_value);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
static void
trg_cell_renderer_epoch_set_property(GObject * object, guint property_id,
- const GValue * value,
- GParamSpec * pspec)
+ const GValue * value,
+ GParamSpec * pspec)
{
TrgCellRendererEpochPrivate *priv =
- TRG_CELL_RENDERER_EPOCH_GET_PRIVATE(object);
+ TRG_CELL_RENDERER_EPOCH_GET_PRIVATE(object);
if (property_id == PROP_EPOCH_VALUE) {
- gint64 new_value = g_value_get_int64(value);
- if (priv->epoch_value != new_value) {
- if (new_value > 0) {
+ gint64 new_value = g_value_get_int64(value);
+ if (priv->epoch_value != new_value) {
+ if (new_value > 0) {
#if GLIB_CHECK_VERSION(2, 26, 00)
- GDateTime *dt = g_date_time_new_from_unix_local(new_value);
- gchar *timestring = g_date_time_format(dt, "%F %H:%M:%S");
- g_object_set(object, "text", timestring, NULL);
- g_free(timestring);
- g_date_time_unref(dt);
+ GDateTime *dt = g_date_time_new_from_unix_local(new_value);
+ gchar *timestring = g_date_time_format(dt, "%F %H:%M:%S");
+ g_object_set(object, "text", timestring, NULL);
+ g_free(timestring);
+ g_date_time_unref(dt);
#else
- time_t time_val = new_value;
- char buf[64];
- struct tm *ts = localtime(&time_val);
- strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", ts);
- g_object_set(object, "text", buf, NULL);
+ time_t time_val = new_value;
+ char buf[64];
+ struct tm *ts = localtime(&time_val);
+ strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", ts);
+ g_object_set(object, "text", buf, NULL);
#endif
- } else {
- g_object_set(object, "text", "", NULL);
- }
- priv->epoch_value = new_value;
- }
+ } else {
+ g_object_set(object, "text", "", NULL);
+ }
+ priv->epoch_value = new_value;
+ }
} else {
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
}
}
@@ -99,20 +99,20 @@ trg_cell_renderer_epoch_class_init(TrgCellRendererEpochClass * klass)
object_class->set_property = trg_cell_renderer_epoch_set_property;
g_object_class_install_property(object_class,
- PROP_EPOCH_VALUE,
- g_param_spec_int64("epoch-value",
- "Epoch Value",
- "Epoch Value",
- INT64_MIN,
- INT64_MAX,
- 0,
- G_PARAM_READWRITE
- |
- G_PARAM_STATIC_NAME
- |
- G_PARAM_STATIC_NICK
- |
- G_PARAM_STATIC_BLURB));
+ PROP_EPOCH_VALUE,
+ g_param_spec_int64("epoch-value",
+ "Epoch Value",
+ "Epoch Value",
+ INT64_MIN,
+ INT64_MAX,
+ 0,
+ G_PARAM_READWRITE
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
g_type_class_add_private(klass, sizeof(TrgCellRendererEpochPrivate));
}
@@ -125,6 +125,6 @@ trg_cell_renderer_epoch_init(TrgCellRendererEpoch * self G_GNUC_UNUSED)
GtkCellRenderer *trg_cell_renderer_epoch_new(void)
{
return
- GTK_CELL_RENDERER(g_object_new
- (TRG_TYPE_CELL_RENDERER_EPOCH, NULL));
+ GTK_CELL_RENDERER(g_object_new
+ (TRG_TYPE_CELL_RENDERER_EPOCH, NULL));
}
diff --git a/src/trg-cell-renderer-epoch.h b/src/trg-cell-renderer-epoch.h
index af235bf..742c1e4 100644
--- a/src/trg-cell-renderer-epoch.h
+++ b/src/trg-cell-renderer-epoch.h
@@ -48,4 +48,4 @@ GType trg_cell_renderer_epoch_get_type(void);
GtkCellRenderer *trg_cell_renderer_epoch_new(void);
G_END_DECLS
-#endif /* TRG_CELL_RENDERER_EPOCH_H_ */
+#endif /* TRG_CELL_RENDERER_EPOCH_H_ */
diff --git a/src/trg-cell-renderer-eta.c b/src/trg-cell-renderer-eta.c
index 604ac8f..fafedb1 100644
--- a/src/trg-cell-renderer-eta.c
+++ b/src/trg-cell-renderer-eta.c
@@ -29,7 +29,7 @@ enum {
};
G_DEFINE_TYPE(TrgCellRendererEta, trg_cell_renderer_eta,
- GTK_TYPE_CELL_RENDERER_TEXT)
+ GTK_TYPE_CELL_RENDERER_TEXT)
#define TRG_CELL_RENDERER_ETA_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_CELL_RENDERER_ETA, TrgCellRendererEtaPrivate))
typedef struct _TrgCellRendererEtaPrivate TrgCellRendererEtaPrivate;
@@ -40,42 +40,42 @@ struct _TrgCellRendererEtaPrivate {
static void
trg_cell_renderer_eta_get_property(GObject * object, guint property_id,
- GValue * value, GParamSpec * pspec)
+ GValue * value, GParamSpec * pspec)
{
TrgCellRendererEtaPrivate *priv =
- TRG_CELL_RENDERER_ETA_GET_PRIVATE(object);
+ TRG_CELL_RENDERER_ETA_GET_PRIVATE(object);
switch (property_id) {
case PROP_ETA_VALUE:
- g_value_set_int64(value, priv->eta_value);
- break;
+ g_value_set_int64(value, priv->eta_value);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
static void
trg_cell_renderer_eta_set_property(GObject * object, guint property_id,
- const GValue * value,
- GParamSpec * pspec)
+ const GValue * value,
+ GParamSpec * pspec)
{
TrgCellRendererEtaPrivate *priv =
- TRG_CELL_RENDERER_ETA_GET_PRIVATE(object);
+ TRG_CELL_RENDERER_ETA_GET_PRIVATE(object);
if (property_id == PROP_ETA_VALUE) {
- priv->eta_value = g_value_get_int64(value);
- if (priv->eta_value > 0) {
- char etaString[32];
- tr_strltime_short(etaString, priv->eta_value,
- sizeof(etaString));
- g_object_set(object, "text", etaString, NULL);
- } else if (priv->eta_value == -2) {
- g_object_set(object, "text", "∞", NULL);
- } else {
- g_object_set(object, "text", "", NULL);
- }
+ priv->eta_value = g_value_get_int64(value);
+ if (priv->eta_value > 0) {
+ char etaString[32];
+ tr_strltime_short(etaString, priv->eta_value,
+ sizeof(etaString));
+ g_object_set(object, "text", etaString, NULL);
+ } else if (priv->eta_value == -2) {
+ g_object_set(object, "text", "∞", NULL);
+ } else {
+ g_object_set(object, "text", "", NULL);
+ }
} else {
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
}
}
@@ -88,20 +88,20 @@ trg_cell_renderer_eta_class_init(TrgCellRendererEtaClass * klass)
object_class->set_property = trg_cell_renderer_eta_set_property;
g_object_class_install_property(object_class,
- PROP_ETA_VALUE,
- g_param_spec_int64("eta-value",
- "Eta Value",
- "Eta Value",
- INT64_MIN,
- INT64_MAX,
- 0,
- G_PARAM_READWRITE
- |
- G_PARAM_STATIC_NAME
- |
- G_PARAM_STATIC_NICK
- |
- G_PARAM_STATIC_BLURB));
+ PROP_ETA_VALUE,
+ g_param_spec_int64("eta-value",
+ "Eta Value",
+ "Eta Value",
+ INT64_MIN,
+ INT64_MAX,
+ 0,
+ G_PARAM_READWRITE
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
g_type_class_add_private(klass, sizeof(TrgCellRendererEtaPrivate));
}
@@ -114,5 +114,5 @@ trg_cell_renderer_eta_init(TrgCellRendererEta * self G_GNUC_UNUSED)
GtkCellRenderer *trg_cell_renderer_eta_new(void)
{
return
- GTK_CELL_RENDERER(g_object_new(TRG_TYPE_CELL_RENDERER_ETA, NULL));
+ GTK_CELL_RENDERER(g_object_new(TRG_TYPE_CELL_RENDERER_ETA, NULL));
}
diff --git a/src/trg-cell-renderer-eta.h b/src/trg-cell-renderer-eta.h
index a56d96f..d3533fc 100644
--- a/src/trg-cell-renderer-eta.h
+++ b/src/trg-cell-renderer-eta.h
@@ -48,4 +48,4 @@ GType trg_cell_renderer_eta_get_type(void);
GtkCellRenderer *trg_cell_renderer_eta_new(void);
G_END_DECLS
-#endif /* TRG_CELL_RENDERER_ETA_H_ */
+#endif /* TRG_CELL_RENDERER_ETA_H_ */
diff --git a/src/trg-cell-renderer-numgteqthan.c b/src/trg-cell-renderer-numgteqthan.c
index 36d579f..4aa07bb 100644
--- a/src/trg-cell-renderer-numgteqthan.c
+++ b/src/trg-cell-renderer-numgteqthan.c
@@ -30,10 +30,11 @@ enum {
};
G_DEFINE_TYPE(TrgCellRendererNumGtEqThan, trg_cell_renderer_numgteqthan,
- GTK_TYPE_CELL_RENDERER_TEXT)
+ GTK_TYPE_CELL_RENDERER_TEXT)
#define TRG_CELL_RENDERER_NUMGTEQTHAN_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_CELL_RENDERER_NUMGTEQTHAN, TrgCellRendererNumGtEqThanPrivate))
-typedef struct _TrgCellRendererNumGtEqThanPrivate TrgCellRendererNumGtEqThanPrivate;
+typedef struct _TrgCellRendererNumGtEqThanPrivate
+ TrgCellRendererNumGtEqThanPrivate;
struct _TrgCellRendererNumGtEqThanPrivate {
gint64 value_value;
@@ -41,88 +42,97 @@ struct _TrgCellRendererNumGtEqThanPrivate {
};
static void
-trg_cell_renderer_numgteqthan_get_property(GObject * object, guint property_id,
- GValue * value, GParamSpec * pspec)
+trg_cell_renderer_numgteqthan_get_property(GObject * object,
+ guint property_id,
+ GValue * value,
+ GParamSpec * pspec)
{
TrgCellRendererNumGtEqThanPrivate *priv =
- TRG_CELL_RENDERER_NUMGTEQTHAN_GET_PRIVATE(object);
+ TRG_CELL_RENDERER_NUMGTEQTHAN_GET_PRIVATE(object);
switch (property_id) {
case PROP_VALUE_VALUE:
- g_value_set_int64(value, priv->value_value);
- break;
+ g_value_set_int64(value, priv->value_value);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
static void
-trg_cell_renderer_numgteqthan_set_property(GObject * object, guint property_id,
- const GValue * value,
- GParamSpec * pspec)
+trg_cell_renderer_numgteqthan_set_property(GObject * object,
+ guint property_id,
+ const GValue * value,
+ GParamSpec * pspec)
{
TrgCellRendererNumGtEqThanPrivate *priv =
- TRG_CELL_RENDERER_NUMGTEQTHAN_GET_PRIVATE(object);
+ TRG_CELL_RENDERER_NUMGTEQTHAN_GET_PRIVATE(object);
if (property_id == PROP_VALUE_VALUE) {
- priv->value_value = g_value_get_int64(value);
- if (priv->value_value >= priv->minvalue) {
- gchar size_text[32];
- g_snprintf(size_text, sizeof(size_text), "%"G_GINT64_FORMAT, priv->value_value);
- g_object_set(object, "text", size_text, NULL);
- } else {
- g_object_set(object, "text", "", NULL);
- }
+ priv->value_value = g_value_get_int64(value);
+ if (priv->value_value >= priv->minvalue) {
+ gchar size_text[32];
+ g_snprintf(size_text, sizeof(size_text), "%" G_GINT64_FORMAT,
+ priv->value_value);
+ g_object_set(object, "text", size_text, NULL);
+ } else {
+ g_object_set(object, "text", "", NULL);
+ }
} else if (property_id == PROP_MINVALUE) {
- priv->minvalue = g_value_get_int64(value);
+ priv->minvalue = g_value_get_int64(value);
} else {
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
}
}
static void
-trg_cell_renderer_numgteqthan_class_init(TrgCellRendererNumGtEqThanClass * klass)
+trg_cell_renderer_numgteqthan_class_init(TrgCellRendererNumGtEqThanClass *
+ klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
- object_class->get_property = trg_cell_renderer_numgteqthan_get_property;
- object_class->set_property = trg_cell_renderer_numgteqthan_set_property;
+ object_class->get_property =
+ trg_cell_renderer_numgteqthan_get_property;
+ object_class->set_property =
+ trg_cell_renderer_numgteqthan_set_property;
g_object_class_install_property(object_class,
- PROP_VALUE_VALUE,
- g_param_spec_int64("value",
- "Value",
- "Value",
- INT64_MIN,
- INT64_MAX,
- 0,
- G_PARAM_READWRITE
- |
- G_PARAM_STATIC_NAME
- |
- G_PARAM_STATIC_NICK
- |
- G_PARAM_STATIC_BLURB));
+ PROP_VALUE_VALUE,
+ g_param_spec_int64("value",
+ "Value",
+ "Value",
+ INT64_MIN,
+ INT64_MAX,
+ 0,
+ G_PARAM_READWRITE
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
g_object_class_install_property(object_class,
- PROP_MINVALUE,
- g_param_spec_int64("minvalue",
- "Min Value",
- "Min Value",
- INT64_MIN,
- INT64_MAX,
- 1,
- G_PARAM_READWRITE
- |
- G_PARAM_STATIC_NAME
- |
- G_PARAM_STATIC_NICK
- |
- G_PARAM_STATIC_BLURB));
-
- g_type_class_add_private(klass, sizeof(TrgCellRendererNumGtEqThanPrivate));
+ PROP_MINVALUE,
+ g_param_spec_int64("minvalue",
+ "Min Value",
+ "Min Value",
+ INT64_MIN,
+ INT64_MAX,
+ 1,
+ G_PARAM_READWRITE
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
+
+ g_type_class_add_private(klass,
+ sizeof(TrgCellRendererNumGtEqThanPrivate));
}
-static void trg_cell_renderer_numgteqthan_init(TrgCellRendererNumGtEqThan * self)
+static void trg_cell_renderer_numgteqthan_init(TrgCellRendererNumGtEqThan *
+ self)
{
g_object_set(self, "xalign", 1.0f, NULL);
}
@@ -130,5 +140,7 @@ static void trg_cell_renderer_numgteqthan_init(TrgCellRendererNumGtEqThan * self
GtkCellRenderer *trg_cell_renderer_numgteqthan_new(gint64 minvalue)
{
return
- GTK_CELL_RENDERER(g_object_new(TRG_TYPE_CELL_RENDERER_NUMGTEQTHAN, "minvalue", minvalue, NULL));
+ GTK_CELL_RENDERER(g_object_new
+ (TRG_TYPE_CELL_RENDERER_NUMGTEQTHAN, "minvalue",
+ minvalue, NULL));
}
diff --git a/src/trg-cell-renderer-numgteqthan.h b/src/trg-cell-renderer-numgteqthan.h
index dca71c6..fb15e5a 100644
--- a/src/trg-cell-renderer-numgteqthan.h
+++ b/src/trg-cell-renderer-numgteqthan.h
@@ -48,4 +48,4 @@ GType trg_cell_renderer_numgteqthan_get_type(void);
GtkCellRenderer *trg_cell_renderer_numgteqthan_new(gint64 minvalue);
G_END_DECLS
-#endif /* TRG_CELL_RENDERER_NUMGTEQTHAN_H_ */
+#endif /* TRG_CELL_RENDERER_NUMGTEQTHAN_H_ */
diff --git a/src/trg-cell-renderer-priority.c b/src/trg-cell-renderer-priority.c
index 14d4763..747c6a5 100644
--- a/src/trg-cell-renderer-priority.c
+++ b/src/trg-cell-renderer-priority.c
@@ -32,7 +32,7 @@ enum {
};
G_DEFINE_TYPE(TrgCellRendererPriority, trg_cell_renderer_priority,
- GTK_TYPE_CELL_RENDERER_TEXT)
+ GTK_TYPE_CELL_RENDERER_TEXT)
#define TRG_CELL_RENDERER_PRIORITY_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_CELL_RENDERER_PRIORITY, TrgCellRendererPriorityPrivate))
typedef struct _TrgCellRendererPriorityPrivate
@@ -44,40 +44,40 @@ struct _TrgCellRendererPriorityPrivate {
static void
trg_cell_renderer_priority_get_property(GObject * object,
- guint property_id, GValue * value,
- GParamSpec * pspec)
+ guint property_id, GValue * value,
+ GParamSpec * pspec)
{
TrgCellRendererPriorityPrivate *priv =
- TRG_CELL_RENDERER_PRIORITY_GET_PRIVATE(object);
+ TRG_CELL_RENDERER_PRIORITY_GET_PRIVATE(object);
switch (property_id) {
case PROP_PRIORITY_VALUE:
- g_value_set_int64(value, priv->priority_value);
- break;
+ g_value_set_int64(value, priv->priority_value);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
}
}
static void
trg_cell_renderer_priority_set_property(GObject * object,
- guint property_id,
- const GValue * value,
- GParamSpec * pspec)
+ guint property_id,
+ const GValue * value,
+ GParamSpec * pspec)
{
TrgCellRendererPriorityPrivate *priv =
- TRG_CELL_RENDERER_PRIORITY_GET_PRIVATE(object);
+ TRG_CELL_RENDERER_PRIORITY_GET_PRIVATE(object);
if (property_id == PROP_PRIORITY_VALUE) {
- priv->priority_value = g_value_get_int64(value);
- if (priv->priority_value == TR_PRI_LOW) {
- g_object_set(object, "text", _("Low"), NULL);
- } else if (priv->priority_value == TR_PRI_HIGH) {
- g_object_set(object, "text", _("High"), NULL);
- } else {
- g_object_set(object, "text", _("Normal"), NULL);
- }
+ priv->priority_value = g_value_get_int64(value);
+ if (priv->priority_value == TR_PRI_LOW) {
+ g_object_set(object, "text", _("Low"), NULL);
+ } else if (priv->priority_value == TR_PRI_HIGH) {
+ g_object_set(object, "text", _("High"), NULL);
+ } else {
+ g_object_set(object, "text", _("Normal"), NULL);
+ }
} else {
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
}
}
@@ -90,30 +90,30 @@ trg_cell_renderer_priority_class_init(TrgCellRendererPriorityClass * klass)
object_class->set_property = trg_cell_renderer_priority_set_property;
g_object_class_install_property(object_class,
- PROP_PRIORITY_VALUE,
- g_param_spec_int64
- ("priority-value",
- "Priority Value",
- "Priority Value", TR_PRI_LOW,
- TR_PRI_HIGH, TR_PRI_NORMAL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
+ PROP_PRIORITY_VALUE,
+ g_param_spec_int64
+ ("priority-value",
+ "Priority Value",
+ "Priority Value", TR_PRI_LOW,
+ TR_PRI_HIGH, TR_PRI_NORMAL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
g_type_class_add_private(klass,
- sizeof(TrgCellRendererPriorityPrivate));
+ sizeof(TrgCellRendererPriorityPrivate));
}
static void
trg_cell_renderer_priority_init(TrgCellRendererPriority *
- self G_GNUC_UNUSED)
+ self G_GNUC_UNUSED)
{
}
GtkCellRenderer *trg_cell_renderer_priority_new(void)
{
return
- GTK_CELL_RENDERER(g_object_new
- (TRG_TYPE_CELL_RENDERER_PRIORITY, NULL));
+ GTK_CELL_RENDERER(g_object_new
+ (TRG_TYPE_CELL_RENDERER_PRIORITY, NULL));
}
diff --git a/src/trg-cell-renderer-priority.h b/src/trg-cell-renderer-priority.h
index 8d47bca..e53d8ce 100644
--- a/src/trg-cell-renderer-priority.h
+++ b/src/trg-cell-renderer-priority.h
@@ -49,4 +49,4 @@ GType trg_cell_renderer_priority_get_type(void);
GtkCellRenderer *trg_cell_renderer_priority_new(void);
G_END_DECLS
-#endif /* TRG_CELL_RENDERER_PRIORITY_H_ */
+#endif /* TRG_CELL_RENDERER_PRIORITY_H_ */
diff --git a/src/trg-cell-renderer-ratio.c b/src/trg-cell-renderer-ratio.c
index 2a1c304..5b0d4b6 100644
--- a/src/trg-cell-renderer-ratio.c
+++ b/src/trg-cell-renderer-ratio.c
@@ -29,7 +29,7 @@ enum {
};
G_DEFINE_TYPE(TrgCellRendererRatio, trg_cell_renderer_ratio,
- GTK_TYPE_CELL_RENDERER_TEXT)
+ GTK_TYPE_CELL_RENDERER_TEXT)
#define TRG_CELL_RENDERER_RATIO_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_CELL_RENDERER_RATIO, TrgCellRendererRatioPrivate))
typedef struct _TrgCellRendererRatioPrivate TrgCellRendererRatioPrivate;
@@ -40,37 +40,37 @@ struct _TrgCellRendererRatioPrivate {
static void
trg_cell_renderer_ratio_get_property(GObject * object, guint property_id,
- GValue * value, GParamSpec * pspec)
+ GValue * value, GParamSpec * pspec)
{
TrgCellRendererRatioPrivate *priv =
- TRG_CELL_RENDERER_RATIO_GET_PRIVATE(object);
+ TRG_CELL_RENDERER_RATIO_GET_PRIVATE(object);
switch (property_id) {
case PROP_RATIO_VALUE:
- g_value_set_double(value, priv->ratio_value);
- break;
+ g_value_set_double(value, priv->ratio_value);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
}
}
static void
trg_cell_renderer_ratio_set_property(GObject * object, guint property_id,
- const GValue * value,
- GParamSpec * pspec)
+ const GValue * value,
+ GParamSpec * pspec)
{
TrgCellRendererRatioPrivate *priv =
- TRG_CELL_RENDERER_RATIO_GET_PRIVATE(object);
+ TRG_CELL_RENDERER_RATIO_GET_PRIVATE(object);
if (property_id == PROP_RATIO_VALUE) {
- priv->ratio_value = g_value_get_double(value);
- if (priv->ratio_value > 0) {
- char ratioString[32];
- trg_strlratio(ratioString, priv->ratio_value);
- g_object_set(object, "text", ratioString, NULL);
- } else {
- g_object_set(object, "text", "", NULL);
- }
+ priv->ratio_value = g_value_get_double(value);
+ if (priv->ratio_value > 0) {
+ char ratioString[32];
+ trg_strlratio(ratioString, priv->ratio_value);
+ g_object_set(object, "text", ratioString, NULL);
+ } else {
+ g_object_set(object, "text", "", NULL);
+ }
} else {
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
}
}
@@ -83,20 +83,20 @@ trg_cell_renderer_ratio_class_init(TrgCellRendererRatioClass * klass)
object_class->set_property = trg_cell_renderer_ratio_set_property;
g_object_class_install_property(object_class,
- PROP_RATIO_VALUE,
- g_param_spec_double("ratio-value",
- "Ratio Value",
- "Ratio Value",
- 0,
- DBL_MAX,
- 0,
- G_PARAM_READWRITE
- |
- G_PARAM_STATIC_NAME
- |
- G_PARAM_STATIC_NICK
- |
- G_PARAM_STATIC_BLURB));
+ PROP_RATIO_VALUE,
+ g_param_spec_double("ratio-value",
+ "Ratio Value",
+ "Ratio Value",
+ 0,
+ DBL_MAX,
+ 0,
+ G_PARAM_READWRITE
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
g_type_class_add_private(klass, sizeof(TrgCellRendererRatioPrivate));
}
@@ -109,6 +109,6 @@ static void trg_cell_renderer_ratio_init(TrgCellRendererRatio * self)
GtkCellRenderer *trg_cell_renderer_ratio_new(void)
{
return
- GTK_CELL_RENDERER(g_object_new
- (TRG_TYPE_CELL_RENDERER_RATIO, NULL));
+ GTK_CELL_RENDERER(g_object_new
+ (TRG_TYPE_CELL_RENDERER_RATIO, NULL));
}
diff --git a/src/trg-cell-renderer-ratio.h b/src/trg-cell-renderer-ratio.h
index 82593a0..9606f54 100644
--- a/src/trg-cell-renderer-ratio.h
+++ b/src/trg-cell-renderer-ratio.h
@@ -48,4 +48,4 @@ GType trg_cell_renderer_ratio_get_type(void);
GtkCellRenderer *trg_cell_renderer_ratio_new(void);
G_END_DECLS
-#endif /* TRG_CELL_RENDERER_RATIO_H_ */
+#endif /* TRG_CELL_RENDERER_RATIO_H_ */
diff --git a/src/trg-cell-renderer-size.c b/src/trg-cell-renderer-size.c
index 2271d2e..eadf59e 100644
--- a/src/trg-cell-renderer-size.c
+++ b/src/trg-cell-renderer-size.c
@@ -29,7 +29,7 @@ enum {
};
G_DEFINE_TYPE(TrgCellRendererSize, trg_cell_renderer_size,
- GTK_TYPE_CELL_RENDERER_TEXT)
+ GTK_TYPE_CELL_RENDERER_TEXT)
#define TRG_CELL_RENDERER_SIZE_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_CELL_RENDERER_SIZE, TrgCellRendererSizePrivate))
typedef struct _TrgCellRendererSizePrivate TrgCellRendererSizePrivate;
@@ -40,37 +40,37 @@ struct _TrgCellRendererSizePrivate {
static void
trg_cell_renderer_size_get_property(GObject * object, guint property_id,
- GValue * value, GParamSpec * pspec)
+ GValue * value, GParamSpec * pspec)
{
TrgCellRendererSizePrivate *priv =
- TRG_CELL_RENDERER_SIZE_GET_PRIVATE(object);
+ TRG_CELL_RENDERER_SIZE_GET_PRIVATE(object);
switch (property_id) {
case PROP_SIZE_VALUE:
- g_value_set_int64(value, priv->size_value);
- break;
+ g_value_set_int64(value, priv->size_value);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
}
}
static void
trg_cell_renderer_size_set_property(GObject * object, guint property_id,
- const GValue * value,
- GParamSpec * pspec)
+ const GValue * value,
+ GParamSpec * pspec)
{
TrgCellRendererSizePrivate *priv =
- TRG_CELL_RENDERER_SIZE_GET_PRIVATE(object);
+ TRG_CELL_RENDERER_SIZE_GET_PRIVATE(object);
if (property_id == PROP_SIZE_VALUE) {
- priv->size_value = g_value_get_int64(value);
- if (priv->size_value > 0) {
- char sizeString[32];
- trg_strlsize(sizeString, priv->size_value);
- g_object_set(object, "text", sizeString, NULL);
- } else {
- g_object_set(object, "text", "", NULL);
- }
+ priv->size_value = g_value_get_int64(value);
+ if (priv->size_value > 0) {
+ char sizeString[32];
+ trg_strlsize(sizeString, priv->size_value);
+ g_object_set(object, "text", sizeString, NULL);
+ } else {
+ g_object_set(object, "text", "", NULL);
+ }
} else {
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
}
}
@@ -83,20 +83,20 @@ trg_cell_renderer_size_class_init(TrgCellRendererSizeClass * klass)
object_class->set_property = trg_cell_renderer_size_set_property;
g_object_class_install_property(object_class,
- PROP_SIZE_VALUE,
- g_param_spec_int64("size-value",
- "Size Value",
- "Size Value",
- 0,
- INT64_MAX,
- 0,
- G_PARAM_READWRITE
- |
- G_PARAM_STATIC_NAME
- |
- G_PARAM_STATIC_NICK
- |
- G_PARAM_STATIC_BLURB));
+ PROP_SIZE_VALUE,
+ g_param_spec_int64("size-value",
+ "Size Value",
+ "Size Value",
+ 0,
+ INT64_MAX,
+ 0,
+ G_PARAM_READWRITE
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
g_type_class_add_private(klass, sizeof(TrgCellRendererSizePrivate));
}
@@ -109,5 +109,5 @@ static void trg_cell_renderer_size_init(TrgCellRendererSize * self)
GtkCellRenderer *trg_cell_renderer_size_new(void)
{
return
- GTK_CELL_RENDERER(g_object_new(TRG_TYPE_CELL_RENDERER_SIZE, NULL));
+ GTK_CELL_RENDERER(g_object_new(TRG_TYPE_CELL_RENDERER_SIZE, NULL));
}
diff --git a/src/trg-cell-renderer-size.h b/src/trg-cell-renderer-size.h
index 94e5a00..b7900d6 100644
--- a/src/trg-cell-renderer-size.h
+++ b/src/trg-cell-renderer-size.h
@@ -48,4 +48,4 @@ GType trg_cell_renderer_size_get_type(void);
GtkCellRenderer *trg_cell_renderer_size_new(void);
G_END_DECLS
-#endif /* TRG_CELL_RENDERER_SIZE_H_ */
+#endif /* TRG_CELL_RENDERER_SIZE_H_ */
diff --git a/src/trg-cell-renderer-speed.c b/src/trg-cell-renderer-speed.c
index 6fcc797..369e04d 100644
--- a/src/trg-cell-renderer-speed.c
+++ b/src/trg-cell-renderer-speed.c
@@ -29,7 +29,7 @@ enum {
};
G_DEFINE_TYPE(TrgCellRendererSpeed, trg_cell_renderer_speed,
- GTK_TYPE_CELL_RENDERER_TEXT)
+ GTK_TYPE_CELL_RENDERER_TEXT)
#define TRG_CELL_RENDERER_SPEED_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_CELL_RENDERER_SPEED, TrgCellRendererSpeedPrivate))
typedef struct _TrgCellRendererSpeedPrivate TrgCellRendererSpeedPrivate;
@@ -40,38 +40,38 @@ struct _TrgCellRendererSpeedPrivate {
static void
trg_cell_renderer_speed_get_property(GObject * object, guint property_id,
- GValue * value, GParamSpec * pspec)
+ GValue * value, GParamSpec * pspec)
{
TrgCellRendererSpeedPrivate *priv =
- TRG_CELL_RENDERER_SPEED_GET_PRIVATE(object);
+ TRG_CELL_RENDERER_SPEED_GET_PRIVATE(object);
switch (property_id) {
case PROP_SPEED_VALUE:
- g_value_set_int64(value, priv->speed_value);
- break;
+ g_value_set_int64(value, priv->speed_value);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
}
}
static void
trg_cell_renderer_speed_set_property(GObject * object, guint property_id,
- const GValue * value,
- GParamSpec * pspec)
+ const GValue * value,
+ GParamSpec * pspec)
{
TrgCellRendererSpeedPrivate *priv =
- TRG_CELL_RENDERER_SPEED_GET_PRIVATE(object);
+ TRG_CELL_RENDERER_SPEED_GET_PRIVATE(object);
if (property_id == PROP_SPEED_VALUE) {
- priv->speed_value = g_value_get_int64(value);
- if (priv->speed_value > 0) {
- char speedString[32];
- trg_strlspeed(speedString,
- priv->speed_value / KILOBYTE_FACTOR);
- g_object_set(object, "text", speedString, NULL);
- } else {
- g_object_set(object, "text", "", NULL);
- }
+ priv->speed_value = g_value_get_int64(value);
+ if (priv->speed_value > 0) {
+ char speedString[32];
+ trg_strlspeed(speedString,
+ priv->speed_value / KILOBYTE_FACTOR);
+ g_object_set(object, "text", speedString, NULL);
+ } else {
+ g_object_set(object, "text", "", NULL);
+ }
} else {
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
}
}
@@ -84,20 +84,20 @@ trg_cell_renderer_speed_class_init(TrgCellRendererSpeedClass * klass)
object_class->set_property = trg_cell_renderer_speed_set_property;
g_object_class_install_property(object_class,
- PROP_SPEED_VALUE,
- g_param_spec_int64("speed-value",
- "Speed Value",
- "Speed Value",
- 0,
- INT64_MAX,
- 0,
- G_PARAM_READWRITE
- |
- G_PARAM_STATIC_NAME
- |
- G_PARAM_STATIC_NICK
- |
- G_PARAM_STATIC_BLURB));
+ PROP_SPEED_VALUE,
+ g_param_spec_int64("speed-value",
+ "Speed Value",
+ "Speed Value",
+ 0,
+ INT64_MAX,
+ 0,
+ G_PARAM_READWRITE
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
g_type_class_add_private(klass, sizeof(TrgCellRendererSpeedPrivate));
}
@@ -110,6 +110,6 @@ static void trg_cell_renderer_speed_init(TrgCellRendererSpeed * self)
GtkCellRenderer *trg_cell_renderer_speed_new(void)
{
return
- GTK_CELL_RENDERER(g_object_new
- (TRG_TYPE_CELL_RENDERER_SPEED, NULL));
+ GTK_CELL_RENDERER(g_object_new
+ (TRG_TYPE_CELL_RENDERER_SPEED, NULL));
}
diff --git a/src/trg-cell-renderer-speed.h b/src/trg-cell-renderer-speed.h
index e8ea8f0..6aa6b7f 100644
--- a/src/trg-cell-renderer-speed.h
+++ b/src/trg-cell-renderer-speed.h
@@ -49,4 +49,4 @@ GType trg_cell_renderer_speed_get_type(void);
GtkCellRenderer *trg_cell_renderer_speed_new(void);
G_END_DECLS
-#endif /* TRG_CELL_RENDERER_SPEED_H_ */
+#endif /* TRG_CELL_RENDERER_SPEED_H_ */
diff --git a/src/trg-client.c b/src/trg-client.c
index c25f166..942121d 100644
--- a/src/trg-client.c
+++ b/src/trg-client.c
@@ -52,7 +52,7 @@
* 8) Holds the latest session object sent in a session-get response.
*/
-G_DEFINE_TYPE (TrgClient, trg_client, G_TYPE_OBJECT)
+G_DEFINE_TYPE(TrgClient, trg_client, G_TYPE_OBJECT)
enum {
TC_SESSION_UPDATED,
@@ -87,67 +87,63 @@ struct _TrgClientPrivate {
GMutex *configMutex;
};
-static void dispatch_async_threadfunc(trg_request *reqrsp,
- TrgClient * client);
+static void dispatch_async_threadfunc(trg_request * reqrsp,
+ TrgClient * client);
static void
-trg_client_get_property (GObject *object, guint property_id,
- GValue *value, GParamSpec *pspec)
+trg_client_get_property(GObject * object, guint property_id,
+ GValue * value, GParamSpec * pspec)
{
- switch (property_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
+ switch (property_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
+ }
}
static void
-trg_client_set_property (GObject *object, guint property_id,
- const GValue *value, GParamSpec *pspec)
+trg_client_set_property(GObject * object, guint property_id,
+ const GValue * value, GParamSpec * pspec)
{
- switch (property_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
+ switch (property_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
+ }
}
-static void
-trg_client_dispose (GObject *object)
+static void trg_client_dispose(GObject * object)
{
- G_OBJECT_CLASS (trg_client_parent_class)->dispose (object);
+ G_OBJECT_CLASS(trg_client_parent_class)->dispose(object);
}
-static void
-trg_client_class_init (TrgClientClass *klass)
+static void trg_client_class_init(TrgClientClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
- g_type_class_add_private (klass, sizeof (TrgClientPrivate));
+ g_type_class_add_private(klass, sizeof(TrgClientPrivate));
- object_class->get_property = trg_client_get_property;
- object_class->set_property = trg_client_set_property;
- object_class->dispose = trg_client_dispose;
+ object_class->get_property = trg_client_get_property;
+ object_class->set_property = trg_client_set_property;
+ object_class->dispose = trg_client_dispose;
- signals[TC_SESSION_UPDATED] =
- g_signal_new("session-updated",
- G_TYPE_FROM_CLASS(object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET(TrgClientClass,
- session_updated), NULL,
- NULL, g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
+ signals[TC_SESSION_UPDATED] =
+ g_signal_new("session-updated",
+ G_TYPE_FROM_CLASS(object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET(TrgClientClass,
+ session_updated), NULL,
+ NULL, g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
}
-static void
-trg_client_init (TrgClient *self)
+static void trg_client_init(TrgClient * self)
{
}
-TrgClient*
-trg_client_new (void)
+TrgClient *trg_client_new(void)
{
- TrgClient *tc = g_object_new (TRG_TYPE_CLIENT, NULL);
+ TrgClient *tc = g_object_new(TRG_TYPE_CLIENT, NULL);
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
TrgPrefs *prefs = priv->prefs = trg_prefs_new();
@@ -158,33 +154,33 @@ trg_client_new (void)
priv->tlsKey = g_private_new(NULL);
priv->pool = g_thread_pool_new((GFunc) dispatch_async_threadfunc, tc,
- DISPATCH_POOL_SIZE, TRUE, NULL);
+ DISPATCH_POOL_SIZE, TRUE, NULL);
return tc;
}
-const gchar *trg_client_get_version_string(TrgClient *tc)
+const gchar *trg_client_get_version_string(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
return session_get_version_string(priv->session);
}
-float trg_client_get_version(TrgClient *tc)
+float trg_client_get_version(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
return priv->version;
}
-gint64 trg_client_get_rpc_version(TrgClient *tc)
+gint64 trg_client_get_rpc_version(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
return session_get_rpc_version(priv->session);
}
-void trg_client_inc_connid(TrgClient *tc)
+void trg_client_inc_connid(TrgClient * tc)
{
- TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
- g_atomic_int_inc(&priv->connid);
+ TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
+ g_atomic_int_inc(&priv->connid);
}
void trg_client_set_session(TrgClient * tc, JsonObject * session)
@@ -192,9 +188,9 @@ void trg_client_set_session(TrgClient * tc, JsonObject * session)
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
if (priv->session) {
- json_object_unref(priv->session);
+ json_object_unref(priv->session);
} else {
- session_get_version(session, &priv->version);
+ session_get_version(session, &priv->version);
}
priv->session = session;
@@ -202,7 +198,7 @@ void trg_client_set_session(TrgClient * tc, JsonObject * session)
g_signal_emit(tc, signals[TC_SESSION_UPDATED], 0, session);
}
-TrgPrefs *trg_client_get_prefs(TrgClient *tc)
+TrgPrefs *trg_client_get_prefs(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
return priv->prefs;
@@ -233,51 +229,56 @@ int trg_client_populate_with_settings(TrgClient * tc)
priv->password = NULL;
port =
- trg_prefs_get_int(prefs, TRG_PREFS_KEY_PORT, TRG_PREFS_CONNECTION);
+ trg_prefs_get_int(prefs, TRG_PREFS_KEY_PORT, TRG_PREFS_CONNECTION);
- host = trg_prefs_get_string(prefs, TRG_PREFS_KEY_HOSTNAME, TRG_PREFS_CONNECTION);
+ host =
+ trg_prefs_get_string(prefs, TRG_PREFS_KEY_HOSTNAME,
+ TRG_PREFS_CONNECTION);
if (!host || strlen(host) < 1) {
- g_free(host);
- g_mutex_unlock(priv->configMutex);
- return TRG_NO_HOSTNAME_SET;
+ g_free(host);
+ g_mutex_unlock(priv->configMutex);
+ return TRG_NO_HOSTNAME_SET;
}
-
#ifndef CURL_NO_SSL
- priv->ssl = trg_prefs_get_bool(prefs, TRG_PREFS_KEY_SSL, TRG_PREFS_CONNECTION);
+ priv->ssl =
+ trg_prefs_get_bool(prefs, TRG_PREFS_KEY_SSL, TRG_PREFS_CONNECTION);
#else
priv->ssl = FALSE;
#endif
priv->url =
- g_strdup_printf("%s://%s:%d/transmission/rpc",
- priv->ssl ? HTTPS_URI_PREFIX : HTTP_URI_PREFIX, host, port);
+ g_strdup_printf("%s://%s:%d/transmission/rpc",
+ priv->ssl ? HTTPS_URI_PREFIX : HTTP_URI_PREFIX,
+ host, port);
g_free(host);
priv->username =
- trg_prefs_get_string(prefs, TRG_PREFS_KEY_USERNAME, TRG_PREFS_CONNECTION);
+ trg_prefs_get_string(prefs, TRG_PREFS_KEY_USERNAME,
+ TRG_PREFS_CONNECTION);
priv->password =
- trg_prefs_get_string(prefs, TRG_PREFS_KEY_PASSWORD, TRG_PREFS_CONNECTION);
+ trg_prefs_get_string(prefs, TRG_PREFS_KEY_PASSWORD,
+ TRG_PREFS_CONNECTION);
g_free(priv->proxy);
priv->proxy = NULL;
#ifdef HAVE_LIBPROXY
if ((pf = px_proxy_factory_new())) {
- char **proxies = px_proxy_factory_get_proxies(pf, priv->url);
- int i;
-
- for (i = 0; proxies[i]; i++) {
- if (g_str_has_prefix(proxies[i], HTTP_URI_PREFIX)) {
- g_free(priv->proxy);
- priv->proxy = proxies[i];
- } else {
- g_free(proxies[i]);
- }
- }
-
- g_free(proxies);
- px_proxy_factory_free(pf);
+ char **proxies = px_proxy_factory_get_proxies(pf, priv->url);
+ int i;
+
+ for (i = 0; proxies[i]; i++) {
+ if (g_str_has_prefix(proxies[i], HTTP_URI_PREFIX)) {
+ g_free(priv->proxy);
+ priv->proxy = proxies[i];
+ } else {
+ g_free(proxies[i]);
+ }
+ }
+
+ g_free(proxies);
+ px_proxy_factory_free(pf);
}
#endif
@@ -286,152 +287,153 @@ int trg_client_populate_with_settings(TrgClient * tc)
return 0;
}
-gchar *trg_client_get_password(TrgClient *tc)
+gchar *trg_client_get_password(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
return priv->password;
}
-gchar *trg_client_get_username(TrgClient *tc)
+gchar *trg_client_get_username(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
return priv->username;
}
-gchar *trg_client_get_url(TrgClient *tc)
+gchar *trg_client_get_url(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
return priv->url;
}
-gchar *trg_client_get_session_id(TrgClient *tc)
+gchar *trg_client_get_session_id(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
return priv->session_id ? g_strdup(priv->session_id) : NULL;
}
-void trg_client_set_session_id(TrgClient *tc, gchar *session_id)
+void trg_client_set_session_id(TrgClient * tc, gchar * session_id)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
g_mutex_lock(priv->configMutex);
if (priv->session_id)
- g_free(priv->session_id);
+ g_free(priv->session_id);
priv->session_id = session_id;
g_mutex_unlock(priv->configMutex);
}
-void trg_client_status_change(TrgClient *tc, gboolean connected)
+void trg_client_status_change(TrgClient * tc, gboolean connected)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
if (!connected) {
- if (priv->session) {
- json_object_unref(priv->session);
- priv->session = NULL;
- }
- g_mutex_lock(priv->configMutex);
- trg_prefs_set_connection(priv->prefs, NULL);
- g_mutex_unlock(priv->configMutex);
+ if (priv->session) {
+ json_object_unref(priv->session);
+ priv->session = NULL;
+ }
+ g_mutex_lock(priv->configMutex);
+ trg_prefs_set_connection(priv->prefs, NULL);
+ g_mutex_unlock(priv->configMutex);
}
}
-JsonObject* trg_client_get_session(TrgClient *tc)
+JsonObject *trg_client_get_session(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
return priv->session;
}
-void trg_client_thread_pool_push(TrgClient *tc, gpointer data, GError **err)
+void trg_client_thread_pool_push(TrgClient * tc, gpointer data,
+ GError ** err)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
g_thread_pool_push(priv->pool, data, err);
}
-void trg_client_inc_serial(TrgClient *tc)
+void trg_client_inc_serial(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
priv->updateSerial++;
}
-gint64 trg_client_get_serial(TrgClient *tc)
+gint64 trg_client_get_serial(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
return priv->updateSerial;
}
#ifndef CURL_NO_SSL
-gboolean trg_client_get_ssl(TrgClient *tc)
+gboolean trg_client_get_ssl(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
return priv->ssl;
}
#endif
-gchar *trg_client_get_proxy(TrgClient *tc)
+gchar *trg_client_get_proxy(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
return priv->proxy;
}
-void trg_client_set_torrent_table(TrgClient *tc, GHashTable *table)
+void trg_client_set_torrent_table(TrgClient * tc, GHashTable * table)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
priv->torrentTable = table;
}
-GHashTable* trg_client_get_torrent_table(TrgClient *tc)
+GHashTable *trg_client_get_torrent_table(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
return priv->torrentTable;
}
-gboolean trg_client_is_connected(TrgClient *tc)
+gboolean trg_client_is_connected(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
return priv->session != NULL;
}
-void trg_client_updatelock(TrgClient *tc)
+void trg_client_updatelock(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
g_mutex_lock(priv->updateMutex);
}
-void trg_client_configlock(TrgClient *tc)
+void trg_client_configlock(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
g_mutex_lock(priv->configMutex);
}
-guint trg_client_get_failcount(TrgClient *tc)
+guint trg_client_get_failcount(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
return priv->failCount;
}
-guint trg_client_inc_failcount(TrgClient *tc)
+guint trg_client_inc_failcount(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
return ++(priv->failCount);
}
-void trg_client_reset_failcount(TrgClient *tc)
+void trg_client_reset_failcount(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
priv->failCount = 0;
}
-void trg_client_updateunlock(TrgClient *tc)
+void trg_client_updateunlock(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
g_mutex_unlock(priv->updateMutex);
}
-void trg_client_configunlock(TrgClient *tc)
+void trg_client_configunlock(TrgClient * tc)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
g_mutex_unlock(priv->configMutex);
@@ -439,10 +441,10 @@ void trg_client_configunlock(TrgClient *tc)
/* formerly http.c */
-void trg_response_free(trg_response *response)
+void trg_response_free(trg_response * response)
{
- if (response->obj)
- json_object_unref(response->obj);
+ if (response->obj)
+ json_object_unref(response->obj);
g_free(response);
}
@@ -454,58 +456,60 @@ http_receive_callback(void *ptr, size_t size, size_t nmemb, void *data)
mem->raw = g_realloc(mem->raw, mem->size + realsize + 1);
if (mem->raw) {
- memcpy(&(mem->raw[mem->size]), ptr, realsize);
- mem->size += realsize;
- mem->raw[mem->size] = 0;
+ memcpy(&(mem->raw[mem->size]), ptr, realsize);
+ mem->size += realsize;
+ mem->raw[mem->size] = 0;
}
return realsize;
}
static size_t header_callback(void *ptr, size_t size, size_t nmemb,
- void *data)
+ void *data)
{
char *header = (char *) (ptr);
TrgClient *tc = TRG_CLIENT(data);
gchar *session_id;
if (g_str_has_prefix(header, X_TRANSMISSION_SESSION_ID_HEADER_PREFIX)) {
- char *nl;
+ char *nl;
- session_id = g_strdup(header);
- nl = strrchr(session_id, '\r');
- if (nl)
- *nl = '\0';
+ session_id = g_strdup(header);
+ nl = strrchr(session_id, '\r');
+ if (nl)
+ *nl = '\0';
- trg_client_set_session_id(tc, session_id);
+ trg_client_set_session_id(tc, session_id);
}
return (nmemb * size);
}
-static void trg_tls_update(TrgClient *tc, trg_tls *tls, gint serial)
+static void trg_tls_update(TrgClient * tc, trg_tls * tls, gint serial)
{
gchar *proxy;
- curl_easy_setopt(tls->curl, CURLOPT_PASSWORD, trg_client_get_password(tc));
- curl_easy_setopt(tls->curl, CURLOPT_USERNAME, trg_client_get_username(tc));
+ curl_easy_setopt(tls->curl, CURLOPT_PASSWORD,
+ trg_client_get_password(tc));
+ curl_easy_setopt(tls->curl, CURLOPT_USERNAME,
+ trg_client_get_username(tc));
curl_easy_setopt(tls->curl, CURLOPT_URL, trg_client_get_url(tc));
#ifndef CURL_NO_SSL
if (trg_client_get_ssl(tc))
- curl_easy_setopt(tls->curl, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_easy_setopt(tls->curl, CURLOPT_SSL_VERIFYPEER, 0);
#endif
proxy = trg_client_get_proxy(tc);
if (proxy) {
- curl_easy_setopt(tls->curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
- curl_easy_setopt(tls->curl, CURLOPT_PROXY, proxy);
+ curl_easy_setopt(tls->curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
+ curl_easy_setopt(tls->curl, CURLOPT_PROXY, proxy);
}
tls->serial = serial;
}
-trg_tls *trg_tls_new(TrgClient *tc)
+trg_tls *trg_tls_new(TrgClient * tc)
{
trg_tls *tls = g_new0(trg_tls, 1);
@@ -514,7 +518,7 @@ trg_tls *trg_tls_new(TrgClient *tc)
curl_easy_setopt(tls->curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_easy_setopt(tls->curl, CURLOPT_TIMEOUT, 20);
curl_easy_setopt(tls->curl, CURLOPT_WRITEFUNCTION,
- &http_receive_callback);
+ &http_receive_callback);
curl_easy_setopt(tls->curl, CURLOPT_HEADERFUNCTION, &header_callback);
curl_easy_setopt(tls->curl, CURLOPT_WRITEHEADER, (void *) tc);
@@ -524,9 +528,9 @@ trg_tls *trg_tls_new(TrgClient *tc)
}
static int trg_http_perform_inner(TrgClient * tc,
- gchar * reqstr,
- trg_response *response,
- gboolean recurse)
+ gchar * reqstr,
+ trg_response * response,
+ gboolean recurse)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
gpointer threadLocalStorage = g_private_get(priv->tlsKey);
@@ -536,21 +540,21 @@ static int trg_http_perform_inner(TrgClient * tc,
struct curl_slist *headers = NULL;
if (!threadLocalStorage) {
- tls = trg_tls_new(tc);
- g_private_set(priv->tlsKey, tls);
+ tls = trg_tls_new(tc);
+ g_private_set(priv->tlsKey, tls);
} else {
- tls = (trg_tls*)threadLocalStorage;
+ tls = (trg_tls *) threadLocalStorage;
}
g_mutex_lock(priv->configMutex);
if (priv->configSerial > tls->serial)
- trg_tls_update(tc, tls, priv->configSerial);
+ trg_tls_update(tc, tls, priv->configSerial);
session_id = trg_client_get_session_id(tc);
if (session_id) {
- headers = curl_slist_append(NULL, session_id);
- curl_easy_setopt(tls->curl, CURLOPT_HTTPHEADER, headers);
+ headers = curl_slist_append(NULL, session_id);
+ curl_easy_setopt(tls->curl, CURLOPT_HTTPHEADER, headers);
}
g_mutex_unlock(priv->configMutex);
@@ -559,27 +563,27 @@ static int trg_http_perform_inner(TrgClient * tc,
response->raw = NULL;
curl_easy_setopt(tls->curl, CURLOPT_POSTFIELDS, reqstr);
- curl_easy_setopt(tls->curl, CURLOPT_WRITEDATA, (void *)response);
+ curl_easy_setopt(tls->curl, CURLOPT_WRITEDATA, (void *) response);
response->status = curl_easy_perform(tls->curl);
if (session_id) {
- g_free(session_id);
- curl_slist_free_all(headers);
+ g_free(session_id);
+ curl_slist_free_all(headers);
}
curl_easy_getinfo(tls->curl, CURLINFO_RESPONSE_CODE, &httpCode);
if (response->status == CURLE_OK) {
- if (httpCode == HTTP_CONFLICT && recurse == TRUE)
- return trg_http_perform_inner(tc, reqstr, response, FALSE);
- else if (httpCode != HTTP_OK)
- response->status = (-httpCode) - 100;
+ if (httpCode == HTTP_CONFLICT && recurse == TRUE)
+ return trg_http_perform_inner(tc, reqstr, response, FALSE);
+ else if (httpCode != HTTP_OK)
+ response->status = (-httpCode) - 100;
}
return response->status;
}
-int trg_http_perform(TrgClient * tc, gchar * reqstr, trg_response *reqrsp)
+int trg_http_perform(TrgClient * tc, gchar * reqstr, trg_response * reqrsp)
{
return trg_http_perform_inner(tc, reqstr, reqrsp, TRUE);
}
@@ -592,12 +596,12 @@ trg_response *dispatch(TrgClient * client, JsonNode * req)
json_node_free(req);
#ifdef DEBUG
if (g_getenv("TRG_SHOW_OUTGOING"))
- g_debug("=>(OUTgoing)=>: %s", serialized);
+ g_debug("=>(OUTgoing)=>: %s", serialized);
#endif
return dispatch_str(client, serialized);
}
-trg_response *dispatch_str(TrgClient * client, gchar *req)
+trg_response *dispatch_str(TrgClient * client, gchar * req)
{
trg_response *response = g_new0(trg_response, 1);
GError *decode_error = NULL;
@@ -607,51 +611,51 @@ trg_response *dispatch_str(TrgClient * client, gchar *req)
g_free(req);
if (response->status != CURLE_OK)
- return response;
+ return response;
response->obj = trg_deserialize(response, &decode_error);
g_free(response->raw);
response->raw = NULL;
if (decode_error) {
- g_error("JSON decoding error: %s", decode_error->message);
- g_error_free(decode_error);
- response->status = FAIL_JSON_DECODE;
- return response;
+ g_error("JSON decoding error: %s", decode_error->message);
+ g_error_free(decode_error);
+ response->status = FAIL_JSON_DECODE;
+ return response;
}
result = json_object_get_member(response->obj, FIELD_RESULT);
if (!result || g_strcmp0(json_node_get_string(result), FIELD_SUCCESS))
- response->status = FAIL_RESPONSE_UNSUCCESSFUL;
+ response->status = FAIL_RESPONSE_UNSUCCESSFUL;
return response;
}
-static void dispatch_async_threadfunc(trg_request *req,
- TrgClient * client)
+static void dispatch_async_threadfunc(trg_request * req,
+ TrgClient * client)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(client);
trg_response *rsp;
if (req->str)
- rsp = dispatch_str(client, req->str);
+ rsp = dispatch_str(client, req->str);
else
- rsp = dispatch(client, req->node);
+ rsp = dispatch(client, req->node);
rsp->cb_data = req->cb_data;
if (req->callback && req->connid == g_atomic_int_get(&priv->connid))
- g_idle_add(req->callback, rsp);
+ g_idle_add(req->callback, rsp);
else
- trg_response_free(rsp);
+ trg_response_free(rsp);
g_free(req);
}
-static gboolean dispatch_async_common(TrgClient * client, trg_request *trg_req,
- GSourceFunc callback,
- gpointer data)
+static gboolean dispatch_async_common(TrgClient * client,
+ trg_request * trg_req,
+ GSourceFunc callback, gpointer data)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(client);
GError *error = NULL;
@@ -662,18 +666,17 @@ static gboolean dispatch_async_common(TrgClient * client, trg_request *trg_req,
trg_client_thread_pool_push(client, trg_req, &error);
if (error) {
- g_error("thread creation error: %s\n", error->message);
- g_error_free(error);
- g_free(trg_req);
- return FALSE;
+ g_error("thread creation error: %s\n", error->message);
+ g_error_free(error);
+ g_free(trg_req);
+ return FALSE;
} else {
- return TRUE;
+ return TRUE;
}
}
-gboolean dispatch_async(TrgClient * client, JsonNode *req,
- GSourceFunc callback,
- gpointer data)
+gboolean dispatch_async(TrgClient * client, JsonNode * req,
+ GSourceFunc callback, gpointer data)
{
trg_request *trg_req = g_new0(trg_request, 1);
trg_req->node = req;
@@ -681,9 +684,8 @@ gboolean dispatch_async(TrgClient * client, JsonNode *req,
return dispatch_async_common(client, trg_req, callback, data);
}
-gboolean dispatch_async_str(TrgClient * client, gchar *req,
- GSourceFunc callback,
- gpointer data)
+gboolean dispatch_async_str(TrgClient * client, gchar * req,
+ GSourceFunc callback, gpointer data)
{
trg_request *trg_req = g_new0(trg_request, 1);
trg_req->str = req;
diff --git a/src/trg-client.h b/src/trg-client.h
index 31a9267..ae3c489 100644
--- a/src/trg-client.h
+++ b/src/trg-client.h
@@ -67,41 +67,34 @@ typedef struct {
gpointer cb_data;
} trg_response;
-typedef struct
-{
+typedef struct {
gint connid;
- JsonNode *node;
- gchar *str;
+ JsonNode *node;
+ gchar *str;
GSourceFunc callback;
gpointer cb_data;
} trg_request;
G_BEGIN_DECLS
-
#define TRG_TYPE_CLIENT trg_client_get_type()
-
#define TRG_CLIENT(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), TRG_TYPE_CLIENT, TrgClient))
-
#define TRG_CLIENT_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), TRG_TYPE_CLIENT, TrgClientClass))
-
#define TRG_IS_CLIENT(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRG_TYPE_CLIENT))
-
#define TRG_IS_CLIENT_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), TRG_TYPE_CLIENT))
-
#define TRG_CLIENT_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), TRG_TYPE_CLIENT, TrgClientClass))
-
-typedef struct {
- GObject parent;
+ typedef struct {
+ GObject parent;
} TrgClient;
typedef struct {
- GObjectClass parent_class;
- void (*session_updated) (TrgClient *tc, JsonObject * session, gpointer data);
+ GObjectClass parent_class;
+ void (*session_updated) (TrgClient * tc, JsonObject * session,
+ gpointer data);
} TrgClientClass;
@@ -119,53 +112,53 @@ typedef struct {
} trg_tls;
/* stuff that used to be in http.h */
-void trg_response_free(trg_response *response);
-int trg_http_perform(TrgClient * client, gchar * reqstr, trg_response *reqrsp);
+void trg_response_free(trg_response * response);
+int trg_http_perform(TrgClient * client, gchar * reqstr,
+ trg_response * reqrsp);
/* end http.h*/
/* stuff that used to be in dispatch.c */
trg_response *dispatch(TrgClient * client, JsonNode * req);
-trg_response *dispatch_str(TrgClient * client, gchar *req);
+trg_response *dispatch_str(TrgClient * client, gchar * req);
gboolean dispatch_async(TrgClient * client, JsonNode * req,
- GSourceFunc callback,
- gpointer data);
+ GSourceFunc callback, gpointer data);
/* end dispatch.c*/
-GType trg_client_get_type (void);
+GType trg_client_get_type(void);
-TrgClient* trg_client_new (void);
-TrgPrefs* trg_client_get_prefs(TrgClient *tc);
+TrgClient *trg_client_new(void);
+TrgPrefs *trg_client_get_prefs(TrgClient * tc);
int trg_client_populate_with_settings(TrgClient * tc);
void trg_client_set_session(TrgClient * tc, JsonObject * session);
-float trg_client_get_version(TrgClient *tc);
-const gchar *trg_client_get_version_string(TrgClient *tc);
-gint64 trg_client_get_rpc_version(TrgClient *tc);
-gchar *trg_client_get_password(TrgClient *tc);
-gchar *trg_client_get_username(TrgClient *tc);
-gchar *trg_client_get_url(TrgClient *tc);
-gchar *trg_client_get_session_id(TrgClient *tc);
-void trg_client_set_session_id(TrgClient *tc, gchar *session_id);
+float trg_client_get_version(TrgClient * tc);
+const gchar *trg_client_get_version_string(TrgClient * tc);
+gint64 trg_client_get_rpc_version(TrgClient * tc);
+gchar *trg_client_get_password(TrgClient * tc);
+gchar *trg_client_get_username(TrgClient * tc);
+gchar *trg_client_get_url(TrgClient * tc);
+gchar *trg_client_get_session_id(TrgClient * tc);
+void trg_client_set_session_id(TrgClient * tc, gchar * session_id);
#ifndef CURL_NO_SSL
-gboolean trg_client_get_ssl(TrgClient *tc);
+gboolean trg_client_get_ssl(TrgClient * tc);
#endif
-gchar *trg_client_get_proxy(TrgClient *tc);
-gint64 trg_client_get_serial(TrgClient *tc);
-void trg_client_thread_pool_push(TrgClient *tc, gpointer data, GError **err);
-void trg_client_set_torrent_table(TrgClient *tc, GHashTable *table);
-GHashTable* trg_client_get_torrent_table(TrgClient *tc);
-JsonObject* trg_client_get_session(TrgClient *tc);
-void trg_client_status_change(TrgClient *tc, gboolean connected);
-gboolean trg_client_is_connected(TrgClient *tc);
-void trg_client_updateunlock(TrgClient *tc);
-void trg_client_updatelock(TrgClient *tc);
-void trg_client_configunlock(TrgClient *tc);
-void trg_client_configlock(TrgClient *tc);
-guint trg_client_inc_failcount(TrgClient *tc);
-guint trg_client_get_failcount(TrgClient *tc);
-void trg_client_reset_failcount(TrgClient *tc);
-void trg_client_inc_serial(TrgClient *tc);
-void trg_client_inc_connid(TrgClient *tc);
+gchar *trg_client_get_proxy(TrgClient * tc);
+gint64 trg_client_get_serial(TrgClient * tc);
+void trg_client_thread_pool_push(TrgClient * tc, gpointer data,
+ GError ** err);
+void trg_client_set_torrent_table(TrgClient * tc, GHashTable * table);
+GHashTable *trg_client_get_torrent_table(TrgClient * tc);
+JsonObject *trg_client_get_session(TrgClient * tc);
+void trg_client_status_change(TrgClient * tc, gboolean connected);
+gboolean trg_client_is_connected(TrgClient * tc);
+void trg_client_updateunlock(TrgClient * tc);
+void trg_client_updatelock(TrgClient * tc);
+void trg_client_configunlock(TrgClient * tc);
+void trg_client_configlock(TrgClient * tc);
+guint trg_client_inc_failcount(TrgClient * tc);
+guint trg_client_get_failcount(TrgClient * tc);
+void trg_client_reset_failcount(TrgClient * tc);
+void trg_client_inc_serial(TrgClient * tc);
+void trg_client_inc_connid(TrgClient * tc);
G_END_DECLS
-
-#endif // _TRG_CLIENT_H_
+#endif // _TRG_CLIENT_H_
diff --git a/src/trg-destination-combo.c b/src/trg-destination-combo.c
index 30bfc83..c19a750 100644
--- a/src/trg-destination-combo.c
+++ b/src/trg-destination-combo.c
@@ -27,7 +27,7 @@
#include "util.h"
G_DEFINE_TYPE(TrgDestinationCombo, trg_destination_combo,
- GTK_TYPE_COMBO_BOX)
+ GTK_TYPE_COMBO_BOX)
#define TRG_DESTINATION_COMBO_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_DESTINATION_COMBO, TrgDestinationComboPrivate))
typedef struct _TrgDestinationComboPrivate TrgDestinationComboPrivate;
@@ -51,147 +51,169 @@ enum {
DEST_COLUMN_LABEL, DEST_COLUMN_DIR, DEST_COLUMN_TYPE, N_DEST_COLUMNS
};
-static void trg_destination_combo_finalize(GObject *object) {
+static void trg_destination_combo_finalize(GObject * object)
+{
TrgDestinationComboPrivate *priv =
- TRG_DESTINATION_COMBO_GET_PRIVATE(object);
- g_free((gpointer)priv->last_selection);
+ TRG_DESTINATION_COMBO_GET_PRIVATE(object);
+ g_free((gpointer) priv->last_selection);
}
static void trg_destination_combo_get_property(GObject * object,
- guint property_id, GValue * value, GParamSpec * pspec) {
+ guint property_id,
+ GValue * value,
+ GParamSpec * pspec)
+{
TrgDestinationComboPrivate *priv =
- TRG_DESTINATION_COMBO_GET_PRIVATE(object);
+ TRG_DESTINATION_COMBO_GET_PRIVATE(object);
switch (property_id) {
case PROP_CLIENT:
- g_value_set_pointer(value, priv->client);
- break;
+ g_value_set_pointer(value, priv->client);
+ break;
case PROP_LAST_SELECTION:
- g_value_set_string(value, priv->last_selection);
- break;
+ g_value_set_string(value, priv->last_selection);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
static void trg_destination_combo_set_property(GObject * object,
- guint property_id, const GValue * value, GParamSpec * pspec) {
+ guint property_id,
+ const GValue * value,
+ GParamSpec * pspec)
+{
TrgDestinationComboPrivate *priv =
- TRG_DESTINATION_COMBO_GET_PRIVATE(object);
+ TRG_DESTINATION_COMBO_GET_PRIVATE(object);
switch (property_id) {
case PROP_CLIENT:
- priv->client = g_value_get_pointer(value);
- break;
+ priv->client = g_value_get_pointer(value);
+ break;
case PROP_LAST_SELECTION:
- priv->last_selection = g_strdup(g_value_get_string(value));
- break;
+ priv->last_selection = g_strdup(g_value_get_string(value));
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
-static gboolean g_slist_str_set_add(GSList ** list, const gchar * string) {
+static gboolean g_slist_str_set_add(GSList ** list, const gchar * string)
+{
GSList *li;
for (li = *list; li; li = g_slist_next(li))
- if (!g_strcmp0((gchar *) li->data, string))
- return FALSE;
+ if (!g_strcmp0((gchar *) li->data, string))
+ return FALSE;
*list = g_slist_insert_sorted(*list, (gpointer) string,
- (GCompareFunc) g_strcmp0);
+ (GCompareFunc) g_strcmp0);
return TRUE;
}
-void trg_destination_combo_save_selection(TrgDestinationCombo *combo_box)
+void trg_destination_combo_save_selection(TrgDestinationCombo * combo_box)
{
- TrgDestinationComboPrivate *priv = TRG_DESTINATION_COMBO_GET_PRIVATE(combo_box);
+ TrgDestinationComboPrivate *priv =
+ TRG_DESTINATION_COMBO_GET_PRIVATE(combo_box);
GtkTreeIter iter;
- if (priv->last_selection && gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo_box), &iter)) {
- GtkTreeModel *model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo_box));
- TrgPrefs *prefs = trg_client_get_prefs(priv->client);
- gchar *text;
-
- gtk_tree_model_get(model, &iter, DEST_COLUMN_LABEL, &text, -1);
- trg_prefs_set_string(prefs, priv->last_selection, text, TRG_PREFS_CONNECTION);
- g_free(text);
+ if (priv->last_selection
+ && gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo_box),
+ &iter)) {
+ GtkTreeModel *model =
+ gtk_combo_box_get_model(GTK_COMBO_BOX(combo_box));
+ TrgPrefs *prefs = trg_client_get_prefs(priv->client);
+ gchar *text;
+
+ gtk_tree_model_get(model, &iter, DEST_COLUMN_LABEL, &text, -1);
+ trg_prefs_set_string(prefs, priv->last_selection, text,
+ TRG_PREFS_CONNECTION);
+ g_free(text);
}
}
-static void gtk_combo_box_entry_active_changed(GtkComboBox *combo_box,
- gpointer user_data) {
+static void gtk_combo_box_entry_active_changed(GtkComboBox * combo_box,
+ gpointer user_data)
+{
GtkTreeModel *model;
GtkTreeIter iter;
gboolean editableEntry = TRUE;
if (gtk_combo_box_get_active_iter(combo_box, &iter)) {
- GtkEntry *entry = trg_destination_combo_get_entry(
- TRG_DESTINATION_COMBO(combo_box));
+ GtkEntry *entry =
+ trg_destination_combo_get_entry(TRG_DESTINATION_COMBO
+ (combo_box));
- if (entry) {
- GValue value = { 0, };
- guint type;
+ if (entry) {
+ GValue value = { 0, };
+ guint type;
- model = gtk_combo_box_get_model(combo_box);
+ model = gtk_combo_box_get_model(combo_box);
- gtk_tree_model_get_value(model, &iter, DEST_COLUMN_LABEL, &value);
- gtk_tree_model_get(model, &iter, DEST_COLUMN_TYPE, &type, -1);
+ gtk_tree_model_get_value(model, &iter, DEST_COLUMN_LABEL,
+ &value);
+ gtk_tree_model_get(model, &iter, DEST_COLUMN_TYPE, &type, -1);
- g_object_set_property(G_OBJECT (entry), "text", &value);
- g_value_unset(&value);
+ g_object_set_property(G_OBJECT(entry), "text", &value);
+ g_value_unset(&value);
- if (type == DEST_LABEL)
- editableEntry = FALSE;
- }
+ if (type == DEST_LABEL)
+ editableEntry = FALSE;
+ }
}
-
#if GTK_CHECK_VERSION( 3, 0, 0 )
- gtk_editable_set_editable(GTK_EDITABLE(trg_destination_combo_get_entry(TRG_DESTINATION_COMBO(combo_box))), editableEntry);
+ gtk_editable_set_editable(GTK_EDITABLE
+ (trg_destination_combo_get_entry
+ (TRG_DESTINATION_COMBO(combo_box))),
+ editableEntry);
#else
- gtk_entry_set_editable(
- trg_destination_combo_get_entry(TRG_DESTINATION_COMBO(combo_box)),
- editableEntry);
+ gtk_entry_set_editable(trg_destination_combo_get_entry
+ (TRG_DESTINATION_COMBO(combo_box)),
+ editableEntry);
#endif
}
-gboolean trg_destination_combo_has_text(TrgDestinationCombo *combo) {
- const gchar *text = gtk_entry_get_text(
- trg_destination_combo_get_entry(TRG_DESTINATION_COMBO(combo)));
+gboolean trg_destination_combo_has_text(TrgDestinationCombo * combo)
+{
+ const gchar *text =
+ gtk_entry_get_text(trg_destination_combo_get_entry
+ (TRG_DESTINATION_COMBO(combo)));
return strlen(text) > 0;
}
-GtkEntry *trg_destination_combo_get_entry(TrgDestinationCombo *combo) {
- TrgDestinationComboPrivate *priv = TRG_DESTINATION_COMBO_GET_PRIVATE(combo);
- return GTK_ENTRY (priv->entry);
+GtkEntry *trg_destination_combo_get_entry(TrgDestinationCombo * combo)
+{
+ TrgDestinationComboPrivate *priv =
+ TRG_DESTINATION_COMBO_GET_PRIVATE(combo);
+ return GTK_ENTRY(priv->entry);
}
-static void add_entry_cb(GtkEntry *entry,
- GtkEntryIconPosition icon_pos,
- GdkEvent *event,
- gpointer user_data)
+static void add_entry_cb(GtkEntry * entry,
+ GtkEntryIconPosition icon_pos,
+ GdkEvent * event, gpointer user_data)
{
GtkComboBox *combo = GTK_COMBO_BOX(user_data);
GtkTreeModel *model = gtk_combo_box_get_model(combo);
GtkTreeIter iter;
- gtk_list_store_insert_with_values(GTK_LIST_STORE(model), &iter, INT_MAX,
- DEST_COLUMN_LABEL, "",
- DEST_COLUMN_DIR, "",
- DEST_COLUMN_TYPE, DEST_USERADD, -1);
+ gtk_list_store_insert_with_values(GTK_LIST_STORE(model), &iter,
+ INT_MAX, DEST_COLUMN_LABEL, "",
+ DEST_COLUMN_DIR, "",
+ DEST_COLUMN_TYPE, DEST_USERADD, -1);
gtk_combo_box_set_active_iter(combo, &iter);
}
-struct findDupeArg
-{
+struct findDupeArg {
const gchar *dir;
gboolean isDupe;
};
gboolean
trg_destination_combo_insert_check_dupe_foreach(GtkTreeModel * model,
- GtkTreePath * path G_GNUC_UNUSED,
- GtkTreeIter * iter, struct findDupeArg *args)
+ GtkTreePath *
+ path G_GNUC_UNUSED,
+ GtkTreeIter * iter,
+ struct findDupeArg *args)
{
gchar *existing;
gtk_tree_model_get(model, iter, DEST_COLUMN_DIR, &existing, -1);
@@ -200,43 +222,53 @@ trg_destination_combo_insert_check_dupe_foreach(GtkTreeModel * model,
return args->isDupe;
}
-static void trg_destination_combo_insert(GtkComboBox *box, const gchar *label,
- const gchar *dir, guint type, const gchar *lastDestination)
+static void trg_destination_combo_insert(GtkComboBox * box,
+ const gchar * label,
+ const gchar * dir, guint type,
+ const gchar * lastDestination)
{
GtkTreeModel *model = gtk_combo_box_get_model(box);
gchar *comboLabel;
GtkTreeIter iter;
- if (type == DEST_EXISTING)
- {
- struct findDupeArg args;
- args.isDupe = FALSE;
- args.dir = dir;
- gtk_tree_model_foreach(GTK_TREE_MODEL(model),
- (GtkTreeModelForeachFunc)trg_destination_combo_insert_check_dupe_foreach, &args);
- if (args.isDupe)
- return;
+ if (type == DEST_EXISTING) {
+ struct findDupeArg args;
+ args.isDupe = FALSE;
+ args.dir = dir;
+ gtk_tree_model_foreach(GTK_TREE_MODEL(model),
+ (GtkTreeModelForeachFunc)
+ trg_destination_combo_insert_check_dupe_foreach,
+ &args);
+ if (args.isDupe)
+ return;
}
- comboLabel = label ? g_strdup_printf("%s (%s)", label, dir) : g_strdup(dir);
+ comboLabel =
+ label ? g_strdup_printf("%s (%s)", label, dir) : g_strdup(dir);
- gtk_list_store_insert_with_values(GTK_LIST_STORE(model), &iter, INT_MAX,
- DEST_COLUMN_LABEL, comboLabel, DEST_COLUMN_DIR, dir,
- DEST_COLUMN_TYPE, type, -1);
+ gtk_list_store_insert_with_values(GTK_LIST_STORE(model), &iter,
+ INT_MAX, DEST_COLUMN_LABEL,
+ comboLabel, DEST_COLUMN_DIR, dir,
+ DEST_COLUMN_TYPE, type, -1);
if (lastDestination && !g_strcmp0(lastDestination, comboLabel))
- gtk_combo_box_set_active_iter(box, &iter);
+ gtk_combo_box_set_active_iter(box, &iter);
g_free(comboLabel);
}
static GObject *trg_destination_combo_constructor(GType type,
- guint n_construct_properties, GObjectConstructParam * construct_params) {
+ guint
+ n_construct_properties,
+ GObjectConstructParam *
+ construct_params)
+{
GObject *object = G_OBJECT_CLASS
- (trg_destination_combo_parent_class)->constructor(type,
- n_construct_properties, construct_params);
+ (trg_destination_combo_parent_class)->constructor(type,
+ n_construct_properties,
+ construct_params);
TrgDestinationComboPrivate *priv =
- TRG_DESTINATION_COMBO_GET_PRIVATE(object);
+ TRG_DESTINATION_COMBO_GET_PRIVATE(object);
TrgClient *client = priv->client;
TrgPrefs *prefs = trg_client_get_prefs(client);
@@ -252,97 +284,102 @@ static GObject *trg_destination_combo_constructor(GType type,
const gchar *lastDestination = NULL;
comboModel = gtk_list_store_new(N_DEST_COLUMNS, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_UINT);
- gtk_combo_box_set_model(GTK_COMBO_BOX(object), GTK_TREE_MODEL(comboModel));
+ G_TYPE_STRING, G_TYPE_UINT);
+ gtk_combo_box_set_model(GTK_COMBO_BOX(object),
+ GTK_TREE_MODEL(comboModel));
g_object_unref(comboModel);
- g_signal_connect (object, "changed",
- G_CALLBACK (gtk_combo_box_entry_active_changed), NULL);
+ g_signal_connect(object, "changed",
+ G_CALLBACK(gtk_combo_box_entry_active_changed), NULL);
- priv->entry = gtk_entry_new ();
- gtk_container_add (GTK_CONTAINER (object), priv->entry);
+ priv->entry = gtk_entry_new();
+ gtk_container_add(GTK_CONTAINER(object), priv->entry);
- priv->text_renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object),
- priv->text_renderer, TRUE);
+ priv->text_renderer = gtk_cell_renderer_text_new();
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(object),
+ priv->text_renderer, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object),
- priv->text_renderer,
- "text", 0,
- NULL);
+ gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(object),
+ priv->text_renderer, "text", 0, NULL);
g_slist_foreach(dirs, (GFunc) g_free, NULL);
g_slist_free(dirs);
- gtk_entry_set_icon_from_stock(GTK_ENTRY(priv->entry), GTK_ENTRY_ICON_SECONDARY,
- GTK_STOCK_CLEAR);
+ gtk_entry_set_icon_from_stock(GTK_ENTRY(priv->entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ GTK_STOCK_CLEAR);
g_signal_connect(priv->entry, "icon-release",
- G_CALLBACK(add_entry_cb), object);
+ G_CALLBACK(add_entry_cb), object);
- defaultDir = g_strdup(
- session_get_download_dir(trg_client_get_session(client)));
+ defaultDir =
+ g_strdup(session_get_download_dir(trg_client_get_session(client)));
rm_trailing_slashes(defaultDir);
- savedDestinations = trg_prefs_get_array(prefs, TRG_PREFS_KEY_DESTINATIONS,
- TRG_PREFS_CONNECTION);
+ savedDestinations =
+ trg_prefs_get_array(prefs, TRG_PREFS_KEY_DESTINATIONS,
+ TRG_PREFS_CONNECTION);
if (priv->last_selection)
- lastDestination = trg_prefs_get_string(prefs, priv->last_selection,
- TRG_PREFS_CONNECTION);
+ lastDestination = trg_prefs_get_string(prefs, priv->last_selection,
+ TRG_PREFS_CONNECTION);
trg_destination_combo_insert(GTK_COMBO_BOX(object),
- NULL,
- defaultDir,
- DEST_DEFAULT, lastDestination);
+ NULL,
+ defaultDir,
+ DEST_DEFAULT, lastDestination);
if (savedDestinations) {
- list = json_array_get_elements(savedDestinations);
- if (list) {
- for (li = list; li; li = g_list_next(li)) {
- JsonObject *obj = json_node_get_object((JsonNode*) li->data);
- trg_destination_combo_insert(GTK_COMBO_BOX(object),
- json_object_get_string_member(obj, TRG_PREFS_SUBKEY_LABEL),
- json_object_get_string_member(obj, TRG_PREFS_KEY_DESTINATIONS_SUBKEY_DIR),
- DEST_LABEL, lastDestination);
- }
- g_list_free(list);
- }
+ list = json_array_get_elements(savedDestinations);
+ if (list) {
+ for (li = list; li; li = g_list_next(li)) {
+ JsonObject *obj =
+ json_node_get_object((JsonNode *) li->data);
+ trg_destination_combo_insert(GTK_COMBO_BOX(object),
+ json_object_get_string_member
+ (obj, TRG_PREFS_SUBKEY_LABEL),
+ json_object_get_string_member
+ (obj,
+ TRG_PREFS_KEY_DESTINATIONS_SUBKEY_DIR),
+ DEST_LABEL, lastDestination);
+ }
+ g_list_free(list);
+ }
}
trg_client_updatelock(client);
list = g_hash_table_get_values(trg_client_get_torrent_table(client));
for (li = list; li; li = g_list_next(li)) {
- rr = (GtkTreeRowReference *) li->data;
- model = gtk_tree_row_reference_get_model(rr);
- path = gtk_tree_row_reference_get_path(rr);
+ rr = (GtkTreeRowReference *) li->data;
+ model = gtk_tree_row_reference_get_model(rr);
+ path = gtk_tree_row_reference_get_path(rr);
- if (path) {
- GtkTreeIter iter;
+ if (path) {
+ GtkTreeIter iter;
- if (gtk_tree_model_get_iter(model, &iter, path)) {
- gchar *dd;
+ if (gtk_tree_model_get_iter(model, &iter, path)) {
+ gchar *dd;
- gtk_tree_model_get(model, &iter,
- TORRENT_COLUMN_DOWNLOADDIR, &dd, -1);
+ gtk_tree_model_get(model, &iter,
+ TORRENT_COLUMN_DOWNLOADDIR, &dd, -1);
- if (dd && g_strcmp0(dd, defaultDir))
- g_slist_str_set_add(&dirs, dd);
- else
- g_free(dd);
- }
+ if (dd && g_strcmp0(dd, defaultDir))
+ g_slist_str_set_add(&dirs, dd);
+ else
+ g_free(dd);
+ }
- gtk_tree_path_free(path);
- }
+ gtk_tree_path_free(path);
+ }
}
trg_client_updateunlock(client);
for (sli = dirs; sli; sli = g_slist_next(sli))
- trg_destination_combo_insert(GTK_COMBO_BOX(object),
- NULL,
- (gchar *) sli->data,
- DEST_EXISTING, lastDestination);
+ trg_destination_combo_insert(GTK_COMBO_BOX(object),
+ NULL,
+ (gchar *) sli->data,
+ DEST_EXISTING, lastDestination);
g_list_free(list);
g_free(defaultDir);
@@ -350,26 +387,31 @@ static GObject *trg_destination_combo_constructor(GType type,
return object;
}
-gchar *trg_destination_combo_get_dir(TrgDestinationCombo *combo) {
+gchar *trg_destination_combo_get_dir(TrgDestinationCombo * combo)
+{
GtkTreeModel *model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
GtkTreeIter iter;
if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) {
- gchar *value;
- guint type;
+ gchar *value;
+ guint type;
- gtk_tree_model_get(model, &iter, DEST_COLUMN_TYPE, &type, -1);
+ gtk_tree_model_get(model, &iter, DEST_COLUMN_TYPE, &type, -1);
- if (type == DEST_LABEL) {
- gtk_tree_model_get(model, &iter, DEST_COLUMN_DIR, &value, -1);
- return value;
- }
+ if (type == DEST_LABEL) {
+ gtk_tree_model_get(model, &iter, DEST_COLUMN_DIR, &value, -1);
+ return value;
+ }
}
- return g_strdup(gtk_entry_get_text(trg_destination_combo_get_entry(combo)));
+ return
+ g_strdup(gtk_entry_get_text
+ (trg_destination_combo_get_entry(combo)));
}
-static void trg_destination_combo_class_init(TrgDestinationComboClass * klass) {
+static void trg_destination_combo_class_init(TrgDestinationComboClass *
+ klass)
+{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
g_type_class_add_private(klass, sizeof(TrgDestinationComboPrivate));
@@ -379,35 +421,43 @@ static void trg_destination_combo_class_init(TrgDestinationComboClass * klass) {
object_class->finalize = trg_destination_combo_finalize;
object_class->constructor = trg_destination_combo_constructor;
- g_object_class_install_property(
- object_class,
- PROP_CLIENT,
- g_param_spec_pointer(
- "trg-client",
- "TClient",
- "Client",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK
- | G_PARAM_STATIC_BLURB));
-
- g_object_class_install_property(
- object_class,
- PROP_LAST_SELECTION,
- g_param_spec_string(
- "last-selection-key",
- "LastSelectionKey",
- "LastSelectionKey",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK
- | G_PARAM_STATIC_BLURB));
+ g_object_class_install_property(object_class,
+ PROP_CLIENT,
+ g_param_spec_pointer("trg-client",
+ "TClient",
+ "Client",
+ G_PARAM_READWRITE
+ |
+ G_PARAM_CONSTRUCT_ONLY
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
+
+ g_object_class_install_property(object_class,
+ PROP_LAST_SELECTION,
+ g_param_spec_string
+ ("last-selection-key",
+ "LastSelectionKey",
+ "LastSelectionKey", NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
}
-static void trg_destination_combo_init(TrgDestinationCombo * self) {
+static void trg_destination_combo_init(TrgDestinationCombo * self)
+{
}
-GtkWidget *trg_destination_combo_new(TrgClient * client, const gchar *lastSelectionKey) {
+GtkWidget *trg_destination_combo_new(TrgClient * client,
+ const gchar * lastSelectionKey)
+{
return GTK_WIDGET(g_object_new(TRG_TYPE_DESTINATION_COMBO,
- "trg-client", client,
- "last-selection-key", lastSelectionKey, NULL));
+ "trg-client", client,
+ "last-selection-key", lastSelectionKey,
+ NULL));
}
diff --git a/src/trg-destination-combo.h b/src/trg-destination-combo.h
index 453e899..c7513f2 100644
--- a/src/trg-destination-combo.h
+++ b/src/trg-destination-combo.h
@@ -47,11 +47,12 @@ typedef struct {
GType trg_destination_combo_get_type(void);
-GtkWidget *trg_destination_combo_new(TrgClient * client, const gchar *lastSelectionKey);
-gchar *trg_destination_combo_get_dir(TrgDestinationCombo *combo);
-gboolean trg_destination_combo_has_text(TrgDestinationCombo *combo);
-GtkEntry *trg_destination_combo_get_entry(TrgDestinationCombo *combo);
-void trg_destination_combo_save_selection(TrgDestinationCombo *combo_box);
+GtkWidget *trg_destination_combo_new(TrgClient * client,
+ const gchar * lastSelectionKey);
+gchar *trg_destination_combo_get_dir(TrgDestinationCombo * combo);
+gboolean trg_destination_combo_has_text(TrgDestinationCombo * combo);
+GtkEntry *trg_destination_combo_get_entry(TrgDestinationCombo * combo);
+void trg_destination_combo_save_selection(TrgDestinationCombo * combo_box);
G_END_DECLS
-#endif /* TRG_DESTINATION_COMBO_H_ */
+#endif /* TRG_DESTINATION_COMBO_H_ */
diff --git a/src/trg-file-parser.c b/src/trg-file-parser.c
index ac3d0ce..f98b677 100644
--- a/src/trg-file-parser.c
+++ b/src/trg-file-parser.c
@@ -28,8 +28,8 @@
static trg_torrent_file_node
* trg_torrent_file_node_insert(trg_torrent_file_node * top,
- be_node * file_node, guint index,
- gint64 * total_length)
+ be_node * file_node, guint index,
+ gint64 * total_length)
{
int i;
trg_torrent_file_node *path_el_parent = top;
@@ -37,45 +37,45 @@ static trg_torrent_file_node
be_node *file_path_node = be_dict_find(file_node, "path", BE_LIST);
if (!file_path_node || !file_length_node)
- return NULL;
+ return NULL;
/* Iterate over the path list which contains each file/directory
* component of the path in order.
*/
for (i = 0;;) {
- be_node *path_el_node = file_path_node->val.l[i];
-
- trg_torrent_file_node *target_node = NULL;
- GList *li;
-
- /* Does this element exist already? */
- for (li = path_el_parent->children; li != NULL;
- li = g_list_next(li)) {
- trg_torrent_file_node *x = (trg_torrent_file_node *) li->data;
- if (!g_strcmp0(x->name, path_el_node->val.s)) {
- target_node = x;
- break;
- }
- }
-
- if (!target_node) {
- /* Create a new node and add it as a child of the parent from the
- * last iteration. */
- target_node = g_new0(trg_torrent_file_node, 1);
- target_node->name = g_strdup(path_el_node->val.s);
- path_el_parent->children =
- g_list_append(path_el_parent->children, target_node);
- }
-
- path_el_parent = target_node;
-
- /* Is this the last component of the path (the file)? */
- if (!file_path_node->val.l[++i]) {
- *total_length += (target_node->length =
- (gint64) (file_length_node->val.i));
- target_node->index = index;
- return target_node;
- }
+ be_node *path_el_node = file_path_node->val.l[i];
+
+ trg_torrent_file_node *target_node = NULL;
+ GList *li;
+
+ /* Does this element exist already? */
+ for (li = path_el_parent->children; li != NULL;
+ li = g_list_next(li)) {
+ trg_torrent_file_node *x = (trg_torrent_file_node *) li->data;
+ if (!g_strcmp0(x->name, path_el_node->val.s)) {
+ target_node = x;
+ break;
+ }
+ }
+
+ if (!target_node) {
+ /* Create a new node and add it as a child of the parent from the
+ * last iteration. */
+ target_node = g_new0(trg_torrent_file_node, 1);
+ target_node->name = g_strdup(path_el_node->val.s);
+ path_el_parent->children =
+ g_list_append(path_el_parent->children, target_node);
+ }
+
+ path_el_parent = target_node;
+
+ /* Is this the last component of the path (the file)? */
+ if (!file_path_node->val.l[++i]) {
+ *total_length += (target_node->length =
+ (gint64) (file_length_node->val.i));
+ target_node->index = index;
+ return target_node;
+ }
}
return NULL;
@@ -85,7 +85,7 @@ static void trg_torrent_file_node_free(trg_torrent_file_node * node)
{
GList *li;
for (li = node->children; li != NULL; li = g_list_next(li))
- trg_torrent_file_node_free((trg_torrent_file_node *) li->data);
+ trg_torrent_file_node_free((trg_torrent_file_node *) li->data);
g_list_free(node->children);
g_free(node->name);
g_free(node);
@@ -99,9 +99,9 @@ void trg_torrent_file_free(trg_torrent_file * t)
}
static trg_torrent_file_node *trg_parse_torrent_file_nodes(be_node *
- info_node,
- gint64 *
- total_length)
+ info_node,
+ gint64 *
+ total_length)
{
be_node *files_node = be_dict_find(info_node, "files", BE_LIST);
trg_torrent_file_node *top_node = g_new0(trg_torrent_file_node, 1);
@@ -109,25 +109,25 @@ static trg_torrent_file_node *trg_parse_torrent_file_nodes(be_node *
/* Probably means single file mode. */
if (!files_node)
- return NULL;
+ return NULL;
for (i = 0; files_node->val.l[i]; ++i) {
- be_node *file_node = files_node->val.l[i];
-
- if (be_validate_node(file_node, BE_DICT) ||
- !trg_torrent_file_node_insert(top_node, file_node, i,
- total_length)) {
- /* Unexpected format. Throw away everything, file indexes need to
- * be correct. */
- trg_torrent_file_node_free(top_node);
- return NULL;
- }
+ be_node *file_node = files_node->val.l[i];
+
+ if (be_validate_node(file_node, BE_DICT) ||
+ !trg_torrent_file_node_insert(top_node, file_node, i,
+ total_length)) {
+ /* Unexpected format. Throw away everything, file indexes need to
+ * be correct. */
+ trg_torrent_file_node_free(top_node);
+ return NULL;
+ }
}
return top_node;
}
-trg_torrent_file *trg_parse_torrent_file(const gchar *filename)
+trg_torrent_file *trg_parse_torrent_file(const gchar * filename)
{
GError *error = NULL;
GMappedFile *mf;
@@ -135,57 +135,59 @@ trg_torrent_file *trg_parse_torrent_file(const gchar *filename)
trg_torrent_file *ret = NULL;
if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) {
- g_message("%s does not exist", filename);
- return NULL;
+ g_message("%s does not exist", filename);
+ return NULL;
}
mf = g_mapped_file_new(filename, FALSE, &error);
if (error) {
- g_error("%s",error->message);
- g_error_free(error);
- g_mapped_file_unref(mf);
- return NULL;
+ g_error("%s", error->message);
+ g_error_free(error);
+ g_mapped_file_unref(mf);
+ return NULL;
} else {
- top_node = be_decoden(g_mapped_file_get_contents(mf), g_mapped_file_get_length(mf));
+ top_node =
+ be_decoden(g_mapped_file_get_contents(mf),
+ g_mapped_file_get_length(mf));
}
g_mapped_file_unref(mf);
if (!top_node) {
- return NULL;
+ return NULL;
} else if (be_validate_node(top_node, BE_DICT)) {
- goto out;
+ goto out;
}
info_node = be_dict_find(top_node, "info", BE_DICT);
if (!info_node)
- goto out;
+ goto out;
name_node = be_dict_find(info_node, "name", BE_STR);
if (!name_node)
- goto out;
+ goto out;
ret = g_new0(trg_torrent_file, 1);
ret->name = g_strdup(name_node->val.s);
ret->top_node =
- trg_parse_torrent_file_nodes(info_node, &(ret->total_length));
+ trg_parse_torrent_file_nodes(info_node, &(ret->total_length));
if (!ret->top_node) {
- trg_torrent_file_node *file_node;
- be_node *length_node = be_dict_find(info_node, "length", BE_INT);
-
- if (!length_node) {
- g_free(ret);
- ret = NULL;
- goto out;
- }
-
- file_node = g_new0(trg_torrent_file_node, 1);
- file_node->length = ret->total_length =
- (gint64) (length_node->val.i);
- file_node->name = g_strdup(ret->name);
- ret->top_node = file_node;
+ trg_torrent_file_node *file_node;
+ be_node *length_node = be_dict_find(info_node, "length", BE_INT);
+
+ if (!length_node) {
+ g_free(ret);
+ ret = NULL;
+ goto out;
+ }
+
+ file_node = g_new0(trg_torrent_file_node, 1);
+ file_node->length = ret->total_length =
+ (gint64) (length_node->val.i);
+ file_node->name = g_strdup(ret->name);
+ ret->top_node = file_node;
}
out:
diff --git a/src/trg-file-parser.h b/src/trg-file-parser.h
index 9f6edf1..10a4d8a 100644
--- a/src/trg-file-parser.h
+++ b/src/trg-file-parser.h
@@ -31,4 +31,4 @@ typedef struct {
} trg_torrent_file;
void trg_torrent_file_free(trg_torrent_file * t);
-trg_torrent_file *trg_parse_torrent_file(const gchar *filename);
+trg_torrent_file *trg_parse_torrent_file(const gchar * filename);
diff --git a/src/trg-files-model.c b/src/trg-files-model.c
index 5d4cf0a..494f94f 100644
--- a/src/trg-files-model.c
+++ b/src/trg-files-model.c
@@ -40,25 +40,25 @@ struct _TrgFilesModelPrivate {
};
static void trg_files_model_iter_new(TrgFilesModel * model,
- GtkTreeIter * iter, JsonObject * file,
- int id)
+ GtkTreeIter * iter, JsonObject * file,
+ int id)
{
gchar *mimetype;
gtk_list_store_append(GTK_LIST_STORE(model), iter);
gtk_list_store_set(GTK_LIST_STORE(model), iter,
- FILESCOL_NAME, file_get_name(file),
- FILESCOL_SIZE, file_get_length(file),
- FILESCOL_ID, id, -1);
+ FILESCOL_NAME, file_get_name(file),
+ FILESCOL_SIZE, file_get_length(file),
+ FILESCOL_ID, id, -1);
mimetype = g_content_type_guess(file_get_name(file), NULL, 0, NULL);
if (mimetype) {
- GIcon *icon = g_content_type_get_icon (mimetype);
- if (icon) {
- gtk_list_store_set(GTK_LIST_STORE(model), iter,
- FILESCOL_ICON, icon, -1);
- g_object_unref(icon);
- }
+ GIcon *icon = g_content_type_get_icon(mimetype);
+ if (icon) {
+ gtk_list_store_set(GTK_LIST_STORE(model), iter,
+ FILESCOL_ICON, icon, -1);
+ g_object_unref(icon);
+ }
}
g_free(mimetype);
@@ -72,26 +72,26 @@ void trg_files_model_set_accept(TrgFilesModel * model, gboolean accept)
static void
trg_files_model_iter_update(TrgFilesModel * model,
- GtkTreeIter * filesIter, JsonObject * file,
- JsonArray * wantedArray,
- JsonArray * prioritiesArray, int id)
+ GtkTreeIter * filesIter, JsonObject * file,
+ JsonArray * wantedArray,
+ JsonArray * prioritiesArray, int id)
{
TrgFilesModelPrivate *priv = TRG_FILES_MODEL_GET_PRIVATE(model);
gboolean wanted = json_node_get_int(json_array_get_element
- (wantedArray, id)) == 1;
+ (wantedArray, id)) == 1;
gint64 priority =
- json_node_get_int(json_array_get_element(prioritiesArray, id));
+ json_node_get_int(json_array_get_element(prioritiesArray, id));
gdouble progress = file_get_progress(file);
gtk_list_store_set(GTK_LIST_STORE(model), filesIter,
- FILESCOL_PROGRESS, progress, -1);
+ FILESCOL_PROGRESS, progress, -1);
if (priv->accept) {
- gtk_list_store_set(GTK_LIST_STORE(model), filesIter,
- FILESCOL_WANTED,
- wanted ? GTK_STOCK_APPLY : GTK_STOCK_CANCEL,
- FILESCOL_PRIORITY, priority, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), filesIter,
+ FILESCOL_WANTED,
+ wanted ? GTK_STOCK_APPLY : GTK_STOCK_CANCEL,
+ FILESCOL_PRIORITY, priority, -1);
}
}
@@ -116,13 +116,13 @@ static void trg_files_model_init(TrgFilesModel * self)
column_types[FILESCOL_PRIORITY] = G_TYPE_INT64;
gtk_list_store_set_column_types(GTK_LIST_STORE(self),
- FILESCOL_COLUMNS, column_types);
+ FILESCOL_COLUMNS, column_types);
}
gboolean
trg_files_model_update_foreach(GtkListStore * model,
- GtkTreePath * path G_GNUC_UNUSED,
- GtkTreeIter * iter, GList * files)
+ GtkTreePath * path G_GNUC_UNUSED,
+ GtkTreeIter * iter, GList * files)
{
TrgFilesModelPrivate *priv = TRG_FILES_MODEL_GET_PRIVATE(model);
JsonObject *file;
@@ -132,14 +132,14 @@ trg_files_model_update_foreach(GtkListStore * model,
file = json_node_get_object(g_list_nth_data(files, id));
trg_files_model_iter_update(TRG_FILES_MODEL(model), iter, file,
- priv->wanted, priv->priorities, id);
+ priv->wanted, priv->priorities, id);
return FALSE;
}
void
trg_files_model_update(TrgFilesModel * model, gint64 updateSerial,
- JsonObject * t, gint mode)
+ JsonObject * t, gint mode)
{
TrgFilesModelPrivate *priv = TRG_FILES_MODEL_GET_PRIVATE(model);
GList *filesList, *li;
@@ -154,34 +154,34 @@ trg_files_model_update(TrgFilesModel * model, gint64 updateSerial,
filesList = json_array_get_elements(torrent_get_files(t));
if (mode == TORRENT_GET_MODE_FIRST) {
- gtk_list_store_clear(GTK_LIST_STORE(model));
- priv->accept = TRUE;
- for (li = filesList; li; li = g_list_next(li)) {
- file = json_node_get_object((JsonNode *) li->data);
-
- trg_files_model_iter_new(model, &filesIter, file, j);
- trg_files_model_iter_update(model, &filesIter,
- file, priv->wanted,
- priv->priorities, j);
- j++;
- }
+ gtk_list_store_clear(GTK_LIST_STORE(model));
+ priv->accept = TRUE;
+ for (li = filesList; li; li = g_list_next(li)) {
+ file = json_node_get_object((JsonNode *) li->data);
+
+ trg_files_model_iter_new(model, &filesIter, file, j);
+ trg_files_model_iter_update(model, &filesIter,
+ file, priv->wanted,
+ priv->priorities, j);
+ j++;
+ }
} else {
- gint n_existing = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(model), NULL);
- guint n_updates = g_list_length(filesList);
- gtk_tree_model_foreach(GTK_TREE_MODEL(model),
- (GtkTreeModelForeachFunc)
- trg_files_model_update_foreach, filesList);
- if (n_updates > n_existing) {
- gint n_new = n_updates - n_existing;
- for (j = n_updates - n_new; j < n_updates; j++)
- {
- file = json_node_get_object(g_list_nth_data(filesList, j));
- trg_files_model_iter_new(model, &filesIter, file, j);
- trg_files_model_iter_update(model, &filesIter,
- file, priv->wanted,
- priv->priorities, j);
- }
- }
+ gint n_existing =
+ gtk_tree_model_iter_n_children(GTK_TREE_MODEL(model), NULL);
+ guint n_updates = g_list_length(filesList);
+ gtk_tree_model_foreach(GTK_TREE_MODEL(model),
+ (GtkTreeModelForeachFunc)
+ trg_files_model_update_foreach, filesList);
+ if (n_updates > n_existing) {
+ gint n_new = n_updates - n_existing;
+ for (j = n_updates - n_new; j < n_updates; j++) {
+ file = json_node_get_object(g_list_nth_data(filesList, j));
+ trg_files_model_iter_new(model, &filesIter, file, j);
+ trg_files_model_iter_update(model, &filesIter,
+ file, priv->wanted,
+ priv->priorities, j);
+ }
+ }
}
g_list_free(filesList);
diff --git a/src/trg-files-model.h b/src/trg-files-model.h
index c47c361..869503d 100644
--- a/src/trg-files-model.h
+++ b/src/trg-files-model.h
@@ -62,8 +62,8 @@ G_END_DECLS enum {
void
trg_files_model_update(TrgFilesModel * model, gint64 updateSerial,
- JsonObject * t, gint mode);
+ JsonObject * t, gint mode);
gint64 trg_files_model_get_torrent_id(TrgFilesModel * model);
void trg_files_model_set_accept(TrgFilesModel * model, gboolean accept);
-#endif /* TRG_FILES_MODEL_H_ */
+#endif /* TRG_FILES_MODEL_H_ */
diff --git a/src/trg-files-tree-view.c b/src/trg-files-tree-view.c
index 4a1cff6..b671b39 100644
--- a/src/trg-files-tree-view.c
+++ b/src/trg-files-tree-view.c
@@ -46,68 +46,70 @@ static void trg_files_tree_view_class_init(TrgFilesTreeViewClass * klass)
}
static void set_unwanted_foreachfunc(GtkTreeModel * model,
- GtkTreePath * path G_GNUC_UNUSED,
- GtkTreeIter * iter,
- gpointer data G_GNUC_UNUSED)
+ GtkTreePath * path G_GNUC_UNUSED,
+ GtkTreeIter * iter,
+ gpointer data G_GNUC_UNUSED)
{
- gtk_list_store_set(GTK_LIST_STORE(model), iter, FILESCOL_WANTED, GTK_STOCK_CANCEL, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), iter, FILESCOL_WANTED,
+ GTK_STOCK_CANCEL, -1);
}
static void set_wanted_foreachfunc(GtkTreeModel * model,
- GtkTreePath * path G_GNUC_UNUSED,
- GtkTreeIter * iter,
- gpointer data G_GNUC_UNUSED)
+ GtkTreePath * path G_GNUC_UNUSED,
+ GtkTreeIter * iter,
+ gpointer data G_GNUC_UNUSED)
{
gtk_list_store_set(GTK_LIST_STORE(model), iter,
- FILESCOL_WANTED, GTK_STOCK_APPLY, -1);
+ FILESCOL_WANTED, GTK_STOCK_APPLY, -1);
}
static void set_priority_foreachfunc(GtkTreeModel * model,
- GtkTreePath * path G_GNUC_UNUSED,
- GtkTreeIter * iter, gpointer data)
+ GtkTreePath * path G_GNUC_UNUSED,
+ GtkTreeIter * iter, gpointer data)
{
GValue value = { 0 };
g_value_init(&value, G_TYPE_INT64);
g_value_set_int64(&value, (gint64) GPOINTER_TO_INT(data));
gtk_list_store_set_value(GTK_LIST_STORE(model), iter,
- FILESCOL_PRIORITY, &value);
+ FILESCOL_PRIORITY, &value);
}
static void send_updated_file_prefs_foreachfunc(GtkTreeModel * model,
- GtkTreePath *
- path G_GNUC_UNUSED,
- GtkTreeIter * iter,
- gpointer data)
+ GtkTreePath *
+ path G_GNUC_UNUSED,
+ GtkTreeIter * iter,
+ gpointer data)
{
JsonObject *args = (JsonObject *) data;
gint64 priority, id;
gchar *wanted;
gtk_tree_model_get(model, iter, FILESCOL_WANTED, &wanted,
- FILESCOL_PRIORITY, &priority, FILESCOL_ID, &id, -1);
+ FILESCOL_PRIORITY, &priority, FILESCOL_ID, &id, -1);
if (!g_strcmp0(wanted, GTK_STOCK_CANCEL))
- add_file_id_to_array(args, FIELD_FILES_UNWANTED, id);
+ add_file_id_to_array(args, FIELD_FILES_UNWANTED, id);
else
- add_file_id_to_array(args, FIELD_FILES_WANTED, id);
+ add_file_id_to_array(args, FIELD_FILES_WANTED, id);
g_free(wanted);
if (priority == TR_PRI_LOW)
- add_file_id_to_array(args, FIELD_FILES_PRIORITY_LOW, id);
+ add_file_id_to_array(args, FIELD_FILES_PRIORITY_LOW, id);
else if (priority == TR_PRI_HIGH)
- add_file_id_to_array(args, FIELD_FILES_PRIORITY_HIGH, id);
+ add_file_id_to_array(args, FIELD_FILES_PRIORITY_HIGH, id);
else
- add_file_id_to_array(args, FIELD_FILES_PRIORITY_NORMAL, id);
+ add_file_id_to_array(args, FIELD_FILES_PRIORITY_NORMAL, id);
}
-static gboolean
-on_files_update(gpointer data)
+static gboolean on_files_update(gpointer data)
{
- trg_response *response = (trg_response*)data;
- TrgFilesTreeViewPrivate *priv = TRG_FILES_TREE_VIEW_GET_PRIVATE(response->cb_data);
- GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(response->cb_data));
+ trg_response *response = (trg_response *) data;
+ TrgFilesTreeViewPrivate *priv =
+ TRG_FILES_TREE_VIEW_GET_PRIVATE(response->cb_data);
+ GtkTreeModel *model =
+ gtk_tree_view_get_model(GTK_TREE_VIEW(response->cb_data));
trg_files_model_set_accept(TRG_FILES_MODEL(model), TRUE);
@@ -136,8 +138,8 @@ static void send_updated_file_prefs(TrgFilesTreeView * tv)
request_set_tag(req, targetId);
gtk_tree_selection_selected_foreach(selection,
- send_updated_file_prefs_foreachfunc,
- args);
+ send_updated_file_prefs_foreachfunc,
+ args);
trg_files_model_set_accept(TRG_FILES_MODEL(model), FALSE);
@@ -148,10 +150,10 @@ static void set_low(GtkWidget * w G_GNUC_UNUSED, gpointer data)
{
TrgFilesTreeView *tv = TRG_FILES_TREE_VIEW(data);
GtkTreeSelection *selection =
- gtk_tree_view_get_selection(GTK_TREE_VIEW(data));
+ gtk_tree_view_get_selection(GTK_TREE_VIEW(data));
gtk_tree_selection_selected_foreach(selection,
- set_priority_foreachfunc,
- GINT_TO_POINTER(TR_PRI_LOW));
+ set_priority_foreachfunc,
+ GINT_TO_POINTER(TR_PRI_LOW));
send_updated_file_prefs(tv);
}
@@ -159,10 +161,10 @@ static void set_normal(GtkWidget * w G_GNUC_UNUSED, gpointer data)
{
TrgFilesTreeView *tv = TRG_FILES_TREE_VIEW(data);
GtkTreeSelection *selection =
- gtk_tree_view_get_selection(GTK_TREE_VIEW(data));
+ gtk_tree_view_get_selection(GTK_TREE_VIEW(data));
gtk_tree_selection_selected_foreach(selection,
- set_priority_foreachfunc,
- GINT_TO_POINTER(TR_PRI_NORMAL));
+ set_priority_foreachfunc,
+ GINT_TO_POINTER(TR_PRI_NORMAL));
send_updated_file_prefs(tv);
}
@@ -170,10 +172,10 @@ static void set_high(GtkWidget * w G_GNUC_UNUSED, gpointer data)
{
TrgFilesTreeView *tv = TRG_FILES_TREE_VIEW(data);
GtkTreeSelection *selection =
- gtk_tree_view_get_selection(GTK_TREE_VIEW(data));
+ gtk_tree_view_get_selection(GTK_TREE_VIEW(data));
gtk_tree_selection_selected_foreach(selection,
- set_priority_foreachfunc,
- GINT_TO_POINTER(TR_PRI_HIGH));
+ set_priority_foreachfunc,
+ GINT_TO_POINTER(TR_PRI_HIGH));
send_updated_file_prefs(tv);
}
@@ -181,9 +183,9 @@ static void set_unwanted(GtkWidget * w G_GNUC_UNUSED, gpointer data)
{
TrgFilesTreeView *tv = TRG_FILES_TREE_VIEW(data);
GtkTreeSelection *selection =
- gtk_tree_view_get_selection(GTK_TREE_VIEW(data));
+ gtk_tree_view_get_selection(GTK_TREE_VIEW(data));
gtk_tree_selection_selected_foreach(selection,
- set_unwanted_foreachfunc, NULL);
+ set_unwanted_foreachfunc, NULL);
send_updated_file_prefs(tv);
}
@@ -191,15 +193,15 @@ static void set_wanted(GtkWidget * w G_GNUC_UNUSED, gpointer data)
{
TrgFilesTreeView *tv = TRG_FILES_TREE_VIEW(data);
GtkTreeSelection *selection =
- gtk_tree_view_get_selection(GTK_TREE_VIEW(data));
+ gtk_tree_view_get_selection(GTK_TREE_VIEW(data));
gtk_tree_selection_selected_foreach(selection,
- set_wanted_foreachfunc, NULL);
+ set_wanted_foreachfunc, NULL);
send_updated_file_prefs(tv);
}
static void
view_popup_menu(GtkWidget * treeview, GdkEventButton * event,
- gpointer data G_GNUC_UNUSED)
+ gpointer data G_GNUC_UNUSED)
{
GtkWidget *menu, *menuitem;
@@ -211,7 +213,7 @@ view_popup_menu(GtkWidget * treeview, GdkEventButton * event,
menuitem = gtk_menu_item_new_with_label(_("Normal Priority"));
g_signal_connect(menuitem, "activate", G_CALLBACK(set_normal),
- treeview);
+ treeview);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
menuitem = gtk_menu_item_new_with_label(_("Low Priority"));
@@ -219,56 +221,56 @@ view_popup_menu(GtkWidget * treeview, GdkEventButton * event,
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
gtk_menu_shell_append(GTK_MENU_SHELL(menu),
- gtk_separator_menu_item_new());
+ gtk_separator_menu_item_new());
menuitem = gtk_image_menu_item_new_with_label(GTK_STOCK_APPLY);
gtk_image_menu_item_set_use_stock(GTK_IMAGE_MENU_ITEM(menuitem), TRUE);
gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM
- (menuitem), TRUE);
+ (menuitem), TRUE);
gtk_menu_item_set_label(GTK_MENU_ITEM(menuitem), _("Download"));
g_signal_connect(menuitem, "activate", G_CALLBACK(set_wanted),
- treeview);
+ treeview);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
menuitem = gtk_image_menu_item_new_with_label(GTK_STOCK_CANCEL);
gtk_image_menu_item_set_use_stock(GTK_IMAGE_MENU_ITEM(menuitem), TRUE);
gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM
- (menuitem), TRUE);
+ (menuitem), TRUE);
gtk_menu_item_set_label(GTK_MENU_ITEM(menuitem), _("Skip"));
g_signal_connect(menuitem, "activate", G_CALLBACK(set_unwanted),
- treeview);
+ treeview);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
gtk_widget_show_all(menu);
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
- (event != NULL) ? event->button : 0,
- gdk_event_get_time((GdkEvent *) event));
+ (event != NULL) ? event->button : 0,
+ gdk_event_get_time((GdkEvent *) event));
}
static gboolean
view_onButtonPressed(GtkWidget * treeview, GdkEventButton * event,
- gpointer userdata)
+ gpointer userdata)
{
GtkTreeSelection *selection;
GtkTreePath *path;
if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
-
- if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview),
- (gint) event->x,
- (gint) event->y, &path,
- NULL, NULL, NULL)) {
- if (!gtk_tree_selection_path_is_selected(selection, path)) {
- gtk_tree_selection_unselect_all(selection);
- gtk_tree_selection_select_path(selection, path);
- }
- gtk_tree_path_free(path);
-
- view_popup_menu(treeview, event, userdata);
- return TRUE;
- }
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
+
+ if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview),
+ (gint) event->x,
+ (gint) event->y, &path,
+ NULL, NULL, NULL)) {
+ if (!gtk_tree_selection_path_is_selected(selection, path)) {
+ gtk_tree_selection_unselect_all(selection);
+ gtk_tree_selection_select_path(selection, path);
+ }
+ gtk_tree_path_free(path);
+
+ view_popup_menu(treeview, event, userdata);
+ return TRUE;
+ }
}
return FALSE;
@@ -286,35 +288,36 @@ static void trg_files_tree_view_init(TrgFilesTreeView * self)
trg_column_description *desc;
desc =
- trg_tree_view_reg_column(ttv, TRG_COLTYPE_GICONTEXT, FILESCOL_NAME,
- _("Name"), "name", 0);
+ trg_tree_view_reg_column(ttv, TRG_COLTYPE_GICONTEXT, FILESCOL_NAME,
+ _("Name"), "name", 0);
desc->model_column_icon = FILESCOL_ICON;
trg_tree_view_reg_column(ttv, TRG_COLTYPE_SIZE, FILESCOL_SIZE,
- _("Size"), "size", 0);
+ _("Size"), "size", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_PROG, FILESCOL_PROGRESS,
- _("Progress"), "progress", 0);
+ _("Progress"), "progress", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_ICON, FILESCOL_WANTED,
- _("Wanted"), "wanted", 0);
+ _("Wanted"), "wanted", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_PRIO, FILESCOL_PRIORITY,
- _("Priority"), "priority", 0);
+ _("Priority"), "priority", 0);
gtk_tree_view_set_search_column(GTK_TREE_VIEW(self), FILESCOL_NAME);
g_signal_connect(self, "button-press-event",
- G_CALLBACK(view_onButtonPressed), NULL);
+ G_CALLBACK(view_onButtonPressed), NULL);
g_signal_connect(self, "popup-menu", G_CALLBACK(view_onPopupMenu),
- NULL);
+ NULL);
}
TrgFilesTreeView *trg_files_tree_view_new(TrgFilesModel * model,
- TrgMainWindow * win,
- TrgClient * client)
+ TrgMainWindow * win,
+ TrgClient * client)
{
GObject *obj = g_object_new(TRG_TYPE_FILES_TREE_VIEW, NULL);
TrgFilesTreeViewPrivate *priv = TRG_FILES_TREE_VIEW_GET_PRIVATE(obj);
- trg_tree_view_set_prefs(TRG_TREE_VIEW(obj), trg_client_get_prefs(client));
+ trg_tree_view_set_prefs(TRG_TREE_VIEW(obj),
+ trg_client_get_prefs(client));
gtk_tree_view_set_model(GTK_TREE_VIEW(obj), GTK_TREE_MODEL(model));
priv->client = client;
priv->win = win;
diff --git a/src/trg-files-tree-view.h b/src/trg-files-tree-view.h
index 06f83ba..2ab4daf 100644
--- a/src/trg-files-tree-view.h
+++ b/src/trg-files-tree-view.h
@@ -49,8 +49,8 @@ typedef struct {
GType trg_files_tree_view_get_type(void);
TrgFilesTreeView *trg_files_tree_view_new(TrgFilesModel * model,
- TrgMainWindow * win,
- TrgClient * client);
+ TrgMainWindow * win,
+ TrgClient * client);
G_END_DECLS
-#endif /* TRG_FILES_TREE_VIEW_H_ */
+#endif /* TRG_FILES_TREE_VIEW_H_ */
diff --git a/src/trg-general-panel.c b/src/trg-general-panel.c
index f11b0d5..144a12a 100644
--- a/src/trg-general-panel.c
+++ b/src/trg-general-panel.c
@@ -38,8 +38,8 @@
static void gtk_label_clear(GtkLabel * l);
static GtkLabel *gen_panel_label_get_key_label(GtkLabel * l);
static GtkLabel *trg_general_panel_add_label(TrgGeneralPanel * gp,
- char *key, guint col,
- guint row);
+ char *key, guint col,
+ guint row);
G_DEFINE_TYPE(TrgGeneralPanel, trg_general_panel, GTK_TYPE_TABLE)
#define TRG_GENERAL_PANEL_GET_PRIVATE(o) \
@@ -84,7 +84,7 @@ void trg_general_panel_clear(TrgGeneralPanel * panel)
gtk_label_clear(priv->gen_downloaddir_label);
gtk_label_clear(priv->gen_error_label);
gtk_label_clear(gen_panel_label_get_key_label
- (GTK_LABEL(priv->gen_error_label)));
+ (GTK_LABEL(priv->gen_error_label)));
}
static void gtk_label_clear(GtkLabel * l)
@@ -103,7 +103,7 @@ static void trg_general_panel_class_init(TrgGeneralPanelClass * klass)
}
void trg_general_panel_update(TrgGeneralPanel * panel, JsonObject * t,
- GtkTreeIter * iter)
+ GtkTreeIter * iter)
{
TrgGeneralPanelPrivate *priv;
gchar buf[32];
@@ -117,9 +117,9 @@ void trg_general_panel_update(TrgGeneralPanel * panel, JsonObject * t,
priv = TRG_GENERAL_PANEL_GET_PRIVATE(panel);
gtk_tree_model_get(GTK_TREE_MODEL(priv->model), iter,
- TORRENT_COLUMN_SEEDS, &seeders,
- TORRENT_COLUMN_LEECHERS, &leechers,
- TORRENT_COLUMN_STATUS, &statusString, -1);
+ TORRENT_COLUMN_SEEDS, &seeders,
+ TORRENT_COLUMN_LEECHERS, &leechers,
+ TORRENT_COLUMN_STATUS, &statusString, -1);
sizeOfBuf = sizeof(buf);
@@ -141,15 +141,17 @@ void trg_general_panel_update(TrgGeneralPanel * panel, JsonObject * t,
gtk_label_set_text(GTK_LABEL(priv->gen_downloaded_label), buf);
if (uploaded > 0 && downloaded > 0) {
- trg_strlratio(buf, (double) uploaded / (double) downloaded);
- gtk_label_set_text(GTK_LABEL(priv->gen_ratio_label), buf);
+ trg_strlratio(buf, (double) uploaded / (double) downloaded);
+ gtk_label_set_text(GTK_LABEL(priv->gen_ratio_label), buf);
} else {
- gtk_label_set_text(GTK_LABEL(priv->gen_ratio_label), _("N/A"));
+ gtk_label_set_text(GTK_LABEL(priv->gen_ratio_label), _("N/A"));
}
fullStatusString = g_strdup_printf("%s %s", statusString,
- torrent_get_is_private(t) ? _("(Private)") : _("(Public)"));
- gtk_label_set_text(GTK_LABEL(priv->gen_status_label), fullStatusString);
+ torrent_get_is_private(t) ?
+ _("(Private)") : _("(Public)"));
+ gtk_label_set_text(GTK_LABEL(priv->gen_status_label),
+ fullStatusString);
g_free(fullStatusString);
g_free(statusString);
@@ -157,37 +159,37 @@ void trg_general_panel_update(TrgGeneralPanel * panel, JsonObject * t,
gtk_label_set_text(GTK_LABEL(priv->gen_completed_label), buf);
gtk_label_set_text(GTK_LABEL(priv->gen_name_label),
- torrent_get_name(t));
+ torrent_get_name(t));
gtk_label_set_text(GTK_LABEL(priv->gen_downloaddir_label),
- torrent_get_download_dir(t));
+ torrent_get_download_dir(t));
errorStr = torrent_get_errorstr(t);
keyLabel =
- gen_panel_label_get_key_label(GTK_LABEL(priv->gen_error_label));
+ gen_panel_label_get_key_label(GTK_LABEL(priv->gen_error_label));
if (strlen(errorStr) > 0) {
- gchar *markup =
- g_markup_printf_escaped("<span fgcolor=\"red\">%s</span>",
- errorStr);
- gtk_label_set_markup(GTK_LABEL(priv->gen_error_label), markup);
- g_free(markup);
-
- markup =
- g_markup_printf_escaped
- ("<span font_weight=\"bold\" fgcolor=\"red\">%s</span>",
- _("Error"));
- gtk_label_set_markup(keyLabel, markup);
- g_free(markup);
+ gchar *markup =
+ g_markup_printf_escaped("<span fgcolor=\"red\">%s</span>",
+ errorStr);
+ gtk_label_set_markup(GTK_LABEL(priv->gen_error_label), markup);
+ g_free(markup);
+
+ markup =
+ g_markup_printf_escaped
+ ("<span font_weight=\"bold\" fgcolor=\"red\">%s</span>",
+ _("Error"));
+ gtk_label_set_markup(keyLabel, markup);
+ g_free(markup);
} else {
- gtk_label_clear(GTK_LABEL(priv->gen_error_label));
- gtk_label_clear(keyLabel);
+ gtk_label_clear(GTK_LABEL(priv->gen_error_label));
+ gtk_label_clear(keyLabel);
}
if ((eta = torrent_get_eta(t)) > 0) {
- tr_strltime_long(buf, eta, sizeOfBuf);
- gtk_label_set_text(GTK_LABEL(priv->gen_eta_label), buf);
+ tr_strltime_long(buf, eta, sizeOfBuf);
+ gtk_label_set_text(GTK_LABEL(priv->gen_eta_label), buf);
} else {
- gtk_label_set_text(GTK_LABEL(priv->gen_eta_label), _("N/A"));
+ gtk_label_set_text(GTK_LABEL(priv->gen_eta_label), _("N/A"));
}
snprintf(buf, sizeof(buf), "%d", seeders >= 0 ? seeders : 0);
@@ -197,10 +199,10 @@ void trg_general_panel_update(TrgGeneralPanel * panel, JsonObject * t,
}
static GtkLabel *trg_general_panel_add_label_with_width(TrgGeneralPanel *
- gp, char *key,
- guint col,
- guint row,
- gint width)
+ gp, char *key,
+ guint col,
+ guint row,
+ gint width)
{
GtkWidget *value, *keyLabel, *alignment;
@@ -209,16 +211,16 @@ static GtkLabel *trg_general_panel_add_label_with_width(TrgGeneralPanel *
alignment = gtk_alignment_new(0, 0, 0, 0);
keyLabel = gtk_label_new(NULL);
if (strlen(key) > 0) {
- gchar *keyMarkup =
- g_markup_printf_escaped(strlen(key) > 0 ? "<b>%s:</b>" : "",
- key);
- gtk_label_set_markup(GTK_LABEL(keyLabel), keyMarkup);
- g_free(keyMarkup);
+ gchar *keyMarkup =
+ g_markup_printf_escaped(strlen(key) > 0 ? "<b>%s:</b>" : "",
+ key);
+ gtk_label_set_markup(GTK_LABEL(keyLabel), keyMarkup);
+ g_free(keyMarkup);
}
gtk_container_add(GTK_CONTAINER(alignment), keyLabel);
gtk_table_attach(GTK_TABLE(gp), alignment, startCol, startCol + 1, row,
- row + 1, GTK_FILL, 0, TRG_GENERAL_PANEL_SPACING_X,
- TRG_GENERAL_PANEL_SPACING_Y);
+ row + 1, GTK_FILL, 0, TRG_GENERAL_PANEL_SPACING_X,
+ TRG_GENERAL_PANEL_SPACING_Y);
alignment = gtk_alignment_new(0, 0, 0, 0);
value = gtk_label_new(NULL);
@@ -226,18 +228,18 @@ static GtkLabel *trg_general_panel_add_label_with_width(TrgGeneralPanel *
gtk_label_set_selectable(GTK_LABEL(value), TRUE);
gtk_container_add(GTK_CONTAINER(alignment), value);
gtk_table_attach(GTK_TABLE(gp), alignment, startCol + 1,
- width <
- 0 ? TRG_GENERAL_PANEL_COLUMNS_TOTAL - 1 : startCol +
- 1 + width, row, row + 1, GTK_FILL | GTK_SHRINK, 0,
- TRG_GENERAL_PANEL_SPACING_X,
- TRG_GENERAL_PANEL_SPACING_Y);
+ width <
+ 0 ? TRG_GENERAL_PANEL_COLUMNS_TOTAL - 1 : startCol +
+ 1 + width, row, row + 1, GTK_FILL | GTK_SHRINK, 0,
+ TRG_GENERAL_PANEL_SPACING_X,
+ TRG_GENERAL_PANEL_SPACING_Y);
return GTK_LABEL(value);
}
static GtkLabel *trg_general_panel_add_label(TrgGeneralPanel * gp,
- char *key, guint col,
- guint row)
+ char *key, guint col,
+ guint row)
{
return trg_general_panel_add_label_with_width(gp, key, col, row, 1);
}
@@ -248,54 +250,55 @@ static void trg_general_panel_init(TrgGeneralPanel * self)
int i;
g_object_set(G_OBJECT(self), "n-columns",
- TRG_GENERAL_PANEL_COLUMNS_TOTAL, "n-rows", 7, NULL);
+ TRG_GENERAL_PANEL_COLUMNS_TOTAL, "n-rows", 7, NULL);
priv->gen_name_label =
- trg_general_panel_add_label_with_width(self, _("Name"), 0, 0, -1);
+ trg_general_panel_add_label_with_width(self, _("Name"), 0, 0, -1);
priv->gen_size_label =
- trg_general_panel_add_label(self, _("Size"), 0, 1);
+ trg_general_panel_add_label(self, _("Size"), 0, 1);
priv->gen_eta_label =
- trg_general_panel_add_label(self, _("ETA"), 1, 1);
+ trg_general_panel_add_label(self, _("ETA"), 1, 1);
priv->gen_completed_label =
- trg_general_panel_add_label(self, _("Completed"), 2, 1);
+ trg_general_panel_add_label(self, _("Completed"), 2, 1);
priv->gen_seeders_label =
- trg_general_panel_add_label(self, _("Seeders"), 0, 2);
+ trg_general_panel_add_label(self, _("Seeders"), 0, 2);
priv->gen_down_rate_label =
- trg_general_panel_add_label(self, _("Rate Down"), 1, 2);
+ trg_general_panel_add_label(self, _("Rate Down"), 1, 2);
priv->gen_downloaded_label =
- trg_general_panel_add_label(self, _("Downloaded"), 2, 2);
+ trg_general_panel_add_label(self, _("Downloaded"), 2, 2);
priv->gen_leechers_label =
- trg_general_panel_add_label(self, _("Leechers"), 0, 3);
+ trg_general_panel_add_label(self, _("Leechers"), 0, 3);
priv->gen_up_rate_label =
- trg_general_panel_add_label(self, _("Rate Up"), 1, 3);
+ trg_general_panel_add_label(self, _("Rate Up"), 1, 3);
priv->gen_uploaded_label =
- trg_general_panel_add_label(self, _("Uploaded"), 2, 3);
+ trg_general_panel_add_label(self, _("Uploaded"), 2, 3);
priv->gen_status_label =
- trg_general_panel_add_label(self, _("Status"), 0, 4);
+ trg_general_panel_add_label(self, _("Status"), 0, 4);
priv->gen_ratio_label =
- trg_general_panel_add_label(self, _("Ratio"), 1, 4);
+ trg_general_panel_add_label(self, _("Ratio"), 1, 4);
priv->gen_downloaddir_label =
- trg_general_panel_add_label_with_width(self, _("Location"), 0, 5,
- -1);
+ trg_general_panel_add_label_with_width(self, _("Location"), 0, 5,
+ -1);
priv->gen_error_label =
- trg_general_panel_add_label_with_width(self, "", 0, 6, -1);
+ trg_general_panel_add_label_with_width(self, "", 0, 6, -1);
for (i = 0; i < TRG_GENERAL_PANEL_COLUMNS_TOTAL; i++)
- gtk_table_set_col_spacing(GTK_TABLE(self), i,
- i % 2 ==
- 0 ? TRG_GENERAL_PANEL_WIDTH_FROM_KEY :
- TRG_GENERAL_PANEL_WIDTH_FROM_VALUE);
+ gtk_table_set_col_spacing(GTK_TABLE(self), i,
+ i % 2 ==
+ 0 ? TRG_GENERAL_PANEL_WIDTH_FROM_KEY :
+ TRG_GENERAL_PANEL_WIDTH_FROM_VALUE);
gtk_widget_set_sensitive(GTK_WIDGET(self), FALSE);
}
-TrgGeneralPanel *trg_general_panel_new(GtkTreeModel * model, TrgClient *tc)
+TrgGeneralPanel *trg_general_panel_new(GtkTreeModel * model,
+ TrgClient * tc)
{
GObject *obj;
TrgGeneralPanelPrivate *priv;
diff --git a/src/trg-general-panel.h b/src/trg-general-panel.h
index 31abb50..ab7e2d3 100644
--- a/src/trg-general-panel.h
+++ b/src/trg-general-panel.h
@@ -50,11 +50,12 @@ typedef struct {
GType trg_general_panel_get_type(void);
-TrgGeneralPanel *trg_general_panel_new(GtkTreeModel * model, TrgClient *tc);
+TrgGeneralPanel *trg_general_panel_new(GtkTreeModel * model,
+ TrgClient * tc);
G_END_DECLS
void trg_general_panel_update(TrgGeneralPanel * panel, JsonObject * t,
- GtkTreeIter * iter);
+ GtkTreeIter * iter);
void trg_general_panel_clear(TrgGeneralPanel * panel);
-#endif /* TRG_GENERAL_PANEL_H_ */
+#endif /* TRG_GENERAL_PANEL_H_ */
diff --git a/src/trg-json-widgets.c b/src/trg-json-widgets.c
index b412c12..64cc757 100644
--- a/src/trg-json-widgets.c
+++ b/src/trg-json-widgets.c
@@ -31,27 +31,26 @@
* pointers for load/save.
*/
-void trg_json_widgets_save(GList *list, JsonObject *out)
+void trg_json_widgets_save(GList * list, JsonObject * out)
{
GList *li;
- for (li = list; li; li = g_list_next(li))
- {
- trg_json_widget_desc *wd = (trg_json_widget_desc*)li->data;
- wd->saveFunc(wd->widget, out, wd->key);
+ for (li = list; li; li = g_list_next(li)) {
+ trg_json_widget_desc *wd = (trg_json_widget_desc *) li->data;
+ wd->saveFunc(wd->widget, out, wd->key);
}
}
-void trg_json_widget_desc_free(trg_json_widget_desc *wd)
+void trg_json_widget_desc_free(trg_json_widget_desc * wd)
{
g_free(wd->key);
g_free(wd);
}
-void trg_json_widget_desc_list_free(GList *list)
+void trg_json_widget_desc_list_free(GList * list)
{
GList *li;
for (li = list; li; li = g_list_next(li))
- trg_json_widget_desc_free((trg_json_widget_desc*)li->data);
+ trg_json_widget_desc_free((trg_json_widget_desc *) li->data);
g_list_free(list);
}
@@ -59,10 +58,13 @@ void trg_json_widget_desc_list_free(GList *list)
void toggle_active_arg_is_sensitive(GtkToggleButton * b, gpointer data)
{
gtk_widget_set_sensitive(GTK_WIDGET(data),
- gtk_toggle_button_get_active(b));
+ gtk_toggle_button_get_active(b));
}
-GtkWidget *trg_json_widget_check_new(GList **wl, JsonObject *obj, const gchar *key, const gchar *label, GtkWidget *toggleDep)
+GtkWidget *trg_json_widget_check_new(GList ** wl, JsonObject * obj,
+ const gchar * key,
+ const gchar * label,
+ GtkWidget * toggleDep)
{
GtkWidget *w = gtk_check_button_new_with_mnemonic(label);
trg_json_widget_desc *wd = g_new0(trg_json_widget_desc, 1);
@@ -72,19 +74,24 @@ GtkWidget *trg_json_widget_check_new(GList **wl, JsonObject *obj, const gchar *k
wd->widget = w;
if (toggleDep) {
- gtk_widget_set_sensitive(w, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggleDep)));
- g_signal_connect(G_OBJECT(toggleDep), "toggled",
- G_CALLBACK(toggle_active_arg_is_sensitive), w);
+ gtk_widget_set_sensitive(w,
+ gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON(toggleDep)));
+ g_signal_connect(G_OBJECT(toggleDep), "toggled",
+ G_CALLBACK(toggle_active_arg_is_sensitive), w);
}
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), json_object_get_boolean_member(obj, key));
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
+ json_object_get_boolean_member(obj, key));
*wl = g_list_append(*wl, wd);
return w;
}
-GtkWidget *trg_json_widget_entry_new(GList **wl, JsonObject *obj, const gchar *key, GtkWidget *toggleDep)
+GtkWidget *trg_json_widget_entry_new(GList ** wl, JsonObject * obj,
+ const gchar * key,
+ GtkWidget * toggleDep)
{
GtkWidget *w = gtk_entry_new();
trg_json_widget_desc *wd = g_new0(trg_json_widget_desc, 1);
@@ -94,76 +101,105 @@ GtkWidget *trg_json_widget_entry_new(GList **wl, JsonObject *obj, const gchar *k
wd->widget = w;
if (toggleDep) {
- gtk_widget_set_sensitive(w, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggleDep)));
- g_signal_connect(G_OBJECT(toggleDep), "toggled",
- G_CALLBACK(toggle_active_arg_is_sensitive), w);
+ gtk_widget_set_sensitive(w,
+ gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON(toggleDep)));
+ g_signal_connect(G_OBJECT(toggleDep), "toggled",
+ G_CALLBACK(toggle_active_arg_is_sensitive), w);
}
- gtk_entry_set_text(GTK_ENTRY(w), json_object_get_string_member(obj, key));
+ gtk_entry_set_text(GTK_ENTRY(w),
+ json_object_get_string_member(obj, key));
*wl = g_list_append(*wl, wd);
return w;
}
-static GtkWidget *trg_json_widget_spin_common_new(GList **wl, JsonObject *obj,
- const gchar *key, GtkWidget *toggleDep, trg_json_widget_spin_type type, gint min,
- gint max, gdouble step)
+static GtkWidget *trg_json_widget_spin_common_new(GList ** wl,
+ JsonObject * obj,
+ const gchar * key,
+ GtkWidget * toggleDep,
+ trg_json_widget_spin_type
+ type, gint min, gint max,
+ gdouble step)
{
GtkWidget *w = gtk_spin_button_new_with_range(min, max, step);
trg_json_widget_desc *wd = g_new0(trg_json_widget_desc, 1);
JsonNode *node = json_object_get_member(obj, key);
if (type == TRG_JSON_WIDGET_SPIN_DOUBLE)
- wd->saveFunc = trg_json_widget_spin_save_double;
+ wd->saveFunc = trg_json_widget_spin_save_double;
else
- wd->saveFunc = trg_json_widget_spin_save_int;
+ wd->saveFunc = trg_json_widget_spin_save_int;
wd->key = g_strdup(key);
wd->widget = w;
if (toggleDep) {
- gtk_widget_set_sensitive(w, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggleDep)));
- g_signal_connect(G_OBJECT(toggleDep), "toggled",
- G_CALLBACK(toggle_active_arg_is_sensitive), w);
+ gtk_widget_set_sensitive(w,
+ gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON(toggleDep)));
+ g_signal_connect(G_OBJECT(toggleDep), "toggled",
+ G_CALLBACK(toggle_active_arg_is_sensitive), w);
}
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), json_node_really_get_double(node));
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
+ json_node_really_get_double(node));
*wl = g_list_append(*wl, wd);
return w;
}
-GtkWidget *trg_json_widget_spin_new_int(GList **wl, JsonObject *obj, const gchar *key, GtkWidget *toggleDep,
- gint min, gint max, gint step)
+GtkWidget *trg_json_widget_spin_new_int(GList ** wl, JsonObject * obj,
+ const gchar * key,
+ GtkWidget * toggleDep, gint min,
+ gint max, gint step)
{
- return trg_json_widget_spin_common_new(wl, obj, key, toggleDep, TRG_JSON_WIDGET_SPIN_INT, min, max, (gdouble)step);
+ return trg_json_widget_spin_common_new(wl, obj, key, toggleDep,
+ TRG_JSON_WIDGET_SPIN_INT, min,
+ max, (gdouble) step);
}
-GtkWidget *trg_json_widget_spin_new_double(GList **wl, JsonObject *obj, const gchar *key, GtkWidget *toggleDep,
- gint min, gint max, gdouble step)
+GtkWidget *trg_json_widget_spin_new_double(GList ** wl, JsonObject * obj,
+ const gchar * key,
+ GtkWidget * toggleDep, gint min,
+ gint max, gdouble step)
{
- return trg_json_widget_spin_common_new(wl, obj, key, toggleDep, TRG_JSON_WIDGET_SPIN_DOUBLE, min, max, step);
+ return trg_json_widget_spin_common_new(wl, obj, key, toggleDep,
+ TRG_JSON_WIDGET_SPIN_DOUBLE,
+ min, max, step);
}
-void trg_json_widget_check_save(GtkWidget *widget, JsonObject *obj, gchar *key)
+void trg_json_widget_check_save(GtkWidget * widget, JsonObject * obj,
+ gchar * key)
{
- gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+ gboolean active =
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
json_object_set_boolean_member(obj, key, active);
}
-void trg_json_widget_entry_save(GtkWidget *widget, JsonObject *obj, gchar *key)
+void trg_json_widget_entry_save(GtkWidget * widget, JsonObject * obj,
+ gchar * key)
{
- json_object_set_string_member(obj, key, gtk_entry_get_text(GTK_ENTRY(widget)));
+ json_object_set_string_member(obj, key,
+ gtk_entry_get_text(GTK_ENTRY(widget)));
}
-void trg_json_widget_spin_save_int(GtkWidget *widget, JsonObject *obj, gchar *key)
+void trg_json_widget_spin_save_int(GtkWidget * widget, JsonObject * obj,
+ gchar * key)
{
- json_object_set_int_member(obj, key, (gint)gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget)));
+ json_object_set_int_member(obj, key,
+ (gint)
+ gtk_spin_button_get_value(GTK_SPIN_BUTTON
+ (widget)));
}
-void trg_json_widget_spin_save_double(GtkWidget *widget, JsonObject *obj, gchar *key)
+void trg_json_widget_spin_save_double(GtkWidget * widget, JsonObject * obj,
+ gchar * key)
{
- json_object_set_double_member(obj, key, gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget)));
+ json_object_set_double_member(obj, key,
+ gtk_spin_button_get_value(GTK_SPIN_BUTTON
+ (widget)));
}
diff --git a/src/trg-json-widgets.h b/src/trg-json-widgets.h
index a82818b..2f53d1e 100644
--- a/src/trg-json-widgets.h
+++ b/src/trg-json-widgets.h
@@ -26,7 +26,7 @@
typedef struct {
GtkWidget *widget;
gchar *key;
- void (*saveFunc)(GtkWidget *widget, JsonObject *obj, gchar *key);
+ void (*saveFunc) (GtkWidget * widget, JsonObject * obj, gchar * key);
} trg_json_widget_desc;
typedef enum {
@@ -36,20 +36,33 @@ typedef enum {
void toggle_active_arg_is_sensitive(GtkToggleButton * b, gpointer data);
-GtkWidget *trg_json_widget_check_new(GList **wl, JsonObject *obj, const gchar *key, const gchar *label, GtkWidget *toggleDep);
-GtkWidget *trg_json_widget_entry_new(GList **wl, JsonObject *obj, const gchar *key, GtkWidget *toggleDep);
-GtkWidget *trg_json_widget_spin_new_int(GList **wl, JsonObject *obj, const gchar *key, GtkWidget *toggleDep,
- gint min, gint max, gint step);
-GtkWidget *trg_json_widget_spin_new_double(GList **wl, JsonObject *obj, const gchar *key, GtkWidget *toggleDep,
- gint min, gint max, gdouble step);
+GtkWidget *trg_json_widget_check_new(GList ** wl, JsonObject * obj,
+ const gchar * key,
+ const gchar * label,
+ GtkWidget * toggleDep);
+GtkWidget *trg_json_widget_entry_new(GList ** wl, JsonObject * obj,
+ const gchar * key,
+ GtkWidget * toggleDep);
+GtkWidget *trg_json_widget_spin_new_int(GList ** wl, JsonObject * obj,
+ const gchar * key,
+ GtkWidget * toggleDep, gint min,
+ gint max, gint step);
+GtkWidget *trg_json_widget_spin_new_double(GList ** wl, JsonObject * obj,
+ const gchar * key,
+ GtkWidget * toggleDep, gint min,
+ gint max, gdouble step);
-void trg_json_widget_check_save(GtkWidget *widget, JsonObject *obj, gchar *key);
-void trg_json_widget_entry_save(GtkWidget *widget, JsonObject *obj, gchar *key);
-void trg_json_widget_spin_save_int(GtkWidget *widget, JsonObject *obj, gchar *key);
-void trg_json_widget_spin_save_double(GtkWidget *widget, JsonObject *obj, gchar *key);
+void trg_json_widget_check_save(GtkWidget * widget, JsonObject * obj,
+ gchar * key);
+void trg_json_widget_entry_save(GtkWidget * widget, JsonObject * obj,
+ gchar * key);
+void trg_json_widget_spin_save_int(GtkWidget * widget, JsonObject * obj,
+ gchar * key);
+void trg_json_widget_spin_save_double(GtkWidget * widget, JsonObject * obj,
+ gchar * key);
-void trg_json_widget_desc_free(trg_json_widget_desc *wd);
-void trg_json_widget_desc_list_free(GList *list);
-void trg_json_widgets_save(GList *list, JsonObject *out);
+void trg_json_widget_desc_free(trg_json_widget_desc * wd);
+void trg_json_widget_desc_list_free(GList * list);
+void trg_json_widgets_save(GList * list, JsonObject * out);
-#endif /* TRG_JSON_WIDGETS_H_ */
+#endif /* TRG_JSON_WIDGETS_H_ */
diff --git a/src/trg-main-window.c b/src/trg-main-window.c
index 95cd703..47c6a9f 100644
--- a/src/trg-main-window.c
+++ b/src/trg-main-window.c
@@ -142,9 +142,9 @@ static void open_about_cb(GtkWidget * w, GtkWindow * parent);
static gboolean trg_torrent_tree_view_visible_func(GtkTreeModel * model,
GtkTreeIter * iter,
gpointer data);
-static TrgTorrentTreeView *
-trg_main_window_torrent_tree_view_new(TrgMainWindow * win,
- GtkTreeModel * model);
+static TrgTorrentTreeView
+ *trg_main_window_torrent_tree_view_new(TrgMainWindow * win,
+ GtkTreeModel * model);
static gboolean trg_dialog_error_handler(TrgMainWindow * win,
trg_response * response);
static gboolean torrent_selection_changed(GtkTreeSelection * selection,
@@ -437,8 +437,7 @@ static void add_url_cb(GtkWidget * w G_GNUC_UNUSED, gpointer data)
TrgMainWindowPrivate *priv = TRG_MAIN_WINDOW_GET_PRIVATE(data);
TrgTorrentAddUrlDialog *dlg = trg_torrent_add_url_dialog_new(win,
- priv->
- client);
+ priv->client);
gtk_widget_show_all(GTK_WIDGET(dlg));
}
@@ -1140,9 +1139,8 @@ static gboolean on_torrent_get(gpointer data, int mode)
update_selected_torrent_notebook(win, mode, priv->selectedTorrentId);
trg_status_bar_update(priv->statusBar, stats, client);
update_whatever_statusicon(win,
- trg_status_bar_get_speed_text(priv->
- statusBar),
- stats);
+ trg_status_bar_get_speed_text
+ (priv->statusBar), stats);
#ifndef TRG_NO_GRAPH
if (priv->graphNotebookIndex >= 0)
@@ -1297,14 +1295,14 @@ void trg_main_window_reload_dir_aliases(TrgMainWindow * win)
{
TrgMainWindowPrivate *priv = TRG_MAIN_WINDOW_GET_PRIVATE(win);
trg_torrent_model_reload_dir_aliases(priv->client,
- GTK_TREE_MODEL(priv->
- torrentModel));
+ GTK_TREE_MODEL
+ (priv->torrentModel));
trg_state_selector_update(priv->stateSelector);
}
static TrgTorrentTreeView
- *trg_main_window_torrent_tree_view_new(TrgMainWindow * win,
- GtkTreeModel * model)
+ * trg_main_window_torrent_tree_view_new(TrgMainWindow * win,
+ GtkTreeModel * model)
{
TrgMainWindowPrivate *priv = TRG_MAIN_WINDOW_GET_PRIVATE(win);
TrgTorrentTreeView *torrentTreeView =
@@ -2394,8 +2392,7 @@ static GObject *trg_main_window_constructor(GType type,
self, NULL);
priv->torrentTreeView = trg_main_window_torrent_tree_view_new(self,
- priv->
- filteredTorrentModel);
+ priv->filteredTorrentModel);
g_signal_connect(priv->torrentTreeView, "key-press-event",
G_CALLBACK(torrent_tv_key_press_event), self);
g_signal_connect(priv->torrentTreeView, "popup-menu",
@@ -2444,8 +2441,7 @@ static GObject *trg_main_window_constructor(GType type,
FALSE, FALSE);
gtk_paned_pack2(GTK_PANED(priv->hpaned), my_scrolledwin_new(GTK_WIDGET
- (priv->
- torrentTreeView)),
+ (priv->torrentTreeView)),
TRUE, TRUE);
g_signal_connect(G_OBJECT(priv->stateSelector),
diff --git a/src/trg-main-window.h b/src/trg-main-window.h
index 4355611..9374c15 100644
--- a/src/trg-main-window.h
+++ b/src/trg-main-window.h
@@ -60,7 +60,7 @@ GType trg_main_window_get_type(void);
gboolean trg_add_from_filename(TrgMainWindow * win, gchar ** uris);
gboolean on_session_set(gpointer data);
gboolean on_generic_interactive_action(gpointer data);
-void auto_connect_if_required(TrgMainWindow * win, gchar **args);
+void auto_connect_if_required(TrgMainWindow * win, gchar ** args);
TrgMainWindow *trg_main_window_new(TrgClient * tc, gboolean minonstart);
void trg_main_window_add_status_icon(TrgMainWindow * win);
void trg_main_window_remove_status_icon(TrgMainWindow * win);
@@ -69,13 +69,14 @@ void trg_main_window_remove_graph(TrgMainWindow * win);
TrgStateSelector *trg_main_window_get_state_selector(TrgMainWindow * win);
gint trg_mw_get_selected_torrent_id(TrgMainWindow * win);
GtkTreeModel *trg_main_window_get_torrent_model(TrgMainWindow * win);
-void trg_main_window_notebook_set_visible(TrgMainWindow *win, gboolean visible);
+void trg_main_window_notebook_set_visible(TrgMainWindow * win,
+ gboolean visible);
void connect_cb(GtkWidget * w, gpointer data);
-void trg_main_window_reload_dir_aliases(TrgMainWindow *win);
+void trg_main_window_reload_dir_aliases(TrgMainWindow * win);
#if !GTK_CHECK_VERSION(2, 21, 1)
#define gdk_drag_context_get_actions(context) context->actions
#endif
G_END_DECLS
-#endif /* MAIN_WINDOW_H_ */
+#endif /* MAIN_WINDOW_H_ */
diff --git a/src/trg-menu-bar.c b/src/trg-menu-bar.c
index 48afbcc..bc1118f 100644
--- a/src/trg-menu-bar.c
+++ b/src/trg-menu-bar.c
@@ -100,7 +100,8 @@ struct _TrgMenuBarPrivate {
TrgMainWindow *main_window;
};
-void trg_menu_bar_set_supports_queues(TrgMenuBar *mb, gboolean supportsQueues)
+void trg_menu_bar_set_supports_queues(TrgMenuBar * mb,
+ gboolean supportsQueues)
{
TrgMenuBarPrivate *priv = TRG_MENU_BAR_GET_PRIVATE(mb);
@@ -127,7 +128,7 @@ void trg_menu_bar_connected_change(TrgMenuBar * mb, gboolean connected)
}
void trg_menu_bar_torrent_actions_sensitive(TrgMenuBar * mb,
- gboolean sensitive)
+ gboolean sensitive)
{
TrgMenuBarPrivate *priv = TRG_MENU_BAR_GET_PRIVATE(mb);
@@ -147,145 +148,148 @@ void trg_menu_bar_torrent_actions_sensitive(TrgMenuBar * mb,
}
static void trg_menu_bar_set_property(GObject * object,
- guint prop_id, const GValue * value, GParamSpec * pspec G_GNUC_UNUSED) {
+ guint prop_id, const GValue * value,
+ GParamSpec * pspec G_GNUC_UNUSED)
+{
TrgMenuBarPrivate *priv = TRG_MENU_BAR_GET_PRIVATE(object);
switch (prop_id) {
case PROP_PREFS:
- priv->prefs = g_value_get_object(value);
- break;
+ priv->prefs = g_value_get_object(value);
+ break;
case PROP_MAIN_WINDOW:
- priv->main_window = g_value_get_object(value);
- break;
+ priv->main_window = g_value_get_object(value);
+ break;
}
}
static void
trg_menu_bar_get_property(GObject * object, guint property_id,
- GValue * value, GParamSpec * pspec)
+ GValue * value, GParamSpec * pspec)
{
TrgMenuBarPrivate *priv = TRG_MENU_BAR_GET_PRIVATE(object);
switch (property_id) {
case PROP_CONNECT_BUTTON:
- g_value_set_object(value, priv->mb_connect);
- break;
+ g_value_set_object(value, priv->mb_connect);
+ break;
case PROP_DISCONNECT_BUTTON:
- g_value_set_object(value, priv->mb_disconnect);
- break;
+ g_value_set_object(value, priv->mb_disconnect);
+ break;
case PROP_ADD_BUTTON:
- g_value_set_object(value, priv->mb_add);
- break;
+ g_value_set_object(value, priv->mb_add);
+ break;
case PROP_ADD_URL_BUTTON:
- g_value_set_object(value, priv->mb_add_url);
- break;
+ g_value_set_object(value, priv->mb_add_url);
+ break;
case PROP_REMOVE_BUTTON:
- g_value_set_object(value, priv->mb_remove);
- break;
+ g_value_set_object(value, priv->mb_remove);
+ break;
case PROP_DELETE_BUTTON:
- g_value_set_object(value, priv->mb_delete);
- break;
+ g_value_set_object(value, priv->mb_delete);
+ break;
case PROP_MOVE_UP_QUEUE:
- g_value_set_object(value, priv->mb_up_queue);
- break;
+ g_value_set_object(value, priv->mb_up_queue);
+ break;
case PROP_MOVE_DOWN_QUEUE:
- g_value_set_object(value, priv->mb_down_queue);
- break;
+ g_value_set_object(value, priv->mb_down_queue);
+ break;
case PROP_MOVE_TOP_QUEUE:
- g_value_set_object(value, priv->mb_top_queue);
- break;
+ g_value_set_object(value, priv->mb_top_queue);
+ break;
case PROP_MOVE_BOTTOM_QUEUE:
- g_value_set_object(value, priv->mb_bottom_queue);
- break;
+ g_value_set_object(value, priv->mb_bottom_queue);
+ break;
case PROP_START_NOW:
- g_value_set_object(value, priv->mb_start_now);
- break;
+ g_value_set_object(value, priv->mb_start_now);
+ break;
case PROP_MOVE_BUTTON:
- g_value_set_object(value, priv->mb_move);
- break;
+ g_value_set_object(value, priv->mb_move);
+ break;
case PROP_RESUME_BUTTON:
- g_value_set_object(value, priv->mb_resume);
- break;
+ g_value_set_object(value, priv->mb_resume);
+ break;
case PROP_RESUME_ALL_BUTTON:
- g_value_set_object(value, priv->mb_resume_all);
- break;
+ g_value_set_object(value, priv->mb_resume_all);
+ break;
case PROP_PAUSE_BUTTON:
- g_value_set_object(value, priv->mb_pause);
- break;
+ g_value_set_object(value, priv->mb_pause);
+ break;
case PROP_PAUSE_ALL_BUTTON:
- g_value_set_object(value, priv->mb_pause_all);
- break;
+ g_value_set_object(value, priv->mb_pause_all);
+ break;
case PROP_VERIFY_BUTTON:
- g_value_set_object(value, priv->mb_verify);
- break;
+ g_value_set_object(value, priv->mb_verify);
+ break;
case PROP_REANNOUNCE_BUTTON:
- g_value_set_object(value, priv->mb_reannounce);
- break;
+ g_value_set_object(value, priv->mb_reannounce);
+ break;
case PROP_PROPS_BUTTON:
- g_value_set_object(value, priv->mb_props);
- break;
+ g_value_set_object(value, priv->mb_props);
+ break;
case PROP_REMOTE_PREFS_BUTTON:
- g_value_set_object(value, priv->mb_remote_prefs);
- break;
+ g_value_set_object(value, priv->mb_remote_prefs);
+ break;
case PROP_LOCAL_PREFS_BUTTON:
- g_value_set_object(value, priv->mb_local_prefs);
- break;
+ g_value_set_object(value, priv->mb_local_prefs);
+ break;
case PROP_ABOUT_BUTTON:
- g_value_set_object(value, priv->mb_about);
- break;
+ g_value_set_object(value, priv->mb_about);
+ break;
case PROP_VIEW_SHOW_GRAPH:
- g_value_set_object(value, priv->mb_view_graph);
- break;
+ g_value_set_object(value, priv->mb_view_graph);
+ break;
case PROP_VIEW_STATES_BUTTON:
- g_value_set_object(value, priv->mb_view_states);
- break;
+ g_value_set_object(value, priv->mb_view_states);
+ break;
case PROP_VIEW_NOTEBOOK_BUTTON:
- g_value_set_object(value, priv->mb_view_notebook);
- break;
+ g_value_set_object(value, priv->mb_view_notebook);
+ break;
case PROP_VIEW_STATS_BUTTON:
- g_value_set_object(value, priv->mb_view_stats);
- break;
+ g_value_set_object(value, priv->mb_view_stats);
+ break;
case PROP_QUIT:
- g_value_set_object(value, priv->mb_quit);
- break;
+ g_value_set_object(value, priv->mb_quit);
+ break;
case PROP_DIR_FILTERS:
- g_value_set_object(value, priv->mb_directory_filters);
- break;
+ g_value_set_object(value, priv->mb_directory_filters);
+ break;
case PROP_TRACKER_FILTERS:
- g_value_set_object(value, priv->mb_tracker_filters);
- break;
+ g_value_set_object(value, priv->mb_tracker_filters);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
static void
trg_menu_bar_install_widget_prop(GObjectClass * class, guint propId,
- const gchar * name, const gchar * nick)
+ const gchar * name, const gchar * nick)
{
g_object_class_install_property(class,
- propId,
- g_param_spec_object(name,
- nick,
- nick,
- GTK_TYPE_WIDGET,
- G_PARAM_READABLE
- |
- G_PARAM_STATIC_NAME
- |
- G_PARAM_STATIC_NICK
- |
- G_PARAM_STATIC_BLURB));
+ propId,
+ g_param_spec_object(name,
+ nick,
+ nick,
+ GTK_TYPE_WIDGET,
+ G_PARAM_READABLE
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
}
-GtkWidget *trg_menu_bar_item_new(GtkMenuShell * shell, const gchar *text,
- const gchar *stock_id, gboolean sensitive)
+GtkWidget *trg_menu_bar_item_new(GtkMenuShell * shell, const gchar * text,
+ const gchar * stock_id,
+ gboolean sensitive)
{
GtkWidget *item = gtk_image_menu_item_new_with_label(stock_id);
gtk_image_menu_item_set_use_stock(GTK_IMAGE_MENU_ITEM(item), TRUE);
gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM
- (item), TRUE);
+ (item), TRUE);
gtk_menu_item_set_use_underline(GTK_MENU_ITEM(item), TRUE);
gtk_menu_item_set_label(GTK_MENU_ITEM(item), text);
gtk_widget_set_sensitive(item, sensitive);
@@ -298,41 +302,56 @@ GtkWidget *trg_menu_bar_item_new(GtkMenuShell * shell, const gchar *text,
static void view_menu_item_toggled_cb(GtkCheckMenuItem * w, gpointer data)
{
TrgPrefs *p = TRG_PREFS(data);
- gchar *key = (gchar*)g_object_get_data(G_OBJECT(w), G_DATAKEY_CONF_KEY);
- trg_prefs_set_bool(p, key, gtk_check_menu_item_get_active(w), TRG_PREFS_GLOBAL);
+ gchar *key =
+ (gchar *) g_object_get_data(G_OBJECT(w), G_DATAKEY_CONF_KEY);
+ trg_prefs_set_bool(p, key, gtk_check_menu_item_get_active(w),
+ TRG_PREFS_GLOBAL);
}
-static void view_menu_bar_toggled_dependency_cb(GtkCheckMenuItem *w, gpointer data)
+static void view_menu_bar_toggled_dependency_cb(GtkCheckMenuItem * w,
+ gpointer data)
{
- gtk_widget_set_sensitive(GTK_WIDGET(data), gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)));
+ gtk_widget_set_sensitive(GTK_WIDGET(data),
+ gtk_check_menu_item_get_active
+ (GTK_CHECK_MENU_ITEM(w)));
}
-static void trg_menu_bar_view_item_update(TrgPrefs *p, gchar *updatedKey, gpointer data)
+static void trg_menu_bar_view_item_update(TrgPrefs * p, gchar * updatedKey,
+ gpointer data)
{
- gchar *key = (gchar*)g_object_get_data(G_OBJECT(data), G_DATAKEY_CONF_KEY);
+ gchar *key =
+ (gchar *) g_object_get_data(G_OBJECT(data), G_DATAKEY_CONF_KEY);
if (!g_strcmp0(updatedKey, key))
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(data) , trg_prefs_get_bool(p, key, TRG_PREFS_GLOBAL));
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(data),
+ trg_prefs_get_bool(p, key,
+ TRG_PREFS_GLOBAL));
}
-static GtkWidget *trg_menu_bar_view_item_new(TrgPrefs *prefs, gchar *key,
- gchar *label, GtkWidget *dependency)
+static GtkWidget *trg_menu_bar_view_item_new(TrgPrefs * prefs, gchar * key,
+ gchar * label,
+ GtkWidget * dependency)
{
GtkWidget *w = gtk_check_menu_item_new_with_label(label);
g_object_set_data_full(G_OBJECT(w), G_DATAKEY_CONF_KEY, g_strdup(key),
- g_free);
+ g_free);
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w) , trg_prefs_get_bool(prefs, key, TRG_PREFS_GLOBAL));
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
+ trg_prefs_get_bool(prefs, key,
+ TRG_PREFS_GLOBAL));
if (dependency) {
- gtk_widget_set_sensitive(w, gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(dependency)));
- g_signal_connect(dependency, "toggled",
- G_CALLBACK(view_menu_bar_toggled_dependency_cb), w);
+ gtk_widget_set_sensitive(w,
+ gtk_check_menu_item_get_active
+ (GTK_CHECK_MENU_ITEM(dependency)));
+ g_signal_connect(dependency, "toggled",
+ G_CALLBACK(view_menu_bar_toggled_dependency_cb),
+ w);
}
g_signal_connect(w, "toggled",
- G_CALLBACK(view_menu_item_toggled_cb), prefs);
+ G_CALLBACK(view_menu_item_toggled_cb), prefs);
g_signal_connect(prefs, "pref-changed",
- G_CALLBACK(trg_menu_bar_view_item_update), w);
+ G_CALLBACK(trg_menu_bar_view_item_update), w);
return w;
}
@@ -345,27 +364,41 @@ static GtkWidget *trg_menu_bar_view_menu_new(TrgMenuBar * mb)
GtkWidget *viewMenu = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), viewMenu);
- priv->mb_view_states = trg_menu_bar_view_item_new(priv->prefs, TRG_PREFS_KEY_SHOW_STATE_SELECTOR, _("State selector"), NULL);
+ priv->mb_view_states =
+ trg_menu_bar_view_item_new(priv->prefs,
+ TRG_PREFS_KEY_SHOW_STATE_SELECTOR,
+ _("State selector"), NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(viewMenu), priv->mb_view_states);
- priv->mb_directory_filters = trg_menu_bar_view_item_new(priv->prefs, TRG_PREFS_KEY_FILTER_DIRS, _("Directory filters"), priv->mb_view_states);
+ priv->mb_directory_filters =
+ trg_menu_bar_view_item_new(priv->prefs, TRG_PREFS_KEY_FILTER_DIRS,
+ _("Directory filters"),
+ priv->mb_view_states);
gtk_menu_shell_append(GTK_MENU_SHELL(viewMenu),
- priv->mb_directory_filters);
+ priv->mb_directory_filters);
- priv->mb_tracker_filters = trg_menu_bar_view_item_new(priv->prefs, TRG_PREFS_KEY_FILTER_TRACKERS, _("Tracker filters"), priv->mb_view_states);
+ priv->mb_tracker_filters =
+ trg_menu_bar_view_item_new(priv->prefs,
+ TRG_PREFS_KEY_FILTER_TRACKERS,
+ _("Tracker filters"),
+ priv->mb_view_states);
gtk_menu_shell_append(GTK_MENU_SHELL(viewMenu),
- priv->mb_tracker_filters);
+ priv->mb_tracker_filters);
- priv->mb_view_notebook = trg_menu_bar_view_item_new(priv->prefs, TRG_PREFS_KEY_SHOW_NOTEBOOK, _("Torrent Details"), NULL);
+ priv->mb_view_notebook =
+ trg_menu_bar_view_item_new(priv->prefs,
+ TRG_PREFS_KEY_SHOW_NOTEBOOK,
+ _("Torrent Details"), NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(viewMenu),
- priv->mb_view_notebook);
+ priv->mb_view_notebook);
- priv->mb_view_graph = trg_menu_bar_view_item_new(priv->prefs, TRG_PREFS_KEY_SHOW_GRAPH, _("Graph"), priv->mb_view_notebook);
- gtk_menu_shell_append(GTK_MENU_SHELL(viewMenu),
- priv->mb_view_graph);
+ priv->mb_view_graph =
+ trg_menu_bar_view_item_new(priv->prefs, TRG_PREFS_KEY_SHOW_GRAPH,
+ _("Graph"), priv->mb_view_notebook);
+ gtk_menu_shell_append(GTK_MENU_SHELL(viewMenu), priv->mb_view_graph);
priv->mb_view_stats =
- gtk_menu_item_new_with_mnemonic(_("_Statistics"));
+ gtk_menu_item_new_with_mnemonic(_("_Statistics"));
gtk_widget_set_sensitive(priv->mb_view_stats, FALSE);
gtk_menu_shell_append(GTK_MENU_SHELL(viewMenu), priv->mb_view_stats);
@@ -380,28 +413,34 @@ GtkWidget *trg_menu_bar_options_menu_new(TrgMenuBarPrivate * priv)
gtk_menu_item_set_submenu(GTK_MENU_ITEM(opts), optsMenu);
priv->mb_local_prefs =
- trg_menu_bar_item_new(GTK_MENU_SHELL(optsMenu),
- _("_Local Preferences"),
- GTK_STOCK_PREFERENCES, TRUE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(optsMenu),
+ _("_Local Preferences"),
+ GTK_STOCK_PREFERENCES, TRUE);
priv->mb_remote_prefs =
- trg_menu_bar_item_new(GTK_MENU_SHELL(optsMenu),
- _("_Remote Preferences"),
- GTK_STOCK_NETWORK, FALSE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(optsMenu),
+ _("_Remote Preferences"),
+ GTK_STOCK_NETWORK, FALSE);
return opts;
}
-static void trg_menu_bar_file_connect_item_new(TrgMainWindow *win, GtkMenuShell *shell, const gchar *text, gboolean checked, JsonObject *profile)
+static void trg_menu_bar_file_connect_item_new(TrgMainWindow * win,
+ GtkMenuShell * shell,
+ const gchar * text,
+ gboolean checked,
+ JsonObject * profile)
{
GtkWidget *item = gtk_check_menu_item_new_with_label(text);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), checked);
g_object_set_data(G_OBJECT(item), "profile", profile);
- g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(connect_cb), win);
+ g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(connect_cb),
+ win);
gtk_menu_shell_append(shell, item);
}
-GtkWidget *trg_menu_bar_file_connect_menu_new(TrgMainWindow *win, TrgPrefs *p)
+GtkWidget *trg_menu_bar_file_connect_menu_new(TrgMainWindow * win,
+ TrgPrefs * p)
{
GtkWidget *menu = gtk_menu_new();
GList *profiles = json_array_get_elements(trg_prefs_get_profiles(p));
@@ -409,18 +448,20 @@ GtkWidget *trg_menu_bar_file_connect_menu_new(TrgMainWindow *win, TrgPrefs *p)
GList *li;
for (li = profiles; li; li = g_list_next(li)) {
- JsonObject *profile = json_node_get_object((JsonNode*) li->data);
- const gchar *name_value;
-
- if (json_object_has_member(profile, TRG_PREFS_KEY_PROFILE_NAME)) {
- name_value = json_object_get_string_member(profile,
- TRG_PREFS_KEY_PROFILE_NAME);
- } else {
- name_value = _(TRG_PROFILE_NAME_DEFAULT);
- }
-
- trg_menu_bar_file_connect_item_new(win, GTK_MENU_SHELL(menu), name_value,
- profile == currentProfile, profile);
+ JsonObject *profile = json_node_get_object((JsonNode *) li->data);
+ const gchar *name_value;
+
+ if (json_object_has_member(profile, TRG_PREFS_KEY_PROFILE_NAME)) {
+ name_value = json_object_get_string_member(profile,
+ TRG_PREFS_KEY_PROFILE_NAME);
+ } else {
+ name_value = _(TRG_PROFILE_NAME_DEFAULT);
+ }
+
+ trg_menu_bar_file_connect_item_new(win, GTK_MENU_SHELL(menu),
+ name_value,
+ profile == currentProfile,
+ profile);
}
g_list_free(profiles);
@@ -434,26 +475,28 @@ GtkWidget *trg_menu_bar_file_file_menu_new(TrgMenuBarPrivate * priv)
GtkWidget *file = gtk_menu_item_new_with_mnemonic(_("_File"));
GtkWidget *fileMenu = gtk_menu_new();
- GtkWidget *connectMenu = trg_menu_bar_file_connect_menu_new(priv->main_window, priv->prefs);
+ GtkWidget *connectMenu =
+ trg_menu_bar_file_connect_menu_new(priv->main_window, priv->prefs);
priv->mb_connect =
- trg_menu_bar_item_new(GTK_MENU_SHELL(fileMenu), _("Connect"),
- GTK_STOCK_CONNECT, TRUE);
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(priv->mb_connect), connectMenu);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(fileMenu), _("Connect"),
+ GTK_STOCK_CONNECT, TRUE);
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(priv->mb_connect),
+ connectMenu);
priv->mb_disconnect =
- trg_menu_bar_item_new(GTK_MENU_SHELL(fileMenu), _("_Disconnect"),
- GTK_STOCK_DISCONNECT, FALSE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(fileMenu), _("_Disconnect"),
+ GTK_STOCK_DISCONNECT, FALSE);
priv->mb_add =
- trg_menu_bar_item_new(GTK_MENU_SHELL(fileMenu), _("_Add"),
- GTK_STOCK_ADD, FALSE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(fileMenu), _("_Add"),
+ GTK_STOCK_ADD, FALSE);
priv->mb_add_url =
- trg_menu_bar_item_new(GTK_MENU_SHELL(fileMenu), _("Add from _URL"),
- GTK_STOCK_ADD, FALSE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(fileMenu), _("Add from _URL"),
+ GTK_STOCK_ADD, FALSE);
priv->mb_quit =
- trg_menu_bar_item_new(GTK_MENU_SHELL(fileMenu), _("_Quit"),
- GTK_STOCK_QUIT, TRUE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(fileMenu), _("_Quit"),
+ GTK_STOCK_QUIT, TRUE);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), fileMenu);
@@ -468,66 +511,69 @@ GtkWidget *trg_menu_bar_torrent_menu_new(TrgMenuBarPrivate * priv)
gtk_menu_item_set_submenu(GTK_MENU_ITEM(torrent), torrentMenu);
priv->mb_props =
- trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu),
- _("Properties"), GTK_STOCK_PROPERTIES,
- FALSE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu),
+ _("Properties"), GTK_STOCK_PROPERTIES,
+ FALSE);
priv->mb_resume =
- trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu), _("_Resume"),
- GTK_STOCK_MEDIA_PLAY, FALSE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu), _("_Resume"),
+ GTK_STOCK_MEDIA_PLAY, FALSE);
priv->mb_pause =
- trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu), _("_Pause"),
- GTK_STOCK_MEDIA_PAUSE, FALSE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu), _("_Pause"),
+ GTK_STOCK_MEDIA_PAUSE, FALSE);
priv->mb_verify =
- trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu), _("_Verify"),
- GTK_STOCK_REFRESH, FALSE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu), _("_Verify"),
+ GTK_STOCK_REFRESH, FALSE);
priv->mb_reannounce =
- trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu),
- _("Re-_announce"), GTK_STOCK_REFRESH, FALSE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu),
+ _("Re-_announce"), GTK_STOCK_REFRESH, FALSE);
priv->mb_move =
- trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu), _("_Move"),
- GTK_STOCK_HARDDISK, FALSE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu), _("_Move"),
+ GTK_STOCK_HARDDISK, FALSE);
priv->mb_remove =
- trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu), _("Remove"),
- GTK_STOCK_REMOVE, FALSE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu), _("Remove"),
+ GTK_STOCK_REMOVE, FALSE);
priv->mb_delete =
- trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu),
- _("Remove and Delete"), GTK_STOCK_CLEAR,
- FALSE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu),
+ _("Remove and Delete"), GTK_STOCK_CLEAR,
+ FALSE);
priv->mb_queues_seperator = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(torrentMenu),
- priv->mb_queues_seperator);
+ priv->mb_queues_seperator);
priv->mb_start_now = trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu),
- _("Start Now"), GTK_STOCK_MEDIA_PLAY,
- FALSE);
+ _("Start Now"),
+ GTK_STOCK_MEDIA_PLAY,
+ FALSE);
priv->mb_up_queue = trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu),
- _("Move Up Queue"), GTK_STOCK_GO_UP,
- FALSE);
+ _("Move Up Queue"),
+ GTK_STOCK_GO_UP, FALSE);
- priv->mb_down_queue = trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu),
- _("Move Down Queue"), GTK_STOCK_GO_DOWN,
- FALSE);
+ priv->mb_down_queue =
+ trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu),
+ _("Move Down Queue"), GTK_STOCK_GO_DOWN,
+ FALSE);
- priv->mb_bottom_queue = trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu),
- _("Bottom Of Queue"), GTK_STOCK_GOTO_BOTTOM,
- FALSE);
+ priv->mb_bottom_queue =
+ trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu),
+ _("Bottom Of Queue"), GTK_STOCK_GOTO_BOTTOM,
+ FALSE);
priv->mb_top_queue = trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu),
- _("Top Of Queue"), GTK_STOCK_GOTO_TOP,
- FALSE);
+ _("Top Of Queue"),
+ GTK_STOCK_GOTO_TOP, FALSE);
gtk_menu_shell_append(GTK_MENU_SHELL(torrentMenu),
- gtk_separator_menu_item_new());
+ gtk_separator_menu_item_new());
priv->mb_resume_all =
- trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu),
- _("_Resume All"), GTK_STOCK_MEDIA_PLAY,
- FALSE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu),
+ _("_Resume All"), GTK_STOCK_MEDIA_PLAY,
+ FALSE);
priv->mb_pause_all =
- trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu), _("_Pause All"),
- GTK_STOCK_MEDIA_PAUSE, FALSE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu), _("_Pause All"),
+ GTK_STOCK_MEDIA_PAUSE, FALSE);
return torrent;
}
@@ -543,17 +589,19 @@ GtkWidget *trg_menu_bar_help_menu_new(TrgMenuBar * menuBar)
gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), help);
priv->mb_about =
- trg_menu_bar_item_new(GTK_MENU_SHELL(helpMenu), _("_About"),
- GTK_STOCK_ABOUT, TRUE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(helpMenu), _("_About"),
+ GTK_STOCK_ABOUT, TRUE);
return helpMenu;
}
-static void menu_bar_refresh_menu(GtkWidget *w, gpointer data)
+static void menu_bar_refresh_menu(GtkWidget * w, gpointer data)
{
TrgMenuBarPrivate *priv = TRG_MENU_BAR_GET_PRIVATE(data);
- GtkWidget *old = gtk_menu_item_get_submenu(GTK_MENU_ITEM(priv->mb_connect));
- GtkWidget *new = trg_menu_bar_file_connect_menu_new(priv->main_window, priv->prefs);
+ GtkWidget *old =
+ gtk_menu_item_get_submenu(GTK_MENU_ITEM(priv->mb_connect));
+ GtkWidget *new =
+ trg_menu_bar_file_connect_menu_new(priv->main_window, priv->prefs);
gtk_widget_destroy(old);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(priv->mb_connect), new);
@@ -561,26 +609,32 @@ static void menu_bar_refresh_menu(GtkWidget *w, gpointer data)
}
static GObject *trg_menu_bar_constructor(GType type,
- guint n_construct_properties, GObjectConstructParam * construct_params) {
+ guint n_construct_properties,
+ GObjectConstructParam *
+ construct_params)
+{
GObject *object;
TrgMenuBarPrivate *priv;
object = G_OBJECT_CLASS
- (trg_menu_bar_parent_class)->constructor(type,
- n_construct_properties, construct_params);
+ (trg_menu_bar_parent_class)->constructor(type,
+ n_construct_properties,
+ construct_params);
priv = TRG_MENU_BAR_GET_PRIVATE(object);
gtk_menu_shell_append(GTK_MENU_SHELL(object),
- trg_menu_bar_file_file_menu_new(priv));
+ trg_menu_bar_file_file_menu_new(priv));
gtk_menu_shell_append(GTK_MENU_SHELL(object),
- trg_menu_bar_torrent_menu_new(priv));
+ trg_menu_bar_torrent_menu_new(priv));
gtk_menu_shell_append(GTK_MENU_SHELL(object),
- trg_menu_bar_options_menu_new(priv));
+ trg_menu_bar_options_menu_new(priv));
gtk_menu_shell_append(GTK_MENU_SHELL(object),
- trg_menu_bar_view_menu_new(TRG_MENU_BAR(object)));
+ trg_menu_bar_view_menu_new(TRG_MENU_BAR
+ (object)));
trg_menu_bar_help_menu_new(TRG_MENU_BAR(object));
- g_signal_connect(G_OBJECT(priv->prefs), "pref-profile-changed", G_CALLBACK(menu_bar_refresh_menu), object);
+ g_signal_connect(G_OBJECT(priv->prefs), "pref-profile-changed",
+ G_CALLBACK(menu_bar_refresh_menu), object);
return object;
}
@@ -595,103 +649,105 @@ static void trg_menu_bar_class_init(TrgMenuBarClass * klass)
g_type_class_add_private(klass, sizeof(TrgMenuBarPrivate));
trg_menu_bar_install_widget_prop(object_class, PROP_CONNECT_BUTTON,
- "connect-button", "Connect Button");
+ "connect-button", "Connect Button");
trg_menu_bar_install_widget_prop(object_class,
- PROP_DISCONNECT_BUTTON,
- "disconnect-button",
- "Disconnect Button");
+ PROP_DISCONNECT_BUTTON,
+ "disconnect-button",
+ "Disconnect Button");
trg_menu_bar_install_widget_prop(object_class, PROP_ADD_BUTTON,
- "add-button", "Add Button");
+ "add-button", "Add Button");
trg_menu_bar_install_widget_prop(object_class, PROP_ADD_URL_BUTTON,
- "add-url-button", "Add URL Button");
+ "add-url-button", "Add URL Button");
trg_menu_bar_install_widget_prop(object_class, PROP_REMOVE_BUTTON,
- "remove-button", "Remove Button");
+ "remove-button", "Remove Button");
trg_menu_bar_install_widget_prop(object_class, PROP_MOVE_BUTTON,
- "move-button", "Move Button");
+ "move-button", "Move Button");
trg_menu_bar_install_widget_prop(object_class, PROP_DELETE_BUTTON,
- "delete-button", "Delete Button");
+ "delete-button", "Delete Button");
trg_menu_bar_install_widget_prop(object_class, PROP_RESUME_BUTTON,
- "resume-button", "Resume Button");
+ "resume-button", "Resume Button");
trg_menu_bar_install_widget_prop(object_class, PROP_RESUME_ALL_BUTTON,
- "resume-all-button",
- "Resume All Button");
+ "resume-all-button",
+ "Resume All Button");
trg_menu_bar_install_widget_prop(object_class, PROP_VERIFY_BUTTON,
- "verify-button", "Verify Button");
+ "verify-button", "Verify Button");
trg_menu_bar_install_widget_prop(object_class, PROP_REANNOUNCE_BUTTON,
- "reannounce-button",
- "Re-announce Button");
+ "reannounce-button",
+ "Re-announce Button");
trg_menu_bar_install_widget_prop(object_class, PROP_PAUSE_ALL_BUTTON,
- "pause-all-button",
- "Pause All Button");
+ "pause-all-button",
+ "Pause All Button");
trg_menu_bar_install_widget_prop(object_class, PROP_PAUSE_BUTTON,
- "pause-button", "Pause Button");
+ "pause-button", "Pause Button");
trg_menu_bar_install_widget_prop(object_class, PROP_PROPS_BUTTON,
- "props-button", "Props Button");
+ "props-button", "Props Button");
trg_menu_bar_install_widget_prop(object_class, PROP_ABOUT_BUTTON,
- "about-button", "About Button");
+ "about-button", "About Button");
trg_menu_bar_install_widget_prop(object_class, PROP_VIEW_STATS_BUTTON,
- "view-stats-button",
- "View stats button");
+ "view-stats-button",
+ "View stats button");
trg_menu_bar_install_widget_prop(object_class, PROP_VIEW_STATES_BUTTON,
- "view-states-button",
- "View states Button");
+ "view-states-button",
+ "View states Button");
trg_menu_bar_install_widget_prop(object_class,
- PROP_VIEW_NOTEBOOK_BUTTON,
- "view-notebook-button",
- "View notebook Button");
+ PROP_VIEW_NOTEBOOK_BUTTON,
+ "view-notebook-button",
+ "View notebook Button");
trg_menu_bar_install_widget_prop(object_class,
- PROP_REMOTE_PREFS_BUTTON,
- "remote-prefs-button",
- "Remote Prefs Button");
+ PROP_REMOTE_PREFS_BUTTON,
+ "remote-prefs-button",
+ "Remote Prefs Button");
trg_menu_bar_install_widget_prop(object_class, PROP_LOCAL_PREFS_BUTTON,
- "local-prefs-button",
- "Local Prefs Button");
+ "local-prefs-button",
+ "Local Prefs Button");
trg_menu_bar_install_widget_prop(object_class, PROP_QUIT,
- "quit-button", "Quit Button");
+ "quit-button", "Quit Button");
trg_menu_bar_install_widget_prop(object_class, PROP_DIR_FILTERS,
- "dir-filters", "Dir Filters");
+ "dir-filters", "Dir Filters");
trg_menu_bar_install_widget_prop(object_class, PROP_TRACKER_FILTERS,
- "tracker-filters", "Tracker Filters");
+ "tracker-filters", "Tracker Filters");
trg_menu_bar_install_widget_prop(object_class, PROP_VIEW_SHOW_GRAPH,
- "show-graph", "Show Graph");
+ "show-graph", "Show Graph");
trg_menu_bar_install_widget_prop(object_class, PROP_MOVE_DOWN_QUEUE,
- "down-queue", "Down Queue");
+ "down-queue", "Down Queue");
trg_menu_bar_install_widget_prop(object_class, PROP_MOVE_UP_QUEUE,
- "up-queue", "Up Queue");
+ "up-queue", "Up Queue");
trg_menu_bar_install_widget_prop(object_class, PROP_MOVE_BOTTOM_QUEUE,
- "bottom-queue", "Bottom Queue");
+ "bottom-queue", "Bottom Queue");
trg_menu_bar_install_widget_prop(object_class, PROP_MOVE_TOP_QUEUE,
- "top-queue", "Top Queue");
+ "top-queue", "Top Queue");
trg_menu_bar_install_widget_prop(object_class, PROP_START_NOW,
- "start-now", "Start Now");
+ "start-now", "Start Now");
g_object_class_install_property(object_class,
- PROP_PREFS,
- g_param_spec_object("prefs",
- "prefs",
- "Prefs",
- TRG_TYPE_PREFS,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- |
- G_PARAM_STATIC_NAME
- |
- G_PARAM_STATIC_NICK
- |
- G_PARAM_STATIC_BLURB));
+ PROP_PREFS,
+ g_param_spec_object("prefs",
+ "prefs",
+ "Prefs",
+ TRG_TYPE_PREFS,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
g_object_class_install_property(object_class,
- PROP_MAIN_WINDOW,
- g_param_spec_object("mainwin",
- "mainwin",
- "mainwin",
- TRG_TYPE_MAIN_WINDOW,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- |
- G_PARAM_STATIC_NAME
- |
- G_PARAM_STATIC_NICK
- |
- G_PARAM_STATIC_BLURB));
+ PROP_MAIN_WINDOW,
+ g_param_spec_object("mainwin",
+ "mainwin",
+ "mainwin",
+ TRG_TYPE_MAIN_WINDOW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
}
@@ -699,9 +755,8 @@ static void trg_menu_bar_init(TrgMenuBar * self)
{
}
-TrgMenuBar *trg_menu_bar_new(TrgMainWindow *win, TrgPrefs *prefs)
+TrgMenuBar *trg_menu_bar_new(TrgMainWindow * win, TrgPrefs * prefs)
{
return g_object_new(TRG_TYPE_MENU_BAR,
- "prefs", prefs,
- "mainwin", win, NULL);
+ "prefs", prefs, "mainwin", win, NULL);
}
diff --git a/src/trg-menu-bar.h b/src/trg-menu-bar.h
index 720aa35..d8b73f0 100644
--- a/src/trg-menu-bar.h
+++ b/src/trg-menu-bar.h
@@ -48,15 +48,18 @@ typedef struct {
GType trg_menu_bar_get_type(void);
-TrgMenuBar *trg_menu_bar_new(TrgMainWindow *win, TrgPrefs *prefs);
-GtkWidget *trg_menu_bar_item_new(GtkMenuShell * shell, const gchar *text,
- const gchar *stock_id, gboolean sensitive);
+TrgMenuBar *trg_menu_bar_new(TrgMainWindow * win, TrgPrefs * prefs);
+GtkWidget *trg_menu_bar_item_new(GtkMenuShell * shell, const gchar * text,
+ const gchar * stock_id,
+ gboolean sensitive);
G_END_DECLS
void trg_menu_bar_torrent_actions_sensitive(TrgMenuBar * mb,
- gboolean sensitive);
+ gboolean sensitive);
void trg_menu_bar_connected_change(TrgMenuBar * mb, gboolean connected);
-void trg_menu_bar_set_supports_queues(TrgMenuBar *mb, gboolean supportsQueues);
-GtkWidget *trg_menu_bar_file_connect_menu_new(TrgMainWindow *win, TrgPrefs *p);
+void trg_menu_bar_set_supports_queues(TrgMenuBar * mb,
+ gboolean supportsQueues);
+GtkWidget *trg_menu_bar_file_connect_menu_new(TrgMainWindow * win,
+ TrgPrefs * p);
-#endif /* TRG_MENU_BAR_H_ */
+#endif /* TRG_MENU_BAR_H_ */
diff --git a/src/trg-model.c b/src/trg-model.c
index e10c974..75c7016 100644
--- a/src/trg-model.c
+++ b/src/trg-model.c
@@ -34,23 +34,23 @@ struct trg_model_remove_removed_foreachfunc_args {
gboolean
trg_model_remove_removed_foreachfunc(GtkTreeModel * model,
- GtkTreePath * path G_GNUC_UNUSED,
- GtkTreeIter * iter, gpointer data)
+ GtkTreePath * path G_GNUC_UNUSED,
+ GtkTreeIter * iter, gpointer data)
{
struct trg_model_remove_removed_foreachfunc_args *args =
- (struct trg_model_remove_removed_foreachfunc_args *) data;
+ (struct trg_model_remove_removed_foreachfunc_args *) data;
gint64 rowSerial;
gtk_tree_model_get(model, iter, args->serial_column, &rowSerial, -1);
if (rowSerial != args->currentSerial)
- args->toRemove =
- g_list_append(args->toRemove, gtk_tree_iter_copy(iter));
+ args->toRemove =
+ g_list_append(args->toRemove, gtk_tree_iter_copy(iter));
return FALSE;
}
guint
trg_model_remove_removed(GtkListStore * model, gint serial_column,
- gint64 currentSerial)
+ gint64 currentSerial)
{
struct trg_model_remove_removed_foreachfunc_args args;
GList *li;
@@ -60,15 +60,15 @@ trg_model_remove_removed(GtkListStore * model, gint serial_column,
args.currentSerial = currentSerial;
args.serial_column = serial_column;
gtk_tree_model_foreach(GTK_TREE_MODEL(model),
- trg_model_remove_removed_foreachfunc, &args);
+ trg_model_remove_removed_foreachfunc, &args);
if (args.toRemove != NULL) {
- for (li = g_list_last(args.toRemove); li != NULL;
- li = g_list_previous(li)) {
- gtk_list_store_remove(model, (GtkTreeIter *) li->data);
- gtk_tree_iter_free((GtkTreeIter *) li->data);
- removed++;
- }
- g_list_free(args.toRemove);
+ for (li = g_list_last(args.toRemove); li != NULL;
+ li = g_list_previous(li)) {
+ gtk_list_store_remove(model, (GtkTreeIter *) li->data);
+ gtk_tree_iter_free((GtkTreeIter *) li->data);
+ removed++;
+ }
+ g_list_free(args.toRemove);
}
return removed;
@@ -83,17 +83,17 @@ struct find_existing_item_foreach_args {
static gboolean
find_existing_item_foreachfunc(GtkTreeModel * model,
- GtkTreePath * path G_GNUC_UNUSED,
- GtkTreeIter * iter, gpointer data)
+ GtkTreePath * path G_GNUC_UNUSED,
+ GtkTreeIter * iter, gpointer data)
{
struct find_existing_item_foreach_args *args =
- (struct find_existing_item_foreach_args *) data;
+ (struct find_existing_item_foreach_args *) data;
gint64 currentId;
gtk_tree_model_get(model, iter, args->search_column, &currentId, -1);
if (currentId == args->id) {
- args->iter = iter;
- return args->found = TRUE;
+ args->iter = iter;
+ return args->found = TRUE;
}
return FALSE;
@@ -101,7 +101,7 @@ find_existing_item_foreachfunc(GtkTreeModel * model,
gboolean
find_existing_model_item(GtkTreeModel * model, gint search_column,
- gint64 id, GtkTreeIter * iter)
+ gint64 id, GtkTreeIter * iter)
{
struct find_existing_item_foreach_args args;
args.id = id;
@@ -109,6 +109,6 @@ find_existing_model_item(GtkTreeModel * model, gint search_column,
args.search_column = search_column;
gtk_tree_model_foreach(model, find_existing_item_foreachfunc, &args);
if (args.found == TRUE)
- *iter = *(args.iter);
+ *iter = *(args.iter);
return args.found;
}
diff --git a/src/trg-model.h b/src/trg-model.h
index 9059303..da92c2a 100644
--- a/src/trg-model.h
+++ b/src/trg-model.h
@@ -23,10 +23,10 @@
#include <gtk/gtk.h>
guint trg_model_remove_removed(GtkListStore * model, gint serial_column,
- gint64 currentSerial);
+ gint64 currentSerial);
gboolean
find_existing_model_item(GtkTreeModel * model, gint search_column,
- gint64 id, GtkTreeIter * iter);
+ gint64 id, GtkTreeIter * iter);
-#endif /* TRG_MODEL_H_ */
+#endif /* TRG_MODEL_H_ */
diff --git a/src/trg-peers-model.c b/src/trg-peers-model.c
index 6ba7d09..e97eb8b 100644
--- a/src/trg-peers-model.c
+++ b/src/trg-peers-model.c
@@ -49,43 +49,51 @@ struct _TrgPeersModelPrivate {
};
#endif
-static void trg_peers_model_class_init(TrgPeersModelClass * klass G_GNUC_UNUSED) {
+static void trg_peers_model_class_init(TrgPeersModelClass *
+ klass G_GNUC_UNUSED)
+{
#ifdef HAVE_GEOIP
g_type_class_add_private(klass, sizeof(TrgPeersModelPrivate));
#endif
}
gboolean find_existing_peer_item_foreachfunc(GtkTreeModel * model,
- GtkTreePath * path G_GNUC_UNUSED, GtkTreeIter * iter, gpointer data) {
+ GtkTreePath *
+ path G_GNUC_UNUSED,
+ GtkTreeIter * iter,
+ gpointer data)
+{
struct peerAndIter *pi = (struct peerAndIter *) data;
gchar *ip;
gtk_tree_model_get(model, iter, PEERSCOL_IP, &ip, -1);
if (g_strcmp0(ip, pi->ip) == 0) {
- pi->iter = *iter;
- pi->found = TRUE;
+ pi->iter = *iter;
+ pi->found = TRUE;
}
g_free(ip);
return pi->found;
}
gboolean find_existing_peer_item(TrgPeersModel * model, JsonObject * p,
- GtkTreeIter * iter) {
+ GtkTreeIter * iter)
+{
struct peerAndIter pi;
pi.ip = peer_get_address(p);
pi.found = FALSE;
gtk_tree_model_foreach(GTK_TREE_MODEL(model),
- find_existing_peer_item_foreachfunc, &pi);
+ find_existing_peer_item_foreachfunc, &pi);
if (pi.found == TRUE)
- *iter = pi.iter;
+ *iter = pi.iter;
return pi.found;
}
static void resolved_dns_cb(GObject * source_object, GAsyncResult * res,
- gpointer data) {
+ gpointer data)
+{
GtkTreeRowReference *treeRef;
GtkTreeModel *model;
GtkTreePath *path;
@@ -95,32 +103,36 @@ static void resolved_dns_cb(GObject * source_object, GAsyncResult * res,
path = gtk_tree_row_reference_get_path(treeRef);
if (path != NULL) {
- gchar *rdns = g_resolver_lookup_by_address_finish(
- G_RESOLVER(source_object), res, NULL);
- if (rdns != NULL) {
- GtkTreeIter iter;
- if (gtk_tree_model_get_iter(model, &iter, path) == TRUE) {
- gdk_threads_enter();
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, PEERSCOL_HOST,
- rdns, -1);
- gdk_threads_leave();
- }
- g_free(rdns);
- }
- gtk_tree_path_free(path);
+ gchar *rdns =
+ g_resolver_lookup_by_address_finish(G_RESOLVER(source_object),
+ res, NULL);
+ if (rdns != NULL) {
+ GtkTreeIter iter;
+ if (gtk_tree_model_get_iter(model, &iter, path) == TRUE) {
+ gdk_threads_enter();
+ gtk_list_store_set(GTK_LIST_STORE(model), &iter,
+ PEERSCOL_HOST, rdns, -1);
+ gdk_threads_leave();
+ }
+ g_free(rdns);
+ }
+ gtk_tree_path_free(path);
}
gtk_tree_row_reference_free(treeRef);
}
-void trg_peers_model_update(TrgPeersModel * model, TrgTreeView *tv,
- gint64 updateSerial, JsonObject * t, gint mode) {
+void trg_peers_model_update(TrgPeersModel * model, TrgTreeView * tv,
+ gint64 updateSerial, JsonObject * t, gint mode)
+{
#ifdef HAVE_GEOIP
TrgPeersModelPrivate *priv = TRG_PEERS_MODEL_GET_PRIVATE(model);
- gboolean doGeoLookup = trg_tree_view_is_column_showing(tv, PEERSCOL_COUNTRY);
+ gboolean doGeoLookup =
+ trg_tree_view_is_column_showing(tv, PEERSCOL_COUNTRY);
#endif
- gboolean doHostLookup = trg_tree_view_is_column_showing(tv, PEERSCOL_HOST);
+ gboolean doHostLookup =
+ trg_tree_view_is_column_showing(tv, PEERSCOL_HOST);
JsonArray *peers;
GtkTreeIter peerIter;
GList *li, *peersList;
@@ -129,75 +141,83 @@ void trg_peers_model_update(TrgPeersModel * model, TrgTreeView *tv,
peers = torrent_get_peers(t);
if (mode == TORRENT_GET_MODE_FIRST)
- gtk_list_store_clear(GTK_LIST_STORE(model));
+ gtk_list_store_clear(GTK_LIST_STORE(model));
peersList = json_array_get_elements(peers);
for (li = peersList; li; li = g_list_next(li)) {
- JsonObject *peer = json_node_get_object((JsonNode *) li->data);
- const gchar *address = NULL, *flagStr;
+ JsonObject *peer = json_node_get_object((JsonNode *) li->data);
+ const gchar *address = NULL, *flagStr;
#ifdef HAVE_GEOIP
- const gchar *country = NULL;
+ const gchar *country = NULL;
#endif
- if (mode == TORRENT_GET_MODE_FIRST || find_existing_peer_item(model,
- peer, &peerIter) == FALSE) {
- gtk_list_store_append(GTK_LIST_STORE(model), &peerIter);
+ if (mode == TORRENT_GET_MODE_FIRST
+ || find_existing_peer_item(model, peer, &peerIter) == FALSE) {
+ gtk_list_store_append(GTK_LIST_STORE(model), &peerIter);
- address = peer_get_address(peer);
+ address = peer_get_address(peer);
#ifdef HAVE_GEOIP
- if (address && doGeoLookup) { // just in case address wasn't set
- if (strchr(address,':') && priv->geoipv6)
- country = GeoIP_country_name_by_addr_v6(priv->geoipv6, address);
- else if (priv->geoip)
- country = GeoIP_country_name_by_addr(priv->geoip, address);
- }
+ if (address && doGeoLookup) { // just in case address wasn't set
+ if (strchr(address, ':') && priv->geoipv6)
+ country =
+ GeoIP_country_name_by_addr_v6(priv->geoipv6,
+ address);
+ else if (priv->geoip)
+ country =
+ GeoIP_country_name_by_addr(priv->geoip, address);
+ }
#endif
- gtk_list_store_set(GTK_LIST_STORE(model), &peerIter, PEERSCOL_ICON,
- GTK_STOCK_NETWORK, PEERSCOL_IP, address,
+ gtk_list_store_set(GTK_LIST_STORE(model), &peerIter,
+ PEERSCOL_ICON, GTK_STOCK_NETWORK,
+ PEERSCOL_IP, address,
#ifdef HAVE_GEOIP
- PEERSCOL_COUNTRY, country ? country : "",
+ PEERSCOL_COUNTRY, country ? country : "",
#endif
- PEERSCOL_CLIENT, peer_get_client_name(peer), -1);
-
- isNew = TRUE;
- } else {
- isNew = FALSE;
- }
-
- flagStr = peer_get_flagstr(peer);
- gtk_list_store_set(GTK_LIST_STORE(model), &peerIter, PEERSCOL_FLAGS,
- flagStr, PEERSCOL_PROGRESS, peer_get_progress(peer),
- PEERSCOL_DOWNSPEED, peer_get_rate_to_client(peer),
- PEERSCOL_UPSPEED, peer_get_rate_to_peer(peer),
- PEERSCOL_UPDATESERIAL, updateSerial, -1);
-
- if (doHostLookup && isNew == TRUE) {
- GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(model),
- &peerIter);
- GtkTreeRowReference *treeRef = gtk_tree_row_reference_new(
- GTK_TREE_MODEL(model), path);
- GInetAddress *inetAddr;
- GResolver *resolver;
-
- gtk_tree_path_free(path);
-
- inetAddr = g_inet_address_new_from_string(address);
- resolver = g_resolver_get_default();
- g_resolver_lookup_by_address_async(resolver, inetAddr, NULL,
- resolved_dns_cb, treeRef);
- g_object_unref(resolver);
- g_object_unref(inetAddr);
- }
+ PEERSCOL_CLIENT, peer_get_client_name(peer),
+ -1);
+
+ isNew = TRUE;
+ } else {
+ isNew = FALSE;
+ }
+
+ flagStr = peer_get_flagstr(peer);
+ gtk_list_store_set(GTK_LIST_STORE(model), &peerIter,
+ PEERSCOL_FLAGS, flagStr, PEERSCOL_PROGRESS,
+ peer_get_progress(peer), PEERSCOL_DOWNSPEED,
+ peer_get_rate_to_client(peer), PEERSCOL_UPSPEED,
+ peer_get_rate_to_peer(peer),
+ PEERSCOL_UPDATESERIAL, updateSerial, -1);
+
+ if (doHostLookup && isNew == TRUE) {
+ GtkTreePath *path =
+ gtk_tree_model_get_path(GTK_TREE_MODEL(model),
+ &peerIter);
+ GtkTreeRowReference *treeRef =
+ gtk_tree_row_reference_new(GTK_TREE_MODEL(model), path);
+ GInetAddress *inetAddr;
+ GResolver *resolver;
+
+ gtk_tree_path_free(path);
+
+ inetAddr = g_inet_address_new_from_string(address);
+ resolver = g_resolver_get_default();
+ g_resolver_lookup_by_address_async(resolver, inetAddr, NULL,
+ resolved_dns_cb, treeRef);
+ g_object_unref(resolver);
+ g_object_unref(inetAddr);
+ }
}
g_list_free(peersList);
if (mode != TORRENT_GET_MODE_FIRST)
- trg_model_remove_removed(GTK_LIST_STORE(model), PEERSCOL_UPDATESERIAL,
- updateSerial);
+ trg_model_remove_removed(GTK_LIST_STORE(model),
+ PEERSCOL_UPDATESERIAL, updateSerial);
}
-static void trg_peers_model_init(TrgPeersModel * self) {
+static void trg_peers_model_init(TrgPeersModel * self)
+{
#ifdef HAVE_GEOIP
TrgPeersModelPrivate *priv = TRG_PEERS_MODEL_GET_PRIVATE(self);
#endif
@@ -218,18 +238,19 @@ static void trg_peers_model_init(TrgPeersModel * self) {
column_types[PEERSCOL_UPDATESERIAL] = G_TYPE_INT64;
gtk_list_store_set_column_types(GTK_LIST_STORE(self), PEERSCOL_COLUMNS,
- column_types);
+ column_types);
#ifdef HAVE_GEOIP
if (g_file_test(TRG_GEOIP_DATABASE, G_FILE_TEST_EXISTS) == TRUE)
- priv->geoip = GeoIP_open(TRG_GEOIP_DATABASE,
- GEOIP_STANDARD | GEOIP_CHECK_CACHE);
+ priv->geoip = GeoIP_open(TRG_GEOIP_DATABASE,
+ GEOIP_STANDARD | GEOIP_CHECK_CACHE);
if (g_file_test(TRG_GEOIPV6_DATABASE, G_FILE_TEST_EXISTS) == TRUE)
- priv->geoipv6 = GeoIP_open(TRG_GEOIPV6_DATABASE,
- GEOIP_STANDARD | GEOIP_CHECK_CACHE);
+ priv->geoipv6 = GeoIP_open(TRG_GEOIPV6_DATABASE,
+ GEOIP_STANDARD | GEOIP_CHECK_CACHE);
#endif
}
-TrgPeersModel *trg_peers_model_new() {
+TrgPeersModel *trg_peers_model_new()
+{
return g_object_new(TRG_TYPE_PEERS_MODEL, NULL);
}
diff --git a/src/trg-peers-model.h b/src/trg-peers-model.h
index 1544bda..59e9476 100644
--- a/src/trg-peers-model.h
+++ b/src/trg-peers-model.h
@@ -80,10 +80,11 @@ enum {
PEERSCOL_COLUMNS
};
-void trg_peers_model_update(TrgPeersModel * model, TrgTreeView *tv, gint64 updateSerial,
- JsonObject * t, gboolean first);
+void trg_peers_model_update(TrgPeersModel * model, TrgTreeView * tv,
+ gint64 updateSerial, JsonObject * t,
+ gboolean first);
-#endif /* TRG_PEERS_MODEL_H_ */
+#endif /* TRG_PEERS_MODEL_H_ */
#define TRG_GEOIP_DATABASE "/usr/share/GeoIP/GeoIP.dat"
#define TRG_GEOIPV6_DATABASE "/usr/share/GeoIP/GeoIPv6.dat"
diff --git a/src/trg-peers-tree-view.c b/src/trg-peers-tree-view.c
index 7ad0304..9d8381b 100644
--- a/src/trg-peers-tree-view.c
+++ b/src/trg-peers-tree-view.c
@@ -47,32 +47,33 @@ static void trg_peers_tree_view_init(TrgPeersTreeView * self)
trg_column_description *desc;
desc =
- trg_tree_view_reg_column(ttv, TRG_COLTYPE_STOCKICONTEXT, PEERSCOL_IP,
- _("IP"), "ip", 0);
+ trg_tree_view_reg_column(ttv, TRG_COLTYPE_STOCKICONTEXT,
+ PEERSCOL_IP, _("IP"), "ip", 0);
desc->model_column_icon = PEERSCOL_ICON;
trg_tree_view_reg_column(ttv, TRG_COLTYPE_TEXT, PEERSCOL_HOST,
- _("Host"), "host", 0);
+ _("Host"), "host", 0);
#ifdef HAVE_GEOIP
trg_tree_view_reg_column(ttv, TRG_COLTYPE_TEXT, PEERSCOL_COUNTRY,
- _("Country"), "country", 0);
+ _("Country"), "country", 0);
#endif
trg_tree_view_reg_column(ttv, TRG_COLTYPE_SPEED, PEERSCOL_DOWNSPEED,
- _("Down Speed"), "down-speed", 0);
+ _("Down Speed"), "down-speed", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_SPEED, PEERSCOL_UPSPEED,
- _("Up Speed"), "up-speed", 0);
+ _("Up Speed"), "up-speed", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_PROG, PEERSCOL_PROGRESS,
- _("Progress"), "progress", 0);
+ _("Progress"), "progress", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_TEXT, PEERSCOL_FLAGS,
- _("Flags"), "flags", 0);
+ _("Flags"), "flags", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_TEXT, PEERSCOL_CLIENT,
- _("Client"), "client", 0);
+ _("Client"), "client", 0);
gtk_tree_view_set_search_column(GTK_TREE_VIEW(self), PEERSCOL_HOST);
}
-TrgPeersTreeView *trg_peers_tree_view_new(TrgPrefs *prefs, TrgPeersModel * model)
+TrgPeersTreeView *trg_peers_tree_view_new(TrgPrefs * prefs,
+ TrgPeersModel * model)
{
GObject *obj = g_object_new(TRG_TYPE_PEERS_TREE_VIEW, NULL);
trg_tree_view_set_prefs(TRG_TREE_VIEW(obj), prefs);
diff --git a/src/trg-peers-tree-view.h b/src/trg-peers-tree-view.h
index dbd5e03..72d4261 100644
--- a/src/trg-peers-tree-view.h
+++ b/src/trg-peers-tree-view.h
@@ -49,7 +49,8 @@ typedef struct {
GType trg_peers_tree_view_get_type(void);
-TrgPeersTreeView *trg_peers_tree_view_new(TrgPrefs *prefs, TrgPeersModel * model);
+TrgPeersTreeView *trg_peers_tree_view_new(TrgPrefs * prefs,
+ TrgPeersModel * model);
G_END_DECLS
-#endif /* TRG_PEERS_TREE_VIEW_H_ */
+#endif /* TRG_PEERS_TREE_VIEW_H_ */
diff --git a/src/trg-persistent-tree-view.c b/src/trg-persistent-tree-view.c
index a8ce65e..dad8b37 100644
--- a/src/trg-persistent-tree-view.c
+++ b/src/trg-persistent-tree-view.c
@@ -29,11 +29,10 @@
* to add/remove entries as well as the TreeView.
*/
-G_DEFINE_TYPE (TrgPersistentTreeView, trg_persistent_tree_view, GTK_TYPE_VBOX)
-
+G_DEFINE_TYPE(TrgPersistentTreeView, trg_persistent_tree_view,
+ GTK_TYPE_VBOX)
#define GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_PERSISTENT_TREE_VIEW, TrgPersistentTreeViewPrivate))
-
typedef struct _TrgPersistentTreeViewPrivate TrgPersistentTreeViewPrivate;
enum {
@@ -52,31 +51,37 @@ struct _TrgPersistentTreeViewPrivate {
trg_persistent_tree_view_column *addSelect;
};
-static void selection_changed(GtkTreeSelection *selection, gpointer data) {
+static void selection_changed(GtkTreeSelection * selection, gpointer data)
+{
TrgPersistentTreeViewPrivate *priv = GET_PRIVATE(data);
if (gtk_tree_selection_get_selected(selection, NULL, NULL))
- gtk_widget_set_sensitive(priv->delButton, TRUE);
+ gtk_widget_set_sensitive(priv->delButton, TRUE);
else
- gtk_widget_set_sensitive(priv->delButton, FALSE);
+ gtk_widget_set_sensitive(priv->delButton, FALSE);
}
static void trg_persistent_tree_view_edit(GtkCellRendererText * renderer,
- gchar * path, gchar * new_text, gpointer user_data) {
+ gchar * path, gchar * new_text,
+ gpointer user_data)
+{
trg_persistent_tree_view_column *cd =
- (trg_persistent_tree_view_column*) user_data;
+ (trg_persistent_tree_view_column *) user_data;
TrgPersistentTreeViewPrivate *priv = GET_PRIVATE(cd->tv);
GtkTreeModel *model = gtk_tree_view_get_model(priv->tv);
GtkTreeIter iter;
gtk_tree_model_get_iter_from_string(model, &iter, path);
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, cd->index, new_text, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &iter, cd->index, new_text,
+ -1);
}
-static void trg_persistent_tree_view_refresh(TrgPrefs *prefs, void *wdp) {
- trg_pref_widget_desc *wd = (trg_pref_widget_desc*) wdp;
+static void trg_persistent_tree_view_refresh(TrgPrefs * prefs, void *wdp)
+{
+ trg_pref_widget_desc *wd = (trg_pref_widget_desc *) wdp;
TrgPersistentTreeViewPrivate *priv = GET_PRIVATE(wd->widget);
- GtkListStore *model = GTK_LIST_STORE(gtk_tree_view_get_model(priv->tv));
+ GtkListStore *model =
+ GTK_LIST_STORE(gtk_tree_view_get_model(priv->tv));
GtkTreeIter iter;
JsonArray *ja;
GList *ja_list, *li;
@@ -87,38 +92,45 @@ static void trg_persistent_tree_view_refresh(TrgPrefs *prefs, void *wdp) {
gtk_list_store_clear(model);
if (!ja)
- return;
+ return;
ja_list = json_array_get_elements(ja);
for (li = ja_list; li; li = g_list_next(li)) {
- JsonNode *ja_node = (JsonNode*) li->data;
- JsonObject *jobj = json_node_get_object(ja_node);
- gtk_list_store_append(model, &iter);
- for (sli = priv->columns; sli; sli = g_slist_next(sli)) {
- trg_persistent_tree_view_column *cd =
- (trg_persistent_tree_view_column*) sli->data;
- gtk_list_store_set(model, &iter, cd->index,
- json_object_get_string_member(jobj, cd->key), -1);
- }
+ JsonNode *ja_node = (JsonNode *) li->data;
+ JsonObject *jobj = json_node_get_object(ja_node);
+ gtk_list_store_append(model, &iter);
+ for (sli = priv->columns; sli; sli = g_slist_next(sli)) {
+ trg_persistent_tree_view_column *cd =
+ (trg_persistent_tree_view_column *) sli->data;
+ gtk_list_store_set(model, &iter, cd->index,
+ json_object_get_string_member(jobj,
+ cd->key), -1);
+ }
}
g_list_free(ja_list);
}
-static gboolean trg_persistent_tree_view_save_foreachfunc(GtkTreeModel *model,
- GtkTreePath *path, GtkTreeIter *iter, gpointer data) {
+static gboolean trg_persistent_tree_view_save_foreachfunc(GtkTreeModel *
+ model,
+ GtkTreePath *
+ path,
+ GtkTreeIter *
+ iter,
+ gpointer data)
+{
TrgPersistentTreeViewPrivate *priv = GET_PRIVATE(data);
JsonObject *new = json_object_new();
gchar *value;
GSList *li;
for (li = priv->columns; li; li = g_slist_next(li)) {
- trg_persistent_tree_view_column *cd =
- (trg_persistent_tree_view_column*) li->data;
- gtk_tree_model_get(model, iter, cd->index, &value, -1);
- json_object_set_string_member(new, cd->key, value);
- g_free(value);
+ trg_persistent_tree_view_column *cd =
+ (trg_persistent_tree_view_column *) li->data;
+ gtk_tree_model_get(model, iter, cd->index, &value, -1);
+ json_object_set_string_member(new, cd->key, value);
+ g_free(value);
}
json_array_add_object_element(priv->ja, new);
@@ -126,29 +138,34 @@ static gboolean trg_persistent_tree_view_save_foreachfunc(GtkTreeModel *model,
return FALSE;
}
-static void trg_persistent_tree_view_save(TrgPrefs *prefs, void *wdp) {
- trg_pref_widget_desc *wd = (trg_pref_widget_desc*) wdp;
+static void trg_persistent_tree_view_save(TrgPrefs * prefs, void *wdp)
+{
+ trg_pref_widget_desc *wd = (trg_pref_widget_desc *) wdp;
TrgPersistentTreeViewPrivate *priv = GET_PRIVATE(wd->widget);
GtkTreeModel *model = gtk_tree_view_get_model(priv->tv);
JsonNode *node = trg_prefs_get_value(prefs, wd->key, JSON_NODE_ARRAY,
- wd->flags | TRG_PREFS_REPLACENODE);
+ wd->
+ flags | TRG_PREFS_REPLACENODE);
priv->ja = json_array_new();
- gtk_tree_model_foreach(model, trg_persistent_tree_view_save_foreachfunc,
- wd->widget);
+ gtk_tree_model_foreach(model,
+ trg_persistent_tree_view_save_foreachfunc,
+ wd->widget);
json_node_take_array(node, priv->ja);
trg_prefs_changed_emit_signal(prefs, wd->key);
}
-trg_persistent_tree_view_column *trg_persistent_tree_view_add_column(
- TrgPersistentTreeView *ptv, gint index, const gchar *key,
- const gchar *label) {
+trg_persistent_tree_view_column
+ *trg_persistent_tree_view_add_column(TrgPersistentTreeView * ptv,
+ gint index, const gchar * key,
+ const gchar * label)
+{
TrgPersistentTreeViewPrivate *priv = GET_PRIVATE(ptv);
trg_persistent_tree_view_column *cd =
- g_new0(trg_persistent_tree_view_column, 1);
+ g_new0(trg_persistent_tree_view_column, 1);
GtkCellRenderer *renderer;
cd->key = g_strdup(key);
@@ -159,9 +176,10 @@ trg_persistent_tree_view_column *trg_persistent_tree_view_add_column(
renderer = gtk_cell_renderer_text_new();
g_object_set(G_OBJECT(renderer), "editable", TRUE, NULL);
g_signal_connect(renderer, "edited",
- G_CALLBACK(trg_persistent_tree_view_edit), cd);
+ G_CALLBACK(trg_persistent_tree_view_edit), cd);
cd->column = gtk_tree_view_column_new_with_attributes(cd->label,
- renderer, "text", cd->index, NULL);
+ renderer, "text",
+ cd->index, NULL);
gtk_tree_view_column_set_resizable(cd->column, TRUE);
gtk_tree_view_append_column(GTK_TREE_VIEW(priv->tv), cd->column);
@@ -170,8 +188,10 @@ trg_persistent_tree_view_column *trg_persistent_tree_view_add_column(
return cd;
}
-static GtkTreeView *trg_persistent_tree_view_tree_view_new(
- TrgPersistentTreeView *ptv, GtkTreeModel *model) {
+static GtkTreeView
+ *trg_persistent_tree_view_tree_view_new(TrgPersistentTreeView * ptv,
+ GtkTreeModel * model)
+{
GtkTreeView *tv = GTK_TREE_VIEW(gtk_tree_view_new_with_model(model));
GtkTreeSelection *selection;
@@ -182,12 +202,13 @@ static GtkTreeView *trg_persistent_tree_view_tree_view_new(
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv));
g_signal_connect(G_OBJECT(selection), "changed",
- G_CALLBACK(selection_changed), ptv);
+ G_CALLBACK(selection_changed), ptv);
return tv;
}
-static void trg_persistent_tree_view_add_cb(GtkWidget *w, gpointer data) {
+static void trg_persistent_tree_view_add_cb(GtkWidget * w, gpointer data)
+{
TrgPersistentTreeViewPrivate *priv = GET_PRIVATE(data);
GtkTreeModel *model = gtk_tree_view_get_model(priv->tv);
GtkTreeIter iter;
@@ -197,106 +218,128 @@ static void trg_persistent_tree_view_add_cb(GtkWidget *w, gpointer data) {
path = gtk_tree_model_get_path(model, &iter);
if (priv->addSelect)
- gtk_tree_view_set_cursor(priv->tv, path, priv->addSelect->column, TRUE);
+ gtk_tree_view_set_cursor(priv->tv, path, priv->addSelect->column,
+ TRUE);
gtk_tree_path_free(path);
}
-static void trg_persistent_tree_view_del_cb(GtkWidget *w, gpointer data) {
+static void trg_persistent_tree_view_del_cb(GtkWidget * w, gpointer data)
+{
TrgPersistentTreeViewPrivate *priv = GET_PRIVATE(data);
GtkTreeSelection *selection = gtk_tree_view_get_selection(priv->tv);
GtkTreeModel *model;
GtkTreeIter iter;
if (gtk_tree_selection_get_selected(selection, &model, &iter))
- gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
+ gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
}
-static void trg_persistent_tree_view_get_property(GObject *object,
- guint property_id, GValue *value, GParamSpec *pspec) {
+static void trg_persistent_tree_view_get_property(GObject * object,
+ guint property_id,
+ GValue * value,
+ GParamSpec * pspec)
+{
switch (property_id) {
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
-static void trg_persistent_tree_view_set_property(GObject *object,
- guint property_id, const GValue *value, GParamSpec *pspec) {
+static void trg_persistent_tree_view_set_property(GObject * object,
+ guint property_id,
+ const GValue * value,
+ GParamSpec * pspec)
+{
TrgPersistentTreeViewPrivate *priv = GET_PRIVATE(object);
switch (property_id) {
case PROP_PREFS:
- priv->prefs = g_value_get_object(value);
- break;
+ priv->prefs = g_value_get_object(value);
+ break;
case PROP_KEY:
- priv->key = g_value_get_pointer(value);
- break;
+ priv->key = g_value_get_pointer(value);
+ break;
case PROP_MODEL:
- priv->model = g_value_get_object(value);
- break;
+ priv->model = g_value_get_object(value);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
-static void trg_persistent_tree_view_finalize(GObject *object) {
+static void trg_persistent_tree_view_finalize(GObject * object)
+{
TrgPersistentTreeViewPrivate *priv = GET_PRIVATE(object);
GSList *li;
for (li = priv->columns; li; li = g_slist_next(li)) {
- trg_persistent_tree_view_column *cd =
- (trg_persistent_tree_view_column*) li->data;
- g_free(cd->key);
- g_free(cd->label);
- g_free(cd);
+ trg_persistent_tree_view_column *cd =
+ (trg_persistent_tree_view_column *) li->data;
+ g_free(cd->key);
+ g_free(cd->label);
+ g_free(cd);
}
g_slist_free(priv->columns);
g_free(priv->key);
- G_OBJECT_CLASS (trg_persistent_tree_view_parent_class)->finalize(object);
+ G_OBJECT_CLASS(trg_persistent_tree_view_parent_class)->
+ finalize(object);
}
-trg_pref_widget_desc* trg_persistent_tree_view_get_widget_desc(
- TrgPersistentTreeView* ptv) {
+trg_pref_widget_desc
+ *trg_persistent_tree_view_get_widget_desc(TrgPersistentTreeView * ptv)
+{
TrgPersistentTreeViewPrivate *priv = GET_PRIVATE(ptv);
return priv->wd;
}
-void trg_persistent_tree_view_set_add_select(TrgPersistentTreeView *ptv,
- trg_persistent_tree_view_column *cd) {
+void trg_persistent_tree_view_set_add_select(TrgPersistentTreeView * ptv,
+ trg_persistent_tree_view_column
+ * cd)
+{
TrgPersistentTreeViewPrivate *priv = GET_PRIVATE(ptv);
priv->addSelect = cd;
}
static GObject *trg_persistent_tree_view_constructor(GType type,
- guint n_construct_properties, GObjectConstructParam * construct_params) {
+ guint
+ n_construct_properties,
+ GObjectConstructParam
+ * construct_params)
+{
GObject *object;
TrgPersistentTreeViewPrivate *priv;
GtkWidget *hbox, *w;
object = G_OBJECT_CLASS
- (trg_persistent_tree_view_parent_class)->constructor(type,
- n_construct_properties, construct_params);
+ (trg_persistent_tree_view_parent_class)->constructor(type,
+ n_construct_properties,
+ construct_params);
priv = GET_PRIVATE(object);
hbox = gtk_hbox_new(FALSE, 0);
w = gtk_button_new_from_stock(GTK_STOCK_ADD);
- g_signal_connect(w, "clicked", G_CALLBACK(trg_persistent_tree_view_add_cb), object);
+ g_signal_connect(w, "clicked",
+ G_CALLBACK(trg_persistent_tree_view_add_cb), object);
gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 4);
w = priv->delButton = gtk_button_new_from_stock(GTK_STOCK_DELETE);
gtk_widget_set_sensitive(w, FALSE);
- g_signal_connect(w, "clicked", G_CALLBACK(trg_persistent_tree_view_del_cb), object);
+ g_signal_connect(w, "clicked",
+ G_CALLBACK(trg_persistent_tree_view_del_cb), object);
gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 4);
- priv->tv = trg_persistent_tree_view_tree_view_new(
- TRG_PERSISTENT_TREE_VIEW(object), priv->model);
+ priv->tv =
+ trg_persistent_tree_view_tree_view_new(TRG_PERSISTENT_TREE_VIEW
+ (object), priv->model);
gtk_box_pack_start(GTK_BOX(object),
- my_scrolledwin_new(GTK_WIDGET(priv->tv)), TRUE, TRUE, 4);
+ my_scrolledwin_new(GTK_WIDGET(priv->tv)), TRUE,
+ TRUE, 4);
gtk_box_pack_start(GTK_BOX(object), hbox, FALSE, FALSE, 4);
priv->wd = trg_pref_widget_desc_new(GTK_WIDGET(priv->tv), priv->key,
- TRG_PREFS_PROFILE);
+ TRG_PREFS_PROFILE);
priv->wd->widget = GTK_WIDGET(object);
priv->wd->saveFunc = &trg_persistent_tree_view_save;
priv->wd->refreshFunc = &trg_persistent_tree_view_refresh;
@@ -304,9 +347,10 @@ static GObject *trg_persistent_tree_view_constructor(GType type,
return object;
}
-static void trg_persistent_tree_view_class_init(
- TrgPersistentTreeViewClass *klass) {
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+static void trg_persistent_tree_view_class_init(TrgPersistentTreeViewClass
+ * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
g_type_class_add_private(klass, sizeof(TrgPersistentTreeViewPrivate));
@@ -315,50 +359,64 @@ static void trg_persistent_tree_view_class_init(
object_class->finalize = trg_persistent_tree_view_finalize;
object_class->constructor = trg_persistent_tree_view_constructor;
- g_object_class_install_property(
- object_class,
- PROP_KEY,
- g_param_spec_pointer(
- "conf-key",
- "Conf Key",
- "Conf Key",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK
- | G_PARAM_STATIC_BLURB));
-
- g_object_class_install_property(
- object_class,
- PROP_PREFS,
- g_param_spec_object(
- "prefs",
- "Prefs",
- "Prefs",
- TRG_TYPE_PREFS,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK
- | G_PARAM_STATIC_BLURB));
-
- g_object_class_install_property(
- object_class,
- PROP_MODEL,
- g_param_spec_object(
- "persistent-model",
- "Persistent Model",
- "Persistent Model",
- GTK_TYPE_LIST_STORE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK
- | G_PARAM_STATIC_BLURB));
+ g_object_class_install_property(object_class,
+ PROP_KEY,
+ g_param_spec_pointer("conf-key",
+ "Conf Key",
+ "Conf Key",
+ G_PARAM_READWRITE
+ |
+ G_PARAM_CONSTRUCT_ONLY
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
+
+ g_object_class_install_property(object_class,
+ PROP_PREFS,
+ g_param_spec_object("prefs",
+ "Prefs",
+ "Prefs",
+ TRG_TYPE_PREFS,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
+
+ g_object_class_install_property(object_class,
+ PROP_MODEL,
+ g_param_spec_object("persistent-model",
+ "Persistent Model",
+ "Persistent Model",
+ GTK_TYPE_LIST_STORE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
}
-static void trg_persistent_tree_view_init(TrgPersistentTreeView *self) {
+static void trg_persistent_tree_view_init(TrgPersistentTreeView * self)
+{
}
-TrgPersistentTreeView*
-trg_persistent_tree_view_new(TrgPrefs *prefs, GtkListStore *model,
- const gchar *key) {
- GObject *obj = g_object_new(TRG_TYPE_PERSISTENT_TREE_VIEW, "prefs", prefs,
- "conf-key", g_strdup(key), "persistent-model", model, NULL);
+TrgPersistentTreeView *trg_persistent_tree_view_new(TrgPrefs * prefs,
+ GtkListStore * model,
+ const gchar * key)
+{
+ GObject *obj =
+ g_object_new(TRG_TYPE_PERSISTENT_TREE_VIEW, "prefs", prefs,
+ "conf-key", g_strdup(key), "persistent-model", model,
+ NULL);
return TRG_PERSISTENT_TREE_VIEW(obj);
}
diff --git a/src/trg-persistent-tree-view.h b/src/trg-persistent-tree-view.h
index fc2e9c0..71d80c5 100644
--- a/src/trg-persistent-tree-view.h
+++ b/src/trg-persistent-tree-view.h
@@ -26,33 +26,26 @@
#include "trg-preferences-dialog.h"
G_BEGIN_DECLS
-
#define TRG_TYPE_PERSISTENT_TREE_VIEW trg_persistent_tree_view_get_type()
-
#define TRG_PERSISTENT_TREE_VIEW(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), TRG_TYPE_PERSISTENT_TREE_VIEW, TrgPersistentTreeView))
-
#define TRG_PERSISTENT_TREE_VIEW_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), TRG_TYPE_PERSISTENT_TREE_VIEW, TrgPersistentTreeViewClass))
-
#define TRG_IS_PERSISTENT_TREE_VIEW(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRG_TYPE_PERSISTENT_TREE_VIEW))
-
#define TRG_IS_PERSISTENT_TREE_VIEW_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), TRG_TYPE_PERSISTENT_TREE_VIEW))
-
#define TRG_PERSISTENT_TREE_VIEW_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), TRG_TYPE_PERSISTENT_TREE_VIEW, TrgPersistentTreeViewClass))
-
-typedef struct {
- GtkVBox parent;
+ typedef struct {
+ GtkVBox parent;
} TrgPersistentTreeView;
typedef struct {
- GtkTreeViewClass parent_class;
+ GtkTreeViewClass parent_class;
} TrgPersistentTreeViewClass;
-GType trg_persistent_tree_view_get_type (void);
+GType trg_persistent_tree_view_get_type(void);
typedef struct {
GtkTreeViewColumn *column;
@@ -62,18 +55,21 @@ typedef struct {
gint index;
} trg_persistent_tree_view_column;
-TrgPersistentTreeView*
-trg_persistent_tree_view_new (TrgPrefs *prefs, GtkListStore *model, const gchar *key);
+TrgPersistentTreeView *trg_persistent_tree_view_new(TrgPrefs * prefs,
+ GtkListStore * model,
+ const gchar * key);
-trg_pref_widget_desc* trg_persistent_tree_view_get_widget_desc(TrgPersistentTreeView* ptv);
+trg_pref_widget_desc
+ *trg_persistent_tree_view_get_widget_desc(TrgPersistentTreeView * ptv);
-void trg_persistent_tree_view_set_add_select(TrgPersistentTreeView *ptv, trg_persistent_tree_view_column *cd);
+void trg_persistent_tree_view_set_add_select(TrgPersistentTreeView * ptv,
+ trg_persistent_tree_view_column
+ * cd);
-trg_persistent_tree_view_column *trg_persistent_tree_view_add_column(TrgPersistentTreeView *ptv,
- gint index,
- const gchar *key,
- const gchar *label);
+trg_persistent_tree_view_column
+ *trg_persistent_tree_view_add_column(TrgPersistentTreeView * ptv,
+ gint index, const gchar * key,
+ const gchar * label);
G_END_DECLS
-
-#endif /* _TRG_PERSISTENT_TREE_VIEW */
+#endif /* _TRG_PERSISTENT_TREE_VIEW */
diff --git a/src/trg-preferences-dialog.c b/src/trg-preferences-dialog.c
index 497444b..d9d79ed 100644
--- a/src/trg-preferences-dialog.c
+++ b/src/trg-preferences-dialog.c
@@ -45,7 +45,8 @@
#define TRG_PREFERENCES_DIALOG_GET_PRIVATE(object) \
(G_TYPE_INSTANCE_GET_PRIVATE ((object), TRG_TYPE_PREFERENCES_DIALOG, TrgPreferencesDialogPrivate))
-G_DEFINE_TYPE(TrgPreferencesDialog, trg_preferences_dialog, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE(TrgPreferencesDialog, trg_preferences_dialog,
+ GTK_TYPE_DIALOG)
enum {
PROP_0, PROP_TRG_CLIENT, PROP_MAIN_WINDOW
@@ -64,13 +65,15 @@ struct _TrgPreferencesDialogPrivate {
static GObject *instance = NULL;
-static void trg_pref_widget_desc_free(trg_pref_widget_desc *wd) {
+static void trg_pref_widget_desc_free(trg_pref_widget_desc * wd)
+{
g_free(wd->key);
g_free(wd);
}
-trg_pref_widget_desc* trg_pref_widget_desc_new(GtkWidget *w, gchar *key,
- int flags) {
+trg_pref_widget_desc *trg_pref_widget_desc_new(GtkWidget * w, gchar * key,
+ int flags)
+{
trg_pref_widget_desc *desc = g_new0(trg_pref_widget_desc, 1);
desc->widget = w;
desc->key = g_strdup(key);
@@ -78,115 +81,137 @@ trg_pref_widget_desc* trg_pref_widget_desc_new(GtkWidget *w, gchar *key,
return desc;
}
-static void trg_pref_widget_refresh(TrgPreferencesDialog *dlg,
- trg_pref_widget_desc* wd) {
- TrgPreferencesDialogPrivate *priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
+static void trg_pref_widget_refresh(TrgPreferencesDialog * dlg,
+ trg_pref_widget_desc * wd)
+{
+ TrgPreferencesDialogPrivate *priv =
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
wd->refreshFunc(priv->prefs, wd);
}
-static void trg_pref_widget_refresh_all(TrgPreferencesDialog *dlg) {
- TrgPreferencesDialogPrivate *priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
+static void trg_pref_widget_refresh_all(TrgPreferencesDialog * dlg)
+{
+ TrgPreferencesDialogPrivate *priv =
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
GList *li;
for (li = priv->widgets; li; li = g_list_next(li))
- trg_pref_widget_refresh(dlg, (trg_pref_widget_desc*) li->data);
+ trg_pref_widget_refresh(dlg, (trg_pref_widget_desc *) li->data);
}
-static void trg_pref_widget_save(TrgPreferencesDialog *dlg,
- trg_pref_widget_desc* wd) {
- TrgPreferencesDialogPrivate *priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
+static void trg_pref_widget_save(TrgPreferencesDialog * dlg,
+ trg_pref_widget_desc * wd)
+{
+ TrgPreferencesDialogPrivate *priv =
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
wd->saveFunc(priv->prefs, wd);
}
-static void trg_pref_widget_save_all(TrgPreferencesDialog *dlg) {
- TrgPreferencesDialogPrivate *priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
+static void trg_pref_widget_save_all(TrgPreferencesDialog * dlg)
+{
+ TrgPreferencesDialogPrivate *priv =
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
GList *li;
- if (trg_prefs_get_profile(priv->prefs) == NULL
- )
- return;
+ if (trg_prefs_get_profile(priv->prefs) == NULL)
+ return;
trg_client_configlock(priv->client);
for (li = priv->widgets; li; li = g_list_next(li)) {
- trg_pref_widget_desc* wd = (trg_pref_widget_desc*) li->data;
- trg_pref_widget_save(dlg, wd);
+ trg_pref_widget_desc *wd = (trg_pref_widget_desc *) li->data;
+ trg_pref_widget_save(dlg, wd);
}
trg_client_configunlock(priv->client);
}
-static void trg_preferences_dialog_set_property(GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec G_GNUC_UNUSED) {
+static void trg_preferences_dialog_set_property(GObject * object,
+ guint prop_id,
+ const GValue * value,
+ GParamSpec *
+ pspec G_GNUC_UNUSED)
+{
TrgPreferencesDialogPrivate *priv =
- TRG_PREFERENCES_DIALOG_GET_PRIVATE(object);
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(object);
switch (prop_id) {
case PROP_MAIN_WINDOW:
- priv->win = g_value_get_object(value);
- break;
+ priv->win = g_value_get_object(value);
+ break;
case PROP_TRG_CLIENT:
- priv->client = g_value_get_pointer(value);
- priv->prefs = trg_client_get_prefs(priv->client);
- break;
+ priv->client = g_value_get_pointer(value);
+ priv->prefs = trg_client_get_prefs(priv->client);
+ break;
}
}
static void trg_preferences_response_cb(GtkDialog * dlg, gint res_id,
- gpointer data G_GNUC_UNUSED) {
- TrgPreferencesDialogPrivate *priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
+ gpointer data G_GNUC_UNUSED)
+{
+ TrgPreferencesDialogPrivate *priv =
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
if (res_id == GTK_RESPONSE_OK) {
- trg_pref_widget_save_all(TRG_PREFERENCES_DIALOG(dlg));
- trg_prefs_save(priv->prefs);
+ trg_pref_widget_save_all(TRG_PREFERENCES_DIALOG(dlg));
+ trg_prefs_save(priv->prefs);
}
trg_main_window_reload_dir_aliases(priv->win);
GList *li;
for (li = priv->widgets; li; li = g_list_next(li))
- trg_pref_widget_desc_free((trg_pref_widget_desc*) li->data);
+ trg_pref_widget_desc_free((trg_pref_widget_desc *) li->data);
g_list_free(priv->widgets);
gtk_widget_destroy(GTK_WIDGET(dlg));
instance = NULL;
}
-static void trg_preferences_dialog_get_property(GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec G_GNUC_UNUSED) {
+static void trg_preferences_dialog_get_property(GObject * object,
+ guint prop_id,
+ GValue * value,
+ GParamSpec *
+ pspec G_GNUC_UNUSED)
+{
TrgPreferencesDialogPrivate *priv =
- TRG_PREFERENCES_DIALOG_GET_PRIVATE(object);
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(object);
switch (prop_id) {
case PROP_MAIN_WINDOW:
- g_value_set_object(value, priv->win);
- break;
+ g_value_set_object(value, priv->win);
+ break;
case PROP_TRG_CLIENT:
- g_value_set_pointer(value, priv->client);
- break;
+ g_value_set_pointer(value, priv->client);
+ break;
}
}
-static void entry_refresh(TrgPrefs *prefs, void *wdp) {
- trg_pref_widget_desc *wd = (trg_pref_widget_desc*) wdp;
+static void entry_refresh(TrgPrefs * prefs, void *wdp)
+{
+ trg_pref_widget_desc *wd = (trg_pref_widget_desc *) wdp;
gchar *value = trg_prefs_get_string(prefs, wd->key, wd->flags);
if (value) {
- gtk_entry_set_text(GTK_ENTRY(wd->widget), value);
- g_free(value);
+ gtk_entry_set_text(GTK_ENTRY(wd->widget), value);
+ g_free(value);
} else {
- gtk_entry_set_text(GTK_ENTRY(wd->widget), "");
+ gtk_entry_set_text(GTK_ENTRY(wd->widget), "");
}
}
-static void entry_save(TrgPrefs *prefs, void *wdp) {
- trg_pref_widget_desc *wd = (trg_pref_widget_desc*) wdp;
+static void entry_save(TrgPrefs * prefs, void *wdp)
+{
+ trg_pref_widget_desc *wd = (trg_pref_widget_desc *) wdp;
trg_prefs_set_string(prefs, wd->key,
- gtk_entry_get_text(GTK_ENTRY(wd->widget)), wd->flags);
+ gtk_entry_get_text(GTK_ENTRY(wd->widget)),
+ wd->flags);
}
-static GtkWidget *trgp_entry_new(TrgPreferencesDialog *dlg, gchar *key,
- int flags) {
- TrgPreferencesDialogPrivate *priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
+static GtkWidget *trgp_entry_new(TrgPreferencesDialog * dlg, gchar * key,
+ int flags)
+{
+ TrgPreferencesDialogPrivate *priv =
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
GtkWidget *w;
w = gtk_entry_new();
@@ -201,28 +226,35 @@ static GtkWidget *trgp_entry_new(TrgPreferencesDialog *dlg, gchar *key,
return w;
}
-static void check_refresh(TrgPrefs *prefs, void *wdp) {
- trg_pref_widget_desc *wd = (trg_pref_widget_desc*) wdp;
+static void check_refresh(TrgPrefs * prefs, void *wdp)
+{
+ trg_pref_widget_desc *wd = (trg_pref_widget_desc *) wdp;
gboolean value = trg_prefs_get_bool(prefs, wd->key, wd->flags);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wd->widget), value);
}
-static void check_save(TrgPrefs *prefs, void *wdp) {
- trg_pref_widget_desc *wd = (trg_pref_widget_desc*) wdp;
+static void check_save(TrgPrefs * prefs, void *wdp)
+{
+ trg_pref_widget_desc *wd = (trg_pref_widget_desc *) wdp;
trg_prefs_set_bool(prefs, wd->key,
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wd->widget)),
- wd->flags);
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+ (wd->widget)),
+ wd->flags);
}
-static void trgp_toggle_dependent(GtkToggleButton *b, gpointer data) {
- gtk_widget_set_sensitive(GTK_WIDGET(data), gtk_toggle_button_get_active(b));
+static void trgp_toggle_dependent(GtkToggleButton * b, gpointer data)
+{
+ gtk_widget_set_sensitive(GTK_WIDGET(data),
+ gtk_toggle_button_get_active(b));
}
-static GtkWidget *trgp_check_new(TrgPreferencesDialog *dlg,
- const char *mnemonic, gchar *key, int flags,
- GtkToggleButton *dependency) {
- TrgPreferencesDialogPrivate *priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
+static GtkWidget *trgp_check_new(TrgPreferencesDialog * dlg,
+ const char *mnemonic, gchar * key,
+ int flags, GtkToggleButton * dependency)
+{
+ TrgPreferencesDialogPrivate *priv =
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
GtkWidget *w = gtk_check_button_new_with_mnemonic(mnemonic);
@@ -232,9 +264,10 @@ static GtkWidget *trgp_check_new(TrgPreferencesDialog *dlg,
check_refresh(priv->prefs, wd);
if (dependency) {
- g_signal_connect(dependency, "toggled",
- G_CALLBACK(trgp_toggle_dependent), w);
- gtk_widget_set_sensitive(w, gtk_toggle_button_get_active(dependency));
+ g_signal_connect(dependency, "toggled",
+ G_CALLBACK(trgp_toggle_dependent), w);
+ gtk_widget_set_sensitive(w,
+ gtk_toggle_button_get_active(dependency));
}
priv->widgets = g_list_append(priv->widgets, wd);
@@ -242,24 +275,30 @@ static GtkWidget *trgp_check_new(TrgPreferencesDialog *dlg,
return w;
}
-static void spin_refresh(TrgPrefs *prefs, void *wdp) {
- trg_pref_widget_desc *wd = (trg_pref_widget_desc*) wdp;
+static void spin_refresh(TrgPrefs * prefs, void *wdp)
+{
+ trg_pref_widget_desc *wd = (trg_pref_widget_desc *) wdp;
GtkWidget *widget = wd->widget;
gint value = trg_prefs_get_int(prefs, wd->key, wd->flags);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), value);
}
-static void spin_save(TrgPrefs * prefs, void* wdp) {
- trg_pref_widget_desc *wd = (trg_pref_widget_desc*) wdp;
+static void spin_save(TrgPrefs * prefs, void *wdp)
+{
+ trg_pref_widget_desc *wd = (trg_pref_widget_desc *) wdp;
trg_prefs_set_int(prefs, wd->key,
- gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(wd->widget)),
- wd->flags);
+ gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON
+ (wd->widget)),
+ wd->flags);
}
-static GtkWidget *trgp_spin_new(TrgPreferencesDialog *dlg, gchar * key, int low,
- int high, int step, int flags, GtkToggleButton *dependency) {
- TrgPreferencesDialogPrivate *priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
+static GtkWidget *trgp_spin_new(TrgPreferencesDialog * dlg, gchar * key,
+ int low, int high, int step, int flags,
+ GtkToggleButton * dependency)
+{
+ TrgPreferencesDialogPrivate *priv =
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
GtkWidget *w;
w = gtk_spin_button_new_with_range(low, high, step);
@@ -271,9 +310,10 @@ static GtkWidget *trgp_spin_new(TrgPreferencesDialog *dlg, gchar * key, int low,
wd->refreshFunc = &spin_refresh;
if (dependency) {
- g_signal_connect(dependency, "toggled",
- G_CALLBACK(trgp_toggle_dependent), w);
- gtk_widget_set_sensitive(w, gtk_toggle_button_get_active(dependency));
+ g_signal_connect(dependency, "toggled",
+ G_CALLBACK(trgp_toggle_dependent), w);
+ gtk_widget_set_sensitive(w,
+ gtk_toggle_button_get_active(dependency));
}
spin_refresh(priv->prefs, wd);
@@ -282,49 +322,59 @@ static GtkWidget *trgp_spin_new(TrgPreferencesDialog *dlg, gchar * key, int low,
return w;
}
-static void toggle_filter_trackers(GtkToggleButton * w, gpointer win) {
- TrgStateSelector *selector = trg_main_window_get_state_selector(
- TRG_MAIN_WINDOW(win));
+static void toggle_filter_trackers(GtkToggleButton * w, gpointer win)
+{
+ TrgStateSelector *selector =
+ trg_main_window_get_state_selector(TRG_MAIN_WINDOW(win));
trg_state_selector_set_show_trackers(selector,
- gtk_toggle_button_get_active(w));
+ gtk_toggle_button_get_active(w));
}
#ifndef TRG_NO_GRAPH
-static void toggle_graph(GtkToggleButton * w, gpointer win) {
+static void toggle_graph(GtkToggleButton * w, gpointer win)
+{
if (gtk_toggle_button_get_active(w))
- trg_main_window_add_graph(TRG_MAIN_WINDOW(win), TRUE);
+ trg_main_window_add_graph(TRG_MAIN_WINDOW(win), TRUE);
else
- trg_main_window_remove_graph(TRG_MAIN_WINDOW(win));
+ trg_main_window_remove_graph(TRG_MAIN_WINDOW(win));
}
#endif
-static void toggle_tray_icon(GtkToggleButton * w, gpointer win) {
+static void toggle_tray_icon(GtkToggleButton * w, gpointer win)
+{
if (gtk_toggle_button_get_active(w))
- trg_main_window_add_status_icon(TRG_MAIN_WINDOW(win));
+ trg_main_window_add_status_icon(TRG_MAIN_WINDOW(win));
else
- trg_main_window_remove_status_icon(TRG_MAIN_WINDOW(win));
+ trg_main_window_remove_status_icon(TRG_MAIN_WINDOW(win));
}
-static void menu_bar_toggle_filter_dirs(GtkToggleButton * w, gpointer win) {
- TrgStateSelector *selector = trg_main_window_get_state_selector(
- TRG_MAIN_WINDOW(win));
- trg_state_selector_set_show_dirs(selector, gtk_toggle_button_get_active(w));
+static void menu_bar_toggle_filter_dirs(GtkToggleButton * w, gpointer win)
+{
+ TrgStateSelector *selector =
+ trg_main_window_get_state_selector(TRG_MAIN_WINDOW(win));
+ trg_state_selector_set_show_dirs(selector,
+ gtk_toggle_button_get_active(w));
}
-static void view_states_toggled_cb(GtkToggleButton * w, gpointer data) {
+static void view_states_toggled_cb(GtkToggleButton * w, gpointer data)
+{
GtkWidget *scroll =
- gtk_widget_get_parent(
- GTK_WIDGET(trg_main_window_get_state_selector(TRG_MAIN_WINDOW(data))));
+ gtk_widget_get_parent(GTK_WIDGET
+ (trg_main_window_get_state_selector
+ (TRG_MAIN_WINDOW(data))));
trg_widget_set_visible(scroll, gtk_toggle_button_get_active(w));
}
-static void notebook_toggled_cb(GtkToggleButton *b, gpointer data) {
+static void notebook_toggled_cb(GtkToggleButton * b, gpointer data)
+{
trg_main_window_notebook_set_visible(TRG_MAIN_WINDOW(data),
- gtk_toggle_button_get_active(b));
+ gtk_toggle_button_get_active(b));
}
-static GtkWidget *trg_prefs_desktopPage(TrgPreferencesDialog *dlg) {
- TrgPreferencesDialogPrivate *priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
+static GtkWidget *trg_prefs_desktopPage(TrgPreferencesDialog * dlg)
+{
+ TrgPreferencesDialogPrivate *priv =
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
GtkWidget *tray, *w, *dep, *t;
gint row = 0;
@@ -334,67 +384,76 @@ static GtkWidget *trg_prefs_desktopPage(TrgPreferencesDialog *dlg) {
hig_workarea_add_section_title(t, &row, _("Features"));
dep = w = trgp_check_new(dlg, _("State selector"),
- TRG_PREFS_KEY_SHOW_STATE_SELECTOR, TRG_PREFS_GLOBAL, NULL);
- g_signal_connect(G_OBJECT(w), "toggled", G_CALLBACK(view_states_toggled_cb),
- priv->win);
+ TRG_PREFS_KEY_SHOW_STATE_SELECTOR,
+ TRG_PREFS_GLOBAL, NULL);
+ g_signal_connect(G_OBJECT(w), "toggled",
+ G_CALLBACK(view_states_toggled_cb), priv->win);
hig_workarea_add_wide_control(t, &row, w);
- w = trgp_check_new(dlg, _("Directory filters"), TRG_PREFS_KEY_FILTER_DIRS,
- TRG_PREFS_GLOBAL, GTK_TOGGLE_BUTTON(dep));
+ w = trgp_check_new(dlg, _("Directory filters"),
+ TRG_PREFS_KEY_FILTER_DIRS, TRG_PREFS_GLOBAL,
+ GTK_TOGGLE_BUTTON(dep));
g_signal_connect(G_OBJECT(w), "toggled",
- G_CALLBACK(menu_bar_toggle_filter_dirs), priv->win);
+ G_CALLBACK(menu_bar_toggle_filter_dirs), priv->win);
hig_workarea_add_wide_control(t, &row, w);
- w = trgp_check_new(dlg, _("Tracker filters"), TRG_PREFS_KEY_FILTER_TRACKERS,
- TRG_PREFS_GLOBAL, GTK_TOGGLE_BUTTON(dep));
- g_signal_connect(G_OBJECT(w), "toggled", G_CALLBACK(toggle_filter_trackers),
- priv->win);
+ w = trgp_check_new(dlg, _("Tracker filters"),
+ TRG_PREFS_KEY_FILTER_TRACKERS, TRG_PREFS_GLOBAL,
+ GTK_TOGGLE_BUTTON(dep));
+ g_signal_connect(G_OBJECT(w), "toggled",
+ G_CALLBACK(toggle_filter_trackers), priv->win);
hig_workarea_add_wide_control(t, &row, w);
- w = trgp_check_new(dlg, _("Torrent Details"), TRG_PREFS_KEY_SHOW_NOTEBOOK,
- TRG_PREFS_GLOBAL, NULL);
- g_signal_connect(G_OBJECT(w), "toggled", G_CALLBACK(notebook_toggled_cb),
- priv->win);
+ w = trgp_check_new(dlg, _("Torrent Details"),
+ TRG_PREFS_KEY_SHOW_NOTEBOOK, TRG_PREFS_GLOBAL,
+ NULL);
+ g_signal_connect(G_OBJECT(w), "toggled",
+ G_CALLBACK(notebook_toggled_cb), priv->win);
hig_workarea_add_wide_control(t, &row, w);
#ifndef TRG_NO_GRAPH
w = trgp_check_new(dlg, _("Show graph"), TRG_PREFS_KEY_SHOW_GRAPH,
- TRG_PREFS_GLOBAL, GTK_TOGGLE_BUTTON(w));
+ TRG_PREFS_GLOBAL, GTK_TOGGLE_BUTTON(w));
g_signal_connect(G_OBJECT(w), "toggled", G_CALLBACK(toggle_graph),
- priv->win);
+ priv->win);
hig_workarea_add_wide_control(t, &row, w);
#endif
#ifdef HAVE_LIBNOTIFY
w = trgp_check_new(dlg, _("Torrent added notifications"),
- TRG_PREFS_KEY_ADD_NOTIFY, TRG_PREFS_GLOBAL, NULL);
+ TRG_PREFS_KEY_ADD_NOTIFY, TRG_PREFS_GLOBAL, NULL);
hig_workarea_add_wide_control(t, &row, w);
w = trgp_check_new(dlg, _("Torrent complete notifications"),
- TRG_PREFS_KEY_COMPLETE_NOTIFY, TRG_PREFS_GLOBAL, NULL);
+ TRG_PREFS_KEY_COMPLETE_NOTIFY, TRG_PREFS_GLOBAL,
+ NULL);
hig_workarea_add_wide_control(t, &row, w);
#endif
tray = trgp_check_new(dlg, _("Show in system tray"),
- TRG_PREFS_KEY_SYSTEM_TRAY, TRG_PREFS_GLOBAL, NULL);
- g_signal_connect(G_OBJECT(tray), "toggled", G_CALLBACK(toggle_tray_icon),
- priv->win);
+ TRG_PREFS_KEY_SYSTEM_TRAY, TRG_PREFS_GLOBAL,
+ NULL);
+ g_signal_connect(G_OBJECT(tray), "toggled",
+ G_CALLBACK(toggle_tray_icon), priv->win);
hig_workarea_add_wide_control(t, &row, tray);
#ifndef HAVE_LIBAPPINDICATOR
w = trgp_check_new(dlg, _("Minimise to system tray"),
- TRG_PREFS_KEY_SYSTEM_TRAY_MINIMISE, TRG_PREFS_GLOBAL, NULL);
- gtk_widget_set_sensitive(w, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
- (tray)));
+ TRG_PREFS_KEY_SYSTEM_TRAY_MINIMISE,
+ TRG_PREFS_GLOBAL, NULL);
+ gtk_widget_set_sensitive(w,
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+ (tray)));
g_signal_connect(G_OBJECT(tray), "toggled",
- G_CALLBACK(toggle_active_arg_is_sensitive), w);
+ G_CALLBACK(toggle_active_arg_is_sensitive), w);
hig_workarea_add_wide_control(t, &row, w);
#endif
return t;
}
-static GtkWidget *trg_prefs_behaviorPage(TrgPreferencesDialog * dlg) {
+static GtkWidget *trg_prefs_behaviorPage(TrgPreferencesDialog * dlg)
+{
GtkWidget *w, *t;
gint row = 0;
@@ -403,23 +462,27 @@ static GtkWidget *trg_prefs_behaviorPage(TrgPreferencesDialog * dlg) {
hig_workarea_add_section_title(t, &row, _("Torrents"));
w = trgp_check_new(dlg, _("Start paused"), TRG_PREFS_KEY_START_PAUSED,
- TRG_PREFS_GLOBAL, NULL);
+ TRG_PREFS_GLOBAL, NULL);
hig_workarea_add_wide_control(t, &row, w);
w = trgp_check_new(dlg, _("Options dialog on add"),
- TRG_PREFS_KEY_ADD_OPTIONS_DIALOG, TRG_PREFS_GLOBAL, NULL);
+ TRG_PREFS_KEY_ADD_OPTIONS_DIALOG, TRG_PREFS_GLOBAL,
+ NULL);
hig_workarea_add_wide_control(t, &row, w);
w = trgp_check_new(dlg, _("Delete local .torrent file after adding"),
- TRG_PREFS_KEY_DELETE_LOCAL_TORRENT, TRG_PREFS_GLOBAL, NULL);
+ TRG_PREFS_KEY_DELETE_LOCAL_TORRENT,
+ TRG_PREFS_GLOBAL, NULL);
hig_workarea_add_wide_control(t, &row, w);
return t;
}
-static void profile_changed_cb(GtkWidget *w, gpointer data) {
+static void profile_changed_cb(GtkWidget * w, gpointer data)
+{
GtkTreeModel *model = gtk_combo_box_get_model(GTK_COMBO_BOX(w));
- TrgPreferencesDialogPrivate *priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(data);
+ TrgPreferencesDialogPrivate *priv =
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(data);
GtkTreeIter iter;
JsonObject *profile;
@@ -428,69 +491,76 @@ static void profile_changed_cb(GtkWidget *w, gpointer data) {
gint n_children = gtk_tree_model_iter_n_children(model, NULL);
if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(w), &iter)) {
- gtk_tree_model_get(model, &iter, 0, &profile, -1);
- trg_prefs_set_profile(priv->prefs, profile);
- trg_pref_widget_refresh_all(TRG_PREFERENCES_DIALOG(data));
- gtk_widget_set_sensitive(priv->profileDelButton, n_children > 1);
+ gtk_tree_model_get(model, &iter, 0, &profile, -1);
+ trg_prefs_set_profile(priv->prefs, profile);
+ trg_pref_widget_refresh_all(TRG_PREFERENCES_DIALOG(data));
+ gtk_widget_set_sensitive(priv->profileDelButton, n_children > 1);
} else {
- gtk_widget_set_sensitive(priv->profileDelButton, FALSE);
- gtk_combo_box_set_active(GTK_COMBO_BOX(w), 0);
+ gtk_widget_set_sensitive(priv->profileDelButton, FALSE);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(w), 0);
}
}
-static void trg_prefs_profile_combo_populate(TrgPreferencesDialog *dialog,
- GtkComboBox *combo, TrgPrefs *prefs) {
+static void trg_prefs_profile_combo_populate(TrgPreferencesDialog * dialog,
+ GtkComboBox * combo,
+ TrgPrefs * prefs)
+{
TrgPreferencesDialogPrivate *priv =
- TRG_PREFERENCES_DIALOG_GET_PRIVATE(dialog);
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(dialog);
gint profile_id = trg_prefs_get_int(prefs, TRG_PREFS_KEY_PROFILE_ID,
- TRG_PREFS_GLOBAL);
+ TRG_PREFS_GLOBAL);
GtkListStore *store = GTK_LIST_STORE(gtk_combo_box_get_model(combo));
- GList *profiles = json_array_get_elements(trg_prefs_get_profiles(prefs));
+ GList *profiles =
+ json_array_get_elements(trg_prefs_get_profiles(prefs));
GList *li;
int i = 0;
for (li = profiles; li; li = g_list_next(li)) {
- JsonObject *profile = json_node_get_object((JsonNode*) li->data);
- const gchar *name_value;
- GtkTreeIter iter;
-
- if (json_object_has_member(profile, TRG_PREFS_KEY_PROFILE_NAME)) {
- name_value = json_object_get_string_member(profile,
- TRG_PREFS_KEY_PROFILE_NAME);
- } else {
- name_value = _(TRG_PROFILE_NAME_DEFAULT);
- }
-
- gtk_list_store_insert_with_values(store, &iter, INT_MAX, 0, profile, 1,
- name_value, -1);
- if (i == profile_id)
- gtk_combo_box_set_active_iter(combo, &iter);
-
- i++;
+ JsonObject *profile = json_node_get_object((JsonNode *) li->data);
+ const gchar *name_value;
+ GtkTreeIter iter;
+
+ if (json_object_has_member(profile, TRG_PREFS_KEY_PROFILE_NAME)) {
+ name_value = json_object_get_string_member(profile,
+ TRG_PREFS_KEY_PROFILE_NAME);
+ } else {
+ name_value = _(TRG_PROFILE_NAME_DEFAULT);
+ }
+
+ gtk_list_store_insert_with_values(store, &iter, INT_MAX, 0,
+ profile, 1, name_value, -1);
+ if (i == profile_id)
+ gtk_combo_box_set_active_iter(combo, &iter);
+
+ i++;
}
gtk_widget_set_sensitive(priv->profileDelButton,
- g_list_length(profiles) > 1);
+ g_list_length(profiles) > 1);
g_list_free(profiles);
}
-static GtkWidget *trg_prefs_profile_combo_new(TrgClient *tc) {
+static GtkWidget *trg_prefs_profile_combo_new(TrgClient * tc)
+{
GtkWidget *w;
GtkCellRenderer *r;
- GtkListStore *store = gtk_list_store_new(2, G_TYPE_POINTER, G_TYPE_STRING);
+ GtkListStore *store =
+ gtk_list_store_new(2, G_TYPE_POINTER, G_TYPE_STRING);
w = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
r = gtk_cell_renderer_text_new();
- gtk_cell_layout_pack_start(GTK_CELL_LAYOUT (w), r, FALSE);
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(w), r, FALSE);
gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(w), r, "text", 1);
return w;
}
-static void name_changed_cb(GtkWidget *w, gpointer data) {
- TrgPreferencesDialogPrivate *priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(data);
+static void name_changed_cb(GtkWidget * w, gpointer data)
+{
+ TrgPreferencesDialogPrivate *priv =
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(data);
GtkTreeIter iter;
GtkTreeModel *model;
GtkComboBox *combo;
@@ -499,14 +569,16 @@ static void name_changed_cb(GtkWidget *w, gpointer data) {
model = gtk_combo_box_get_model(combo);
if (gtk_combo_box_get_active_iter(combo, &iter)) {
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, 1,
- gtk_entry_get_text(GTK_ENTRY(w)), -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &iter, 1,
+ gtk_entry_get_text(GTK_ENTRY(w)), -1);
}
}
-static void del_profile_cb(GtkWidget *w, gpointer data) {
+static void del_profile_cb(GtkWidget * w, gpointer data)
+{
GtkWidget *win = gtk_widget_get_toplevel(w);
- TrgPreferencesDialogPrivate *priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(win);
+ TrgPreferencesDialogPrivate *priv =
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(win);
TrgPrefs *prefs = priv->prefs;
GtkComboBox *combo = GTK_COMBO_BOX(data);
GtkTreeModel *profileModel = gtk_combo_box_get_model(combo);
@@ -514,40 +586,51 @@ static void del_profile_cb(GtkWidget *w, gpointer data) {
JsonObject *profile;
if (gtk_combo_box_get_active_iter(combo, &iter)) {
- gtk_tree_model_get(profileModel, &iter, 0, &profile, -1);
- trg_prefs_del_profile(prefs, profile);
- trg_prefs_set_profile(prefs, NULL);
- gtk_list_store_remove(GTK_LIST_STORE(profileModel), &iter);
- gtk_combo_box_set_active(combo, 0);
+ gtk_tree_model_get(profileModel, &iter, 0, &profile, -1);
+ trg_prefs_del_profile(prefs, profile);
+ trg_prefs_set_profile(prefs, NULL);
+ gtk_list_store_remove(GTK_LIST_STORE(profileModel), &iter);
+ gtk_combo_box_set_active(combo, 0);
}
}
-static void add_profile_cb(GtkWidget *w, gpointer data) {
+static void add_profile_cb(GtkWidget * w, gpointer data)
+{
GtkWidget *win = gtk_widget_get_toplevel(w);
- TrgPreferencesDialogPrivate *priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(win);
+ TrgPreferencesDialogPrivate *priv =
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(win);
GtkComboBox *combo = GTK_COMBO_BOX(data);
GtkTreeModel *profileModel = gtk_combo_box_get_model(combo);
GtkTreeIter iter;
JsonObject *profile = trg_prefs_new_profile(priv->prefs);
gtk_list_store_insert_with_values(GTK_LIST_STORE(profileModel), &iter,
- INT_MAX, 0, profile, 1, _(TRG_PROFILE_NAME_DEFAULT), -1);
+ INT_MAX, 0, profile, 1,
+ _(TRG_PROFILE_NAME_DEFAULT), -1);
gtk_combo_box_set_active_iter(combo, &iter);
}
-static void trgp_double_special_dependent(GtkWidget *widget, gpointer data) {
+static void trgp_double_special_dependent(GtkWidget * widget,
+ gpointer data)
+{
TrgPreferencesDialogPrivate *priv =
- TRG_PREFERENCES_DIALOG_GET_PRIVATE(gtk_widget_get_toplevel(widget));
- gtk_widget_set_sensitive(
- GTK_WIDGET(data),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))
- && gtk_widget_get_sensitive(priv->fullUpdateCheck)
- && gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON(priv->fullUpdateCheck)));
-}
-
-static GtkWidget *trg_prefs_openExecPage(TrgPreferencesDialog *dlg) {
- TrgPreferencesDialogPrivate *priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(gtk_widget_get_toplevel
+ (widget));
+ gtk_widget_set_sensitive(GTK_WIDGET(data),
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+ (widget))
+ && gtk_widget_get_sensitive(priv->
+ fullUpdateCheck)
+ &&
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+ (priv->
+ fullUpdateCheck)));
+}
+
+static GtkWidget *trg_prefs_openExecPage(TrgPreferencesDialog * dlg)
+{
+ TrgPreferencesDialogPrivate *priv =
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
GtkWidget *t;
TrgPersistentTreeView *ptv;
GtkListStore *model;
@@ -561,26 +644,30 @@ static GtkWidget *trg_prefs_openExecPage(TrgPreferencesDialog *dlg) {
model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
ptv = trg_persistent_tree_view_new(priv->prefs, model,
- TRG_PREFS_KEY_EXEC_COMMANDS);
- trg_persistent_tree_view_set_add_select(
- ptv,
- trg_persistent_tree_view_add_column(ptv, 0, TRG_PREFS_SUBKEY_LABEL,
- _("Label")));
+ TRG_PREFS_KEY_EXEC_COMMANDS);
+ trg_persistent_tree_view_set_add_select(ptv,
+ trg_persistent_tree_view_add_column
+ (ptv, 0,
+ TRG_PREFS_SUBKEY_LABEL,
+ _("Label")));
trg_persistent_tree_view_add_column(ptv, 1,
- TRG_PREFS_KEY_EXEC_COMMANDS_SUBKEY_CMD, _("Command"));
+ TRG_PREFS_KEY_EXEC_COMMANDS_SUBKEY_CMD,
+ _("Command"));
wd = trg_persistent_tree_view_get_widget_desc(ptv);
trg_pref_widget_refresh(dlg, wd);
priv->widgets = g_list_append(priv->widgets, wd);
gtk_table_attach(GTK_TABLE(t), GTK_WIDGET(ptv), 1, 2, row, row + 1,
- GTK_EXPAND | GTK_SHRINK | GTK_FILL,
- GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);
+ GTK_EXPAND | GTK_SHRINK | GTK_FILL,
+ GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);
return t;
}
-static GtkWidget *trg_prefs_dirsPage(TrgPreferencesDialog *dlg) {
- TrgPreferencesDialogPrivate *priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
+static GtkWidget *trg_prefs_dirsPage(TrgPreferencesDialog * dlg)
+{
+ TrgPreferencesDialogPrivate *priv =
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
GtkWidget *t;
TrgPersistentTreeView *ptv;
GtkListStore *model;
@@ -589,31 +676,36 @@ static GtkWidget *trg_prefs_dirsPage(TrgPreferencesDialog *dlg) {
t = hig_workarea_create();
- hig_workarea_add_section_title(t, &row, _("Remote Download Directories"));
+ hig_workarea_add_section_title(t, &row,
+ _("Remote Download Directories"));
model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
ptv = trg_persistent_tree_view_new(priv->prefs, model,
- TRG_PREFS_KEY_DESTINATIONS);
- trg_persistent_tree_view_set_add_select(
- ptv,
- trg_persistent_tree_view_add_column(ptv, 0, TRG_PREFS_SUBKEY_LABEL,
- _("Label")));
+ TRG_PREFS_KEY_DESTINATIONS);
+ trg_persistent_tree_view_set_add_select(ptv,
+ trg_persistent_tree_view_add_column
+ (ptv, 0,
+ TRG_PREFS_SUBKEY_LABEL,
+ _("Label")));
trg_persistent_tree_view_add_column(ptv, 1,
- TRG_PREFS_KEY_DESTINATIONS_SUBKEY_DIR, _("Directory"));
+ TRG_PREFS_KEY_DESTINATIONS_SUBKEY_DIR,
+ _("Directory"));
wd = trg_persistent_tree_view_get_widget_desc(ptv);
trg_pref_widget_refresh(dlg, wd);
priv->widgets = g_list_append(priv->widgets, wd);
gtk_table_attach(GTK_TABLE(t), GTK_WIDGET(ptv), 1, 2, row, row + 1,
- GTK_EXPAND | GTK_SHRINK | GTK_FILL,
- GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);
+ GTK_EXPAND | GTK_SHRINK | GTK_FILL,
+ GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);
return t;
}
-static GtkWidget *trg_prefs_serverPage(TrgPreferencesDialog *dlg) {
- TrgPreferencesDialogPrivate *priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
+static GtkWidget *trg_prefs_serverPage(TrgPreferencesDialog * dlg)
+{
+ TrgPreferencesDialogPrivate *priv =
+ TRG_PREFERENCES_DIALOG_GET_PRIVATE(dlg);
TrgPrefs *prefs = priv->prefs;
GtkWidget *w, *t, *frame, *frameHbox, *profileLabel, *activeOnly;
@@ -626,8 +718,8 @@ static GtkWidget *trg_prefs_serverPage(TrgPreferencesDialog *dlg) {
hig_workarea_add_section_title(t, &row, _("Profile"));
- priv->profileNameEntry = trgp_entry_new(dlg, TRG_PREFS_KEY_PROFILE_NAME,
- TRG_PREFS_PROFILE);
+ priv->profileNameEntry =
+ trgp_entry_new(dlg, TRG_PREFS_KEY_PROFILE_NAME, TRG_PREFS_PROFILE);
w = priv->profileComboBox = trg_prefs_profile_combo_new(priv->client);
profileLabel = gtk_label_new(_("Profile: "));
@@ -635,29 +727,32 @@ static GtkWidget *trg_prefs_serverPage(TrgPreferencesDialog *dlg) {
profileButtonsHbox = gtk_hbox_new(FALSE, 0);
w = gtk_button_new_from_stock(GTK_STOCK_ADD);
g_signal_connect(w, "clicked", G_CALLBACK(add_profile_cb),
- priv->profileComboBox);
+ priv->profileComboBox);
gtk_box_pack_start(GTK_BOX(profileButtonsHbox), w, FALSE, FALSE, 4);
- w = priv->profileDelButton = gtk_button_new_from_stock(GTK_STOCK_DELETE);
+ w = priv->profileDelButton =
+ gtk_button_new_from_stock(GTK_STOCK_DELETE);
g_signal_connect(w, "clicked", G_CALLBACK(del_profile_cb),
- priv->profileComboBox);
+ priv->profileComboBox);
gtk_widget_set_sensitive(w, FALSE);
gtk_box_pack_start(GTK_BOX(profileButtonsHbox), w, FALSE, FALSE, 4);
- trg_prefs_profile_combo_populate(dlg, GTK_COMBO_BOX(priv->profileComboBox),
- prefs);
+ trg_prefs_profile_combo_populate(dlg,
+ GTK_COMBO_BOX(priv->profileComboBox),
+ prefs);
g_signal_connect(G_OBJECT(priv->profileComboBox), "changed",
- G_CALLBACK(profile_changed_cb), dlg);
+ G_CALLBACK(profile_changed_cb), dlg);
/* Name */
g_signal_connect(priv->profileNameEntry, "changed",
- G_CALLBACK(name_changed_cb), dlg);
+ G_CALLBACK(name_changed_cb), dlg);
- hig_workarea_add_row(t, &row, _("Name:"), priv->profileNameEntry, NULL);
+ hig_workarea_add_row(t, &row, _("Name:"), priv->profileNameEntry,
+ NULL);
gtk_table_attach(GTK_TABLE(t), profileButtonsHbox, 1, 2, row, row + 1,
- GTK_EXPAND | GTK_SHRINK, 0, 0, 0);
+ GTK_EXPAND | GTK_SHRINK, 0, 0, 0);
row++;
@@ -666,8 +761,8 @@ static GtkWidget *trg_prefs_serverPage(TrgPreferencesDialog *dlg) {
w = trgp_entry_new(dlg, TRG_PREFS_KEY_HOSTNAME, TRG_PREFS_PROFILE);
hig_workarea_add_row(t, &row, _("Host:"), w, NULL);
- w = trgp_spin_new(dlg, TRG_PREFS_KEY_PORT, 1, 65535, 1, TRG_PREFS_PROFILE,
- NULL);
+ w = trgp_spin_new(dlg, TRG_PREFS_KEY_PORT, 1, 65535, 1,
+ TRG_PREFS_PROFILE, NULL);
hig_workarea_add_row(t, &row, _("Port:"), w, NULL);
w = trgp_entry_new(dlg, TRG_PREFS_KEY_USERNAME, TRG_PREFS_PROFILE);
@@ -678,35 +773,41 @@ static GtkWidget *trg_prefs_serverPage(TrgPreferencesDialog *dlg) {
hig_workarea_add_row(t, &row, _("Password:"), w, NULL);
w = trgp_spin_new(dlg, TRG_PREFS_KEY_UPDATE_INTERVAL, 1, INT_MAX, 1,
- TRG_PREFS_PROFILE, NULL);
+ TRG_PREFS_PROFILE, NULL);
hig_workarea_add_row(t, &row, _("Update interval:"), w, NULL);
w = trgp_spin_new(dlg, TRG_PREFS_KEY_MINUPDATE_INTERVAL, 1, INT_MAX, 1,
- TRG_PREFS_PROFILE, NULL);
- hig_workarea_add_row(t, &row, _("Minimised update interval:"), w, NULL);
+ TRG_PREFS_PROFILE, NULL);
+ hig_workarea_add_row(t, &row, _("Minimised update interval:"), w,
+ NULL);
w = trgp_check_new(dlg, _("Automatically connect"),
- TRG_PREFS_KEY_AUTO_CONNECT, TRG_PREFS_PROFILE, NULL);
+ TRG_PREFS_KEY_AUTO_CONNECT, TRG_PREFS_PROFILE,
+ NULL);
hig_workarea_add_wide_control(t, &row, w);
#ifndef CURL_NO_SSL
w = trgp_check_new(dlg, _("SSL"), TRG_PREFS_KEY_SSL, TRG_PREFS_PROFILE,
- NULL);
+ NULL);
hig_workarea_add_wide_control(t, &row, w);
#endif
activeOnly = w = trgp_check_new(dlg, _("Update active torrents only"),
- TRG_PREFS_KEY_UPDATE_ACTIVE_ONLY, TRG_PREFS_PROFILE, NULL);
+ TRG_PREFS_KEY_UPDATE_ACTIVE_ONLY,
+ TRG_PREFS_PROFILE, NULL);
hig_workarea_add_wide_control(t, &row, w);
priv->fullUpdateCheck = trgp_check_new(dlg,
- _("Full update every (?) updates"),
- TRG_PREFS_ACTIVEONLY_FULLSYNC_ENABLED, TRG_PREFS_PROFILE,
- GTK_TOGGLE_BUTTON(activeOnly));
- w = trgp_spin_new(dlg, TRG_PREFS_ACTIVEONLY_FULLSYNC_EVERY, 2, INT_MAX, 1,
- TRG_PREFS_PROFILE, GTK_TOGGLE_BUTTON(priv->fullUpdateCheck));
+ _
+ ("Full update every (?) updates"),
+ TRG_PREFS_ACTIVEONLY_FULLSYNC_ENABLED,
+ TRG_PREFS_PROFILE,
+ GTK_TOGGLE_BUTTON(activeOnly));
+ w = trgp_spin_new(dlg, TRG_PREFS_ACTIVEONLY_FULLSYNC_EVERY, 2, INT_MAX,
+ 1, TRG_PREFS_PROFILE,
+ GTK_TOGGLE_BUTTON(priv->fullUpdateCheck));
g_signal_connect(activeOnly, "toggled",
- G_CALLBACK(trgp_double_special_dependent), w);
+ G_CALLBACK(trgp_double_special_dependent), w);
hig_workarea_add_row_w(t, &row, priv->fullUpdateCheck, w, NULL);
@@ -715,8 +816,8 @@ static GtkWidget *trg_prefs_serverPage(TrgPreferencesDialog *dlg) {
frame = gtk_frame_new(NULL);
frameHbox = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(frameHbox), profileLabel, FALSE, FALSE, 2);
- gtk_box_pack_start(GTK_BOX(frameHbox), priv->profileComboBox, FALSE, FALSE,
- 4);
+ gtk_box_pack_start(GTK_BOX(frameHbox), priv->profileComboBox, FALSE,
+ FALSE, 4);
gtk_frame_set_label_widget(GTK_FRAME(frame), frameHbox);
gtk_container_add(GTK_CONTAINER(frame), t);
@@ -724,23 +825,30 @@ static GtkWidget *trg_prefs_serverPage(TrgPreferencesDialog *dlg) {
}
static GObject *trg_preferences_dialog_constructor(GType type,
- guint n_construct_properties, GObjectConstructParam * construct_params) {
+ guint
+ n_construct_properties,
+ GObjectConstructParam *
+ construct_params)
+{
GObject *object;
TrgPreferencesDialogPrivate *priv;
GtkWidget *notebook, *contentvbox;
object = G_OBJECT_CLASS
- (trg_preferences_dialog_parent_class)->constructor(type,
- n_construct_properties, construct_params);
+ (trg_preferences_dialog_parent_class)->constructor(type,
+ n_construct_properties,
+ construct_params);
priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(object);
contentvbox = gtk_dialog_get_content_area(GTK_DIALOG(object));
- gtk_window_set_transient_for(GTK_WINDOW(object), GTK_WINDOW(priv->win));
+ gtk_window_set_transient_for(GTK_WINDOW(object),
+ GTK_WINDOW(priv->win));
gtk_window_set_destroy_with_parent(GTK_WINDOW(object), TRUE);
gtk_dialog_add_button(GTK_DIALOG(object), GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE);
- gtk_dialog_add_button(GTK_DIALOG(object), GTK_STOCK_OK, GTK_RESPONSE_OK);
+ GTK_RESPONSE_CLOSE);
+ gtk_dialog_add_button(GTK_DIALOG(object), GTK_STOCK_OK,
+ GTK_RESPONSE_OK);
gtk_dialog_set_default_response(GTK_DIALOG(object), GTK_RESPONSE_OK);
@@ -748,29 +856,34 @@ static GObject *trg_preferences_dialog_constructor(GType type,
gtk_container_set_border_width(GTK_CONTAINER(object), GUI_PAD);
g_signal_connect(G_OBJECT(object), "response",
- G_CALLBACK(trg_preferences_response_cb), NULL);
+ G_CALLBACK(trg_preferences_response_cb), NULL);
notebook = gtk_notebook_new();
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
- trg_prefs_serverPage(TRG_PREFERENCES_DIALOG(object)),
- gtk_label_new(_("Connection")));
+ trg_prefs_serverPage(TRG_PREFERENCES_DIALOG
+ (object)),
+ gtk_label_new(_("Connection")));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
- trg_prefs_openExecPage(TRG_PREFERENCES_DIALOG(object)),
- gtk_label_new(_("Actions")));
+ trg_prefs_openExecPage(TRG_PREFERENCES_DIALOG
+ (object)),
+ gtk_label_new(_("Actions")));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
- trg_prefs_dirsPage(TRG_PREFERENCES_DIALOG(object)),
- gtk_label_new(_("Directories")));
+ trg_prefs_dirsPage(TRG_PREFERENCES_DIALOG
+ (object)),
+ gtk_label_new(_("Directories")));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
- trg_prefs_desktopPage(TRG_PREFERENCES_DIALOG(object)),
- gtk_label_new(_("Desktop")));
+ trg_prefs_desktopPage(TRG_PREFERENCES_DIALOG
+ (object)),
+ gtk_label_new(_("Desktop")));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
- trg_prefs_behaviorPage(TRG_PREFERENCES_DIALOG(object)),
- gtk_label_new(_("Behavior")));
+ trg_prefs_behaviorPage(TRG_PREFERENCES_DIALOG
+ (object)),
+ gtk_label_new(_("Behavior")));
gtk_container_set_border_width(GTK_CONTAINER(notebook), GUI_PAD);
@@ -779,48 +892,60 @@ static GObject *trg_preferences_dialog_constructor(GType type,
return object;
}
-static void trg_preferences_dialog_init(TrgPreferencesDialog * pref_dlg) {
+static void trg_preferences_dialog_init(TrgPreferencesDialog * pref_dlg)
+{
}
-static void trg_preferences_dialog_class_init(TrgPreferencesDialogClass * class) {
+static void trg_preferences_dialog_class_init(TrgPreferencesDialogClass *
+ class)
+{
GObjectClass *g_object_class = (GObjectClass *) class;
g_object_class->constructor = trg_preferences_dialog_constructor;
g_object_class->set_property = trg_preferences_dialog_set_property;
g_object_class->get_property = trg_preferences_dialog_get_property;
- g_object_class_install_property(
- g_object_class,
- PROP_TRG_CLIENT,
- g_param_spec_pointer(
- "trg-client",
- "TClient",
- "Client",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK
- | G_PARAM_STATIC_BLURB));
-
- g_object_class_install_property(
- g_object_class,
- PROP_MAIN_WINDOW,
- g_param_spec_object(
- "main-window",
- "Main Window",
- "Main Window",
- TRG_TYPE_MAIN_WINDOW,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK
- | G_PARAM_STATIC_BLURB));
+ g_object_class_install_property(g_object_class,
+ PROP_TRG_CLIENT,
+ g_param_spec_pointer("trg-client",
+ "TClient",
+ "Client",
+ G_PARAM_READWRITE
+ |
+ G_PARAM_CONSTRUCT_ONLY
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
+
+ g_object_class_install_property(g_object_class,
+ PROP_MAIN_WINDOW,
+ g_param_spec_object("main-window",
+ "Main Window",
+ "Main Window",
+ TRG_TYPE_MAIN_WINDOW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
g_type_class_add_private(g_object_class,
- sizeof(TrgPreferencesDialogPrivate));
+ sizeof(TrgPreferencesDialogPrivate));
}
GtkWidget *trg_preferences_dialog_get_instance(TrgMainWindow * win,
- TrgClient * client) {
+ TrgClient * client)
+{
if (!instance)
- instance = g_object_new(TRG_TYPE_PREFERENCES_DIALOG, "main-window", win,
- "trg-client", client, NULL);
+ instance =
+ g_object_new(TRG_TYPE_PREFERENCES_DIALOG, "main-window", win,
+ "trg-client", client, NULL);
return GTK_WIDGET(instance);
}
diff --git a/src/trg-preferences-dialog.h b/src/trg-preferences-dialog.h
index 92190a6..55760ef 100644
--- a/src/trg-preferences-dialog.h
+++ b/src/trg-preferences-dialog.h
@@ -41,8 +41,8 @@ typedef struct {
GtkWidget *widget;
int flags;
gchar *key;
- void (*saveFunc)(TrgPrefs*,void*);
- void (*refreshFunc)(TrgPrefs*,void*);
+ void (*saveFunc) (TrgPrefs *, void *);
+ void (*refreshFunc) (TrgPrefs *, void *);
} trg_pref_widget_desc;
struct _TrgPreferencesDialog {
@@ -57,9 +57,9 @@ struct _TrgPreferencesDialogClass {
GType trg_preferences_dialog_get_type(void);
GtkWidget *trg_preferences_dialog_get_instance(TrgMainWindow * win,
- TrgClient * client);
-trg_pref_widget_desc* trg_pref_widget_desc_new(GtkWidget *w, gchar *key,
- int flags);
+ TrgClient * client);
+trg_pref_widget_desc *trg_pref_widget_desc_new(GtkWidget * w, gchar * key,
+ int flags);
G_END_DECLS
-#endif /* TRG_PREFERENCES_WINDOW_H_ */
+#endif /* TRG_PREFERENCES_WINDOW_H_ */
diff --git a/src/trg-prefs.c b/src/trg-prefs.c
index 33d8f39..08e425c 100644
--- a/src/trg-prefs.c
+++ b/src/trg-prefs.c
@@ -36,11 +36,9 @@
* 5) Transparently use configurables from the current connection, not current profile.
*/
-G_DEFINE_TYPE (TrgPrefs, trg_prefs, G_TYPE_OBJECT)
-
+G_DEFINE_TYPE(TrgPrefs, trg_prefs, G_TYPE_OBJECT)
#define GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_PREFS, TrgPrefsPrivate))
-
typedef struct _TrgPrefsPrivate TrgPrefsPrivate;
struct _TrgPrefsPrivate {
@@ -60,47 +58,54 @@ enum {
static guint signals[PREFS_SIGNAL_COUNT] = { 0 };
-void trg_prefs_profile_change_emit_signal(TrgPrefs *p)
+void trg_prefs_profile_change_emit_signal(TrgPrefs * p)
{
g_signal_emit(p, signals[PREF_PROFILE_CHANGE], 0);
}
-void trg_prefs_changed_emit_signal(TrgPrefs *p, const gchar *key)
+void trg_prefs_changed_emit_signal(TrgPrefs * p, const gchar * key)
{
g_signal_emit(p, signals[PREF_CHANGE], 0, key);
}
-static void trg_prefs_get_property(GObject *object, guint property_id,
- GValue *value, GParamSpec *pspec) {
+static void trg_prefs_get_property(GObject * object, guint property_id,
+ GValue * value, GParamSpec * pspec)
+{
switch (property_id) {
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
-static void trg_prefs_set_property(GObject *object, guint property_id,
- const GValue *value, GParamSpec *pspec) {
+static void trg_prefs_set_property(GObject * object, guint property_id,
+ const GValue * value,
+ GParamSpec * pspec)
+{
switch (property_id) {
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
-static void trg_prefs_dispose(GObject *object) {
- G_OBJECT_CLASS (trg_prefs_parent_class)->dispose(object);
+static void trg_prefs_dispose(GObject * object)
+{
+ G_OBJECT_CLASS(trg_prefs_parent_class)->dispose(object);
}
-static void trg_prefs_create_defaults(TrgPrefs *p) {
+static void trg_prefs_create_defaults(TrgPrefs * p)
+{
TrgPrefsPrivate *priv = GET_PRIVATE(p);
priv->defaultsObj = json_object_new();
trg_prefs_add_default_string(p, TRG_PREFS_KEY_PROFILE_NAME,
- _(TRG_PROFILE_NAME_DEFAULT));
+ _(TRG_PROFILE_NAME_DEFAULT));
trg_prefs_add_default_int(p, TRG_PREFS_KEY_PORT, 9091);
- trg_prefs_add_default_int(p, TRG_PREFS_KEY_UPDATE_INTERVAL, TRG_INTERVAL_DEFAULT);
- trg_prefs_add_default_int(p, TRG_PREFS_KEY_MINUPDATE_INTERVAL, TRG_INTERVAL_DEFAULT);
+ trg_prefs_add_default_int(p, TRG_PREFS_KEY_UPDATE_INTERVAL,
+ TRG_INTERVAL_DEFAULT);
+ trg_prefs_add_default_int(p, TRG_PREFS_KEY_MINUPDATE_INTERVAL,
+ TRG_INTERVAL_DEFAULT);
trg_prefs_add_default_int(p, TRG_PREFS_ACTIVEONLY_FULLSYNC_EVERY, 2);
trg_prefs_add_default_int(p, TRG_PREFS_KEY_STATES_PANED_POS, 120);
@@ -112,26 +117,31 @@ static void trg_prefs_create_defaults(TrgPrefs *p) {
trg_prefs_add_default_bool_true(p, TRG_PREFS_KEY_SHOW_NOTEBOOK);
}
-static GObject *trg_prefs_constructor(GType type, guint n_construct_properties,
- GObjectConstructParam * construct_params) {
+static GObject *trg_prefs_constructor(GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *
+ construct_params)
+{
GObject *object;
TrgPrefsPrivate *priv;
object = G_OBJECT_CLASS
- (trg_prefs_parent_class)->constructor(type, n_construct_properties,
- construct_params);
+ (trg_prefs_parent_class)->constructor(type, n_construct_properties,
+ construct_params);
priv = GET_PRIVATE(object);
trg_prefs_create_defaults(TRG_PREFS(object));
priv->file = g_build_filename(g_get_user_config_dir(),
- g_get_application_name(), TRG_PREFS_FILENAME, NULL);
+ g_get_application_name(),
+ TRG_PREFS_FILENAME, NULL);
return object;
}
-static void trg_prefs_class_init(TrgPrefsClass *klass) {
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+static void trg_prefs_class_init(TrgPrefsClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
g_type_class_add_private(klass, sizeof(TrgPrefsPrivate));
@@ -141,171 +151,200 @@ static void trg_prefs_class_init(TrgPrefsClass *klass) {
object_class->constructor = trg_prefs_constructor;
signals[PREF_CHANGE] =
- g_signal_new("pref-changed",
- G_TYPE_FROM_CLASS(object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET(TrgPrefsClass,
- pref_changed), NULL,
- NULL, g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
+ g_signal_new("pref-changed",
+ G_TYPE_FROM_CLASS(object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET(TrgPrefsClass,
+ pref_changed), NULL,
+ NULL, g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
signals[PREF_PROFILE_CHANGE] =
- g_signal_new("pref-profile-changed",
- G_TYPE_FROM_CLASS(object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET(TrgPrefsClass,
- pref_changed), NULL,
- NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new("pref-profile-changed",
+ G_TYPE_FROM_CLASS(object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET(TrgPrefsClass,
+ pref_changed), NULL,
+ NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}
-static void trg_prefs_init(TrgPrefs *self) {
+static void trg_prefs_init(TrgPrefs * self)
+{
}
-TrgPrefs*
-trg_prefs_new(void) {
+TrgPrefs *trg_prefs_new(void)
+{
return g_object_new(TRG_TYPE_PREFS, NULL);
}
-static JsonObject *trg_prefs_new_profile_object() {
+static JsonObject *trg_prefs_new_profile_object()
+{
JsonObject *obj = json_object_new();
return obj;
}
-void trg_prefs_add_default_int(TrgPrefs *p, const gchar *key, int value) {
+void trg_prefs_add_default_int(TrgPrefs * p, const gchar * key, int value)
+{
TrgPrefsPrivate *priv = GET_PRIVATE(p);
json_object_set_int_member(priv->defaultsObj, key, value);
}
-void trg_prefs_add_default_string(TrgPrefs *p, const gchar *key, gchar *value) {
+void trg_prefs_add_default_string(TrgPrefs * p, const gchar * key,
+ gchar * value)
+{
TrgPrefsPrivate *priv = GET_PRIVATE(p);
json_object_set_string_member(priv->defaultsObj, key, value);
}
-void trg_prefs_add_default_double(TrgPrefs *p, const gchar *key, double value) {
+void trg_prefs_add_default_double(TrgPrefs * p, const gchar * key,
+ double value)
+{
TrgPrefsPrivate *priv = GET_PRIVATE(p);
json_object_set_double_member(priv->defaultsObj, key, value);
}
/* Not much point adding a default of FALSE, as that's the fallback */
-void trg_prefs_add_default_bool_true(TrgPrefs *p, const gchar *key) {
+void trg_prefs_add_default_bool_true(TrgPrefs * p, const gchar * key)
+{
TrgPrefsPrivate *priv = GET_PRIVATE(p);
json_object_set_boolean_member(priv->defaultsObj, key, TRUE);
}
-gint trg_prefs_get_profile_id(TrgPrefs *p) {
+gint trg_prefs_get_profile_id(TrgPrefs * p)
+{
TrgPrefsPrivate *priv = GET_PRIVATE(p);
return (gint) json_object_get_int_member(priv->userObj,
- TRG_PREFS_KEY_PROFILE_ID);
+ TRG_PREFS_KEY_PROFILE_ID);
}
-static JsonNode *trg_prefs_get_value_inner(JsonObject *obj, const gchar *key, int type, int flags)
+static JsonNode *trg_prefs_get_value_inner(JsonObject * obj,
+ const gchar * key, int type,
+ int flags)
{
if (json_object_has_member(obj, key)) {
- if ((flags & TRG_PREFS_REPLACENODE))
- json_object_remove_member(obj, key);
- else
- return json_object_get_member(obj, key);
+ if ((flags & TRG_PREFS_REPLACENODE))
+ json_object_remove_member(obj, key);
+ else
+ return json_object_get_member(obj, key);
}
if ((flags & TRG_PREFS_NEWNODE) || (flags & TRG_PREFS_REPLACENODE)) {
- JsonNode *newNode = json_node_new(type);
- json_object_set_member(obj, key, newNode);
- return newNode;
+ JsonNode *newNode = json_node_new(type);
+ json_object_set_member(obj, key, newNode);
+ return newNode;
}
return NULL;
}
-JsonNode *trg_prefs_get_value(TrgPrefs *p, const gchar *key, int type, int flags) {
+JsonNode *trg_prefs_get_value(TrgPrefs * p, const gchar * key, int type,
+ int flags)
+{
TrgPrefsPrivate *priv = GET_PRIVATE(p);
JsonNode *res;
if (priv->profile && (flags & TRG_PREFS_PROFILE)) {
- if ((res = trg_prefs_get_value_inner(priv->profile, key, type, flags)))
- return res;
+ if ((res =
+ trg_prefs_get_value_inner(priv->profile, key, type, flags)))
+ return res;
} else if (priv->connectionObj && (flags & TRG_PREFS_CONNECTION)) {
- if ((res = trg_prefs_get_value_inner(priv->connectionObj, key, type, flags)))
- return res;
+ if ((res =
+ trg_prefs_get_value_inner(priv->connectionObj, key, type,
+ flags)))
+ return res;
} else {
- if ((res = trg_prefs_get_value_inner(priv->userObj, key, type, flags)))
- return res;
+ if ((res =
+ trg_prefs_get_value_inner(priv->userObj, key, type, flags)))
+ return res;
}
- if (priv->defaultsObj && json_object_has_member(priv->defaultsObj, key))
- return json_object_get_member(priv->defaultsObj, key);
+ if (priv->defaultsObj
+ && json_object_has_member(priv->defaultsObj, key))
+ return json_object_get_member(priv->defaultsObj, key);
return NULL;
}
-void trg_prefs_set_connection(TrgPrefs *p, JsonObject *profile)
+void trg_prefs_set_connection(TrgPrefs * p, JsonObject * profile)
{
TrgPrefsPrivate *priv = GET_PRIVATE(p);
if (priv->connectionObj)
- json_object_unref(priv->connectionObj);
+ json_object_unref(priv->connectionObj);
if (profile)
- json_object_ref(profile);
+ json_object_ref(profile);
priv->connectionObj = profile;
}
-gchar *trg_prefs_get_string(TrgPrefs *p, const gchar *key, int flags) {
+gchar *trg_prefs_get_string(TrgPrefs * p, const gchar * key, int flags)
+{
JsonNode *node = trg_prefs_get_value(p, key, JSON_NODE_VALUE, flags);
if (node)
- return g_strdup(json_node_get_string(node));
+ return g_strdup(json_node_get_string(node));
else
- return NULL;
+ return NULL;
}
-JsonArray *trg_prefs_get_array(TrgPrefs *p, const gchar *key, int flags)
+JsonArray *trg_prefs_get_array(TrgPrefs * p, const gchar * key, int flags)
{
JsonNode *node = trg_prefs_get_value(p, key, JSON_NODE_ARRAY, flags);
if (node)
- return json_node_get_array(node);
+ return json_node_get_array(node);
else
- return NULL;
+ return NULL;
}
-gint64 trg_prefs_get_int(TrgPrefs *p, const gchar *key, int flags) {
+gint64 trg_prefs_get_int(TrgPrefs * p, const gchar * key, int flags)
+{
JsonNode *node = trg_prefs_get_value(p, key, JSON_NODE_VALUE, flags);
if (node)
- return json_node_get_int(node);
+ return json_node_get_int(node);
else
- return 0;
+ return 0;
}
-gdouble trg_prefs_get_double(TrgPrefs *p, const gchar *key, int flags) {
+gdouble trg_prefs_get_double(TrgPrefs * p, const gchar * key, int flags)
+{
JsonNode *node = trg_prefs_get_value(p, key, JSON_NODE_VALUE, flags);
if (node)
- return json_node_get_double(node);
+ return json_node_get_double(node);
else
- return 0.0;
+ return 0.0;
}
-gboolean trg_prefs_get_bool(TrgPrefs *p, const gchar *key, int flags) {
+gboolean trg_prefs_get_bool(TrgPrefs * p, const gchar * key, int flags)
+{
JsonNode *node = trg_prefs_get_value(p, key, JSON_NODE_VALUE, flags);
if (node)
- return json_node_get_boolean(node);
+ return json_node_get_boolean(node);
else
- return FALSE;
+ return FALSE;
}
-void trg_prefs_set_int(TrgPrefs *p, const gchar *key, int value, int flags) {
- JsonNode *node = trg_prefs_get_value(p, key, JSON_NODE_VALUE, flags | TRG_PREFS_NEWNODE);
+void trg_prefs_set_int(TrgPrefs * p, const gchar * key, int value,
+ int flags)
+{
+ JsonNode *node =
+ trg_prefs_get_value(p, key, JSON_NODE_VALUE,
+ flags | TRG_PREFS_NEWNODE);
json_node_set_int(node, (gint64) value);
trg_prefs_changed_emit_signal(p, key);
}
-void trg_prefs_set_string(TrgPrefs *p, const gchar *key, const gchar *value,
- int flags) {
- JsonNode *node = trg_prefs_get_value(p, key, JSON_NODE_VALUE, flags | TRG_PREFS_NEWNODE);
+void trg_prefs_set_string(TrgPrefs * p, const gchar * key,
+ const gchar * value, int flags)
+{
+ JsonNode *node =
+ trg_prefs_get_value(p, key, JSON_NODE_VALUE,
+ flags | TRG_PREFS_NEWNODE);
json_node_set_string(node, value);
trg_prefs_changed_emit_signal(p, key);
}
-void trg_prefs_set_profile(TrgPrefs *p, JsonObject *profile) {
+void trg_prefs_set_profile(TrgPrefs * p, JsonObject * profile)
+{
TrgPrefsPrivate *priv = GET_PRIVATE(p);
GList *profiles = json_array_get_elements(trg_prefs_get_profiles(p));
priv->profile = profile;
@@ -314,11 +353,12 @@ void trg_prefs_set_profile(TrgPrefs *p, JsonObject *profile) {
gint i = 0;
for (li = profiles; li; li = g_list_next(li)) {
- if (json_node_get_object((JsonNode*) li->data) == profile) {
- trg_prefs_set_int(p, TRG_PREFS_KEY_PROFILE_ID, i, TRG_PREFS_GLOBAL);
- break;
- }
- i++;
+ if (json_node_get_object((JsonNode *) li->data) == profile) {
+ trg_prefs_set_int(p, TRG_PREFS_KEY_PROFILE_ID, i,
+ TRG_PREFS_GLOBAL);
+ break;
+ }
+ i++;
}
g_list_free(profiles);
@@ -327,14 +367,16 @@ void trg_prefs_set_profile(TrgPrefs *p, JsonObject *profile) {
trg_prefs_profile_change_emit_signal(p);
}
-JsonObject *trg_prefs_new_profile(TrgPrefs *p) {
+JsonObject *trg_prefs_new_profile(TrgPrefs * p)
+{
JsonArray *profiles = trg_prefs_get_profiles(p);
JsonObject *newp = trg_prefs_new_profile_object();
json_array_add_object_element(profiles, newp);
return newp;
}
-void trg_prefs_del_profile(TrgPrefs *p, JsonObject *profile) {
+void trg_prefs_del_profile(TrgPrefs * p, JsonObject * profile)
+{
JsonArray *profiles = trg_prefs_get_profiles(p);
GList *profilesList = json_array_get_elements(profiles);
@@ -343,12 +385,12 @@ void trg_prefs_del_profile(TrgPrefs *p, JsonObject *profile) {
int i = 0;
for (li = profilesList; li; li = g_list_next(li)) {
- node = (JsonNode*) li->data;
- if (profile == (gpointer) json_node_get_object(node)) {
- json_array_remove_element(profiles, i);
- break;
- }
- i++;
+ node = (JsonNode *) li->data;
+ if (profile == (gpointer) json_node_get_object(node)) {
+ json_array_remove_element(profiles, i);
+ break;
+ }
+ i++;
}
g_list_free(profilesList);
@@ -356,34 +398,47 @@ void trg_prefs_del_profile(TrgPrefs *p, JsonObject *profile) {
trg_prefs_profile_change_emit_signal(p);
}
-JsonObject* trg_prefs_get_profile(TrgPrefs *p) {
+JsonObject *trg_prefs_get_profile(TrgPrefs * p)
+{
TrgPrefsPrivate *priv = GET_PRIVATE(p);
return priv->profile;
}
-JsonObject* trg_prefs_get_connection(TrgPrefs *p) {
+JsonObject *trg_prefs_get_connection(TrgPrefs * p)
+{
TrgPrefsPrivate *priv = GET_PRIVATE(p);
return priv->connectionObj;
}
-JsonArray* trg_prefs_get_profiles(TrgPrefs *p) {
+JsonArray *trg_prefs_get_profiles(TrgPrefs * p)
+{
TrgPrefsPrivate *priv = GET_PRIVATE(p);
- return json_object_get_array_member(priv->userObj, TRG_PREFS_KEY_PROFILES);
+ return json_object_get_array_member(priv->userObj,
+ TRG_PREFS_KEY_PROFILES);
}
-void trg_prefs_set_double(TrgPrefs *p, const gchar *key, gdouble value, int flags) {
- JsonNode *node = trg_prefs_get_value(p, key, JSON_NODE_VALUE, flags | TRG_PREFS_NEWNODE);
+void trg_prefs_set_double(TrgPrefs * p, const gchar * key, gdouble value,
+ int flags)
+{
+ JsonNode *node =
+ trg_prefs_get_value(p, key, JSON_NODE_VALUE,
+ flags | TRG_PREFS_NEWNODE);
json_node_set_double(node, value);
trg_prefs_changed_emit_signal(p, key);
}
-void trg_prefs_set_bool(TrgPrefs *p, const gchar *key, gboolean value, int flags) {
- JsonNode *node = trg_prefs_get_value(p, key, JSON_NODE_VALUE, flags | TRG_PREFS_NEWNODE);
+void trg_prefs_set_bool(TrgPrefs * p, const gchar * key, gboolean value,
+ int flags)
+{
+ JsonNode *node =
+ trg_prefs_get_value(p, key, JSON_NODE_VALUE,
+ flags | TRG_PREFS_NEWNODE);
json_node_set_boolean(node, value);
trg_prefs_changed_emit_signal(p, key);
}
-gboolean trg_prefs_save(TrgPrefs *p) {
+gboolean trg_prefs_save(TrgPrefs * p)
+{
TrgPrefsPrivate *priv = GET_PRIVATE(p);
JsonGenerator *gen = json_generator_new();
gchar *dirName;
@@ -392,16 +447,18 @@ gboolean trg_prefs_save(TrgPrefs *p) {
dirName = g_path_get_dirname(priv->file);
if (!g_file_test(dirName, G_FILE_TEST_IS_DIR)) {
- success = g_mkdir_with_parents(dirName, TRG_PREFS_DEFAULT_DIR_MODE)
- == 0;
+ success = g_mkdir_with_parents(dirName, TRG_PREFS_DEFAULT_DIR_MODE)
+ == 0;
} else if (g_file_test(priv->file, G_FILE_TEST_IS_REGULAR)) {
- isNew = FALSE;
+ isNew = FALSE;
}
g_free(dirName);
if (!success) {
- g_error("Problem creating parent directory (permissions?) for: %s\n", priv->file);
- return success;
+ g_error
+ ("Problem creating parent directory (permissions?) for: %s\n",
+ priv->file);
+ return success;
}
g_object_set(G_OBJECT(gen), "pretty", TRUE, NULL);
@@ -410,21 +467,24 @@ gboolean trg_prefs_save(TrgPrefs *p) {
success = json_generator_to_file(gen, priv->file, NULL);
if (!success)
- g_error("Problem writing configuration file (permissions?) to: %s", priv->file);
+ g_error("Problem writing configuration file (permissions?) to: %s",
+ priv->file);
else if (isNew)
- g_chmod(priv->file, 384);
+ g_chmod(priv->file, 384);
g_object_unref(gen);
return success;
}
-JsonObject *trg_prefs_get_root(TrgPrefs *p) {
+JsonObject *trg_prefs_get_root(TrgPrefs * p)
+{
TrgPrefsPrivate *priv = GET_PRIVATE(p);
return priv->userObj;
}
-void trg_prefs_empty_init(TrgPrefs *p) {
+void trg_prefs_empty_init(TrgPrefs * p)
+{
TrgPrefsPrivate *priv = GET_PRIVATE(p);
priv->user = json_node_new(JSON_NODE_OBJECT);
priv->userObj = json_object_new();
@@ -435,12 +495,13 @@ void trg_prefs_empty_init(TrgPrefs *p) {
JsonArray *profiles = json_array_new();
json_array_add_object_element(profiles, priv->profile);
json_object_set_array_member(priv->userObj, TRG_PREFS_KEY_PROFILES,
- profiles);
+ profiles);
json_object_set_int_member(priv->userObj, TRG_PREFS_KEY_PROFILE_ID, 0);
}
-void trg_prefs_load(TrgPrefs *p) {
+void trg_prefs_load(TrgPrefs * p)
+{
TrgPrefsPrivate *priv = GET_PRIVATE(p);
JsonParser *parser = json_parser_new();
JsonNode *root;
@@ -450,59 +511,63 @@ void trg_prefs_load(TrgPrefs *p) {
gboolean parsed = json_parser_load_from_file(parser, priv->file, NULL);
if (!parsed) {
- trg_prefs_empty_init(p);
- g_object_unref(parser);
- return;
+ trg_prefs_empty_init(p);
+ g_object_unref(parser);
+ return;
}
root = json_parser_get_root(parser);
if (root) {
- priv->user = json_node_copy(root);
- priv->userObj = json_node_get_object(priv->user);
+ priv->user = json_node_copy(root);
+ priv->userObj = json_node_get_object(priv->user);
}
g_object_unref(parser);
if (!root) {
- trg_prefs_empty_init(p);
- return;
+ trg_prefs_empty_init(p);
+ return;
}
if (!json_object_has_member(priv->userObj, TRG_PREFS_KEY_PROFILES)) {
- profiles = json_array_new();
- json_object_set_array_member(priv->userObj, TRG_PREFS_KEY_PROFILES,
- profiles);
+ profiles = json_array_new();
+ json_object_set_array_member(priv->userObj, TRG_PREFS_KEY_PROFILES,
+ profiles);
} else {
- profiles = json_object_get_array_member(priv->userObj,
- TRG_PREFS_KEY_PROFILES);
+ profiles = json_object_get_array_member(priv->userObj,
+ TRG_PREFS_KEY_PROFILES);
}
n_profiles = json_array_get_length(profiles);
if (n_profiles < 1) {
- priv->profile = trg_prefs_new_profile_object();
- json_array_add_object_element(profiles, priv->profile);
- trg_prefs_set_int(p, TRG_PREFS_KEY_PROFILE_ID, 0, TRG_PREFS_GLOBAL);
+ priv->profile = trg_prefs_new_profile_object();
+ json_array_add_object_element(profiles, priv->profile);
+ trg_prefs_set_int(p, TRG_PREFS_KEY_PROFILE_ID, 0,
+ TRG_PREFS_GLOBAL);
} else {
- gint profile_id = trg_prefs_get_int(p, TRG_PREFS_KEY_PROFILE_ID,
- TRG_PREFS_GLOBAL);
- if (profile_id >= n_profiles)
- trg_prefs_set_int(p, TRG_PREFS_KEY_PROFILE_ID, profile_id = 0,
- TRG_PREFS_GLOBAL);
-
- priv->profile = json_array_get_object_element(profiles, profile_id);
+ gint profile_id = trg_prefs_get_int(p, TRG_PREFS_KEY_PROFILE_ID,
+ TRG_PREFS_GLOBAL);
+ if (profile_id >= n_profiles)
+ trg_prefs_set_int(p, TRG_PREFS_KEY_PROFILE_ID, profile_id = 0,
+ TRG_PREFS_GLOBAL);
+
+ priv->profile =
+ json_array_get_object_element(profiles, profile_id);
}
}
-guint trg_prefs_get_add_flags(TrgPrefs *p)
+guint trg_prefs_get_add_flags(TrgPrefs * p)
{
guint flags = 0x00;
- if (trg_prefs_get_bool(p, TRG_PREFS_KEY_START_PAUSED, TRG_PREFS_GLOBAL))
- flags |= TORRENT_ADD_FLAG_PAUSED;
+ if (trg_prefs_get_bool
+ (p, TRG_PREFS_KEY_START_PAUSED, TRG_PREFS_GLOBAL))
+ flags |= TORRENT_ADD_FLAG_PAUSED;
- if (trg_prefs_get_bool(p, TRG_PREFS_KEY_DELETE_LOCAL_TORRENT, TRG_PREFS_GLOBAL))
- flags |= TORRENT_ADD_FLAG_DELETE;
+ if (trg_prefs_get_bool
+ (p, TRG_PREFS_KEY_DELETE_LOCAL_TORRENT, TRG_PREFS_GLOBAL))
+ flags |= TORRENT_ADD_FLAG_DELETE;
return flags;
}
diff --git a/src/trg-prefs.h b/src/trg-prefs.h
index 9a737e6..bb86264 100644
--- a/src/trg-prefs.h
+++ b/src/trg-prefs.h
@@ -76,78 +76,77 @@
#define TRG_PREFS_KEY_DESTINATIONS_SUBKEY_DIR "dir"
-#define TRG_PREFS_NOFLAGS (1 << 0) /* 0x00 */
-#define TRG_PREFS_GLOBAL (1 << 1) /* 0x01 */
-#define TRG_PREFS_PROFILE (1 << 2) /* 0x02 */
-#define TRG_PREFS_CONNECTION (1 << 3) /* 0x04 */
-#define TRG_PREFS_NEWNODE (1 << 4) /* 0x08 */
-#define TRG_PREFS_REPLACENODE (1 << 5) /* 0x16 */
+#define TRG_PREFS_NOFLAGS (1 << 0) /* 0x00 */
+#define TRG_PREFS_GLOBAL (1 << 1) /* 0x01 */
+#define TRG_PREFS_PROFILE (1 << 2) /* 0x02 */
+#define TRG_PREFS_CONNECTION (1 << 3) /* 0x04 */
+#define TRG_PREFS_NEWNODE (1 << 4) /* 0x08 */
+#define TRG_PREFS_REPLACENODE (1 << 5) /* 0x16 */
G_BEGIN_DECLS
-
#define TRG_TYPE_PREFS trg_prefs_get_type()
-
#define TRG_PREFS(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), TRG_TYPE_PREFS, TrgPrefs))
-
#define TRG_PREFS_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), TRG_TYPE_PREFS, TrgPrefsClass))
-
#define TRG_IS_PREFS(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRG_TYPE_PREFS))
-
#define TRG_IS_PREFS_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), TRG_TYPE_PREFS))
-
#define TRG_PREFS_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), TRG_TYPE_PREFS, TrgPrefsClass))
-
-typedef struct {
- GObject parent;
+ typedef struct {
+ GObject parent;
} TrgPrefs;
typedef struct {
- GObjectClass parent_class;
- void (*pref_changed) (TrgPrefs *tc, const gchar *key, gpointer data);
+ GObjectClass parent_class;
+ void (*pref_changed) (TrgPrefs * tc, const gchar * key, gpointer data);
} TrgPrefsClass;
-GType trg_prefs_get_type (void);
-
-TrgPrefs* trg_prefs_new (void);
-
-void trg_prefs_add_default_int(TrgPrefs *p, const gchar *key, int value);
-void trg_prefs_add_default_string(TrgPrefs *p, const gchar *key, gchar *value);
-void trg_prefs_add_default_double(TrgPrefs *p, const gchar *key, double value);
-void trg_prefs_add_default_bool_true(TrgPrefs *p, const gchar *key);
-
-JsonNode *trg_prefs_get_value(TrgPrefs *p, const gchar *key, int type, int flags);
-gchar *trg_prefs_get_string(TrgPrefs *p, const gchar *key, int flags);
-gint64 trg_prefs_get_int(TrgPrefs *p, const gchar *key, int flags);
-gdouble trg_prefs_get_double(TrgPrefs *p, const gchar *key, int flags);
-gboolean trg_prefs_get_bool(TrgPrefs *p, const gchar *key, int flags);
-JsonObject* trg_prefs_get_profile(TrgPrefs *p);
-JsonObject* trg_prefs_get_connection(TrgPrefs *p);
-JsonArray* trg_prefs_get_profiles(TrgPrefs *p);
-void trg_prefs_set_connection(TrgPrefs *p, JsonObject *profile);
-gint trg_prefs_get_profile_id(TrgPrefs *p);
-void trg_prefs_del_profile(TrgPrefs *p, JsonObject *profile);
-void trg_prefs_set_profile(TrgPrefs *p, JsonObject *profile);
-JsonObject *trg_prefs_new_profile(TrgPrefs *p);
-JsonObject *trg_get_current_profile(TrgPrefs *p);
-JsonObject *trg_prefs_get_root(TrgPrefs *p);
-JsonArray *trg_prefs_get_array(TrgPrefs *p, const gchar *key, int flags);
-
-void trg_prefs_set_int(TrgPrefs *p, const gchar *key, int value, int flags);
-void trg_prefs_set_string(TrgPrefs *p, const gchar *key, const gchar *value, int flags);
-void trg_prefs_set_double(TrgPrefs *p, const gchar *key, double value, int flags);
-void trg_prefs_set_bool(TrgPrefs *p, const gchar *key, gboolean value, int flags);
-
-gboolean trg_prefs_save(TrgPrefs *p);
-void trg_prefs_load(TrgPrefs *p);
-void trg_prefs_changed_emit_signal(TrgPrefs *p, const gchar *key);
-void trg_prefs_profile_change_emit_signal(TrgPrefs *p);
-guint trg_prefs_get_add_flags(TrgPrefs *p);
+GType trg_prefs_get_type(void);
+
+TrgPrefs *trg_prefs_new(void);
+
+void trg_prefs_add_default_int(TrgPrefs * p, const gchar * key, int value);
+void trg_prefs_add_default_string(TrgPrefs * p, const gchar * key,
+ gchar * value);
+void trg_prefs_add_default_double(TrgPrefs * p, const gchar * key,
+ double value);
+void trg_prefs_add_default_bool_true(TrgPrefs * p, const gchar * key);
+
+JsonNode *trg_prefs_get_value(TrgPrefs * p, const gchar * key, int type,
+ int flags);
+gchar *trg_prefs_get_string(TrgPrefs * p, const gchar * key, int flags);
+gint64 trg_prefs_get_int(TrgPrefs * p, const gchar * key, int flags);
+gdouble trg_prefs_get_double(TrgPrefs * p, const gchar * key, int flags);
+gboolean trg_prefs_get_bool(TrgPrefs * p, const gchar * key, int flags);
+JsonObject *trg_prefs_get_profile(TrgPrefs * p);
+JsonObject *trg_prefs_get_connection(TrgPrefs * p);
+JsonArray *trg_prefs_get_profiles(TrgPrefs * p);
+void trg_prefs_set_connection(TrgPrefs * p, JsonObject * profile);
+gint trg_prefs_get_profile_id(TrgPrefs * p);
+void trg_prefs_del_profile(TrgPrefs * p, JsonObject * profile);
+void trg_prefs_set_profile(TrgPrefs * p, JsonObject * profile);
+JsonObject *trg_prefs_new_profile(TrgPrefs * p);
+JsonObject *trg_get_current_profile(TrgPrefs * p);
+JsonObject *trg_prefs_get_root(TrgPrefs * p);
+JsonArray *trg_prefs_get_array(TrgPrefs * p, const gchar * key, int flags);
+
+void trg_prefs_set_int(TrgPrefs * p, const gchar * key, int value,
+ int flags);
+void trg_prefs_set_string(TrgPrefs * p, const gchar * key,
+ const gchar * value, int flags);
+void trg_prefs_set_double(TrgPrefs * p, const gchar * key, double value,
+ int flags);
+void trg_prefs_set_bool(TrgPrefs * p, const gchar * key, gboolean value,
+ int flags);
+
+gboolean trg_prefs_save(TrgPrefs * p);
+void trg_prefs_load(TrgPrefs * p);
+void trg_prefs_changed_emit_signal(TrgPrefs * p, const gchar * key);
+void trg_prefs_profile_change_emit_signal(TrgPrefs * p);
+guint trg_prefs_get_add_flags(TrgPrefs * p);
G_END_DECLS
-
-#endif /* _TRG_PREFS_H_ */
+#endif /* _TRG_PREFS_H_ */
diff --git a/src/trg-remote-prefs-dialog.c b/src/trg-remote-prefs-dialog.c
index b9a059e..6169706 100644
--- a/src/trg-remote-prefs-dialog.c
+++ b/src/trg-remote-prefs-dialog.c
@@ -41,7 +41,7 @@
*/
G_DEFINE_TYPE(TrgRemotePrefsDialog, trg_remote_prefs_dialog,
- GTK_TYPE_DIALOG)
+ GTK_TYPE_DIALOG)
#define TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_REMOTE_PREFS_DIALOG, TrgRemotePrefsDialogPrivate))
enum {
@@ -62,9 +62,10 @@ struct _TrgRemotePrefsDialogPrivate {
static GObject *instance = NULL;
-static void update_session(GtkDialog * dlg) {
+static void update_session(GtkDialog * dlg)
+{
TrgRemotePrefsDialogPrivate *priv =
- TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(dlg);
+ TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(dlg);
JsonNode *request = session_set();
JsonObject *args = node_get_arguments(request);
@@ -72,16 +73,17 @@ static void update_session(GtkDialog * dlg) {
/* Connection */
- switch (gtk_combo_box_get_active(GTK_COMBO_BOX(priv->encryption_combo))) {
+ switch (gtk_combo_box_get_active
+ (GTK_COMBO_BOX(priv->encryption_combo))) {
case 0:
- encryption = "required";
- break;
+ encryption = "required";
+ break;
case 2:
- encryption = "tolerated";
- break;
+ encryption = "tolerated";
+ break;
default:
- encryption = "preferred";
- break;
+ encryption = "preferred";
+ break;
}
json_object_set_string_member(args, SGET_ENCRYPTION, encryption);
@@ -92,12 +94,13 @@ static void update_session(GtkDialog * dlg) {
}
static void trg_remote_prefs_response_cb(GtkDialog * dlg, gint res_id,
- gpointer data G_GNUC_UNUSED) {
+ gpointer data G_GNUC_UNUSED)
+{
TrgRemotePrefsDialogPrivate *priv =
- TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(dlg);
+ TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(dlg);
if (res_id == GTK_RESPONSE_OK)
- update_session(dlg);
+ update_session(dlg);
trg_json_widget_desc_list_free(priv->widgets);
@@ -106,43 +109,50 @@ static void trg_remote_prefs_response_cb(GtkDialog * dlg, gint res_id,
}
static void trg_remote_prefs_dialog_get_property(GObject * object,
- guint property_id, GValue * value, GParamSpec * pspec) {
+ guint property_id,
+ GValue * value,
+ GParamSpec * pspec)
+{
TrgRemotePrefsDialogPrivate *priv =
- TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(object);
+ TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(object);
switch (property_id) {
case PROP_PARENT:
- g_value_set_object(value, priv->parent);
- break;
+ g_value_set_object(value, priv->parent);
+ break;
case PROP_CLIENT:
- g_value_set_pointer(value, priv->client);
- break;
+ g_value_set_pointer(value, priv->client);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
static void trg_remote_prefs_dialog_set_property(GObject * object,
- guint property_id, const GValue * value, GParamSpec * pspec) {
+ guint property_id,
+ const GValue * value,
+ GParamSpec * pspec)
+{
TrgRemotePrefsDialogPrivate *priv =
- TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(object);
+ TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(object);
switch (property_id) {
case PROP_PARENT:
- priv->parent = g_value_get_object(value);
- break;
+ priv->parent = g_value_get_object(value);
+ break;
case PROP_CLIENT:
- priv->client = g_value_get_pointer(value);
- break;
+ priv->client = g_value_get_pointer(value);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
static GtkWidget *trg_rprefs_limitsPage(TrgRemotePrefsDialog * win,
- JsonObject * json) {
+ JsonObject * json)
+{
TrgRemotePrefsDialogPrivate *priv =
- TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(win);
+ TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(win);
GtkWidget *w, *tb, *t;
gint row = 0;
@@ -151,97 +161,112 @@ static GtkWidget *trg_rprefs_limitsPage(TrgRemotePrefsDialog * win,
hig_workarea_add_section_title(t, &row, _("Bandwidth"));
tb = trg_json_widget_check_new(&priv->widgets, json,
- SGET_SPEED_LIMIT_DOWN_ENABLED, _("Limit download speed (KB/s)"),
- NULL);
+ SGET_SPEED_LIMIT_DOWN_ENABLED,
+ _("Limit download speed (KB/s)"), NULL);
w = trg_json_widget_spin_new_int(&priv->widgets, json,
- SGET_SPEED_LIMIT_DOWN, tb, 0, INT_MAX, 1);
+ SGET_SPEED_LIMIT_DOWN, tb, 0, INT_MAX,
+ 1);
hig_workarea_add_row_w(t, &row, tb, w, NULL);
tb = trg_json_widget_check_new(&priv->widgets, json,
- SGET_SPEED_LIMIT_UP_ENABLED, _("Limit upload speed (KB/s)"), NULL);
- w = trg_json_widget_spin_new_int(&priv->widgets, json, SGET_SPEED_LIMIT_UP,
- tb, 0, INT_MAX, 1);
+ SGET_SPEED_LIMIT_UP_ENABLED,
+ _("Limit upload speed (KB/s)"), NULL);
+ w = trg_json_widget_spin_new_int(&priv->widgets, json,
+ SGET_SPEED_LIMIT_UP, tb, 0, INT_MAX,
+ 1);
hig_workarea_add_row_w(t, &row, tb, w, NULL);
hig_workarea_add_section_title(t, &row, _("Seeding"));
tb = trg_json_widget_check_new(&priv->widgets, json,
- SGET_SEED_RATIO_LIMITED, _("Seed ratio limit"), NULL);
+ SGET_SEED_RATIO_LIMITED,
+ _("Seed ratio limit"), NULL);
w = trg_json_widget_spin_new_double(&priv->widgets, json,
- SGET_SEED_RATIO_LIMIT, tb, 0, INT_MAX, 0.1);
+ SGET_SEED_RATIO_LIMIT, tb, 0,
+ INT_MAX, 0.1);
hig_workarea_add_row_w(t, &row, tb, w, NULL);
if (json_object_has_member(json, SGET_DOWNLOAD_QUEUE_ENABLED)) {
- hig_workarea_add_section_title(t, &row, _("Queues"));
-
- tb = trg_json_widget_check_new(&priv->widgets, json,
- SGET_DOWNLOAD_QUEUE_ENABLED, _("Download queue size"), NULL);
- w = trg_json_widget_spin_new_int(&priv->widgets, json,
- SGET_DOWNLOAD_QUEUE_SIZE, tb, 0, INT_MAX, 1);
- hig_workarea_add_row_w(t, &row, tb, w, NULL);
-
- tb = trg_json_widget_check_new(&priv->widgets, json,
- SGET_SEED_QUEUE_ENABLED, _("Seed queue size"), NULL);
- w = trg_json_widget_spin_new_int(&priv->widgets, json,
- SGET_SEED_QUEUE_SIZE, tb, 0, INT_MAX, 1);
- hig_workarea_add_row_w(t, &row, tb, w, NULL);
-
- tb
- = trg_json_widget_check_new(&priv->widgets, json,
- SGET_QUEUE_STALLED_ENABLED,
- _("Ignore stalled (minutes)"), NULL);
- w = trg_json_widget_spin_new_int(&priv->widgets, json,
- SGET_QUEUE_STALLED_MINUTES, tb, 0, INT_MAX, 1);
- hig_workarea_add_row_w(t, &row, tb, w, NULL);
+ hig_workarea_add_section_title(t, &row, _("Queues"));
+
+ tb = trg_json_widget_check_new(&priv->widgets, json,
+ SGET_DOWNLOAD_QUEUE_ENABLED,
+ _("Download queue size"), NULL);
+ w = trg_json_widget_spin_new_int(&priv->widgets, json,
+ SGET_DOWNLOAD_QUEUE_SIZE, tb, 0,
+ INT_MAX, 1);
+ hig_workarea_add_row_w(t, &row, tb, w, NULL);
+
+ tb = trg_json_widget_check_new(&priv->widgets, json,
+ SGET_SEED_QUEUE_ENABLED,
+ _("Seed queue size"), NULL);
+ w = trg_json_widget_spin_new_int(&priv->widgets, json,
+ SGET_SEED_QUEUE_SIZE, tb, 0,
+ INT_MAX, 1);
+ hig_workarea_add_row_w(t, &row, tb, w, NULL);
+
+ tb = trg_json_widget_check_new(&priv->widgets, json,
+ SGET_QUEUE_STALLED_ENABLED,
+ _("Ignore stalled (minutes)"),
+ NULL);
+ w = trg_json_widget_spin_new_int(&priv->widgets, json,
+ SGET_QUEUE_STALLED_MINUTES, tb, 0,
+ INT_MAX, 1);
+ hig_workarea_add_row_w(t, &row, tb, w, NULL);
}
hig_workarea_add_section_title(t, &row, _("Peers"));
w = trg_json_widget_spin_new_int(&priv->widgets, json,
- SGET_PEER_LIMIT_GLOBAL, NULL, 0, INT_MAX, 5);
+ SGET_PEER_LIMIT_GLOBAL, NULL, 0,
+ INT_MAX, 5);
hig_workarea_add_row(t, &row, _("Global peer limit"), w, w);
w = trg_json_widget_spin_new_int(&priv->widgets, json,
- SGET_PEER_LIMIT_PER_TORRENT, NULL, 0, INT_MAX, 5);
+ SGET_PEER_LIMIT_PER_TORRENT, NULL, 0,
+ INT_MAX, 5);
hig_workarea_add_row(t, &row, _("Per torrent peer limit"), w, w);
return t;
}
-static gboolean on_port_tested(gpointer data) {
- trg_response *response = (trg_response*) data;
+static gboolean on_port_tested(gpointer data)
+{
+ trg_response *response = (trg_response *) data;
if (TRG_IS_REMOTE_PREFS_DIALOG(response->cb_data)) {
- TrgRemotePrefsDialogPrivate *priv =
- TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(response->cb_data);
-
- gtk_button_set_label(GTK_BUTTON(priv->port_test_button), _("Retest"));
- gtk_widget_set_sensitive(priv->port_test_button, TRUE);
-
- if (response->status == CURLE_OK) {
- gboolean isOpen = json_object_get_boolean_member(
- get_arguments(response->obj), "port-is-open");
- if (isOpen)
- gtk_label_set_markup(
- GTK_LABEL(priv->port_test_label),
- _
- ("Port is <span font_weight=\"bold\" fgcolor=\"darkgreen\">open</span>"));
- else
- gtk_label_set_markup(
- GTK_LABEL(priv->port_test_label),
- _
- ("Port is <span font_weight=\"bold\" fgcolor=\"red\">closed</span>"));
- } else {
- trg_error_dialog(GTK_WINDOW(data), response);
- }
+ TrgRemotePrefsDialogPrivate *priv =
+ TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(response->cb_data);
+
+ gtk_button_set_label(GTK_BUTTON(priv->port_test_button),
+ _("Retest"));
+ gtk_widget_set_sensitive(priv->port_test_button, TRUE);
+
+ if (response->status == CURLE_OK) {
+ gboolean isOpen =
+ json_object_get_boolean_member(get_arguments
+ (response->obj),
+ "port-is-open");
+ if (isOpen)
+ gtk_label_set_markup(GTK_LABEL(priv->port_test_label),
+ _
+ ("Port is <span font_weight=\"bold\" fgcolor=\"darkgreen\">open</span>"));
+ else
+ gtk_label_set_markup(GTK_LABEL(priv->port_test_label),
+ _
+ ("Port is <span font_weight=\"bold\" fgcolor=\"red\">closed</span>"));
+ } else {
+ trg_error_dialog(GTK_WINDOW(data), response);
+ }
}
trg_response_free(response);
return FALSE;
}
-static void port_test_cb(GtkButton * b, gpointer data) {
+static void port_test_cb(GtkButton * b, gpointer data)
+{
TrgRemotePrefsDialogPrivate *priv =
- TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(data);
+ TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(data);
JsonNode *req = port_test();
gtk_label_set_text(GTK_LABEL(priv->port_test_label), _("Port test"));
@@ -251,25 +276,29 @@ static void port_test_cb(GtkButton * b, gpointer data) {
dispatch_async(priv->client, req, on_port_tested, data);
}
-static gboolean on_blocklist_updated(gpointer data) {
- trg_response *response = (trg_response*) data;
+static gboolean on_blocklist_updated(gpointer data)
+{
+ trg_response *response = (trg_response *) data;
if (TRG_IS_REMOTE_PREFS_DIALOG(response->cb_data)) {
- TrgRemotePrefsDialogPrivate *priv =
- TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(response->cb_data);
-
- gtk_widget_set_sensitive(priv->blocklist_update_button, TRUE);
- gtk_button_set_label(GTK_BUTTON(priv->blocklist_update_button),
- _("Update"));
-
- if (response->status == CURLE_OK) {
- JsonObject *args = get_arguments(response->obj);
- gchar *labelText = g_strdup_printf(_("Blocklist (%ld entries)"),
- json_object_get_int_member(args, SGET_BLOCKLIST_SIZE));
- gtk_button_set_label(GTK_BUTTON(priv->blocklist_check), labelText);
- g_free(labelText);
- } else {
- trg_error_dialog(GTK_WINDOW(response->cb_data), response);
- }
+ TrgRemotePrefsDialogPrivate *priv =
+ TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(response->cb_data);
+
+ gtk_widget_set_sensitive(priv->blocklist_update_button, TRUE);
+ gtk_button_set_label(GTK_BUTTON(priv->blocklist_update_button),
+ _("Update"));
+
+ if (response->status == CURLE_OK) {
+ JsonObject *args = get_arguments(response->obj);
+ gchar *labelText =
+ g_strdup_printf(_("Blocklist (%ld entries)"),
+ json_object_get_int_member(args,
+ SGET_BLOCKLIST_SIZE));
+ gtk_button_set_label(GTK_BUTTON(priv->blocklist_check),
+ labelText);
+ g_free(labelText);
+ } else {
+ trg_error_dialog(GTK_WINDOW(response->cb_data), response);
+ }
}
trg_response_free(response);
@@ -277,9 +306,10 @@ static gboolean on_blocklist_updated(gpointer data) {
return FALSE;
}
-static gboolean update_blocklist_cb(GtkButton * b, gpointer data) {
+static gboolean update_blocklist_cb(GtkButton * b, gpointer data)
+{
TrgRemotePrefsDialogPrivate *priv =
- TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(data);
+ TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(data);
JsonNode *req = blocklist_update();
gtk_widget_set_sensitive(GTK_WIDGET(b), FALSE);
@@ -291,9 +321,10 @@ static gboolean update_blocklist_cb(GtkButton * b, gpointer data) {
}
static GtkWidget *trg_rprefs_connPage(TrgRemotePrefsDialog * win,
- JsonObject * s) {
+ JsonObject * s)
+{
TrgRemotePrefsDialogPrivate *priv =
- TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(win);
+ TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(win);
GtkWidget *w, *tb, *t;
const gchar *stringValue;
@@ -302,19 +333,21 @@ static GtkWidget *trg_rprefs_connPage(TrgRemotePrefsDialog * win,
t = hig_workarea_create();
w = priv->encryption_combo = gtr_combo_box_new_enum(_("Required"), 0,
- _("Preferred"), 1, _("Tolerated"), 2, NULL);
+ _("Preferred"), 1,
+ _("Tolerated"), 2,
+ NULL);
stringValue = session_get_encryption(s);
if (g_strcmp0(stringValue, "required") == 0) {
- gtk_combo_box_set_active(GTK_COMBO_BOX(w), 0);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(w), 0);
} else if (g_strcmp0(stringValue, "tolerated") == 0) {
- gtk_combo_box_set_active(GTK_COMBO_BOX(w), 2);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(w), 2);
} else {
- gtk_combo_box_set_active(GTK_COMBO_BOX(w), 1);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(w), 1);
}
hig_workarea_add_row(t, &row, _("Encryption"), w, NULL);
- w = trg_json_widget_spin_new_int(&priv->widgets, s, SGET_PEER_PORT, NULL,
- 0, 65535, 1);
+ w = trg_json_widget_spin_new_int(&priv->widgets, s, SGET_PEER_PORT,
+ NULL, 0, 65535, 1);
hig_workarea_add_row(t, &row, _("Peer port"), w, w);
w = priv->port_test_label = gtk_label_new(_("Port test"));
@@ -323,52 +356,57 @@ static GtkWidget *trg_rprefs_connPage(TrgRemotePrefsDialog * win,
hig_workarea_add_row_w(t, &row, priv->port_test_label, w, NULL);
w = trg_json_widget_check_new(&priv->widgets, s,
- SGET_PEER_PORT_RANDOM_ON_START, _("Random peer port on start"),
- NULL);
+ SGET_PEER_PORT_RANDOM_ON_START,
+ _("Random peer port on start"), NULL);
hig_workarea_add_wide_control(t, &row, w);
w = trg_json_widget_check_new(&priv->widgets, s,
- SGET_PORT_FORWARDING_ENABLED, _("Peer port forwarding"), NULL);
+ SGET_PORT_FORWARDING_ENABLED,
+ _("Peer port forwarding"), NULL);
hig_workarea_add_wide_control(t, &row, w);
w = trg_json_widget_check_new(&priv->widgets, s, SGET_PEX_ENABLED,
- _("Peer exchange (PEX)"), NULL);
+ _("Peer exchange (PEX)"), NULL);
hig_workarea_add_wide_control(t, &row, w);
w = trg_json_widget_check_new(&priv->widgets, s, SGET_DHT_ENABLED,
- _("Distributed Hash Table (DHT)"), NULL);
+ _("Distributed Hash Table (DHT)"), NULL);
hig_workarea_add_wide_control(t, &row, w);
w = trg_json_widget_check_new(&priv->widgets, s, SGET_LPD_ENABLED,
- _("Local peer discovery"), NULL);
+ _("Local peer discovery"), NULL);
hig_workarea_add_wide_control(t, &row, w);
stringValue = g_strdup_printf(_("Blocklist (%ld entries)"),
- session_get_blocklist_size(s));
- tb = priv->blocklist_check = trg_json_widget_check_new(&priv->widgets, s,
- SGET_BLOCKLIST_ENABLED, stringValue, NULL);
+ session_get_blocklist_size(s));
+ tb = priv->blocklist_check =
+ trg_json_widget_check_new(&priv->widgets, s,
+ SGET_BLOCKLIST_ENABLED, stringValue,
+ NULL);
g_free((gchar *) stringValue);
- w = priv->blocklist_update_button = gtk_button_new_with_label(_("Update"));
+ w = priv->blocklist_update_button =
+ gtk_button_new_with_label(_("Update"));
g_signal_connect(G_OBJECT(w), "clicked",
- G_CALLBACK(update_blocklist_cb), win);
+ G_CALLBACK(update_blocklist_cb), win);
hig_workarea_add_row_w(t, &row, tb, w, NULL);
//GtkWidget *trg_json_widget_entry_new(GList **wl, JsonObject *obj, gchar *key, GtkWidget *toggleDep);
stringValue = session_get_blocklist_url(s);
if (stringValue) {
- w = trg_json_widget_entry_new(&priv->widgets, s, SGET_BLOCKLIST_URL,
- NULL);
- hig_workarea_add_row(t, &row, _("Blocklist URL:"), w, NULL);
+ w = trg_json_widget_entry_new(&priv->widgets, s,
+ SGET_BLOCKLIST_URL, NULL);
+ hig_workarea_add_row(t, &row, _("Blocklist URL:"), w, NULL);
}
return t;
}
static GtkWidget *trg_rprefs_generalPage(TrgRemotePrefsDialog * win,
- JsonObject * s) {
+ JsonObject * s)
+{
TrgRemotePrefsDialogPrivate *priv =
- TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(win);
+ TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(win);
GtkWidget *w, *tb, *t;
gint row = 0;
@@ -376,87 +414,104 @@ static GtkWidget *trg_rprefs_generalPage(TrgRemotePrefsDialog * win,
t = hig_workarea_create();
- w = trg_json_widget_entry_new(&priv->widgets, s, SGET_DOWNLOAD_DIR, NULL);
+ w = trg_json_widget_entry_new(&priv->widgets, s, SGET_DOWNLOAD_DIR,
+ NULL);
hig_workarea_add_row(t, &row, _("Download directory"), w, NULL);
tb = trg_json_widget_check_new(&priv->widgets, s,
- SGET_INCOMPLETE_DIR_ENABLED, _("Incomplete download dir"), NULL);
- w = trg_json_widget_entry_new(&priv->widgets, s, SGET_INCOMPLETE_DIR, tb);
+ SGET_INCOMPLETE_DIR_ENABLED,
+ _("Incomplete download dir"), NULL);
+ w = trg_json_widget_entry_new(&priv->widgets, s, SGET_INCOMPLETE_DIR,
+ tb);
hig_workarea_add_row_w(t, &row, tb, w, NULL);
tb = trg_json_widget_check_new(&priv->widgets, s,
- SGET_SCRIPT_TORRENT_DONE_ENABLED, _("Torrent done script"), NULL);
+ SGET_SCRIPT_TORRENT_DONE_ENABLED,
+ _("Torrent done script"), NULL);
w = trg_json_widget_entry_new(&priv->widgets, s,
- SGET_SCRIPT_TORRENT_DONE_FILENAME, tb);
+ SGET_SCRIPT_TORRENT_DONE_FILENAME, tb);
hig_workarea_add_row_w(t, &row, tb, w, NULL);
cache_size_mb = session_get_cache_size_mb(s);
if (cache_size_mb >= 0) {
- w = trg_json_widget_spin_new_int(&priv->widgets, s, SGET_CACHE_SIZE_MB,
- NULL, 0, INT_MAX, 1);
- hig_workarea_add_row(t, &row, _("Cache size (MB)"), w, w);
+ w = trg_json_widget_spin_new_int(&priv->widgets, s,
+ SGET_CACHE_SIZE_MB, NULL, 0,
+ INT_MAX, 1);
+ hig_workarea_add_row(t, &row, _("Cache size (MB)"), w, w);
}
- w = trg_json_widget_check_new(&priv->widgets, s, SGET_RENAME_PARTIAL_FILES,
- _("Rename partial files"), NULL);
+ w = trg_json_widget_check_new(&priv->widgets, s,
+ SGET_RENAME_PARTIAL_FILES,
+ _("Rename partial files"), NULL);
hig_workarea_add_wide_control(t, &row, w);
w = trg_json_widget_check_new(&priv->widgets, s,
- SGET_TRASH_ORIGINAL_TORRENT_FILES, _
- ("Trash original torrent files"), NULL);
+ SGET_TRASH_ORIGINAL_TORRENT_FILES, _
+ ("Trash original torrent files"), NULL);
hig_workarea_add_wide_control(t, &row, w);
- w = trg_json_widget_check_new(&priv->widgets, s, SGET_START_ADDED_TORRENTS,
- _("Start added torrents"), NULL);
+ w = trg_json_widget_check_new(&priv->widgets, s,
+ SGET_START_ADDED_TORRENTS,
+ _("Start added torrents"), NULL);
hig_workarea_add_wide_control(t, &row, w);
return t;
}
static GObject *trg_remote_prefs_dialog_constructor(GType type,
- guint n_construct_properties, GObjectConstructParam * construct_params) {
+ guint
+ n_construct_properties,
+ GObjectConstructParam *
+ construct_params)
+{
GObject *object;
TrgRemotePrefsDialogPrivate *priv;
JsonObject *session;
GtkWidget *notebook, *contentvbox;
object = G_OBJECT_CLASS
- (trg_remote_prefs_dialog_parent_class)->constructor(type,
- n_construct_properties, construct_params);
+ (trg_remote_prefs_dialog_parent_class)->constructor(type,
+ n_construct_properties,
+ construct_params);
priv = TRG_REMOTE_PREFS_DIALOG_GET_PRIVATE(object);
session = trg_client_get_session(priv->client);
contentvbox = gtk_dialog_get_content_area(GTK_DIALOG(object));
gtk_window_set_title(GTK_WINDOW(object), _("Remote Preferences"));
- gtk_window_set_transient_for(GTK_WINDOW(object), GTK_WINDOW(priv->parent));
+ gtk_window_set_transient_for(GTK_WINDOW(object),
+ GTK_WINDOW(priv->parent));
gtk_window_set_destroy_with_parent(GTK_WINDOW(object), TRUE);
gtk_dialog_add_button(GTK_DIALOG(object), GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE);
- gtk_dialog_add_button(GTK_DIALOG(object), GTK_STOCK_OK, GTK_RESPONSE_OK);
+ GTK_RESPONSE_CLOSE);
+ gtk_dialog_add_button(GTK_DIALOG(object), GTK_STOCK_OK,
+ GTK_RESPONSE_OK);
gtk_container_set_border_width(GTK_CONTAINER(object), GUI_PAD);
gtk_dialog_set_default_response(GTK_DIALOG(object), GTK_RESPONSE_OK);
g_signal_connect(G_OBJECT(object),
- "response",
- G_CALLBACK(trg_remote_prefs_response_cb), NULL);
+ "response",
+ G_CALLBACK(trg_remote_prefs_response_cb), NULL);
notebook = gtk_notebook_new();
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
- trg_rprefs_generalPage(TRG_REMOTE_PREFS_DIALOG(object), session),
- gtk_label_new(_("General")));
+ trg_rprefs_generalPage(TRG_REMOTE_PREFS_DIALOG
+ (object), session),
+ gtk_label_new(_("General")));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
- trg_rprefs_connPage(TRG_REMOTE_PREFS_DIALOG(object), session),
- gtk_label_new(_("Connections")));
+ trg_rprefs_connPage(TRG_REMOTE_PREFS_DIALOG
+ (object), session),
+ gtk_label_new(_("Connections")));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
- trg_rprefs_limitsPage(TRG_REMOTE_PREFS_DIALOG(object), session),
- gtk_label_new(_("Limits")));
+ trg_rprefs_limitsPage(TRG_REMOTE_PREFS_DIALOG
+ (object), session),
+ gtk_label_new(_("Limits")));
gtk_container_set_border_width(GTK_CONTAINER(notebook), GUI_PAD);
@@ -465,8 +520,9 @@ static GObject *trg_remote_prefs_dialog_constructor(GType type,
return object;
}
-static void trg_remote_prefs_dialog_class_init(
- TrgRemotePrefsDialogClass * klass) {
+static void trg_remote_prefs_dialog_class_init(TrgRemotePrefsDialogClass *
+ klass)
+{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
g_type_class_add_private(klass, sizeof(TrgRemotePrefsDialogPrivate));
@@ -475,38 +531,51 @@ static void trg_remote_prefs_dialog_class_init(
object_class->get_property = trg_remote_prefs_dialog_get_property;
object_class->set_property = trg_remote_prefs_dialog_set_property;
- g_object_class_install_property(
- object_class,
- PROP_CLIENT,
- g_param_spec_pointer(
- "trg-client",
- "TClient",
- "Client",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK
- | G_PARAM_STATIC_BLURB));
-
- g_object_class_install_property(
- object_class,
- PROP_PARENT,
- g_param_spec_object(
- "parent-window",
- "Parent window",
- "Parent window",
- TRG_TYPE_MAIN_WINDOW,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK
- | G_PARAM_STATIC_BLURB));
+ g_object_class_install_property(object_class,
+ PROP_CLIENT,
+ g_param_spec_pointer("trg-client",
+ "TClient",
+ "Client",
+ G_PARAM_READWRITE
+ |
+ G_PARAM_CONSTRUCT_ONLY
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
+
+ g_object_class_install_property(object_class,
+ PROP_PARENT,
+ g_param_spec_object("parent-window",
+ "Parent window",
+ "Parent window",
+ TRG_TYPE_MAIN_WINDOW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
}
-static void trg_remote_prefs_dialog_init(TrgRemotePrefsDialog * self G_GNUC_UNUSED) {
+static void trg_remote_prefs_dialog_init(TrgRemotePrefsDialog *
+ self G_GNUC_UNUSED)
+{
}
-TrgRemotePrefsDialog *trg_remote_prefs_dialog_get_instance(
- TrgMainWindow * parent, TrgClient * client) {
+TrgRemotePrefsDialog *trg_remote_prefs_dialog_get_instance(TrgMainWindow *
+ parent,
+ TrgClient *
+ client)
+{
if (instance == NULL) {
- instance = g_object_new(TRG_TYPE_REMOTE_PREFS_DIALOG, "parent-window",
- parent, "trg-client", client, NULL);
+ instance =
+ g_object_new(TRG_TYPE_REMOTE_PREFS_DIALOG, "parent-window",
+ parent, "trg-client", client, NULL);
}
return TRG_REMOTE_PREFS_DIALOG(instance);
diff --git a/src/trg-remote-prefs-dialog.h b/src/trg-remote-prefs-dialog.h
index 0c340a1..412f3af 100644
--- a/src/trg-remote-prefs-dialog.h
+++ b/src/trg-remote-prefs-dialog.h
@@ -48,9 +48,9 @@ typedef struct {
GType trg_remote_prefs_dialog_get_type(void);
TrgRemotePrefsDialog *trg_remote_prefs_dialog_get_instance(TrgMainWindow *
- parent,
- TrgClient *
- client);
+ parent,
+ TrgClient *
+ client);
G_END_DECLS
-#endif /* TRG_REMOTE_PREFS_DIALOG_H_ */
+#endif /* TRG_REMOTE_PREFS_DIALOG_H_ */
diff --git a/src/trg-sortable-filtered-model.c b/src/trg-sortable-filtered-model.c
index 198a723..649d999 100644
--- a/src/trg-sortable-filtered-model.c
+++ b/src/trg-sortable-filtered-model.c
@@ -28,113 +28,178 @@
*/
static void
-trg_sortable_filtered_model_tree_sortable_init(GtkTreeSortableIface *iface);
+trg_sortable_filtered_model_tree_sortable_init(GtkTreeSortableIface *
+ iface);
/* TreeSortable interface */
-static GtkTreeSortable *trg_sortable_filtered_model_get_real_sortable(GtkTreeSortable *sortable);
-static gboolean trg_sortable_filtered_model_sort_get_sort_column_id(
- GtkTreeSortable *sortable, gint *sort_column_id, GtkSortType *order);
-static void trg_sortable_filtered_model_sort_set_sort_column_id(
- GtkTreeSortable *sortable, gint sort_column_id, GtkSortType order);
-static void trg_sortable_filtered_model_sort_set_sort_func(
- GtkTreeSortable *sortable, gint sort_column_id,
- GtkTreeIterCompareFunc func, gpointer data, GDestroyNotify destroy);
-static void trg_sortable_filtered_model_sort_set_default_sort_func(
- GtkTreeSortable *sortable, GtkTreeIterCompareFunc func, gpointer data,
- GDestroyNotify destroy);
-static gboolean trg_sortable_filtered_model_sort_has_default_sort_func(
- GtkTreeSortable *sortable);
-static void trg_sortable_filtered_model_sort_column_changed(GtkTreeSortable *realSortable,
- GtkTreeSortable *fakeSortable);
-
-G_DEFINE_TYPE_WITH_CODE(
- TrgSortableFilteredModel,
- trg_sortable_filtered_model,
- GTK_TYPE_TREE_MODEL_FILTER,
- G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_SORTABLE, trg_sortable_filtered_model_tree_sortable_init))
-
-static void trg_sortable_filtered_model_class_init(
- TrgSortableFilteredModelClass *klass) {
+static GtkTreeSortable
+ *trg_sortable_filtered_model_get_real_sortable(GtkTreeSortable *
+ sortable);
+static gboolean
+trg_sortable_filtered_model_sort_get_sort_column_id(GtkTreeSortable *
+ sortable,
+ gint * sort_column_id,
+ GtkSortType * order);
+static void
+trg_sortable_filtered_model_sort_set_sort_column_id(GtkTreeSortable *
+ sortable,
+ gint sort_column_id,
+ GtkSortType order);
+static void trg_sortable_filtered_model_sort_set_sort_func(GtkTreeSortable
+ * sortable,
+ gint
+ sort_column_id,
+ GtkTreeIterCompareFunc
+ func,
+ gpointer data,
+ GDestroyNotify
+ destroy);
+static void
+trg_sortable_filtered_model_sort_set_default_sort_func(GtkTreeSortable *
+ sortable,
+ GtkTreeIterCompareFunc
+ func, gpointer data,
+ GDestroyNotify
+ destroy);
+static gboolean
+trg_sortable_filtered_model_sort_has_default_sort_func(GtkTreeSortable *
+ sortable);
+static void trg_sortable_filtered_model_sort_column_changed(GtkTreeSortable
+ * realSortable,
+ GtkTreeSortable
+ *
+ fakeSortable);
+
+G_DEFINE_TYPE_WITH_CODE(TrgSortableFilteredModel,
+ trg_sortable_filtered_model,
+ GTK_TYPE_TREE_MODEL_FILTER,
+ G_IMPLEMENT_INTERFACE(GTK_TYPE_TREE_SORTABLE,
+ trg_sortable_filtered_model_tree_sortable_init))
+
+static void
+trg_sortable_filtered_model_class_init(TrgSortableFilteredModelClass *
+ klass)
+{
}
-static void trg_sortable_filtered_model_init(TrgSortableFilteredModel *self) {
+static void trg_sortable_filtered_model_init(TrgSortableFilteredModel *
+ self)
+{
}
-static void trg_sortable_filtered_model_tree_sortable_init(
- GtkTreeSortableIface *iface) {
+static void
+trg_sortable_filtered_model_tree_sortable_init(GtkTreeSortableIface *
+ iface)
+{
iface->get_sort_column_id =
- trg_sortable_filtered_model_sort_get_sort_column_id;
+ trg_sortable_filtered_model_sort_get_sort_column_id;
iface->set_sort_column_id =
- trg_sortable_filtered_model_sort_set_sort_column_id;
+ trg_sortable_filtered_model_sort_set_sort_column_id;
iface->set_sort_func = trg_sortable_filtered_model_sort_set_sort_func;
iface->set_default_sort_func =
- trg_sortable_filtered_model_sort_set_default_sort_func;
+ trg_sortable_filtered_model_sort_set_default_sort_func;
iface->has_default_sort_func =
- trg_sortable_filtered_model_sort_has_default_sort_func;
+ trg_sortable_filtered_model_sort_has_default_sort_func;
}
-static void trg_sortable_filtered_model_sort_column_changed(GtkTreeSortable *realSortable G_GNUC_UNUSED,
- GtkTreeSortable *fakeSortable)
+static void trg_sortable_filtered_model_sort_column_changed(GtkTreeSortable
+ *
+ realSortable
+ G_GNUC_UNUSED,
+ GtkTreeSortable
+ * fakeSortable)
{
- g_signal_emit_by_name (fakeSortable, "sort-column-changed");
+ g_signal_emit_by_name(fakeSortable, "sort-column-changed");
}
-GtkTreeModel *
-trg_sortable_filtered_model_new (GtkTreeSortable *child_model,
- GtkTreePath *root)
+GtkTreeModel *trg_sortable_filtered_model_new(GtkTreeSortable *
+ child_model,
+ GtkTreePath * root)
{
- g_return_val_if_fail (GTK_IS_TREE_MODEL (child_model), NULL);
- g_return_val_if_fail (GTK_IS_TREE_SORTABLE (child_model), NULL);
+ g_return_val_if_fail(GTK_IS_TREE_MODEL(child_model), NULL);
+ g_return_val_if_fail(GTK_IS_TREE_SORTABLE(child_model), NULL);
- GObject *obj = g_object_new (TRG_TYPE_SORTABLE_FILTERED_MODEL,
- "child-model", GTK_TREE_MODEL(child_model),
- "virtual-root", root,
- NULL);
+ GObject *obj = g_object_new(TRG_TYPE_SORTABLE_FILTERED_MODEL,
+ "child-model", GTK_TREE_MODEL(child_model),
+ "virtual-root", root,
+ NULL);
- g_signal_connect (child_model, "sort-column-changed",
- G_CALLBACK (trg_sortable_filtered_model_sort_column_changed),
- obj);
+ g_signal_connect(child_model, "sort-column-changed",
+ G_CALLBACK
+ (trg_sortable_filtered_model_sort_column_changed),
+ obj);
- return GTK_TREE_MODEL(obj);
+ return GTK_TREE_MODEL(obj);
}
-static GtkTreeSortable *trg_sortable_filtered_model_get_real_sortable(GtkTreeSortable *sortable)
+static GtkTreeSortable
+ *trg_sortable_filtered_model_get_real_sortable(GtkTreeSortable *
+ sortable)
{
- return GTK_TREE_SORTABLE(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(sortable)));
+ return
+ GTK_TREE_SORTABLE(gtk_tree_model_filter_get_model
+ (GTK_TREE_MODEL_FILTER(sortable)));
}
-static gboolean trg_sortable_filtered_model_sort_get_sort_column_id(
- GtkTreeSortable *sortable, gint *sort_column_id, GtkSortType *order) {
- GtkTreeSortable *realSortable = trg_sortable_filtered_model_get_real_sortable(sortable);
- return gtk_tree_sortable_get_sort_column_id(realSortable, sort_column_id, order);
+static gboolean
+trg_sortable_filtered_model_sort_get_sort_column_id(GtkTreeSortable *
+ sortable,
+ gint * sort_column_id,
+ GtkSortType * order)
+{
+ GtkTreeSortable *realSortable =
+ trg_sortable_filtered_model_get_real_sortable(sortable);
+ return gtk_tree_sortable_get_sort_column_id(realSortable,
+ sort_column_id, order);
}
-static void trg_sortable_filtered_model_sort_set_sort_column_id(
- GtkTreeSortable *sortable, gint sort_column_id, GtkSortType order)
+static void
+trg_sortable_filtered_model_sort_set_sort_column_id(GtkTreeSortable *
+ sortable,
+ gint sort_column_id,
+ GtkSortType order)
{
- GtkTreeSortable *realSortable = trg_sortable_filtered_model_get_real_sortable(sortable);
- gtk_tree_sortable_set_sort_column_id(realSortable, sort_column_id, order);
+ GtkTreeSortable *realSortable =
+ trg_sortable_filtered_model_get_real_sortable(sortable);
+ gtk_tree_sortable_set_sort_column_id(realSortable, sort_column_id,
+ order);
}
-static void trg_sortable_filtered_model_sort_set_sort_func(
- GtkTreeSortable *sortable, gint sort_column_id,
- GtkTreeIterCompareFunc func, gpointer data, GDestroyNotify destroy)
+static void trg_sortable_filtered_model_sort_set_sort_func(GtkTreeSortable
+ * sortable,
+ gint
+ sort_column_id,
+ GtkTreeIterCompareFunc
+ func,
+ gpointer data,
+ GDestroyNotify
+ destroy)
{
- GtkTreeSortable *realSortable = trg_sortable_filtered_model_get_real_sortable(sortable);
- gtk_tree_sortable_set_sort_func(realSortable, sort_column_id, func, data, destroy);
+ GtkTreeSortable *realSortable =
+ trg_sortable_filtered_model_get_real_sortable(sortable);
+ gtk_tree_sortable_set_sort_func(realSortable, sort_column_id, func,
+ data, destroy);
}
-static void trg_sortable_filtered_model_sort_set_default_sort_func(
- GtkTreeSortable *sortable, GtkTreeIterCompareFunc func, gpointer data,
- GDestroyNotify destroy)
+static void
+trg_sortable_filtered_model_sort_set_default_sort_func(GtkTreeSortable *
+ sortable,
+ GtkTreeIterCompareFunc
+ func, gpointer data,
+ GDestroyNotify
+ destroy)
{
- GtkTreeSortable *realSortable = trg_sortable_filtered_model_get_real_sortable(sortable);
- gtk_tree_sortable_set_default_sort_func(realSortable, func, data, destroy);
+ GtkTreeSortable *realSortable =
+ trg_sortable_filtered_model_get_real_sortable(sortable);
+ gtk_tree_sortable_set_default_sort_func(realSortable, func, data,
+ destroy);
}
-static gboolean trg_sortable_filtered_model_sort_has_default_sort_func(
- GtkTreeSortable *sortable)
+static gboolean
+trg_sortable_filtered_model_sort_has_default_sort_func(GtkTreeSortable *
+ sortable)
{
- GtkTreeSortable *realSortable = trg_sortable_filtered_model_get_real_sortable(sortable);
+ GtkTreeSortable *realSortable =
+ trg_sortable_filtered_model_get_real_sortable(sortable);
return gtk_tree_sortable_has_default_sort_func(realSortable);
}
diff --git a/src/trg-sortable-filtered-model.h b/src/trg-sortable-filtered-model.h
index 50782c8..9abc456 100644
--- a/src/trg-sortable-filtered-model.h
+++ b/src/trg-sortable-filtered-model.h
@@ -24,39 +24,31 @@
#include <gtk/gtk.h>
G_BEGIN_DECLS
-
#define TRG_TYPE_SORTABLE_FILTERED_MODEL trg_sortable_filtered_model_get_type()
-
#define TRG_SORTABLE_FILTERED_MODEL(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), TRG_TYPE_SORTABLE_FILTERED_MODEL, TrgSortableFilteredModel))
-
#define TRG_SORTABLE_FILTERED_MODEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), TRG_TYPE_SORTABLE_FILTERED_MODEL, TrgSortableFilteredModelClass))
-
#define TRG_IS_SORTABLE_FILTERED_MODEL(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRG_TYPE_SORTABLE_FILTERED_MODEL))
-
#define TRG_IS_SORTABLE_FILTERED_MODEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), TRG_TYPE_SORTABLE_FILTERED_MODEL))
-
#define TRG_SORTABLE_FILTERED_MODEL_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), TRG_TYPE_SORTABLE_FILTERED_MODEL, TrgSortableFilteredModelClass))
-
-typedef struct {
- GtkTreeModelFilter parent;
+ typedef struct {
+ GtkTreeModelFilter parent;
} TrgSortableFilteredModel;
typedef struct {
- GtkTreeModelFilterClass parent_class;
+ GtkTreeModelFilterClass parent_class;
} TrgSortableFilteredModelClass;
-GType trg_sortable_filtered_model_get_type (void);
+GType trg_sortable_filtered_model_get_type(void);
-GtkTreeModel *
-trg_sortable_filtered_model_new (GtkTreeSortable *child_model,
- GtkTreePath *root);
+GtkTreeModel *trg_sortable_filtered_model_new(GtkTreeSortable *
+ child_model,
+ GtkTreePath * root);
G_END_DECLS
-
-#endif /* _TRG_SORTABLE_FILTERED_MODEL */
+#endif /* _TRG_SORTABLE_FILTERED_MODEL */
diff --git a/src/trg-state-selector.c b/src/trg-state-selector.c
index 41a552f..eded9f4 100644
--- a/src/trg-state-selector.c
+++ b/src/trg-state-selector.c
@@ -60,17 +60,21 @@ struct _TrgStateSelectorPrivate {
GtkTreeRowReference *error_rr;
};
-GRegex *trg_state_selector_get_url_host_regex(TrgStateSelector * s) {
+GRegex *trg_state_selector_get_url_host_regex(TrgStateSelector * s)
+{
TrgStateSelectorPrivate *priv = TRG_STATE_SELECTOR_GET_PRIVATE(s);
return priv->urlHostRegex;
}
-guint32 trg_state_selector_get_flag(TrgStateSelector * s) {
+guint32 trg_state_selector_get_flag(TrgStateSelector * s)
+{
TrgStateSelectorPrivate *priv = TRG_STATE_SELECTOR_GET_PRIVATE(s);
return priv->flag;
}
-static void state_selection_changed(GtkTreeSelection * selection, gpointer data) {
+static void state_selection_changed(GtkTreeSelection * selection,
+ gpointer data)
+{
TrgStateSelectorPrivate *priv;
GtkTreeIter iter;
GtkTreeModel *stateModel;
@@ -79,20 +83,21 @@ static void state_selection_changed(GtkTreeSelection * selection, gpointer data)
priv = TRG_STATE_SELECTOR_GET_PRIVATE(data);
if (gtk_tree_selection_get_selected(selection, &stateModel, &iter))
- gtk_tree_model_get(stateModel, &iter, STATE_SELECTOR_BIT, &priv->flag,
- STATE_SELECTOR_INDEX, &index, -1);
+ gtk_tree_model_get(stateModel, &iter, STATE_SELECTOR_BIT,
+ &priv->flag, STATE_SELECTOR_INDEX, &index, -1);
else
- priv->flag = 0;
+ priv->flag = 0;
trg_prefs_set_int(priv->prefs, TRG_PREFS_STATE_SELECTOR_LAST, index,
- TRG_PREFS_GLOBAL);
+ TRG_PREFS_GLOBAL);
- g_signal_emit(TRG_STATE_SELECTOR(data), signals[SELECTOR_STATE_CHANGED], 0,
- priv->flag);
+ g_signal_emit(TRG_STATE_SELECTOR(data),
+ signals[SELECTOR_STATE_CHANGED], 0, priv->flag);
}
static GtkTreeRowReference *quick_tree_ref_new(GtkTreeModel * model,
- GtkTreeIter * iter) {
+ GtkTreeIter * iter)
+{
GtkTreePath *path = gtk_tree_model_get_path(model, iter);
GtkTreeRowReference *rr = gtk_tree_row_reference_new(model, path);
gtk_tree_path_free(path);
@@ -104,8 +109,10 @@ struct cruft_remove_args {
gint64 serial;
};
-static gboolean trg_state_selector_remove_cruft(gpointer key, gpointer value,
- gpointer data) {
+static gboolean trg_state_selector_remove_cruft(gpointer key,
+ gpointer value,
+ gpointer data)
+{
struct cruft_remove_args *args = (struct cruft_remove_args *) data;
GtkTreeRowReference *rr = (GtkTreeRowReference *) value;
GtkTreeModel *model = gtk_tree_row_reference_get_model(rr);
@@ -116,7 +123,8 @@ static gboolean trg_state_selector_remove_cruft(gpointer key, gpointer value,
gint64 currentSerial;
gtk_tree_model_get_iter(model, &iter, path);
- gtk_tree_model_get(model, &iter, STATE_SELECTOR_SERIAL, &currentSerial, -1);
+ gtk_tree_model_get(model, &iter, STATE_SELECTOR_SERIAL, &currentSerial,
+ -1);
remove = (args->serial != currentSerial);
@@ -125,34 +133,39 @@ static gboolean trg_state_selector_remove_cruft(gpointer key, gpointer value,
return remove;
}
-gchar *trg_state_selector_get_selected_text(TrgStateSelector * s) {
+gchar *trg_state_selector_get_selected_text(TrgStateSelector * s)
+{
GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(s));
GtkTreeModel *model;
GtkTreeIter iter;
gchar *name = NULL;
if (gtk_tree_selection_get_selected(sel, &model, &iter))
- gtk_tree_model_get(model, &iter, STATE_SELECTOR_NAME, &name, -1);
+ gtk_tree_model_get(model, &iter, STATE_SELECTOR_NAME, &name, -1);
return name;
}
static void trg_state_selector_update_serial(GtkTreeModel * model,
- GtkTreeRowReference * rr, gint64 serial) {
+ GtkTreeRowReference * rr,
+ gint64 serial)
+{
GtkTreeIter iter;
GtkTreePath *path = gtk_tree_row_reference_get_path(rr);
gtk_tree_model_get_iter(model, &iter, path);
gtk_list_store_set(GTK_LIST_STORE(model), &iter, STATE_SELECTOR_SERIAL,
- serial, -1);
+ serial, -1);
gtk_tree_path_free(path);
}
-static void refresh_statelist_cb(GtkWidget * w, gpointer data) {
+static void refresh_statelist_cb(GtkWidget * w, gpointer data)
+{
trg_state_selector_update(TRG_STATE_SELECTOR(data));
}
static void view_popup_menu(GtkWidget * treeview, GdkEventButton * event,
- gpointer data G_GNUC_UNUSED) {
+ gpointer data G_GNUC_UNUSED)
+{
GtkWidget *menu, *item;
menu = gtk_menu_new();
@@ -160,28 +173,31 @@ static void view_popup_menu(GtkWidget * treeview, GdkEventButton * event,
item = gtk_image_menu_item_new_with_label(GTK_STOCK_REFRESH);
gtk_image_menu_item_set_use_stock(GTK_IMAGE_MENU_ITEM(item), TRUE);
gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM
- (item), TRUE);
+ (item), TRUE);
g_signal_connect(item, "activate", G_CALLBACK(refresh_statelist_cb),
- treeview);
+ treeview);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
gtk_widget_show_all(menu);
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
- (event != NULL) ? event->button : 0,
- gdk_event_get_time((GdkEvent *) event));
+ (event != NULL) ? event->button : 0,
+ gdk_event_get_time((GdkEvent *) event));
}
-static gboolean view_onPopupMenu(GtkWidget * treeview, gpointer userdata) {
+static gboolean view_onPopupMenu(GtkWidget * treeview, gpointer userdata)
+{
view_popup_menu(treeview, NULL, userdata);
return TRUE;
}
static gboolean view_onButtonPressed(GtkWidget * treeview,
- GdkEventButton * event, gpointer userdata) {
+ GdkEventButton * event,
+ gpointer userdata)
+{
if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
- view_popup_menu(treeview, event, userdata);
- return TRUE;
+ view_popup_menu(treeview, event, userdata);
+ return TRUE;
}
return FALSE;
@@ -194,17 +210,21 @@ struct state_find_pos {
const gchar *name;
};
-static gboolean trg_state_selector_find_pos_foreach(GtkTreeModel *model,
- GtkTreePath *path, GtkTreeIter *iter, gpointer data) {
- struct state_find_pos *args = (struct state_find_pos*) data;
+static gboolean trg_state_selector_find_pos_foreach(GtkTreeModel * model,
+ GtkTreePath * path,
+ GtkTreeIter * iter,
+ gpointer data)
+{
+ struct state_find_pos *args = (struct state_find_pos *) data;
gchar *name;
gboolean res;
if (args->pos < args->offset) {
- args->pos++;
- return FALSE;
- } else if (args->range >= 0 && args->pos > args->offset + args->range - 1) {
- return TRUE;
+ args->pos++;
+ return FALSE;
+ } else if (args->range >= 0
+ && args->pos > args->offset + args->range - 1) {
+ return TRUE;
}
gtk_tree_model_get(model, iter, STATE_SELECTOR_NAME, &name, -1);
@@ -212,13 +232,15 @@ static gboolean trg_state_selector_find_pos_foreach(GtkTreeModel *model,
g_free(name);
if (!res)
- args->pos++;
+ args->pos++;
return res;
}
-static void trg_state_selector_insert(TrgStateSelector *s, int offset,
- gint range, const gchar *name, GtkTreeIter *iter) {
+static void trg_state_selector_insert(TrgStateSelector * s, int offset,
+ gint range, const gchar * name,
+ GtkTreeIter * iter)
+{
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(s));
struct state_find_pos args;
@@ -227,11 +249,13 @@ static void trg_state_selector_insert(TrgStateSelector *s, int offset,
args.range = range;
args.name = name;
- gtk_tree_model_foreach(model, trg_state_selector_find_pos_foreach, &args);
+ gtk_tree_model_foreach(model, trg_state_selector_find_pos_foreach,
+ &args);
gtk_list_store_insert(GTK_LIST_STORE(model), iter, args.pos);
}
-void trg_state_selector_update(TrgStateSelector * s) {
+void trg_state_selector_update(TrgStateSelector * s)
+{
TrgStateSelectorPrivate *priv = TRG_STATE_SELECTOR_GET_PRIVATE(s);
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(s));
TrgClient *client = priv->client;
@@ -246,88 +270,102 @@ void trg_state_selector_update(TrgStateSelector * s) {
struct cruft_remove_args cruft;
if (!trg_client_is_connected(client))
- return;
+ return;
- torrentItemRefs = g_hash_table_get_values(trg_client_get_torrent_table(client));
+ torrentItemRefs =
+ g_hash_table_get_values(trg_client_get_torrent_table(client));
for (li = torrentItemRefs; li; li = g_list_next(li)) {
- JsonObject *t = NULL;
- rr = (GtkTreeRowReference *) li->data;
- path = gtk_tree_row_reference_get_path(rr);
- torrentModel = gtk_tree_row_reference_get_model(rr);
-
- if (path) {
- if (gtk_tree_model_get_iter(torrentModel, &torrentIter, path)) {
- gtk_tree_model_get(torrentModel, &torrentIter, TORRENT_COLUMN_JSON,
- &t, -1);
- }
- gtk_tree_path_free(path);
- }
-
- if (!t)
- continue;
-
- if (priv->showTrackers) {
- trackersList
- = json_array_get_elements(torrent_get_tracker_stats(t));
- for (trackerItem = trackersList; trackerItem; trackerItem
- = g_list_next(trackerItem)) {
- JsonObject *tracker = json_node_get_object(
- (JsonNode *) trackerItem->data);
- const gchar *announceUrl = tracker_stats_get_announce(tracker);
- gchar *announceHost = trg_gregex_get_first(priv->urlHostRegex,
- announceUrl);
-
- if (!announceHost)
- continue;
-
- result = g_hash_table_lookup(priv->trackers, announceHost);
-
- if (result) {
- trg_state_selector_update_serial(model,
- (GtkTreeRowReference *) result, updateSerial);
- g_free(announceHost);
- } else {
- trg_state_selector_insert(s, priv->n_categories,
- g_hash_table_size(priv->trackers), announceHost,
- &iter);
- gtk_list_store_set(GTK_LIST_STORE(model), &iter,
- STATE_SELECTOR_ICON, GTK_STOCK_NETWORK,
- STATE_SELECTOR_NAME, announceHost,
- STATE_SELECTOR_SERIAL, updateSerial,
- STATE_SELECTOR_BIT, FILTER_FLAG_TRACKER,
- STATE_SELECTOR_INDEX, 0, -1);
- g_hash_table_insert(priv->trackers, announceHost,
- quick_tree_ref_new(model, &iter));
- }
- }
- g_list_free(trackersList);
- }
-
- if (priv->showDirs) {
- gchar *dir;
- gtk_tree_model_get(torrentModel, &torrentIter, TORRENT_COLUMN_DOWNLOADDIR_SHORT,
- &dir, -1);
-
- result = g_hash_table_lookup(priv->directories, dir);
- if (result) {
- trg_state_selector_update_serial(model,
- (GtkTreeRowReference *) result, updateSerial);
- } else {
- trg_state_selector_insert(s,
- priv->n_categories + g_hash_table_size(priv->trackers), -1,
- dir, &iter);
- gtk_list_store_set(GTK_LIST_STORE(model), &iter,
- STATE_SELECTOR_ICON, GTK_STOCK_DIRECTORY,
- STATE_SELECTOR_NAME, dir, STATE_SELECTOR_SERIAL,
- updateSerial, STATE_SELECTOR_BIT, FILTER_FLAG_DIR,
- STATE_SELECTOR_INDEX, 0, -1);
- g_hash_table_insert(priv->directories, g_strdup(dir),
- quick_tree_ref_new(model, &iter));
- }
-
- g_free(dir);
- }
+ JsonObject *t = NULL;
+ rr = (GtkTreeRowReference *) li->data;
+ path = gtk_tree_row_reference_get_path(rr);
+ torrentModel = gtk_tree_row_reference_get_model(rr);
+
+ if (path) {
+ if (gtk_tree_model_get_iter(torrentModel, &torrentIter, path)) {
+ gtk_tree_model_get(torrentModel, &torrentIter,
+ TORRENT_COLUMN_JSON, &t, -1);
+ }
+ gtk_tree_path_free(path);
+ }
+
+ if (!t)
+ continue;
+
+ if (priv->showTrackers) {
+ trackersList
+ = json_array_get_elements(torrent_get_tracker_stats(t));
+ for (trackerItem = trackersList; trackerItem; trackerItem
+ = g_list_next(trackerItem)) {
+ JsonObject *tracker = json_node_get_object((JsonNode *)
+ trackerItem->
+ data);
+ const gchar *announceUrl =
+ tracker_stats_get_announce(tracker);
+ gchar *announceHost =
+ trg_gregex_get_first(priv->urlHostRegex,
+ announceUrl);
+
+ if (!announceHost)
+ continue;
+
+ result = g_hash_table_lookup(priv->trackers, announceHost);
+
+ if (result) {
+ trg_state_selector_update_serial(model,
+ (GtkTreeRowReference
+ *) result,
+ updateSerial);
+ g_free(announceHost);
+ } else {
+ trg_state_selector_insert(s, priv->n_categories,
+ g_hash_table_size(priv->
+ trackers),
+ announceHost, &iter);
+ gtk_list_store_set(GTK_LIST_STORE(model), &iter,
+ STATE_SELECTOR_ICON,
+ GTK_STOCK_NETWORK,
+ STATE_SELECTOR_NAME, announceHost,
+ STATE_SELECTOR_SERIAL, updateSerial,
+ STATE_SELECTOR_BIT,
+ FILTER_FLAG_TRACKER,
+ STATE_SELECTOR_INDEX, 0, -1);
+ g_hash_table_insert(priv->trackers, announceHost,
+ quick_tree_ref_new(model, &iter));
+ }
+ }
+ g_list_free(trackersList);
+ }
+
+ if (priv->showDirs) {
+ gchar *dir;
+ gtk_tree_model_get(torrentModel, &torrentIter,
+ TORRENT_COLUMN_DOWNLOADDIR_SHORT, &dir, -1);
+
+ result = g_hash_table_lookup(priv->directories, dir);
+ if (result) {
+ trg_state_selector_update_serial(model,
+ (GtkTreeRowReference *)
+ result, updateSerial);
+ } else {
+ trg_state_selector_insert(s,
+ priv->n_categories +
+ g_hash_table_size(priv->
+ trackers), -1,
+ dir, &iter);
+ gtk_list_store_set(GTK_LIST_STORE(model), &iter,
+ STATE_SELECTOR_ICON,
+ GTK_STOCK_DIRECTORY,
+ STATE_SELECTOR_NAME, dir,
+ STATE_SELECTOR_SERIAL, updateSerial,
+ STATE_SELECTOR_BIT, FILTER_FLAG_DIR,
+ STATE_SELECTOR_INDEX, 0, -1);
+ g_hash_table_insert(priv->directories, g_strdup(dir),
+ quick_tree_ref_new(model, &iter));
+ }
+
+ g_free(dir);
+ }
}
g_list_free(torrentItemRefs);
@@ -335,55 +373,68 @@ void trg_state_selector_update(TrgStateSelector * s) {
cruft.serial = trg_client_get_serial(client);
if (priv->showTrackers) {
- cruft.table = priv->trackers;
- g_hash_table_foreach_remove(priv->trackers,
- trg_state_selector_remove_cruft, &cruft);
+ cruft.table = priv->trackers;
+ g_hash_table_foreach_remove(priv->trackers,
+ trg_state_selector_remove_cruft,
+ &cruft);
}
if (priv->showDirs) {
- cruft.table = priv->directories;
- g_hash_table_foreach_remove(priv->directories,
- trg_state_selector_remove_cruft, &cruft);
+ cruft.table = priv->directories;
+ g_hash_table_foreach_remove(priv->directories,
+ trg_state_selector_remove_cruft,
+ &cruft);
}
}
-void trg_state_selector_set_show_dirs(TrgStateSelector * s, gboolean show) {
+void trg_state_selector_set_show_dirs(TrgStateSelector * s, gboolean show)
+{
TrgStateSelectorPrivate *priv = TRG_STATE_SELECTOR_GET_PRIVATE(s);
priv->showDirs = show;
if (!show)
- g_hash_table_remove_all(priv->directories);
+ g_hash_table_remove_all(priv->directories);
else
- trg_state_selector_update(s);
+ trg_state_selector_update(s);
}
-void trg_state_selector_set_show_trackers(TrgStateSelector * s, gboolean show) {
+void trg_state_selector_set_show_trackers(TrgStateSelector * s,
+ gboolean show)
+{
TrgStateSelectorPrivate *priv = TRG_STATE_SELECTOR_GET_PRIVATE(s);
priv->showTrackers = show;
if (!show)
- g_hash_table_remove_all(priv->trackers);
+ g_hash_table_remove_all(priv->trackers);
else
- trg_state_selector_update(s);
+ trg_state_selector_update(s);
}
-static void trg_state_selector_add_state(TrgStateSelector *selector,
- GtkTreeIter * iter, gint pos, gchar * icon, gchar * name, guint32 flag) {
- TrgStateSelectorPrivate *priv = TRG_STATE_SELECTOR_GET_PRIVATE(selector);
- GtkListStore *model = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(selector)));
+static void trg_state_selector_add_state(TrgStateSelector * selector,
+ GtkTreeIter * iter, gint pos,
+ gchar * icon, gchar * name,
+ guint32 flag)
+{
+ TrgStateSelectorPrivate *priv =
+ TRG_STATE_SELECTOR_GET_PRIVATE(selector);
+ GtkListStore *model =
+ GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(selector)));
if (pos < 0)
- gtk_list_store_append(priv->store, iter);
+ gtk_list_store_append(priv->store, iter);
else
- gtk_list_store_insert(priv->store, iter, pos);
+ gtk_list_store_insert(priv->store, iter, pos);
gtk_list_store_set(model, iter, STATE_SELECTOR_ICON, icon,
- STATE_SELECTOR_NAME, name, STATE_SELECTOR_BIT, flag,
- STATE_SELECTOR_INDEX,
- gtk_tree_model_iter_n_children(GTK_TREE_MODEL(model), NULL) - 1, -1);
+ STATE_SELECTOR_NAME, name, STATE_SELECTOR_BIT, flag,
+ STATE_SELECTOR_INDEX,
+ gtk_tree_model_iter_n_children(GTK_TREE_MODEL
+ (model), NULL) - 1,
+ -1);
priv->n_categories++;
}
-static void remove_row_ref_and_free(GtkTreeRowReference * rr) {
+static void remove_row_ref_and_free(GtkTreeRowReference * rr)
+{
GtkTreeModel *model = gtk_tree_row_reference_get_model(rr);
GtkTreePath *path = gtk_tree_row_reference_get_path(rr);
GtkTreeIter iter;
@@ -394,43 +445,54 @@ static void remove_row_ref_and_free(GtkTreeRowReference * rr) {
gtk_tree_row_reference_free(rr);
}
-void trg_state_selector_stats_update(TrgStateSelector * s, trg_torrent_model_update_stats *stats)
+void trg_state_selector_stats_update(TrgStateSelector * s,
+ trg_torrent_model_update_stats *
+ stats)
{
TrgStateSelectorPrivate *priv = TRG_STATE_SELECTOR_GET_PRIVATE(s);
GtkTreeIter iter;
if (stats->error > 0 && !priv->error_rr) {
- trg_state_selector_add_state(s, &iter, priv->n_categories-1, GTK_STOCK_DIALOG_WARNING,
- _("Error"), TORRENT_FLAG_ERROR);
- priv->error_rr = quick_tree_ref_new(GTK_TREE_MODEL(priv->store), &iter);
+ trg_state_selector_add_state(s, &iter, priv->n_categories - 1,
+ GTK_STOCK_DIALOG_WARNING, _("Error"),
+ TORRENT_FLAG_ERROR);
+ priv->error_rr =
+ quick_tree_ref_new(GTK_TREE_MODEL(priv->store), &iter);
} else if (stats->error < 1 && priv->error_rr) {
- remove_row_ref_and_free(priv->error_rr);
- priv->error_rr = NULL;
- priv->n_categories--;
+ remove_row_ref_and_free(priv->error_rr);
+ priv->error_rr = NULL;
+ priv->n_categories--;
}
}
-void trg_state_selector_disconnect(TrgStateSelector * s) {
+void trg_state_selector_disconnect(TrgStateSelector * s)
+{
TrgStateSelectorPrivate *priv = TRG_STATE_SELECTOR_GET_PRIVATE(s);
if (priv->error_rr) {
- remove_row_ref_and_free(priv->error_rr);
- priv->error_rr = NULL;
- priv->n_categories--;
+ remove_row_ref_and_free(priv->error_rr);
+ priv->error_rr = NULL;
+ priv->n_categories--;
}
g_hash_table_remove_all(priv->trackers);
g_hash_table_remove_all(priv->directories);
}
-static void trg_state_selector_init(TrgStateSelector * self) {
+static void trg_state_selector_init(TrgStateSelector * self)
+{
}
-TrgStateSelector *trg_state_selector_new(TrgClient * client) {
+TrgStateSelector *trg_state_selector_new(TrgClient * client)
+{
return g_object_new(TRG_TYPE_STATE_SELECTOR, "client", client, NULL);
}
static GObject *trg_state_selector_constructor(GType type,
- guint n_construct_properties, GObjectConstructParam * construct_params) {
+ guint
+ n_construct_properties,
+ GObjectConstructParam *
+ construct_params)
+{
GObject *object;
TrgStateSelector *selector;
TrgStateSelectorPrivate *priv;
@@ -442,17 +504,20 @@ static GObject *trg_state_selector_constructor(GType type,
GtkTreeSelection *selection;
object = G_OBJECT_CLASS
- (trg_state_selector_parent_class)->constructor(type,
- n_construct_properties, construct_params);
+ (trg_state_selector_parent_class)->constructor(type,
+ n_construct_properties,
+ construct_params);
selector = TRG_STATE_SELECTOR(object);
priv = TRG_STATE_SELECTOR_GET_PRIVATE(object);
priv->urlHostRegex = trg_uri_host_regex_new();
priv->trackers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
- (GDestroyNotify) remove_row_ref_and_free);
- priv->directories = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
- (GDestroyNotify) remove_row_ref_and_free);
+ (GDestroyNotify)
+ remove_row_ref_and_free);
+ priv->directories =
+ g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
+ (GDestroyNotify) remove_row_ref_and_free);
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(object), FALSE);
@@ -461,7 +526,8 @@ static GObject *trg_state_selector_constructor(GType type,
renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(column, renderer, FALSE);
g_object_set(renderer, "stock-size", 4, NULL);
- gtk_tree_view_column_set_attributes(column, renderer, "stock-id", 0, NULL);
+ gtk_tree_view_column_set_attributes(column, renderer, "stock-id", 0,
+ NULL);
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(column, renderer, TRUE);
@@ -469,29 +535,36 @@ static GObject *trg_state_selector_constructor(GType type,
gtk_tree_view_append_column(GTK_TREE_VIEW(object), column);
- store = priv->store = gtk_list_store_new(STATE_SELECTOR_COLUMNS, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INT64, G_TYPE_UINT);
+ store = priv->store =
+ gtk_list_store_new(STATE_SELECTOR_COLUMNS, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INT64,
+ G_TYPE_UINT);
gtk_tree_view_set_model(GTK_TREE_VIEW(object), GTK_TREE_MODEL(store));
- trg_state_selector_add_state(selector, &iter, -1, GTK_STOCK_ABOUT, _("All"), 0);
+ trg_state_selector_add_state(selector, &iter, -1, GTK_STOCK_ABOUT,
+ _("All"), 0);
trg_state_selector_add_state(selector, &iter, -1, GTK_STOCK_GO_DOWN,
- _("Downloading"), TORRENT_FLAG_DOWNLOADING);
- trg_state_selector_add_state(selector, &iter, -1, GTK_STOCK_MEDIA_REWIND,
- _("Queue Down"), TORRENT_FLAG_DOWNLOADING_WAIT);
- trg_state_selector_add_state(selector, &iter, -1, GTK_STOCK_GO_UP, _("Seeding"),
- TORRENT_FLAG_SEEDING);
- trg_state_selector_add_state(selector, &iter, -1, GTK_STOCK_MEDIA_FORWARD,
- _("Queue Up"), TORRENT_FLAG_SEEDING_WAIT);
- trg_state_selector_add_state(selector, &iter, -1, GTK_STOCK_MEDIA_PAUSE,
- _("Paused"), TORRENT_FLAG_PAUSED);
- trg_state_selector_add_state(selector, &iter, -1, GTK_STOCK_APPLY, _("Complete"),
- TORRENT_FLAG_COMPLETE);
+ _("Downloading"),
+ TORRENT_FLAG_DOWNLOADING);
+ trg_state_selector_add_state(selector, &iter, -1,
+ GTK_STOCK_MEDIA_REWIND, _("Queue Down"),
+ TORRENT_FLAG_DOWNLOADING_WAIT);
+ trg_state_selector_add_state(selector, &iter, -1, GTK_STOCK_GO_UP,
+ _("Seeding"), TORRENT_FLAG_SEEDING);
+ trg_state_selector_add_state(selector, &iter, -1,
+ GTK_STOCK_MEDIA_FORWARD, _("Queue Up"),
+ TORRENT_FLAG_SEEDING_WAIT);
+ trg_state_selector_add_state(selector, &iter, -1,
+ GTK_STOCK_MEDIA_PAUSE, _("Paused"),
+ TORRENT_FLAG_PAUSED);
+ trg_state_selector_add_state(selector, &iter, -1, GTK_STOCK_APPLY,
+ _("Complete"), TORRENT_FLAG_COMPLETE);
trg_state_selector_add_state(selector, &iter, -1, GTK_STOCK_SELECT_ALL,
- _("Incomplete"), TORRENT_FLAG_INCOMPLETE);
- trg_state_selector_add_state(selector, &iter, -1, GTK_STOCK_NETWORK, _("Active"),
- TORRENT_FLAG_ACTIVE);
+ _("Incomplete"), TORRENT_FLAG_INCOMPLETE);
+ trg_state_selector_add_state(selector, &iter, -1, GTK_STOCK_NETWORK,
+ _("Active"), TORRENT_FLAG_ACTIVE);
trg_state_selector_add_state(selector, &iter, -1, GTK_STOCK_REFRESH,
- _("Checking"), TORRENT_FLAG_CHECKING_ANY);
+ _("Checking"), TORRENT_FLAG_CHECKING_ANY);
trg_state_selector_add_state(selector, &iter, -1, NULL, NULL, 0);
gtk_tree_view_set_rubber_banding(GTK_TREE_VIEW(object), TRUE);
@@ -499,102 +572,125 @@ static GObject *trg_state_selector_constructor(GType type,
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(object));
g_signal_connect(G_OBJECT(selection), "changed",
- G_CALLBACK(state_selection_changed), object);
+ G_CALLBACK(state_selection_changed), object);
g_signal_connect(object, "button-press-event",
- G_CALLBACK(view_onButtonPressed), NULL);
+ G_CALLBACK(view_onButtonPressed), NULL);
g_signal_connect(object, "popup-menu", G_CALLBACK(view_onPopupMenu),
- NULL);
+ NULL);
- gtk_tree_view_set_search_column(GTK_TREE_VIEW(object), STATE_SELECTOR_NAME);
+ gtk_tree_view_set_search_column(GTK_TREE_VIEW(object),
+ STATE_SELECTOR_NAME);
index = trg_prefs_get_int(priv->prefs, TRG_PREFS_STATE_SELECTOR_LAST,
- TRG_PREFS_GLOBAL);
+ TRG_PREFS_GLOBAL);
if (index > 0 && gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store),
- &iter, NULL, index)) {
- GtkTreeSelection *selection = gtk_tree_view_get_selection(
- GTK_TREE_VIEW(object));
- gtk_tree_selection_select_iter(selection, &iter);
+ &iter, NULL, index)) {
+ GtkTreeSelection *selection =
+ gtk_tree_view_get_selection(GTK_TREE_VIEW(object));
+ gtk_tree_selection_select_iter(selection, &iter);
}
- priv->showDirs = trg_prefs_get_bool(priv->prefs, TRG_PREFS_KEY_FILTER_DIRS,
- TRG_PREFS_GLOBAL);
- priv->showTrackers = trg_prefs_get_bool(priv->prefs,
- TRG_PREFS_KEY_FILTER_TRACKERS, TRG_PREFS_GLOBAL);
+ priv->showDirs =
+ trg_prefs_get_bool(priv->prefs, TRG_PREFS_KEY_FILTER_DIRS,
+ TRG_PREFS_GLOBAL);
+ priv->showTrackers =
+ trg_prefs_get_bool(priv->prefs, TRG_PREFS_KEY_FILTER_TRACKERS,
+ TRG_PREFS_GLOBAL);
return object;
}
-void trg_state_selector_set_queues_enabled(TrgStateSelector *s, gboolean enabled)
+void trg_state_selector_set_queues_enabled(TrgStateSelector * s,
+ gboolean enabled)
{
TrgStateSelectorPrivate *priv = TRG_STATE_SELECTOR_GET_PRIVATE(s);
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(s));
GtkTreeIter iter;
if (enabled) {
- trg_state_selector_add_state(s, &iter, 2, GTK_STOCK_MEDIA_REWIND,
- _("Queue Down"), TORRENT_FLAG_DOWNLOADING_WAIT);
- trg_state_selector_add_state(s, &iter, 4, GTK_STOCK_MEDIA_FORWARD,
- _("Queue Up"), TORRENT_FLAG_SEEDING_WAIT);
+ trg_state_selector_add_state(s, &iter, 2, GTK_STOCK_MEDIA_REWIND,
+ _("Queue Down"),
+ TORRENT_FLAG_DOWNLOADING_WAIT);
+ trg_state_selector_add_state(s, &iter, 4, GTK_STOCK_MEDIA_FORWARD,
+ _("Queue Up"),
+ TORRENT_FLAG_SEEDING_WAIT);
} else {
- gtk_tree_model_iter_nth_child(model, &iter, NULL, 4);
- gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
+ gtk_tree_model_iter_nth_child(model, &iter, NULL, 4);
+ gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
- gtk_tree_model_iter_nth_child(model, &iter, NULL, 2);
- gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
+ gtk_tree_model_iter_nth_child(model, &iter, NULL, 2);
+ gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
- priv->n_categories -= 2;
+ priv->n_categories -= 2;
}
}
static void trg_state_selector_get_property(GObject * object,
- guint property_id, GValue * value, GParamSpec * pspec) {
+ guint property_id,
+ GValue * value,
+ GParamSpec * pspec)
+{
TrgStateSelectorPrivate *priv = TRG_STATE_SELECTOR_GET_PRIVATE(object);
switch (property_id) {
case PROP_CLIENT:
- g_value_set_object(value, priv->client);
- break;
+ g_value_set_object(value, priv->client);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
-static void trg_state_selector_set_property(GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec G_GNUC_UNUSED) {
+static void trg_state_selector_set_property(GObject * object,
+ guint prop_id,
+ const GValue * value,
+ GParamSpec *
+ pspec G_GNUC_UNUSED)
+{
TrgStateSelectorPrivate *priv = TRG_STATE_SELECTOR_GET_PRIVATE(object);
switch (prop_id) {
case PROP_CLIENT:
- priv->client = g_value_get_object(value);
- priv->prefs = trg_client_get_prefs(priv->client);
- break;
+ priv->client = g_value_get_object(value);
+ priv->prefs = trg_client_get_prefs(priv->client);
+ break;
}
}
-static void trg_state_selector_class_init(TrgStateSelectorClass * klass) {
+static void trg_state_selector_class_init(TrgStateSelectorClass * klass)
+{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
object_class->constructor = trg_state_selector_constructor;
object_class->set_property = trg_state_selector_set_property;
object_class->get_property = trg_state_selector_get_property;
signals[SELECTOR_STATE_CHANGED] = g_signal_new("torrent-state-changed",
- G_TYPE_FROM_CLASS(object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET(TrgStateSelectorClass,
- torrent_state_changed), NULL, NULL,
- g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
-
- g_object_class_install_property(
- object_class,
- PROP_CLIENT,
- g_param_spec_object(
- "client",
- "Client",
- "Client",
- TRG_TYPE_CLIENT,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK
- | G_PARAM_STATIC_BLURB));
+ G_TYPE_FROM_CLASS
+ (object_class),
+ G_SIGNAL_RUN_LAST |
+ G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET
+ (TrgStateSelectorClass,
+ torrent_state_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__UINT,
+ G_TYPE_NONE, 1,
+ G_TYPE_UINT);
+
+ g_object_class_install_property(object_class,
+ PROP_CLIENT,
+ g_param_spec_object("client",
+ "Client",
+ "Client",
+ TRG_TYPE_CLIENT,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
g_type_class_add_private(klass, sizeof(TrgStateSelectorPrivate));
}
diff --git a/src/trg-state-selector.h b/src/trg-state-selector.h
index a2f6021..37d2f3a 100644
--- a/src/trg-state-selector.h
+++ b/src/trg-state-selector.h
@@ -55,7 +55,7 @@ typedef struct {
GtkTreeViewClass parent_class;
void (*torrent_state_changed) (TrgStateSelector * selector,
- guint flag, gpointer data);
+ guint flag, gpointer data);
} TrgStateSelectorClass;
@@ -68,9 +68,12 @@ gchar *trg_state_selector_get_selected_text(TrgStateSelector * s);
GRegex *trg_state_selector_get_url_host_regex(TrgStateSelector * s);
void trg_state_selector_disconnect(TrgStateSelector * s);
void trg_state_selector_set_show_trackers(TrgStateSelector * s,
- gboolean show);
+ gboolean show);
void trg_state_selector_set_show_dirs(TrgStateSelector * s, gboolean show);
-void trg_state_selector_set_queues_enabled(TrgStateSelector *s, gboolean enabled);
-void trg_state_selector_stats_update(TrgStateSelector * s, trg_torrent_model_update_stats *stats);
+void trg_state_selector_set_queues_enabled(TrgStateSelector * s,
+ gboolean enabled);
+void trg_state_selector_stats_update(TrgStateSelector * s,
+ trg_torrent_model_update_stats *
+ stats);
-#endif /* TRG_STATE_LIST_H_ */
+#endif /* TRG_STATE_LIST_H_ */
diff --git a/src/trg-stats-dialog.c b/src/trg-stats-dialog.c
index 966b9d7..87aaf5d 100644
--- a/src/trg-stats-dialog.c
+++ b/src/trg-stats-dialog.c
@@ -57,7 +57,7 @@ struct _TrgStatsDialogPrivate {
GtkWidget *tv;
GtkListStore *model;
GtkTreeRowReference *rr_up, *rr_down, *rr_files_added,
- *rr_session_count, *rr_active, *rr_version;
+ *rr_session_count, *rr_active, *rr_version;
};
static GObject *instance = NULL;
@@ -66,39 +66,39 @@ static gboolean on_stats_reply(gpointer data);
static void
trg_stats_dialog_get_property(GObject * object, guint property_id,
- GValue * value, GParamSpec * pspec)
+ GValue * value, GParamSpec * pspec)
{
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
}
static void
trg_stats_dialog_set_property(GObject * object, guint property_id,
- const GValue * value, GParamSpec * pspec)
+ const GValue * value, GParamSpec * pspec)
{
TrgStatsDialogPrivate *priv = TRG_STATS_DIALOG_GET_PRIVATE(object);
switch (property_id) {
case PROP_CLIENT:
- priv->client = g_value_get_pointer(value);
- break;
+ priv->client = g_value_get_pointer(value);
+ break;
case PROP_PARENT:
- priv->parent = g_value_get_object(value);
- break;
+ priv->parent = g_value_get_object(value);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
static void
trg_stats_response_cb(GtkDialog * dlg, gint res_id,
- gpointer data G_GNUC_UNUSED)
+ gpointer data G_GNUC_UNUSED)
{
gtk_widget_destroy(GTK_WIDGET(dlg));
instance = NULL;
}
static GtkTreeRowReference *stats_dialog_add_statistic(GtkListStore *
- model, gchar * name)
+ model, gchar * name)
{
GtkTreeIter iter;
GtkTreePath *path;
@@ -115,7 +115,7 @@ static GtkTreeRowReference *stats_dialog_add_statistic(GtkListStore *
}
static void update_statistic(GtkTreeRowReference * rr, gchar * session,
- gchar * cumulat)
+ gchar * cumulat)
{
GtkTreePath *path = gtk_tree_row_reference_get_path(rr);
GtkTreeModel *model = gtk_tree_row_reference_get_model(rr);
@@ -124,7 +124,7 @@ static void update_statistic(GtkTreeRowReference * rr, gchar * session,
gtk_tree_model_get_iter(model, &iter, path);
gtk_list_store_set(GTK_LIST_STORE(model), &iter, STATCOL_SESSION,
- session, STATCOL_CUMULAT, cumulat, -1);
+ session, STATCOL_CUMULAT, cumulat, -1);
gtk_tree_path_free(path);
}
@@ -140,83 +140,86 @@ static JsonObject *get_cumulat_arg(JsonObject * args)
}
static void update_int_stat(JsonObject * args, GtkTreeRowReference * rr,
- gchar * jsonKey)
+ gchar * jsonKey)
{
gchar session_val[32];
gchar cumulat_val[32];
- g_snprintf(session_val, sizeof(session_val), "%"G_GINT64_FORMAT,
- json_object_get_int_member(get_session_arg(args), jsonKey));
- g_snprintf(cumulat_val, sizeof(cumulat_val), "%"G_GINT64_FORMAT,
- json_object_get_int_member(get_cumulat_arg(args), jsonKey));
+ g_snprintf(session_val, sizeof(session_val), "%" G_GINT64_FORMAT,
+ json_object_get_int_member(get_session_arg(args), jsonKey));
+ g_snprintf(cumulat_val, sizeof(cumulat_val), "%" G_GINT64_FORMAT,
+ json_object_get_int_member(get_cumulat_arg(args), jsonKey));
update_statistic(rr, session_val, cumulat_val);
}
static void update_size_stat(JsonObject * args, GtkTreeRowReference * rr,
- gchar * jsonKey)
+ gchar * jsonKey)
{
gchar session_val[32];
gchar cumulat_val[32];
trg_strlsize(cumulat_val,
- json_object_get_int_member(get_cumulat_arg(args),
- jsonKey));
+ json_object_get_int_member(get_cumulat_arg(args),
+ jsonKey));
trg_strlsize(session_val,
- json_object_get_int_member(get_session_arg(args),
- jsonKey));
+ json_object_get_int_member(get_session_arg(args),
+ jsonKey));
update_statistic(rr, session_val, cumulat_val);
}
static void update_time_stat(JsonObject * args, GtkTreeRowReference * rr,
- gchar * jsonKey)
+ gchar * jsonKey)
{
gchar session_val[32];
gchar cumulat_val[32];
tr_strltime_long(session_val,
- json_object_get_int_member(get_session_arg(args),
- jsonKey),
- sizeof(session_val));
+ json_object_get_int_member(get_session_arg(args),
+ jsonKey),
+ sizeof(session_val));
tr_strltime_long(cumulat_val,
- json_object_get_int_member(get_cumulat_arg(args),
- jsonKey),
- sizeof(cumulat_val));
+ json_object_get_int_member(get_cumulat_arg(args),
+ jsonKey),
+ sizeof(cumulat_val));
update_statistic(rr, session_val, cumulat_val);
}
static gboolean on_stats_reply(gpointer data)
{
- trg_response *response = (trg_response*)data;
+ trg_response *response = (trg_response *) data;
TrgStatsDialogPrivate *priv;
JsonObject *args;
if (!TRG_IS_STATS_DIALOG(response->cb_data)) {
- trg_response_free(response);
- return FALSE;
+ trg_response_free(response);
+ return FALSE;
}
priv = TRG_STATS_DIALOG_GET_PRIVATE(response->cb_data);
if (response->status == CURLE_OK) {
- args = get_arguments(response->obj);
-
- char versionStr[32];
- g_snprintf(versionStr, sizeof(versionStr), "Transmission %s", trg_client_get_version_string(priv->client));
- update_statistic(priv->rr_version, versionStr, "");
-
- update_size_stat(args, priv->rr_up, "uploadedBytes");
- update_size_stat(args, priv->rr_down, "downloadedBytes");
- update_int_stat(args, priv->rr_files_added, "filesAdded");
- update_int_stat(args, priv->rr_session_count, "sessionCount");
- update_time_stat(args, priv->rr_active, "secondsActive");
-
- if (trg_client_is_connected(priv->client))
- g_timeout_add_seconds(STATS_UPDATE_INTERVAL, trg_update_stats_timerfunc, response->cb_data);
+ args = get_arguments(response->obj);
+
+ char versionStr[32];
+ g_snprintf(versionStr, sizeof(versionStr), "Transmission %s",
+ trg_client_get_version_string(priv->client));
+ update_statistic(priv->rr_version, versionStr, "");
+
+ update_size_stat(args, priv->rr_up, "uploadedBytes");
+ update_size_stat(args, priv->rr_down, "downloadedBytes");
+ update_int_stat(args, priv->rr_files_added, "filesAdded");
+ update_int_stat(args, priv->rr_session_count, "sessionCount");
+ update_time_stat(args, priv->rr_active, "secondsActive");
+
+ if (trg_client_is_connected(priv->client))
+ g_timeout_add_seconds(STATS_UPDATE_INTERVAL,
+ trg_update_stats_timerfunc,
+ response->cb_data);
} else {
- trg_error_dialog(GTK_WINDOW(data), response);
+ trg_error_dialog(GTK_WINDOW(data), response);
}
trg_response_free(response);
@@ -228,21 +231,21 @@ static gboolean trg_update_stats_timerfunc(gpointer data)
TrgStatsDialogPrivate *priv;
if (TRG_IS_STATS_DIALOG(data)) {
- priv = TRG_STATS_DIALOG_GET_PRIVATE(data);
- dispatch_async(priv->client, session_stats(), on_stats_reply,
- data);
+ priv = TRG_STATS_DIALOG_GET_PRIVATE(data);
+ dispatch_async(priv->client, session_stats(), on_stats_reply,
+ data);
}
return FALSE;
}
static void trg_stats_add_column(GtkTreeView * tv, gint index,
- gchar * title, gint width)
+ gchar * title, gint width)
{
GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
GtkTreeViewColumn *column =
- gtk_tree_view_column_new_with_attributes(title, renderer,
- "text", index, NULL);
+ gtk_tree_view_column_new_with_attributes(title, renderer,
+ "text", index, NULL);
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_fixed_width(column, width);
@@ -250,65 +253,66 @@ static void trg_stats_add_column(GtkTreeView * tv, gint index,
}
static GObject *trg_stats_dialog_constructor(GType type,
- guint
- n_construct_properties,
- GObjectConstructParam
- * construct_params)
+ guint
+ n_construct_properties,
+ GObjectConstructParam
+ * construct_params)
{
GtkWidget *tv;
GObject *obj = G_OBJECT_CLASS
- (trg_stats_dialog_parent_class)->constructor(type,
- n_construct_properties,
- construct_params);
+ (trg_stats_dialog_parent_class)->constructor(type,
+ n_construct_properties,
+ construct_params);
TrgStatsDialogPrivate *priv = TRG_STATS_DIALOG_GET_PRIVATE(obj);
gtk_window_set_title(GTK_WINDOW(obj), _("Statistics"));
gtk_window_set_transient_for(GTK_WINDOW(obj),
- GTK_WINDOW(priv->parent));
+ GTK_WINDOW(priv->parent));
gtk_window_set_destroy_with_parent(GTK_WINDOW(obj), TRUE);
gtk_dialog_add_button(GTK_DIALOG(obj), GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE);
+ GTK_RESPONSE_CLOSE);
gtk_container_set_border_width(GTK_CONTAINER(obj), GUI_PAD);
gtk_dialog_set_default_response(GTK_DIALOG(obj), GTK_RESPONSE_CLOSE);
g_signal_connect(G_OBJECT(obj),
- "response", G_CALLBACK(trg_stats_response_cb), NULL);
+ "response", G_CALLBACK(trg_stats_response_cb), NULL);
priv->model =
- gtk_list_store_new(STATCOL_COLUMNS, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING);
+ gtk_list_store_new(STATCOL_COLUMNS, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING);
priv->rr_version =
- stats_dialog_add_statistic(priv->model, _("Version"));
+ stats_dialog_add_statistic(priv->model, _("Version"));
priv->rr_down =
- stats_dialog_add_statistic(priv->model, _("Download Total"));
+ stats_dialog_add_statistic(priv->model, _("Download Total"));
priv->rr_up =
- stats_dialog_add_statistic(priv->model, _("Upload Total"));
+ stats_dialog_add_statistic(priv->model, _("Upload Total"));
priv->rr_files_added =
- stats_dialog_add_statistic(priv->model, _("Files Added"));
+ stats_dialog_add_statistic(priv->model, _("Files Added"));
priv->rr_session_count =
- stats_dialog_add_statistic(priv->model, _("Session Count"));
+ stats_dialog_add_statistic(priv->model, _("Session Count"));
priv->rr_active =
- stats_dialog_add_statistic(priv->model, _("Time Active"));
+ stats_dialog_add_statistic(priv->model, _("Time Active"));
tv = priv->tv = trg_tree_view_new();
gtk_widget_set_sensitive(tv, TRUE);
trg_stats_add_column(GTK_TREE_VIEW(tv), STATCOL_STAT, _("Statistic"),
- 200);
+ 200);
trg_stats_add_column(GTK_TREE_VIEW(tv), STATCOL_SESSION, _("Session"),
- 200);
+ 200);
trg_stats_add_column(GTK_TREE_VIEW(tv), STATCOL_CUMULAT,
- _("Cumulative"), 200);
+ _("Cumulative"), 200);
gtk_tree_view_set_model(GTK_TREE_VIEW(tv),
- GTK_TREE_MODEL(priv->model));
+ GTK_TREE_MODEL(priv->model));
gtk_container_set_border_width(GTK_CONTAINER(tv), GUI_PAD);
- gtk_box_pack_start(GTK_BOX(gtk_bin_get_child(GTK_BIN(obj))), tv, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(gtk_bin_get_child(GTK_BIN(obj))), tv, TRUE,
+ TRUE, 0);
dispatch_async(priv->client, session_stats(), on_stats_reply, obj);
@@ -326,27 +330,27 @@ static void trg_stats_dialog_class_init(TrgStatsDialogClass * klass)
object_class->constructor = trg_stats_dialog_constructor;
g_object_class_install_property(object_class,
- PROP_PARENT,
- g_param_spec_object
- ("parent-window", "Parent window",
- "Parent window",
- TRG_TYPE_MAIN_WINDOW,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
+ PROP_PARENT,
+ g_param_spec_object
+ ("parent-window", "Parent window",
+ "Parent window",
+ TRG_TYPE_MAIN_WINDOW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
g_object_class_install_property(object_class,
- PROP_CLIENT,
- g_param_spec_pointer
- ("trg-client", "TClient",
- "Client",
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
+ PROP_CLIENT,
+ g_param_spec_pointer
+ ("trg-client", "TClient",
+ "Client",
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
}
static void trg_stats_dialog_init(TrgStatsDialog * self)
@@ -354,12 +358,12 @@ static void trg_stats_dialog_init(TrgStatsDialog * self)
}
TrgStatsDialog *trg_stats_dialog_get_instance(TrgMainWindow * parent,
- TrgClient * client)
+ TrgClient * client)
{
if (instance == NULL) {
- instance = g_object_new(TRG_TYPE_STATS_DIALOG,
- "trg-client", client,
- "parent-window", parent, NULL);
+ instance = g_object_new(TRG_TYPE_STATS_DIALOG,
+ "trg-client", client,
+ "parent-window", parent, NULL);
}
return TRG_STATS_DIALOG(instance);
diff --git a/src/trg-stats-dialog.h b/src/trg-stats-dialog.h
index ee0656e..06da1e7 100644
--- a/src/trg-stats-dialog.h
+++ b/src/trg-stats-dialog.h
@@ -50,7 +50,7 @@ typedef struct {
GType trg_stats_dialog_get_type(void);
TrgStatsDialog *trg_stats_dialog_get_instance(TrgMainWindow * parent,
- TrgClient * client);
+ TrgClient * client);
G_END_DECLS
-#endif /* TRG_STATS_DIALOG_H_ */
+#endif /* TRG_STATS_DIALOG_H_ */
diff --git a/src/trg-status-bar.c b/src/trg-status-bar.c
index 8e5725e..a6524ed 100644
--- a/src/trg-status-bar.c
+++ b/src/trg-status-bar.c
@@ -53,14 +53,14 @@ static void trg_status_bar_class_init(TrgStatusBarClass * klass)
g_type_class_add_private(klass, sizeof(TrgStatusBarPrivate));
}
-void trg_status_bar_clear_indicators(TrgStatusBar *sb)
+void trg_status_bar_clear_indicators(TrgStatusBar * sb)
{
TrgStatusBarPrivate *priv = TRG_STATUS_BAR_GET_PRIVATE(sb);
gtk_label_set_text(GTK_LABEL(priv->free_lbl), "");
gtk_label_set_text(GTK_LABEL(priv->speed_lbl), "");
}
-void trg_status_bar_reset(TrgStatusBar *sb)
+void trg_status_bar_reset(TrgStatusBar * sb)
{
TrgStatusBarPrivate *priv = TRG_STATUS_BAR_GET_PRIVATE(sb);
trg_status_bar_clear_indicators(sb);
@@ -70,7 +70,7 @@ void trg_status_bar_reset(TrgStatusBar *sb)
static void trg_status_bar_init(TrgStatusBar * self)
{
TrgStatusBarPrivate *priv = TRG_STATUS_BAR_GET_PRIVATE(self);
- gtk_container_set_border_width (GTK_CONTAINER(self), 2);
+ gtk_container_set_border_width(GTK_CONTAINER(self), 2);
priv->info_lbl = gtk_label_new(_("Disconnected"));
gtk_box_pack_start(GTK_BOX(self), priv->info_lbl, FALSE, TRUE, 0);
@@ -83,7 +83,7 @@ static void trg_status_bar_init(TrgStatusBar * self)
}
void trg_status_bar_push_connection_msg(TrgStatusBar * sb,
- const gchar * msg)
+ const gchar * msg)
{
TrgStatusBarPrivate *priv = TRG_STATUS_BAR_GET_PRIVATE(sb);
@@ -97,33 +97,33 @@ void trg_status_bar_connect(TrgStatusBar * sb, JsonObject * session)
session_get_version(session, &version);
statusMsg =
- g_strdup_printf
- (_("Connected to Transmission %g, getting torrents..."), version);
+ g_strdup_printf
+ (_("Connected to Transmission %g, getting torrents..."), version);
g_message("%s", statusMsg);
trg_status_bar_push_connection_msg(sb, statusMsg);
g_free(statusMsg);
}
-void trg_status_bar_session_update(TrgStatusBar *sb, JsonObject *session)
+void trg_status_bar_session_update(TrgStatusBar * sb, JsonObject * session)
{
TrgStatusBarPrivate *priv = TRG_STATUS_BAR_GET_PRIVATE(sb);
gint64 free = session_get_download_dir_free_space(session);
gchar freeSpace[64];
if (free >= 0) {
- gchar *freeSpaceString;
- trg_strlsize(freeSpace, free);
- freeSpaceString = g_strdup_printf(_("Free space: %s"), freeSpace);
- gtk_label_set_text(GTK_LABEL(priv->free_lbl), freeSpaceString);
- g_free(freeSpaceString);
+ gchar *freeSpaceString;
+ trg_strlsize(freeSpace, free);
+ freeSpaceString = g_strdup_printf(_("Free space: %s"), freeSpace);
+ gtk_label_set_text(GTK_LABEL(priv->free_lbl), freeSpaceString);
+ g_free(freeSpaceString);
} else {
- gtk_label_set_text(GTK_LABEL(priv->free_lbl), "");
+ gtk_label_set_text(GTK_LABEL(priv->free_lbl), "");
}
}
void trg_status_bar_update(TrgStatusBar * sb,
- trg_torrent_model_update_stats * stats,
- TrgClient * client)
+ trg_torrent_model_update_stats * stats,
+ TrgClient * client)
{
TrgStatusBarPrivate *priv;
JsonObject *session;
@@ -137,46 +137,45 @@ void trg_status_bar_update(TrgStatusBar * sb,
// The session should always exist otherwise this function wouldn't be called
downlimitraw =
- json_object_get_boolean_member(session,
- SGET_SPEED_LIMIT_DOWN_ENABLED) ?
- json_object_get_int_member(session,
- SGET_SPEED_LIMIT_DOWN) : -1;
+ json_object_get_boolean_member(session,
+ SGET_SPEED_LIMIT_DOWN_ENABLED) ?
+ json_object_get_int_member(session, SGET_SPEED_LIMIT_DOWN) : -1;
uplimitraw =
- json_object_get_boolean_member(session,
- SGET_SPEED_LIMIT_UP_ENABLED) ?
- json_object_get_int_member(session,
- SGET_SPEED_LIMIT_UP) : -1;
+ json_object_get_boolean_member(session,
+ SGET_SPEED_LIMIT_UP_ENABLED) ?
+ json_object_get_int_member(session, SGET_SPEED_LIMIT_UP) : -1;
trg_strlspeed(downRateTotalString,
- stats->downRateTotal / KILOBYTE_FACTOR);
+ stats->downRateTotal / KILOBYTE_FACTOR);
trg_strlspeed(upRateTotalString, stats->upRateTotal / KILOBYTE_FACTOR);
if (uplimitraw >= 0) {
- gchar uplimitstring[32];
- trg_strlspeed(uplimitstring, uplimitraw);
- g_snprintf(uplimit, sizeof(uplimit), _(" (Limit: %s)"),
- uplimitstring);
+ gchar uplimitstring[32];
+ trg_strlspeed(uplimitstring, uplimitraw);
+ g_snprintf(uplimit, sizeof(uplimit), _(" (Limit: %s)"),
+ uplimitstring);
}
if (downlimitraw >= 0) {
- gchar downlimitstring[32];
- trg_strlspeed(downlimitstring, downlimitraw);
- g_snprintf(downlimit, sizeof(downlimit), _(" (Limit: %s)"),
- downlimitstring);
+ gchar downlimitstring[32];
+ trg_strlspeed(downlimitstring, downlimitraw);
+ g_snprintf(downlimit, sizeof(downlimit), _(" (Limit: %s)"),
+ downlimitstring);
}
- speedText = g_strdup_printf(_("Down: %s%s, Up: %s%s"), downRateTotalString,
- downlimitraw >= 0 ? downlimit : "", upRateTotalString,
- uplimitraw >= 0 ? uplimit : "");
+ speedText =
+ g_strdup_printf(_("Down: %s%s, Up: %s%s"), downRateTotalString,
+ downlimitraw >= 0 ? downlimit : "",
+ upRateTotalString, uplimitraw >= 0 ? uplimit : "");
infoText =
- g_strdup_printf
- (ngettext
- ("%d torrent: %d seeding, %d downloading, %d paused",
- "%d torrents: %d seeding, %d downloading, %d paused",
- stats->count), stats->count, stats->seeding, stats->down,
- stats->paused);
+ g_strdup_printf
+ (ngettext
+ ("%d torrent: %d seeding, %d downloading, %d paused",
+ "%d torrents: %d seeding, %d downloading, %d paused",
+ stats->count), stats->count, stats->seeding, stats->down,
+ stats->paused);
gtk_label_set_text(GTK_LABEL(priv->info_lbl), infoText);
gtk_label_set_text(GTK_LABEL(priv->speed_lbl), speedText);
@@ -185,7 +184,7 @@ void trg_status_bar_update(TrgStatusBar * sb,
g_free(infoText);
}
-const gchar *trg_status_bar_get_speed_text(TrgStatusBar *s)
+const gchar *trg_status_bar_get_speed_text(TrgStatusBar * s)
{
TrgStatusBarPrivate *priv = TRG_STATUS_BAR_GET_PRIVATE(s);
return gtk_label_get_text(GTK_LABEL(priv->speed_lbl));
diff --git a/src/trg-status-bar.h b/src/trg-status-bar.h
index d6f0557..fad907b 100644
--- a/src/trg-status-bar.h
+++ b/src/trg-status-bar.h
@@ -51,14 +51,15 @@ TrgStatusBar *trg_status_bar_new();
G_END_DECLS
void trg_status_bar_update(TrgStatusBar * sb,
- trg_torrent_model_update_stats * stats,
- TrgClient * client);
-void trg_status_bar_session_update(TrgStatusBar *sb, JsonObject *session);
+ trg_torrent_model_update_stats * stats,
+ TrgClient * client);
+void trg_status_bar_session_update(TrgStatusBar * sb,
+ JsonObject * session);
void trg_status_bar_connect(TrgStatusBar * sb, JsonObject * session);
void trg_status_bar_push_connection_msg(TrgStatusBar * sb,
- const gchar * msg);
-void trg_status_bar_reset(TrgStatusBar *sb);
-void trg_status_bar_clear_indicators(TrgStatusBar *sb);
-const gchar *trg_status_bar_get_speed_text(TrgStatusBar *s);
+ const gchar * msg);
+void trg_status_bar_reset(TrgStatusBar * sb);
+void trg_status_bar_clear_indicators(TrgStatusBar * sb);
+const gchar *trg_status_bar_get_speed_text(TrgStatusBar * s);
-#endif /* TRG_STATUS_BAR_H_ */
+#endif /* TRG_STATUS_BAR_H_ */
diff --git a/src/trg-toolbar.c b/src/trg-toolbar.c
index 722037c..1c28c74 100644
--- a/src/trg-toolbar.c
+++ b/src/trg-toolbar.c
@@ -67,124 +67,127 @@ struct _TrgToolbarPrivate {
static void
trg_toolbar_set_property(GObject * object,
- guint prop_id,
- const GValue * value,
- GParamSpec * pspec G_GNUC_UNUSED)
+ guint prop_id,
+ const GValue * value,
+ GParamSpec * pspec G_GNUC_UNUSED)
{
- TrgToolbarPrivate *priv =
- TRG_TOOLBAR_GET_PRIVATE(object);
+ TrgToolbarPrivate *priv = TRG_TOOLBAR_GET_PRIVATE(object);
switch (prop_id) {
case PROP_PREFS:
- priv->prefs = g_value_get_pointer(value);
- break;
+ priv->prefs = g_value_get_pointer(value);
+ break;
case PROP_MAIN_WINDOW:
- priv->main_window = g_value_get_object(value);
- break;
+ priv->main_window = g_value_get_object(value);
+ break;
}
}
static void
trg_toolbar_get_property(GObject * object, guint property_id,
- GValue * value, GParamSpec * pspec)
+ GValue * value, GParamSpec * pspec)
{
TrgToolbarPrivate *priv = TRG_TOOLBAR_GET_PRIVATE(object);
switch (property_id) {
case PROP_CONNECT_BUTTON:
- g_value_set_object(value, priv->tb_connect);
- break;
+ g_value_set_object(value, priv->tb_connect);
+ break;
case PROP_DISCONNECT_BUTTON:
- g_value_set_object(value, priv->tb_disconnect);
- break;
+ g_value_set_object(value, priv->tb_disconnect);
+ break;
case PROP_ADD_BUTTON:
- g_value_set_object(value, priv->tb_add);
- break;
+ g_value_set_object(value, priv->tb_add);
+ break;
/* case PROP_ADD_URL_BUTTON:
g_value_set_object(value, priv->tb_add_url);
break;*/
case PROP_REMOVE_BUTTON:
- g_value_set_object(value, priv->tb_remove);
- break;
+ g_value_set_object(value, priv->tb_remove);
+ break;
case PROP_DELETE_BUTTON:
- g_value_set_object(value, priv->tb_delete);
- break;
+ g_value_set_object(value, priv->tb_delete);
+ break;
case PROP_RESUME_BUTTON:
- g_value_set_object(value, priv->tb_resume);
- break;
+ g_value_set_object(value, priv->tb_resume);
+ break;
case PROP_PAUSE_BUTTON:
- g_value_set_object(value, priv->tb_pause);
- break;
- /*case PROP_VERIFY_BUTTON:
- g_value_set_object(value, priv->tb_verify);
- break; */
+ g_value_set_object(value, priv->tb_pause);
+ break;
+ /*case PROP_VERIFY_BUTTON:
+ g_value_set_object(value, priv->tb_verify);
+ break; */
case PROP_PROPS_BUTTON:
- g_value_set_object(value, priv->tb_props);
- break;
+ g_value_set_object(value, priv->tb_props);
+ break;
case PROP_REMOTE_PREFS_BUTTON:
- g_value_set_object(value, priv->tb_remote_prefs);
- break;
+ g_value_set_object(value, priv->tb_remote_prefs);
+ break;
case PROP_LOCAL_PREFS_BUTTON:
- g_value_set_object(value, priv->tb_local_prefs);
- break;
+ g_value_set_object(value, priv->tb_local_prefs);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
static void
trg_toolbar_install_widget_prop(GObjectClass * class, guint propId,
- const gchar * name, const gchar * nick)
+ const gchar * name, const gchar * nick)
{
g_object_class_install_property(class,
- propId,
- g_param_spec_object(name,
- nick,
- nick,
- GTK_TYPE_WIDGET,
- G_PARAM_READABLE
- |
- G_PARAM_STATIC_NAME
- |
- G_PARAM_STATIC_NICK
- |
- G_PARAM_STATIC_BLURB));
+ propId,
+ g_param_spec_object(name,
+ nick,
+ nick,
+ GTK_TYPE_WIDGET,
+ G_PARAM_READABLE
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
}
GtkWidget *trg_toolbar_item_new(TrgToolbar * toolbar,
- gchar * text,
- int *index, gchar * icon,
- gboolean sensitive)
+ gchar * text,
+ int *index, gchar * icon,
+ gboolean sensitive)
{
GtkToolItem *w = gtk_tool_button_new_from_stock(icon);
gtk_widget_set_sensitive(GTK_WIDGET(w), sensitive);
- gtk_tool_item_set_tooltip_text (w,text);
+ gtk_tool_item_set_tooltip_text(w, text);
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), w, (*index)++);
return GTK_WIDGET(w);
}
-static void trg_toolbar_refresh_menu(GtkWidget *w, gpointer data)
+static void trg_toolbar_refresh_menu(GtkWidget * w, gpointer data)
{
TrgToolbarPrivate *priv = TRG_TOOLBAR_GET_PRIVATE(data);
- GtkWidget *old = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(priv->tb_connect));
- GtkWidget *new = trg_menu_bar_file_connect_menu_new(priv->main_window, priv->prefs);
+ GtkWidget *old =
+ gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON
+ (priv->tb_connect));
+ GtkWidget *new =
+ trg_menu_bar_file_connect_menu_new(priv->main_window, priv->prefs);
gtk_widget_destroy(old);
- gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(priv->tb_connect), new);
+ gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(priv->tb_connect),
+ new);
gtk_widget_show_all(new);
}
static GObject *trg_toolbar_constructor(GType type,
- guint
- n_construct_properties,
- GObjectConstructParam
- * construct_params)
+ guint
+ n_construct_properties,
+ GObjectConstructParam
+ * construct_params)
{
GObject *obj = G_OBJECT_CLASS
- (trg_toolbar_parent_class)->constructor(type,
- n_construct_properties,
- construct_params);
+ (trg_toolbar_parent_class)->constructor(type,
+ n_construct_properties,
+ construct_params);
TrgToolbarPrivate *priv = TRG_TOOLBAR_GET_PRIVATE(obj);
GtkToolItem *separator;
@@ -192,26 +195,31 @@ static GObject *trg_toolbar_constructor(GType type,
int position = 0;
gtk_toolbar_set_icon_size(GTK_TOOLBAR(obj),
- GTK_ICON_SIZE_LARGE_TOOLBAR);
+ GTK_ICON_SIZE_LARGE_TOOLBAR);
gtk_toolbar_set_style(GTK_TOOLBAR(obj), GTK_TOOLBAR_ICONS);
//priv->tb_connect =
- /*trg_toolbar_item_new(self, _("Connect"), &position,
- GTK_STOCK_CONNECT, TRUE);*/
-
- priv->tb_connect = GTK_WIDGET(gtk_menu_tool_button_new_from_stock(GTK_STOCK_CONNECT));
- gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(priv->tb_connect), _("Connect"));
- menu = trg_menu_bar_file_connect_menu_new(priv->main_window, priv->prefs);
- gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(priv->tb_connect), menu);
- gtk_toolbar_insert(GTK_TOOLBAR(obj), GTK_TOOL_ITEM(priv->tb_connect), position++);
+ /*trg_toolbar_item_new(self, _("Connect"), &position,
+ GTK_STOCK_CONNECT, TRUE); */
+
+ priv->tb_connect =
+ GTK_WIDGET(gtk_menu_tool_button_new_from_stock(GTK_STOCK_CONNECT));
+ gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(priv->tb_connect),
+ _("Connect"));
+ menu =
+ trg_menu_bar_file_connect_menu_new(priv->main_window, priv->prefs);
+ gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(priv->tb_connect),
+ menu);
+ gtk_toolbar_insert(GTK_TOOLBAR(obj), GTK_TOOL_ITEM(priv->tb_connect),
+ position++);
gtk_widget_show_all(menu);
priv->tb_disconnect =
- trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Disconnect"), &position,
- GTK_STOCK_DISCONNECT, FALSE);
+ trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Disconnect"), &position,
+ GTK_STOCK_DISCONNECT, FALSE);
priv->tb_add =
- trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Add"), &position, GTK_STOCK_ADD,
- FALSE);
+ trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Add"), &position,
+ GTK_STOCK_ADD, FALSE);
/*priv->tb_add_url =
trg_toolbar_item_new(self, "Add URL", 3, GTK_STOCK_ADD, FALSE); */
@@ -220,23 +228,23 @@ static GObject *trg_toolbar_constructor(GType type,
gtk_toolbar_insert(GTK_TOOLBAR(obj), separator, position++);
priv->tb_resume =
- trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Resume"), &position,
- GTK_STOCK_MEDIA_PLAY, FALSE);
+ trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Resume"), &position,
+ GTK_STOCK_MEDIA_PLAY, FALSE);
priv->tb_pause =
- trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Pause"), &position,
- GTK_STOCK_MEDIA_PAUSE, FALSE);
+ trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Pause"), &position,
+ GTK_STOCK_MEDIA_PAUSE, FALSE);
priv->tb_props =
- trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Properties"), &position,
- GTK_STOCK_PROPERTIES, FALSE);
+ trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Properties"), &position,
+ GTK_STOCK_PROPERTIES, FALSE);
priv->tb_remove =
- trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Remove"), &position,
- GTK_STOCK_REMOVE, FALSE);
+ trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Remove"), &position,
+ GTK_STOCK_REMOVE, FALSE);
priv->tb_delete =
- trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Remove with data"),
- &position, GTK_STOCK_CLEAR, FALSE);
+ trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Remove with data"),
+ &position, GTK_STOCK_CLEAR, FALSE);
/*priv->tb_verify =
trg_toolbar_item_new(self, "Verify", 11,
@@ -246,16 +254,17 @@ static GObject *trg_toolbar_constructor(GType type,
gtk_toolbar_insert(GTK_TOOLBAR(obj), separator, position++);
priv->tb_local_prefs =
- trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Local Preferences"), &position,
- GTK_STOCK_PREFERENCES, TRUE);
+ trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Local Preferences"),
+ &position, GTK_STOCK_PREFERENCES, TRUE);
priv->tb_remote_prefs =
- trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Remote Preferences"),
- &position, GTK_STOCK_NETWORK, FALSE);
+ trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Remote Preferences"),
+ &position, GTK_STOCK_NETWORK, FALSE);
gtk_toolbar_set_tooltips(GTK_TOOLBAR(obj), TRUE);
- g_signal_connect(G_OBJECT(priv->prefs), "pref-profile-changed", G_CALLBACK(trg_toolbar_refresh_menu), obj);
+ g_signal_connect(G_OBJECT(priv->prefs), "pref-profile-changed",
+ G_CALLBACK(trg_toolbar_refresh_menu), obj);
return obj;
}
@@ -268,62 +277,65 @@ static void trg_toolbar_class_init(TrgToolbarClass * klass)
object_class->constructor = trg_toolbar_constructor;
g_object_class_install_property(object_class,
- PROP_PREFS,
- g_param_spec_pointer("prefs",
- "Prefs",
- "Prefs",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT
- |
- G_PARAM_STATIC_NAME
- |
- G_PARAM_STATIC_NICK
- |
- G_PARAM_STATIC_BLURB));
+ PROP_PREFS,
+ g_param_spec_pointer("prefs",
+ "Prefs",
+ "Prefs",
+ G_PARAM_READWRITE
+ |
+ G_PARAM_CONSTRUCT
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
g_object_class_install_property(object_class,
- PROP_MAIN_WINDOW,
- g_param_spec_object("mainwindow",
- "mainwindow",
- "mainwindow",
- TRG_TYPE_MAIN_WINDOW,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- |
- G_PARAM_STATIC_NAME
- |
- G_PARAM_STATIC_NICK
- |
- G_PARAM_STATIC_BLURB));
+ PROP_MAIN_WINDOW,
+ g_param_spec_object("mainwindow",
+ "mainwindow",
+ "mainwindow",
+ TRG_TYPE_MAIN_WINDOW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
trg_toolbar_install_widget_prop(object_class, PROP_CONNECT_BUTTON,
- "connect-button", "Connect Button");
+ "connect-button", "Connect Button");
trg_toolbar_install_widget_prop(object_class,
- PROP_DISCONNECT_BUTTON,
- "disconnect-button",
- "Disconnect Button");
+ PROP_DISCONNECT_BUTTON,
+ "disconnect-button",
+ "Disconnect Button");
trg_toolbar_install_widget_prop(object_class, PROP_ADD_BUTTON,
- "add-button", "Add Button");
+ "add-button", "Add Button");
trg_toolbar_install_widget_prop(object_class, PROP_ADD_URL_BUTTON,
- "add-url-button", "Add URL Button");
+ "add-url-button", "Add URL Button");
trg_toolbar_install_widget_prop(object_class, PROP_REMOVE_BUTTON,
- "remove-button", "Remove Button");
+ "remove-button", "Remove Button");
trg_toolbar_install_widget_prop(object_class, PROP_DELETE_BUTTON,
- "delete-button", "Delete Button");
+ "delete-button", "Delete Button");
trg_toolbar_install_widget_prop(object_class, PROP_RESUME_BUTTON,
- "resume-button", "Resume Button");
+ "resume-button", "Resume Button");
trg_toolbar_install_widget_prop(object_class, PROP_PAUSE_BUTTON,
- "pause-button", "Pause Button");
+ "pause-button", "Pause Button");
/*trg_toolbar_install_widget_prop(object_class, PROP_VERIFY_BUTTON,
"verify-button", "Verify Button"); */
trg_toolbar_install_widget_prop(object_class, PROP_PROPS_BUTTON,
- "props-button", "Props Button");
+ "props-button", "Props Button");
trg_toolbar_install_widget_prop(object_class,
- PROP_REMOTE_PREFS_BUTTON,
- "remote-prefs-button",
- "Remote Prefs Button");
+ PROP_REMOTE_PREFS_BUTTON,
+ "remote-prefs-button",
+ "Remote Prefs Button");
trg_toolbar_install_widget_prop(object_class,
- PROP_LOCAL_PREFS_BUTTON,
- "local-prefs-button",
- "Local Prefs Button");
+ PROP_LOCAL_PREFS_BUTTON,
+ "local-prefs-button",
+ "Local Prefs Button");
g_type_class_add_private(klass, sizeof(TrgToolbarPrivate));
}
@@ -340,7 +352,7 @@ void trg_toolbar_connected_change(TrgToolbar * tb, gboolean connected)
}
void trg_toolbar_torrent_actions_sensitive(TrgToolbar * tb,
- gboolean sensitive)
+ gboolean sensitive)
{
TrgToolbarPrivate *priv = TRG_TOOLBAR_GET_PRIVATE(tb);
@@ -357,10 +369,8 @@ static void trg_toolbar_init(TrgToolbar * self)
//TrgToolbarPrivate *priv = TRG_TOOLBAR_GET_PRIVATE(self);
}
-TrgToolbar *trg_toolbar_new(TrgMainWindow *win, TrgPrefs *prefs)
+TrgToolbar *trg_toolbar_new(TrgMainWindow * win, TrgPrefs * prefs)
{
return g_object_new(TRG_TYPE_TOOLBAR,
- "prefs", prefs,
- "mainwindow", win,
- NULL);
+ "prefs", prefs, "mainwindow", win, NULL);
}
diff --git a/src/trg-toolbar.h b/src/trg-toolbar.h
index 5e36503..cdbc199 100644
--- a/src/trg-toolbar.h
+++ b/src/trg-toolbar.h
@@ -49,11 +49,11 @@ typedef struct {
GType trg_toolbar_get_type(void);
-TrgToolbar *trg_toolbar_new(TrgMainWindow *win, TrgPrefs *prefs);
+TrgToolbar *trg_toolbar_new(TrgMainWindow * win, TrgPrefs * prefs);
G_END_DECLS
void trg_toolbar_torrent_actions_sensitive(TrgToolbar * mb,
- gboolean sensitive);
+ gboolean sensitive);
void trg_toolbar_connected_change(TrgToolbar * tb, gboolean connected);
-#endif /* TRG_TOOLBAR_H_ */
+#endif /* TRG_TOOLBAR_H_ */
diff --git a/src/trg-torrent-add-dialog.c b/src/trg-torrent-add-dialog.c
index f06600e..a405556 100644
--- a/src/trg-torrent-add-dialog.c
+++ b/src/trg-torrent-add-dialog.c
@@ -86,85 +86,85 @@ struct _TrgTorrentAddDialogPrivate {
static void
trg_torrent_add_dialog_set_property(GObject * object,
- guint prop_id,
- const GValue * value,
- GParamSpec * pspec G_GNUC_UNUSED)
+ guint prop_id,
+ const GValue * value,
+ GParamSpec * pspec G_GNUC_UNUSED)
{
TrgTorrentAddDialogPrivate *priv =
- TRG_TORRENT_ADD_DIALOG_GET_PRIVATE(object);
+ TRG_TORRENT_ADD_DIALOG_GET_PRIVATE(object);
switch (prop_id) {
case PROP_FILENAME:
- priv->filenames = g_value_get_pointer(value);
- break;
+ priv->filenames = g_value_get_pointer(value);
+ break;
case PROP_PARENT:
- priv->parent = g_value_get_object(value);
- break;
+ priv->parent = g_value_get_object(value);
+ break;
case PROP_CLIENT:
- priv->client = g_value_get_pointer(value);
- break;
+ priv->client = g_value_get_pointer(value);
+ break;
}
}
static void
trg_torrent_add_dialog_get_property(GObject * object,
- guint prop_id,
- GValue * value,
- GParamSpec * pspec G_GNUC_UNUSED)
+ guint prop_id,
+ GValue * value,
+ GParamSpec * pspec G_GNUC_UNUSED)
{
TrgTorrentAddDialogPrivate *priv =
- TRG_TORRENT_ADD_DIALOG_GET_PRIVATE(object);
+ TRG_TORRENT_ADD_DIALOG_GET_PRIVATE(object);
switch (prop_id) {
case PROP_FILENAME:
- g_value_set_pointer(value, priv->filenames);
- break;
+ g_value_set_pointer(value, priv->filenames);
+ break;
case PROP_PARENT:
- g_value_set_object(value, priv->parent);
- break;
+ g_value_set_object(value, priv->parent);
+ break;
}
}
static void add_set_common_args(JsonObject * args, gint priority,
- gchar * dir)
+ gchar * dir)
{
json_object_set_string_member(args, FIELD_FILE_DOWNLOAD_DIR, dir);
json_object_set_int_member(args, FIELD_BANDWIDTH_PRIORITY,
- (gint64) priority);
+ (gint64) priority);
}
static gpointer add_files_threadfunc(gpointer data)
{
struct add_torrent_threadfunc_args *files_thread_data =
- (struct add_torrent_threadfunc_args *) data;
+ (struct add_torrent_threadfunc_args *) data;
GSList *li;
for (li = files_thread_data->list; li; li = g_slist_next(li)) {
- gchar *fileName = (gchar *) li->data;
- JsonNode *request =
- torrent_add(fileName, files_thread_data->flags);
- JsonObject *args;
- trg_response *response;
+ gchar *fileName = (gchar *) li->data;
+ JsonNode *request =
+ torrent_add(fileName, files_thread_data->flags);
+ JsonObject *args;
+ trg_response *response;
- if (!request)
- continue;
+ if (!request)
+ continue;
- args = node_get_arguments(request);
+ args = node_get_arguments(request);
- if (files_thread_data->extraArgs)
- add_set_common_args(args, files_thread_data->priority,
- files_thread_data->dir);
+ if (files_thread_data->extraArgs)
+ add_set_common_args(args, files_thread_data->priority,
+ files_thread_data->dir);
- response = dispatch(files_thread_data->client, request);
- response->cb_data = files_thread_data->cb_data;
- g_idle_add(on_generic_interactive_action, response);
+ response = dispatch(files_thread_data->client, request);
+ response->cb_data = files_thread_data->cb_data;
+ g_idle_add(on_generic_interactive_action, response);
}
g_str_slist_free(files_thread_data->list);
if (files_thread_data->extraArgs)
- g_free(files_thread_data->dir);
+ g_free(files_thread_data->dir);
g_free(files_thread_data);
@@ -177,39 +177,39 @@ void launch_add_thread(struct add_torrent_threadfunc_args *args)
g_thread_create(add_files_threadfunc, args, FALSE, &error);
if (error) {
- g_error("thread creation error: %s", error->message);
- g_error_free(error);
- g_str_slist_free(args->list);
- g_free(args);
+ g_error("thread creation error: %s", error->message);
+ g_error_free(error);
+ g_str_slist_free(args->list);
+ g_free(args);
}
}
static gboolean add_file_indexes_foreachfunc(GtkTreeModel * model,
- GtkTreePath *
- path G_GNUC_UNUSED,
- GtkTreeIter * iter,
- gpointer data)
+ GtkTreePath *
+ path G_GNUC_UNUSED,
+ GtkTreeIter * iter,
+ gpointer data)
{
JsonObject *args = (JsonObject *) data;
gint priority, index, wanted;
gtk_tree_model_get(model, iter, FC_PRIORITY, &priority,
- FC_ENABLED, &wanted, FC_INDEX, &index, -1);
+ FC_ENABLED, &wanted, FC_INDEX, &index, -1);
if (gtk_tree_model_iter_has_child(model, iter))
- return FALSE;
+ return FALSE;
if (wanted)
- add_file_id_to_array(args, FIELD_FILES_WANTED, index);
+ add_file_id_to_array(args, FIELD_FILES_WANTED, index);
else
- add_file_id_to_array(args, FIELD_FILES_UNWANTED, index);
+ add_file_id_to_array(args, FIELD_FILES_UNWANTED, index);
if (priority == TR_PRI_LOW)
- add_file_id_to_array(args, FIELD_FILES_PRIORITY_LOW, index);
+ add_file_id_to_array(args, FIELD_FILES_PRIORITY_LOW, index);
else if (priority == TR_PRI_HIGH)
- add_file_id_to_array(args, FIELD_FILES_PRIORITY_HIGH, index);
+ add_file_id_to_array(args, FIELD_FILES_PRIORITY_HIGH, index);
else
- add_file_id_to_array(args, FIELD_FILES_PRIORITY_NORMAL, index);
+ add_file_id_to_array(args, FIELD_FILES_PRIORITY_NORMAL, index);
return FALSE;
}
@@ -218,50 +218,54 @@ static void
trg_torrent_add_response_cb(GtkDialog * dlg, gint res_id, gpointer data)
{
TrgTorrentAddDialogPrivate *priv =
- TRG_TORRENT_ADD_DIALOG_GET_PRIVATE(dlg);
+ TRG_TORRENT_ADD_DIALOG_GET_PRIVATE(dlg);
guint flags = 0x00;
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->paused_check)))
- flags |= TORRENT_ADD_FLAG_PAUSED;
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->delete_check)))
- flags |= TORRENT_ADD_FLAG_DELETE;
+ if (gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON(priv->paused_check)))
+ flags |= TORRENT_ADD_FLAG_PAUSED;
+ if (gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON(priv->delete_check)))
+ flags |= TORRENT_ADD_FLAG_DELETE;
if (res_id == GTK_RESPONSE_ACCEPT) {
- gint priority =
- gtk_combo_box_get_active(GTK_COMBO_BOX(priv->priority_combo)) -
- 1;
- gchar *dir =
- trg_destination_combo_get_dir(TRG_DESTINATION_COMBO(priv->dest_combo));
-
- if (g_slist_length(priv->filenames) == 1) {
- JsonNode *req =
- torrent_add((gchar *) priv->filenames->data, flags);
- if (req) {
- JsonObject *args = node_get_arguments(req);
- gtk_tree_model_foreach(GTK_TREE_MODEL(priv->store),
- add_file_indexes_foreachfunc, args);
- add_set_common_args(args, priority, dir);
- dispatch_async(priv->client, req,
- on_generic_interactive_action, priv->parent);
- }
- g_str_slist_free(priv->filenames);
- } else {
- struct add_torrent_threadfunc_args *args =
- g_new(struct add_torrent_threadfunc_args, 1);
- args->list = priv->filenames;
- args->cb_data = priv->parent;
- args->client = priv->client;
- args->dir = g_strdup(dir);
- args->priority = priority;
- args->flags = flags;
- args->extraArgs = TRUE;
-
- launch_add_thread(args);
- }
-
- g_free(dir);
+ gint priority =
+ gtk_combo_box_get_active(GTK_COMBO_BOX(priv->priority_combo)) -
+ 1;
+ gchar *dir =
+ trg_destination_combo_get_dir(TRG_DESTINATION_COMBO
+ (priv->dest_combo));
+
+ if (g_slist_length(priv->filenames) == 1) {
+ JsonNode *req =
+ torrent_add((gchar *) priv->filenames->data, flags);
+ if (req) {
+ JsonObject *args = node_get_arguments(req);
+ gtk_tree_model_foreach(GTK_TREE_MODEL(priv->store),
+ add_file_indexes_foreachfunc, args);
+ add_set_common_args(args, priority, dir);
+ dispatch_async(priv->client, req,
+ on_generic_interactive_action,
+ priv->parent);
+ }
+ g_str_slist_free(priv->filenames);
+ } else {
+ struct add_torrent_threadfunc_args *args =
+ g_new(struct add_torrent_threadfunc_args, 1);
+ args->list = priv->filenames;
+ args->cb_data = priv->parent;
+ args->client = priv->client;
+ args->dir = g_strdup(dir);
+ args->priority = priority;
+ args->flags = flags;
+ args->extraArgs = TRUE;
+
+ launch_add_thread(args);
+ }
+
+ g_free(dir);
} else {
- g_str_slist_free(priv->filenames);
+ g_str_slist_free(priv->filenames);
}
gtk_widget_destroy(GTK_WIDGET(dlg));
@@ -269,40 +273,40 @@ trg_torrent_add_response_cb(GtkDialog * dlg, gint res_id, gpointer data)
static void
renderPriority(GtkTreeViewColumn * column G_GNUC_UNUSED,
- GtkCellRenderer * renderer,
- GtkTreeModel * model,
- GtkTreeIter * iter, gpointer data G_GNUC_UNUSED)
+ GtkCellRenderer * renderer,
+ GtkTreeModel * model,
+ GtkTreeIter * iter, gpointer data G_GNUC_UNUSED)
{
int priority;
const char *text;
gtk_tree_model_get(model, iter, FC_PRIORITY, &priority, -1);
switch (priority) {
case TR_PRI_HIGH:
- text = _("High");
- break;
+ text = _("High");
+ break;
case TR_PRI_NORMAL:
- text = _("Normal");
- break;
+ text = _("Normal");
+ break;
case TR_PRI_LOW:
- text = _("Low");
- break;
+ text = _("Low");
+ break;
default:
- text = _("Mixed");
- break;
+ text = _("Mixed");
+ break;
}
g_object_set(renderer, "text", text, NULL);
}
static void
renderDownload(GtkTreeViewColumn * column G_GNUC_UNUSED,
- GtkCellRenderer * renderer,
- GtkTreeModel * model,
- GtkTreeIter * iter, gpointer data G_GNUC_UNUSED)
+ GtkCellRenderer * renderer,
+ GtkTreeModel * model,
+ GtkTreeIter * iter, gpointer data G_GNUC_UNUSED)
{
gint enabled;
gtk_tree_model_get(model, iter, FC_ENABLED, &enabled, -1);
g_object_set(renderer, "inconsistent", (enabled == MIXED),
- "active", (enabled == TRUE), NULL);
+ "active", (enabled == TRUE), NULL);
}
struct SubtreeForeachData {
@@ -313,116 +317,116 @@ struct SubtreeForeachData {
static gboolean
setSubtreeForeach(GtkTreeModel * model,
- GtkTreePath * path, GtkTreeIter * iter, gpointer gdata)
+ GtkTreePath * path, GtkTreeIter * iter, gpointer gdata)
{
struct SubtreeForeachData *data = gdata;
if (!gtk_tree_path_compare(path, data->path)
- || gtk_tree_path_is_descendant(path, data->path)) {
- gtk_tree_store_set(GTK_TREE_STORE(model), iter, data->column,
- data->new_value, -1);
+ || gtk_tree_path_is_descendant(path, data->path)) {
+ gtk_tree_store_set(GTK_TREE_STORE(model), iter, data->column,
+ data->new_value, -1);
}
- return FALSE; /* keep walking */
+ return FALSE; /* keep walking */
}
static void
setSubtree(GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter,
- gint column, gint new_value)
+ gint column, gint new_value)
{
gint result = new_value;
GtkTreeIter back_iter = *iter;
if (gtk_tree_model_iter_has_child(model, iter)) {
- struct SubtreeForeachData tmp;
- GtkTreeIter parent;
+ struct SubtreeForeachData tmp;
+ GtkTreeIter parent;
- tmp.column = column;
- tmp.new_value = new_value;
- tmp.path = path;
- gtk_tree_model_foreach(model, setSubtreeForeach, &tmp);
+ tmp.column = column;
+ tmp.new_value = new_value;
+ tmp.path = path;
+ gtk_tree_model_foreach(model, setSubtreeForeach, &tmp);
- gtk_tree_model_iter_parent(model, &parent, iter);
+ gtk_tree_model_iter_parent(model, &parent, iter);
} else {
- gtk_tree_store_set(GTK_TREE_STORE(model), &back_iter, column,
- new_value, -1);
+ gtk_tree_store_set(GTK_TREE_STORE(model), &back_iter, column,
+ new_value, -1);
}
while (1) {
- GtkTreeIter tmp_iter;
- gint n_children, i;
+ GtkTreeIter tmp_iter;
+ gint n_children, i;
- if (!gtk_tree_model_iter_parent(model, &tmp_iter, &back_iter))
- break;
+ if (!gtk_tree_model_iter_parent(model, &tmp_iter, &back_iter))
+ break;
- n_children = gtk_tree_model_iter_n_children(model, &tmp_iter);
+ n_children = gtk_tree_model_iter_n_children(model, &tmp_iter);
- for (i = 0; i < n_children; i++) {
- GtkTreeIter child;
- gint current_value;
+ for (i = 0; i < n_children; i++) {
+ GtkTreeIter child;
+ gint current_value;
- if (!gtk_tree_model_iter_nth_child
- (model, &child, &tmp_iter, i))
- continue;
+ if (!gtk_tree_model_iter_nth_child
+ (model, &child, &tmp_iter, i))
+ continue;
- gtk_tree_model_get(model, &child, column, &current_value, -1);
- if (current_value != new_value) {
- result = MIXED;
- break;
- }
- }
+ gtk_tree_model_get(model, &child, column, &current_value, -1);
+ if (current_value != new_value) {
+ result = MIXED;
+ break;
+ }
+ }
- gtk_tree_store_set(GTK_TREE_STORE(model), &tmp_iter, column,
- result, -1);
+ gtk_tree_store_set(GTK_TREE_STORE(model), &tmp_iter, column,
+ result, -1);
- back_iter = tmp_iter;
+ back_iter = tmp_iter;
}
}
static gboolean
onViewPathToggled(GtkTreeView * view,
- GtkTreeViewColumn * col,
- GtkTreePath * path, gpointer data)
+ GtkTreeViewColumn * col,
+ GtkTreePath * path, gpointer data)
{
int cid;
gboolean handled = FALSE;
if (!col || !path)
- return FALSE;
+ return FALSE;
cid =
- GPOINTER_TO_INT(g_object_get_data
- (G_OBJECT(col), TR_COLUMN_ID_KEY));
+ GPOINTER_TO_INT(g_object_get_data
+ (G_OBJECT(col), TR_COLUMN_ID_KEY));
if ((cid == FC_PRIORITY) || (cid == FC_ENABLED)) {
- GtkTreeIter iter;
- GtkTreeModel *model = gtk_tree_view_get_model(view);
-
- gtk_tree_model_get_iter(model, &iter, path);
-
- if (cid == FC_PRIORITY) {
- int priority;
- gtk_tree_model_get(model, &iter, FC_PRIORITY, &priority, -1);
- switch (priority) {
- case TR_PRI_NORMAL:
- priority = TR_PRI_HIGH;
- break;
- case TR_PRI_HIGH:
- priority = TR_PRI_LOW;
- break;
- default:
- priority = TR_PRI_NORMAL;
- break;
- }
- setSubtree(model, path, &iter, FC_PRIORITY, priority);
- } else {
- int enabled;
- gtk_tree_model_get(model, &iter, FC_ENABLED, &enabled, -1);
- enabled = !enabled;
-
- setSubtree(model, path, &iter, FC_ENABLED, enabled);
- }
-
- handled = TRUE;
+ GtkTreeIter iter;
+ GtkTreeModel *model = gtk_tree_view_get_model(view);
+
+ gtk_tree_model_get_iter(model, &iter, path);
+
+ if (cid == FC_PRIORITY) {
+ int priority;
+ gtk_tree_model_get(model, &iter, FC_PRIORITY, &priority, -1);
+ switch (priority) {
+ case TR_PRI_NORMAL:
+ priority = TR_PRI_HIGH;
+ break;
+ case TR_PRI_HIGH:
+ priority = TR_PRI_LOW;
+ break;
+ default:
+ priority = TR_PRI_NORMAL;
+ break;
+ }
+ setSubtree(model, path, &iter, FC_PRIORITY, priority);
+ } else {
+ int enabled;
+ gtk_tree_model_get(model, &iter, FC_ENABLED, &enabled, -1);
+ enabled = !enabled;
+
+ setSubtree(model, path, &iter, FC_ENABLED, enabled);
+ }
+
+ handled = TRUE;
}
return handled;
@@ -430,20 +434,20 @@ onViewPathToggled(GtkTreeView * view,
static gboolean
getAndSelectEventPath(GtkTreeView * treeview,
- GdkEventButton * event,
- GtkTreeViewColumn ** col, GtkTreePath ** path)
+ GdkEventButton * event,
+ GtkTreeViewColumn ** col, GtkTreePath ** path)
{
GtkTreeSelection *sel;
if (gtk_tree_view_get_path_at_pos(treeview,
- event->x, event->y,
- path, col, NULL, NULL)) {
- sel = gtk_tree_view_get_selection(treeview);
- if (!gtk_tree_selection_path_is_selected(sel, *path)) {
- gtk_tree_selection_unselect_all(sel);
- gtk_tree_selection_select_path(sel, *path);
- }
- return TRUE;
+ event->x, event->y,
+ path, col, NULL, NULL)) {
+ sel = gtk_tree_view_get_selection(treeview);
+ if (!gtk_tree_selection_path_is_selected(sel, *path)) {
+ gtk_tree_selection_unselect_all(sel);
+ gtk_tree_selection_select_path(sel, *path);
+ }
+ return TRUE;
}
return FALSE;
@@ -458,9 +462,9 @@ onViewButtonPressed(GtkWidget * w, GdkEventButton * event, gpointer gdata)
GtkTreeView *treeview = GTK_TREE_VIEW(w);
if (event->type == GDK_BUTTON_PRESS && event->button == 1
- && !(event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK))
- && getAndSelectEventPath(treeview, event, &col, &path)) {
- handled = onViewPathToggled(treeview, col, path, NULL);
+ && !(event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK))
+ && getAndSelectEventPath(treeview, event, &col, &path)) {
+ handled = onViewPathToggled(treeview, col, path, NULL);
}
gtk_tree_path_free(path);
@@ -488,12 +492,12 @@ GtkWidget *gtr_file_list_new(GtkTreeStore ** store)
gtk_tree_view_set_rules_hint(tree_view, TRUE);
gtk_container_set_border_width(GTK_CONTAINER(view), GUI_PAD_BIG);
g_signal_connect(view, "button-press-event",
- G_CALLBACK(onViewButtonPressed), view);
+ G_CALLBACK(onViewButtonPressed), view);
pango_context = gtk_widget_create_pango_context(view);
pango_font_description =
- pango_font_description_copy(pango_context_get_font_description
- (pango_context));
+ pango_font_description_copy(pango_context_get_font_description
+ (pango_context));
size = pango_font_description_get_size(pango_font_description);
pango_font_description_set_size(pango_font_description, size * 0.8);
g_object_unref(G_OBJECT(pango_context));
@@ -506,8 +510,8 @@ GtkWidget *gtr_file_list_new(GtkTreeStore ** store)
/* add file column */
col = GTK_TREE_VIEW_COLUMN(g_object_new(GTK_TYPE_TREE_VIEW_COLUMN,
- "expand", TRUE,
- "title", _("Name"), NULL));
+ "expand", TRUE,
+ "title", _("Name"), NULL));
gtk_tree_view_column_set_resizable(col, TRUE);
rend = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(col, rend, FALSE);
@@ -516,7 +520,7 @@ GtkWidget *gtr_file_list_new(GtkTreeStore ** store)
/* add text renderer */
rend = gtk_cell_renderer_text_new();
g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, "font-desc",
- pango_font_description, NULL);
+ pango_font_description, NULL);
gtk_tree_view_column_pack_start(col, rend, TRUE);
gtk_tree_view_column_set_attributes(col, rend, "text", FC_LABEL, NULL);
gtk_tree_view_column_set_sort_column_id(col, FC_LABEL);
@@ -527,29 +531,29 @@ GtkWidget *gtr_file_list_new(GtkTreeStore ** store)
title = _("Size");
rend = trg_cell_renderer_size_new();
g_object_set(rend, "alignment", PANGO_ALIGN_RIGHT,
- "font-desc", pango_font_description,
- "xpad", GUI_PAD, "xalign", 1.0f, "yalign", 0.5f, NULL);
+ "font-desc", pango_font_description,
+ "xpad", GUI_PAD, "xalign", 1.0f, "yalign", 0.5f, NULL);
col = gtk_tree_view_column_new_with_attributes(title, rend, NULL);
gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
gtk_tree_view_column_set_sort_column_id(col, FC_SIZE);
gtk_tree_view_column_set_attributes(col, rend, "size-value", FC_SIZE,
- NULL);
+ NULL);
gtk_tree_view_append_column(tree_view, col);
/* add "enabled" column */
title = _("Download");
pango_layout = gtk_widget_create_pango_layout(view, title);
pango_layout_get_pixel_size(pango_layout, &width, NULL);
- width += 30; /* room for the sort indicator */
+ width += 30; /* room for the sort indicator */
g_object_unref(G_OBJECT(pango_layout));
rend = gtk_cell_renderer_toggle_new();
col = gtk_tree_view_column_new_with_attributes(title, rend, NULL);
g_object_set_data(G_OBJECT(col), TR_COLUMN_ID_KEY,
- GINT_TO_POINTER(FC_ENABLED));
+ GINT_TO_POINTER(FC_ENABLED));
gtk_tree_view_column_set_fixed_width(col, width);
gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_cell_data_func(col, rend, renderDownload,
- NULL, NULL);
+ NULL, NULL);
gtk_tree_view_column_set_sort_column_id(col, FC_ENABLED);
gtk_tree_view_append_column(tree_view, col);
@@ -557,27 +561,27 @@ GtkWidget *gtr_file_list_new(GtkTreeStore ** store)
title = _("Priority");
pango_layout = gtk_widget_create_pango_layout(view, title);
pango_layout_get_pixel_size(pango_layout, &width, NULL);
- width += 30; /* room for the sort indicator */
+ width += 30; /* room for the sort indicator */
g_object_unref(G_OBJECT(pango_layout));
rend = gtk_cell_renderer_text_new();
g_object_set(rend, "xalign", (gfloat) 0.5, "yalign", (gfloat) 0.5,
- NULL);
+ NULL);
col = gtk_tree_view_column_new_with_attributes(title, rend, NULL);
g_object_set_data(G_OBJECT(col), TR_COLUMN_ID_KEY,
- GINT_TO_POINTER(FC_PRIORITY));
+ GINT_TO_POINTER(FC_PRIORITY));
gtk_tree_view_column_set_fixed_width(col, width);
gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_sort_column_id(col, FC_PRIORITY);
gtk_tree_view_column_set_cell_data_func(col, rend, renderPriority,
- NULL, NULL);
+ NULL, NULL);
gtk_tree_view_append_column(tree_view, col);
- *store = gtk_tree_store_new(N_FILE_COLS, G_TYPE_STRING, /* icon */
- G_TYPE_UINT, /* index */
- G_TYPE_STRING, /* label */
- G_TYPE_INT64, /* size */
- G_TYPE_INT, /* priority */
- G_TYPE_INT); /* dl enabled */
+ *store = gtk_tree_store_new(N_FILE_COLS, G_TYPE_STRING, /* icon */
+ G_TYPE_UINT, /* index */
+ G_TYPE_STRING, /* label */
+ G_TYPE_INT64, /* size */
+ G_TYPE_INT, /* priority */
+ G_TYPE_INT); /* dl enabled */
gtk_tree_view_set_model(tree_view, GTK_TREE_MODEL(*store));
g_object_unref(G_OBJECT(*store));
@@ -585,10 +589,10 @@ GtkWidget *gtr_file_list_new(GtkTreeStore ** store)
/* create the scrolled window and stick the view in it */
scroll = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll),
- GTK_SHADOW_IN);
+ GTK_SHADOW_IN);
gtk_container_add(GTK_CONTAINER(scroll), view);
gtk_widget_set_size_request(scroll, -1, 200);
@@ -615,8 +619,8 @@ static void gtr_dialog_set_content(GtkDialog * dialog, GtkWidget * content)
GtkWidget *gtr_priority_combo_new(void)
{
return gtr_combo_box_new_enum(_("Low"), TR_PRI_LOW,
- _("Normal"), TR_PRI_NORMAL,
- _("High"), TR_PRI_HIGH, NULL);
+ _("Normal"), TR_PRI_NORMAL,
+ _("High"), TR_PRI_HIGH, NULL);
}
static void addTorrentFilters(GtkFileChooser * chooser)
@@ -635,181 +639,184 @@ static void addTorrentFilters(GtkFileChooser * chooser)
}
static void store_add_node(GtkTreeStore * store, GtkTreeIter * parent,
- trg_torrent_file_node * node)
+ trg_torrent_file_node * node)
{
GtkTreeIter child;
GList *li;
if (node->name) {
- gtk_tree_store_append(store, &child, parent);
- gtk_tree_store_set(store, &child, FC_LABEL, node->name, -1);
- gtk_tree_store_set(store, &child, FC_ICON,
- node->children ? GTK_STOCK_DIRECTORY :
- GTK_STOCK_FILE, -1);
- gtk_tree_store_set(store, &child, FC_ENABLED, 1, -1);
- if (!node->children) {
- gtk_tree_store_set(store, &child, FC_INDEX, node->index, -1);
- gtk_tree_store_set(store, &child, FC_SIZE, node->length, -1);
- gtk_tree_store_set(store, &child, FC_PRIORITY, 0, -1);
- }
+ gtk_tree_store_append(store, &child, parent);
+ gtk_tree_store_set(store, &child, FC_LABEL, node->name, -1);
+ gtk_tree_store_set(store, &child, FC_ICON,
+ node->children ? GTK_STOCK_DIRECTORY :
+ GTK_STOCK_FILE, -1);
+ gtk_tree_store_set(store, &child, FC_ENABLED, 1, -1);
+ if (!node->children) {
+ gtk_tree_store_set(store, &child, FC_INDEX, node->index, -1);
+ gtk_tree_store_set(store, &child, FC_SIZE, node->length, -1);
+ gtk_tree_store_set(store, &child, FC_PRIORITY, 0, -1);
+ }
}
for (li = node->children; li; li = g_list_next(li))
- store_add_node(store, node->name ? &child : NULL,
- (trg_torrent_file_node *) li->data);
+ store_add_node(store, node->name ? &child : NULL,
+ (trg_torrent_file_node *) li->data);
}
static void torrent_not_parsed_warning(GtkWindow * parent)
{
GtkWidget *dialog =
- gtk_message_dialog_new(parent, GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,
- _
- ("Unable to parse torrent file. File preferences unavailable, but you can still try uploading it."));
+ gtk_message_dialog_new(parent, GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,
+ _
+ ("Unable to parse torrent file. File preferences unavailable, but you can still try uploading it."));
gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
}
-static void torrent_not_found_error(GtkWindow * parent, gchar *file)
+static void torrent_not_found_error(GtkWindow * parent, gchar * file)
{
GtkWidget *dialog =
- gtk_message_dialog_new(parent, GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- _
- ("Unable to open torrent file: %s"), file);
+ gtk_message_dialog_new(parent, GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+ _("Unable to open torrent file: %s"), file);
gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
}
static void trg_torrent_add_dialog_set_filenames(TrgTorrentAddDialog * d,
- GSList * filenames)
+ GSList * filenames)
{
TrgTorrentAddDialogPrivate *priv =
- TRG_TORRENT_ADD_DIALOG_GET_PRIVATE(d);
+ TRG_TORRENT_ADD_DIALOG_GET_PRIVATE(d);
GtkButton *chooser = GTK_BUTTON(priv->source_chooser);
gint nfiles = filenames ? g_slist_length(filenames) : 0;
gtk_tree_store_clear(priv->store);
if (nfiles == 1) {
- gchar *file_name = (gchar *) filenames->data;
- if (is_url(file_name) || is_magnet(file_name)) {
- gtk_button_set_label(chooser, file_name);
- gtk_widget_set_sensitive(priv->file_list, FALSE);
- gtk_widget_set_sensitive(priv->delete_check, FALSE);
- } else {
- gchar *file_name_base;
- trg_torrent_file *tor_data = NULL;
-
- file_name_base = g_path_get_basename(file_name);
-
- if (file_name_base) {
- gtk_button_set_label(chooser, file_name_base);
- g_free(file_name_base);
- } else {
- gtk_button_set_label(chooser, file_name);
- }
-
- if (g_file_test(file_name, G_FILE_TEST_IS_REGULAR))
- {
- tor_data = trg_parse_torrent_file(file_name);
- if (!tor_data) {
- torrent_not_parsed_warning(GTK_WINDOW(priv->parent));
- } else {
- store_add_node(priv->store, NULL, tor_data->top_node);
- trg_torrent_file_free(tor_data);
- }
- } else {
- torrent_not_found_error(GTK_WINDOW(priv->parent), file_name);
- }
-
- gtk_widget_set_sensitive(priv->file_list, tor_data != NULL);
- }
+ gchar *file_name = (gchar *) filenames->data;
+ if (is_url(file_name) || is_magnet(file_name)) {
+ gtk_button_set_label(chooser, file_name);
+ gtk_widget_set_sensitive(priv->file_list, FALSE);
+ gtk_widget_set_sensitive(priv->delete_check, FALSE);
+ } else {
+ gchar *file_name_base;
+ trg_torrent_file *tor_data = NULL;
+
+ file_name_base = g_path_get_basename(file_name);
+
+ if (file_name_base) {
+ gtk_button_set_label(chooser, file_name_base);
+ g_free(file_name_base);
+ } else {
+ gtk_button_set_label(chooser, file_name);
+ }
+
+ if (g_file_test(file_name, G_FILE_TEST_IS_REGULAR)) {
+ tor_data = trg_parse_torrent_file(file_name);
+ if (!tor_data) {
+ torrent_not_parsed_warning(GTK_WINDOW(priv->parent));
+ } else {
+ store_add_node(priv->store, NULL, tor_data->top_node);
+ trg_torrent_file_free(tor_data);
+ }
+ } else {
+ torrent_not_found_error(GTK_WINDOW(priv->parent),
+ file_name);
+ }
+
+ gtk_widget_set_sensitive(priv->file_list, tor_data != NULL);
+ }
} else {
- gtk_widget_set_sensitive(priv->file_list, FALSE);
- if (nfiles < 1) {
- gtk_button_set_label(chooser, _("(None)"));
- } else {
- gtk_button_set_label(chooser, _("(Multiple)"));
- }
+ gtk_widget_set_sensitive(priv->file_list, FALSE);
+ if (nfiles < 1) {
+ gtk_button_set_label(chooser, _("(None)"));
+ } else {
+ gtk_button_set_label(chooser, _("(Multiple)"));
+ }
}
priv->filenames = filenames;
}
static void trg_torrent_add_dialog_generic_save_dir(GtkFileChooser * c,
- TrgPrefs *prefs)
+ TrgPrefs * prefs)
{
gchar *cwd = gtk_file_chooser_get_current_folder(c);
if (cwd) {
- trg_prefs_set_string(prefs, TRG_PREFS_KEY_LAST_TORRENT_DIR, cwd, TRG_PREFS_GLOBAL);
- g_free(cwd);
+ trg_prefs_set_string(prefs, TRG_PREFS_KEY_LAST_TORRENT_DIR, cwd,
+ TRG_PREFS_GLOBAL);
+ g_free(cwd);
}
}
static GtkWidget *trg_torrent_add_dialog_generic(GtkWindow * parent,
- TrgPrefs * prefs)
+ TrgPrefs * prefs)
{
GtkWidget *w = gtk_file_chooser_dialog_new(_("Add a Torrent"), parent,
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL,
- GTK_STOCK_ADD,
- GTK_RESPONSE_ACCEPT,
- NULL);
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_ADD,
+ GTK_RESPONSE_ACCEPT,
+ NULL);
gchar *dir =
- trg_prefs_get_string(prefs, TRG_PREFS_KEY_LAST_TORRENT_DIR, TRG_PREFS_GLOBAL);
+ trg_prefs_get_string(prefs, TRG_PREFS_KEY_LAST_TORRENT_DIR,
+ TRG_PREFS_GLOBAL);
if (dir) {
- gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(w), dir);
- g_free(dir);
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(w), dir);
+ g_free(dir);
}
addTorrentFilters(GTK_FILE_CHOOSER(w));
gtk_dialog_set_alternative_button_order(GTK_DIALOG(w),
- GTK_RESPONSE_ACCEPT,
- GTK_RESPONSE_CANCEL, -1);
+ GTK_RESPONSE_ACCEPT,
+ GTK_RESPONSE_CANCEL, -1);
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(w), TRUE);
return w;
}
static void trg_torrent_add_dialog_source_click_cb(GtkWidget * w,
- gpointer data)
+ gpointer data)
{
TrgTorrentAddDialogPrivate *priv =
- TRG_TORRENT_ADD_DIALOG_GET_PRIVATE(data);
+ TRG_TORRENT_ADD_DIALOG_GET_PRIVATE(data);
GtkWidget *d = trg_torrent_add_dialog_generic(GTK_WINDOW(data),
- trg_client_get_prefs(priv->client));
+ trg_client_get_prefs
+ (priv->client));
if (gtk_dialog_run(GTK_DIALOG(d)) == GTK_RESPONSE_ACCEPT) {
- if (priv->filenames)
- g_str_slist_free(priv->filenames);
+ if (priv->filenames)
+ g_str_slist_free(priv->filenames);
- priv->filenames =
- gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(d));
+ priv->filenames =
+ gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(d));
- trg_torrent_add_dialog_generic_save_dir(GTK_FILE_CHOOSER(d),
- trg_client_get_prefs(priv->client));
- trg_torrent_add_dialog_set_filenames(TRG_TORRENT_ADD_DIALOG(data),
- priv->filenames);
+ trg_torrent_add_dialog_generic_save_dir(GTK_FILE_CHOOSER(d),
+ trg_client_get_prefs(priv->
+ client));
+ trg_torrent_add_dialog_set_filenames(TRG_TORRENT_ADD_DIALOG(data),
+ priv->filenames);
}
gtk_widget_destroy(GTK_WIDGET(d));
}
static GObject *trg_torrent_add_dialog_constructor(GType type,
- guint
- n_construct_properties,
- GObjectConstructParam
- * construct_params)
+ guint
+ n_construct_properties,
+ GObjectConstructParam
+ * construct_params)
{
GObject *obj = G_OBJECT_CLASS
- (trg_torrent_add_dialog_parent_class)->constructor(type,
- n_construct_properties,
- construct_params);
+ (trg_torrent_add_dialog_parent_class)->constructor(type,
+ n_construct_properties,
+ construct_params);
TrgTorrentAddDialogPrivate *priv =
- TRG_TORRENT_ADD_DIALOG_GET_PRIVATE(obj);
+ TRG_TORRENT_ADD_DIALOG_GET_PRIVATE(obj);
TrgPrefs *prefs = trg_client_get_prefs(priv->client);
GtkWidget *t, *l;
@@ -819,17 +826,17 @@ static GObject *trg_torrent_add_dialog_constructor(GType type,
/* window */
gtk_window_set_title(GTK_WINDOW(obj), _("Add Torrent"));
gtk_window_set_transient_for(GTK_WINDOW(obj),
- GTK_WINDOW(priv->parent));
+ GTK_WINDOW(priv->parent));
gtk_window_set_destroy_with_parent(GTK_WINDOW(obj), TRUE);
/* buttons */
gtk_dialog_add_button(GTK_DIALOG(obj), GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL);
+ GTK_RESPONSE_CANCEL);
gtk_dialog_add_button(GTK_DIALOG(obj), GTK_STOCK_OPEN,
- GTK_RESPONSE_ACCEPT);
+ GTK_RESPONSE_ACCEPT);
gtk_dialog_set_alternative_button_order(GTK_DIALOG(obj),
- GTK_RESPONSE_ACCEPT,
- GTK_RESPONSE_CANCEL, -1);
+ GTK_RESPONSE_ACCEPT,
+ GTK_RESPONSE_CANCEL, -1);
gtk_dialog_set_default_response(GTK_DIALOG(obj), GTK_RESPONSE_ACCEPT);
/* workspace */
@@ -842,13 +849,19 @@ static GObject *trg_torrent_add_dialog_constructor(GType type,
gtk_widget_set_sensitive(priv->file_list, FALSE);
priv->paused_check =
- gtk_check_button_new_with_mnemonic(_("Start _paused"));
+ gtk_check_button_new_with_mnemonic(_("Start _paused"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->paused_check),
- trg_prefs_get_bool(prefs, TRG_PREFS_KEY_START_PAUSED, TRG_PREFS_GLOBAL));
+ trg_prefs_get_bool(prefs,
+ TRG_PREFS_KEY_START_PAUSED,
+ TRG_PREFS_GLOBAL));
- priv->delete_check = gtk_check_button_new_with_mnemonic(_("Delete local .torrent file after adding"));
+ priv->delete_check =
+ gtk_check_button_new_with_mnemonic(_
+ ("Delete local .torrent file after adding"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->delete_check),
- trg_prefs_get_bool(prefs, TRG_PREFS_KEY_DELETE_LOCAL_TORRENT, TRG_PREFS_GLOBAL));
+ trg_prefs_get_bool(prefs,
+ TRG_PREFS_KEY_DELETE_LOCAL_TORRENT,
+ TRG_PREFS_GLOBAL));
priv->priority_combo = gtr_priority_combo_new();
gtk_combo_box_set_active(GTK_COMBO_BOX(priv->priority_combo), 1);
@@ -856,68 +869,68 @@ static GObject *trg_torrent_add_dialog_constructor(GType type,
l = gtk_label_new_with_mnemonic(_("_Torrent file:"));
gtk_misc_set_alignment(GTK_MISC(l), 0.0f, 0.5f);
gtk_table_attach(GTK_TABLE(t), l, col, col + 1, row, row + 1, GTK_FILL,
- 0, 0, 0);
+ 0, 0, 0);
++col;
priv->source_chooser = gtk_button_new();
gtk_button_set_alignment(GTK_BUTTON(priv->source_chooser), 0.0f, 0.5f);
trg_torrent_add_dialog_set_filenames(TRG_TORRENT_ADD_DIALOG(obj),
- priv->filenames);
+ priv->filenames);
gtk_table_attach(GTK_TABLE(t), priv->source_chooser, col, col + 1, row,
- row + 1, ~0, 0, 0, 0);
+ row + 1, ~0, 0, 0, 0);
gtk_label_set_mnemonic_widget(GTK_LABEL(l), priv->source_chooser);
g_signal_connect(priv->source_chooser, "clicked",
- G_CALLBACK(trg_torrent_add_dialog_source_click_cb),
- obj);
+ G_CALLBACK(trg_torrent_add_dialog_source_click_cb),
+ obj);
++row;
col = 0;
l = gtk_label_new_with_mnemonic(_("_Destination folder:"));
gtk_misc_set_alignment(GTK_MISC(l), 0.0f, 0.5f);
gtk_table_attach(GTK_TABLE(t), l, col, col + 1, row, row + 1, GTK_FILL,
- 0, 0, 0);
+ 0, 0, 0);
++col;
priv->dest_combo = trg_destination_combo_new(priv->client, NULL);
gtk_combo_box_set_active(GTK_COMBO_BOX(priv->dest_combo), 0);
gtk_table_attach(GTK_TABLE(t), priv->dest_combo, col, col + 1, row,
- row + 1, ~0, 0, 0, 0);
+ row + 1, ~0, 0, 0, 0);
gtk_label_set_mnemonic_widget(GTK_LABEL(l), priv->dest_combo);
++row;
col = 0;
gtk_widget_set_size_request(priv->file_list, 466u, 300u);
gtk_table_attach_defaults(GTK_TABLE(t), priv->file_list, col, col + 2,
- row, row + 1);
+ row, row + 1);
++row;
col = 0;
l = gtk_label_new_with_mnemonic(_("Torrent _priority:"));
gtk_misc_set_alignment(GTK_MISC(l), 0.0f, 0.5f);
gtk_table_attach(GTK_TABLE(t), l, col, col + 1, row, row + 1, ~0, 0, 0,
- 0);
+ 0);
++col;
gtk_table_attach(GTK_TABLE(t), priv->priority_combo, col, col + 1, row,
- row + 1, ~0, 0, 0, 0);
+ row + 1, ~0, 0, 0, 0);
gtk_label_set_mnemonic_widget(GTK_LABEL(l), priv->priority_combo);
++row;
col = 0;
gtk_table_attach(GTK_TABLE(t), priv->paused_check, col, col + 2, row,
- row + 1, GTK_FILL, 0, 0, 0);
+ row + 1, GTK_FILL, 0, 0, 0);
++row;
col = 0;
gtk_table_attach(GTK_TABLE(t), priv->delete_check, col, col + 2, row,
- row + 1, GTK_FILL, 0, 0, 0);
+ row + 1, GTK_FILL, 0, 0, 0);
gtr_dialog_set_content(GTK_DIALOG(obj), t);
g_signal_connect(G_OBJECT(obj),
- "response",
- G_CALLBACK(trg_torrent_add_response_cb),
- priv->parent);
+ "response",
+ G_CALLBACK(trg_torrent_add_response_cb),
+ priv->parent);
return obj;
}
@@ -934,48 +947,48 @@ trg_torrent_add_dialog_class_init(TrgTorrentAddDialogClass * klass)
object_class->constructor = trg_torrent_add_dialog_constructor;
g_object_class_install_property(object_class,
- PROP_FILENAME,
- g_param_spec_pointer("filenames",
- "filenames",
- "filenames",
- G_PARAM_READWRITE
- |
- G_PARAM_CONSTRUCT_ONLY
- |
- G_PARAM_STATIC_NAME
- |
- G_PARAM_STATIC_NICK
- |
- G_PARAM_STATIC_BLURB));
+ PROP_FILENAME,
+ g_param_spec_pointer("filenames",
+ "filenames",
+ "filenames",
+ G_PARAM_READWRITE
+ |
+ G_PARAM_CONSTRUCT_ONLY
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
g_object_class_install_property(object_class,
- PROP_CLIENT,
- g_param_spec_pointer("client",
- "client",
- "client",
- G_PARAM_READWRITE
- |
- G_PARAM_CONSTRUCT_ONLY
- |
- G_PARAM_STATIC_NAME
- |
- G_PARAM_STATIC_NICK
- |
- G_PARAM_STATIC_BLURB));
+ PROP_CLIENT,
+ g_param_spec_pointer("client",
+ "client",
+ "client",
+ G_PARAM_READWRITE
+ |
+ G_PARAM_CONSTRUCT_ONLY
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
g_object_class_install_property(object_class,
- PROP_PARENT,
- g_param_spec_object("parent", "parent",
- "parent",
- TRG_TYPE_MAIN_WINDOW,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY
- |
- G_PARAM_STATIC_NAME
- |
- G_PARAM_STATIC_NICK
- |
- G_PARAM_STATIC_BLURB));
+ PROP_PARENT,
+ g_param_spec_object("parent", "parent",
+ "parent",
+ TRG_TYPE_MAIN_WINDOW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
}
static void trg_torrent_add_dialog_init(TrgTorrentAddDialog * self)
@@ -983,12 +996,12 @@ static void trg_torrent_add_dialog_init(TrgTorrentAddDialog * self)
}
TrgTorrentAddDialog *trg_torrent_add_dialog_new(TrgMainWindow * parent,
- TrgClient * client,
- GSList * filenames)
+ TrgClient * client,
+ GSList * filenames)
{
return g_object_new(TRG_TYPE_TORRENT_ADD_DIALOG,
- "filenames", filenames,
- "parent", parent, "client", client, NULL);
+ "filenames", filenames,
+ "parent", parent, "client", client, NULL);
}
void trg_torrent_add_dialog(TrgMainWindow * win, TrgClient * client)
@@ -1001,36 +1014,38 @@ void trg_torrent_add_dialog(TrgMainWindow * win, TrgClient * client)
c = gtk_check_button_new_with_mnemonic(_("Show _options dialog"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(c),
- trg_prefs_get_bool(prefs, TRG_PREFS_KEY_ADD_OPTIONS_DIALOG, TRG_PREFS_GLOBAL));
+ trg_prefs_get_bool(prefs,
+ TRG_PREFS_KEY_ADD_OPTIONS_DIALOG,
+ TRG_PREFS_GLOBAL));
gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(w), c);
if (gtk_dialog_run(GTK_DIALOG(w)) == GTK_RESPONSE_ACCEPT) {
- GtkFileChooser *chooser = GTK_FILE_CHOOSER(w);
- GtkToggleButton *tb =
- GTK_TOGGLE_BUTTON(gtk_file_chooser_get_extra_widget(chooser));
- gboolean showOptions = gtk_toggle_button_get_active(tb);
- GSList *l = gtk_file_chooser_get_filenames(chooser);
-
- trg_torrent_add_dialog_generic_save_dir(GTK_FILE_CHOOSER(w),
- prefs);
-
- if (showOptions) {
- TrgTorrentAddDialog *dialog =
- trg_torrent_add_dialog_new(win, client, l);
-
- gtk_widget_show_all(GTK_WIDGET(dialog));
- } else {
- struct add_torrent_threadfunc_args *args =
- g_new0(struct add_torrent_threadfunc_args, 1);
-
- args->list = l;
- args->cb_data = win;
- args->client = client;
- args->extraArgs = FALSE;
- args->flags = trg_prefs_get_add_flags(prefs);
-
- launch_add_thread(args);
- }
+ GtkFileChooser *chooser = GTK_FILE_CHOOSER(w);
+ GtkToggleButton *tb =
+ GTK_TOGGLE_BUTTON(gtk_file_chooser_get_extra_widget(chooser));
+ gboolean showOptions = gtk_toggle_button_get_active(tb);
+ GSList *l = gtk_file_chooser_get_filenames(chooser);
+
+ trg_torrent_add_dialog_generic_save_dir(GTK_FILE_CHOOSER(w),
+ prefs);
+
+ if (showOptions) {
+ TrgTorrentAddDialog *dialog =
+ trg_torrent_add_dialog_new(win, client, l);
+
+ gtk_widget_show_all(GTK_WIDGET(dialog));
+ } else {
+ struct add_torrent_threadfunc_args *args =
+ g_new0(struct add_torrent_threadfunc_args, 1);
+
+ args->list = l;
+ args->cb_data = win;
+ args->client = client;
+ args->extraArgs = FALSE;
+ args->flags = trg_prefs_get_add_flags(prefs);
+
+ launch_add_thread(args);
+ }
}
gtk_widget_destroy(GTK_WIDGET(w));
diff --git a/src/trg-torrent-add-dialog.h b/src/trg-torrent-add-dialog.h
index 0d95103..be355f6 100644
--- a/src/trg-torrent-add-dialog.h
+++ b/src/trg-torrent-add-dialog.h
@@ -64,10 +64,10 @@ struct add_torrent_threadfunc_args {
GType trg_torrent_add_dialog_get_type(void);
TrgTorrentAddDialog *trg_torrent_add_dialog_new(TrgMainWindow * win,
- TrgClient * client,
- GSList * filenames);
+ TrgClient * client,
+ GSList * filenames);
void trg_torrent_add_dialog(TrgMainWindow * win, TrgClient * client);
void launch_add_thread(struct add_torrent_threadfunc_args *args);
G_END_DECLS
-#endif /* TRG_TORRENT_ADD_DIALOG_H_ */
+#endif /* TRG_TORRENT_ADD_DIALOG_H_ */
diff --git a/src/trg-torrent-add-url-dialog.c b/src/trg-torrent-add-url-dialog.c
index 44a74db..67f87c0 100644
--- a/src/trg-torrent-add-url-dialog.c
+++ b/src/trg-torrent-add-url-dialog.c
@@ -28,7 +28,7 @@
#include "requests.h"
G_DEFINE_TYPE(TrgTorrentAddUrlDialog, trg_torrent_add_url_dialog,
- GTK_TYPE_DIALOG)
+ GTK_TYPE_DIALOG)
#define TRG_TORRENT_ADD_URL_DIALOG_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_TORRENT_ADD_URL_DIALOG, TrgTorrentAddUrlDialogPrivate))
typedef struct _TrgTorrentAddUrlDialogPrivate
@@ -46,20 +46,24 @@ trg_torrent_add_url_dialog_class_init(TrgTorrentAddUrlDialogClass * klass)
g_type_class_add_private(klass, sizeof(TrgTorrentAddUrlDialogPrivate));
}
-static gboolean has_dht_support(TrgTorrentAddUrlDialog *dlg)
+static gboolean has_dht_support(TrgTorrentAddUrlDialog * dlg)
{
TrgTorrentAddUrlDialogPrivate *priv =
- TRG_TORRENT_ADD_URL_DIALOG_GET_PRIVATE(dlg);
+ TRG_TORRENT_ADD_URL_DIALOG_GET_PRIVATE(dlg);
JsonObject *session = trg_client_get_session(priv->client);
return session_get_dht_enabled(session);
}
-static void show_dht_not_enabled_warning(TrgTorrentAddUrlDialog *dlg)
+static void show_dht_not_enabled_warning(TrgTorrentAddUrlDialog * dlg)
{
- gchar *msg = _("You are trying to add a magnet torrent, but DHT is disabled. Distributed Hash Table (DHT) should be enabled in remote settings.");
+ gchar *msg =
+ _
+ ("You are trying to add a magnet torrent, but DHT is disabled. Distributed Hash Table (DHT) should be enabled in remote settings.");
GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(dlg),
- GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,
- "%s", msg);
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK,
+ "%s", msg);
gtk_window_set_title(GTK_WINDOW(dialog), _("Error"));
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
@@ -67,24 +71,26 @@ static void show_dht_not_enabled_warning(TrgTorrentAddUrlDialog *dlg)
static void
trg_torrent_add_url_response_cb(TrgTorrentAddUrlDialog * dlg, gint res_id,
- gpointer data)
+ gpointer data)
{
TrgTorrentAddUrlDialogPrivate *priv =
- TRG_TORRENT_ADD_URL_DIALOG_GET_PRIVATE(dlg);
+ TRG_TORRENT_ADD_URL_DIALOG_GET_PRIVATE(dlg);
if (res_id == GTK_RESPONSE_ACCEPT) {
- JsonNode *request;
- const gchar *entryText = gtk_entry_get_text(GTK_ENTRY(priv->urlEntry));
-
- if (g_str_has_prefix(entryText, "magnet:") && !has_dht_support(dlg))
- show_dht_not_enabled_warning(dlg);
-
- request =
- torrent_add_url(entryText,
- gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON(priv->startCheck)));
- dispatch_async(priv->client, request,
- on_generic_interactive_action, data);
+ JsonNode *request;
+ const gchar *entryText =
+ gtk_entry_get_text(GTK_ENTRY(priv->urlEntry));
+
+ if (g_str_has_prefix(entryText, "magnet:")
+ && !has_dht_support(dlg))
+ show_dht_not_enabled_warning(dlg);
+
+ request =
+ torrent_add_url(entryText,
+ gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON(priv->startCheck)));
+ dispatch_async(priv->client, request,
+ on_generic_interactive_action, data);
}
gtk_widget_destroy(GTK_WIDGET(dlg));
@@ -93,19 +99,19 @@ trg_torrent_add_url_response_cb(TrgTorrentAddUrlDialog * dlg, gint res_id,
static void url_entry_changed(GtkWidget * w, gpointer data)
{
TrgTorrentAddUrlDialogPrivate *priv =
- TRG_TORRENT_ADD_URL_DIALOG_GET_PRIVATE(data);
+ TRG_TORRENT_ADD_URL_DIALOG_GET_PRIVATE(data);
gtk_widget_set_sensitive(priv->addButton,
- gtk_entry_get_text_length(GTK_ENTRY(w)) > 0);
+ gtk_entry_get_text_length(GTK_ENTRY(w)) > 0);
}
static void trg_torrent_add_url_dialog_init(TrgTorrentAddUrlDialog * self)
{
TrgTorrentAddUrlDialogPrivate *priv =
- TRG_TORRENT_ADD_URL_DIALOG_GET_PRIVATE(self);
+ TRG_TORRENT_ADD_URL_DIALOG_GET_PRIVATE(self);
GtkWidget *w, *t, *contentvbox;
gint row = 0;
- contentvbox = gtk_dialog_get_content_area (GTK_DIALOG(self));
+ contentvbox = gtk_dialog_get_content_area(GTK_DIALOG(self));
t = hig_workarea_create();
@@ -114,17 +120,17 @@ static void trg_torrent_add_url_dialog_init(TrgTorrentAddUrlDialog * self)
hig_workarea_add_row(t, &row, _("URL:"), w, NULL);
priv->startCheck =
- hig_workarea_add_wide_checkbutton(t, &row, _("Start Paused"),
- FALSE);
+ hig_workarea_add_wide_checkbutton(t, &row, _("Start Paused"),
+ FALSE);
gtk_window_set_title(GTK_WINDOW(self), _("Add torrent from URL"));
gtk_window_set_destroy_with_parent(GTK_WINDOW(self), TRUE);
gtk_dialog_add_button(GTK_DIALOG(self), GTK_STOCK_CLOSE,
- GTK_RESPONSE_CANCEL);
+ GTK_RESPONSE_CANCEL);
priv->addButton =
- gtk_dialog_add_button(GTK_DIALOG(self), GTK_STOCK_ADD,
- GTK_RESPONSE_ACCEPT);
+ gtk_dialog_add_button(GTK_DIALOG(self), GTK_STOCK_ADD,
+ GTK_RESPONSE_ACCEPT);
gtk_widget_set_sensitive(priv->addButton, FALSE);
gtk_container_set_border_width(GTK_CONTAINER(self), GUI_PAD);
@@ -132,8 +138,8 @@ static void trg_torrent_add_url_dialog_init(TrgTorrentAddUrlDialog * self)
gtk_dialog_set_default_response(GTK_DIALOG(self), GTK_RESPONSE_ACCEPT);
gtk_dialog_set_alternative_button_order(GTK_DIALOG(self),
- GTK_RESPONSE_ACCEPT,
- GTK_RESPONSE_CANCEL, -1);
+ GTK_RESPONSE_ACCEPT,
+ GTK_RESPONSE_CANCEL, -1);
gtk_container_set_border_width(GTK_CONTAINER(t), GUI_PAD);
@@ -141,19 +147,19 @@ static void trg_torrent_add_url_dialog_init(TrgTorrentAddUrlDialog * self)
}
TrgTorrentAddUrlDialog *trg_torrent_add_url_dialog_new(TrgMainWindow * win,
- TrgClient * client)
+ TrgClient * client)
{
GObject *obj = g_object_new(TRG_TYPE_TORRENT_ADD_URL_DIALOG, NULL);
TrgTorrentAddUrlDialogPrivate *priv =
- TRG_TORRENT_ADD_URL_DIALOG_GET_PRIVATE(obj);
+ TRG_TORRENT_ADD_URL_DIALOG_GET_PRIVATE(obj);
priv->client = client;
priv->win = win;
gtk_window_set_transient_for(GTK_WINDOW(obj), GTK_WINDOW(win));
g_signal_connect(G_OBJECT(obj),
- "response",
- G_CALLBACK(trg_torrent_add_url_response_cb), win);
+ "response",
+ G_CALLBACK(trg_torrent_add_url_response_cb), win);
return TRG_TORRENT_ADD_URL_DIALOG(obj);
}
diff --git a/src/trg-torrent-add-url-dialog.h b/src/trg-torrent-add-url-dialog.h
index a9a801d..4742837 100644
--- a/src/trg-torrent-add-url-dialog.h
+++ b/src/trg-torrent-add-url-dialog.h
@@ -49,8 +49,7 @@ typedef struct {
GType trg_torrent_add_url_dialog_get_type(void);
TrgTorrentAddUrlDialog *trg_torrent_add_url_dialog_new(TrgMainWindow * win,
- TrgClient *
- client);
+ TrgClient * client);
G_END_DECLS
-#endif /* TRG_TORRENT_ADD_URL_DIALOG_H_ */
+#endif /* TRG_TORRENT_ADD_URL_DIALOG_H_ */
diff --git a/src/trg-torrent-graph.c b/src/trg-torrent-graph.c
index 99c5dad..26e5fd4 100644
--- a/src/trg-torrent-graph.c
+++ b/src/trg-torrent-graph.c
@@ -90,23 +90,23 @@ static int trg_torrent_graph_update(gpointer user_data);
static void
trg_torrent_graph_get_property(GObject * object, guint property_id,
- GValue * value, GParamSpec * pspec)
+ GValue * value, GParamSpec * pspec)
{
switch (property_id) {
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
static void
trg_torrent_graph_set_property(GObject * object, guint property_id,
- const GValue * value, GParamSpec * pspec)
+ const GValue * value, GParamSpec * pspec)
{
switch (property_id) {
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
@@ -127,18 +127,18 @@ void trg_torrent_graph_draw_background(TrgTorrentGraph * g)
priv = TRG_TORRENT_GRAPH_GET_PRIVATE(g);
num_bars = trg_torrent_graph_get_num_bars(g);
- priv->graph_dely = (priv->draw_height - 15) / num_bars; /* round to int to avoid AA blur */
+ priv->graph_dely = (priv->draw_height - 15) / num_bars; /* round to int to avoid AA blur */
priv->real_draw_height = priv->graph_dely * num_bars;
priv->graph_delx =
- (priv->draw_width - 2.0 - priv->rmargin -
- priv->indent) / (GRAPH_NUM_POINTS - 3);
+ (priv->draw_width - 2.0 - priv->rmargin -
+ priv->indent) / (GRAPH_NUM_POINTS - 3);
priv->graph_buffer_offset =
- (int) (1.5 * priv->graph_delx) + GRAPH_FRAME_WIDTH;
+ (int) (1.5 * priv->graph_delx) + GRAPH_FRAME_WIDTH;
gtk_widget_get_allocation(priv->disp, &allocation);
priv->background =
- gdk_pixmap_new(GDK_DRAWABLE(gtk_widget_get_window(priv->disp)),
- allocation.width, allocation.height, -1);
+ gdk_pixmap_new(GDK_DRAWABLE(gtk_widget_get_window(priv->disp)),
+ allocation.width, allocation.height, -1);
cr = gdk_cairo_create(priv->background);
gdk_cairo_set_source_color(cr, &priv->style->bg[GTK_STATE_NORMAL]);
@@ -146,8 +146,8 @@ void trg_torrent_graph_draw_background(TrgTorrentGraph * g)
cairo_translate(cr, GRAPH_FRAME_WIDTH, GRAPH_FRAME_WIDTH);
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
cairo_rectangle(cr, priv->rmargin + priv->indent, 0,
- priv->draw_width - priv->rmargin - priv->indent,
- priv->real_draw_height);
+ priv->draw_width - priv->rmargin - priv->indent,
+ priv->real_draw_height);
cairo_fill(cr);
@@ -156,22 +156,22 @@ void trg_torrent_graph_draw_background(TrgTorrentGraph * g)
cairo_set_font_size(cr, priv->fontsize);
for (i = 0; i <= num_bars; ++i) {
- double y;
- gchar caption[32];
-
- if (i == 0)
- y = 0.5 + priv->fontsize / 2.0;
- else if (i == num_bars)
- y = i * priv->graph_dely + 0.5;
- else
- y = i * priv->graph_dely + priv->fontsize / 2.0;
-
- gdk_cairo_set_source_color(cr, &priv->style->fg[GTK_STATE_NORMAL]);
- rate = priv->max - (i * priv->max / num_bars);
- trg_strlspeed(caption, (gint64) (rate / 1024));
- cairo_text_extents(cr, caption, &extents);
- cairo_move_to(cr, priv->indent - extents.width + 20, y);
- cairo_show_text(cr, caption);
+ double y;
+ gchar caption[32];
+
+ if (i == 0)
+ y = 0.5 + priv->fontsize / 2.0;
+ else if (i == num_bars)
+ y = i * priv->graph_dely + 0.5;
+ else
+ y = i * priv->graph_dely + priv->fontsize / 2.0;
+
+ gdk_cairo_set_source_color(cr, &priv->style->fg[GTK_STATE_NORMAL]);
+ rate = priv->max - (i * priv->max / num_bars);
+ trg_strlspeed(caption, (gint64) (rate / 1024));
+ cairo_text_extents(cr, caption, &extents);
+ cairo_move_to(cr, priv->indent - extents.width + 20, y);
+ cairo_show_text(cr, caption);
}
cairo_stroke(cr);
@@ -181,29 +181,29 @@ void trg_torrent_graph_draw_background(TrgTorrentGraph * g)
total_seconds = priv->speed * (GRAPH_NUM_POINTS - 2) / 1000;
for (i = 0; i < 7; i++) {
- unsigned seconds;
- const char *format;
- double x =
- (i) * (priv->draw_width - priv->rmargin - priv->indent) / 6;
- cairo_set_source_rgba(cr, 0, 0, 0, 0.75);
- cairo_move_to(cr, (ceil(x) + 0.5) + priv->rmargin + priv->indent,
- 0.5);
- cairo_line_to(cr, (ceil(x) + 0.5) + priv->rmargin + priv->indent,
- priv->real_draw_height + 4.5);
- cairo_stroke(cr);
- seconds = total_seconds - i * total_seconds / 6;
- if (i == 0)
- format = "%u seconds";
- else
- format = "%u";
- caption = g_strdup_printf(format, seconds);
- cairo_text_extents(cr, caption, &extents);
- cairo_move_to(cr,
- ((ceil(x) + 0.5) + priv->rmargin + priv->indent) -
- (extents.width / 2), priv->draw_height);
- gdk_cairo_set_source_color(cr, &priv->style->fg[GTK_STATE_NORMAL]);
- cairo_show_text(cr, caption);
- g_free(caption);
+ unsigned seconds;
+ const char *format;
+ double x =
+ (i) * (priv->draw_width - priv->rmargin - priv->indent) / 6;
+ cairo_set_source_rgba(cr, 0, 0, 0, 0.75);
+ cairo_move_to(cr, (ceil(x) + 0.5) + priv->rmargin + priv->indent,
+ 0.5);
+ cairo_line_to(cr, (ceil(x) + 0.5) + priv->rmargin + priv->indent,
+ priv->real_draw_height + 4.5);
+ cairo_stroke(cr);
+ seconds = total_seconds - i * total_seconds / 6;
+ if (i == 0)
+ format = "%u seconds";
+ else
+ format = "%u";
+ caption = g_strdup_printf(format, seconds);
+ cairo_text_extents(cr, caption, &extents);
+ cairo_move_to(cr,
+ ((ceil(x) + 0.5) + priv->rmargin + priv->indent) -
+ (extents.width / 2), priv->draw_height);
+ gdk_cairo_set_source_color(cr, &priv->style->fg[GTK_STATE_NORMAL]);
+ cairo_show_text(cr, caption);
+ g_free(caption);
}
cairo_stroke(cr);
@@ -218,7 +218,7 @@ void trg_torrent_graph_set_nothing(TrgTorrentGraph * g)
}
void trg_torrent_graph_set_speed(TrgTorrentGraph * g,
- trg_torrent_model_update_stats * stats)
+ trg_torrent_model_update_stats * stats)
{
TrgTorrentGraphPrivate *priv = TRG_TORRENT_GRAPH_GET_PRIVATE(g);
@@ -228,7 +228,7 @@ void trg_torrent_graph_set_speed(TrgTorrentGraph * g,
static gboolean
trg_torrent_graph_configure(GtkWidget * widget,
- GdkEventConfigure * event, gpointer data_ptr)
+ GdkEventConfigure * event, gpointer data_ptr)
{
GtkAllocation allocation;
TrgTorrentGraph *g = TRG_TORRENT_GRAPH(data_ptr);
@@ -241,7 +241,7 @@ trg_torrent_graph_configure(GtkWidget * widget,
trg_torrent_graph_clear_background(g);
if (priv->gc == NULL)
- priv->gc = gdk_gc_new(GDK_DRAWABLE(gtk_widget_get_window(widget)));
+ priv->gc = gdk_gc_new(GDK_DRAWABLE(gtk_widget_get_window(widget)));
trg_torrent_graph_draw(g);
@@ -250,7 +250,7 @@ trg_torrent_graph_configure(GtkWidget * widget,
static gboolean
trg_torrent_graph_expose(GtkWidget * widget,
- GdkEventExpose * event, gpointer data_ptr)
+ GdkEventExpose * event, gpointer data_ptr)
{
TrgTorrentGraph *g = TRG_TORRENT_GRAPH(data_ptr);
TrgTorrentGraphPrivate *priv = TRG_TORRENT_GRAPH_GET_PRIVATE(data_ptr);
@@ -264,22 +264,22 @@ trg_torrent_graph_expose(GtkWidget * widget,
gdouble sample_width, x_offset;
if (priv->background == NULL)
- trg_torrent_graph_draw_background(g);
+ trg_torrent_graph_draw_background(g);
window = gtk_widget_get_window(priv->disp);
gtk_widget_get_allocation(priv->disp, &allocation);
gdk_draw_drawable(window,
- priv->gc,
- priv->background,
- 0, 0, 0, 0, allocation.width, allocation.height);
+ priv->gc,
+ priv->background,
+ 0, 0, 0, 0, allocation.width, allocation.height);
sample_width =
- (float) (priv->draw_width - priv->rmargin -
- priv->indent) / (float) GRAPH_NUM_POINTS;
+ (float) (priv->draw_width - priv->rmargin -
+ priv->indent) / (float) GRAPH_NUM_POINTS;
x_offset = priv->draw_width - priv->rmargin + (sample_width * 2);
x_offset +=
- priv->rmargin -
- ((sample_width / priv->frames_per_unit) * priv->render_counter);
+ priv->rmargin -
+ ((sample_width / priv->frames_per_unit) * priv->render_counter);
cr = gdk_cairo_create(window);
@@ -287,39 +287,39 @@ trg_torrent_graph_expose(GtkWidget * widget,
cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND);
cairo_rectangle(cr,
- priv->rmargin + priv->indent + GRAPH_FRAME_WIDTH + 1,
- GRAPH_FRAME_WIDTH - 1,
- priv->draw_width - priv->rmargin - priv->indent - 1,
- priv->real_draw_height + GRAPH_FRAME_WIDTH - 1);
+ priv->rmargin + priv->indent + GRAPH_FRAME_WIDTH + 1,
+ GRAPH_FRAME_WIDTH - 1,
+ priv->draw_width - priv->rmargin - priv->indent - 1,
+ priv->real_draw_height + GRAPH_FRAME_WIDTH - 1);
cairo_clip(cr);
for (j = 0; j < GRAPH_NUM_LINES; ++j) {
- GList *li = priv->points;
- fp = (float *) li->data;
- cairo_move_to(cr, x_offset,
- (1.0f - fp[j]) * priv->real_draw_height);
- gdk_cairo_set_source_color(cr, &(priv->colors[j]));
-
- i = 0;
- for (li = g_list_next(li); li != NULL; li = g_list_next(li)) {
- GList *lli = g_list_previous(li);
- float *lfp = (float *) lli->data;
- fp = (float *) li->data;
-
- i++;
-
- if (fp[j] == -1.0f)
- continue;
-
- cairo_curve_to(cr,
- x_offset - ((i - 0.5f) * priv->graph_delx),
- (1.0f - lfp[j]) * priv->real_draw_height + 3.5f,
- x_offset - ((i - 0.5f) * priv->graph_delx),
- (1.0f - fp[j]) * priv->real_draw_height + 3.5f,
- x_offset - (i * priv->graph_delx),
- (1.0f - fp[j]) * priv->real_draw_height + 3.5f);
- }
- cairo_stroke(cr);
+ GList *li = priv->points;
+ fp = (float *) li->data;
+ cairo_move_to(cr, x_offset,
+ (1.0f - fp[j]) * priv->real_draw_height);
+ gdk_cairo_set_source_color(cr, &(priv->colors[j]));
+
+ i = 0;
+ for (li = g_list_next(li); li != NULL; li = g_list_next(li)) {
+ GList *lli = g_list_previous(li);
+ float *lfp = (float *) lli->data;
+ fp = (float *) li->data;
+
+ i++;
+
+ if (fp[j] == -1.0f)
+ continue;
+
+ cairo_curve_to(cr,
+ x_offset - ((i - 0.5f) * priv->graph_delx),
+ (1.0f - lfp[j]) * priv->real_draw_height + 3.5f,
+ x_offset - ((i - 0.5f) * priv->graph_delx),
+ (1.0f - fp[j]) * priv->real_draw_height + 3.5f,
+ x_offset - (i * priv->graph_delx),
+ (1.0f - fp[j]) * priv->real_draw_height + 3.5f);
+ }
+ cairo_stroke(cr);
}
cairo_destroy(cr);
@@ -342,7 +342,7 @@ static void trg_torrent_graph_dispose(GObject * object)
trg_torrent_graph_stop(g);
if (priv->timer_index)
- g_source_remove(priv->timer_index);
+ g_source_remove(priv->timer_index);
trg_torrent_graph_clear_background(g);
@@ -354,11 +354,11 @@ void trg_torrent_graph_start(TrgTorrentGraph * g)
TrgTorrentGraphPrivate *priv = TRG_TORRENT_GRAPH_GET_PRIVATE(g);
if (!priv->timer_index) {
- trg_torrent_graph_update(g);
+ trg_torrent_graph_update(g);
- priv->timer_index =
- g_timeout_add(priv->speed / priv->frames_per_unit,
- trg_torrent_graph_update, g);
+ priv->timer_index =
+ g_timeout_add(priv->speed / priv->frames_per_unit,
+ trg_torrent_graph_update, g);
}
priv->draw = TRUE;
@@ -371,8 +371,8 @@ static unsigned get_max_value_element(TrgTorrentGraph * g)
int i;
for (i = 0; i < GRAPH_NUM_POINTS; i++)
- if (priv->values[i] > r)
- r = priv->values[i];
+ if (priv->values[i] > r)
+ r = priv->values[i];
return r;
}
@@ -382,7 +382,7 @@ static void trg_torrent_graph_update_net(TrgTorrentGraph * g)
TrgTorrentGraphPrivate *priv = TRG_TORRENT_GRAPH_GET_PRIVATE(g);
unsigned max, new_max, bak_max, pow2, base10, coef10, factor10,
- num_bars;
+ num_bars;
float scale;
char speed[32];
@@ -402,17 +402,17 @@ static void trg_torrent_graph_update_net(TrgTorrentGraph * g)
trg_strlspeed(speed, (gint64) (priv->out / KILOBYTE_FACTOR));
labelMarkup =
- g_markup_printf_escaped("<span font_size=\"small\" color=\""
- GRAPH_OUT_COLOR "\">%s: %s</span>",
- _("Total Uploading"), speed);
+ g_markup_printf_escaped("<span font_size=\"small\" color=\""
+ GRAPH_OUT_COLOR "\">%s: %s</span>",
+ _("Total Uploading"), speed);
gtk_label_set_markup(GTK_LABEL(priv->label_out), labelMarkup);
g_free(labelMarkup);
trg_strlspeed(speed, (gint64) (priv->in / 1024));
labelMarkup =
- g_markup_printf_escaped("<span font_size=\"small\" color=\""
- GRAPH_IN_COLOR "\">%s: %s</span>",
- _("Total Downloading"), speed);
+ g_markup_printf_escaped("<span font_size=\"small\" color=\""
+ GRAPH_IN_COLOR "\">%s: %s</span>",
+ _("Total Downloading"), speed);
gtk_label_set_markup(GTK_LABEL(priv->label_in), labelMarkup);
g_free(labelMarkup);
@@ -421,9 +421,9 @@ static void trg_torrent_graph_update_net(TrgTorrentGraph * g)
priv->cur = (priv->cur + 1) % GRAPH_NUM_POINTS;
if (max >= priv->max)
- new_max = max;
+ new_max = max;
else
- new_max = get_max_value_element(g);
+ new_max = get_max_value_element(g);
bak_max = new_max;
new_max = 1.1 * new_max;
@@ -437,25 +437,25 @@ static void trg_torrent_graph_update_net(TrgTorrentGraph * g)
num_bars = trg_torrent_graph_get_num_bars(g);
if (coef10 % num_bars != 0)
- coef10 = coef10 + (num_bars - coef10 % num_bars);
+ coef10 = coef10 + (num_bars - coef10 % num_bars);
new_max = coef10 * (1UL << (base10 * 10));
if (bak_max > new_max) {
- new_max = bak_max;
+ new_max = bak_max;
}
if ((0.8 * priv->max) < new_max && new_max <= priv->max)
- return;
+ return;
scale = 1.0f * priv->max / new_max;
for (li = priv->points; li != NULL; li = g_list_next(li)) {
- float *fp = (float *) li->data;
- if (fp[0] >= 0.0f) {
- fp[0] *= scale;
- fp[1] *= scale;
- }
+ float *fp = (float *) li->data;
+ if (fp[0] >= 0.0f) {
+ fp[0] *= scale;
+ fp[1] *= scale;
+ }
}
priv->max = new_max;
@@ -464,10 +464,10 @@ static void trg_torrent_graph_update_net(TrgTorrentGraph * g)
}
static GObject *trg_torrent_graph_constructor(GType type,
- guint
- n_construct_properties,
- GObjectConstructParam *
- construct_params)
+ guint
+ n_construct_properties,
+ GObjectConstructParam *
+ construct_params)
{
GObject *object;
TrgTorrentGraphPrivate *priv;
@@ -475,10 +475,10 @@ static GObject *trg_torrent_graph_constructor(GType type,
int i;
object =
- G_OBJECT_CLASS
- (trg_torrent_graph_parent_class)->constructor(type,
- n_construct_properties,
- construct_params);
+ G_OBJECT_CLASS
+ (trg_torrent_graph_parent_class)->constructor(type,
+ n_construct_properties,
+ construct_params);
priv = TRG_TORRENT_GRAPH_GET_PRIVATE(object);
priv->draw_width = 0;
@@ -526,9 +526,9 @@ static GObject *trg_torrent_graph_constructor(GType type,
priv->disp = gtk_drawing_area_new();
g_signal_connect(G_OBJECT(priv->disp), "expose_event",
- G_CALLBACK(trg_torrent_graph_expose), object);
+ G_CALLBACK(trg_torrent_graph_expose), object);
g_signal_connect(G_OBJECT(priv->disp), "configure_event",
- G_CALLBACK(trg_torrent_graph_configure), object);
+ G_CALLBACK(trg_torrent_graph_configure), object);
gtk_widget_set_events(priv->disp, GDK_EXPOSURE_MASK);
@@ -536,10 +536,10 @@ static GObject *trg_torrent_graph_constructor(GType type,
priv->points = NULL;
for (i = 0; i < GRAPH_NUM_DATA_BLOCK_ELEMENTS; i++) {
- priv->data_block[i] = -1.0f;
- if (i % GRAPH_NUM_LINES == 0)
- priv->points =
- g_list_append(priv->points, &priv->data_block[i]);
+ priv->data_block[i] = -1.0f;
+ if (i % GRAPH_NUM_LINES == 0)
+ priv->points =
+ g_list_append(priv->points, &priv->data_block[i]);
}
return object;
@@ -583,8 +583,8 @@ void trg_torrent_graph_clear_background(TrgTorrentGraph * g)
TrgTorrentGraphPrivate *priv = TRG_TORRENT_GRAPH_GET_PRIVATE(g);
if (priv->background) {
- g_object_unref(priv->background);
- priv->background = NULL;
+ g_object_unref(priv->background);
+ priv->background = NULL;
}
}
@@ -593,18 +593,18 @@ static gboolean trg_torrent_graph_update(gpointer user_data)
{
TrgTorrentGraph *g = TRG_TORRENT_GRAPH(user_data);
TrgTorrentGraphPrivate *priv =
- TRG_TORRENT_GRAPH_GET_PRIVATE(user_data);
+ TRG_TORRENT_GRAPH_GET_PRIVATE(user_data);
if (priv->render_counter == priv->frames_per_unit - 1)
- trg_torrent_graph_update_net(g);
+ trg_torrent_graph_update_net(g);
if (priv->draw)
- trg_torrent_graph_draw(g);
+ trg_torrent_graph_draw(g);
priv->render_counter++;
if (priv->render_counter >= priv->frames_per_unit)
- priv->render_counter = 0;
+ priv->render_counter = 0;
return TRUE;
}
@@ -617,18 +617,18 @@ unsigned trg_torrent_graph_get_num_bars(TrgTorrentGraph * g)
switch ((int) (priv->draw_height / (priv->fontsize + 14))) {
case 0:
case 1:
- n = 1;
- break;
+ n = 1;
+ break;
case 2:
case 3:
- n = 2;
- break;
+ n = 2;
+ break;
case 4:
- n = 4;
- break;
+ n = 4;
+ break;
default:
- n = 5;
- break;
+ n = 5;
+ break;
}
return n;
diff --git a/src/trg-torrent-graph.h b/src/trg-torrent-graph.h
index c71f3b6..7a9e7c9 100644
--- a/src/trg-torrent-graph.h
+++ b/src/trg-torrent-graph.h
@@ -45,8 +45,8 @@ void trg_torrent_graph_stop(TrgTorrentGraph * g);
void trg_torrent_graph_change_speed(TrgTorrentGraph * g, guint new_speed);
void trg_torrent_graph_set_speed(TrgTorrentGraph * g,
- trg_torrent_model_update_stats * stats);
+ trg_torrent_model_update_stats * stats);
void trg_torrent_graph_set_nothing(TrgTorrentGraph * g);
G_END_DECLS
-#endif /* _TRG_TORRENT_GRAPH */
+#endif /* _TRG_TORRENT_GRAPH */
diff --git a/src/trg-torrent-model.c b/src/trg-torrent-model.c
index 4c86682..678f39a 100644
--- a/src/trg-torrent-model.c
+++ b/src/trg-torrent-model.c
@@ -73,98 +73,125 @@ struct _TrgTorrentModelPrivate {
trg_torrent_model_update_stats stats;
};
-static void trg_torrent_model_dispose(GObject * object) {
+static void trg_torrent_model_dispose(GObject * object)
+{
TrgTorrentModelPrivate *priv = TRG_TORRENT_MODEL_GET_PRIVATE(object);
g_hash_table_destroy(priv->ht);
G_OBJECT_CLASS(trg_torrent_model_parent_class)->dispose(object);
}
static void
-update_torrent_iter(TrgTorrentModel * model, TrgClient *tc, gint64 rpcv,
- gint64 serial, GtkTreeIter * iter, JsonObject * t,
- trg_torrent_model_update_stats * stats, gboolean *updateFilters);
+update_torrent_iter(TrgTorrentModel * model, TrgClient * tc, gint64 rpcv,
+ gint64 serial, GtkTreeIter * iter, JsonObject * t,
+ trg_torrent_model_update_stats * stats,
+ gboolean * updateFilters);
-static void trg_torrent_model_class_init(TrgTorrentModelClass * klass) {
+static void trg_torrent_model_class_init(TrgTorrentModelClass * klass)
+{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
g_type_class_add_private(klass, sizeof(TrgTorrentModelPrivate));
object_class->dispose = trg_torrent_model_dispose;
signals[TMODEL_TORRENT_COMPLETED] = g_signal_new("torrent-completed",
- G_TYPE_FROM_CLASS(object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET(TrgTorrentModelClass,
- torrent_completed), NULL, NULL,
- g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
+ G_TYPE_FROM_CLASS
+ (object_class),
+ G_SIGNAL_RUN_LAST |
+ G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET
+ (TrgTorrentModelClass,
+ torrent_completed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1,
+ G_TYPE_POINTER);
signals[TMODEL_TORRENT_ADDED] = g_signal_new("torrent-added",
- G_TYPE_FROM_CLASS(object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET(TrgTorrentModelClass,
- torrent_added), NULL, NULL,
- g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
+ G_TYPE_FROM_CLASS
+ (object_class),
+ G_SIGNAL_RUN_LAST |
+ G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET
+ (TrgTorrentModelClass,
+ torrent_added), NULL,
+ NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1,
+ G_TYPE_POINTER);
signals[TMODEL_UPDATE_FILTERS] = g_signal_new("update-filters",
- G_TYPE_FROM_CLASS(object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET(TrgTorrentModelClass,
- torrent_removed), NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ G_TYPE_FROM_CLASS
+ (object_class),
+ G_SIGNAL_RUN_LAST |
+ G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET
+ (TrgTorrentModelClass,
+ torrent_removed), NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
-trg_torrent_model_update_stats *trg_torrent_model_get_stats(TrgTorrentModel * model)
+trg_torrent_model_update_stats *trg_torrent_model_get_stats(TrgTorrentModel
+ * model)
{
TrgTorrentModelPrivate *priv = TRG_TORRENT_MODEL_GET_PRIVATE(model);
return &(priv->stats);
}
static void trg_torrent_model_count_peers(TrgTorrentModel * model,
- GtkTreeIter * iter, JsonObject * t) {
- GList *trackersList = json_array_get_elements(torrent_get_tracker_stats(t));
+ GtkTreeIter * iter,
+ JsonObject * t)
+{
+ GList *trackersList =
+ json_array_get_elements(torrent_get_tracker_stats(t));
gint seeders = 0;
gint leechers = 0;
gint downloads = 0;
GList *li;
for (li = trackersList; li; li = g_list_next(li)) {
- JsonObject *tracker = json_node_get_object((JsonNode *) li->data);
+ JsonObject *tracker = json_node_get_object((JsonNode *) li->data);
- seeders += tracker_stats_get_seeder_count(tracker);
- leechers += tracker_stats_get_leecher_count(tracker);
- downloads += tracker_stats_get_download_count(tracker);
+ seeders += tracker_stats_get_seeder_count(tracker);
+ leechers += tracker_stats_get_leecher_count(tracker);
+ downloads += tracker_stats_get_download_count(tracker);
}
g_list_free(trackersList);
gtk_list_store_set(GTK_LIST_STORE(model), iter, TORRENT_COLUMN_SEEDS,
- seeders, TORRENT_COLUMN_LEECHERS, leechers,
- TORRENT_COLUMN_DOWNLOADS, downloads, -1);
+ seeders, TORRENT_COLUMN_LEECHERS, leechers,
+ TORRENT_COLUMN_DOWNLOADS, downloads, -1);
}
-static void trg_torrent_model_ref_free(gpointer data) {
+static void trg_torrent_model_ref_free(gpointer data)
+{
GtkTreeRowReference *rr = (GtkTreeRowReference *) data;
GtkTreeModel *model = gtk_tree_row_reference_get_model(rr);
GtkTreePath *path = gtk_tree_row_reference_get_path(rr);
if (path) {
- GtkTreeIter iter;
- JsonObject *json;
- if (gtk_tree_model_get_iter(model, &iter, path)) {
- gtk_tree_model_get(model, &iter, TORRENT_COLUMN_JSON, &json, -1);
- json_object_unref(json);
- g_object_set_data(G_OBJECT(model), PROP_REMOVE_IN_PROGRESS,
- GINT_TO_POINTER(TRUE));
- gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
- g_object_set_data(G_OBJECT(model), PROP_REMOVE_IN_PROGRESS,
- GINT_TO_POINTER(FALSE));
- }
-
- gtk_tree_path_free(path);
+ GtkTreeIter iter;
+ JsonObject *json;
+ if (gtk_tree_model_get_iter(model, &iter, path)) {
+ gtk_tree_model_get(model, &iter, TORRENT_COLUMN_JSON, &json,
+ -1);
+ json_object_unref(json);
+ g_object_set_data(G_OBJECT(model), PROP_REMOVE_IN_PROGRESS,
+ GINT_TO_POINTER(TRUE));
+ gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
+ g_object_set_data(G_OBJECT(model), PROP_REMOVE_IN_PROGRESS,
+ GINT_TO_POINTER(FALSE));
+ }
+
+ gtk_tree_path_free(path);
}
gtk_tree_row_reference_free(rr);
}
-static void trg_torrent_model_init(TrgTorrentModel * self) {
+static void trg_torrent_model_init(TrgTorrentModel * self)
+{
TrgTorrentModelPrivate *priv = TRG_TORRENT_MODEL_GET_PRIVATE(self);
GType column_types[TORRENT_COLUMN_COLUMNS];
@@ -207,34 +234,43 @@ static void trg_torrent_model_init(TrgTorrentModel * self) {
column_types[TORRENT_COLUMN_LASTACTIVE] = G_TYPE_INT64;
gtk_list_store_set_column_types(GTK_LIST_STORE(self),
- TORRENT_COLUMN_COLUMNS, column_types);
+ TORRENT_COLUMN_COLUMNS, column_types);
priv->ht = g_hash_table_new_full(g_int64_hash, g_int64_equal,
- (GDestroyNotify) g_free, trg_torrent_model_ref_free);
+ (GDestroyNotify) g_free,
+ trg_torrent_model_ref_free);
g_object_set_data(G_OBJECT(self), PROP_REMOVE_IN_PROGRESS,
- GINT_TO_POINTER(FALSE));
+ GINT_TO_POINTER(FALSE));
priv->urlHostRegex = trg_uri_host_regex_new();
}
-gboolean trg_torrent_model_is_remove_in_progress(TrgTorrentModel * model) {
+gboolean trg_torrent_model_is_remove_in_progress(TrgTorrentModel * model)
+{
return (gboolean) GPOINTER_TO_INT(g_object_get_data
- (G_OBJECT(model), PROP_REMOVE_IN_PROGRESS));
+ (G_OBJECT(model),
+ PROP_REMOVE_IN_PROGRESS));
}
-static gboolean trg_torrent_model_reload_dir_aliases_foreachfunc(
- GtkTreeModel * model, GtkTreePath * path G_GNUC_UNUSED,
- GtkTreeIter * iter, gpointer gdata) {
+static gboolean
+trg_torrent_model_reload_dir_aliases_foreachfunc(GtkTreeModel * model,
+ GtkTreePath *
+ path G_GNUC_UNUSED,
+ GtkTreeIter * iter,
+ gpointer gdata)
+{
gchar *downloadDir, *shortDownloadDir;
- gtk_tree_model_get(model, iter, TORRENT_COLUMN_DOWNLOADDIR, &downloadDir,
- -1);
+ gtk_tree_model_get(model, iter, TORRENT_COLUMN_DOWNLOADDIR,
+ &downloadDir, -1);
- shortDownloadDir = shorten_download_dir((TrgClient*) gdata, downloadDir);
+ shortDownloadDir =
+ shorten_download_dir((TrgClient *) gdata, downloadDir);
gtk_list_store_set(GTK_LIST_STORE(model), iter,
- TORRENT_COLUMN_DOWNLOADDIR_SHORT, shortDownloadDir, -1);
+ TORRENT_COLUMN_DOWNLOADDIR_SHORT, shortDownloadDir,
+ -1);
g_free(downloadDir);
g_free(shortDownloadDir);
@@ -242,95 +278,109 @@ static gboolean trg_torrent_model_reload_dir_aliases_foreachfunc(
return FALSE;
}
-void trg_torrent_model_reload_dir_aliases(TrgClient *tc, GtkTreeModel *model)
+void trg_torrent_model_reload_dir_aliases(TrgClient * tc,
+ GtkTreeModel * model)
{
gtk_tree_model_foreach(model,
- trg_torrent_model_reload_dir_aliases_foreachfunc, tc);
+ trg_torrent_model_reload_dir_aliases_foreachfunc,
+ tc);
}
-static gboolean trg_torrent_model_stats_scan_foreachfunc(GtkTreeModel * model,
- GtkTreePath * path G_GNUC_UNUSED, GtkTreeIter * iter, gpointer gdata) {
+static gboolean trg_torrent_model_stats_scan_foreachfunc(GtkTreeModel *
+ model,
+ GtkTreePath *
+ path
+ G_GNUC_UNUSED,
+ GtkTreeIter *
+ iter,
+ gpointer gdata)
+{
trg_torrent_model_update_stats *stats =
- (trg_torrent_model_update_stats *) gdata;
+ (trg_torrent_model_update_stats *) gdata;
guint flags;
gtk_tree_model_get(model, iter, TORRENT_COLUMN_FLAGS, &flags, -1);
- if (flags & TORRENT_FLAG_SEEDING
- )
- stats->seeding++;
- else if (flags & TORRENT_FLAG_DOWNLOADING
- )
- stats->down++;
- else if (flags & TORRENT_FLAG_PAUSED
- )
- stats->paused++;
+ if (flags & TORRENT_FLAG_SEEDING)
+ stats->seeding++;
+ else if (flags & TORRENT_FLAG_DOWNLOADING)
+ stats->down++;
+ else if (flags & TORRENT_FLAG_PAUSED)
+ stats->paused++;
- if (flags & TORRENT_FLAG_ERROR
- )
- stats->error++;
+ if (flags & TORRENT_FLAG_ERROR)
+ stats->error++;
stats->count++;
return FALSE;
}
-void trg_torrent_model_remove_all(TrgTorrentModel *model) {
+void trg_torrent_model_remove_all(TrgTorrentModel * model)
+{
TrgTorrentModelPrivate *priv = TRG_TORRENT_MODEL_GET_PRIVATE(model);
g_hash_table_remove_all(priv->ht);
gtk_list_store_clear(GTK_LIST_STORE(model));
}
-gchar *shorten_download_dir(TrgClient *tc, const gchar *downloadDir) {
+gchar *shorten_download_dir(TrgClient * tc, const gchar * downloadDir)
+{
TrgPrefs *prefs = trg_client_get_prefs(tc);
- JsonArray *labels = trg_prefs_get_array(prefs, TRG_PREFS_KEY_DESTINATIONS,
- TRG_PREFS_CONNECTION);
+ JsonArray *labels =
+ trg_prefs_get_array(prefs, TRG_PREFS_KEY_DESTINATIONS,
+ TRG_PREFS_CONNECTION);
JsonObject *session = trg_client_get_session(tc);
const gchar *defaultDownloadDir = session_get_download_dir(session);
gchar *shortDownloadDir = NULL;
if (labels) {
- GList *labelsList = json_array_get_elements(labels);
- if (labelsList) {
- GList *li;
- for (li = labelsList; li; li = g_list_next(li)) {
- JsonObject *labelObj = json_node_get_object(
- (JsonNode*) li->data);
- const gchar *labelDir = json_object_get_string_member(labelObj,
- TRG_PREFS_KEY_DESTINATIONS_SUBKEY_DIR);
- if (!g_strcmp0(downloadDir, labelDir)) {
- const gchar *labelLabel = json_object_get_string_member(
- labelObj, TRG_PREFS_SUBKEY_LABEL);
- shortDownloadDir = g_strdup(labelLabel);
- break;
- }
- }
- g_list_free(labelsList);
- }
+ GList *labelsList = json_array_get_elements(labels);
+ if (labelsList) {
+ GList *li;
+ for (li = labelsList; li; li = g_list_next(li)) {
+ JsonObject *labelObj = json_node_get_object((JsonNode *)
+ li->data);
+ const gchar *labelDir =
+ json_object_get_string_member(labelObj,
+ TRG_PREFS_KEY_DESTINATIONS_SUBKEY_DIR);
+ if (!g_strcmp0(downloadDir, labelDir)) {
+ const gchar *labelLabel =
+ json_object_get_string_member(labelObj,
+ TRG_PREFS_SUBKEY_LABEL);
+ shortDownloadDir = g_strdup(labelLabel);
+ break;
+ }
+ }
+ g_list_free(labelsList);
+ }
}
if (shortDownloadDir) {
- return shortDownloadDir;
+ return shortDownloadDir;
} else {
- if (!g_strcmp0(defaultDownloadDir, downloadDir))
- return g_strdup(_("Default"));
+ if (!g_strcmp0(defaultDownloadDir, downloadDir))
+ return g_strdup(_("Default"));
- if (g_str_has_prefix(downloadDir, defaultDownloadDir)) {
- int offset = strlen(defaultDownloadDir);
- if (*(downloadDir + offset) == '/')
- offset++;
+ if (g_str_has_prefix(downloadDir, defaultDownloadDir)) {
+ int offset = strlen(defaultDownloadDir);
+ if (*(downloadDir + offset) == '/')
+ offset++;
- if (offset < strlen(downloadDir))
- return g_strdup(downloadDir + offset);
- }
+ if (offset < strlen(downloadDir))
+ return g_strdup(downloadDir + offset);
+ }
}
return g_strdup(downloadDir);
}
-static inline void update_torrent_iter(TrgTorrentModel * model, TrgClient *tc,
- gint64 rpcv, gint64 serial, GtkTreeIter * iter, JsonObject * t,
- trg_torrent_model_update_stats * stats, gboolean *updateFilters) {
+static inline void update_torrent_iter(TrgTorrentModel * model,
+ TrgClient * tc, gint64 rpcv,
+ gint64 serial, GtkTreeIter * iter,
+ JsonObject * t,
+ trg_torrent_model_update_stats *
+ stats, gboolean * updateFilters)
+{
TrgTorrentModelPrivate *priv = TRG_TORRENT_MODEL_GET_PRIVATE(model);
GtkListStore *ls = GTK_LIST_STORE(model);
guint lastFlags, newFlags;
@@ -351,7 +401,7 @@ static inline void update_torrent_iter(TrgTorrentModel * model, TrgClient *tc,
uploaded = torrent_get_uploaded(t);
downloaded = torrent_get_downloaded(t);
- downloadDir = (gchar*) torrent_get_download_dir(t);
+ downloadDir = (gchar *) torrent_get_download_dir(t);
rm_trailing_slashes(downloadDir);
id = torrent_get_id(t);
@@ -363,168 +413,180 @@ static inline void update_torrent_iter(TrgTorrentModel * model, TrgClient *tc,
trackerStats = torrent_get_tracker_stats(t);
gtk_tree_model_get(GTK_TREE_MODEL(model), iter, TORRENT_COLUMN_FLAGS,
- &lastFlags, TORRENT_COLUMN_JSON, &lastJson,
- TORRENT_COLUMN_DOWNLOADDIR, &lastDownloadDir, -1);
+ &lastFlags, TORRENT_COLUMN_JSON, &lastJson,
+ TORRENT_COLUMN_DOWNLOADDIR, &lastDownloadDir, -1);
json_object_ref(t);
if (json_array_get_length(trackerStats) > 0) {
- JsonObject *firstTracker = json_array_get_object_element(trackerStats,
- 0);
- firstTrackerHost = trg_gregex_get_first(priv->urlHostRegex,
- tracker_stats_get_host(firstTracker));
+ JsonObject *firstTracker =
+ json_array_get_object_element(trackerStats,
+ 0);
+ firstTrackerHost = trg_gregex_get_first(priv->urlHostRegex,
+ tracker_stats_get_host
+ (firstTracker));
}
lpd = peerfrom_get_lpd(pf);
if (newFlags & TORRENT_FLAG_ACTIVE) {
- if (lpd >= 0) {
- peerSources = g_strdup_printf(
- "%ld / %ld / %ld / %ld / %ld / %ld / %ld",
- peerfrom_get_trackers(pf), peerfrom_get_incoming(pf),
- peerfrom_get_ltep(pf), peerfrom_get_dht(pf),
- peerfrom_get_pex(pf), lpd, peerfrom_get_resume(pf));
- } else {
- peerSources = g_strdup_printf(
- "%ld / %ld / %ld / %ld / %ld / N/A / %ld",
- peerfrom_get_trackers(pf), peerfrom_get_incoming(pf),
- peerfrom_get_ltep(pf), peerfrom_get_dht(pf),
- peerfrom_get_pex(pf), peerfrom_get_resume(pf));
- }
+ if (lpd >= 0) {
+ peerSources =
+ g_strdup_printf("%ld / %ld / %ld / %ld / %ld / %ld / %ld",
+ peerfrom_get_trackers(pf),
+ peerfrom_get_incoming(pf),
+ peerfrom_get_ltep(pf),
+ peerfrom_get_dht(pf), peerfrom_get_pex(pf),
+ lpd, peerfrom_get_resume(pf));
+ } else {
+ peerSources =
+ g_strdup_printf("%ld / %ld / %ld / %ld / %ld / N/A / %ld",
+ peerfrom_get_trackers(pf),
+ peerfrom_get_incoming(pf),
+ peerfrom_get_ltep(pf),
+ peerfrom_get_dht(pf), peerfrom_get_pex(pf),
+ peerfrom_get_resume(pf));
+ }
}
-
#ifdef DEBUG
gtk_list_store_set(ls, iter, TORRENT_COLUMN_ICON, statusIcon, -1);
gtk_list_store_set(ls, iter,
- TORRENT_COLUMN_NAME, torrent_get_name(t), -1);
+ TORRENT_COLUMN_NAME, torrent_get_name(t), -1);
gtk_list_store_set(ls, iter,
- TORRENT_COLUMN_SIZE, torrent_get_size(t), -1);
+ TORRENT_COLUMN_SIZE, torrent_get_size(t), -1);
gtk_list_store_set(ls, iter,
- TORRENT_COLUMN_DONE, (newFlags & TORRENT_FLAG_CHECKING) ?
- torrent_get_recheck_progress(t)
- : torrent_get_percent_done(t),
- -1);
+ TORRENT_COLUMN_DONE,
+ (newFlags & TORRENT_FLAG_CHECKING) ?
+ torrent_get_recheck_progress(t)
+ : torrent_get_percent_done(t), -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_STATUS, statusString, -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_DOWNSPEED, downRate, -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_FLAGS, newFlags, -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_UPSPEED, upRate, -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_ETA,
- torrent_get_eta(t), -1);
+ torrent_get_eta(t), -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_UPLOADED, uploaded, -1);
gtk_list_store_set(ls, iter,
- TORRENT_COLUMN_DOWNLOADED, downloaded, -1);
+ TORRENT_COLUMN_DOWNLOADED, downloaded, -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_RATIO,
- uploaded > 0
- && downloaded >
- 0 ? (double) uploaded / (double) downloaded : 0,
- -1);
+ uploaded > 0
+ && downloaded >
+ 0 ? (double) uploaded / (double) downloaded : 0,
+ -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_ID, id, -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_JSON, t, -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_UPDATESERIAL, serial, -1);
gtk_list_store_set(ls, iter,
- TORRENT_COLUMN_ADDED, torrent_get_added_date(t),
- -1);
+ TORRENT_COLUMN_ADDED, torrent_get_added_date(t),
+ -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_DOWNLOADDIR,
- downloadDir, -1);
+ downloadDir, -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_BANDWIDTH_PRIORITY,
- torrent_get_bandwidth_priority(t), -1);
+ torrent_get_bandwidth_priority(t), -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_DONE_DATE,
- torrent_get_done_date(t), -1);
+ torrent_get_done_date(t), -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_FROMPEX,
- peerfrom_get_pex(pf), -1);
+ peerfrom_get_pex(pf), -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_FROMDHT,
- peerfrom_get_dht(pf), -1);
+ peerfrom_get_dht(pf), -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_FROMTRACKERS,
- peerfrom_get_trackers(pf), -1);
+ peerfrom_get_trackers(pf), -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_FROMLTEP,
- peerfrom_get_ltep(pf), -1);
+ peerfrom_get_ltep(pf), -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_FROMRESUME,
- peerfrom_get_resume(pf), -1);
+ peerfrom_get_resume(pf), -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_FROMINCOMING,
- peerfrom_get_incoming(pf), -1);
+ peerfrom_get_incoming(pf), -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_PEER_SOURCES,
- peerSources, -1);
+ peerSources, -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_PEERS_CONNECTED,
- torrent_get_peers_connected(t), -1);
+ torrent_get_peers_connected(t), -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_PEERS_TO_US,
- torrent_get_peers_sending_to_us(t), -1);
+ torrent_get_peers_sending_to_us(t), -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_PEERS_FROM_US,
- torrent_get_peers_getting_from_us(t), -1);
+ torrent_get_peers_getting_from_us(t), -1);
gtk_list_store_set(ls, iter, TORRENT_COLUMN_TRACKERHOST,
- firstTrackerHost ? firstTrackerHost : "", -1);
- gtk_list_store_set(ls, iter, TORRENT_COLUMN_QUEUE_POSITION, torrent_get_queue_position(t), -1);
- gtk_list_store_set(ls, iter, TORRENT_COLUMN_LASTACTIVE, torrent_get_activity_date(t), -1);
+ firstTrackerHost ? firstTrackerHost : "", -1);
+ gtk_list_store_set(ls, iter, TORRENT_COLUMN_QUEUE_POSITION,
+ torrent_get_queue_position(t), -1);
+ gtk_list_store_set(ls, iter, TORRENT_COLUMN_LASTACTIVE,
+ torrent_get_activity_date(t), -1);
#else
gtk_list_store_set(ls, iter, TORRENT_COLUMN_ICON, statusIcon,
- TORRENT_COLUMN_ADDED, torrent_get_added_date(t),
- TORRENT_COLUMN_DONE_DATE, torrent_get_done_date(t),
- TORRENT_COLUMN_NAME, torrent_get_name(t), TORRENT_COLUMN_SIZE,
- torrent_get_size(t), TORRENT_COLUMN_DONE,
- (newFlags & TORRENT_FLAG_CHECKING) ?
- torrent_get_recheck_progress(t)
- : torrent_get_percent_done(t),
- TORRENT_COLUMN_STATUS, statusString,
- TORRENT_COLUMN_DOWNSPEED, downRate,
- TORRENT_COLUMN_FLAGS, newFlags,
- TORRENT_COLUMN_UPSPEED, upRate,
- TORRENT_COLUMN_ETA, torrent_get_eta(t),
- TORRENT_COLUMN_UPLOADED, uploaded,
- TORRENT_COLUMN_DOWNLOADED, downloaded,
- TORRENT_COLUMN_FROMPEX, peerfrom_get_pex(pf),
- TORRENT_COLUMN_FROMDHT, peerfrom_get_dht(pf),
- TORRENT_COLUMN_FROMTRACKERS, peerfrom_get_trackers(pf),
- TORRENT_COLUMN_FROMLTEP, peerfrom_get_ltep(pf),
- TORRENT_COLUMN_FROMRESUME, peerfrom_get_resume(pf),
- TORRENT_COLUMN_FROMINCOMING, peerfrom_get_incoming(pf),
- TORRENT_COLUMN_PEER_SOURCES, peerSources,
- TORRENT_COLUMN_PEERS_CONNECTED, torrent_get_peers_connected(t),
- TORRENT_COLUMN_PEERS_TO_US, torrent_get_peers_sending_to_us(t),
- TORRENT_COLUMN_PEERS_FROM_US, torrent_get_peers_getting_from_us(t),
- TORRENT_COLUMN_QUEUE_POSITION, torrent_get_queue_position(t),
- TORRENT_COLUMN_LASTACTIVE, torrent_get_activity_date(t),
- TORRENT_COLUMN_RATIO,
- uploaded >
- 0
- && downloaded >
- 0 ? (double) uploaded / (double) downloaded : 0,
- TORRENT_COLUMN_DOWNLOADDIR,
- downloadDir,
- TORRENT_COLUMN_BANDWIDTH_PRIORITY,
- torrent_get_bandwidth_priority(t),
- TORRENT_COLUMN_ID, id, TORRENT_COLUMN_JSON, t,
- TORRENT_COLUMN_TRACKERHOST,
- firstTrackerHost ? firstTrackerHost : "",
- TORRENT_COLUMN_UPDATESERIAL, serial, -1);
+ TORRENT_COLUMN_ADDED, torrent_get_added_date(t),
+ TORRENT_COLUMN_DONE_DATE, torrent_get_done_date(t),
+ TORRENT_COLUMN_NAME, torrent_get_name(t),
+ TORRENT_COLUMN_SIZE, torrent_get_size(t),
+ TORRENT_COLUMN_DONE,
+ (newFlags & TORRENT_FLAG_CHECKING) ?
+ torrent_get_recheck_progress(t)
+ : torrent_get_percent_done(t),
+ TORRENT_COLUMN_STATUS, statusString,
+ TORRENT_COLUMN_DOWNSPEED, downRate,
+ TORRENT_COLUMN_FLAGS, newFlags,
+ TORRENT_COLUMN_UPSPEED, upRate, TORRENT_COLUMN_ETA,
+ torrent_get_eta(t), TORRENT_COLUMN_UPLOADED,
+ uploaded, TORRENT_COLUMN_DOWNLOADED, downloaded,
+ TORRENT_COLUMN_FROMPEX, peerfrom_get_pex(pf),
+ TORRENT_COLUMN_FROMDHT, peerfrom_get_dht(pf),
+ TORRENT_COLUMN_FROMTRACKERS,
+ peerfrom_get_trackers(pf), TORRENT_COLUMN_FROMLTEP,
+ peerfrom_get_ltep(pf), TORRENT_COLUMN_FROMRESUME,
+ peerfrom_get_resume(pf),
+ TORRENT_COLUMN_FROMINCOMING,
+ peerfrom_get_incoming(pf),
+ TORRENT_COLUMN_PEER_SOURCES, peerSources,
+ TORRENT_COLUMN_PEERS_CONNECTED,
+ torrent_get_peers_connected(t),
+ TORRENT_COLUMN_PEERS_TO_US,
+ torrent_get_peers_sending_to_us(t),
+ TORRENT_COLUMN_PEERS_FROM_US,
+ torrent_get_peers_getting_from_us(t),
+ TORRENT_COLUMN_QUEUE_POSITION,
+ torrent_get_queue_position(t),
+ TORRENT_COLUMN_LASTACTIVE,
+ torrent_get_activity_date(t), TORRENT_COLUMN_RATIO,
+ uploaded > 0
+ && downloaded >
+ 0 ? (double) uploaded / (double) downloaded : 0,
+ TORRENT_COLUMN_DOWNLOADDIR, downloadDir,
+ TORRENT_COLUMN_BANDWIDTH_PRIORITY,
+ torrent_get_bandwidth_priority(t),
+ TORRENT_COLUMN_ID, id, TORRENT_COLUMN_JSON, t,
+ TORRENT_COLUMN_TRACKERHOST,
+ firstTrackerHost ? firstTrackerHost : "",
+ TORRENT_COLUMN_UPDATESERIAL, serial, -1);
#endif
if (!lastDownloadDir || g_strcmp0(downloadDir, lastDownloadDir)) {
- gchar *shortDownloadDir = shorten_download_dir(tc, downloadDir);
- gtk_list_store_set(ls, iter, TORRENT_COLUMN_DOWNLOADDIR_SHORT,
- shortDownloadDir, -1);
- g_free(shortDownloadDir);
- *updateFilters = TRUE;
+ gchar *shortDownloadDir = shorten_download_dir(tc, downloadDir);
+ gtk_list_store_set(ls, iter, TORRENT_COLUMN_DOWNLOADDIR_SHORT,
+ shortDownloadDir, -1);
+ g_free(shortDownloadDir);
+ *updateFilters = TRUE;
}
if (lastJson)
- json_object_unref(lastJson);
+ json_object_unref(lastJson);
if ((lastFlags & TORRENT_FLAG_DOWNLOADING)
- && (newFlags & TORRENT_FLAG_COMPLETE))
- g_signal_emit(model, signals[TMODEL_TORRENT_COMPLETED], 0, iter);
+ && (newFlags & TORRENT_FLAG_COMPLETE))
+ g_signal_emit(model, signals[TMODEL_TORRENT_COMPLETED], 0, iter);
trg_torrent_model_count_peers(model, iter, t);
if (firstTrackerHost)
- g_free(firstTrackerHost);
+ g_free(firstTrackerHost);
if (peerSources)
- g_free(peerSources);
+ g_free(peerSources);
g_free(lastDownloadDir);
g_free(statusString);
g_free(statusIcon);
}
-TrgTorrentModel *trg_torrent_model_new(void) {
+TrgTorrentModel *trg_torrent_model_new(void)
+{
return g_object_new(TRG_TYPE_TORRENT_MODEL, NULL);
}
@@ -533,67 +595,79 @@ struct TrgModelRemoveData {
gint64 currentSerial;
};
-GHashTable *get_torrent_table(TrgTorrentModel * model) {
+GHashTable *get_torrent_table(TrgTorrentModel * model)
+{
TrgTorrentModelPrivate *priv = TRG_TORRENT_MODEL_GET_PRIVATE(model);
return priv->ht;
}
gboolean trg_model_find_removed_foreachfunc(GtkTreeModel * model,
- GtkTreePath * path G_GNUC_UNUSED, GtkTreeIter * iter, gpointer gdata) {
+ GtkTreePath *
+ path G_GNUC_UNUSED,
+ GtkTreeIter * iter,
+ gpointer gdata)
+{
struct TrgModelRemoveData *args = (struct TrgModelRemoveData *) gdata;
gint64 rowSerial;
- gtk_tree_model_get(model, iter, TORRENT_COLUMN_UPDATESERIAL, &rowSerial,
- -1);
+ gtk_tree_model_get(model, iter, TORRENT_COLUMN_UPDATESERIAL,
+ &rowSerial, -1);
if (rowSerial != args->currentSerial) {
- gint64 *id = g_new(gint64, 1);
- gtk_tree_model_get(model, iter, TORRENT_COLUMN_ID, id, -1);
- args->toRemove = g_list_append(args->toRemove, id);
+ gint64 *id = g_new(gint64, 1);
+ gtk_tree_model_get(model, iter, TORRENT_COLUMN_ID, id, -1);
+ args->toRemove = g_list_append(args->toRemove, id);
}
return FALSE;
}
GList *trg_torrent_model_find_removed(GtkTreeModel * model,
- gint64 currentSerial) {
+ gint64 currentSerial)
+{
struct TrgModelRemoveData args;
args.toRemove = NULL;
args.currentSerial = currentSerial;
gtk_tree_model_foreach(GTK_TREE_MODEL(model),
- trg_model_find_removed_foreachfunc, &args);
+ trg_model_find_removed_foreachfunc, &args);
return args.toRemove;
}
gboolean get_torrent_data(GHashTable * table, gint64 id, JsonObject ** t,
- GtkTreeIter * out_iter) {
+ GtkTreeIter * out_iter)
+{
gpointer result = g_hash_table_lookup(table, &id);
gboolean found = FALSE;
if (result) {
- GtkTreeRowReference *rr = (GtkTreeRowReference *) result;
- GtkTreePath *path = gtk_tree_row_reference_get_path(rr);
- GtkTreeIter iter;
- if (path) {
- GtkTreeModel *model = gtk_tree_row_reference_get_model(rr);
- gtk_tree_model_get_iter(model, &iter, path);
- if (out_iter)
- *out_iter = iter;
- if (t)
- gtk_tree_model_get(model, &iter, TORRENT_COLUMN_JSON, t, -1);
- found = TRUE;
- gtk_tree_path_free(path);
- }
+ GtkTreeRowReference *rr = (GtkTreeRowReference *) result;
+ GtkTreePath *path = gtk_tree_row_reference_get_path(rr);
+ GtkTreeIter iter;
+ if (path) {
+ GtkTreeModel *model = gtk_tree_row_reference_get_model(rr);
+ gtk_tree_model_get_iter(model, &iter, path);
+ if (out_iter)
+ *out_iter = iter;
+ if (t)
+ gtk_tree_model_get(model, &iter, TORRENT_COLUMN_JSON, t,
+ -1);
+ found = TRUE;
+ gtk_tree_path_free(path);
+ }
}
return found;
}
-trg_torrent_model_update_stats* trg_torrent_model_update(TrgTorrentModel * model, TrgClient * tc,
- JsonObject * response,
- gint mode) {
+trg_torrent_model_update_stats *trg_torrent_model_update(TrgTorrentModel *
+ model,
+ TrgClient * tc,
+ JsonObject *
+ response,
+ gint mode)
+{
TrgTorrentModelPrivate *priv = TRG_TORRENT_MODEL_GET_PRIVATE(model);
GList *torrentList;
@@ -616,73 +690,76 @@ trg_torrent_model_update_stats* trg_torrent_model_update(TrgTorrentModel * model
memset(&(priv->stats), 0, sizeof(trg_torrent_model_update_stats));
for (li = torrentList; li; li = g_list_next(li)) {
- t = json_node_get_object((JsonNode *) li->data);
- id = torrent_get_id(t);
-
- result =
- mode == TORRENT_GET_MODE_FIRST ? NULL :
- g_hash_table_lookup(priv->ht, &id);
-
- if (!result) {
- gtk_list_store_append(GTK_LIST_STORE(model), &iter);
-
- update_torrent_iter(model, tc, rpcv, trg_client_get_serial(tc),
- &iter, t, &(priv->stats), &updateFilters);
-
- path = gtk_tree_model_get_path(GTK_TREE_MODEL(model), &iter);
- rr = gtk_tree_row_reference_new(GTK_TREE_MODEL(model), path);
- idCopy = g_new(gint64, 1);
- *idCopy = id;
- g_hash_table_insert(priv->ht, idCopy, rr);
- gtk_tree_path_free(path);
- if (mode != TORRENT_GET_MODE_FIRST)
- g_signal_emit(model, signals[TMODEL_TORRENT_ADDED], 0, &iter);
- } else {
- path = gtk_tree_row_reference_get_path(
- (GtkTreeRowReference *) result);
- if (path) {
- if (gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter,
- path)) {
- update_torrent_iter(model, tc, rpcv,
- trg_client_get_serial(tc), &iter, t, &(priv->stats), &updateFilters);
- }
- gtk_tree_path_free(path);
- }
- }
+ t = json_node_get_object((JsonNode *) li->data);
+ id = torrent_get_id(t);
+
+ result =
+ mode == TORRENT_GET_MODE_FIRST ? NULL :
+ g_hash_table_lookup(priv->ht, &id);
+
+ if (!result) {
+ gtk_list_store_append(GTK_LIST_STORE(model), &iter);
+
+ update_torrent_iter(model, tc, rpcv, trg_client_get_serial(tc),
+ &iter, t, &(priv->stats), &updateFilters);
+
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL(model), &iter);
+ rr = gtk_tree_row_reference_new(GTK_TREE_MODEL(model), path);
+ idCopy = g_new(gint64, 1);
+ *idCopy = id;
+ g_hash_table_insert(priv->ht, idCopy, rr);
+ gtk_tree_path_free(path);
+ if (mode != TORRENT_GET_MODE_FIRST)
+ g_signal_emit(model, signals[TMODEL_TORRENT_ADDED], 0,
+ &iter);
+ } else {
+ path = gtk_tree_row_reference_get_path((GtkTreeRowReference *)
+ result);
+ if (path) {
+ if (gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter,
+ path)) {
+ update_torrent_iter(model, tc, rpcv,
+ trg_client_get_serial(tc), &iter,
+ t, &(priv->stats), &updateFilters);
+ }
+ gtk_tree_path_free(path);
+ }
+ }
}
g_list_free(torrentList);
if (mode == TORRENT_GET_MODE_UPDATE) {
- GList *hitlist = trg_torrent_model_find_removed(GTK_TREE_MODEL(model),
- trg_client_get_serial(tc));
- if (hitlist) {
- for (li = hitlist; li; li = g_list_next(li)) {
- g_hash_table_remove(priv->ht, li->data);
- g_free(li->data);
- }
- updateFilters = TRUE;
- g_list_free(hitlist);
- }
+ GList *hitlist =
+ trg_torrent_model_find_removed(GTK_TREE_MODEL(model),
+ trg_client_get_serial(tc));
+ if (hitlist) {
+ for (li = hitlist; li; li = g_list_next(li)) {
+ g_hash_table_remove(priv->ht, li->data);
+ g_free(li->data);
+ }
+ updateFilters = TRUE;
+ g_list_free(hitlist);
+ }
} else if (mode > TORRENT_GET_MODE_FIRST) {
- removedTorrents = get_torrents_removed(args);
- if (removedTorrents) {
- GList *hitlist = json_array_get_elements(removedTorrents);
- for (li = hitlist; li; li = g_list_next(li)) {
- id = json_node_get_int((JsonNode *) li->data);
- g_hash_table_remove(priv->ht, &id);
- updateFilters = TRUE;
- }
- g_list_free(hitlist);
- }
+ removedTorrents = get_torrents_removed(args);
+ if (removedTorrents) {
+ GList *hitlist = json_array_get_elements(removedTorrents);
+ for (li = hitlist; li; li = g_list_next(li)) {
+ id = json_node_get_int((JsonNode *) li->data);
+ g_hash_table_remove(priv->ht, &id);
+ updateFilters = TRUE;
+ }
+ g_list_free(hitlist);
+ }
}
if (updateFilters)
- g_signal_emit(model, signals[TMODEL_UPDATE_FILTERS], 0);
+ g_signal_emit(model, signals[TMODEL_UPDATE_FILTERS], 0);
gtk_tree_model_foreach(GTK_TREE_MODEL(model),
- trg_torrent_model_stats_scan_foreachfunc, &(priv->stats));
+ trg_torrent_model_stats_scan_foreachfunc,
+ &(priv->stats));
return &(priv->stats);
}
-
diff --git a/src/trg-torrent-model.h b/src/trg-torrent-model.h
index e036d5d..a29c279 100644
--- a/src/trg-torrent-model.h
+++ b/src/trg-torrent-model.h
@@ -44,9 +44,9 @@ G_BEGIN_DECLS
typedef struct {
GtkListStoreClass parent_class;
void (*torrent_completed) (TrgTorrentModel * model,
- GtkTreeIter * iter, gpointer data);
+ GtkTreeIter * iter, gpointer data);
void (*torrent_added) (TrgTorrentModel * model,
- GtkTreeIter * iter, gpointer data);
+ GtkTreeIter * iter, gpointer data);
void (*torrent_removed) (TrgTorrentModel * model, gpointer data);
} TrgTorrentModelClass;
@@ -66,26 +66,30 @@ GType trg_torrent_model_get_type(void);
TrgTorrentModel *trg_torrent_model_new();
G_END_DECLS
-
gboolean
find_existing_peer_item(GtkListStore * model, JsonObject * p,
- GtkTreeIter * iter);
+ GtkTreeIter * iter);
-trg_torrent_model_update_stats* trg_torrent_model_update(TrgTorrentModel * model, TrgClient * tc,
- JsonObject * response,
- gint mode);
-trg_torrent_model_update_stats *trg_torrent_model_get_stats(TrgTorrentModel * model);
+trg_torrent_model_update_stats *trg_torrent_model_update(TrgTorrentModel *
+ model,
+ TrgClient * tc,
+ JsonObject *
+ response,
+ gint mode);
+trg_torrent_model_update_stats *trg_torrent_model_get_stats(TrgTorrentModel
+ * model);
GHashTable *get_torrent_table(TrgTorrentModel * model);
-void trg_torrent_model_remove_all(TrgTorrentModel *model);
+void trg_torrent_model_remove_all(TrgTorrentModel * model);
gboolean trg_torrent_model_is_remove_in_progress(TrgTorrentModel * model);
gboolean get_torrent_data(GHashTable * table, gint64 id, JsonObject ** t,
- GtkTreeIter * out_iter);
+ GtkTreeIter * out_iter);
-gchar *shorten_download_dir(TrgClient *tc, const gchar *downloadDir);
-void trg_torrent_model_reload_dir_aliases(TrgClient *tc, GtkTreeModel *model);
+gchar *shorten_download_dir(TrgClient * tc, const gchar * downloadDir);
+void trg_torrent_model_reload_dir_aliases(TrgClient * tc,
+ GtkTreeModel * model);
enum {
TORRENT_COLUMN_ICON,
@@ -127,4 +131,4 @@ enum {
TORRENT_COLUMN_COLUMNS
};
-#endif /* TRG_TORRENT_MODEL_H_ */
+#endif /* TRG_TORRENT_MODEL_H_ */
diff --git a/src/trg-torrent-move-dialog.c b/src/trg-torrent-move-dialog.c
index 4343373..bfd18f2 100644
--- a/src/trg-torrent-move-dialog.c
+++ b/src/trg-torrent-move-dialog.c
@@ -31,7 +31,7 @@
#include "requests.h"
G_DEFINE_TYPE(TrgTorrentMoveDialog, trg_torrent_move_dialog,
- GTK_TYPE_DIALOG)
+ GTK_TYPE_DIALOG)
#define TRG_TORRENT_MOVE_DIALOG_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_TORRENT_MOVE_DIALOG, TrgTorrentMoveDialogPrivate))
typedef struct _TrgTorrentMoveDialogPrivate
@@ -56,23 +56,24 @@ static void
trg_torrent_move_response_cb(GtkDialog * dlg, gint res_id, gpointer data)
{
TrgTorrentMoveDialogPrivate *priv =
- TRG_TORRENT_MOVE_DIALOG_GET_PRIVATE(dlg);
+ TRG_TORRENT_MOVE_DIALOG_GET_PRIVATE(dlg);
if (res_id == GTK_RESPONSE_ACCEPT) {
- gchar *location =
- trg_destination_combo_get_dir(TRG_DESTINATION_COMBO
- (priv->location_combo));
- JsonNode *request = torrent_set_location(priv->ids, location,
- gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON
- (priv->move_check)));
- g_free(location);
- request_set_tag_from_ids(request, priv->ids);
- trg_destination_combo_save_selection(TRG_DESTINATION_COMBO(priv->location_combo));
- dispatch_async(priv->client, request,
- on_generic_interactive_action, data);
+ gchar *location =
+ trg_destination_combo_get_dir(TRG_DESTINATION_COMBO
+ (priv->location_combo));
+ JsonNode *request = torrent_set_location(priv->ids, location,
+ gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON
+ (priv->move_check)));
+ g_free(location);
+ request_set_tag_from_ids(request, priv->ids);
+ trg_destination_combo_save_selection(TRG_DESTINATION_COMBO
+ (priv->location_combo));
+ dispatch_async(priv->client, request,
+ on_generic_interactive_action, data);
} else {
- json_array_unref(priv->ids);
+ json_array_unref(priv->ids);
}
gtk_widget_destroy(GTK_WIDGET(dlg));
}
@@ -80,22 +81,25 @@ trg_torrent_move_response_cb(GtkDialog * dlg, gint res_id, gpointer data)
static void location_changed(GtkWidget * w, gpointer data)
{
TrgTorrentMoveDialogPrivate *priv =
- TRG_TORRENT_MOVE_DIALOG_GET_PRIVATE(data);
- gtk_widget_set_sensitive(priv->move_button, trg_destination_combo_has_text(TRG_DESTINATION_COMBO(priv->location_combo)));
+ TRG_TORRENT_MOVE_DIALOG_GET_PRIVATE(data);
+ gtk_widget_set_sensitive(priv->move_button,
+ trg_destination_combo_has_text
+ (TRG_DESTINATION_COMBO
+ (priv->location_combo)));
}
static GObject *trg_torrent_move_dialog_constructor(GType type,
- guint
- n_construct_properties,
- GObjectConstructParam
- * construct_params)
+ guint
+ n_construct_properties,
+ GObjectConstructParam
+ * construct_params)
{
GObject *object = G_OBJECT_CLASS
- (trg_torrent_move_dialog_parent_class)->constructor(type,
- n_construct_properties,
- construct_params);
+ (trg_torrent_move_dialog_parent_class)->constructor(type,
+ n_construct_properties,
+ construct_params);
TrgTorrentMoveDialogPrivate *priv =
- TRG_TORRENT_MOVE_DIALOG_GET_PRIVATE(object);
+ TRG_TORRENT_MOVE_DIALOG_GET_PRIVATE(object);
gint count;
gchar *msg;
@@ -105,109 +109,117 @@ static GObject *trg_torrent_move_dialog_constructor(GType type,
t = hig_workarea_create();
- w = priv->location_combo = trg_destination_combo_new(priv->client, TRG_PREFS_KEY_LAST_MOVE_DESTINATION);
- g_signal_connect(trg_destination_combo_get_entry(TRG_DESTINATION_COMBO(w)), "changed", G_CALLBACK(location_changed), object);
+ w = priv->location_combo =
+ trg_destination_combo_new(priv->client,
+ TRG_PREFS_KEY_LAST_MOVE_DESTINATION);
+ g_signal_connect(trg_destination_combo_get_entry
+ (TRG_DESTINATION_COMBO(w)), "changed",
+ G_CALLBACK(location_changed), object);
hig_workarea_add_row(t, &row, _("Location:"), w, NULL);
priv->move_check =
- hig_workarea_add_wide_checkbutton(t, &row, _("Move"), TRUE);
+ hig_workarea_add_wide_checkbutton(t, &row, _("Move"), TRUE);
gtk_window_set_destroy_with_parent(GTK_WINDOW(object), TRUE);
gtk_dialog_add_button(GTK_DIALOG(object), GTK_STOCK_CLOSE,
- GTK_RESPONSE_CANCEL);
+ GTK_RESPONSE_CANCEL);
priv->move_button =
- gtk_dialog_add_button(GTK_DIALOG(object), _("Move"),
- GTK_RESPONSE_ACCEPT);
+ gtk_dialog_add_button(GTK_DIALOG(object), _("Move"),
+ GTK_RESPONSE_ACCEPT);
- gtk_widget_set_sensitive(priv->move_button, trg_destination_combo_has_text(TRG_DESTINATION_COMBO(priv->location_combo)));
+ gtk_widget_set_sensitive(priv->move_button,
+ trg_destination_combo_has_text
+ (TRG_DESTINATION_COMBO
+ (priv->location_combo)));
gtk_container_set_border_width(GTK_CONTAINER(object), GUI_PAD);
gtk_dialog_set_default_response(GTK_DIALOG(object),
- GTK_RESPONSE_ACCEPT);
+ GTK_RESPONSE_ACCEPT);
gtk_dialog_set_alternative_button_order(GTK_DIALOG(object),
- GTK_RESPONSE_ACCEPT,
- GTK_RESPONSE_CANCEL, -1);
+ GTK_RESPONSE_ACCEPT,
+ GTK_RESPONSE_CANCEL, -1);
gtk_container_set_border_width(GTK_CONTAINER(t), GUI_PAD);
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area (GTK_DIALOG(object))), t, TRUE, TRUE,
- 0);
+ gtk_box_pack_start(GTK_BOX
+ (gtk_dialog_get_content_area(GTK_DIALOG(object))),
+ t, TRUE, TRUE, 0);
count =
- gtk_tree_selection_count_selected_rows(gtk_tree_view_get_selection
- (GTK_TREE_VIEW
- (priv->treeview)));
+ gtk_tree_selection_count_selected_rows(gtk_tree_view_get_selection
+ (GTK_TREE_VIEW
+ (priv->treeview)));
priv->ids = build_json_id_array(priv->treeview);
if (count == 1) {
- JsonObject *json;
- const gchar *name;
-
- get_torrent_data(trg_client_get_torrent_table(priv->client),
- trg_mw_get_selected_torrent_id(priv->win), &json,
- NULL);
- name = torrent_get_name(json);
- msg = g_strdup_printf(_("Move %s"), name);
+ JsonObject *json;
+ const gchar *name;
+
+ get_torrent_data(trg_client_get_torrent_table(priv->client),
+ trg_mw_get_selected_torrent_id(priv->win), &json,
+ NULL);
+ name = torrent_get_name(json);
+ msg = g_strdup_printf(_("Move %s"), name);
} else {
- msg = g_strdup_printf(_("Move %d torrents"), count);
+ msg = g_strdup_printf(_("Move %d torrents"), count);
}
gtk_window_set_transient_for(GTK_WINDOW(object),
- GTK_WINDOW(priv->win));
+ GTK_WINDOW(priv->win));
gtk_window_set_title(GTK_WINDOW(object), msg);
g_signal_connect(G_OBJECT(object),
- "response",
- G_CALLBACK(trg_torrent_move_response_cb), priv->win);
+ "response",
+ G_CALLBACK(trg_torrent_move_response_cb), priv->win);
return object;
}
static void
trg_torrent_move_dialog_get_property(GObject * object, guint property_id,
- GValue * value, GParamSpec * pspec)
+ GValue * value, GParamSpec * pspec)
{
TrgTorrentMoveDialogPrivate *priv =
- TRG_TORRENT_MOVE_DIALOG_GET_PRIVATE(object);
+ TRG_TORRENT_MOVE_DIALOG_GET_PRIVATE(object);
switch (property_id) {
case PROP_CLIENT:
- g_value_set_pointer(value, priv->client);
- break;
+ g_value_set_pointer(value, priv->client);
+ break;
case PROP_PARENT_WINDOW:
- g_value_set_object(value, priv->win);
- break;
+ g_value_set_object(value, priv->win);
+ break;
case PROP_TREEVIEW:
- g_value_set_object(value, priv->treeview);
- break;
+ g_value_set_object(value, priv->treeview);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
static void
trg_torrent_move_dialog_set_property(GObject * object, guint property_id,
- const GValue * value,
- GParamSpec * pspec)
+ const GValue * value,
+ GParamSpec * pspec)
{
TrgTorrentMoveDialogPrivate *priv =
- TRG_TORRENT_MOVE_DIALOG_GET_PRIVATE(object);
+ TRG_TORRENT_MOVE_DIALOG_GET_PRIVATE(object);
switch (property_id) {
case PROP_CLIENT:
- priv->client = g_value_get_pointer(value);
- break;
+ priv->client = g_value_get_pointer(value);
+ break;
case PROP_PARENT_WINDOW:
- priv->win = g_value_get_object(value);
- break;
+ priv->win = g_value_get_object(value);
+ break;
case PROP_TREEVIEW:
- priv->treeview = g_value_get_object(value);
- break;
+ priv->treeview = g_value_get_object(value);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
@@ -223,39 +235,39 @@ trg_torrent_move_dialog_class_init(TrgTorrentMoveDialogClass * klass)
object_class->constructor = trg_torrent_move_dialog_constructor;
g_object_class_install_property(object_class,
- PROP_TREEVIEW,
- g_param_spec_object
- ("torrent-tree-view",
- "TrgTorrentTreeView",
- "TrgTorrentTreeView",
- TRG_TYPE_TORRENT_TREE_VIEW,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
+ PROP_TREEVIEW,
+ g_param_spec_object
+ ("torrent-tree-view",
+ "TrgTorrentTreeView",
+ "TrgTorrentTreeView",
+ TRG_TYPE_TORRENT_TREE_VIEW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
g_object_class_install_property(object_class,
- PROP_PARENT_WINDOW,
- g_param_spec_object
- ("parent-window", "Parent window",
- "Parent window", TRG_TYPE_MAIN_WINDOW,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
+ PROP_PARENT_WINDOW,
+ g_param_spec_object
+ ("parent-window", "Parent window",
+ "Parent window", TRG_TYPE_MAIN_WINDOW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
g_object_class_install_property(object_class,
- PROP_CLIENT,
- g_param_spec_pointer
- ("trg-client", "TClient",
- "Client",
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
+ PROP_CLIENT,
+ g_param_spec_pointer
+ ("trg-client", "TClient",
+ "Client",
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
}
static void trg_torrent_move_dialog_init(TrgTorrentMoveDialog * self)
@@ -263,11 +275,11 @@ static void trg_torrent_move_dialog_init(TrgTorrentMoveDialog * self)
}
TrgTorrentMoveDialog *trg_torrent_move_dialog_new(TrgMainWindow * win,
- TrgClient * client,
- TrgTorrentTreeView * ttv)
+ TrgClient * client,
+ TrgTorrentTreeView * ttv)
{
return g_object_new(TRG_TYPE_TORRENT_MOVE_DIALOG,
- "trg-client", client,
- "torrent-tree-view", ttv,
- "parent-window", win, NULL);
+ "trg-client", client,
+ "torrent-tree-view", ttv,
+ "parent-window", win, NULL);
}
diff --git a/src/trg-torrent-move-dialog.h b/src/trg-torrent-move-dialog.h
index c99f78f..40c38ca 100644
--- a/src/trg-torrent-move-dialog.h
+++ b/src/trg-torrent-move-dialog.h
@@ -49,9 +49,9 @@ typedef struct {
GType trg_torrent_move_dialog_get_type(void);
TrgTorrentMoveDialog *trg_torrent_move_dialog_new(TrgMainWindow * win,
- TrgClient * client,
- TrgTorrentTreeView *
- ttv);
+ TrgClient * client,
+ TrgTorrentTreeView *
+ ttv);
G_END_DECLS
-#endif /* TRG_TORRENT_MOVE_DIALOG_H_ */
+#endif /* TRG_TORRENT_MOVE_DIALOG_H_ */
diff --git a/src/trg-torrent-props-dialog.c b/src/trg-torrent-props-dialog.c
index 8f650bf..9486c41 100644
--- a/src/trg-torrent-props-dialog.c
+++ b/src/trg-torrent-props-dialog.c
@@ -47,7 +47,7 @@
*/
G_DEFINE_TYPE(TrgTorrentPropsDialog, trg_torrent_props_dialog,
- GTK_TYPE_DIALOG)
+ GTK_TYPE_DIALOG)
enum {
PROP_0,
@@ -73,51 +73,51 @@ struct _TrgTorrentPropsDialogPrivate {
static void
trg_torrent_props_dialog_set_property(GObject * object,
- guint prop_id,
- const GValue * value,
- GParamSpec * pspec G_GNUC_UNUSED)
+ guint prop_id,
+ const GValue * value,
+ GParamSpec * pspec G_GNUC_UNUSED)
{
TrgTorrentPropsDialogPrivate *priv =
- TRG_TORRENT_PROPS_DIALOG_GET_PRIVATE(object);
+ TRG_TORRENT_PROPS_DIALOG_GET_PRIVATE(object);
switch (prop_id) {
case PROP_PARENT_WINDOW:
- priv->parent = g_value_get_object(value);
- break;
+ priv->parent = g_value_get_object(value);
+ break;
case PROP_TREEVIEW:
- priv->tv = g_value_get_object(value);
- break;
+ priv->tv = g_value_get_object(value);
+ break;
case PROP_CLIENT:
- priv->client = g_value_get_pointer(value);
- break;
+ priv->client = g_value_get_pointer(value);
+ break;
}
}
static void
trg_torrent_props_dialog_get_property(GObject * object,
- guint prop_id,
- GValue * value,
- GParamSpec * pspec G_GNUC_UNUSED)
+ guint prop_id,
+ GValue * value,
+ GParamSpec * pspec G_GNUC_UNUSED)
{
TrgTorrentPropsDialogPrivate *priv =
- TRG_TORRENT_PROPS_DIALOG_GET_PRIVATE(object);
+ TRG_TORRENT_PROPS_DIALOG_GET_PRIVATE(object);
switch (prop_id) {
case PROP_TREEVIEW:
- g_value_set_object(value, priv->tv);
- break;
+ g_value_set_object(value, priv->tv);
+ break;
case PROP_PARENT_WINDOW:
- g_value_set_object(value, priv->parent);
- break;
+ g_value_set_object(value, priv->parent);
+ break;
case PROP_CLIENT:
- g_value_set_pointer(value, priv->client);
- break;
+ g_value_set_pointer(value, priv->client);
+ break;
}
}
static void
trg_torrent_props_response_cb(GtkDialog * dlg, gint res_id,
- gpointer data G_GNUC_UNUSED)
+ gpointer data G_GNUC_UNUSED)
{
TrgTorrentPropsDialogPrivate *priv;
JsonNode *request;
@@ -126,9 +126,9 @@ trg_torrent_props_response_cb(GtkDialog * dlg, gint res_id,
priv = TRG_TORRENT_PROPS_DIALOG_GET_PRIVATE(dlg);
if (res_id != GTK_RESPONSE_OK) {
- gtk_widget_destroy(GTK_WIDGET(dlg));
- json_array_unref(priv->targetIds);
- return;
+ gtk_widget_destroy(GTK_WIDGET(dlg));
+ json_array_unref(priv->targetIds);
+ return;
}
request = torrent_set(priv->targetIds);
@@ -136,19 +136,18 @@ trg_torrent_props_response_cb(GtkDialog * dlg, gint res_id,
args = node_get_arguments(request);
json_object_set_int_member(args, FIELD_SEED_RATIO_MODE,
- gtk_combo_box_get_active(GTK_COMBO_BOX
- (priv->
- seedRatioMode)));
+ gtk_combo_box_get_active(GTK_COMBO_BOX
+ (priv->seedRatioMode)));
json_object_set_int_member(args, FIELD_BANDWIDTH_PRIORITY,
- gtk_combo_box_get_active(GTK_COMBO_BOX
- (priv->
- bandwidthPriorityCombo)) - 1);
+ gtk_combo_box_get_active(GTK_COMBO_BOX
+ (priv->bandwidthPriorityCombo))
+ - 1);
trg_json_widgets_save(priv->widgets, args);
trg_json_widget_desc_list_free(priv->widgets);
dispatch_async(priv->client, request,
- on_generic_interactive_action, priv->parent);
+ on_generic_interactive_action, priv->parent);
gtk_widget_destroy(GTK_WIDGET(dlg));
}
@@ -156,15 +155,15 @@ trg_torrent_props_response_cb(GtkDialog * dlg, gint res_id,
static void seed_ratio_mode_changed_cb(GtkWidget * w, gpointer data)
{
gtk_widget_set_sensitive(GTK_WIDGET(data),
- gtk_combo_box_get_active(GTK_COMBO_BOX(w))
- == 1 ? TRUE : FALSE);
+ gtk_combo_box_get_active(GTK_COMBO_BOX(w))
+ == 1 ? TRUE : FALSE);
}
static GtkWidget *trg_props_limitsPage(TrgTorrentPropsDialog * win,
- JsonObject * json)
+ JsonObject * json)
{
TrgTorrentPropsDialogPrivate *priv =
- TRG_TORRENT_PROPS_DIALOG_GET_PRIVATE(win);
+ TRG_TORRENT_PROPS_DIALOG_GET_PRIVATE(win);
GtkWidget *w, *tb, *t;
gint row = 0;
@@ -172,54 +171,75 @@ static GtkWidget *trg_props_limitsPage(TrgTorrentPropsDialog * win,
hig_workarea_add_section_title(t, &row, _("Bandwidth"));
- w = trg_json_widget_check_new(&priv->widgets, json, FIELD_HONORS_SESSION_LIMITS, _("Honor global limits"), NULL);
+ w = trg_json_widget_check_new(&priv->widgets, json,
+ FIELD_HONORS_SESSION_LIMITS,
+ _("Honor global limits"), NULL);
hig_workarea_add_wide_control(t, &row, w);
- w = priv->bandwidthPriorityCombo = gtr_combo_box_new_enum(_("Low"), 0, _("Normal"), 1, _("High"), 2, NULL);
+ w = priv->bandwidthPriorityCombo =
+ gtr_combo_box_new_enum(_("Low"), 0, _("Normal"), 1, _("High"), 2,
+ NULL);
gtk_combo_box_set_active(GTK_COMBO_BOX(w),
- torrent_get_bandwidth_priority(json) + 1);
+ torrent_get_bandwidth_priority(json) + 1);
hig_workarea_add_row(t, &row, _("Torrent priority:"), w, NULL);
if (json_object_has_member(json, FIELD_QUEUE_POSITION)) {
- w = trg_json_widget_spin_new_int(&priv->widgets, json, FIELD_QUEUE_POSITION, NULL, 0, INT_MAX, 1);
- hig_workarea_add_row(t, &row, _("Queue Position:"), w, w);
+ w = trg_json_widget_spin_new_int(&priv->widgets, json,
+ FIELD_QUEUE_POSITION, NULL, 0,
+ INT_MAX, 1);
+ hig_workarea_add_row(t, &row, _("Queue Position:"), w, w);
}
- tb = trg_json_widget_check_new(&priv->widgets, json, FIELD_DOWNLOAD_LIMITED, _("Limit download speed (Kbps)"), NULL);
- w = trg_json_widget_spin_new_int(&priv->widgets, json, FIELD_DOWNLOAD_LIMIT, tb, 0, INT_MAX, 1);
+ tb = trg_json_widget_check_new(&priv->widgets, json,
+ FIELD_DOWNLOAD_LIMITED,
+ _("Limit download speed (Kbps)"), NULL);
+ w = trg_json_widget_spin_new_int(&priv->widgets, json,
+ FIELD_DOWNLOAD_LIMIT, tb, 0, INT_MAX,
+ 1);
hig_workarea_add_row_w(t, &row, tb, w, NULL);
- tb = trg_json_widget_check_new(&priv->widgets, json, FIELD_UPLOAD_LIMITED, _("Limit upload speed (Kbps)"), NULL);
- w = trg_json_widget_spin_new_int(&priv->widgets, json, FIELD_UPLOAD_LIMIT, tb, 0, INT_MAX, 1);
+ tb = trg_json_widget_check_new(&priv->widgets, json,
+ FIELD_UPLOAD_LIMITED,
+ _("Limit upload speed (Kbps)"), NULL);
+ w = trg_json_widget_spin_new_int(&priv->widgets, json,
+ FIELD_UPLOAD_LIMIT, tb, 0, INT_MAX,
+ 1);
hig_workarea_add_row_w(t, &row, tb, w, NULL);
hig_workarea_add_section_title(t, &row, _("Seeding"));
- w = priv->seedRatioMode = gtr_combo_box_new_enum(_("Use global settings"), 0, _("Stop seeding at ratio"), 1, _("Seed regardless of ratio"), 2, NULL);
+ w = priv->seedRatioMode =
+ gtr_combo_box_new_enum(_("Use global settings"), 0,
+ _("Stop seeding at ratio"), 1,
+ _("Seed regardless of ratio"), 2, NULL);
gtk_combo_box_set_active(GTK_COMBO_BOX(w),
- torrent_get_seed_ratio_mode(json));
+ torrent_get_seed_ratio_mode(json));
hig_workarea_add_row(t, &row, _("Seed ratio mode:"), w, NULL);
- w = trg_json_widget_spin_new_double(&priv->widgets, json, FIELD_SEED_RATIO_LIMIT, NULL, 0, INT_MAX, 0.2);
+ w = trg_json_widget_spin_new_double(&priv->widgets, json,
+ FIELD_SEED_RATIO_LIMIT, NULL, 0,
+ INT_MAX, 0.2);
seed_ratio_mode_changed_cb(priv->seedRatioMode, w);
g_signal_connect(G_OBJECT(priv->seedRatioMode), "changed",
- G_CALLBACK(seed_ratio_mode_changed_cb), w);
+ G_CALLBACK(seed_ratio_mode_changed_cb), w);
hig_workarea_add_row(t, &row, _("Seed ratio limit:"), w, w);
hig_workarea_add_section_title(t, &row, _("Peers"));
- w = trg_json_widget_spin_new_int(&priv->widgets, json, FIELD_PEER_LIMIT, NULL, 0, INT_MAX, 5);
+ w = trg_json_widget_spin_new_int(&priv->widgets, json,
+ FIELD_PEER_LIMIT, NULL, 0, INT_MAX,
+ 5);
hig_workarea_add_row(t, &row, _("Peer limit:"), w, w);
return t;
}
static GObject *trg_torrent_props_dialog_constructor(GType type,
- guint
- n_construct_properties,
- GObjectConstructParam
- * construct_params)
+ guint
+ n_construct_properties,
+ GObjectConstructParam
+ * construct_params)
{
GObject *object;
TrgTorrentPropsDialogPrivate *priv;
@@ -229,59 +249,57 @@ static GObject *trg_torrent_props_dialog_constructor(GType type,
GtkWidget *notebook, *contentvbox;
object = G_OBJECT_CLASS
- (trg_torrent_props_dialog_parent_class)->constructor(type,
- n_construct_properties,
- construct_params);
+ (trg_torrent_props_dialog_parent_class)->constructor(type,
+ n_construct_properties,
+ construct_params);
priv = TRG_TORRENT_PROPS_DIALOG_GET_PRIVATE(object);
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->tv));
rowCount = gtk_tree_selection_count_selected_rows(selection);
get_torrent_data(trg_client_get_torrent_table(priv->client),
- trg_mw_get_selected_torrent_id(priv->parent), &json,
- NULL);
+ trg_mw_get_selected_torrent_id(priv->parent), &json,
+ NULL);
priv->targetIds = build_json_id_array(priv->tv);
if (rowCount > 1) {
- gchar *windowTitle =
- g_strdup_printf(_("Multiple (%d) torrent properties"),
- rowCount);
- gtk_window_set_title(GTK_WINDOW(object), windowTitle);
- g_free(windowTitle);
+ gchar *windowTitle =
+ g_strdup_printf(_("Multiple (%d) torrent properties"),
+ rowCount);
+ gtk_window_set_title(GTK_WINDOW(object), windowTitle);
+ g_free(windowTitle);
} else if (rowCount == 1) {
- gtk_window_set_title(GTK_WINDOW(object), torrent_get_name(json));
+ gtk_window_set_title(GTK_WINDOW(object), torrent_get_name(json));
}
gtk_window_set_transient_for(GTK_WINDOW(object),
- GTK_WINDOW(priv->parent));
+ GTK_WINDOW(priv->parent));
gtk_window_set_destroy_with_parent(GTK_WINDOW(object), TRUE);
gtk_dialog_add_button(GTK_DIALOG(object), GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE);
+ GTK_RESPONSE_CLOSE);
gtk_dialog_add_button(GTK_DIALOG(object), GTK_STOCK_OK,
- GTK_RESPONSE_OK);
+ GTK_RESPONSE_OK);
gtk_container_set_border_width(GTK_CONTAINER(object), GUI_PAD);
- gtk_dialog_set_default_response(GTK_DIALOG(object),
- GTK_RESPONSE_OK);
+ gtk_dialog_set_default_response(GTK_DIALOG(object), GTK_RESPONSE_OK);
g_signal_connect(G_OBJECT(object),
- "response",
- G_CALLBACK(trg_torrent_props_response_cb), NULL);
+ "response",
+ G_CALLBACK(trg_torrent_props_response_cb), NULL);
notebook = gtk_notebook_new();
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
- trg_props_limitsPage
- (TRG_TORRENT_PROPS_DIALOG(object), json),
- gtk_label_new(_("Limits")));
+ trg_props_limitsPage
+ (TRG_TORRENT_PROPS_DIALOG(object), json),
+ gtk_label_new(_("Limits")));
gtk_container_set_border_width(GTK_CONTAINER(notebook), GUI_PAD);
contentvbox = gtk_dialog_get_content_area(GTK_DIALOG(object));
- gtk_box_pack_start(GTK_BOX(contentvbox), notebook,
- TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(contentvbox), notebook, TRUE, TRUE, 0);
return object;
}
@@ -298,39 +316,39 @@ trg_torrent_props_dialog_class_init(TrgTorrentPropsDialogClass * klass)
g_type_class_add_private(klass, sizeof(TrgTorrentPropsDialogPrivate));
g_object_class_install_property(object_class,
- PROP_TREEVIEW,
- g_param_spec_object
- ("torrent-tree-view",
- "TrgTorrentTreeView",
- "TrgTorrentTreeView",
- TRG_TYPE_TORRENT_TREE_VIEW,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
+ PROP_TREEVIEW,
+ g_param_spec_object
+ ("torrent-tree-view",
+ "TrgTorrentTreeView",
+ "TrgTorrentTreeView",
+ TRG_TYPE_TORRENT_TREE_VIEW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
g_object_class_install_property(object_class,
- PROP_PARENT_WINDOW,
- g_param_spec_object
- ("parent-window", "Parent window",
- "Parent window", TRG_TYPE_MAIN_WINDOW,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
+ PROP_PARENT_WINDOW,
+ g_param_spec_object
+ ("parent-window", "Parent window",
+ "Parent window", TRG_TYPE_MAIN_WINDOW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
g_object_class_install_property(object_class,
- PROP_CLIENT,
- g_param_spec_pointer
- ("trg-client", "TClient",
- "Client",
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
+ PROP_CLIENT,
+ g_param_spec_pointer
+ ("trg-client", "TClient",
+ "Client",
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
}
static void
@@ -340,12 +358,12 @@ trg_torrent_props_dialog_init(TrgTorrentPropsDialog * self G_GNUC_UNUSED)
}
TrgTorrentPropsDialog *trg_torrent_props_dialog_new(GtkWindow * window,
- TrgTorrentTreeView *
- treeview,
- TrgClient * client)
+ TrgTorrentTreeView *
+ treeview,
+ TrgClient * client)
{
return g_object_new(TRG_TYPE_TORRENT_PROPS_DIALOG,
- "parent-window", window,
- "torrent-tree-view", treeview,
- "trg-client", client, NULL);
+ "parent-window", window,
+ "torrent-tree-view", treeview,
+ "trg-client", client, NULL);
}
diff --git a/src/trg-torrent-props-dialog.h b/src/trg-torrent-props-dialog.h
index 78d72de..9c935db 100644
--- a/src/trg-torrent-props-dialog.h
+++ b/src/trg-torrent-props-dialog.h
@@ -48,9 +48,9 @@ typedef struct {
GType trg_torrent_props_dialog_get_type(void);
TrgTorrentPropsDialog *trg_torrent_props_dialog_new(GtkWindow * window,
- TrgTorrentTreeView *
- treeview,
- TrgClient * client);
+ TrgTorrentTreeView *
+ treeview,
+ TrgClient * client);
G_END_DECLS
-#endif /* TRG_TORRENT_PROPS_DIALOG_H_ */
+#endif /* TRG_TORRENT_PROPS_DIALOG_H_ */
diff --git a/src/trg-torrent-tree-view.c b/src/trg-torrent-tree-view.c
index cbf20a0..de1d986 100644
--- a/src/trg-torrent-tree-view.c
+++ b/src/trg-torrent-tree-view.c
@@ -26,11 +26,11 @@
#include "trg-torrent-tree-view.h"
G_DEFINE_TYPE(TrgTorrentTreeView, trg_torrent_tree_view,
- TRG_TYPE_TREE_VIEW)
+ TRG_TYPE_TREE_VIEW)
static void
trg_torrent_tree_view_class_init(TrgTorrentTreeViewClass *
- klass G_GNUC_UNUSED)
+ klass G_GNUC_UNUSED)
{
}
@@ -40,104 +40,110 @@ static void trg_torrent_tree_view_init(TrgTorrentTreeView * tttv)
trg_column_description *desc;
desc =
- trg_tree_view_reg_column(ttv, TRG_COLTYPE_STOCKICONTEXT,
- TORRENT_COLUMN_NAME, _("Name"), "name",
- 0);
+ trg_tree_view_reg_column(ttv, TRG_COLTYPE_STOCKICONTEXT,
+ TORRENT_COLUMN_NAME, _("Name"), "name",
+ 0);
desc->model_column_icon = TORRENT_COLUMN_ICON;
trg_tree_view_reg_column(ttv, TRG_COLTYPE_SIZE, TORRENT_COLUMN_SIZE,
- _("Size"), "size", 0);
+ _("Size"), "size", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_PROG, TORRENT_COLUMN_DONE,
- _("Done"), "done", 0);
+ _("Done"), "done", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_TEXT, TORRENT_COLUMN_STATUS,
- _("Status"), "status", 0);
- trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO, TORRENT_COLUMN_SEEDS,
- _("Seeds"), "seeds", 0);
+ _("Status"), "status", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO,
- TORRENT_COLUMN_PEERS_TO_US, _("Sending"),
- "sending", TRG_COLUMN_EXTRA);
+ TORRENT_COLUMN_SEEDS, _("Seeds"), "seeds", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO,
- TORRENT_COLUMN_LEECHERS, _("Leechers"),
- "leechers", 0);
+ TORRENT_COLUMN_PEERS_TO_US, _("Sending"),
+ "sending", TRG_COLUMN_EXTRA);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO,
- TORRENT_COLUMN_DOWNLOADS, _("Downloads"),
- "downloads", TRG_COLUMN_EXTRA);
+ TORRENT_COLUMN_LEECHERS, _("Leechers"),
+ "leechers", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO,
- TORRENT_COLUMN_PEERS_FROM_US, _("Receiving"),
- "connected-leechers", TRG_COLUMN_EXTRA);
+ TORRENT_COLUMN_DOWNLOADS, _("Downloads"),
+ "downloads", TRG_COLUMN_EXTRA);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO,
- TORRENT_COLUMN_PEERS_CONNECTED, _("Connected"),
- "connected-peers", 0);
+ TORRENT_COLUMN_PEERS_FROM_US, _("Receiving"),
+ "connected-leechers", TRG_COLUMN_EXTRA);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO,
- TORRENT_COLUMN_FROMPEX, _("PEX Peers"),
- "from-pex", TRG_COLUMN_EXTRA);
+ TORRENT_COLUMN_PEERS_CONNECTED,
+ _("Connected"), "connected-peers", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO,
- TORRENT_COLUMN_FROMDHT, _("DHT Peers"),
- "from-dht", TRG_COLUMN_EXTRA);
+ TORRENT_COLUMN_FROMPEX, _("PEX Peers"),
+ "from-pex", TRG_COLUMN_EXTRA);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO,
- TORRENT_COLUMN_FROMTRACKERS, _("Tracker Peers"),
- "from-trackers", TRG_COLUMN_EXTRA);
+ TORRENT_COLUMN_FROMDHT, _("DHT Peers"),
+ "from-dht", TRG_COLUMN_EXTRA);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO,
- TORRENT_COLUMN_FROMLTEP, _("LTEP Peers"),
- "from-ltep", TRG_COLUMN_EXTRA);
+ TORRENT_COLUMN_FROMTRACKERS,
+ _("Tracker Peers"), "from-trackers",
+ TRG_COLUMN_EXTRA);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO,
- TORRENT_COLUMN_FROMRESUME, _("Resumed Peers"),
- "from-resume", TRG_COLUMN_EXTRA);
+ TORRENT_COLUMN_FROMLTEP, _("LTEP Peers"),
+ "from-ltep", TRG_COLUMN_EXTRA);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO,
- TORRENT_COLUMN_FROMINCOMING, _("Incoming Peers"),
- "from-incoming", TRG_COLUMN_EXTRA);
- trg_tree_view_reg_column(ttv, TRG_COLTYPE_TEXT, TORRENT_COLUMN_PEER_SOURCES,
- _("Peers T/I/E/H/X/L/R"), "peer-sources", TRG_COLUMN_EXTRA);
+ TORRENT_COLUMN_FROMRESUME, _("Resumed Peers"),
+ "from-resume", TRG_COLUMN_EXTRA);
+ trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO,
+ TORRENT_COLUMN_FROMINCOMING,
+ _("Incoming Peers"), "from-incoming",
+ TRG_COLUMN_EXTRA);
+ trg_tree_view_reg_column(ttv, TRG_COLTYPE_TEXT,
+ TORRENT_COLUMN_PEER_SOURCES,
+ _("Peers T/I/E/H/X/L/R"), "peer-sources",
+ TRG_COLUMN_EXTRA);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_SPEED,
- TORRENT_COLUMN_DOWNSPEED, _("Down Speed"),
- "down-speed", 0);
+ TORRENT_COLUMN_DOWNSPEED, _("Down Speed"),
+ "down-speed", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_SPEED,
- TORRENT_COLUMN_UPSPEED, _("Up Speed"),
- "up-speed", 0);
+ TORRENT_COLUMN_UPSPEED, _("Up Speed"),
+ "up-speed", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_ETA, TORRENT_COLUMN_ETA,
- _("ETA"), "eta", 0);
+ _("ETA"), "eta", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_SIZE,
- TORRENT_COLUMN_UPLOADED, _("Uploaded"),
- "uploaded", 0);
+ TORRENT_COLUMN_UPLOADED, _("Uploaded"),
+ "uploaded", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_SIZE,
- TORRENT_COLUMN_DOWNLOADED, _("Downloaded"),
- "downloaded", 0);
+ TORRENT_COLUMN_DOWNLOADED, _("Downloaded"),
+ "downloaded", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_RATIO, TORRENT_COLUMN_RATIO,
- _("Ratio"), "ratio", 0);
+ _("Ratio"), "ratio", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_EPOCH, TORRENT_COLUMN_ADDED,
- _("Added"), "added", 0);
+ _("Added"), "added", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_TEXT,
- TORRENT_COLUMN_TRACKERHOST, _("First Tracker"),
- "first-tracker", TRG_COLUMN_EXTRA);
+ TORRENT_COLUMN_TRACKERHOST,
+ _("First Tracker"), "first-tracker",
+ TRG_COLUMN_EXTRA);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_TEXT,
- TORRENT_COLUMN_DOWNLOADDIR, _("Location"),
- "download-dir", TRG_COLUMN_EXTRA);
+ TORRENT_COLUMN_DOWNLOADDIR, _("Location"),
+ "download-dir", TRG_COLUMN_EXTRA);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_TEXT, TORRENT_COLUMN_ID,
- _("ID"), "id", TRG_COLUMN_EXTRA);
+ _("ID"), "id", TRG_COLUMN_EXTRA);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_PRIO,
- TORRENT_COLUMN_BANDWIDTH_PRIORITY,
- _("Priority"), "priority", TRG_COLUMN_EXTRA);
+ TORRENT_COLUMN_BANDWIDTH_PRIORITY,
+ _("Priority"), "priority", TRG_COLUMN_EXTRA);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTEQZERO,
- TORRENT_COLUMN_QUEUE_POSITION,
- _("Queue Position"), "queue-position", TRG_COLUMN_EXTRA);
+ TORRENT_COLUMN_QUEUE_POSITION,
+ _("Queue Position"), "queue-position",
+ TRG_COLUMN_EXTRA);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_EPOCH,
- TORRENT_COLUMN_DONE_DATE, _("Completed"),
- "done-date", TRG_COLUMN_EXTRA);
+ TORRENT_COLUMN_DONE_DATE, _("Completed"),
+ "done-date", TRG_COLUMN_EXTRA);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_EPOCH,
- TORRENT_COLUMN_LASTACTIVE, _("Last Active"),
- "last-active", TRG_COLUMN_EXTRA);
+ TORRENT_COLUMN_LASTACTIVE, _("Last Active"),
+ "last-active", TRG_COLUMN_EXTRA);
gtk_tree_view_set_search_column(GTK_TREE_VIEW(tttv),
- TORRENT_COLUMN_NAME);
+ TORRENT_COLUMN_NAME);
}
static void
trg_torrent_model_get_json_id_array_foreach(GtkTreeModel * model,
- GtkTreePath *
- path G_GNUC_UNUSED,
- GtkTreeIter * iter,
- gpointer data)
+ GtkTreePath *
+ path G_GNUC_UNUSED,
+ GtkTreeIter * iter,
+ gpointer data)
{
JsonArray *output = (JsonArray *) data;
gint64 id;
@@ -148,18 +154,19 @@ trg_torrent_model_get_json_id_array_foreach(GtkTreeModel * model,
JsonArray *build_json_id_array(TrgTorrentTreeView * tv)
{
GtkTreeSelection *selection =
- gtk_tree_view_get_selection(GTK_TREE_VIEW(tv));
+ gtk_tree_view_get_selection(GTK_TREE_VIEW(tv));
JsonArray *ids = json_array_new();
gtk_tree_selection_selected_foreach(selection,
- (GtkTreeSelectionForeachFunc)
- trg_torrent_model_get_json_id_array_foreach,
- ids);
+ (GtkTreeSelectionForeachFunc)
+ trg_torrent_model_get_json_id_array_foreach,
+ ids);
return ids;
}
-TrgTorrentTreeView *trg_torrent_tree_view_new(TrgPrefs *prefs, GtkTreeModel * model)
+TrgTorrentTreeView *trg_torrent_tree_view_new(TrgPrefs * prefs,
+ GtkTreeModel * model)
{
GObject *obj = g_object_new(TRG_TYPE_TORRENT_TREE_VIEW, NULL);
diff --git a/src/trg-torrent-tree-view.h b/src/trg-torrent-tree-view.h
index 318afd0..42887ef 100644
--- a/src/trg-torrent-tree-view.h
+++ b/src/trg-torrent-tree-view.h
@@ -50,8 +50,9 @@ typedef struct {
GType trg_torrent_tree_view_get_type(void);
-TrgTorrentTreeView *trg_torrent_tree_view_new(TrgPrefs *prefs, GtkTreeModel * model);
+TrgTorrentTreeView *trg_torrent_tree_view_new(TrgPrefs * prefs,
+ GtkTreeModel * model);
JsonArray *build_json_id_array(TrgTorrentTreeView * tv);
G_END_DECLS
-#endif /* _TRG_TORRENT_TREE_VIEW_H_ */
+#endif /* _TRG_TORRENT_TREE_VIEW_H_ */
diff --git a/src/trg-trackers-model.c b/src/trg-trackers-model.c
index bfe8490..d86ed7a 100644
--- a/src/trg-trackers-model.c
+++ b/src/trg-trackers-model.c
@@ -49,8 +49,8 @@ gint64 trg_trackers_model_get_torrent_id(TrgTrackersModel * model)
}
void trg_trackers_model_update(TrgTrackersModel * model,
- gint64 updateSerial, JsonObject * t,
- gint mode)
+ gint64 updateSerial, JsonObject * t,
+ gint mode)
{
TrgTrackersModelPrivate *priv = TRG_TRACKERS_MODEL_GET_PRIVATE(model);
@@ -62,76 +62,93 @@ void trg_trackers_model_update(TrgTrackersModel * model,
const gchar *scrape;
if (mode == TORRENT_GET_MODE_FIRST) {
- gtk_list_store_clear(GTK_LIST_STORE(model));
- priv->torrentId = torrent_get_id(t);
- priv->accept = TRUE;
+ gtk_list_store_clear(GTK_LIST_STORE(model));
+ priv->torrentId = torrent_get_id(t);
+ priv->accept = TRUE;
} else if (!priv->accept) {
- return;
+ return;
}
trackers = json_array_get_elements(torrent_get_tracker_stats(t));
for (li = trackers; li; li = g_list_next(li)) {
- tracker = json_node_get_object((JsonNode *) li->data);
- trackerId = tracker_stats_get_id(tracker);
- announce = tracker_stats_get_announce(tracker);
- scrape = tracker_stats_get_scrape(tracker);
+ tracker = json_node_get_object((JsonNode *) li->data);
+ trackerId = tracker_stats_get_id(tracker);
+ announce = tracker_stats_get_announce(tracker);
+ scrape = tracker_stats_get_scrape(tracker);
- if (mode == TORRENT_GET_MODE_FIRST
- || find_existing_model_item(GTK_TREE_MODEL(model),
- TRACKERCOL_ID, trackerId,
- &trackIter) == FALSE)
- gtk_list_store_append(GTK_LIST_STORE(model), &trackIter);
+ if (mode == TORRENT_GET_MODE_FIRST
+ || find_existing_model_item(GTK_TREE_MODEL(model),
+ TRACKERCOL_ID, trackerId,
+ &trackIter) == FALSE)
+ gtk_list_store_append(GTK_LIST_STORE(model), &trackIter);
#ifdef DEBUG
- gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
- TRACKERCOL_ICON, GTK_STOCK_NETWORK, -1);
- gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
- TRACKERCOL_TIER, tracker_stats_get_tier(tracker), -1);
- gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
- TRACKERCOL_ANNOUNCE, announce, -1);
- gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
- TRACKERCOL_SCRAPE, scrape, -1);
- gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
- TRACKERCOL_ID, trackerId, -1);
- gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
- TRACKERCOL_UPDATESERIAL, updateSerial, -1);
- gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
- TRACKERCOL_LAST_ANNOUNCE_RESULT, tracker_stats_get_announce_result(tracker), -1);
- gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
- TRACKERCOL_LAST_ANNOUNCE_TIME, tracker_stats_get_last_announce_time(tracker), -1);
- gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
- TRACKERCOL_LAST_SCRAPE_TIME, tracker_stats_get_last_scrape_time(tracker), -1);
- gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
- TRACKERCOL_HOST, tracker_stats_get_host(tracker), -1);
- gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
- TRACKERCOL_LAST_ANNOUNCE_PEER_COUNT, tracker_stats_get_last_announce_peer_count(tracker), -1);
- gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
- TRACKERCOL_LEECHERCOUNT, tracker_stats_get_leecher_count(tracker), -1);
- gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
- TRACKERCOL_SEEDERCOUNT, tracker_stats_get_seeder_count(tracker), -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
+ TRACKERCOL_ICON, GTK_STOCK_NETWORK, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
+ TRACKERCOL_TIER,
+ tracker_stats_get_tier(tracker), -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
+ TRACKERCOL_ANNOUNCE, announce, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
+ TRACKERCOL_SCRAPE, scrape, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
+ TRACKERCOL_ID, trackerId, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
+ TRACKERCOL_UPDATESERIAL, updateSerial, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
+ TRACKERCOL_LAST_ANNOUNCE_RESULT,
+ tracker_stats_get_announce_result(tracker), -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
+ TRACKERCOL_LAST_ANNOUNCE_TIME,
+ tracker_stats_get_last_announce_time(tracker),
+ -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
+ TRACKERCOL_LAST_SCRAPE_TIME,
+ tracker_stats_get_last_scrape_time(tracker),
+ -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
+ TRACKERCOL_HOST,
+ tracker_stats_get_host(tracker), -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
+ TRACKERCOL_LAST_ANNOUNCE_PEER_COUNT,
+ tracker_stats_get_last_announce_peer_count
+ (tracker), -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
+ TRACKERCOL_LEECHERCOUNT,
+ tracker_stats_get_leecher_count(tracker), -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
+ TRACKERCOL_SEEDERCOUNT,
+ tracker_stats_get_seeder_count(tracker), -1);
#else
- gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
- TRACKERCOL_ICON, GTK_STOCK_NETWORK,
- TRACKERCOL_ID, trackerId,
- TRACKERCOL_UPDATESERIAL, updateSerial,
- TRACKERCOL_TIER, tracker_stats_get_tier(tracker),
- TRACKERCOL_ANNOUNCE, announce,
- TRACKERCOL_SCRAPE, scrape,
- TRACKERCOL_HOST, tracker_stats_get_host(tracker),
- TRACKERCOL_LAST_ANNOUNCE_RESULT, tracker_stats_get_announce_result(tracker),
- TRACKERCOL_LAST_ANNOUNCE_TIME, tracker_stats_get_last_announce_time(tracker),
- TRACKERCOL_LAST_SCRAPE_TIME, tracker_stats_get_last_scrape_time(tracker),
- TRACKERCOL_LAST_ANNOUNCE_PEER_COUNT, tracker_stats_get_last_announce_peer_count(tracker),
- TRACKERCOL_LEECHERCOUNT, tracker_stats_get_leecher_count(tracker),
- TRACKERCOL_SEEDERCOUNT, tracker_stats_get_seeder_count(tracker),
- -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &trackIter,
+ TRACKERCOL_ICON, GTK_STOCK_NETWORK,
+ TRACKERCOL_ID, trackerId,
+ TRACKERCOL_UPDATESERIAL, updateSerial,
+ TRACKERCOL_TIER,
+ tracker_stats_get_tier(tracker),
+ TRACKERCOL_ANNOUNCE, announce,
+ TRACKERCOL_SCRAPE, scrape, TRACKERCOL_HOST,
+ tracker_stats_get_host(tracker),
+ TRACKERCOL_LAST_ANNOUNCE_RESULT,
+ tracker_stats_get_announce_result(tracker),
+ TRACKERCOL_LAST_ANNOUNCE_TIME,
+ tracker_stats_get_last_announce_time(tracker),
+ TRACKERCOL_LAST_SCRAPE_TIME,
+ tracker_stats_get_last_scrape_time(tracker),
+ TRACKERCOL_LAST_ANNOUNCE_PEER_COUNT,
+ tracker_stats_get_last_announce_peer_count
+ (tracker), TRACKERCOL_LEECHERCOUNT,
+ tracker_stats_get_leecher_count(tracker),
+ TRACKERCOL_SEEDERCOUNT,
+ tracker_stats_get_seeder_count(tracker), -1);
#endif
}
g_list_free(trackers);
trg_model_remove_removed(GTK_LIST_STORE(model),
- TRACKERCOL_UPDATESERIAL, updateSerial);
+ TRACKERCOL_UPDATESERIAL, updateSerial);
}
static void trg_trackers_model_class_init(TrgTrackersModelClass * klass)
@@ -140,7 +157,7 @@ static void trg_trackers_model_class_init(TrgTrackersModelClass * klass)
}
void trg_trackers_model_set_accept(TrgTrackersModel * model,
- gboolean accept)
+ gboolean accept)
{
TrgTrackersModelPrivate *priv = TRG_TRACKERS_MODEL_GET_PRIVATE(model);
priv->accept = accept;
@@ -170,7 +187,7 @@ static void trg_trackers_model_init(TrgTrackersModel * self)
priv->torrentId = -1;
gtk_list_store_set_column_types(GTK_LIST_STORE(self),
- TRACKERCOL_COLUMNS, column_types);
+ TRACKERCOL_COLUMNS, column_types);
}
TrgTrackersModel *trg_trackers_model_new(void)
diff --git a/src/trg-trackers-model.h b/src/trg-trackers-model.h
index 391b137..20189ce 100644
--- a/src/trg-trackers-model.h
+++ b/src/trg-trackers-model.h
@@ -49,15 +49,14 @@ TrgTrackersModel *trg_trackers_model_new(void);
G_END_DECLS
void trg_trackers_model_update(TrgTrackersModel * model,
- gint64 updateSerial, JsonObject * t,
- gint mode);
+ gint64 updateSerial, JsonObject * t,
+ gint mode);
void trg_trackers_model_set_accept(TrgTrackersModel * model,
- gboolean accept);
+ gboolean accept);
gint64 trg_trackers_model_get_torrent_id(TrgTrackersModel * model);
void trg_trackers_model_set_no_selection(TrgTrackersModel * model);
-typedef enum
-{
+typedef enum {
/* we won't (announce,scrape) this torrent to this tracker because
* the torrent is stopped, or because of an error, or whatever */
TR_TRACKER_INACTIVE = 0,
@@ -72,8 +71,7 @@ typedef enum
/* we're (announcing,scraping) this torrent right now */
TR_TRACKER_ACTIVE = 3
-}
-tr_tracker_state;
+} tr_tracker_state;
enum {
/* trackers */
@@ -95,4 +93,4 @@ enum {
TRACKERCOL_COLUMNS
};
-#endif /* TRG_TRACKERS_MODEL_H_ */
+#endif /* TRG_TRACKERS_MODEL_H_ */
diff --git a/src/trg-trackers-tree-view.c b/src/trg-trackers-tree-view.c
index 3a902e3..2edf858 100644
--- a/src/trg-trackers-tree-view.c
+++ b/src/trg-trackers-tree-view.c
@@ -32,7 +32,7 @@
#include "trg-main-window.h"
G_DEFINE_TYPE(TrgTrackersTreeView, trg_trackers_tree_view,
- TRG_TYPE_TREE_VIEW)
+ TRG_TYPE_TREE_VIEW)
#define TRG_TRACKERS_TREE_VIEW_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_TRACKERS_TREE_VIEW, TrgTrackersTreeViewPrivate))
typedef struct _TrgTrackersTreeViewPrivate TrgTrackersTreeViewPrivate;
@@ -50,18 +50,18 @@ trg_trackers_tree_view_class_init(TrgTrackersTreeViewClass * klass)
g_type_class_add_private(klass, sizeof(TrgTrackersTreeViewPrivate));
}
-static gboolean is_tracker_edit_supported(TrgClient *tc)
+static gboolean is_tracker_edit_supported(TrgClient * tc)
{
return trg_client_get_rpc_version(tc) >= 10;
}
-static gboolean
-on_trackers_update(gpointer data)
+static gboolean on_trackers_update(gpointer data)
{
- trg_response *response = (trg_response*)data;
+ trg_response *response = (trg_response *) data;
TrgTrackersTreeViewPrivate *priv =
- TRG_TRACKERS_TREE_VIEW_GET_PRIVATE(response->cb_data);
- GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(response->cb_data));
+ TRG_TRACKERS_TREE_VIEW_GET_PRIVATE(response->cb_data);
+ GtkTreeModel *model =
+ gtk_tree_view_get_model(GTK_TREE_VIEW(response->cb_data));
trg_trackers_model_set_accept(TRG_TRACKERS_MODEL(model), TRUE);
@@ -70,30 +70,30 @@ on_trackers_update(gpointer data)
}
void trg_trackers_tree_view_new_connection(TrgTrackersTreeView * tv,
- TrgClient * tc)
+ TrgClient * tc)
{
TrgTrackersTreeViewPrivate *priv =
- TRG_TRACKERS_TREE_VIEW_GET_PRIVATE(tv);
+ TRG_TRACKERS_TREE_VIEW_GET_PRIVATE(tv);
gboolean editable = is_tracker_edit_supported(tc);
g_object_set(priv->announceRenderer, "editable", editable, NULL);
g_object_set(priv->announceRenderer, "mode",
- editable ? GTK_CELL_RENDERER_MODE_EDITABLE :
- GTK_CELL_RENDERER_MODE_INERT, NULL);
+ editable ? GTK_CELL_RENDERER_MODE_EDITABLE :
+ GTK_CELL_RENDERER_MODE_INERT, NULL);
}
static void trg_tracker_announce_edited(GtkCellRendererText * renderer,
- gchar * path,
- gchar * new_text,
- gpointer user_data)
+ gchar * path,
+ gchar * new_text,
+ gpointer user_data)
{
TrgTrackersTreeViewPrivate *priv =
- TRG_TRACKERS_TREE_VIEW_GET_PRIVATE(user_data);
+ TRG_TRACKERS_TREE_VIEW_GET_PRIVATE(user_data);
GtkTreeModel *model =
- gtk_tree_view_get_model(GTK_TREE_VIEW(user_data));
+ gtk_tree_view_get_model(GTK_TREE_VIEW(user_data));
gint64 torrentId =
- trg_trackers_model_get_torrent_id(TRG_TRACKERS_MODEL(model));
+ trg_trackers_model_get_torrent_id(TRG_TRACKERS_MODEL(model));
JsonArray *torrentIds = json_array_new();
JsonArray *trackerModifiers = json_array_new();
@@ -105,9 +105,9 @@ static void trg_tracker_announce_edited(GtkCellRendererText * renderer,
gtk_tree_model_get_iter_from_string(model, &iter, path);
gtk_list_store_set(GTK_LIST_STORE(model), &iter, TRACKERCOL_ANNOUNCE,
- new_text, -1);
+ new_text, -1);
gtk_tree_model_get(model, &iter, TRACKERCOL_ID, &trackerId,
- TRACKERCOL_ICON, &icon, -1);
+ TRACKERCOL_ICON, &icon, -1);
json_array_add_int_element(torrentIds, torrentId);
@@ -116,13 +116,13 @@ static void trg_tracker_announce_edited(GtkCellRendererText * renderer,
args = node_get_arguments(req);
if (!g_strcmp0(icon, GTK_STOCK_ADD)) {
- json_array_add_string_element(trackerModifiers, new_text);
- json_object_set_array_member(args, "trackerAdd", trackerModifiers);
+ json_array_add_string_element(trackerModifiers, new_text);
+ json_object_set_array_member(args, "trackerAdd", trackerModifiers);
} else {
- json_array_add_int_element(trackerModifiers, trackerId);
- json_array_add_string_element(trackerModifiers, new_text);
- json_object_set_array_member(args, "trackerReplace",
- trackerModifiers);
+ json_array_add_int_element(trackerModifiers, trackerId);
+ json_array_add_string_element(trackerModifiers, new_text);
+ json_object_set_array_member(args, "trackerReplace",
+ trackerModifiers);
}
g_free(icon);
@@ -131,26 +131,26 @@ static void trg_tracker_announce_edited(GtkCellRendererText * renderer,
}
static void trg_tracker_announce_editing_started(GtkCellRenderer *
- renderer G_GNUC_UNUSED,
- GtkCellEditable *
- editable G_GNUC_UNUSED,
- gchar *
- path G_GNUC_UNUSED,
- gpointer user_data)
+ renderer G_GNUC_UNUSED,
+ GtkCellEditable *
+ editable G_GNUC_UNUSED,
+ gchar *
+ path G_GNUC_UNUSED,
+ gpointer user_data)
{
TrgTrackersModel *model =
- TRG_TRACKERS_MODEL(gtk_tree_view_get_model
- (GTK_TREE_VIEW(user_data)));
+ TRG_TRACKERS_MODEL(gtk_tree_view_get_model
+ (GTK_TREE_VIEW(user_data)));
trg_trackers_model_set_accept(model, FALSE);
}
static void trg_tracker_announce_editing_canceled(GtkWidget *
- w G_GNUC_UNUSED,
- gpointer data)
+ w G_GNUC_UNUSED,
+ gpointer data)
{
TrgTrackersModel *model =
- TRG_TRACKERS_MODEL(gtk_tree_view_get_model(GTK_TREE_VIEW(data)));
+ TRG_TRACKERS_MODEL(gtk_tree_view_get_model(GTK_TREE_VIEW(data)));
trg_trackers_model_set_accept(model, TRUE);
}
@@ -158,62 +158,68 @@ static void trg_tracker_announce_editing_canceled(GtkWidget *
static void trg_trackers_tree_view_init(TrgTrackersTreeView * self)
{
TrgTrackersTreeViewPrivate *priv =
- TRG_TRACKERS_TREE_VIEW_GET_PRIVATE(self);
+ TRG_TRACKERS_TREE_VIEW_GET_PRIVATE(self);
TrgTreeView *ttv = TRG_TREE_VIEW(self);
trg_column_description *desc;
desc =
- trg_tree_view_reg_column(ttv, TRG_COLTYPE_STOCKICONTEXT,
- TRACKERCOL_TIER, _("Tier"), "tier",
- TRG_COLUMN_UNREMOVABLE);
+ trg_tree_view_reg_column(ttv, TRG_COLTYPE_STOCKICONTEXT,
+ TRACKERCOL_TIER, _("Tier"), "tier",
+ TRG_COLUMN_UNREMOVABLE);
desc->model_column_icon = TRACKERCOL_ICON;
desc =
- trg_tree_view_reg_column(ttv, TRG_COLTYPE_TEXT,
- TRACKERCOL_ANNOUNCE, _("Announce URL"),
- "announce-url", TRG_COLUMN_UNREMOVABLE);
+ trg_tree_view_reg_column(ttv, TRG_COLTYPE_TEXT,
+ TRACKERCOL_ANNOUNCE, _("Announce URL"),
+ "announce-url", TRG_COLUMN_UNREMOVABLE);
priv->announceRenderer = desc->customRenderer =
- gtk_cell_renderer_text_new();
+ gtk_cell_renderer_text_new();
g_signal_connect(priv->announceRenderer, "edited",
- G_CALLBACK(trg_tracker_announce_edited), self);
+ G_CALLBACK(trg_tracker_announce_edited), self);
g_signal_connect(priv->announceRenderer, "editing-canceled",
- G_CALLBACK(trg_tracker_announce_editing_canceled),
- self);
+ G_CALLBACK(trg_tracker_announce_editing_canceled),
+ self);
g_signal_connect(priv->announceRenderer, "editing-started",
- G_CALLBACK(trg_tracker_announce_editing_started),
- self);
+ G_CALLBACK(trg_tracker_announce_editing_started),
+ self);
desc->out = &priv->announceColumn;
- trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO, TRACKERCOL_LAST_ANNOUNCE_PEER_COUNT,
- _("Peers"), "last-announce-peer-count", 0);
- trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO, TRACKERCOL_SEEDERCOUNT,
- _("Seeder Count"), "seeder-count", 0);
- trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO, TRACKERCOL_LEECHERCOUNT,
- _("Leecher Count"), "leecher-count", 0);
- trg_tree_view_reg_column(ttv, TRG_COLTYPE_EPOCH, TRACKERCOL_LAST_ANNOUNCE_TIME,
- _("Last Announce"), "last-announce-time", 0);
- trg_tree_view_reg_column(ttv, TRG_COLTYPE_TEXT, TRACKERCOL_LAST_ANNOUNCE_RESULT,
- _("Last Result"), "last-result", 0);
+ trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO,
+ TRACKERCOL_LAST_ANNOUNCE_PEER_COUNT,
+ _("Peers"), "last-announce-peer-count", 0);
+ trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO,
+ TRACKERCOL_SEEDERCOUNT, _("Seeder Count"),
+ "seeder-count", 0);
+ trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO,
+ TRACKERCOL_LEECHERCOUNT, _("Leecher Count"),
+ "leecher-count", 0);
+ trg_tree_view_reg_column(ttv, TRG_COLTYPE_EPOCH,
+ TRACKERCOL_LAST_ANNOUNCE_TIME,
+ _("Last Announce"), "last-announce-time", 0);
+ trg_tree_view_reg_column(ttv, TRG_COLTYPE_TEXT,
+ TRACKERCOL_LAST_ANNOUNCE_RESULT,
+ _("Last Result"), "last-result", 0);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_TEXT, TRACKERCOL_SCRAPE,
- _("Scrape URL"), "scrape-url", 0);
- trg_tree_view_reg_column(ttv, TRG_COLTYPE_EPOCH, TRACKERCOL_LAST_SCRAPE_TIME,
- _("Last Scrape"), "last-scrape-time", TRG_COLUMN_EXTRA);
+ _("Scrape URL"), "scrape-url", 0);
+ trg_tree_view_reg_column(ttv, TRG_COLTYPE_EPOCH,
+ TRACKERCOL_LAST_SCRAPE_TIME, _("Last Scrape"),
+ "last-scrape-time", TRG_COLUMN_EXTRA);
trg_tree_view_reg_column(ttv, TRG_COLTYPE_TEXT, TRACKERCOL_HOST,
- _("Host"), "host", TRG_COLUMN_EXTRA);
+ _("Host"), "host", TRG_COLUMN_EXTRA);
}
static void add_tracker(GtkWidget * w, gpointer data)
{
GtkTreeView *tv = GTK_TREE_VIEW(data);
TrgTrackersTreeViewPrivate *priv =
- TRG_TRACKERS_TREE_VIEW_GET_PRIVATE(data);
+ TRG_TRACKERS_TREE_VIEW_GET_PRIVATE(data);
GtkTreeModel *model = gtk_tree_view_get_model(tv);
GtkTreeIter iter;
GtkTreePath *path;
gtk_list_store_append(GTK_LIST_STORE(model), &iter);
gtk_list_store_set(GTK_LIST_STORE(model), &iter, TRACKERCOL_ICON,
- GTK_STOCK_ADD, -1);
+ GTK_STOCK_ADD, -1);
path = gtk_tree_model_get_path(model, &iter);
gtk_tree_view_set_cursor(tv, path, priv->announceColumn, TRUE);
@@ -223,13 +229,13 @@ static void add_tracker(GtkWidget * w, gpointer data)
static void delete_tracker(GtkWidget * w, gpointer data)
{
TrgTrackersTreeViewPrivate *priv =
- TRG_TRACKERS_TREE_VIEW_GET_PRIVATE(data);
+ TRG_TRACKERS_TREE_VIEW_GET_PRIVATE(data);
GtkTreeView *tv = GTK_TREE_VIEW(data);
GList *selectionRefs = trg_tree_view_get_selected_refs_list(tv);
GtkTreeModel *model = gtk_tree_view_get_model(tv);
JsonArray *trackerIds = json_array_new();
gint64 torrentId =
- trg_trackers_model_get_torrent_id(TRG_TRACKERS_MODEL(model));
+ trg_trackers_model_get_torrent_id(TRG_TRACKERS_MODEL(model));
JsonArray *torrentIds = json_array_new();
JsonNode *req;
@@ -237,19 +243,19 @@ static void delete_tracker(GtkWidget * w, gpointer data)
GList *li;
for (li = selectionRefs; li; li = g_list_next(li)) {
- GtkTreeRowReference *rr = (GtkTreeRowReference *) li->data;
- GtkTreePath *path = gtk_tree_row_reference_get_path(rr);
- if (path) {
- gint64 trackerId;
- GtkTreeIter trackerIter;
- gtk_tree_model_get_iter(model, &trackerIter, path);
- gtk_tree_model_get(model, &trackerIter, TRACKERCOL_ID,
- &trackerId, -1);
- json_array_add_int_element(trackerIds, trackerId);
- gtk_list_store_remove(GTK_LIST_STORE(model), &trackerIter);
- gtk_tree_path_free(path);
- }
- gtk_tree_row_reference_free(rr);
+ GtkTreeRowReference *rr = (GtkTreeRowReference *) li->data;
+ GtkTreePath *path = gtk_tree_row_reference_get_path(rr);
+ if (path) {
+ gint64 trackerId;
+ GtkTreeIter trackerIter;
+ gtk_tree_model_get_iter(model, &trackerIter, path);
+ gtk_tree_model_get(model, &trackerIter, TRACKERCOL_ID,
+ &trackerId, -1);
+ json_array_add_int_element(trackerIds, trackerId);
+ gtk_list_store_remove(GTK_LIST_STORE(model), &trackerIter);
+ gtk_tree_path_free(path);
+ }
+ gtk_tree_row_reference_free(rr);
}
g_list_free(selectionRefs);
@@ -268,85 +274,85 @@ static void delete_tracker(GtkWidget * w, gpointer data)
static void
view_popup_menu_add_only(GtkWidget * treeview, GdkEventButton * event,
- gpointer data G_GNUC_UNUSED)
+ gpointer data G_GNUC_UNUSED)
{
GtkWidget *menu, *menuitem;
menu = gtk_menu_new();
menuitem =
- trg_menu_bar_item_new(GTK_MENU_SHELL(menu), _("Add"),
- GTK_STOCK_ADD, TRUE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(menu), _("Add"),
+ GTK_STOCK_ADD, TRUE);
g_signal_connect(menuitem, "activate", G_CALLBACK(add_tracker),
- treeview);
+ treeview);
gtk_widget_show_all(menu);
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
- (event != NULL) ? event->button : 0,
- gdk_event_get_time((GdkEvent *) event));
+ (event != NULL) ? event->button : 0,
+ gdk_event_get_time((GdkEvent *) event));
}
static void
view_popup_menu(GtkWidget * treeview, GdkEventButton * event,
- gpointer data G_GNUC_UNUSED)
+ gpointer data G_GNUC_UNUSED)
{
GtkWidget *menu, *menuitem;
menu = gtk_menu_new();
menuitem =
- trg_menu_bar_item_new(GTK_MENU_SHELL(menu), _("Delete"),
- GTK_STOCK_DELETE, TRUE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(menu), _("Delete"),
+ GTK_STOCK_DELETE, TRUE);
g_signal_connect(menuitem, "activate", G_CALLBACK(delete_tracker),
- treeview);
+ treeview);
menuitem =
- trg_menu_bar_item_new(GTK_MENU_SHELL(menu), _("Add"),
- GTK_STOCK_ADD, TRUE);
+ trg_menu_bar_item_new(GTK_MENU_SHELL(menu), _("Add"),
+ GTK_STOCK_ADD, TRUE);
g_signal_connect(menuitem, "activate", G_CALLBACK(add_tracker),
- treeview);
+ treeview);
gtk_widget_show_all(menu);
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
- (event != NULL) ? event->button : 0,
- gdk_event_get_time((GdkEvent *) event));
+ (event != NULL) ? event->button : 0,
+ gdk_event_get_time((GdkEvent *) event));
}
static gboolean
view_onButtonPressed(GtkWidget * treeview, GdkEventButton * event,
- gpointer userdata)
+ gpointer userdata)
{
TrgTrackersTreeViewPrivate *priv =
- TRG_TRACKERS_TREE_VIEW_GET_PRIVATE(treeview);
+ TRG_TRACKERS_TREE_VIEW_GET_PRIVATE(treeview);
TrgTrackersModel *model =
- TRG_TRACKERS_MODEL(gtk_tree_view_get_model
- (GTK_TREE_VIEW(treeview)));
+ TRG_TRACKERS_MODEL(gtk_tree_view_get_model
+ (GTK_TREE_VIEW(treeview)));
GtkTreeSelection *selection;
GtkTreePath *path;
if (!is_tracker_edit_supported(priv->client))
- return FALSE;
+ return FALSE;
if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
-
- if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview),
- (gint) event->x,
- (gint) event->y, &path,
- NULL, NULL, NULL)) {
- if (!gtk_tree_selection_path_is_selected(selection, path)) {
- gtk_tree_selection_unselect_all(selection);
- gtk_tree_selection_select_path(selection, path);
- }
- gtk_tree_path_free(path);
-
- view_popup_menu(treeview, event, userdata);
- } else if (trg_trackers_model_get_torrent_id(model) >= 0) {
- view_popup_menu_add_only(treeview, event, userdata);
- }
- return TRUE;
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
+
+ if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview),
+ (gint) event->x,
+ (gint) event->y, &path,
+ NULL, NULL, NULL)) {
+ if (!gtk_tree_selection_path_is_selected(selection, path)) {
+ gtk_tree_selection_unselect_all(selection);
+ gtk_tree_selection_select_path(selection, path);
+ }
+ gtk_tree_path_free(path);
+
+ view_popup_menu(treeview, event, userdata);
+ } else if (trg_trackers_model_get_torrent_id(model) >= 0) {
+ view_popup_menu_add_only(treeview, event, userdata);
+ }
+ return TRUE;
}
return FALSE;
@@ -359,19 +365,20 @@ static gboolean view_onPopupMenu(GtkWidget * treeview, gpointer userdata)
}
TrgTrackersTreeView *trg_trackers_tree_view_new(TrgTrackersModel * model,
- TrgClient * client,
- TrgMainWindow * win)
+ TrgClient * client,
+ TrgMainWindow * win)
{
GObject *obj = g_object_new(TRG_TYPE_TRACKERS_TREE_VIEW, NULL);
TrgTrackersTreeViewPrivate *priv =
- TRG_TRACKERS_TREE_VIEW_GET_PRIVATE(obj);
+ TRG_TRACKERS_TREE_VIEW_GET_PRIVATE(obj);
- trg_tree_view_set_prefs(TRG_TREE_VIEW(obj), trg_client_get_prefs(client));
+ trg_tree_view_set_prefs(TRG_TREE_VIEW(obj),
+ trg_client_get_prefs(client));
g_signal_connect(obj, "button-press-event",
- G_CALLBACK(view_onButtonPressed), NULL);
+ G_CALLBACK(view_onButtonPressed), NULL);
g_signal_connect(obj, "popup-menu", G_CALLBACK(view_onPopupMenu),
- NULL);
+ NULL);
gtk_tree_view_set_model(GTK_TREE_VIEW(obj), GTK_TREE_MODEL(model));
priv->client = client;
diff --git a/src/trg-trackers-tree-view.h b/src/trg-trackers-tree-view.h
index c98a472..d6a4942 100644
--- a/src/trg-trackers-tree-view.h
+++ b/src/trg-trackers-tree-view.h
@@ -51,10 +51,10 @@ typedef struct {
GType trg_trackers_tree_view_get_type(void);
TrgTrackersTreeView *trg_trackers_tree_view_new(TrgTrackersModel * model,
- TrgClient * client,
- TrgMainWindow * win);
+ TrgClient * client,
+ TrgMainWindow * win);
void trg_trackers_tree_view_new_connection(TrgTrackersTreeView * tv,
- TrgClient * tc);
+ TrgClient * tc);
G_END_DECLS
-#endif /* TRG_TRACKERS_TREE_VIEW_H_ */
+#endif /* TRG_TRACKERS_TREE_VIEW_H_ */
diff --git a/src/trg-tree-view.c b/src/trg-tree-view.c
index f4dae36..26c90cd 100644
--- a/src/trg-tree-view.c
+++ b/src/trg-tree-view.c
@@ -57,52 +57,60 @@ struct _TrgTreeViewPrivate {
TrgPrefs *prefs;
};
-gboolean trg_tree_view_is_column_showing(TrgTreeView *tv, gint index) {
+gboolean trg_tree_view_is_column_showing(TrgTreeView * tv, gint index)
+{
TrgTreeViewPrivate *priv = TRG_TREE_VIEW_GET_PRIVATE(tv);
GList *li;
for (li = priv->columns; li; li = g_list_next(li)) {
- trg_column_description *cd = (trg_column_description*) li->data;
- if (cd->model_column == index) {
- if (cd->flags & TRG_COLUMN_SHOWING
- )
- return TRUE;
- else
- break;
- }
+ trg_column_description *cd = (trg_column_description *) li->data;
+ if (cd->model_column == index) {
+ if (cd->flags & TRG_COLUMN_SHOWING)
+ return TRUE;
+ else
+ break;
+ }
}
return FALSE;
}
static void trg_tree_view_get_property(GObject * object, guint property_id,
- GValue * value, GParamSpec * pspec) {
+ GValue * value, GParamSpec * pspec)
+{
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
}
static void trg_tree_view_set_property(GObject * object, guint property_id,
- const GValue * value, GParamSpec * pspec) {
+ const GValue * value,
+ GParamSpec * pspec)
+{
TrgTreeViewPrivate *priv = TRG_TREE_VIEW_GET_PRIVATE(object);
switch (property_id) {
case PROP_PREFS:
- priv->prefs = g_value_get_object(value);
- break;
+ priv->prefs = g_value_get_object(value);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
static GObject *trg_tree_view_constructor(GType type,
- guint n_construct_properties, GObjectConstructParam * construct_params) {
+ guint n_construct_properties,
+ GObjectConstructParam *
+ construct_params)
+{
GObject *obj = G_OBJECT_CLASS
- (trg_tree_view_parent_class)->constructor(type,
- n_construct_properties, construct_params);
+ (trg_tree_view_parent_class)->constructor(type,
+ n_construct_properties,
+ construct_params);
return obj;
}
-static JsonObject* trg_prefs_get_tree_view_props(TrgTreeView *tv) {
+static JsonObject *trg_prefs_get_tree_view_props(TrgTreeView * tv)
+{
TrgTreeViewPrivate *priv = TRG_TREE_VIEW_GET_PRIVATE(tv);
JsonObject *root = trg_prefs_get_root(priv->prefs);
const gchar *className = G_OBJECT_TYPE_NAME(tv);
@@ -110,28 +118,34 @@ static JsonObject* trg_prefs_get_tree_view_props(TrgTreeView *tv) {
JsonObject *tvProps = NULL;
if (!json_object_has_member(root, TRG_PREFS_KEY_TREE_VIEWS)) {
- obj = json_object_new();
- json_object_set_object_member(root, TRG_PREFS_KEY_TREE_VIEWS, obj);
+ obj = json_object_new();
+ json_object_set_object_member(root, TRG_PREFS_KEY_TREE_VIEWS, obj);
} else {
- obj = json_object_get_object_member(root, TRG_PREFS_KEY_TREE_VIEWS);
+ obj =
+ json_object_get_object_member(root, TRG_PREFS_KEY_TREE_VIEWS);
}
if (!json_object_has_member(obj, className)) {
- tvProps = json_object_new();
- json_object_set_object_member(obj, className, tvProps);
+ tvProps = json_object_new();
+ json_object_set_object_member(obj, className, tvProps);
} else {
- tvProps = json_object_get_object_member(obj, className);
+ tvProps = json_object_get_object_member(obj, className);
}
return tvProps;
}
static void trg_tree_view_add_column_after(TrgTreeView * tv,
- trg_column_description * desc, gint64 width,
- GtkTreeViewColumn * after_col);
-
-trg_column_description *trg_tree_view_reg_column(TrgTreeView * tv, gint type,
- gint model_column, gchar * header, gchar * id, gint flags) {
+ trg_column_description * desc,
+ gint64 width,
+ GtkTreeViewColumn * after_col);
+
+trg_column_description *trg_tree_view_reg_column(TrgTreeView * tv,
+ gint type,
+ gint model_column,
+ gchar * header,
+ gchar * id, gint flags)
+{
TrgTreeViewPrivate *priv = TRG_TREE_VIEW_GET_PRIVATE(tv);
trg_column_description *desc = g_new0(trg_column_description, 1);
@@ -147,43 +161,51 @@ trg_column_description *trg_tree_view_reg_column(TrgTreeView * tv, gint type,
}
static trg_column_description *trg_tree_view_find_column(TrgTreeView * tv,
- const gchar * id) {
+ const gchar * id)
+{
TrgTreeViewPrivate *priv = TRG_TREE_VIEW_GET_PRIVATE(tv);
GList *li;
trg_column_description *desc;
for (li = priv->columns; li; li = g_list_next(li)) {
- desc = (trg_column_description *) li->data;
- if (!g_strcmp0(desc->id, id))
- return desc;
+ desc = (trg_column_description *) li->data;
+ if (!g_strcmp0(desc->id, id))
+ return desc;
}
return NULL;
}
-static void trg_tree_view_hide_column(GtkWidget * w, GtkTreeViewColumn * col) {
+static void trg_tree_view_hide_column(GtkWidget * w,
+ GtkTreeViewColumn * col)
+{
trg_column_description *desc = g_object_get_data(G_OBJECT(col),
- "column-desc");
+ "column-desc");
GtkWidget *tv = gtk_tree_view_column_get_tree_view(col);
desc->flags &= ~TRG_COLUMN_SHOWING;
gtk_tree_view_remove_column(GTK_TREE_VIEW(tv), col);
}
static void trg_tree_view_add_column(TrgTreeView * tv,
- trg_column_description * desc, gint64 width) {
+ trg_column_description * desc,
+ gint64 width)
+{
trg_tree_view_add_column_after(tv, desc, width, NULL);
}
static void trg_tree_view_user_add_column_cb(GtkWidget * w,
- trg_column_description * desc) {
+ trg_column_description * desc)
+{
GtkTreeViewColumn *col = g_object_get_data(G_OBJECT(w), "parent-col");
- TrgTreeView *tv = TRG_TREE_VIEW(gtk_tree_view_column_get_tree_view(col));
+ TrgTreeView *tv =
+ TRG_TREE_VIEW(gtk_tree_view_column_get_tree_view(col));
trg_tree_view_add_column_after(tv, desc, -1, col);
}
static void view_popup_menu(GtkButton * button, GdkEventButton * event,
- GtkTreeViewColumn * column) {
+ GtkTreeViewColumn * column)
+{
GtkWidget *tv = gtk_tree_view_column_get_tree_view(column);
TrgTreeViewPrivate *priv = TRG_TREE_VIEW_GET_PRIVATE(tv);
GtkWidget *menu, *menuitem;
@@ -196,130 +218,179 @@ static void view_popup_menu(GtkButton * button, GdkEventButton * event,
menuitem = gtk_check_menu_item_new_with_label(desc->header);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
g_signal_connect(menuitem, "activate",
- G_CALLBACK(trg_tree_view_hide_column), column);
- gtk_widget_set_sensitive(menuitem, !(desc->flags & TRG_COLUMN_UNREMOVABLE));
+ G_CALLBACK(trg_tree_view_hide_column), column);
+ gtk_widget_set_sensitive(menuitem,
+ !(desc->flags & TRG_COLUMN_UNREMOVABLE));
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
for (li = priv->columns; li; li = g_list_next(li)) {
- trg_column_description *desc = (trg_column_description *) li->data;
- if (!(desc->flags & TRG_COLUMN_SHOWING)) {
- menuitem = gtk_check_menu_item_new_with_label(desc->header);
- g_object_set_data(G_OBJECT(menuitem), "parent-col", column);
- g_signal_connect(menuitem, "activate",
- G_CALLBACK(trg_tree_view_user_add_column_cb), desc);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
- }
+ trg_column_description *desc = (trg_column_description *) li->data;
+ if (!(desc->flags & TRG_COLUMN_SHOWING)) {
+ menuitem = gtk_check_menu_item_new_with_label(desc->header);
+ g_object_set_data(G_OBJECT(menuitem), "parent-col", column);
+ g_signal_connect(menuitem, "activate",
+ G_CALLBACK(trg_tree_view_user_add_column_cb),
+ desc);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
+ }
}
gtk_widget_show_all(menu);
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
- (event != NULL) ? event->button : 0,
- gdk_event_get_time((GdkEvent *) event));
- }
+ (event != NULL) ? event->button : 0,
+ gdk_event_get_time((GdkEvent *) event));
+}
-static gboolean col_onButtonPressed(GtkButton * button, GdkEventButton * event,
- GtkTreeViewColumn * col) {
+static gboolean col_onButtonPressed(GtkButton * button,
+ GdkEventButton * event,
+ GtkTreeViewColumn * col)
+{
if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
- view_popup_menu(button, event, col);
- return TRUE;
+ view_popup_menu(button, event, col);
+ return TRUE;
}
return FALSE;
}
-static GtkTreeViewColumn *trg_tree_view_icontext_column_new(
- trg_column_description *desc, gchar *renderer_property) {
+static GtkTreeViewColumn
+ *trg_tree_view_icontext_column_new(trg_column_description * desc,
+ gchar * renderer_property)
+{
GtkTreeViewColumn *column = gtk_tree_view_column_new();
GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_set_title(column, desc->header);
gtk_tree_view_column_pack_start(column, renderer, FALSE);
- gtk_tree_view_column_set_attributes(column, renderer, renderer_property,
- desc->model_column_icon, NULL);
+ gtk_tree_view_column_set_attributes(column, renderer,
+ renderer_property,
+ desc->model_column_icon, NULL);
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(column, renderer, TRUE);
gtk_tree_view_column_set_attributes(column, renderer, "text",
- desc->model_column, NULL);
+ desc->model_column, NULL);
return column;
}
static void trg_tree_view_add_column_after(TrgTreeView * tv,
- trg_column_description * desc, gint64 width,
- GtkTreeViewColumn * after_col) {
+ trg_column_description * desc,
+ gint64 width,
+ GtkTreeViewColumn * after_col)
+{
GtkCellRenderer *renderer;
GtkTreeViewColumn *column = NULL;
switch (desc->type) {
case TRG_COLTYPE_TEXT:
- renderer =
- desc->customRenderer ? desc->customRenderer :
- gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "text", desc->model_column, NULL);
-
- break;
+ renderer =
+ desc->customRenderer ? desc->customRenderer :
+ gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer, "text",
+ desc->
+ model_column,
+ NULL);
+
+ break;
case TRG_COLTYPE_SPEED:
- renderer = trg_cell_renderer_speed_new();
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "speed-value", desc->model_column, NULL);
- break;
+ renderer = trg_cell_renderer_speed_new();
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer,
+ "speed-value",
+ desc->
+ model_column,
+ NULL);
+ break;
case TRG_COLTYPE_EPOCH:
- renderer = trg_cell_renderer_epoch_new();
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "epoch-value", desc->model_column, NULL);
- break;
+ renderer = trg_cell_renderer_epoch_new();
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer,
+ "epoch-value",
+ desc->
+ model_column,
+ NULL);
+ break;
case TRG_COLTYPE_ETA:
- renderer = trg_cell_renderer_eta_new();
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "eta-value", desc->model_column, NULL);
- break;
+ renderer = trg_cell_renderer_eta_new();
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer,
+ "eta-value",
+ desc->
+ model_column,
+ NULL);
+ break;
case TRG_COLTYPE_SIZE:
- renderer = trg_cell_renderer_size_new();
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "size-value", desc->model_column, NULL);
- break;
+ renderer = trg_cell_renderer_size_new();
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer,
+ "size-value",
+ desc->
+ model_column,
+ NULL);
+ break;
case TRG_COLTYPE_PROG:
- renderer = gtk_cell_renderer_progress_new();
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "value", desc->model_column, NULL);
- break;
+ renderer = gtk_cell_renderer_progress_new();
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer,
+ "value",
+ desc->
+ model_column,
+ NULL);
+ break;
case TRG_COLTYPE_RATIO:
- renderer = trg_cell_renderer_ratio_new();
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "ratio-value", desc->model_column, NULL);
- break;
+ renderer = trg_cell_renderer_ratio_new();
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer,
+ "ratio-value",
+ desc->
+ model_column,
+ NULL);
+ break;
case TRG_COLTYPE_ICON:
- column = gtk_tree_view_column_new();
- renderer = gtk_cell_renderer_pixbuf_new();
- gtk_cell_renderer_set_alignment(GTK_CELL_RENDERER(renderer), 0.5f, 0.0);
- gtk_tree_view_column_set_title(column, desc->header);
- gtk_tree_view_column_pack_start(column, renderer, TRUE);
- gtk_tree_view_column_set_attributes(column, renderer, "stock-id",
- desc->model_column, NULL);
- break;
+ column = gtk_tree_view_column_new();
+ renderer = gtk_cell_renderer_pixbuf_new();
+ gtk_cell_renderer_set_alignment(GTK_CELL_RENDERER(renderer), 0.5f,
+ 0.0);
+ gtk_tree_view_column_set_title(column, desc->header);
+ gtk_tree_view_column_pack_start(column, renderer, TRUE);
+ gtk_tree_view_column_set_attributes(column, renderer, "stock-id",
+ desc->model_column, NULL);
+ break;
case TRG_COLTYPE_STOCKICONTEXT:
- column = trg_tree_view_icontext_column_new(desc, "stock-id");
- break;
+ column = trg_tree_view_icontext_column_new(desc, "stock-id");
+ break;
case TRG_COLTYPE_GICONTEXT:
- column = trg_tree_view_icontext_column_new(desc, "gicon");
- break;
+ column = trg_tree_view_icontext_column_new(desc, "gicon");
+ break;
case TRG_COLTYPE_PRIO:
- renderer = trg_cell_renderer_priority_new();
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "priority-value", desc->model_column, NULL);
- break;
+ renderer = trg_cell_renderer_priority_new();
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer,
+ "priority-value",
+ desc->
+ model_column,
+ NULL);
+ break;
case TRG_COLTYPE_NUMGTZERO:
- renderer = trg_cell_renderer_numgteqthan_new(1);
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "value", desc->model_column, NULL);
- break;
+ renderer = trg_cell_renderer_numgteqthan_new(1);
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer,
+ "value",
+ desc->
+ model_column,
+ NULL);
+ break;
case TRG_COLTYPE_NUMGTEQZERO:
- renderer = trg_cell_renderer_numgteqthan_new(0);
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "value", desc->model_column, NULL);
- break;
+ renderer = trg_cell_renderer_numgteqthan_new(0);
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer,
+ "value",
+ desc->
+ model_column,
+ NULL);
+ break;
}
gtk_tree_view_column_set_min_width(column, 0);
@@ -328,8 +399,9 @@ static void trg_tree_view_add_column_after(TrgTreeView * tv,
gtk_tree_view_column_set_sort_column_id(column, desc->model_column);
if (width >= 0) {
- gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
- gtk_tree_view_column_set_fixed_width(column, width);
+ gtk_tree_view_column_set_sizing(column,
+ GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_fixed_width(column, width);
}
g_object_set_data(G_OBJECT(column), "column-desc", desc);
@@ -337,23 +409,26 @@ static void trg_tree_view_add_column_after(TrgTreeView * tv,
gtk_tree_view_append_column(GTK_TREE_VIEW(tv), column);
if (after_col)
- gtk_tree_view_move_column_after(GTK_TREE_VIEW(tv), column, after_col);
+ gtk_tree_view_move_column_after(GTK_TREE_VIEW(tv), column,
+ after_col);
#if GTK_CHECK_VERSION( 3,0,0 )
- g_signal_connect(gtk_tree_view_column_get_button(column), "button-press-event",
- G_CALLBACK(col_onButtonPressed), column);
+ g_signal_connect(gtk_tree_view_column_get_button(column),
+ "button-press-event", G_CALLBACK(col_onButtonPressed),
+ column);
#else
g_signal_connect(column->button, "button-press-event",
- G_CALLBACK(col_onButtonPressed), column);
+ G_CALLBACK(col_onButtonPressed), column);
#endif
if (desc->out)
- *(desc->out) = column;
+ *(desc->out) = column;
desc->flags |= TRG_COLUMN_SHOWING;
}
-void trg_tree_view_persist(TrgTreeView * tv, gboolean parentIsSortable) {
+void trg_tree_view_persist(TrgTreeView * tv, gboolean parentIsSortable)
+{
JsonObject *props = trg_prefs_get_tree_view_props(tv);
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(tv));
GList *cols = gtk_tree_view_get_columns(GTK_TREE_VIEW(tv));
@@ -364,106 +439,123 @@ void trg_tree_view_persist(TrgTreeView * tv, gboolean parentIsSortable) {
JsonArray *widths, *columns;
if (json_object_has_member(props, TRG_PREFS_KEY_TV_WIDTHS))
- json_object_remove_member(props, TRG_PREFS_KEY_TV_WIDTHS);
+ json_object_remove_member(props, TRG_PREFS_KEY_TV_WIDTHS);
widths = json_array_new();
json_object_set_array_member(props, TRG_PREFS_KEY_TV_WIDTHS, widths);
if (json_object_has_member(props, TRG_PREFS_KEY_TV_COLUMNS))
- json_object_remove_member(props, TRG_PREFS_KEY_TV_COLUMNS);
+ json_object_remove_member(props, TRG_PREFS_KEY_TV_COLUMNS);
columns = json_array_new();
json_object_set_array_member(props, TRG_PREFS_KEY_TV_COLUMNS, columns);
for (li = cols; li; li = g_list_next(li)) {
- GtkTreeViewColumn *col = (GtkTreeViewColumn *) li->data;
- trg_column_description *desc = g_object_get_data(G_OBJECT(li->data),
- "column-desc");
-
- json_array_add_string_element(columns, desc->id);
- json_array_add_int_element(widths, gtk_tree_view_column_get_width(col));
+ GtkTreeViewColumn *col = (GtkTreeViewColumn *) li->data;
+ trg_column_description *desc =
+ g_object_get_data(G_OBJECT(li->data),
+ "column-desc");
+
+ json_array_add_string_element(columns, desc->id);
+ json_array_add_int_element(widths,
+ gtk_tree_view_column_get_width(col));
}
g_list_free(cols);
- gtk_tree_sortable_get_sort_column_id(
- GTK_TREE_SORTABLE(parentIsSortable ? gtk_tree_model_filter_get_model(
- GTK_TREE_MODEL_FILTER(model)) :
- model), &sort_column_id, &sort_type);
+ gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE
+ (parentIsSortable ?
+ gtk_tree_model_filter_get_model
+ (GTK_TREE_MODEL_FILTER(model)) :
+ model), &sort_column_id,
+ &sort_type);
if (json_object_has_member(props, TRG_PREFS_KEY_TV_SORT_COL))
- json_object_remove_member(props, TRG_PREFS_KEY_TV_SORT_COL);
+ json_object_remove_member(props, TRG_PREFS_KEY_TV_SORT_COL);
if (json_object_has_member(props, TRG_PREFS_KEY_TV_SORT_TYPE))
- json_object_remove_member(props, TRG_PREFS_KEY_TV_SORT_TYPE);
+ json_object_remove_member(props, TRG_PREFS_KEY_TV_SORT_TYPE);
json_object_set_int_member(props, TRG_PREFS_KEY_TV_SORT_COL,
- (gint64) sort_column_id);
+ (gint64) sort_column_id);
json_object_set_int_member(props, TRG_PREFS_KEY_TV_SORT_TYPE,
- (gint64) sort_type);
+ (gint64) sort_type);
}
-void trg_tree_view_restore_sort(TrgTreeView * tv, gboolean parentIsSortable) {
+void trg_tree_view_restore_sort(TrgTreeView * tv,
+ gboolean parentIsSortable)
+{
JsonObject *props = trg_prefs_get_tree_view_props(tv);
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(tv));
if (json_object_has_member(props, TRG_PREFS_KEY_TV_SORT_COL)
- && json_object_has_member(props, TRG_PREFS_KEY_TV_SORT_TYPE)) {
- gint64 sort_col = json_object_get_int_member(props,
- TRG_PREFS_KEY_TV_SORT_COL);
- gint64 sort_type = json_object_get_int_member(props,
- TRG_PREFS_KEY_TV_SORT_TYPE);
- gtk_tree_sortable_set_sort_column_id(
- GTK_TREE_SORTABLE(parentIsSortable ? gtk_tree_model_filter_get_model(
- GTK_TREE_MODEL_FILTER(model)) :
- model), sort_col, (GtkSortType) sort_type);
+ && json_object_has_member(props, TRG_PREFS_KEY_TV_SORT_TYPE)) {
+ gint64 sort_col = json_object_get_int_member(props,
+ TRG_PREFS_KEY_TV_SORT_COL);
+ gint64 sort_type = json_object_get_int_member(props,
+ TRG_PREFS_KEY_TV_SORT_TYPE);
+ gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE
+ (parentIsSortable ?
+ gtk_tree_model_filter_get_model
+ (GTK_TREE_MODEL_FILTER
+ (model)) : model), sort_col,
+ (GtkSortType) sort_type);
}
}
-void trg_tree_view_set_prefs(TrgTreeView *tv, TrgPrefs *prefs) {
+void trg_tree_view_set_prefs(TrgTreeView * tv, TrgPrefs * prefs)
+{
TrgTreeViewPrivate *priv = TRG_TREE_VIEW_GET_PRIVATE(tv);
priv->prefs = prefs;
}
-void trg_tree_view_setup_columns(TrgTreeView * tv) {
+void trg_tree_view_setup_columns(TrgTreeView * tv)
+{
TrgTreeViewPrivate *priv = TRG_TREE_VIEW_GET_PRIVATE(tv);
JsonObject *props = trg_prefs_get_tree_view_props(tv);
if (!json_object_has_member(props, TRG_PREFS_KEY_TV_COLUMNS)
- || !json_object_has_member(props, TRG_PREFS_KEY_TV_WIDTHS)) {
- GList *li;
- for (li = priv->columns; li; li = g_list_next(li)) {
- trg_column_description *desc = (trg_column_description *) li->data;
- if (desc && !(desc->flags & TRG_COLUMN_EXTRA))
- trg_tree_view_add_column(tv, desc, -1);
- }
- return;
+ || !json_object_has_member(props, TRG_PREFS_KEY_TV_WIDTHS)) {
+ GList *li;
+ for (li = priv->columns; li; li = g_list_next(li)) {
+ trg_column_description *desc =
+ (trg_column_description *) li->data;
+ if (desc && !(desc->flags & TRG_COLUMN_EXTRA))
+ trg_tree_view_add_column(tv, desc, -1);
+ }
+ return;
}
- GList *columns = json_array_get_elements(
- json_object_get_array_member(props, TRG_PREFS_KEY_TV_COLUMNS));
- GList *widths = json_array_get_elements(
- json_object_get_array_member(props, TRG_PREFS_KEY_TV_WIDTHS));
+ GList *columns =
+ json_array_get_elements(json_object_get_array_member
+ (props, TRG_PREFS_KEY_TV_COLUMNS));
+ GList *widths =
+ json_array_get_elements(json_object_get_array_member
+ (props, TRG_PREFS_KEY_TV_WIDTHS));
GList *wli = widths;
GList *cli = columns;
for (; cli; cli = g_list_next(cli)) {
- trg_column_description *desc = trg_tree_view_find_column(tv,
- json_node_get_string((JsonNode*) cli->data));
- if (desc) {
- gint64 width = json_node_get_int((JsonNode*) wli->data);
- trg_tree_view_add_column(tv, desc, width);
- }
- wli = g_list_next(wli);
+ trg_column_description *desc = trg_tree_view_find_column(tv,
+ json_node_get_string
+ ((JsonNode
+ *) cli->
+ data));
+ if (desc) {
+ gint64 width = json_node_get_int((JsonNode *) wli->data);
+ trg_tree_view_add_column(tv, desc, width);
+ }
+ wli = g_list_next(wli);
}
g_list_free(columns);
g_list_free(widths);
}
-GList *trg_tree_view_get_selected_refs_list(GtkTreeView * tv) {
+GList *trg_tree_view_get_selected_refs_list(GtkTreeView * tv)
+{
GtkTreeModel *model = gtk_tree_view_get_model(tv);
GtkTreeSelection *selection = gtk_tree_view_get_selection(tv);
GList *li, *selectionList;
@@ -471,17 +563,18 @@ GList *trg_tree_view_get_selected_refs_list(GtkTreeView * tv) {
selectionList = gtk_tree_selection_get_selected_rows(selection, NULL);
for (li = selectionList; li != NULL; li = g_list_next(li)) {
- GtkTreePath *path = (GtkTreePath *) li->data;
- GtkTreeRowReference *ref = gtk_tree_row_reference_new(model, path);
- gtk_tree_path_free(path);
- refList = g_list_append(refList, ref);
+ GtkTreePath *path = (GtkTreePath *) li->data;
+ GtkTreeRowReference *ref = gtk_tree_row_reference_new(model, path);
+ gtk_tree_path_free(path);
+ refList = g_list_append(refList, ref);
}
g_list_free(selectionList);
return refList;
}
-static void trg_tree_view_class_init(TrgTreeViewClass * klass) {
+static void trg_tree_view_class_init(TrgTreeViewClass * klass)
+{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
g_type_class_add_private(klass, sizeof(TrgTreeViewPrivate));
@@ -490,29 +583,35 @@ static void trg_tree_view_class_init(TrgTreeViewClass * klass) {
object_class->set_property = trg_tree_view_set_property;
object_class->constructor = trg_tree_view_constructor;
- g_object_class_install_property(
- object_class,
- PROP_PREFS,
- g_param_spec_object(
- "prefs",
- "Trg Prefs",
- "Trg Prefs",
- TRG_TYPE_PREFS,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK
- | G_PARAM_STATIC_BLURB));
+ g_object_class_install_property(object_class,
+ PROP_PREFS,
+ g_param_spec_object("prefs",
+ "Trg Prefs",
+ "Trg Prefs",
+ TRG_TYPE_PREFS,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
}
-static void trg_tree_view_init(TrgTreeView * tv) {
+static void trg_tree_view_init(TrgTreeView * tv)
+{
gtk_tree_view_set_rubber_banding(GTK_TREE_VIEW(tv), TRUE);
gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(tv), TRUE);
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tv), TRUE);
- gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)),
- GTK_SELECTION_MULTIPLE);
+ gtk_tree_selection_set_mode(gtk_tree_view_get_selection
+ (GTK_TREE_VIEW(tv)),
+ GTK_SELECTION_MULTIPLE);
gtk_widget_set_sensitive(GTK_WIDGET(tv), FALSE);
}
-GtkWidget *trg_tree_view_new(void) {
+GtkWidget *trg_tree_view_new(void)
+{
return GTK_WIDGET(g_object_new(TRG_TYPE_TREE_VIEW, NULL));
}
diff --git a/src/trg-tree-view.h b/src/trg-tree-view.h
index 55db8dd..7d1a33f 100644
--- a/src/trg-tree-view.h
+++ b/src/trg-tree-view.h
@@ -78,19 +78,20 @@ typedef struct {
} trg_column_description;
#define TRG_COLUMN_DEFAULT 0x00
-#define TRG_COLUMN_SHOWING (1 << 0) /* 0x01 */
-#define TRG_COLUMN_UNREMOVABLE (1 << 1) /* 0x02 */
-#define TRG_COLUMN_EXTRA (1 << 2) /* 0x04 */
+#define TRG_COLUMN_SHOWING (1 << 0) /* 0x01 */
+#define TRG_COLUMN_UNREMOVABLE (1 << 1) /* 0x02 */
+#define TRG_COLUMN_EXTRA (1 << 2) /* 0x04 */
trg_column_description *trg_tree_view_reg_column(TrgTreeView * tv,
- gint type,
- gint model_column,
- gchar * header,
- gchar * id, gint flags);
+ gint type,
+ gint model_column,
+ gchar * header,
+ gchar * id, gint flags);
void trg_tree_view_setup_columns(TrgTreeView * tv);
-void trg_tree_view_set_prefs(TrgTreeView *tv, TrgPrefs *prefs);
+void trg_tree_view_set_prefs(TrgTreeView * tv, TrgPrefs * prefs);
void trg_tree_view_persist(TrgTreeView * tv, gboolean parentIsSortable);
-void trg_tree_view_restore_sort(TrgTreeView * tv, gboolean parentIsSortable);
-gboolean trg_tree_view_is_column_showing(TrgTreeView *tv, gint index);
+void trg_tree_view_restore_sort(TrgTreeView * tv,
+ gboolean parentIsSortable);
+gboolean trg_tree_view_is_column_showing(TrgTreeView * tv, gint index);
-#endif /* _TRG_TREE_VIEW_H_ */
+#endif /* _TRG_TREE_VIEW_H_ */
diff --git a/src/util.c b/src/util.c
index e520dd6..2beefb1 100644
--- a/src/util.c
+++ b/src/util.c
@@ -33,25 +33,25 @@
#include "util.h"
-gboolean is_magnet(gchar *string)
+gboolean is_magnet(gchar * string)
{
return g_str_has_prefix(string, "magnet:");
}
-gboolean is_url(gchar *string)
+gboolean is_url(gchar * string)
{
//return g_regex_match_simple ("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?", string, 0, 0);
- return g_regex_match_simple ("^http[s]?://", string, 0, 0);
+ return g_regex_match_simple("^http[s]?://", string, 0, 0);
}
void add_file_id_to_array(JsonObject * args, gchar * key, gint index)
{
JsonArray *array;
if (json_object_has_member(args, key)) {
- array = json_object_get_array_member(args, key);
+ array = json_object_get_array_member(args, key);
} else {
- array = json_array_new();
- json_object_set_array_member(args, key, array);
+ array = json_array_new();
+ json_object_set_array_member(args, key, array);
}
json_array_add_int_element(array, index);
}
@@ -64,14 +64,18 @@ void g_str_slist_free(GSList * list)
GRegex *trg_uri_host_regex_new(void)
{
- return g_regex_new("^[^:/?#]+:?//(?:www\\.|torrent\\.|torrents\\.|tracker\\.|\\d+\\.)?([^/?#:]*)",
- G_REGEX_OPTIMIZE, 0, NULL);
+ return
+ g_regex_new
+ ("^[^:/?#]+:?//(?:www\\.|torrent\\.|torrents\\.|tracker\\.|\\d+\\.)?([^/?#:]*)",
+ G_REGEX_OPTIMIZE, 0, NULL);
}
-GtkWidget *my_scrolledwin_new(GtkWidget * child) {
+GtkWidget *my_scrolledwin_new(GtkWidget * child)
+{
GtkWidget *scrolled_win = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_win),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
gtk_container_add(GTK_CONTAINER(scrolled_win), child);
return scrolled_win;
}
@@ -82,20 +86,20 @@ gchar *trg_gregex_get_first(GRegex * rx, const gchar * src)
gchar *dst = NULL;
g_regex_match(rx, src, 0, &mi);
if (mi) {
- dst = g_match_info_fetch(mi, 1);
- g_match_info_free(mi);
+ dst = g_match_info_fetch(mi, 1);
+ g_match_info_free(mi);
}
return dst;
}
-void trg_error_dialog(GtkWindow * parent, trg_response *response)
+void trg_error_dialog(GtkWindow * parent, trg_response * response)
{
gchar *msg = make_error_message(response->obj, response->status);
GtkWidget *dialog = gtk_message_dialog_new(parent,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK, "%s",
- msg);
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK, "%s",
+ msg);
gtk_window_set_title(GTK_WINDOW(dialog), _("Error"));
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
@@ -105,19 +109,19 @@ void trg_error_dialog(GtkWindow * parent, trg_response *response)
gchar *make_error_message(JsonObject * response, int status)
{
if (status == FAIL_JSON_DECODE) {
- return g_strdup(_("JSON decoding error."));
+ return g_strdup(_("JSON decoding error."));
} else if (status == FAIL_RESPONSE_UNSUCCESSFUL) {
- const gchar *resultStr =
- json_object_get_string_member(response, "result");
- if (resultStr == NULL)
- return g_strdup(_("Server responded, but with no result."));
- else
- return g_strdup(resultStr);
+ const gchar *resultStr =
+ json_object_get_string_member(response, "result");
+ if (resultStr == NULL)
+ return g_strdup(_("Server responded, but with no result."));
+ else
+ return g_strdup(resultStr);
} else if (status <= -100) {
- return g_strdup_printf(_("Request failed with HTTP code %d"),
- -(status + 100));
+ return g_strdup_printf(_("Request failed with HTTP code %d"),
+ -(status + 100));
} else {
- return g_strdup(curl_easy_strerror(status));
+ return g_strdup(curl_easy_strerror(status));
}
}
@@ -130,11 +134,11 @@ char *tr_strpercent(char *buf, double x, size_t buflen)
{
int precision;
if (x < 10.0)
- precision = 2;
+ precision = 2;
else if (x < 100.0)
- precision = 1;
+ precision = 1;
else
- precision = 0;
+ precision = 0;
tr_snprintf(buf, buflen, "%.*f%%", precision, tr_truncd(x, precision));
return buf;
@@ -148,18 +152,18 @@ double tr_truncd(double x, int decimal_places)
}
char *tr_strratio(char *buf, size_t buflen, double ratio,
- const char *infinity)
+ const char *infinity)
{
if ((int) ratio == TR_RATIO_NA)
- tr_strlcpy(buf, _("None"), buflen);
+ tr_strlcpy(buf, _("None"), buflen);
else if ((int) ratio == TR_RATIO_INF)
- tr_strlcpy(buf, infinity, buflen);
+ tr_strlcpy(buf, infinity, buflen);
else if (ratio < 10.0)
- tr_snprintf(buf, buflen, "%.2f", tr_truncd(ratio, 2));
+ tr_snprintf(buf, buflen, "%.2f", tr_truncd(ratio, 2));
else if (ratio < 100.0)
- tr_snprintf(buf, buflen, "%.1f", tr_truncd(ratio, 1));
+ tr_snprintf(buf, buflen, "%.1f", tr_truncd(ratio, 1));
else
- tr_snprintf(buf, buflen, "%'.0f", ratio);
+ tr_snprintf(buf, buflen, "%'.0f", ratio);
return buf;
}
@@ -171,30 +175,30 @@ char *tr_strlratio(char *buf, double ratio, size_t buflen)
char *tr_strlsize(char *buf, guint64 size, size_t buflen)
{
if (!size)
- g_strlcpy(buf, _("None"), buflen);
+ g_strlcpy(buf, _("None"), buflen);
#if GLIB_CHECK_VERSION( 2, 16, 0 )
else {
- char *tmp = g_format_size_for_display(size);
- g_strlcpy(buf, tmp, buflen);
- g_free(tmp);
+ char *tmp = g_format_size_for_display(size);
+ g_strlcpy(buf, tmp, buflen);
+ g_free(tmp);
}
#else
else if (size < (guint64) KILOBYTE_FACTOR)
- g_snprintf(buf, buflen,
- ngettext("%'u byte", "%'u bytes", (guint) size),
- (guint) size);
+ g_snprintf(buf, buflen,
+ ngettext("%'u byte", "%'u bytes", (guint) size),
+ (guint) size);
else {
- gdouble displayed_size;
- if (size < (guint64) MEGABYTE_FACTOR) {
- displayed_size = (gdouble) size / KILOBYTE_FACTOR;
- g_snprintf(buf, buflen, _("%'.1f KB"), displayed_size);
- } else if (size < (guint64) GIGABYTE_FACTOR) {
- displayed_size = (gdouble) size / MEGABYTE_FACTOR;
- g_snprintf(buf, buflen, _("%'.1f MB"), displayed_size);
- } else {
- displayed_size = (gdouble) size / GIGABYTE_FACTOR;
- g_snprintf(buf, buflen, _("%'.1f GB"), displayed_size);
- }
+ gdouble displayed_size;
+ if (size < (guint64) MEGABYTE_FACTOR) {
+ displayed_size = (gdouble) size / KILOBYTE_FACTOR;
+ g_snprintf(buf, buflen, _("%'.1f KB"), displayed_size);
+ } else if (size < (guint64) GIGABYTE_FACTOR) {
+ displayed_size = (gdouble) size / MEGABYTE_FACTOR;
+ g_snprintf(buf, buflen, _("%'.1f MB"), displayed_size);
+ } else {
+ displayed_size = (gdouble) size / GIGABYTE_FACTOR;
+ g_snprintf(buf, buflen, _("%'.1f GB"), displayed_size);
+ }
}
#endif
return buf;
@@ -204,14 +208,14 @@ char *tr_strlspeed(char *buf, double kb_sec, size_t buflen)
{
const double speed = kb_sec;
- if (speed < 1000.0) /* 0.0 KB to 999.9 KB */
- g_snprintf(buf, buflen, _("%.1f KB/s"), speed);
- else if (speed < 102400.0) /* 0.98 MB to 99.99 MB */
- g_snprintf(buf, buflen, _("%.2f MB/s"), (speed / KILOBYTE_FACTOR));
- else if (speed < 1024000.0) /* 100.0 MB to 999.9 MB */
- g_snprintf(buf, buflen, _("%.1f MB/s"), (speed / MEGABYTE_FACTOR));
- else /* insane speeds */
- g_snprintf(buf, buflen, _("%.2f GB/s"), (speed / GIGABYTE_FACTOR));
+ if (speed < 1000.0) /* 0.0 KB to 999.9 KB */
+ g_snprintf(buf, buflen, _("%.1f KB/s"), speed);
+ else if (speed < 102400.0) /* 0.98 MB to 99.99 MB */
+ g_snprintf(buf, buflen, _("%.2f MB/s"), (speed / KILOBYTE_FACTOR));
+ else if (speed < 1024000.0) /* 100.0 MB to 999.9 MB */
+ g_snprintf(buf, buflen, _("%.1f MB/s"), (speed / MEGABYTE_FACTOR));
+ else /* insane speeds */
+ g_snprintf(buf, buflen, _("%.2f GB/s"), (speed / GIGABYTE_FACTOR));
return buf;
}
@@ -221,7 +225,7 @@ char *tr_strltime_short(char *buf, long seconds, size_t buflen)
int hours, minutes;
if (seconds < 0)
- seconds = 0;
+ seconds = 0;
hours = seconds / 3600;
minutes = (seconds % 3600) / 60;
@@ -238,7 +242,7 @@ char *tr_strltime_long(char *buf, long seconds, size_t buflen)
char d[128], h[128], m[128], s[128];
if (seconds < 0)
- seconds = 0;
+ seconds = 0;
days = seconds / 86400;
hours = (seconds % 86400) / 3600;
@@ -247,32 +251,32 @@ char *tr_strltime_long(char *buf, long seconds, size_t buflen)
g_snprintf(d, sizeof(d), ngettext("%d day", "%d days", days), days);
g_snprintf(h, sizeof(h), ngettext("%d hour", "%d hours", hours),
- hours);
+ hours);
g_snprintf(m, sizeof(m), ngettext("%d minute", "%d minutes", minutes),
- minutes);
+ minutes);
g_snprintf(s, sizeof(s),
- ngettext("%ld second", "%ld seconds", seconds), seconds);
+ ngettext("%ld second", "%ld seconds", seconds), seconds);
if (days) {
- if (days >= 4 || !hours) {
- g_strlcpy(buf, d, buflen);
- } else {
- g_snprintf(buf, buflen, "%s, %s", d, h);
- }
+ if (days >= 4 || !hours) {
+ g_strlcpy(buf, d, buflen);
+ } else {
+ g_snprintf(buf, buflen, "%s, %s", d, h);
+ }
} else if (hours) {
- if (hours >= 4 || !minutes) {
- g_strlcpy(buf, h, buflen);
- } else {
- g_snprintf(buf, buflen, "%s, %s", h, m);
- }
+ if (hours >= 4 || !minutes) {
+ g_strlcpy(buf, h, buflen);
+ } else {
+ g_snprintf(buf, buflen, "%s, %s", h, m);
+ }
} else if (minutes) {
- if (minutes >= 4 || !seconds) {
- g_strlcpy(buf, m, buflen);
- } else {
- g_snprintf(buf, buflen, "%s, %s", m, s);
- }
+ if (minutes >= 4 || !seconds) {
+ g_strlcpy(buf, m, buflen);
+ } else {
+ g_snprintf(buf, buflen, "%s, %s", m, s);
+ }
} else {
- g_strlcpy(buf, s, buflen);
+ g_strlcpy(buf, s, buflen);
}
return buf;
@@ -285,7 +289,7 @@ char *gtr_localtime(time_t time)
g_strlcpy(buf, asctime(&tm), sizeof(buf));
if ((eoln = strchr(buf, '\n')))
- *eoln = '\0';
+ *eoln = '\0';
return g_locale_to_utf8(buf, -1, NULL, NULL, NULL);
}
@@ -320,20 +324,20 @@ size_t tr_strlcpy(char *dst, const void *src, size_t siz)
/* Copy as many bytes as will fit */
if (n != 0) {
- while (--n != 0) {
- if ((*d++ = *s++) == '\0')
- break;
- }
+ while (--n != 0) {
+ if ((*d++ = *s++) == '\0')
+ break;
+ }
}
/* Not enough room in dst, add NUL and traverse rest of src */
if (n == 0) {
- if (siz != 0)
- *d = '\0'; /* NUL-terminate dst */
- while (*s++);
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++);
}
- return s - (char *) src - 1; /* count does not include NUL */
+ return s - (char *) src - 1; /* count does not include NUL */
#endif
}
@@ -344,9 +348,9 @@ evutil_vsnprintf(char *buf, size_t buflen, const char *format, va_list ap)
int r = _vsnprintf(buf, buflen, format, ap);
buf[buflen - 1] = '\0';
if (r >= 0)
- return r;
+ return r;
else
- return _vscprintf(format, ap);
+ return _vscprintf(format, ap);
#else
int r = vsnprintf(buf, buflen, format, ap);
buf[buflen - 1] = '\0';
@@ -354,66 +358,67 @@ evutil_vsnprintf(char *buf, size_t buflen, const char *format, va_list ap)
#endif
}
-void rm_trailing_slashes(gchar *str)
+void rm_trailing_slashes(gchar * str)
{
if (!str)
- return;
+ return;
int i, len;
if ((len = strlen(str)) < 1)
- return;
-
- for (i = strlen(str)-1; str[i]; i--)
- {
- if (str[i] == '/')
- str[i] = '\0';
- else
- return;
+ return;
+
+ for (i = strlen(str) - 1; str[i]; i--) {
+ if (str[i] == '/')
+ str[i] = '\0';
+ else
+ return;
}
}
/* gtk_widget_set_sensitive() was introduced in 2.18, we can have a minimum of
* 2.16 otherwise. */
-void trg_widget_set_visible(GtkWidget * w, gboolean visible) {
+void trg_widget_set_visible(GtkWidget * w, gboolean visible)
+{
if (visible)
- gtk_widget_show(w);
+ gtk_widget_show(w);
else
- gtk_widget_hide(w);
+ gtk_widget_hide(w);
}
-gdouble json_double_to_progress(JsonNode *n)
+gdouble json_double_to_progress(JsonNode * n)
{
- return json_node_really_get_double(n)*100.0;
+ return json_node_really_get_double(n) * 100.0;
}
-gdouble json_node_really_get_double(JsonNode *node)
+gdouble json_node_really_get_double(JsonNode * node)
{
GValue a = { 0 };
json_node_get_value(node, &a);
switch (G_VALUE_TYPE(&a)) {
case G_TYPE_INT64:
- return (gdouble) g_value_get_int64(&a);
+ return (gdouble) g_value_get_int64(&a);
case G_TYPE_DOUBLE:
- return g_value_get_double(&a);
+ return g_value_get_double(&a);
default:
- return 0.0;
+ return 0.0;
}
}
-gchar *trg_base64encode(const gchar *filename)
+gchar *trg_base64encode(const gchar * filename)
{
GError *error = NULL;
- GMappedFile *mf = g_mapped_file_new(filename, FALSE, &error);
+ GMappedFile *mf = g_mapped_file_new(filename, FALSE, &error);
gchar *b64out = NULL;
- if (error)
- {
- g_error("%s",error->message);
- g_error_free(error);
+ if (error) {
+ g_error("%s", error->message);
+ g_error_free(error);
} else {
- b64out = g_base64_encode((guchar*)g_mapped_file_get_contents(mf), g_mapped_file_get_length(mf));
+ b64out =
+ g_base64_encode((guchar *) g_mapped_file_get_contents(mf),
+ g_mapped_file_get_length(mf));
}
g_mapped_file_unref(mf);
@@ -434,13 +439,13 @@ GtkWidget *gtr_combo_box_new_enum(const char *text_1, ...)
text = text_1;
if (text != NULL)
- do {
- const int val = va_arg(vl, int);
- gtk_list_store_insert_with_values(store, NULL, INT_MAX, 0, val,
- 1, text, -1);
- text = va_arg(vl, const char *);
- }
- while (text != NULL);
+ do {
+ const int val = va_arg(vl, int);
+ gtk_list_store_insert_with_values(store, NULL, INT_MAX, 0, val,
+ 1, text, -1);
+ text = va_arg(vl, const char *);
+ }
+ while (text != NULL);
w = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
r = gtk_cell_renderer_text_new();
diff --git a/src/util.h b/src/util.h
index 31fc094..a99933f 100644
--- a/src/util.h
+++ b/src/util.h
@@ -51,7 +51,7 @@ char *tr_strltime_short(char *buf, long seconds, size_t buflen);
char *tr_strpercent(char *buf, double x, size_t buflen);
char *tr_strlpercent(char *buf, double x, size_t buflen);
char *tr_strratio(char *buf, size_t buflen, double ratio,
- const char *infinity);
+ const char *infinity);
char *tr_strlratio(char *buf, double ratio, size_t buflen);
char *tr_strlspeed(char *buf, double kb_sec, size_t buflen);
char *tr_strlsize(char *buf, guint64 size, size_t buflen);
@@ -62,15 +62,15 @@ int tr_snprintf(char *buf, size_t buflen, const char *fmt, ...);
size_t tr_strlcpy(char *dst, const void *src, size_t siz);
double tr_truncd(double x, int decimal_places);
int evutil_vsnprintf(char *buf, size_t buflen, const char *format,
- va_list ap);
-void rm_trailing_slashes(gchar *str);
+ va_list ap);
+void rm_trailing_slashes(gchar * str);
void trg_widget_set_visible(GtkWidget * w, gboolean visible);
-gdouble json_double_to_progress(JsonNode *n);
-gchar *trg_base64encode(const gchar *filename);
+gdouble json_double_to_progress(JsonNode * n);
+gchar *trg_base64encode(const gchar * filename);
GtkWidget *my_scrolledwin_new(GtkWidget * child);
-gboolean is_url(gchar *string);
-gboolean is_magnet(gchar *string);
-gdouble json_node_really_get_double(JsonNode *node);
+gboolean is_url(gchar * string);
+gboolean is_magnet(gchar * string);
+gdouble json_node_really_get_double(JsonNode * node);
GtkWidget *gtr_combo_box_new_enum(const char *text_1, ...);
-#endif /* UTIL_H_ */
+#endif /* UTIL_H_ */