Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use GtkStack on details and on preferences #27

Open
wants to merge 3 commits into
base: wip/gtk-3.14
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 67 additions & 60 deletions gtk/details.c
Original file line number Diff line number Diff line change
Expand Up @@ -2681,66 +2681,73 @@ details_free (gpointer gdata)
GtkWidget*
gtr_torrent_details_dialog_new (GtkWindow * parent, TrCore * core)
{
GtkWidget *d, *n, *v, *w, *l;
struct DetailsImpl * di = g_new0 (struct DetailsImpl, 1);

/* one-time setup */
if (ARG_KEY == 0)
{
ARG_KEY = g_quark_from_static_string ("tr-arg-key");
DETAILS_KEY = g_quark_from_static_string ("tr-details-data-key");
TORRENT_ID_KEY = g_quark_from_static_string ("tr-torrent-id-key");
TEXT_BUFFER_KEY = g_quark_from_static_string ("tr-text-buffer-key");
URL_ENTRY_KEY = g_quark_from_static_string ("tr-url-entry-key");
}

/* create the dialog */
di->core = core;
di->gstr = g_string_new (NULL);
d = gtk_dialog_new_with_buttons (NULL, parent, GTK_DIALOG_USE_HEADER_BAR,
_("Cl_ose"), GTK_RESPONSE_CLOSE,
NULL);

gtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_CLOSE);

di->dialog = d;
gtk_window_set_role (GTK_WINDOW (d), "tr-info");
g_signal_connect_swapped (d, "response",
G_CALLBACK (gtk_widget_destroy), d);
g_object_set_qdata_full (G_OBJECT (d), DETAILS_KEY, di, details_free);

n = gtk_notebook_new ();
gtk_notebook_set_show_border (GTK_NOTEBOOK (n), FALSE);

w = info_page_new (di);
l = gtk_label_new (_("Information"));
gtk_notebook_append_page (GTK_NOTEBOOK (n), w, l);

w = peer_page_new (di);
l = gtk_label_new (_("Peers"));
gtk_notebook_append_page (GTK_NOTEBOOK (n), w, l);

w = tracker_page_new (di);
l = gtk_label_new (_("Trackers"));
gtk_notebook_append_page (GTK_NOTEBOOK (n), w, l);

v = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
di->file_list = gtr_file_list_new (core, 0);
di->file_label = gtk_label_new (_("File listing not available for combined torrent properties"));
gtk_box_pack_start (GTK_BOX (v), di->file_list, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (v), di->file_label, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (v), GUI_PAD_BIG);
l = gtk_label_new (_("Files"));
gtk_notebook_append_page (GTK_NOTEBOOK (n), v, l);

w = options_page_new (di);
l = gtk_label_new (_("Options"));
gtk_notebook_append_page (GTK_NOTEBOOK (n), w, l);

gtr_dialog_set_content (GTK_DIALOG (d), n);
di->periodic_refresh_tag = gdk_threads_add_timeout_seconds (SECONDARY_WINDOW_REFRESH_INTERVAL_SECONDS,
periodic_refresh, di);
return d;
GtkWidget *d, *n, *v, *switcher, *b;
struct DetailsImpl * di = g_new0 (struct DetailsImpl, 1);

/* one-time setup */
if (ARG_KEY == 0)
{
ARG_KEY = g_quark_from_static_string ("tr-arg-key");
DETAILS_KEY = g_quark_from_static_string ("tr-details-data-key");
TORRENT_ID_KEY = g_quark_from_static_string ("tr-torrent-id-key");
TEXT_BUFFER_KEY = g_quark_from_static_string ("tr-text-buffer-key");
URL_ENTRY_KEY = g_quark_from_static_string ("tr-url-entry-key");
}

/* create the dialog */
di->core = core;
di->gstr = g_string_new (NULL);
d = gtk_dialog_new_with_buttons (NULL, parent, 0,
_("Cl_ose"), GTK_RESPONSE_CLOSE,
NULL);

gtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_CLOSE);
gtk_window_set_deletable (GTK_WINDOW(d), FALSE);

di->dialog = d;
gtk_window_set_role (GTK_WINDOW (d), "tr-info");
g_signal_connect_swapped (d, "response",
G_CALLBACK (gtk_widget_destroy), d);
gtk_container_set_border_width (GTK_CONTAINER (d), GUI_PAD);
g_object_set_qdata_full (G_OBJECT (d), DETAILS_KEY, di, details_free);


switcher = gtk_stack_switcher_new ();
gtk_widget_set_halign (switcher, GTK_ALIGN_CENTER);

n = gtk_stack_new ();
gtk_stack_set_homogeneous (GTK_STACK(n), true);
gtk_stack_set_transition_type (GTK_STACK(n), GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);

gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER(switcher), GTK_STACK(n));

gtk_stack_add_titled (GTK_STACK(n), info_page_new (di), "info", _("Information"));

gtk_stack_add_titled (GTK_STACK(n), peer_page_new (di), "peers", _("Peers"));

gtk_stack_add_titled (GTK_STACK(n), tracker_page_new (di), "trackers", _("Trackers"));

v = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
di->file_list = gtr_file_list_new (core, 0);
di->file_label = gtk_label_new (_("File listing not availablse for combined torrent properties"));
gtk_box_pack_start (GTK_BOX (v), di->file_list, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (v), di->file_label, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (v), GUI_PAD_BIG);
gtk_stack_add_titled (GTK_STACK(n), v, "files", _("Files"));

gtk_stack_add_titled (GTK_STACK(n), options_page_new (di), "options", _("Options"));

b = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_box_pack_start (GTK_BOX(b), switcher, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX(b), n, TRUE, TRUE, 1);

