diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 5 | ||||
-rw-r--r-- | src/trg-file-parser.c | 6 | ||||
-rw-r--r-- | src/trg-main-window.c | 44 | ||||
-rw-r--r-- | src/trg-menu-bar.c | 3 | ||||
-rw-r--r-- | src/trg-preferences-dialog.c | 4 | ||||
-rw-r--r-- | src/trg-preferences.c | 10 | ||||
-rw-r--r-- | src/trg-preferences.h | 3 | ||||
-rw-r--r-- | src/trg-torrent-add-dialog.c | 46 | ||||
-rw-r--r-- | src/trg-torrent-add-dialog.h | 3 | ||||
-rw-r--r-- | src/trg-torrent-props-dialog.c | 6 | ||||
-rw-r--r-- | src/util.c | 2 | ||||
-rw-r--r-- | src/util.h | 4 |
12 files changed, 57 insertions, 79 deletions
@@ -50,6 +50,7 @@ message_received_cb(UniqueApp * app G_GNUC_UNUSED, { TrgMainWindow *win; UniqueResponse res; + gchar *fileName; win = TRG_MAIN_WINDOW(user_data); @@ -61,10 +62,10 @@ message_received_cb(UniqueApp * app G_GNUC_UNUSED, res = UNIQUE_RESPONSE_OK; break; case COMMAND_ADD: + fileName = unique_message_data_get_filename(message); res = trg_add_from_filename(win, - unique_message_data_get_filename - (message)) ? UNIQUE_RESPONSE_OK : + fileName) ? UNIQUE_RESPONSE_OK : UNIQUE_RESPONSE_FAIL; break; default: diff --git a/src/trg-file-parser.c b/src/trg-file-parser.c index ec22d1d..9bb9d67 100644 --- a/src/trg-file-parser.c +++ b/src/trg-file-parser.c @@ -15,9 +15,9 @@ #define my_print_errno(x) printf("%s: error (%d) %s\n", __func__, errno, x); static trg_torrent_file_node - *trg_torrent_file_node_insert(trg_torrent_file_node * top, - be_node * file_node, guint index, - gint64 * total_length) + * trg_torrent_file_node_insert(trg_torrent_file_node * top, + be_node * file_node, guint index, + gint64 * total_length) { int i; trg_torrent_file_node *path_el_parent = top; diff --git a/src/trg-main-window.c b/src/trg-main-window.c index 8080038..af6b048 100644 --- a/src/trg-main-window.c +++ b/src/trg-main-window.c @@ -383,32 +383,8 @@ static void add_url_cb(GtkWidget * w G_GNUC_UNUSED, gpointer data) static void add_cb(GtkWidget * w G_GNUC_UNUSED, gpointer data) { TrgMainWindowPrivate *priv = TRG_MAIN_WINDOW_GET_PRIVATE(data); - /*TrgTorrentAddDialog *dialog; - GtkFileFilter *filter; */ trg_torrent_add_dialog(TRG_MAIN_WINDOW(data), priv->client); - - /*dialog = trg_torrent_add_dialog_new(TRG_MAIN_WINDOW(data), priv->client, NULL, TRUE); - gtk_dialog_run(GTK_DIALOG(dialog)); */ - - /*dialog = gtk_file_chooser_dialog_new("Open File", - GTK_WINDOW(data), - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, - GTK_RESPONSE_ACCEPT, NULL); - gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE); - - filter = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filter, "*.torrent"); - gtk_file_filter_set_name(filter, _("BitTorrent Metadata")); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); - - if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { - } - - gtk_widget_destroy(dialog); */ } static void pause_cb(GtkWidget * w G_GNUC_UNUSED, gpointer data) @@ -426,10 +402,24 @@ gboolean trg_add_from_filename(TrgMainWindow * win, gchar * fileName) TrgMainWindowPrivate *priv = TRG_MAIN_WINDOW_GET_PRIVATE(win); if (g_file_test(fileName, G_FILE_TEST_EXISTS) == TRUE) { - JsonNode *torrentAddReq = torrent_add(fileName, pref_get_start_paused(priv->client->gconf)); - dispatch_async(priv->client, torrentAddReq, - on_generic_interactive_action, win); + if (pref_get_add_options_dialog(priv->client->gconf)) { + GSList *filesList = g_slist_append(NULL, fileName); + TrgTorrentAddDialog *dialog = + trg_torrent_add_dialog_new(win, priv->client, filesList); + + gtk_widget_show_all(GTK_WIDGET(dialog)); + } else { + JsonNode *torrentAddReq = + torrent_add(fileName, + pref_get_start_paused(priv->client->gconf)); + dispatch_async(priv->client, torrentAddReq, + on_generic_interactive_action, win); + g_free(fileName); + } return TRUE; + } else { + g_printf("file doesn't exist: \"%s\"\n", fileName); + g_free(fileName); } return FALSE; diff --git a/src/trg-menu-bar.c b/src/trg-menu-bar.c index ddbdd58..9b81154 100644 --- a/src/trg-menu-bar.c +++ b/src/trg-menu-bar.c @@ -287,7 +287,8 @@ GtkWidget *trg_menu_bar_torrent_menu_new(TrgMenuBarPrivate * priv) priv->mb_props = trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu), - _("Properties"), GTK_STOCK_PROPERTIES, FALSE); + _("Properties"), GTK_STOCK_PROPERTIES, + FALSE); priv->mb_resume = trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu), _("_Resume"), GTK_STOCK_MEDIA_PLAY, FALSE); diff --git a/src/trg-preferences-dialog.c b/src/trg-preferences-dialog.c index fb71881..6adf26c 100644 --- a/src/trg-preferences-dialog.c +++ b/src/trg-preferences-dialog.c @@ -305,7 +305,7 @@ static GtkWidget *trg_prefs_desktopPage(GConfClient * gconf, return t; } -static GtkWidget *trg_prefs_behaviorPage(GConfClient *gconf) +static GtkWidget *trg_prefs_behaviorPage(GConfClient * gconf) { GtkWidget *w, *t; gint row = 0; @@ -407,7 +407,7 @@ static GObject *trg_preferences_dialog_constructor(GType type, gtk_label_new(_("Desktop"))); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), - trg_prefs_behaviorPage(priv->gconf), + trg_prefs_behaviorPage(priv->gconf), gtk_label_new(_("Behavior"))); gtk_container_set_border_width(GTK_CONTAINER(notebook), GUI_PAD); diff --git a/src/trg-preferences.c b/src/trg-preferences.c index ca52be4..6d53007 100644 --- a/src/trg-preferences.c +++ b/src/trg-preferences.c @@ -20,8 +20,16 @@ #include <glib.h> #include <gconf/gconf-client.h> +#include "util.h" #include "trg-preferences.h" -gboolean pref_get_start_paused(GConfClient *gcc) { +gboolean pref_get_add_options_dialog(GConfClient * gcc) +{ + return gconf_client_get_bool_or_true(gcc, + TRG_GCONF_KEY_ADD_OPTIONS_DIALOG); +} + +gboolean pref_get_start_paused(GConfClient * gcc) +{ return gconf_client_get_bool(gcc, TRG_GCONF_KEY_START_PAUSED, NULL); } diff --git a/src/trg-preferences.h b/src/trg-preferences.h index e781dc6..a58b7e2 100644 --- a/src/trg-preferences.h +++ b/src/trg-preferences.h @@ -41,6 +41,7 @@ #define TRG_GCONF_KEY_ADD_OPTIONS_DIALOG "/apps/transmission-remote-gtk/add-options-dialog" #define TRG_GCONF_KEY_START_PAUSED "/apps/transmission-remote-gtk/start-paused" -gboolean pref_get_start_paused(GConfClient *gcc); +gboolean pref_get_start_paused(GConfClient * gcc); +gboolean pref_get_add_options_dialog(GConfClient * gcc); #endif /* TRG_PREFERENCES_H_ */ diff --git a/src/trg-torrent-add-dialog.c b/src/trg-torrent-add-dialog.c index 2837e62..46bb30c 100644 --- a/src/trg-torrent-add-dialog.c +++ b/src/trg-torrent-add-dialog.c @@ -45,7 +45,6 @@ enum { PROP_0, PROP_FILENAME, PROP_PARENT, - PROP_SHOW_OPTIONS, PROP_CLIENT }; @@ -75,7 +74,6 @@ typedef struct _TrgTorrentAddDialogPrivate struct _TrgTorrentAddDialogPrivate { trg_client *client; TrgMainWindow *parent; - gint show_options; GSList *filenames; GtkWidget *source_chooser; GtkWidget *dest_combo; @@ -98,9 +96,6 @@ trg_torrent_add_dialog_set_property(GObject * object, case PROP_FILENAME: priv->filenames = g_value_get_pointer(value); break; - case PROP_SHOW_OPTIONS: - priv->show_options = g_value_get_int(value); - break; case PROP_PARENT: priv->parent = g_value_get_object(value); break; @@ -123,9 +118,6 @@ trg_torrent_add_dialog_get_property(GObject * object, case PROP_FILENAME: g_value_set_pointer(value, priv->filenames); break; - case PROP_SHOW_OPTIONS: - g_value_set_int(value, priv->show_options); - break; case PROP_PARENT: g_value_set_object(value, priv->parent); break; @@ -370,8 +362,8 @@ setSubtree(GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * 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) { @@ -381,14 +373,14 @@ setSubtree(GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter, 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; - if (!gtk_tree_model_iter_nth_child(model, &child, &tmp_iter, i)) + if (!gtk_tree_model_iter_nth_child + (model, &child, &tmp_iter, i)) continue; gtk_tree_model_get(model, &child, column, ¤t_value, -1); @@ -851,8 +843,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); @@ -969,19 +961,6 @@ trg_torrent_add_dialog_class_init(TrgTorrentAddDialogClass * klass) G_PARAM_STATIC_BLURB)); g_object_class_install_property(object_class, - PROP_SHOW_OPTIONS, - g_param_spec_int("show-options", - "show-options", - "show-options", 0, 1, - 1, - 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", @@ -1002,12 +981,10 @@ static void trg_torrent_add_dialog_init(TrgTorrentAddDialog * self) TrgTorrentAddDialog *trg_torrent_add_dialog_new(TrgMainWindow * parent, trg_client * client, - GSList * filenames, - gboolean showOptions) + GSList * filenames) { return g_object_new(TRG_TYPE_TORRENT_ADD_DIALOG, "filenames", filenames, - "show-options", showOptions ? 1 : 0, "parent", parent, "client", client, NULL); } @@ -1020,9 +997,8 @@ void trg_torrent_add_dialog(TrgMainWindow * win, trg_client * client) c = gtk_check_button_new_with_mnemonic(_("Show _options dialog")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(c), - gconf_client_get_bool_or_true(client-> - gconf, - TRG_GCONF_KEY_ADD_OPTIONS_DIALOG)); + pref_get_add_options_dialog + (client->gconf)); gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(w), c); if (gtk_dialog_run(GTK_DIALOG(w)) == GTK_RESPONSE_ACCEPT) { @@ -1037,7 +1013,7 @@ void trg_torrent_add_dialog(TrgMainWindow * win, trg_client * client) if (showOptions) { TrgTorrentAddDialog *dialog = - trg_torrent_add_dialog_new(win, client, l, showOptions); + trg_torrent_add_dialog_new(win, client, l); gtk_widget_show_all(GTK_WIDGET(dialog)); } else { diff --git a/src/trg-torrent-add-dialog.h b/src/trg-torrent-add-dialog.h index ab3d6cb..0b932ff 100644 --- a/src/trg-torrent-add-dialog.h +++ b/src/trg-torrent-add-dialog.h @@ -50,8 +50,7 @@ GType trg_torrent_add_dialog_get_type(void); TrgTorrentAddDialog *trg_torrent_add_dialog_new(TrgMainWindow * win, trg_client * client, - GSList * filenames, - gint showOptions); + GSList * filenames); void trg_torrent_add_dialog(TrgMainWindow * win, trg_client * client); G_END_DECLS diff --git a/src/trg-torrent-props-dialog.c b/src/trg-torrent-props-dialog.c index bf9f096..2851b7c 100644 --- a/src/trg-torrent-props-dialog.c +++ b/src/trg-torrent-props-dialog.c @@ -138,10 +138,12 @@ 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 @@ -49,7 +49,7 @@ void add_file_id_to_array(JsonObject * args, gchar * key, gint index) void g_str_slist_free(GSList * list) { - g_slist_foreach( list, (GFunc)g_free, NULL ); + g_slist_foreach(list, (GFunc) g_free, NULL); g_slist_free(list); } @@ -22,6 +22,7 @@ #ifndef UTIL_H_ #define UTIL_H_ +#include <gtk/gtk.h> #include <gconf/gconf-client.h> #include <glib-object.h> #include <json-glib/json-glib.h> @@ -45,8 +46,7 @@ gboolean gconf_client_get_bool_or_true(GConfClient * gconf, gchar * key); void response_unref(JsonObject * response); const gchar *make_error_message(JsonObject * response, int status); -void trg_error_dialog(GtkWindow * parent, int status, - JsonObject * response); +void trg_error_dialog(GtkWindow * parent, int status, JsonObject * response); char *tr_strltime_long(char *buf, gint64 seconds, size_t buflen); char *tr_strltime_short(char *buf, gint64 seconds, size_t buflen); |