summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am1
-rw-r--r--src/protocol-constants.h24
-rw-r--r--src/requests.c9
-rw-r--r--src/requests.h1
-rw-r--r--src/torrent.c5
-rw-r--r--src/torrent.h1
-rw-r--r--src/trg-main-window.c192
-rw-r--r--src/trg-main-window.h18
-rw-r--r--src/trg-menu-bar.c11
-rw-r--r--src/trg-peers-model.c10
-rw-r--r--src/trg-peers-tree-view.c4
-rw-r--r--src/trg-preferences-dialog.c49
-rw-r--r--src/trg-preferences-dialog.h4
-rw-r--r--src/trg-torrent-add-url-dialog.h1
14 files changed, 206 insertions, 124 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 00853af..260bf2d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -66,6 +66,7 @@ transmission_remote_gtk_SOURCES = main.c \
trg-remote-prefs-dialog.c \
trg-cell-renderer-wanted.c \
trg-cell-renderer-priority.c \
+ trg-torrent-move-dialog.c \
$(NULL)
transmission_remote_gtk_LDFLAGS = -lcurl $(jsonglib_LIBS) $(gtk_LIBS) $(gthread_LIBS) $(GEOIP_LIBS) $(gconf_LIBS) $(gio_LIBS) $(unique_LIBS) $(notify_LIBS)
diff --git a/src/protocol-constants.h b/src/protocol-constants.h
index 1f83e21..ea1e917 100644
--- a/src/protocol-constants.h
+++ b/src/protocol-constants.h
@@ -38,17 +38,19 @@
#define FIELD_HASH_STRING "hashString"
#define FIELD_SWARM_SPEED "swarmSpeed"
#define FIELD_ERROR_STRING "errorString"
-#define FIELD_NAME "name"
-#define FIELD_SIZEWHENDONE "sizeWhenDone"
-#define FIELD_STATUS "status"
-#define FIELD_RATEDOWNLOAD "rateDownload"
-#define FIELD_RATEUPLOAD "rateUpload"
-#define FIELD_ETA "eta"
-#define FIELD_UPLOADEDEVER "uploadedEver"
+#define FIELD_NAME "name"
+#define FIELD_SIZEWHENDONE "sizeWhenDone"
+#define FIELD_STATUS "status"
+#define FIELD_MOVE "move"
+#define FIELD_LOCATION "location"
+#define FIELD_RATEDOWNLOAD "rateDownload"
+#define FIELD_RATEUPLOAD "rateUpload"
+#define FIELD_ETA "eta"
+#define FIELD_UPLOADEDEVER "uploadedEver"
#define FIELD_DOWNLOADEDEVER "downloadedEver"
-#define FIELD_HAVEVALID "haveValid"
-#define FIELD_HAVEUNCHECKED "haveUnchecked"
-#define FIELD_PERCENTDONE "percentDone"
+#define FIELD_HAVEVALID "haveValid"
+#define FIELD_HAVEUNCHECKED "haveUnchecked"
+#define FIELD_PERCENTDONE "percentDone"
#define FIELD_TRACKERS "trackers"
#define FIELD_PEERS "peers"
#define FIELD_FILES "files"
@@ -67,6 +69,7 @@
#define FIELD_SEED_RATIO_MODE "seedRatioMode"
#define FIELD_SEED_RATIO_LIMIT "seedRatioLimit"
#define FIELD_PEER_LIMIT "peer-limit"
+#define FIELD_DOWNLOAD_DIR "downloadDir"
#define FIELD_FILES_WANTED "files-wanted"
#define FIELD_FILES_UNWANTED "files-unwanted"
@@ -87,6 +90,7 @@
#define METHOD_SESSION_SET "session-set"
#define METHOD_TORRENT_GET "torrent-get"
#define METHOD_TORRENT_SET "torrent-set"
+#define METHOD_TORRENT_SET_LOCATION "torrent-set-location"
#define METHOD_TORRENT_STOP "torrent-stop"
#define METHOD_TORRENT_VERIFY "torrent-verify"
#define METHOD_TORRENT_REMOVE "torrent-remove"
diff --git a/src/requests.c b/src/requests.c
index 7448e96..3858dd7 100644
--- a/src/requests.c
+++ b/src/requests.c
@@ -45,6 +45,15 @@ JsonNode *session_get()
return generic_request(METHOD_SESSION_GET, NULL);
}
+JsonNode *torrent_set_location(JsonArray *array, gchar *location, gboolean move)
+{
+ JsonNode *req = generic_request(METHOD_TORRENT_SET_LOCATION, array);
+ JsonObject *args = node_get_arguments(req);
+ json_object_set_boolean_member(args, FIELD_MOVE, move);
+ json_object_set_string_member(args, FIELD_LOCATION, location);
+ return req;
+}
+
JsonNode *torrent_start(JsonArray * array)
{
return generic_request(METHOD_TORRENT_START, array);
diff --git a/src/requests.h b/src/requests.h
index 9e9e502..a490004 100644
--- a/src/requests.h
+++ b/src/requests.h
@@ -35,5 +35,6 @@ JsonNode *torrent_verify(JsonArray * array);
JsonNode *torrent_remove(JsonArray * array, int removeData);
JsonNode *torrent_add(gchar * filename, gboolean paused);
JsonNode *torrent_add_url(const gchar * url, gboolean paused);
+JsonNode *torrent_set_location(JsonArray *array, gchar *location, gboolean move);
#endif /* REQUESTS_H_ */
diff --git a/src/torrent.c b/src/torrent.c
index d05cb2b..29f9e30 100644
--- a/src/torrent.c
+++ b/src/torrent.c
@@ -49,6 +49,11 @@ gint64 torrent_get_id(JsonObject * t)
return json_object_get_int_member(t, FIELD_ID);
}
+const gchar *torrent_get_download_dir(JsonObject * t)
+{
+ return json_object_get_string_member(t, FIELD_DOWNLOAD_DIR);
+}
+
const gchar *torrent_get_name(JsonObject * t)
{
return json_object_get_string_member(t, FIELD_NAME);
diff --git a/src/torrent.h b/src/torrent.h
index fa1ccf0..bfac5a6 100644
--- a/src/torrent.h
+++ b/src/torrent.h
@@ -39,6 +39,7 @@ gint64 torrent_get_eta(JsonObject * t);
gint64 torrent_get_uploaded(JsonObject * t);
gint64 torrent_get_downloaded(JsonObject * t);
const gchar *torrent_get_errorstr(JsonObject * t);
+const gchar *torrent_get_download_dir(JsonObject * t);
gint64 torrent_get_have_unchecked(JsonObject * t);
gint64 torrent_get_have_valid(JsonObject * t);
gint64 torrent_get_status(JsonObject * t);
diff --git a/src/trg-main-window.c b/src/trg-main-window.c
index a282cf0..fee7444 100644
--- a/src/trg-main-window.c
+++ b/src/trg-main-window.c
@@ -54,6 +54,7 @@
#include "trg-trackers-tree-view.h"
#include "trg-trackers-model.h"
#include "trg-state-selector.h"
+#include "trg-torrent-move-dialog.h"
#include "trg-torrent-props-dialog.h"
#include "trg-torrent-add-url-dialog.h"
#include "trg-toolbar.h"
@@ -62,62 +63,69 @@
#include "trg-remote-prefs-dialog.h"
#include "trg-preferences-dialog.h"
-/* Events */
-
-static void on_torrent_get(JsonObject * response, int status,
- gpointer data);
-
-static void on_torrent_get_first(JsonObject * response, int status,
- gpointer data);
-
-static void on_torrent_get_multipurpose(JsonObject * response,
- gboolean first, int status,
- gpointer data);
-
-static void trg_main_window_conn_changed(TrgMainWindow * win,
- gboolean connected);
-static void
-trg_main_window_update_notebook_displays(TrgMainWindow * win,
- JsonObject * t,
- GtkTreeIter * iter,
- gboolean first);
-
-static gboolean torrent_selection_changed(GtkWidget * w, gpointer data);
-
+static gboolean update_selected_torrent_notebook(TrgMainWindow *win, gboolean first);
+static void response_unref(JsonObject *response);
+static void torrent_event_notification(TrgTorrentModel *model, gchar *icon, gchar *desc, gint tmout, gchar *prefKey, GtkTreeIter *iter, gpointer *data);
+static void on_torrent_completed(TrgTorrentModel *model, GtkTreeIter *iter, gpointer *data);
+static void on_torrent_added(TrgTorrentModel *model, GtkTreeIter *iter, gpointer *data);
+static gboolean delete_event(GtkWidget *w, GdkEvent *event, gpointer *data);
+static void destroy_window(GtkWidget *w, gpointer data);
+static const gchar *make_error_message(JsonObject *response, int status);
+static void torrent_tv_onRowActivated(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *col, gpointer userdata);
+static gpointer add_files_threadfunc(gpointer data);
+static void add_url_cb(GtkWidget *w, gpointer data);
+static void add_cb(GtkWidget *w, gpointer data);
+static void disconnect_cb(GtkWidget *w, gpointer data);
+static void connect_cb(GtkWidget *w, gpointer data);
+static void open_local_prefs_cb(GtkWidget *w, gpointer data);
+static void open_remote_prefs_cb(GtkWidget *w, gpointer data);
+static TrgToolbar *trg_main_window_toolbar_new(TrgMainWindow *win);
+static void verify_cb(GtkWidget *w, gpointer data);
+static void pause_cb(GtkWidget *w, gpointer data);
+static void resume_cb(GtkWidget *w, gpointer data);
+static void remove_cb(GtkWidget *w, gpointer data);
+static void move_cb(GtkWidget *w, gpointer data);
+static void delete_cb(GtkWidget *w, gpointer data);
+static void open_props_cb(GtkWidget *w, gpointer data);
+static gint confirm_action_dialog(GtkWindow *win, GtkTreeSelection *selection, gchar *question_single, gchar *question_multi, gchar *action_stock);
+static GtkWidget *my_scrolledwin_new(GtkWidget *child);
+static void view_states_toggled_cb(GtkCheckMenuItem *w, gpointer data);
+static void view_notebook_toggled_cb(GtkCheckMenuItem *w, gpointer data);
+static GtkWidget *trg_main_window_notebook_new(TrgMainWindow *win);
+static void on_session_get(JsonObject *response, int status, gpointer data);
+static void on_torrent_get_first(JsonObject *response, int status, gpointer data);
+static void on_torrent_get(JsonObject *response, int status, gpointer data);
static gboolean trg_update_torrents_timerfunc(gpointer data);
-
-static void destroy_window();
-
-static void on_torrent_completed(TrgTorrentModel * model,
- GtkTreeIter * iter, gpointer * data);
-
-static void on_session_get(JsonObject * response, int status,
- gpointer data);
-
-static void entry_filter_changed_cb(GtkWidget * w, gpointer data);
-
-/* Actions */
-
-static void connect_cb(GtkWidget * w, gpointer data);
-static void disconnect_cb(GtkWidget * w, gpointer data);
-static void add_cb(GtkWidget * w, gpointer data);
-static void resume_cb(GtkWidget * w, gpointer data);
-static void pause_cb(GtkWidget * w, gpointer data);
-static void verify_cb(GtkWidget * w, gpointer data);
-static void remove_cb(GtkWidget * w, gpointer data);
-static void delete_cb(GtkWidget * w, gpointer data);
-static void open_about_cb(GtkWidget * w, GtkWindow * parent);
-
-/* Utility */
-
-static
-void trg_main_window_torrent_scrub(TrgMainWindow * win);
-static const gchar *make_error_message(JsonObject * response, int status);
-static GtkWidget *my_scrolledwin_new(GtkWidget * child);
-static gboolean
-trg_dialog_error_handler(TrgMainWindow * win, JsonObject * response,
- int status);
-static void response_unref(JsonObject * response);
+static void trg_main_window_update_notebook_displays(TrgMainWindow *win, JsonObject *t, GtkTreeIter *iter, gboolean first);
+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, TrgStateSelector *selector);
+static gboolean trg_dialog_error_handler(TrgMainWindow *win, JsonObject *response, int status);
+static gboolean torrent_selection_changed(GtkWidget *w, gpointer data);
+static void trg_main_window_torrent_scrub(TrgMainWindow *win);
+static void on_torrent_get_multipurpose(JsonObject *response, gboolean first, int status, gpointer data);
+static void entry_filter_changed_cb(GtkWidget *w, gpointer data);
+static void torrent_state_selection_changed(TrgStateSelector *selector, guint flag, gpointer data);
+static void trg_main_window_conn_changed(TrgMainWindow *win, gboolean connected);
+static void trg_main_window_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
+static void trg_main_window_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
+static void quit_cb(GtkWidget *w, gpointer data);
+static TrgMenuBar *trg_main_window_menu_bar_new(TrgMainWindow *win);
+static void status_icon_activated(GtkStatusIcon *icon, gpointer data);
+static void clear_filter_entry_cb(GtkWidget *w, gpointer data);
+static gboolean torrent_tv_key_press_event(GtkWidget *w, GdkEventKey *key, gpointer data);
+static GtkWidget *trg_imagemenuitem_new(GtkMenuShell *shell, char *text, char *stock_id, gboolean sensitive, GCallback cb, gpointer cbdata);
+static void set_limit_cb(GtkWidget *w, gpointer data);
+static GtkWidget *limit_item_new(TrgMainWindow *win, GtkWidget *menu, gint64 currentLimit, gint limit);
+static GtkWidget *limit_menu_new(TrgMainWindow *win, gchar *title, gchar *enabledKey, gchar *speedKey, JsonArray *ids);
+static void trg_torrent_tv_view_menu(GtkWidget *treeview, GdkEventButton *event, gpointer data);
+static void trg_status_icon_view_menu(GtkStatusIcon *icon, GdkEventButton *event, gpointer data);
+static gboolean trg_status_icon_popup_menu_cb(GtkStatusIcon *icon, gpointer userdata);
+static gboolean status_icon_button_press_event(GtkStatusIcon *icon, GdkEventButton *event, gpointer data);
+static gboolean torrent_tv_button_pressed_cb(GtkWidget *treeview, GdkEventButton *event, gpointer userdata);
+static gboolean torrent_tv_popup_menu_cb(GtkWidget *treeview, gpointer userdata);
+static void status_bar_text_pushed(GtkStatusbar *statusbar, guint context_id, gchar *text, gpointer user_data);
+static gboolean window_state_event(GtkWidget *widget, GdkEventWindowState *event, gpointer trayIcon);
G_DEFINE_TYPE(TrgMainWindow, trg_main_window, GTK_TYPE_WINDOW)
#define TRG_MAIN_WINDOW_GET_PRIVATE(o) \
@@ -131,6 +139,7 @@ struct _TrgMainWindowPrivate {
TrgStatusBar *statusBar;
GtkStatusIcon *statusIcon;
+ GdkPixbuf *icon;
TrgStateSelector *stateSelector;
TrgGeneralPanel *genDetails;
GtkWidget *notebook;
@@ -302,7 +311,7 @@ static void open_props_cb(GtkWidget * w, gpointer data)
gtk_widget_show_all(GTK_WIDGET(dialog));
}
-void
+static void
torrent_tv_onRowActivated (GtkTreeView *treeview,
GtkTreePath *path G_GNUC_UNUSED,
GtkTreeViewColumn *col G_GNUC_UNUSED,
@@ -316,6 +325,12 @@ torrent_tv_onRowActivated (GtkTreeView *treeview,
* working concurrently for each upload.
*/
+struct add_torrent_threadfunc_args {
+ GSList *list;
+ trg_client *client;
+ gpointer cb_data;
+};
+
static gpointer add_files_threadfunc(gpointer data)
{
JsonObject *response;
@@ -483,7 +498,7 @@ static void open_local_prefs_cb(GtkWidget * w G_GNUC_UNUSED, gpointer data)
{
TrgMainWindowPrivate *priv = TRG_MAIN_WINDOW_GET_PRIVATE(data);
- GtkWidget *dlg = trg_preferences_dialog_get_instance(GTK_WINDOW(data),
+ GtkWidget *dlg = trg_preferences_dialog_get_instance(TRG_MAIN_WINDOW(data),
priv->
client->gconf);
gtk_widget_show_all(dlg);
@@ -613,6 +628,13 @@ static gint confirm_action_dialog(GtkWindow * win,
return response;
}
+static void move_cb(GtkWidget * w G_GNUC_UNUSED, gpointer data)
+{
+ TrgMainWindowPrivate *priv = TRG_MAIN_WINDOW_GET_PRIVATE(data);
+ TrgTorrentMoveDialog *dlg = trg_torrent_move_dialog_new(TRG_MAIN_WINDOW(data), priv->client, priv->torrentTreeView);
+ gtk_widget_show_all(GTK_WIDGET(dlg));
+}
+
static void remove_cb(GtkWidget * w G_GNUC_UNUSED, gpointer data)
{
TrgMainWindowPrivate *priv;
@@ -1106,7 +1128,7 @@ static TrgMenuBar *trg_main_window_menu_bar_new(TrgMainWindow * win)
GObject *b_connect, *b_disconnect, *b_add, *b_resume, *b_pause,
*b_verify, *b_remove, *b_delete, *b_props, *b_local_prefs,
*b_remote_prefs, *b_about, *b_view_states, *b_view_notebook,
- *b_add_url, *b_quit;
+ *b_add_url, *b_quit, *b_move;
TrgMenuBar *menuBar;
menuBar = trg_menu_bar_new(win);
@@ -1119,6 +1141,7 @@ static TrgMenuBar *trg_main_window_menu_bar_new(TrgMainWindow * win)
"pause-button", &b_pause,
"delete-button", &b_delete,
"remove-button", &b_remove,
+ "move-button", &b_move,
"verify-button", &b_verify,
"props-button", &b_props,
"remote-prefs-button", &b_remote_prefs,
@@ -1137,6 +1160,7 @@ static TrgMenuBar *trg_main_window_menu_bar_new(TrgMainWindow * win)
g_signal_connect(b_verify, "activate", G_CALLBACK(verify_cb), win);
g_signal_connect(b_delete, "activate", G_CALLBACK(delete_cb), win);
g_signal_connect(b_remove, "activate", G_CALLBACK(remove_cb), win);
+ g_signal_connect(b_move, "activate", G_CALLBACK(move_cb), win);
g_signal_connect(b_about, "activate", G_CALLBACK(open_about_cb), win);
g_signal_connect(b_local_prefs, "activate",
G_CALLBACK(open_local_prefs_cb), win);
@@ -1325,6 +1349,9 @@ trg_torrent_tv_view_menu(GtkWidget * treeview,
trg_imagemenuitem_new(GTK_MENU_SHELL(menu), "Verify",
GTK_STOCK_REFRESH, TRUE, G_CALLBACK(verify_cb),
data);
+ trg_imagemenuitem_new(GTK_MENU_SHELL(menu), "Move",
+ GTK_STOCK_HARDDISK, TRUE, G_CALLBACK(move_cb),
+ data);
trg_imagemenuitem_new(GTK_MENU_SHELL(menu), "Remove", GTK_STOCK_REMOVE,
TRUE, G_CALLBACK(remove_cb), data);
trg_imagemenuitem_new(GTK_MENU_SHELL(menu), "Remove & Delete",
@@ -1475,6 +1502,35 @@ static gboolean window_state_event(GtkWidget * widget,
return TRUE;
}
+void trg_main_window_remove_status_icon(TrgMainWindow *win)
+{
+ TrgMainWindowPrivate *priv = TRG_MAIN_WINDOW_GET_PRIVATE(win);
+
+ if (priv->statusIcon != NULL)
+ g_object_unref(G_OBJECT(priv->statusIcon));
+
+ priv->statusIcon = NULL;
+}
+
+void trg_main_window_add_status_icon(TrgMainWindow *win)
+{
+ TrgMainWindowPrivate *priv = TRG_MAIN_WINDOW_GET_PRIVATE(win);
+
+ if (priv->icon == NULL)
+ return;
+
+ priv->statusIcon = gtk_status_icon_new_from_pixbuf(priv->icon);
+ gtk_status_icon_set_screen(priv->statusIcon,
+ gtk_window_get_screen(GTK_WINDOW
+ (win)));
+ g_signal_connect(priv->statusIcon, "activate",
+ G_CALLBACK(status_icon_activated), win);
+ g_signal_connect(priv->statusIcon, "button-press-event",
+ G_CALLBACK(status_icon_button_press_event), win);
+ g_signal_connect(priv->statusIcon, "popup-menu",
+ G_CALLBACK(trg_status_icon_popup_menu_cb), win);
+}
+
static GObject *trg_main_window_constructor(GType type,
guint
n_construct_properties,
@@ -1487,7 +1543,6 @@ static GObject *trg_main_window_constructor(GType type,
GtkWidget *outerVbox;
GtkWidget *toolbarHbox;
GtkIconTheme *theme;
- GdkPixbuf *icon;
gint width, height;
GError *error = NULL;
gboolean tray;
@@ -1499,12 +1554,12 @@ static GObject *trg_main_window_constructor(GType type,
priv = TRG_MAIN_WINDOW_GET_PRIVATE(self);
theme = gtk_icon_theme_get_default();
- icon =
+ priv->icon =
gtk_icon_theme_load_icon(theme, PACKAGE_NAME, 48,
GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
- if (icon)
- gtk_window_set_default_icon(icon);
+ if (priv->icon)
+ gtk_window_set_default_icon(priv->icon);
gtk_window_set_title(GTK_WINDOW(self), PACKAGE_NAME);
gtk_container_set_border_width(GTK_CONTAINER(self), 5);
@@ -1620,18 +1675,9 @@ static GObject *trg_main_window_constructor(GType type,
}
if (tray) {
- priv->statusIcon = gtk_status_icon_new_from_pixbuf(icon);
- gtk_status_icon_set_screen(priv->statusIcon,
- gtk_window_get_screen(GTK_WINDOW
- (self)));
- g_signal_connect(priv->statusIcon, "activate",
- G_CALLBACK(status_icon_activated), self);
- g_signal_connect(priv->statusIcon, "button-press-event",
- G_CALLBACK(status_icon_button_press_event), self);
- g_signal_connect(priv->statusIcon, "popup-menu",
- G_CALLBACK(trg_status_icon_popup_menu_cb), self);
+ trg_main_window_add_status_icon(self);
} else {
- priv->statusIcon = NULL;
+ priv->statusIcon = NULL;
}
priv->statusBar = trg_status_bar_new();
diff --git a/src/trg-main-window.h b/src/trg-main-window.h
index f5fcff2..bf8df6e 100644
--- a/src/trg-main-window.h
+++ b/src/trg-main-window.h
@@ -54,18 +54,14 @@ typedef struct {
} TrgMainWindowClass;
GType trg_main_window_get_type(void);
-
+gboolean trg_add_from_filename(TrgMainWindow *win, gchar *fileName);
+void on_session_set(JsonObject *response, int status, gpointer data);
+void on_generic_interactive_action(JsonObject *response, int status, gpointer data);
+void auto_connect_if_required(TrgMainWindow *win, trg_client *tc);
TrgMainWindow *trg_main_window_new(trg_client * tc);
-gboolean trg_add_from_filename(TrgMainWindow * win, gchar * fileName);
-void on_generic_interactive_action(JsonObject * response,
- int status, gpointer data);
-void auto_connect_if_required(TrgMainWindow * win, trg_client * tc);
-void on_session_set(JsonObject * response, int status, gpointer data);
+void trg_main_window_add_status_icon(TrgMainWindow *win);
+void trg_main_window_remove_status_icon(TrgMainWindow *win);
-G_END_DECLS struct add_torrent_threadfunc_args {
- GSList *list;
- trg_client *client;
- gpointer cb_data;
-};
+G_END_DECLS
#endif /* MAIN_WINDOW_H_ */
diff --git a/src/trg-menu-bar.c b/src/trg-menu-bar.c
index c2de388..61f5be3 100644
--- a/src/trg-menu-bar.c
+++ b/src/trg-menu-bar.c
@@ -33,6 +33,7 @@ enum {
PROP_PAUSE_BUTTON,
PROP_VERIFY_BUTTON,
PROP_PROPS_BUTTON,
+ PROP_MOVE_BUTTON,
PROP_REMOTE_PREFS_BUTTON,
PROP_LOCAL_PREFS_BUTTON,
PROP_ABOUT_BUTTON,
@@ -51,6 +52,7 @@ struct _TrgMenuBarPrivate {
GtkWidget *mb_disconnect;
GtkWidget *mb_add;
GtkWidget *mb_add_url;
+ GtkWidget *mb_move;
GtkWidget *mb_remove;
GtkWidget *mb_delete;
GtkWidget *mb_resume;
@@ -87,6 +89,7 @@ void trg_menu_bar_torrent_actions_sensitive(TrgMenuBar * mb,
gtk_widget_set_sensitive(priv->mb_resume, sensitive);
gtk_widget_set_sensitive(priv->mb_pause, sensitive);
gtk_widget_set_sensitive(priv->mb_verify, sensitive);
+ gtk_widget_set_sensitive(priv->mb_move, sensitive);
}
static void
@@ -113,6 +116,9 @@ trg_menu_bar_get_property(GObject * object, guint property_id,
case PROP_DELETE_BUTTON:
g_value_set_object(value, priv->mb_delete);
break;
+ case PROP_MOVE_BUTTON:
+ g_value_set_object(value, priv->mb_move);
+ break;
case PROP_RESUME_BUTTON:
g_value_set_object(value, priv->mb_resume);
break;
@@ -272,6 +278,9 @@ GtkWidget *trg_menu_bar_torrent_menu_new(TrgMenuBarPrivate * priv)
priv->mb_verify =
trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu), "Verify",
GTK_STOCK_REFRESH, FALSE);
+ priv->mb_move =
+ 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);
@@ -319,6 +328,8 @@ static void trg_menu_bar_class_init(TrgMenuBarClass * klass)
"add-url-button", "Add URL Button");
trg_menu_bar_install_widget_prop(object_class, PROP_REMOVE_BUTTON,
"remove-button", "Remove Button");
+ trg_menu_bar_install_widget_prop(object_class, PROP_MOVE_BUTTON,
+ "move-button", "Move Button");
trg_menu_bar_install_widget_prop(object_class, PROP_DELETE_BUTTON,
"delete-button", "Delete Button");
trg_menu_bar_install_widget_prop(object_class, PROP_RESUME_BUTTON,
diff --git a/src/trg-peers-model.c b/src/trg-peers-model.c
index a814123..26ac636 100644
--- a/src/trg-peers-model.c
+++ b/src/trg-peers-model.c
@@ -17,7 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -26,7 +26,7 @@
#include <json-glib/json-glib.h>
#include <gio/gio.h>
#include <glib/gstdio.h>
-#if HAVE_GEOIP
+#ifdef HAVE_GEOIP
#include <GeoIP.h>
#endif
@@ -159,7 +159,7 @@ void trg_peers_model_update(TrgPeersModel * model, gint64 updateSerial,
gtk_list_store_set(GTK_LIST_STORE(model), &peerIter,
PEERSCOL_ICON, GTK_STOCK_NETWORK,
PEERSCOL_IP, address,
-#if HAVE_GEOIP
+#ifdef HAVE_GEOIP
PEERSCOL_COUNTRY,
country != NULL ? country : "",
#endif
@@ -220,7 +220,7 @@ static void trg_peers_model_init(TrgPeersModel * self)
column_types[PEERSCOL_ICON] = G_TYPE_STRING;
column_types[PEERSCOL_IP] = G_TYPE_STRING;
-#if HAVE_GEOIP
+#ifdef HAVE_GEOIP
column_types[PEERSCOL_COUNTRY] = G_TYPE_STRING;
#endif
column_types[PEERSCOL_HOST] = G_TYPE_STRING;
@@ -234,7 +234,7 @@ static void trg_peers_model_init(TrgPeersModel * self)
gtk_list_store_set_column_types(GTK_LIST_STORE(self),
PEERSCOL_COLUMNS, column_types);
-#if HAVE_GEOIP
+#ifdef HAVE_GEOIP
if (g_file_test(TRG_GEOIP_DATABASE, G_FILE_TEST_EXISTS) == TRUE)
priv->geoip =
GeoIP_open(TRG_GEOIP_DATABASE,
diff --git a/src/trg-peers-tree-view.c b/src/trg-peers-tree-view.c
index 4827574..2bd624b 100644
--- a/src/trg-peers-tree-view.c
+++ b/src/trg-peers-tree-view.c
@@ -17,11 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#if HAVE_GEOIP
+#ifdef HAVE_GEOIP
#include <GeoIP.h>
#endif
diff --git a/src/trg-preferences-dialog.c b/src/trg-preferences-dialog.c
index a597f38..9964353 100644
--- a/src/trg-preferences-dialog.c
+++ b/src/trg-preferences-dialog.c
@@ -29,6 +29,7 @@
#include "hig.h"
#include "trg-preferences-dialog.h"
#include "trg-json-widgets.h"
+#include "trg-main-window.h"
#include "trg-preferences.h"
#define TRG_PREFERENCES_DIALOG_GET_PRIVATE(object) \
@@ -40,14 +41,14 @@ G_DEFINE_TYPE(TrgPreferencesDialog, trg_preferences_dialog,
enum {
PROP_0,
PROP_GCONF_CLIENT,
- PROP_PARENT_WINDOW
+ PROP_MAIN_WINDOW
};
#define GCONF_OBJECT_KEY "gconf-key"
struct _TrgPreferencesDialogPrivate {
GConfClient *gconf;
- GtkWindow *parent;
+ TrgMainWindow *win;
};
static GObject *instance = NULL;
@@ -58,14 +59,14 @@ trg_preferences_dialog_set_property(GObject * object,
const GValue * value,
GParamSpec * pspec G_GNUC_UNUSED)
{
- TrgPreferencesDialog *pref_dlg = TRG_PREFERENCES_DIALOG(object);
+ TrgPreferencesDialogPrivate *priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(object);
switch (prop_id) {
case PROP_GCONF_CLIENT:
- pref_dlg->priv->gconf = g_value_get_object(value);
+ priv->gconf = g_value_get_object(value);
break;
- case PROP_PARENT_WINDOW:
- pref_dlg->priv->parent = g_value_get_object(value);
+ case PROP_MAIN_WINDOW:
+ priv->win = g_value_get_object(value);
break;
}
}
@@ -87,14 +88,14 @@ trg_preferences_dialog_get_property(GObject * object,
GValue * value,
GParamSpec * pspec G_GNUC_UNUSED)
{
- TrgPreferencesDialog *pref_dlg = TRG_PREFERENCES_DIALOG(object);
+ TrgPreferencesDialogPrivate *priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(object);
switch (prop_id) {
case PROP_GCONF_CLIENT:
- g_value_set_object(value, pref_dlg->priv->gconf);
+ g_value_set_object(value, priv->gconf);
break;
- case PROP_PARENT_WINDOW:
- g_value_set_object(value, pref_dlg->priv->parent);
+ case PROP_MAIN_WINDOW:
+ g_value_set_object(value, priv->win);
break;
}
}
@@ -194,7 +195,15 @@ static GtkWidget *new_entry(GConfClient * gconf, const char *key)
return w;
}
-static GtkWidget *trg_prefs_desktopPage(GConfClient * gconf)
+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));
+ else
+ trg_main_window_remove_status_icon(TRG_MAIN_WINDOW(win));
+}
+
+static GtkWidget *trg_prefs_desktopPage(GConfClient * gconf, TrgMainWindow *win)
{
GtkWidget *tray, *w, *t;
gint row = 0;
@@ -205,6 +214,7 @@ static GtkWidget *trg_prefs_desktopPage(GConfClient * gconf)
tray = new_check_button(gconf, "Show in system tray",
TRG_GCONF_KEY_SYSTEM_TRAY);
+ g_signal_connect(G_OBJECT(tray), "toggled", G_CALLBACK(toggle_tray_icon), win);
hig_workarea_add_wide_control(t, &row, tray);
w = new_check_button(gconf, "Minimise to system tray",
@@ -290,7 +300,7 @@ static GObject *trg_preferences_dialog_constructor(GType type,
construct_params);
priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(object);
- gtk_window_set_transient_for(GTK_WINDOW(object), priv->parent);
+ 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);
@@ -308,7 +318,7 @@ static GObject *trg_preferences_dialog_constructor(GType type,
gtk_label_new("Connection"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
- trg_prefs_desktopPage(priv->gconf),
+ trg_prefs_desktopPage(priv->gconf, priv->win),
gtk_label_new("Desktop"));
gtk_container_set_border_width(GTK_CONTAINER(notebook), GUI_PAD);
@@ -347,10 +357,10 @@ trg_preferences_dialog_class_init(TrgPreferencesDialogClass * class)
G_PARAM_STATIC_BLURB));
g_object_class_install_property(g_object_class,
- PROP_PARENT_WINDOW,
+ PROP_MAIN_WINDOW,
g_param_spec_object
- ("parent-window", "Parent window",
- "Parent window", GTK_TYPE_WINDOW,
+ ("main-window", "Main Window",
+ "Main Window", TRG_TYPE_MAIN_WINDOW,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_NAME |
@@ -363,17 +373,14 @@ trg_preferences_dialog_class_init(TrgPreferencesDialogClass * class)
static void trg_preferences_dialog_init(TrgPreferencesDialog * pref_dlg)
{
- pref_dlg->priv = TRG_PREFERENCES_DIALOG_GET_PRIVATE(pref_dlg);
-
- pref_dlg->priv->gconf = NULL;
}
-GtkWidget *trg_preferences_dialog_get_instance(GtkWindow * parent,
+GtkWidget *trg_preferences_dialog_get_instance(TrgMainWindow *win,
GConfClient * client)
{
if (instance == NULL) {
instance = g_object_new(TRG_TYPE_PREFERENCES_DIALOG,
- "parent-window", parent,
+ "main-window", win,
"gconf-client", client, NULL);
}
diff --git a/src/trg-preferences-dialog.h b/src/trg-preferences-dialog.h
index 214eedb..49791a5 100644
--- a/src/trg-preferences-dialog.h
+++ b/src/trg-preferences-dialog.h
@@ -25,6 +25,8 @@
#include <gtk/gtk.h>
#include <gconf/gconf-client.h>
+#include "trg-main-window.h"
+
G_BEGIN_DECLS typedef struct _TrgPreferencesDialog TrgPreferencesDialog;
typedef struct _TrgPreferencesDialogClass TrgPreferencesDialogClass;
typedef struct _TrgPreferencesDialogPrivate TrgPreferencesDialogPrivate;
@@ -47,7 +49,7 @@ struct _TrgPreferencesDialogClass {
GType trg_preferences_dialog_get_type(void);
-GtkWidget *trg_preferences_dialog_get_instance(GtkWindow * parent,
+GtkWidget *trg_preferences_dialog_get_instance(TrgMainWindow *win,
GConfClient * client);
G_END_DECLS
#endif /* TRG_PREFERENCES_WINDOW_H_ */
diff --git a/src/trg-torrent-add-url-dialog.h b/src/trg-torrent-add-url-dialog.h
index cdf8a26..d089169 100644
--- a/src/trg-torrent-add-url-dialog.h
+++ b/src/trg-torrent-add-url-dialog.h
@@ -17,7 +17,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
#ifndef TRG_TORRENT_ADD_URL_DIALOG_H_
#define TRG_TORRENT_ADD_URL_DIALOG_H_