gtk_container_set_border_width (GTK_CONTAINER (b), GUI_PAD);

gtr_dialog_set_content (GTK_DIALOG (d), b);

di->periodic_refresh_tag = gdk_threads_add_timeout_seconds (SECONDARY_WINDOW_REFRESH_INTERVAL_SECONDS,
periodic_refresh, di);
return d;
}

void
Expand Down
8 changes: 4 additions & 4 deletions gtk/dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ gtr_confirm_remove (GtkWindow * parent,

if (!delete_files)
{
g_string_printf (primary_text, ngettext ("Remove torrent?",
"Remove %d torrents?",
g_string_printf (primary_text, ngettext ("Remove Torrent?",
"Remove %d Torrents?",
count), count);
}
else
Expand All @@ -108,8 +108,8 @@ gtr_confirm_remove (GtkWindow * parent,
if (!incomplete && !connected)
{
g_string_assign (secondary_text, ngettext (
"Once removed, continuing the transfer will require the torrent file or magnet link.",
"Once removed, continuing the transfers will require the torrent files or magnet links.",
"Once removed, continuing the transfer will require re-adding the torrent file or magnet link.",
"Once removed, continuing the transfers will require re-adding the torrent files or magnet links.",
count));
}
else if (count == incomplete)
Expand Down
52 changes: 30 additions & 22 deletions gtk/tr-prefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,8 @@ gtr_prefs_dialog_new (GtkWindow * parent, GObject * core)
size_t i;
GtkWidget * d;
GtkWidget * n;
GtkWidget * ss;
GtkWidget * b;
struct prefs_dialog_data * data;
const tr_quark prefs_quarks[] = { TR_KEY_peer_port, TR_KEY_download_dir };

Expand All @@ -1312,43 +1314,49 @@ gtr_prefs_dialog_new (GtkWindow * parent, GObject * core)

d = gtk_dialog_new_with_buttons (_("Transmission Preferences"),
parent,
GTK_DIALOG_USE_HEADER_BAR |
//GTK_DIALOG_USE_HEADER_BAR |
GTK_DIALOG_DESTROY_WITH_PARENT,
_("_Help"), GTK_RESPONSE_HELP,
_("_Close"), GTK_RESPONSE_CLOSE,
NULL);

gtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_CLOSE);
gtk_window_set_deletable (GTK_WINDOW(d), FALSE);

g_object_weak_ref (G_OBJECT(d), on_prefs_dialog_destroyed, data);
gtk_window_set_role (GTK_WINDOW (d), "transmission-preferences-dialog");

n = gtk_notebook_new ();
gtk_notebook_set_show_border (GTK_NOTEBOOK (n), FALSE);

gtk_notebook_set_tab_pos (GTK_NOTEBOOK (n), GTK_POS_LEFT);

gtk_notebook_append_page (GTK_NOTEBOOK (n), speedPage (core),
gtk_label_new (_("Speed")));
gtk_notebook_append_page (GTK_NOTEBOOK (n), downloadingPage (core, data),
gtk_label_new (C_("Gerund", "Downloading")));
gtk_notebook_append_page (GTK_NOTEBOOK (n), seedingPage (core),
gtk_label_new (C_("Gerund", "Seeding")));
gtk_notebook_append_page (GTK_NOTEBOOK (n), privacyPage (core),
gtk_label_new (_("Privacy")));
gtk_notebook_append_page (GTK_NOTEBOOK (n), networkPage (core),
gtk_label_new (_("Network")));
gtk_notebook_append_page (GTK_NOTEBOOK (n), desktopPage (core),
gtk_label_new (_("Desktop")));
gtk_notebook_append_page (GTK_NOTEBOOK (n), remotePage (core),
gtk_label_new (_("Remote")));
ss = gtk_stack_switcher_new ();
n = gtk_stack_new ();

gtk_widget_set_halign (ss, GTK_ALIGN_CENTER);
//gtk_orientable_set_orientation (GTK_ORIENTABLE(ss), GTK_ORIENTATION_VERTICAL);

gtk_stack_set_homogeneous (GTK_STACK(n), false);
gtk_stack_set_transition_type (GTK_STACK(n), GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN);

gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER(ss), GTK_STACK(n));

gtk_stack_add_titled (GTK_STACK (n), speedPage (core), "speed", _("Speed"));
gtk_stack_add_titled (GTK_STACK (n), downloadingPage (core, data), "down",_("Downloading"));
gtk_stack_add_titled (GTK_STACK (n), seedingPage (core), "seed", _("Seeding"));
gtk_stack_add_titled (GTK_STACK (n), privacyPage (core), "privacy", _("Privacy"));
gtk_stack_add_titled (GTK_STACK (n), networkPage (core), "net", _("Network"));
gtk_stack_add_titled (GTK_STACK (n), desktopPage (core), "desktop", _("Desktop"));
gtk_stack_add_titled (GTK_STACK (n), remotePage (core), "rem", _("Remote"));

/* init from prefs keys */
for (i=0; i<sizeof(prefs_quarks)/sizeof(prefs_quarks[0]); ++i)
on_core_prefs_changed (TR_CORE(core), prefs_quarks[i], data);

g_signal_connect (d, "response", G_CALLBACK (response_cb), core);
gtr_dialog_set_content (GTK_DIALOG (d), n);

b = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_box_pack_start (GTK_BOX(b), ss, FALSE,TRUE,0);
gtk_box_pack_start (GTK_BOX(b), n, TRUE,TRUE,1);

gtk_container_set_border_width (GTK_CONTAINER (b), GUI_PAD);

gtr_dialog_set_content (GTK_DIALOG (d), b);
return d;
}