diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/torrent.c | 2 | ||||
-rw-r--r-- | src/trg-destination-combo.c | 180 | ||||
-rw-r--r-- | src/trg-destination-combo.h | 53 | ||||
-rw-r--r-- | src/trg-main-window.c | 3 | ||||
-rw-r--r-- | src/trg-peers-tree-view.c | 2 | ||||
-rw-r--r-- | src/trg-preferences.c | 2 | ||||
-rw-r--r-- | src/trg-state-selector.c | 3 | ||||
-rw-r--r-- | src/trg-stats-dialog.c | 2 | ||||
-rw-r--r-- | src/trg-stats-dialog.h | 2 | ||||
-rw-r--r-- | src/trg-torrent-add-dialog.c | 68 | ||||
-rw-r--r-- | src/trg-torrent-move-dialog.c | 194 | ||||
-rw-r--r-- | src/trg-torrent-props-dialog.c | 6 | ||||
-rw-r--r-- | src/trg-trackers-tree-view.c | 9 | ||||
-rw-r--r-- | src/trg-tree-view.c | 6 | ||||
-rw-r--r-- | src/trg-tree-view.h | 2 | ||||
-rw-r--r-- | src/util.c | 1 | ||||
-rw-r--r-- | src/util.h | 2 |
18 files changed, 413 insertions, 125 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index ab258c3..5756834 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -74,6 +74,7 @@ transmission_remote_gtk_SOURCES = main.c \ trg-file-parser.c \ bencode.c \ trg-preferences.c \ + trg-destination-combo.c \ $(NULL) transmission_remote_gtk_LDFLAGS = -lm -lcurl $(jsonglib_LIBS) $(gtk_LIBS) $(gthread_LIBS) $(GEOIP_LIBS) $(gconf_LIBS) $(gio_LIBS) $(unique_LIBS) $(notify_LIBS) $(libproxy_LIBS) diff --git a/src/torrent.c b/src/torrent.c index 032e9b7..1d3d247 100644 --- a/src/torrent.c +++ b/src/torrent.c @@ -227,7 +227,7 @@ gboolean torrent_has_tracker(JsonObject * t, GRegex * rx, gchar * search) GList *li; for (li = trackers; li; li = g_list_next(li)) { - JsonObject *tracker = json_node_get_object((JsonNode*)li->data); + JsonObject *tracker = json_node_get_object((JsonNode *) li->data); const gchar *trackerAnnounce = tracker_get_announce(tracker); gchar *trackerAnnounceHost = trg_gregex_get_first(rx, trackerAnnounce); diff --git a/src/trg-destination-combo.c b/src/trg-destination-combo.c new file mode 100644 index 0000000..87ce934 --- /dev/null +++ b/src/trg-destination-combo.c @@ -0,0 +1,180 @@ +/* + * transmission-remote-gtk - Transmission RPC client for GTK + * Copyright (C) 2010 Alan Fitton + + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <gtk/gtk.h> + +#include "trg-client.h" +#include "torrent.h" +#include "trg-torrent-model.h" +#include "trg-destination-combo.h" +#include "util.h" + +G_DEFINE_TYPE(TrgDestinationCombo, trg_destination_combo, + GTK_TYPE_COMBO_BOX_ENTRY) +#define TRG_DESTINATION_COMBO_GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_DESTINATION_COMBO, TrgDestinationComboPrivate)) +typedef struct _TrgDestinationComboPrivate TrgDestinationComboPrivate; + +struct _TrgDestinationComboPrivate { + trg_client *client; +}; + +enum { + PROP_0, + PROP_CLIENT +}; + +static void +trg_destination_combo_get_property(GObject * object, guint property_id, + GValue * value, GParamSpec * pspec) +{ + TrgDestinationComboPrivate *priv = + TRG_DESTINATION_COMBO_GET_PRIVATE(object); + switch (property_id) { + case PROP_CLIENT: + g_value_set_pointer(value, priv->client); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + } +} + +static void +trg_destination_combo_set_property(GObject * object, guint property_id, + const GValue * value, + GParamSpec * pspec) +{ + TrgDestinationComboPrivate *priv = + TRG_DESTINATION_COMBO_GET_PRIVATE(object); + switch (property_id) { + case PROP_CLIENT: + priv->client = g_value_get_pointer(value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + } +} + +static GObject *trg_destination_combo_constructor(GType type, + guint + n_construct_properties, + GObjectConstructParam + * construct_params) +{ + GObject *object = G_OBJECT_CLASS + (trg_destination_combo_parent_class)->constructor(type, + n_construct_properties, + construct_params); + + TrgDestinationComboPrivate *priv = + TRG_DESTINATION_COMBO_GET_PRIVATE(object); + trg_client *client = priv->client; + + const gchar *defaultDownDir = + json_object_get_string_member(client->session, SGET_DOWNLOAD_DIR); + + GtkListStore *comboModel = gtk_list_store_new(1, G_TYPE_STRING); + + GSList *dirs = NULL; + GSList *sli; + GList *li; + GList *torrentItemRefs; + + GtkTreeRowReference *rr; + GtkTreeModel *model; + GtkTreePath *path; + JsonObject *t; + + g_slist_str_set_add(&dirs, defaultDownDir); + + g_mutex_lock(client->updateMutex); + torrentItemRefs = g_hash_table_get_values(client->torrentTable); + for (li = torrentItemRefs; 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); + + if (path) { + GtkTreeIter iter; + if (gtk_tree_model_get_iter(model, &iter, path)) { + const gchar *dd; + gtk_tree_model_get(model, &iter, TORRENT_COLUMN_JSON, &t, + -1); + dd = torrent_get_download_dir(t); + if (dd) + g_slist_str_set_add(&dirs, dd); + + } + gtk_tree_path_free(path); + } + } + + g_list_free(torrentItemRefs); + g_mutex_unlock(client->updateMutex); + + for (sli = dirs; sli != NULL; sli = g_slist_next(sli)) + gtk_list_store_insert_with_values(comboModel, NULL, INT_MAX, 0, + (gchar *) sli->data, -1); + + g_str_slist_free(dirs); + + gtk_combo_box_set_model(GTK_COMBO_BOX(object), + GTK_TREE_MODEL(comboModel)); + + gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(object), 0); + + /* cleanup */ + g_object_unref(comboModel); + + return object; +} + +static void +trg_destination_combo_class_init(TrgDestinationComboClass * klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS(klass); + + g_type_class_add_private(klass, sizeof(TrgDestinationComboPrivate)); + + object_class->get_property = trg_destination_combo_get_property; + object_class->set_property = trg_destination_combo_set_property; + 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)); + +} + +static void trg_destination_combo_init(TrgDestinationCombo * self) +{ +} + +GtkWidget *trg_destination_combo_new(trg_client * client) +{ + return GTK_WIDGET(g_object_new(TRG_TYPE_DESTINATION_COMBO, + "trg-client", client, NULL)); +} diff --git a/src/trg-destination-combo.h b/src/trg-destination-combo.h new file mode 100644 index 0000000..d93300d --- /dev/null +++ b/src/trg-destination-combo.h @@ -0,0 +1,53 @@ +/* + * transmission-remote-gtk - Transmission RPC client for GTK + * Copyright (C) 2010 Alan Fitton + + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef TRG_DESTINATION_COMBO_H_ +#define TRG_DESTINATION_COMBO_H_ + +#include <glib-object.h> +#include <gtk/gtk.h> + +#include "trg-client.h" + +G_BEGIN_DECLS +#define TRG_TYPE_DESTINATION_COMBO trg_destination_combo_get_type() +#define TRG_DESTINATION_COMBO(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRG_TYPE_DESTINATION_COMBO, TrgDestinationCombo)) +#define TRG_DESTINATION_COMBO_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), TRG_TYPE_DESTINATION_COMBO, TrgDestinationComboClass)) +#define TRG_IS_DESTINATION_COMBO(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRG_TYPE_DESTINATION_COMBO)) +#define TRG_IS_DESTINATION_COMBO_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), TRG_TYPE_DESTINATION_COMBO)) +#define TRG_DESTINATION_COMBO_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), TRG_TYPE_DESTINATION_COMBO, TrgDestinationComboClass)) + typedef struct { + GtkComboBoxEntry parent; +} TrgDestinationCombo; + +typedef struct { + GtkComboBoxEntryClass parent_class; +} TrgDestinationComboClass; + +GType trg_destination_combo_get_type(void); + +GtkWidget *trg_destination_combo_new(trg_client * client); + +G_END_DECLS +#endif /* TRG_DESTINATION_COMBO_H_ */ diff --git a/src/trg-main-window.c b/src/trg-main-window.c index 39553fd..2975614 100644 --- a/src/trg-main-window.c +++ b/src/trg-main-window.c @@ -262,8 +262,7 @@ static void update_selected_torrent_notebook(TrgMainWindow * win, JsonObject *t; GtkTreeIter iter; - if (id >= 0 - && get_torrent_data(client->torrentTable, id, &t, &iter)) { + if (id >= 0 && get_torrent_data(client->torrentTable, id, &t, &iter)) { trg_toolbar_torrent_actions_sensitive(priv->toolBar, TRUE); trg_menu_bar_torrent_actions_sensitive(priv->menuBar, TRUE); trg_general_panel_update(priv->genDetails, t, &iter); diff --git a/src/trg-peers-tree-view.c b/src/trg-peers-tree-view.c index c4f9c32..8d160d1 100644 --- a/src/trg-peers-tree-view.c +++ b/src/trg-peers-tree-view.c @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * 51 Franklin Streef, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifdef HAVE_CONFIG_H diff --git a/src/trg-preferences.c b/src/trg-preferences.c index 6d53007..8c7fafe 100644 --- a/src/trg-preferences.c +++ b/src/trg-preferences.c @@ -1,6 +1,6 @@ /* * transmission-remote-gtk - Transmission RPC client for GTK - * Copyright (C) 2010 Alan Fitton + * Copyright (C) 2011 Alan Fitton * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/trg-state-selector.c b/src/trg-state-selector.c index 85b6ade..81ffc84 100644 --- a/src/trg-state-selector.c +++ b/src/trg-state-selector.c @@ -457,7 +457,8 @@ static void trg_state_selector_init(TrgStateSelector * self) g_signal_connect(self, "popup-menu", G_CALLBACK(view_onPopupMenu), NULL); - gtk_tree_view_set_search_column(GTK_TREE_VIEW(self), STATE_SELECTOR_NAME); + gtk_tree_view_set_search_column(GTK_TREE_VIEW(self), + STATE_SELECTOR_NAME); } TrgStateSelector *trg_state_selector_new(trg_client * client) diff --git a/src/trg-stats-dialog.c b/src/trg-stats-dialog.c index 42eab66..d5b6561 100644 --- a/src/trg-stats-dialog.c +++ b/src/trg-stats-dialog.c @@ -1,6 +1,6 @@ /* * transmission-remote-gtk - Transmission RPC client for GTK - * Copyright (C) 2010 Alan Fitton + * Copyright (C) 2011 Alan Fitton * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/trg-stats-dialog.h b/src/trg-stats-dialog.h index acdbc55..1353d68 100644 --- a/src/trg-stats-dialog.h +++ b/src/trg-stats-dialog.h @@ -1,6 +1,6 @@ /* * transmission-remote-gtk - Transmission RPC client for GTK - * Copyright (C) 2010 Alan Fitton + * Copyright (C) 2011 Alan Fitton * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/trg-torrent-add-dialog.c b/src/trg-torrent-add-dialog.c index 4604a8e..4282cc7 100644 --- a/src/trg-torrent-add-dialog.c +++ b/src/trg-torrent-add-dialog.c @@ -35,6 +35,7 @@ #include "trg-file-parser.h" #include "trg-torrent-add-dialog.h" #include "trg-cell-renderer-size.h" +#include "trg-destination-combo.h" #include "trg-preferences.h" #include "requests.h" #include "torrent.h" @@ -165,63 +166,6 @@ static gpointer add_files_threadfunc(gpointer data) return NULL; } -static gchar *trg_destination_folder_get(GtkComboBox * box) -{ - return gtk_combo_box_get_active_text(box); -} - -static GtkWidget *trg_destination_folder_new(trg_client * client) -{ - const gchar *defaultDownDir = - json_object_get_string_member(client->session, SGET_DOWNLOAD_DIR); - GtkWidget *combo = gtk_combo_box_entry_new_text(); - GSList *dirs = NULL; - GSList *sli; - GList *li; - GList *torrentItemRefs; - - GtkTreeRowReference *rr; - GtkTreeModel *model; - GtkTreePath *path; - JsonObject *t; - - g_slist_str_set_add(&dirs, defaultDownDir); - - g_mutex_lock(client->updateMutex); - torrentItemRefs = g_hash_table_get_values(client->torrentTable); - for (li = torrentItemRefs; 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); - - if (path) { - GtkTreeIter iter; - if (gtk_tree_model_get_iter(model, &iter, path)) { - const gchar *dd; - gtk_tree_model_get(model, &iter, TORRENT_COLUMN_JSON, &t, - -1); - dd = torrent_get_download_dir(t); - if (dd) - g_slist_str_set_add(&dirs, dd); - - } - gtk_tree_path_free(path); - } - } - - g_list_free(torrentItemRefs); - g_mutex_unlock(client->updateMutex); - - for (sli = dirs; sli != NULL; sli = g_slist_next(sli)) - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), - (gchar *) sli->data); - - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); - g_str_slist_free(dirs); - - return combo; -} - void launch_add_thread(struct add_torrent_threadfunc_args *args) { GError *error = NULL; @@ -279,7 +223,7 @@ trg_torrent_add_response_cb(GtkDialog * dlg, gint res_id, gpointer data) gtk_combo_box_get_active(GTK_COMBO_BOX(priv->priority_combo)) - 1; gchar *dir = - trg_destination_folder_get(GTK_COMBO_BOX(priv->dest_combo)); + gtk_combo_box_get_active_text(GTK_COMBO_BOX(priv->dest_combo)); if (g_slist_length(priv->filenames) == 1) { JsonNode *req = @@ -624,6 +568,7 @@ GtkWidget *gtr_file_list_new(GtkTreeStore ** store) G_TYPE_INT); /* dl enabled */ gtk_tree_view_set_model(tree_view, GTK_TREE_MODEL(*store)); + g_object_unref(G_OBJECT(*store)); /* create the scrolled window and stick the view in it */ scroll = gtk_scrolled_window_new(NULL, NULL); @@ -891,8 +836,8 @@ static GObject *trg_torrent_add_dialog_constructor(GType type, priv->paused_check = gtk_check_button_new_with_mnemonic(_("Start _paused")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->paused_check), - pref_get_start_paused(priv-> - client->gconf)); + pref_get_start_paused(priv->client-> + gconf)); priv->priority_combo = gtr_priority_combo_new(); gtk_combo_box_set_active(GTK_COMBO_BOX(priv->priority_combo), 1); @@ -922,8 +867,9 @@ static GObject *trg_torrent_add_dialog_constructor(GType type, gtk_table_attach(GTK_TABLE(t), l, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); ++col; - priv->dest_combo = trg_destination_folder_new(priv->client); + priv->dest_combo = trg_destination_combo_new(priv->client); + 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); gtk_label_set_mnemonic_widget(GTK_LABEL(l), priv->dest_combo); diff --git a/src/trg-torrent-move-dialog.c b/src/trg-torrent-move-dialog.c index b10a471..d683663 100644 --- a/src/trg-torrent-move-dialog.c +++ b/src/trg-torrent-move-dialog.c @@ -25,6 +25,7 @@ #include "trg-client.h" #include "trg-main-window.h" #include "trg-torrent-move-dialog.h" +#include "trg-destination-combo.h" #include "hig.h" #include "torrent.h" #include "requests.h" @@ -40,15 +41,17 @@ typedef struct _TrgTorrentMoveDialogPrivate struct _TrgTorrentMoveDialogPrivate { trg_client *client; TrgMainWindow *win; + TrgTorrentTreeView *treeview; JsonArray *ids; GtkWidget *location_combo, *move_check, *move_button; }; -static void -trg_torrent_move_dialog_class_init(TrgTorrentMoveDialogClass * klass) -{ - g_type_class_add_private(klass, sizeof(TrgTorrentMoveDialogPrivate)); -} +enum { + PROP_0, + PROP_CLIENT, + PROP_PARENT_WINDOW, + PROP_TREEVIEW +}; static void trg_torrent_move_response_cb(GtkDialog * dlg, gint res_id, gpointer data) @@ -84,86 +87,187 @@ static void location_changed(GtkWidget * w, gpointer data) g_free(location); } -static void trg_torrent_move_dialog_init(TrgTorrentMoveDialog * self) +static GObject *trg_torrent_move_dialog_constructor(GType type, + 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); TrgTorrentMoveDialogPrivate *priv = - TRG_TORRENT_MOVE_DIALOG_GET_PRIVATE(self); + TRG_TORRENT_MOVE_DIALOG_GET_PRIVATE(object); + + gint count; + gchar *msg; + GtkWidget *w, *t; gint row = 0; t = hig_workarea_create(); - w = priv->location_combo = gtk_combo_box_entry_new_text(); - g_signal_connect(w, "changed", G_CALLBACK(location_changed), self); + w = priv->location_combo = trg_destination_combo_new(priv->client); + g_signal_connect(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); - gtk_window_set_destroy_with_parent(GTK_WINDOW(self), TRUE); + gtk_window_set_destroy_with_parent(GTK_WINDOW(object), TRUE); - gtk_dialog_add_button(GTK_DIALOG(self), GTK_STOCK_CLOSE, + gtk_dialog_add_button(GTK_DIALOG(object), GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL); priv->move_button = - gtk_dialog_add_button(GTK_DIALOG(self), _("Move"), + gtk_dialog_add_button(GTK_DIALOG(object), _("Move"), GTK_RESPONSE_ACCEPT); gtk_widget_set_sensitive(priv->move_button, FALSE); - gtk_container_set_border_width(GTK_CONTAINER(self), GUI_PAD); + gtk_container_set_border_width(GTK_CONTAINER(object), GUI_PAD); - gtk_dialog_set_default_response(GTK_DIALOG(self), GTK_RESPONSE_ACCEPT); + gtk_dialog_set_default_response(GTK_DIALOG(object), + GTK_RESPONSE_ACCEPT); - gtk_dialog_set_alternative_button_order(GTK_DIALOG(self), + gtk_dialog_set_alternative_button_order(GTK_DIALOG(object), 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(self)->vbox), t, TRUE, TRUE, 0); -} - -TrgTorrentMoveDialog *trg_torrent_move_dialog_new(TrgMainWindow * win, - trg_client * client, - TrgTorrentTreeView * ttv) -{ - GObject *obj = g_object_new(TRG_TYPE_TORRENT_MOVE_DIALOG, NULL); - TrgTorrentMoveDialogPrivate *priv = - TRG_TORRENT_MOVE_DIALOG_GET_PRIVATE(obj); - - gint count; - gchar *msg; - - priv->client = client; - priv->win = win; - priv->ids = build_json_id_array(ttv); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(object)->vbox), t, TRUE, TRUE, + 0); count = gtk_tree_selection_count_selected_rows(gtk_tree_view_get_selection - (GTK_TREE_VIEW(ttv))); + (GTK_TREE_VIEW + (priv->treeview))); + priv->ids = build_json_id_array(priv->treeview); if (count == 1) { JsonObject *json; const gchar *name; - const gchar *current_location; - get_torrent_data(client->torrentTable, - trg_mw_get_selected_torrent_id(win), &json, NULL); + get_torrent_data(priv->client->torrentTable, + trg_mw_get_selected_torrent_id(priv->win), &json, + NULL); name = torrent_get_name(json); - current_location = torrent_get_download_dir(json); - gtk_combo_box_append_text(GTK_COMBO_BOX(priv->location_combo), - current_location); - gtk_combo_box_set_active(GTK_COMBO_BOX(priv->location_combo), 0); msg = g_strdup_printf(_("Move %s"), name); } else { msg = g_strdup_printf(_("Move %d torrents"), count); } - gtk_window_set_transient_for(GTK_WINDOW(obj), GTK_WINDOW(win)); - gtk_window_set_title(GTK_WINDOW(obj), msg); + gtk_window_set_transient_for(GTK_WINDOW(object), + GTK_WINDOW(priv->win)); + gtk_window_set_title(GTK_WINDOW(object), msg); - g_signal_connect(G_OBJECT(obj), + g_signal_connect(G_OBJECT(object), "response", - G_CALLBACK(trg_torrent_move_response_cb), win); + G_CALLBACK(trg_torrent_move_response_cb), priv->win); + + return object; +} - return TRG_TORRENT_MOVE_DIALOG(obj); +static void +trg_torrent_move_dialog_get_property(GObject * object, guint property_id, + GValue * value, GParamSpec * pspec) +{ + TrgTorrentMoveDialogPrivate *priv = + TRG_TORRENT_MOVE_DIALOG_GET_PRIVATE(object); + switch (property_id) { + case PROP_CLIENT: + g_value_set_pointer(value, priv->client); + break; + case PROP_PARENT_WINDOW: + g_value_set_object(value, priv->win); + break; + case PROP_TREEVIEW: + g_value_set_object(value, priv->treeview); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + } +} + +static void +trg_torrent_move_dialog_set_property(GObject * object, guint property_id, + const GValue * value, + GParamSpec * pspec) +{ + TrgTorrentMoveDialogPrivate *priv = + TRG_TORRENT_MOVE_DIALOG_GET_PRIVATE(object); + switch (property_id) { + case PROP_CLIENT: + priv->client = g_value_get_pointer(value); + break; + case PROP_PARENT_WINDOW: + priv->win = g_value_get_object(value); + break; + case PROP_TREEVIEW: + priv->treeview = g_value_get_object(value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + } +} + +static void +trg_torrent_move_dialog_class_init(TrgTorrentMoveDialogClass * klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS(klass); + + g_type_class_add_private(klass, sizeof(TrgTorrentMoveDialogPrivate)); + + object_class->get_property = trg_torrent_move_dialog_get_property; + object_class->set_property = trg_torrent_move_dialog_set_property; + 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)); + + 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)); + + 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)); +} + +static void trg_torrent_move_dialog_init(TrgTorrentMoveDialog * self) +{ +} + +TrgTorrentMoveDialog *trg_torrent_move_dialog_new(TrgMainWindow * win, + trg_client * client, + TrgTorrentTreeView * ttv) +{ + return g_object_new(TRG_TYPE_TORRENT_MOVE_DIALOG, + "trg-client", client, + "torrent-tree-view", ttv, + "parent-window", win, NULL); } diff --git a/src/trg-torrent-props-dialog.c b/src/trg-torrent-props-dialog.c index 9b82297..d50bd89 100644 --- a/src/trg-torrent-props-dialog.c +++ b/src/trg-torrent-props-dialog.c @@ -139,12 +139,10 @@ trg_torrent_props_response_cb(GtkDialog * dlg, gint res_id, (priv->seedRatioLimit), args); json_object_set_int_member(args, FIELD_SEED_RATIO_MODE, gtk_combo_box_get_active(GTK_COMBO_BOX - (priv-> - seedRatioMode))); + (priv->seedRatioMode))); json_object_set_int_member(args, FIELD_BANDWIDTH_PRIORITY, gtk_combo_box_get_active(GTK_COMBO_BOX - (priv-> - bandwidthPriorityCombo)) + (priv->bandwidthPriorityCombo)) - 1); gtk_spin_button_json_int_out(GTK_SPIN_BUTTON diff --git a/src/trg-trackers-tree-view.c b/src/trg-trackers-tree-view.c index ea4d703..a543078 100644 --- a/src/trg-trackers-tree-view.c +++ b/src/trg-trackers-tree-view.c @@ -125,7 +125,8 @@ static void trg_tracker_announce_editing_started(GtkCellRenderer * renderer G_GNUC_UNUSED, GtkCellEditable * editable G_GNUC_UNUSED, - gchar * path G_GNUC_UNUSED, + gchar * + path G_GNUC_UNUSED, gpointer user_data) { TrgTrackersModel *model = @@ -135,7 +136,8 @@ static void trg_tracker_announce_editing_started(GtkCellRenderer * trg_trackers_model_set_accept(model, FALSE); } -static void trg_tracker_announce_editing_canceled(GtkWidget * w G_GNUC_UNUSED, +static void trg_tracker_announce_editing_canceled(GtkWidget * + w G_GNUC_UNUSED, gpointer data) { TrgTrackersModel *model = @@ -153,7 +155,8 @@ static void trg_trackers_tree_view_init(TrgTrackersTreeView * self) desc = trg_tree_view_reg_column(ttv, TRG_COLTYPE_ICONTEXT, - TRACKERCOL_TIER, _("Tier"), "tier", TRG_COLUMN_UNREMOVABLE); + TRACKERCOL_TIER, _("Tier"), "tier", + TRG_COLUMN_UNREMOVABLE); desc->model_column_icon = TRACKERCOL_ICON; desc = diff --git a/src/trg-tree-view.c b/src/trg-tree-view.c index 07188ac..0bf9f5b 100644 --- a/src/trg-tree-view.c +++ b/src/trg-tree-view.c @@ -145,7 +145,8 @@ view_popup_menu(GtkButton * button, GdkEventButton * event, 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)); + 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)) { @@ -189,8 +190,7 @@ static void trg_tree_view_add_column_after(TrgTreeView * tv, switch (desc->type) { case TRG_COLTYPE_TEXT: renderer = - desc-> - customRenderer ? desc->customRenderer : + desc->customRenderer ? desc->customRenderer : gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(desc->header, diff --git a/src/trg-tree-view.h b/src/trg-tree-view.h index 74f3adc..8418ae2 100644 --- a/src/trg-tree-view.h +++ b/src/trg-tree-view.h @@ -75,7 +75,7 @@ typedef struct { #define TRG_COLUMN_DEFAULT 0x00 #define TRG_COLUMN_SHOWING (1 << 0) /* 0x01 */ -#define TRG_COLUMN_UNREMOVABLE (1 << 1) /* 0x02 */ +#define TRG_COLUMN_UNREMOVABLE (1 << 1) /* 0x02 */ #define TRG_COLUMN_EXTRA (1 << 2) /* 0x04 */ trg_column_description *trg_tree_view_reg_column(TrgTreeView * tv, @@ -34,6 +34,7 @@ #include "util.h" #include "dispatch.h" +#include "trg-client.h" void add_file_id_to_array(JsonObject * args, gchar * key, gint index) { @@ -27,6 +27,8 @@ #include <glib-object.h> #include <json-glib/json-glib.h> +#include "trg-client.h" + #define trg_strlspeed(a, b) tr_strlspeed(a, b, sizeof(a)) #define trg_strlpercent(a, b) tr_strlpercent(a, b, sizeof(a)) #define trg_strlsize(a, b) tr_strlsize(a, b, sizeof(a)) |