From bf2e684c7bcb6a57e13373d82912835661241d89 Mon Sep 17 00:00:00 2001 From: Cleiton Floss Date: Thu, 29 Oct 2015 21:29:47 -0300 Subject: [PATCH 1/3] Use GtkStack on details and on preferences --- gtk/details.c | 123 +++++++++++++++++++++++++------------------------ gtk/tr-prefs.c | 50 ++++++++++++-------- 2 files changed, 93 insertions(+), 80 deletions(-) diff --git a/gtk/details.c b/gtk/details.c index 08ef2a3..9fdd539 100644 --- a/gtk/details.c +++ b/gtk/details.c @@ -2681,66 +2681,69 @@ 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); + 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 diff --git a/gtk/tr-prefs.c b/gtk/tr-prefs.c index c3af043..87cc8fb 100644 --- a/gtk/tr-prefs.c +++ b/gtk/tr-prefs.c @@ -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 }; @@ -1323,32 +1325,40 @@ gtr_prefs_dialog_new (GtkWindow * parent, GObject * core) 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_stack_set_homogeneous (GTK_STACK(n), false); + gtk_stack_set_transition_type (GTK_STACK(n), GTK_STACK_TRANSITION_TYPE_CROSSFADE); + + gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER(ss), GTK_STACK(n)); + + //gtk_notebook_set_show_border (GTK_NOTEBOOK (n), FALSE); + + //gtk_stack_add_titled (GTK_STACK(n), w, "info", _("Information")); + + 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 Date: Thu, 5 Nov 2015 12:02:14 -0300 Subject: [PATCH 2/3] Changed preferences to vertical StackSwitcher and removed additonal close button on dialogs --- gtk/details.c | 4 ++++ gtk/tr-prefs.c | 12 +++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gtk/details.c b/gtk/details.c index 9fdd539..53cf291 100644 --- a/gtk/details.c +++ b/gtk/details.c @@ -2700,6 +2700,10 @@ gtr_torrent_details_dialog_new (GtkWindow * parent, TrCore * core) 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", diff --git a/gtk/tr-prefs.c b/gtk/tr-prefs.c index 87cc8fb..34f6f2a 100644 --- a/gtk/tr-prefs.c +++ b/gtk/tr-prefs.c @@ -1321,6 +1321,7 @@ gtr_prefs_dialog_new (GtkWindow * parent, GObject * core) 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"); @@ -1329,15 +1330,13 @@ gtr_prefs_dialog_new (GtkWindow * parent, GObject * core) 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_CROSSFADE); + 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_notebook_set_show_border (GTK_NOTEBOOK (n), FALSE); - - //gtk_stack_add_titled (GTK_STACK(n), w, "info", _("Information")); - 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")); @@ -1352,7 +1351,7 @@ gtr_prefs_dialog_new (GtkWindow * parent, GObject * core) g_signal_connect (d, "response", G_CALLBACK (response_cb), core); - b = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + b = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5); gtk_box_pack_start (GTK_BOX(b), ss, FALSE,TRUE,0); gtk_box_pack_start (GTK_BOX(b), n, TRUE,TRUE,1); @@ -1361,4 +1360,3 @@ gtr_prefs_dialog_new (GtkWindow * parent, GObject * core) gtr_dialog_set_content (GTK_DIALOG (d), b); return d; } - From 94fbfbe3298a6ae7735d3d82871e04c666fe178e Mon Sep 17 00:00:00 2001 From: Cleiton Floss Date: Thu, 5 Nov 2015 22:10:14 -0300 Subject: [PATCH 3/3] Modified messages --- gtk/dialogs.c | 8 ++++---- gtk/tr-prefs.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gtk/dialogs.c b/gtk/dialogs.c index c058b01..9e9e926 100644 --- a/gtk/dialogs.c +++ b/gtk/dialogs.c @@ -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 @@ -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) diff --git a/gtk/tr-prefs.c b/gtk/tr-prefs.c index 34f6f2a..a1788c2 100644 --- a/gtk/tr-prefs.c +++ b/gtk/tr-prefs.c @@ -1314,7 +1314,7 @@ 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, @@ -1330,8 +1330,8 @@ gtr_prefs_dialog_new (GtkWindow * parent, GObject * core) n = gtk_stack_new (); gtk_widget_set_halign (ss, GTK_ALIGN_CENTER); - gtk_orientable_set_orientation (GTK_ORIENTABLE(ss), GTK_ORIENTATION_VERTICAL); - + //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); @@ -1351,7 +1351,7 @@ gtr_prefs_dialog_new (GtkWindow * parent, GObject * core) g_signal_connect (d, "response", G_CALLBACK (response_cb), core); - b = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5); + 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);