Rewrite error messages to be less unnecessarily verbose.
Only allow one instance of the preference window at a time. Beat the dialogs with the GNOME HiG stick. Handle missing .torrent files on startup better.
This commit is contained in:
parent
38050332f5
commit
a2914be847
42
gtk/conf.c
42
gtk/conf.c
|
@ -70,8 +70,7 @@ lockfile(const char *file, char **errstr) {
|
|||
|
||||
if(0 > (fd = open(file, O_RDWR | O_CREAT, 0666))) {
|
||||
savederr = errno;
|
||||
*errstr = g_strdup_printf(
|
||||
_("An error occurred while opening the file %s for writing:\n%s"),
|
||||
*errstr = g_strdup_printf(_("Failed to open the file %s for writing:\n%s"),
|
||||
file, strerror(errno));
|
||||
errno = savederr;
|
||||
return -1;
|
||||
|
@ -88,8 +87,7 @@ lockfile(const char *file, char **errstr) {
|
|||
*errstr = g_strdup_printf(_("Another copy of %s is already running."),
|
||||
g_get_application_name());
|
||||
else
|
||||
*errstr = g_strdup_printf(
|
||||
_("An error occurred while locking the file %s:\n%s"),
|
||||
*errstr = g_strdup_printf(_("Failed to lock the file %s:\n%s"),
|
||||
file, strerror(errno));
|
||||
close(fd);
|
||||
errno = savederr;
|
||||
|
@ -108,15 +106,13 @@ cf_init(const char *dir, char **errstr) {
|
|||
|
||||
if(0 > stat(dir, &sb)) {
|
||||
if(ENOENT != errno)
|
||||
*errstr = g_strdup_printf(
|
||||
_("An error occurred while checking the directory %s:\n%s"),
|
||||
*errstr = g_strdup_printf(_("Failed to check the directory %s:\n%s"),
|
||||
dir, strerror(errno));
|
||||
else {
|
||||
if(0 == mkdir(dir, 0777))
|
||||
return TRUE;
|
||||
else
|
||||
*errstr = g_strdup_printf(
|
||||
_("An error occurred while creating the directory %s:\n%s"),
|
||||
*errstr = g_strdup_printf(_("Failed to create the directory %s:\n%s"),
|
||||
dir, strerror(errno));
|
||||
}
|
||||
return FALSE;
|
||||
|
@ -160,8 +156,7 @@ cf_loadprefs(char **errstr) {
|
|||
if(NULL != err) {
|
||||
if(!g_error_matches(err, G_FILE_ERROR, G_FILE_ERROR_NOENT))
|
||||
*errstr = g_strdup_printf(
|
||||
_("An error occurred while opening the file %s for reading:\n%s"),
|
||||
path, err->message);
|
||||
_("Failed to open the file %s for reading:\n%s"), path, err->message);
|
||||
goto done;
|
||||
}
|
||||
g_io_channel_set_line_term(io, &term, 1);
|
||||
|
@ -172,8 +167,7 @@ cf_loadprefs(char **errstr) {
|
|||
switch(g_io_channel_read_line(io, &line, &len, &termpos, &err)) {
|
||||
case G_IO_STATUS_ERROR:
|
||||
*errstr = g_strdup_printf(
|
||||
_("An error occurred while reading from the file %s:\n%s"),
|
||||
path, err->message);
|
||||
_("Error while reading from the file %s:\n%s"), path, err->message);
|
||||
goto done;
|
||||
case G_IO_STATUS_NORMAL:
|
||||
if(NULL != line) {
|
||||
|
@ -236,8 +230,7 @@ cf_saveprefs(char **errstr) {
|
|||
|
||||
if(0 > (fd = lockfile(tmpfile, errstr))) {
|
||||
g_free(errstr);
|
||||
*errstr = g_strdup_printf(
|
||||
_("An error occurred while opening or locking the file %s:\n%s"),
|
||||
*errstr = g_strdup_printf(_("Failed to open or lock the file %s:\n%s"),
|
||||
tmpfile, strerror(errno));
|
||||
goto done;
|
||||
}
|
||||
|
@ -257,16 +250,14 @@ cf_saveprefs(char **errstr) {
|
|||
g_tree_foreach(prefs, writefile_traverse, &info);
|
||||
if(NULL != info.err ||
|
||||
G_IO_STATUS_ERROR == g_io_channel_shutdown(io, TRUE, &info.err)) {
|
||||
*errstr = g_strdup_printf(
|
||||
_("An error occurred while writing to the file %s:\n%s"),
|
||||
*errstr = g_strdup_printf(_("Error while writing to the file %s:\n%s"),
|
||||
tmpfile, info.err->message);
|
||||
g_error_free(info.err);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if(0 > rename(tmpfile, file)) {
|
||||
*errstr = g_strdup_printf(
|
||||
_("An error occurred while renaming the file %s to %s:\n%s"),
|
||||
*errstr = g_strdup_printf(_("Failed to rename the file %s to %s:\n%s"),
|
||||
tmpfile, file, strerror(errno));
|
||||
goto done;
|
||||
}
|
||||
|
@ -328,8 +319,7 @@ cf_loadstate(char **errstr) {
|
|||
if(NULL != err) {
|
||||
if(!g_error_matches(err, G_FILE_ERROR, G_FILE_ERROR_NOENT))
|
||||
*errstr = g_strdup_printf(
|
||||
_("An error occurred while opening the file %s for reading:\n%s"),
|
||||
path, err->message);
|
||||
_("Failed to open the file %s for reading:\n%s"), path, err->message);
|
||||
goto done;
|
||||
}
|
||||
g_io_channel_set_line_term(io, &term, 1);
|
||||
|
@ -340,8 +330,7 @@ cf_loadstate(char **errstr) {
|
|||
switch(g_io_channel_read_line(io, &line, &len, &termpos, &err)) {
|
||||
case G_IO_STATUS_ERROR:
|
||||
*errstr = g_strdup_printf(
|
||||
_("An error occurred while reading from the file %s:\n%s"),
|
||||
path, err->message);
|
||||
_("Error while reading from the file %s:\n%s"), path, err->message);
|
||||
goto done;
|
||||
case G_IO_STATUS_NORMAL:
|
||||
if(NULL != line) {
|
||||
|
@ -439,8 +428,7 @@ cf_savestate(int count, tr_stat_t *torrents, char **errstr) {
|
|||
|
||||
if(0 > (fd = lockfile(tmpfile, errstr))) {
|
||||
g_free(errstr);
|
||||
*errstr = g_strdup_printf(
|
||||
_("An error occurred while opening or locking the file %s:\n%s"),
|
||||
*errstr = g_strdup_printf(_("Failed to open or lock the file %s:\n%s"),
|
||||
tmpfile, strerror(errno));
|
||||
goto done;
|
||||
}
|
||||
|
@ -480,16 +468,14 @@ cf_savestate(int count, tr_stat_t *torrents, char **errstr) {
|
|||
}
|
||||
if(NULL != err ||
|
||||
G_IO_STATUS_ERROR == g_io_channel_shutdown(io, TRUE, &err)) {
|
||||
*errstr = g_strdup_printf(
|
||||
_("An error occurred while writing to the file %s:\n%s"),
|
||||
*errstr = g_strdup_printf(_("Error while writing to the file %s:\n%s"),
|
||||
tmpfile, err->message);
|
||||
g_error_free(err);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if(0 > rename(tmpfile, file)) {
|
||||
*errstr = g_strdup_printf(
|
||||
_("An error occurred while renaming the file %s to %s:\n%s"),
|
||||
*errstr = g_strdup_printf(_("Failed to rename the file %s to %s:\n%s"),
|
||||
tmpfile, file, strerror(errno));
|
||||
goto done;
|
||||
}
|
||||
|
|
110
gtk/dialogs.c
110
gtk/dialogs.c
|
@ -58,6 +58,8 @@ struct addcb {
|
|||
GtkButtonBox *altbox;
|
||||
};
|
||||
|
||||
static void
|
||||
windclosed(GtkWidget *widget SHUTUP, gpointer gdata);
|
||||
static void
|
||||
clicklimitbox(GtkWidget *widget, gpointer gdata);
|
||||
static void
|
||||
|
@ -70,7 +72,7 @@ static void
|
|||
addresp(GtkWidget *widget, gint resp, gpointer gdata);
|
||||
|
||||
void
|
||||
makeprefwindow(GtkWindow *parent, tr_handle_t *tr) {
|
||||
makeprefwindow(GtkWindow *parent, tr_handle_t *tr, gboolean *opened) {
|
||||
char *title = g_strdup_printf(_("%s Preferences"), g_get_application_name());
|
||||
GtkWidget *wind = gtk_dialog_new_with_buttons(title, parent,
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
|
||||
|
@ -78,20 +80,26 @@ makeprefwindow(GtkWindow *parent, tr_handle_t *tr) {
|
|||
GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
|
||||
GtkWidget *table = gtk_table_new(4, 2, FALSE);
|
||||
GtkWidget *portnum = gtk_spin_button_new_with_range(1, 0xffff, 1);
|
||||
GtkWidget *limitbox = gtk_check_button_new_with_label(_("Limit upload speed"));
|
||||
GtkWidget *limitbox = gtk_check_button_new_with_mnemonic(
|
||||
_("_Limit upload speed"));
|
||||
GtkWidget *limitnum = gtk_spin_button_new_with_range(0, G_MAXLONG, 1);
|
||||
GtkWidget *dirstr = gtk_file_chooser_button_new(_("Choose download directory"),
|
||||
GtkWidget *dirstr = gtk_file_chooser_button_new(
|
||||
_("Choose download directory"),
|
||||
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
|
||||
GtkWidget *label;
|
||||
GtkWidget **array;
|
||||
const char *pref;
|
||||
struct prefdata *data = g_new0(struct prefdata, 1);
|
||||
|
||||
*opened = TRUE;
|
||||
|
||||
g_free(title);
|
||||
gtk_widget_set_name(wind, "TransmissionDialog");
|
||||
gtk_table_set_col_spacings(GTK_TABLE(table), 12);
|
||||
gtk_table_set_row_spacings(GTK_TABLE(table), 12);
|
||||
gtk_dialog_set_default_response(GTK_DIALOG(wind), GTK_RESPONSE_OK);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(table), 12);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(table), 6);
|
||||
gtk_window_set_resizable(GTK_WINDOW(wind), FALSE);
|
||||
|
||||
data->port = GTK_SPIN_BUTTON(portnum);
|
||||
data->uselimit = GTK_CHECK_BUTTON(limitbox);
|
||||
|
@ -100,15 +108,6 @@ makeprefwindow(GtkWindow *parent, tr_handle_t *tr) {
|
|||
data->parent = parent;
|
||||
data->tr = tr;
|
||||
|
||||
/* port label and entry */
|
||||
label = gtk_label_new(_("Listening port:"));
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0, .5);
|
||||
pref = cf_getpref(PREF_PORT);
|
||||
gtk_spin_button_set_value(GTK_SPIN_BUTTON(portnum),
|
||||
(NULL == pref ? TR_DEFAULT_PORT : strtol(pref, NULL, 10)));
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), portnum, 1, 2, 0, 1);
|
||||
|
||||
/* limit checkbox */
|
||||
pref = cf_getpref(PREF_USELIMIT);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(limitbox),
|
||||
|
@ -116,34 +115,56 @@ makeprefwindow(GtkWindow *parent, tr_handle_t *tr) {
|
|||
array = g_new(GtkWidget*, 2);
|
||||
g_signal_connect_data(limitbox, "clicked", G_CALLBACK(clicklimitbox),
|
||||
array, (GClosureNotify)g_free, 0);
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), limitbox, 0, 2, 1, 2);
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), limitbox, 0, 2, 0, 1);
|
||||
|
||||
/* limit label and entry */
|
||||
label = gtk_label_new(_("Maximum upload speed:"));
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0, 1.0/3.0);
|
||||
label = gtk_label_new_with_mnemonic(_("Maximum _upload speed:"));
|
||||
gtk_label_set_mnemonic_widget(GTK_LABEL(label), limitnum);
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0, .5);
|
||||
pref = cf_getpref(PREF_LIMIT);
|
||||
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(limitnum), TRUE);
|
||||
gtk_spin_button_set_value(GTK_SPIN_BUTTON(limitnum),
|
||||
(NULL == pref ? DEFAULT_UPLIMIT : strtol(pref,NULL,10)));
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3);
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), limitnum, 1, 2, 2, 3);
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), limitnum, 1, 2, 1, 2);
|
||||
array[0] = label;
|
||||
array[1] = limitnum;
|
||||
clicklimitbox(limitbox, array);
|
||||
|
||||
/* directory label and chooser */
|
||||
label = gtk_label_new(_("Download Directory:"));
|
||||
label = gtk_label_new_with_mnemonic(_("_Download directory:"));
|
||||
gtk_label_set_mnemonic_widget(GTK_LABEL(label), dirstr);
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0, .5);
|
||||
if(NULL != (pref = cf_getpref(PREF_DIR)))
|
||||
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dirstr), pref);
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3);
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), dirstr, 1, 2, 2, 3);
|
||||
|
||||
/* port label and entry */
|
||||
label = gtk_label_new_with_mnemonic(_("Listening _port:"));
|
||||
gtk_label_set_mnemonic_widget(GTK_LABEL(label), portnum);
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0, .5);
|
||||
pref = cf_getpref(PREF_PORT);
|
||||
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(portnum), TRUE);
|
||||
gtk_spin_button_set_value(GTK_SPIN_BUTTON(portnum),
|
||||
(NULL == pref ? TR_DEFAULT_PORT : strtol(pref, NULL, 10)));
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4);
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), dirstr, 1, 2, 3, 4);
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), portnum, 1, 2, 3, 4);
|
||||
|
||||
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(wind)->vbox), table);
|
||||
g_signal_connect_data(wind, "response", G_CALLBACK(clickdialog),
|
||||
data, (GClosureNotify)g_free, 0);
|
||||
g_signal_connect(wind, "destroy", G_CALLBACK(windclosed), opened);
|
||||
gtk_widget_show_all(wind);
|
||||
}
|
||||
|
||||
static void
|
||||
windclosed(GtkWidget *widget SHUTUP, gpointer gdata) {
|
||||
gboolean *preachy_gcc = gdata;
|
||||
|
||||
*preachy_gcc = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
clicklimitbox(GtkWidget *widget, gpointer gdata) {
|
||||
GtkWidget **widgets = gdata;
|
||||
|
@ -162,12 +183,12 @@ clickdialog(GtkWidget *widget, int resp, gpointer gdata) {
|
|||
char *strnum, *errstr;
|
||||
gboolean boolval;
|
||||
|
||||
if(GTK_RESPONSE_OK == resp) {
|
||||
if(GTK_RESPONSE_APPLY == resp || GTK_RESPONSE_OK == resp) {
|
||||
/* check directory */
|
||||
if(NULL != (strval = gtk_file_chooser_get_current_folder(data->dir))) {
|
||||
if(!mkdir_p(strval, 0777)) {
|
||||
errmsg(data->parent,
|
||||
_("An error occurred while creating the directory %s:\n%s"),
|
||||
_("Failed to create the directory %s:\n%s"),
|
||||
strval, strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
@ -202,6 +223,7 @@ clickdialog(GtkWidget *widget, int resp, gpointer gdata) {
|
|||
setlimit(data->tr);
|
||||
}
|
||||
|
||||
if(GTK_RESPONSE_APPLY != resp)
|
||||
gtk_widget_destroy(widget);
|
||||
}
|
||||
|
||||
|
@ -226,10 +248,10 @@ makeaddwind(add_torrent_func_t addfunc, GtkWindow *parent, tr_handle_t *tr,
|
|||
struct addcb *data = g_new(struct addcb, 1);
|
||||
GtkWidget *vbox = gtk_vbox_new(FALSE, 3);
|
||||
GtkWidget *bbox = gtk_hbutton_box_new();
|
||||
GtkWidget *autocheck = gtk_check_button_new_with_label(
|
||||
_("Automatically start torrent"));
|
||||
GtkWidget *dircheck = gtk_check_button_new_with_label(
|
||||
_("Use alternate download directory"));
|
||||
GtkWidget *autocheck = gtk_check_button_new_with_mnemonic(
|
||||
_("Automatically _start torrent"));
|
||||
GtkWidget *dircheck = gtk_check_button_new_with_mnemonic(
|
||||
_("Use alternate _download directory"));
|
||||
GtkFileFilter *filter = gtk_file_filter_new();
|
||||
GtkFileFilter *unfilter = gtk_file_filter_new();
|
||||
GtkWidget *getdir = gtk_file_chooser_button_new(
|
||||
|
@ -246,7 +268,7 @@ makeaddwind(add_torrent_func_t addfunc, GtkWindow *parent, tr_handle_t *tr,
|
|||
data->altdir = GTK_FILE_CHOOSER(getdir);
|
||||
data->altbox = GTK_BUTTON_BOX(bbox);
|
||||
|
||||
gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_START);
|
||||
gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_EDGE);
|
||||
gtk_box_pack_start_defaults(GTK_BOX(bbox), dircheck);
|
||||
gtk_box_pack_start_defaults(GTK_BOX(bbox), getdir);
|
||||
|
||||
|
@ -258,6 +280,7 @@ makeaddwind(add_torrent_func_t addfunc, GtkWindow *parent, tr_handle_t *tr,
|
|||
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(getdir), pref);
|
||||
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dircheck), FALSE);
|
||||
gtk_widget_set_sensitive(getdir, FALSE);
|
||||
|
||||
gtk_file_filter_set_name(filter, _("Torrent files"));
|
||||
gtk_file_filter_add_pattern(filter, "*.torrent");
|
||||
|
@ -274,7 +297,6 @@ makeaddwind(add_torrent_func_t addfunc, GtkWindow *parent, tr_handle_t *tr,
|
|||
g_signal_connect(G_OBJECT(wind), "response", G_CALLBACK(addresp), data);
|
||||
|
||||
gtk_widget_show_all(wind);
|
||||
gtk_widget_hide(getdir);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -289,12 +311,7 @@ dirclick(GtkWidget *widget, gpointer gdata) {
|
|||
struct addcb *data = gdata;
|
||||
|
||||
data->usingaltdir = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
|
||||
gtk_button_box_set_layout(data->altbox,
|
||||
(data->usingaltdir ? GTK_BUTTONBOX_EDGE : GTK_BUTTONBOX_START));
|
||||
if(data->usingaltdir)
|
||||
gtk_widget_show(GTK_WIDGET(data->altdir));
|
||||
else
|
||||
gtk_widget_hide(GTK_WIDGET(data->altdir));
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(data->altdir), data->usingaltdir);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -310,7 +327,7 @@ addresp(GtkWidget *widget, gint resp, gpointer gdata) {
|
|||
files = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(widget));
|
||||
for(ii = files; NULL != ii; ii = ii->next)
|
||||
if(data->addfunc(data->tr, data->parent, ii->data, dir,
|
||||
!data->autostart))
|
||||
!data->autostart, NULL))
|
||||
added = TRUE;
|
||||
if(added)
|
||||
data->donefunc(data->donedata);
|
||||
|
@ -329,40 +346,42 @@ addresp(GtkWidget *widget, gint resp, gpointer gdata) {
|
|||
gtk_label_set_markup(GTK_LABEL(wid), txt); \
|
||||
gtk_table_attach_defaults(GTK_TABLE(tab), wid, 0, 1, ii, ii + 1); \
|
||||
wid = gtk_label_new(val); \
|
||||
gtk_label_set_selectable(GTK_LABEL(wid), TRUE); \
|
||||
gtk_misc_set_alignment(GTK_MISC(wid), 0, .5); \
|
||||
gtk_table_attach_defaults(GTK_TABLE(tab), wid, 1, 2, ii, ii + 1); \
|
||||
ii++; \
|
||||
g_free(txt); \
|
||||
} while(0);
|
||||
} while(0)
|
||||
|
||||
#define INFOLINEF(tab, ii, fmt, nam, val) \
|
||||
do { \
|
||||
char *buf = g_strdup_printf(fmt, val); \
|
||||
INFOLINE(tab, ii, nam, buf); \
|
||||
g_free(buf); \
|
||||
} while(0);
|
||||
} while(0)
|
||||
|
||||
#define INFOLINEA(tab, ii, nam, val) \
|
||||
do { \
|
||||
char *buf = val; \
|
||||
INFOLINE(tab, ii, nam, buf); \
|
||||
g_free(buf); \
|
||||
} while(0);
|
||||
} while(0)
|
||||
|
||||
#define INFOSEP(tab, ii) \
|
||||
do { \
|
||||
GtkWidget *wid = gtk_hseparator_new(); \
|
||||
gtk_table_attach_defaults(GTK_TABLE(tab), wid, 0, 2, ii, ii + 1); \
|
||||
ii++; \
|
||||
} while(0);
|
||||
} while(0)
|
||||
|
||||
void
|
||||
makeinfowind(GtkWindow *parent, tr_handle_t *tr, int id) {
|
||||
tr_stat_t *sb;
|
||||
GtkWidget *wind, *table, *label;
|
||||
GtkWidget *wind, *label;
|
||||
int ii;
|
||||
char *str;
|
||||
const int rowcount = 12;
|
||||
GtkWidget *table = gtk_table_new(rowcount, 2, FALSE);
|
||||
|
||||
/* XXX would be nice to be able to stat just one */
|
||||
if(id >= tr_torrentStat(tr, &sb))
|
||||
|
@ -373,11 +392,15 @@ makeinfowind(GtkWindow *parent, tr_handle_t *tr, int id) {
|
|||
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
|
||||
g_free(str);
|
||||
|
||||
table = gtk_table_new(rowcount, 2, FALSE);
|
||||
gtk_widget_set_name(wind, "TransmissionDialog");
|
||||
gtk_table_set_col_spacings(GTK_TABLE(table), 12);
|
||||
gtk_table_set_row_spacings(GTK_TABLE(table), 12);
|
||||
gtk_dialog_set_default_response(GTK_DIALOG(wind), GTK_RESPONSE_ACCEPT);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(table), 6);
|
||||
gtk_window_set_resizable(GTK_WINDOW(wind), FALSE);
|
||||
|
||||
label = gtk_label_new(NULL);
|
||||
gtk_label_set_selectable(GTK_LABEL(label), TRUE);
|
||||
str = g_markup_printf_escaped("<big>%s</big>", sb[id].info.name);
|
||||
gtk_label_set_markup(GTK_LABEL(label), str);
|
||||
g_free(str);
|
||||
|
@ -387,6 +410,10 @@ makeinfowind(GtkWindow *parent, tr_handle_t *tr, int id) {
|
|||
|
||||
INFOSEP(table, ii);
|
||||
|
||||
if(80 == sb[id].info.trackerPort)
|
||||
INFOLINEA(table, ii, _("Tracker:"), g_strdup_printf("http://%s",
|
||||
sb[id].info.trackerAddress));
|
||||
else
|
||||
INFOLINEA(table, ii, _("Tracker:"), g_strdup_printf("http://%s:%i",
|
||||
sb[id].info.trackerAddress, sb[id].info.trackerPort));
|
||||
INFOLINE(table, ii, _("Announce:"), sb[id].info.trackerAnnounce);
|
||||
|
@ -404,7 +431,6 @@ makeinfowind(GtkWindow *parent, tr_handle_t *tr, int id) {
|
|||
|
||||
assert(rowcount == ii);
|
||||
|
||||
gtk_container_set_border_width(GTK_CONTAINER(table), 12);
|
||||
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(wind)->vbox), table);
|
||||
g_signal_connect(G_OBJECT(wind), "response",
|
||||
G_CALLBACK(gtk_widget_destroy), NULL);
|
||||
|
|
|
@ -37,11 +37,11 @@
|
|||
|
||||
#define DEFAULT_UPLIMIT 20
|
||||
|
||||
typedef gboolean (*add_torrent_func_t)(tr_handle_t*, GtkWindow*, const char*, const char *, gboolean);
|
||||
typedef gboolean (*add_torrent_func_t)(tr_handle_t*, GtkWindow*, const char*, const char *, gboolean, GList **);
|
||||
typedef void (*torrents_added_func_t)(void *);
|
||||
|
||||
void
|
||||
makeprefwindow(GtkWindow *parent, tr_handle_t *tr);
|
||||
makeprefwindow(GtkWindow *parent, tr_handle_t *tr, gboolean *opened);
|
||||
|
||||
/* set the upload limit based on saved prefs */
|
||||
void
|
||||
|
|
45
gtk/main.c
45
gtk/main.c
|
@ -54,6 +54,7 @@ struct cbdata {
|
|||
GtkStatusbar *bar;
|
||||
GtkWidget **buttons;
|
||||
guint timer;
|
||||
gboolean prefsopen;
|
||||
};
|
||||
|
||||
struct exitdata {
|
||||
|
@ -117,7 +118,7 @@ doubleclick(GtkWidget *widget, GtkTreePath *path, GtkTreeViewColumn *col,
|
|||
|
||||
gboolean
|
||||
addtorrent(tr_handle_t *tr, GtkWindow *parentwind, const char *torrent,
|
||||
const char *dir, gboolean paused);
|
||||
const char *dir, gboolean paused, GList **errs);
|
||||
void
|
||||
addedtorrents(void *vdata);
|
||||
gboolean
|
||||
|
@ -182,6 +183,14 @@ main(int argc, char **argv) {
|
|||
|
||||
setuphandlers(stoptransmission, tr);
|
||||
|
||||
gtk_rc_parse_string(
|
||||
"style \"transmission-standard\" {\n"
|
||||
" GtkDialog::action-area-border = 6\n"
|
||||
" GtkDialog::button-spacing = 12\n"
|
||||
" GtkDialog::content-area-border = 6\n"
|
||||
"}\n"
|
||||
"widget \"TransmissionDialog\" style \"transmission-standard\"\n");
|
||||
|
||||
if(cf_init(tr_getPrefsDirectory(), &err)) {
|
||||
if(cf_lock(&err)) {
|
||||
/* create main window now so any error dialogs can be it's children */
|
||||
|
@ -254,9 +263,10 @@ makewind(GtkWidget *wind, tr_handle_t *tr, GList *saved) {
|
|||
struct cbdata *data = g_new0(struct cbdata, 1);
|
||||
GtkWidget *list;
|
||||
GtkRequisition req;
|
||||
GList *ii;
|
||||
GList *loaderrs, *ii;
|
||||
struct cf_torrentstate *ts;
|
||||
gint height;
|
||||
char *str;
|
||||
|
||||
data->tr = tr;
|
||||
data->wind = GTK_WINDOW(wind);
|
||||
|
@ -266,6 +276,7 @@ makewind(GtkWidget *wind, tr_handle_t *tr, GList *saved) {
|
|||
data->view = NULL;
|
||||
data->bar = GTK_STATUSBAR(status);
|
||||
data->buttons = NULL;
|
||||
data->prefsopen = FALSE;
|
||||
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_NEVER,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
@ -283,14 +294,26 @@ makewind(GtkWidget *wind, tr_handle_t *tr, GList *saved) {
|
|||
gtk_window_set_title(data->wind, g_get_application_name());
|
||||
g_signal_connect(G_OBJECT(wind), "delete_event", G_CALLBACK(winclose), data);
|
||||
|
||||
loaderrs = NULL;
|
||||
for(ii = g_list_first(saved); NULL != ii; ii = ii->next) {
|
||||
ts = ii->data;
|
||||
addtorrent(tr, GTK_WINDOW(wind),
|
||||
ts->ts_torrent, ts->ts_directory, ts->ts_paused);
|
||||
addtorrent(tr, GTK_WINDOW(wind), ts->ts_torrent, ts->ts_directory,
|
||||
ts->ts_paused, &loaderrs);
|
||||
cf_freestate(ts);
|
||||
}
|
||||
g_list_free(saved);
|
||||
|
||||
if(NULL != loaderrs) {
|
||||
str = joinstrlist(loaderrs, "\n");
|
||||
errmsg(GTK_WINDOW(wind), ngettext("Failed to load the torrent file %s",
|
||||
"Failed to load the torrent files:\n%s",
|
||||
g_list_length(loaderrs)), str);
|
||||
g_list_foreach(loaderrs, (GFunc)g_free, NULL);
|
||||
g_list_free(loaderrs);
|
||||
g_free(str);
|
||||
savetorrents(tr, GTK_WINDOW(wind), -1, NULL);
|
||||
}
|
||||
|
||||
data->timer = g_timeout_add(500, updatemodel, data);
|
||||
updatemodel(data);
|
||||
|
||||
|
@ -807,7 +830,8 @@ actionclick(GtkWidget *widget, gpointer gdata) {
|
|||
makeaddwind(addtorrent, data->wind, data->tr, addedtorrents, data);
|
||||
return;
|
||||
case ACT_PREF:
|
||||
makeprefwindow(data->wind, data->tr);
|
||||
if(!data->prefsopen)
|
||||
makeprefwindow(data->wind, data->tr, &data->prefsopen);
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
|
@ -915,13 +939,12 @@ doubleclick(GtkWidget *widget SHUTUP, GtkTreePath *path,
|
|||
|
||||
gboolean
|
||||
addtorrent(tr_handle_t *tr, GtkWindow *parentwind, const char *torrent,
|
||||
const char *dir, gboolean paused) {
|
||||
const char *dir, gboolean paused, GList **errs) {
|
||||
char *wd;
|
||||
|
||||
if(NULL == dir && NULL != (dir = cf_getpref(PREF_DIR))) {
|
||||
if(!mkdir_p(dir, 0777)) {
|
||||
errmsg(parentwind,
|
||||
_("An error occurred while creating directory %s:\n%s"),
|
||||
errmsg(parentwind, _("Failed to create the directory %s:\n%s"),
|
||||
dir, strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -932,8 +955,10 @@ addtorrent(tr_handle_t *tr, GtkWindow *parentwind, const char *torrent,
|
|||
if(0 != tr_torrentInit(tr, torrent)) {
|
||||
unblocksigs();
|
||||
/* XXX would be nice to have errno strings, are they printed to stdout? */
|
||||
errmsg(parentwind,
|
||||
_("An error occurred while opening the torrent file %s"), torrent);
|
||||
if(NULL == errs)
|
||||
errmsg(parentwind, _("Failed to load the torrent file %s"), torrent);
|
||||
else
|
||||
*errs = g_list_append(*errs, g_strdup(torrent));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2006-02-04 11:17-0500\n"
|
||||
"POT-Creation-Date: 2006-02-05 12:27-0500\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -17,294 +17,291 @@ msgstr ""
|
|||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
||||
|
||||
#: conf.c:74
|
||||
#: conf.c:73
|
||||
#, c-format
|
||||
msgid ""
|
||||
"An error occurred while opening the file %s for writing:\n"
|
||||
"Failed to open the file %s for writing:\n"
|
||||
"%s"
|
||||
msgstr ""
|
||||
|
||||
#: conf.c:88
|
||||
#: conf.c:87
|
||||
#, c-format
|
||||
msgid "Another copy of %s is already running."
|
||||
msgstr ""
|
||||
|
||||
#: conf.c:92
|
||||
#: conf.c:90
|
||||
#, c-format
|
||||
msgid ""
|
||||
"An error occurred while locking the file %s:\n"
|
||||
"Failed to lock the file %s:\n"
|
||||
"%s"
|
||||
msgstr ""
|
||||
|
||||
#: conf.c:112
|
||||
#: conf.c:109
|
||||
#, c-format
|
||||
msgid ""
|
||||
"An error occurred while checking the directory %s:\n"
|
||||
"Failed to check the directory %s:\n"
|
||||
"%s"
|
||||
msgstr ""
|
||||
|
||||
#: conf.c:119 dialogs.c:170
|
||||
#: conf.c:115 dialogs.c:191 main.c:947
|
||||
#, c-format
|
||||
msgid ""
|
||||
"An error occurred while creating the directory %s:\n"
|
||||
"Failed to create the directory %s:\n"
|
||||
"%s"
|
||||
msgstr ""
|
||||
|
||||
#: conf.c:128
|
||||
#: conf.c:124
|
||||
#, c-format
|
||||
msgid "%s is not a directory"
|
||||
msgstr ""
|
||||
|
||||
#: conf.c:163 conf.c:331
|
||||
#: conf.c:159 conf.c:322
|
||||
#, c-format
|
||||
msgid ""
|
||||
"An error occurred while opening the file %s for reading:\n"
|
||||
"Failed to open the file %s for reading:\n"
|
||||
"%s"
|
||||
msgstr ""
|
||||
|
||||
#: conf.c:175 conf.c:343
|
||||
#: conf.c:170 conf.c:333
|
||||
#, c-format
|
||||
msgid ""
|
||||
"An error occurred while reading from the file %s:\n"
|
||||
"Error while reading from the file %s:\n"
|
||||
"%s"
|
||||
msgstr ""
|
||||
|
||||
#: conf.c:240 conf.c:443
|
||||
#: conf.c:233 conf.c:431
|
||||
#, c-format
|
||||
msgid ""
|
||||
"An error occurred while opening or locking the file %s:\n"
|
||||
"Failed to open or lock the file %s:\n"
|
||||
"%s"
|
||||
msgstr ""
|
||||
|
||||
#: conf.c:261 conf.c:484
|
||||
#: conf.c:253 conf.c:471
|
||||
#, c-format
|
||||
msgid ""
|
||||
"An error occurred while writing to the file %s:\n"
|
||||
"Error while writing to the file %s:\n"
|
||||
"%s"
|
||||
msgstr ""
|
||||
|
||||
#: conf.c:269 conf.c:492
|
||||
#: conf.c:260 conf.c:478
|
||||
#, c-format
|
||||
msgid ""
|
||||
"An error occurred while renaming the file %s to %s:\n"
|
||||
"Failed to rename the file %s to %s:\n"
|
||||
"%s"
|
||||
msgstr ""
|
||||
|
||||
#: dialogs.c:74
|
||||
#: dialogs.c:76
|
||||
#, c-format
|
||||
msgid "%s Preferences"
|
||||
msgstr ""
|
||||
|
||||
#: dialogs.c:81
|
||||
msgid "Limit upload speed"
|
||||
#: dialogs.c:84
|
||||
msgid "_Limit upload speed"
|
||||
msgstr ""
|
||||
|
||||
#: dialogs.c:83
|
||||
#: dialogs.c:87
|
||||
msgid "Choose download directory"
|
||||
msgstr ""
|
||||
|
||||
#. port label and entry
|
||||
#: dialogs.c:104
|
||||
msgid "Listening port:"
|
||||
msgstr ""
|
||||
|
||||
#. limit label and entry
|
||||
#: dialogs.c:122
|
||||
msgid "Maximum upload speed:"
|
||||
#: dialogs.c:121
|
||||
msgid "Maximum _upload speed:"
|
||||
msgstr ""
|
||||
|
||||
#. directory label and chooser
|
||||
#: dialogs.c:134
|
||||
msgid "Download Directory:"
|
||||
#: dialogs.c:135
|
||||
msgid "_Download directory:"
|
||||
msgstr ""
|
||||
|
||||
#: dialogs.c:223
|
||||
#. port label and entry
|
||||
#: dialogs.c:144
|
||||
msgid "Listening _port:"
|
||||
msgstr ""
|
||||
|
||||
#: dialogs.c:245
|
||||
msgid "Add a Torrent"
|
||||
msgstr ""
|
||||
|
||||
#: dialogs.c:230
|
||||
msgid "Automatically start torrent"
|
||||
#: dialogs.c:252
|
||||
msgid "Automatically _start torrent"
|
||||
msgstr ""
|
||||
|
||||
#: dialogs.c:232
|
||||
msgid "Use alternate download directory"
|
||||
#: dialogs.c:254
|
||||
msgid "Use alternate _download directory"
|
||||
msgstr ""
|
||||
|
||||
#: dialogs.c:236
|
||||
#: dialogs.c:258
|
||||
msgid "Choose a download directory"
|
||||
msgstr ""
|
||||
|
||||
#: dialogs.c:262
|
||||
#: dialogs.c:285
|
||||
msgid "Torrent files"
|
||||
msgstr ""
|
||||
|
||||
#: dialogs.c:264
|
||||
#: dialogs.c:287
|
||||
msgid "All files"
|
||||
msgstr ""
|
||||
|
||||
#: dialogs.c:370
|
||||
#: dialogs.c:389
|
||||
#, c-format
|
||||
msgid "%s Properties"
|
||||
msgstr ""
|
||||
|
||||
#: dialogs.c:390
|
||||
#: dialogs.c:414 dialogs.c:417
|
||||
msgid "Tracker:"
|
||||
msgstr ""
|
||||
|
||||
#: dialogs.c:392
|
||||
#: dialogs.c:419
|
||||
msgid "Announce:"
|
||||
msgstr ""
|
||||
|
||||
#: dialogs.c:393
|
||||
#: dialogs.c:420
|
||||
msgid "Piece Size:"
|
||||
msgstr ""
|
||||
|
||||
#: dialogs.c:394
|
||||
#: dialogs.c:421
|
||||
msgid "Pieces:"
|
||||
msgstr ""
|
||||
|
||||
#: dialogs.c:395
|
||||
#: dialogs.c:422
|
||||
msgid "Total Size:"
|
||||
msgstr ""
|
||||
|
||||
#: dialogs.c:399
|
||||
#: dialogs.c:426
|
||||
msgid "Directory:"
|
||||
msgstr ""
|
||||
|
||||
#: dialogs.c:400
|
||||
#: dialogs.c:427
|
||||
msgid "Downloaded:"
|
||||
msgstr ""
|
||||
|
||||
#: dialogs.c:401
|
||||
#: dialogs.c:428
|
||||
msgid "Uploaded:"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:148
|
||||
#: main.c:149
|
||||
msgid "Add"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:149
|
||||
#: main.c:150
|
||||
msgid "Add a new torrent"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:150
|
||||
#: main.c:151
|
||||
msgid "Start"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:152
|
||||
#: main.c:153
|
||||
msgid "Start a torrent that is not running"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:153
|
||||
#: main.c:154
|
||||
msgid "Stop"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:155
|
||||
#: main.c:156
|
||||
msgid "Stop a torrent that is running"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:156
|
||||
#: main.c:157
|
||||
msgid "Remove"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:157
|
||||
#: main.c:158
|
||||
msgid "Remove a torrent"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:158
|
||||
#: main.c:159
|
||||
msgid "Properties"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:159
|
||||
#: main.c:160
|
||||
msgid "Show additional information about a torrent"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:160
|
||||
#: main.c:161
|
||||
msgid "Preferences"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:161
|
||||
#: main.c:162
|
||||
msgid "Customize application behavior"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:179
|
||||
#: main.c:180
|
||||
msgid "Transmission"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:471
|
||||
#: main.c:308 main.c:959
|
||||
#, c-format
|
||||
msgid "Failed to load the torrent file %s"
|
||||
msgid_plural ""
|
||||
"Failed to load the torrent files:\n"
|
||||
"%s"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
#: main.c:494
|
||||
msgid "Name"
|
||||
msgstr ""
|
||||
|
||||
#. this string is only used to determing the size of the progress bar
|
||||
#: main.c:478
|
||||
#: main.c:501
|
||||
msgid " fnord fnord "
|
||||
msgstr ""
|
||||
|
||||
#: main.c:481
|
||||
#: main.c:504
|
||||
msgid "Progress"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:556
|
||||
#: main.c:579
|
||||
#, c-format
|
||||
msgid "Checking existing files (%.1f%%)"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:558
|
||||
#: main.c:581
|
||||
#, c-format
|
||||
msgid "Finishing in %02i:%02i:%02i (%.1f%%)"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:561
|
||||
#: main.c:584
|
||||
#, c-format
|
||||
msgid "Seeding, uploading to %d of %d peer"
|
||||
msgid_plural "Seeding, uploading to %d of %d peers"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
#: main.c:565
|
||||
#: main.c:588
|
||||
msgid "Stopping..."
|
||||
msgstr ""
|
||||
|
||||
#: main.c:567
|
||||
#: main.c:590
|
||||
#, c-format
|
||||
msgid "Stopped (%.1f%%)"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:575
|
||||
#: main.c:598
|
||||
msgid "Error: "
|
||||
msgstr ""
|
||||
|
||||
#: main.c:579
|
||||
#: main.c:602
|
||||
#, c-format
|
||||
msgid "Downloading from %i of %i peer"
|
||||
msgid_plural "Downloading from %i of %i peers"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
#: main.c:611
|
||||
#: main.c:634
|
||||
#, c-format
|
||||
msgid ""
|
||||
"DL: %s/s\n"
|
||||
"UL: %s/s"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:658
|
||||
#: main.c:681
|
||||
#, c-format
|
||||
msgid " Total DL: %s/s Total UL: %s/s"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:924
|
||||
#, c-format
|
||||
msgid ""
|
||||
"An error occurred while creating directory %s:\n"
|
||||
"%s"
|
||||
msgstr ""
|
||||
|
||||
#: main.c:936
|
||||
#, c-format
|
||||
msgid "An error occurred while opening the torrent file %s"
|
||||
msgstr ""
|
||||
|
||||
#: util.c:63
|
||||
msgid "B"
|
||||
msgstr ""
|
||||
|
|
23
gtk/util.c
23
gtk/util.c
|
@ -105,6 +105,29 @@ mkdir_p(const char *name, mode_t mode) {
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
char *
|
||||
joinstrlist(GList *list, char *sep) {
|
||||
GList *ii;
|
||||
int len;
|
||||
char *ret, *dest;
|
||||
|
||||
if(0 > (len = strlen(sep) * (g_list_length(list) - 1)))
|
||||
return NULL;
|
||||
|
||||
for(ii = g_list_first(list); NULL != ii; ii = ii->next)
|
||||
len += strlen(ii->data);
|
||||
|
||||
dest = ret = g_new(char, len + 1);
|
||||
|
||||
for(ii = g_list_first(list); NULL != ii; ii = ii->next) {
|
||||
dest = g_stpcpy(dest, ii->data);
|
||||
if(NULL != ii->next)
|
||||
dest = g_stpcpy(dest, sep);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int exit_sigs[] = {SIGHUP, SIGINT, SIGQUIT, SIGTERM, SIGUSR1, SIGUSR2};
|
||||
static callbackfunc_t exit_func = NULL;
|
||||
static void *exit_data = NULL;
|
||||
|
|
|
@ -57,6 +57,10 @@ readablesize(guint64 size, int decimals);
|
|||
gboolean
|
||||
mkdir_p(const char *name, mode_t mode);
|
||||
|
||||
/* joins a GList of strings into one string using an optional separator */
|
||||
char *
|
||||
joinstrlist(GList *list, char *sep);
|
||||
|
||||
/* set up a handler for various fatal signals */
|
||||
void
|
||||
setuphandlers(callbackfunc_t func, void *data);
|
||||
|
|
Loading…
Reference in New Issue