summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alan Fitton <ajf@eth0.org.uk>2011-03-07 09:30:52 +0000
committerGravatar Alan Fitton <ajf@eth0.org.uk>2011-03-07 09:30:52 +0000
commitecbd6bbb7423bc9b6f329f937bf740b7dc87598d (patch)
treed94b975144b1aed8300d75ab5e4a12fbc8d906de
parent5cf07d32732a12cc049fde68213d4589cb951e67 (diff)
Make the presence of the graph configurable, and prevent ":" showing (introduced by gettext changes) for empty labels like errors (usually).
-rw-r--r--src/transmission-remote-gtk.schemas13
-rw-r--r--src/trg-general-panel.c2
-rw-r--r--src/trg-main-window.c54
-rw-r--r--src/trg-main-window.h3
-rw-r--r--src/trg-preferences-dialog.c16
-rw-r--r--src/trg-preferences.h1
6 files changed, 81 insertions, 8 deletions
diff --git a/src/transmission-remote-gtk.schemas b/src/transmission-remote-gtk.schemas
index 6e8f784..def8fe2 100644
--- a/src/transmission-remote-gtk.schemas
+++ b/src/transmission-remote-gtk.schemas
@@ -28,6 +28,19 @@
</schema>
<schema>
+ <key>/schemas/apps/transmission-remote-gtk/show-graph</key>
+ <applyto>/apps/transmission-remote-gtk/show-graph</applyto>
+ <owner>transmission-remote-gtk</owner>
+ <type>bool</type>
+ <default>1</default>
+
+ <locale name="C">
+ <short>Show graph</short>
+ <long>Show graph</long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/transmission-remote-gtk/ssl</key>
<applyto>/apps/transmission-remote-gtk/ssl</applyto>
<owner>transmission-remote-gtk</owner>
diff --git a/src/trg-general-panel.c b/src/trg-general-panel.c
index 9045744..c4edf60 100644
--- a/src/trg-general-panel.c
+++ b/src/trg-general-panel.c
@@ -189,7 +189,7 @@ static GtkLabel *trg_general_panel_add_label(TrgGeneralPanel * fixed,
gchar *keyMarkup;
keyLabel = gtk_label_new(NULL);
- keyMarkup = g_markup_printf_escaped("<b>%s:</b>", key);
+ keyMarkup = g_markup_printf_escaped(strlen(key) > 0 ? "<b>%s:</b>" : "", key);
gtk_label_set_markup(GTK_LABEL(keyLabel), keyMarkup);
g_free(keyMarkup);
gtk_fixed_put(GTK_FIXED(fixed), keyLabel, 10 + (col * 280),
diff --git a/src/trg-main-window.c b/src/trg-main-window.c
index c54f2c6..12568de 100644
--- a/src/trg-main-window.c
+++ b/src/trg-main-window.c
@@ -224,6 +224,7 @@ struct _TrgMainWindowPrivate {
TrgPeersTreeView *peersTreeView;
TrgTorrentGraph *graph;
+ gint graphNotebookIndex;
GtkWidget *hpaned, *vpaned;
GtkWidget *filterEntry, *filterEntryClearButton;
@@ -790,7 +791,9 @@ GtkWidget *trg_main_window_notebook_new(TrgMainWindow * win)
{
TrgMainWindowPrivate *priv = TRG_MAIN_WINDOW_GET_PRIVATE(win);
- GtkWidget *notebook = gtk_notebook_new();
+ GtkWidget *notebook = priv->notebook = gtk_notebook_new();
+ gboolean show_graph;
+ GError *error = NULL;
gtk_widget_set_size_request(notebook, -1, 190);
@@ -822,11 +825,20 @@ GtkWidget *trg_main_window_notebook_new(TrgMainWindow * win)
(priv->peersTreeView)),
gtk_label_new(_("Peers")));
- priv->graph = trg_torrent_graph_new(gtk_widget_get_style(notebook));
- gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
- GTK_WIDGET(priv->graph),
- gtk_label_new(_("Graph")));
- trg_torrent_graph_start(priv->graph);
+
+ show_graph = gconf_client_get_bool(priv->client->gconf, TRG_GCONF_KEY_SHOW_GRAPH,
+ &error);
+
+ if (error) {
+ g_error_free(error);
+ show_graph = TRUE;
+ }
+
+ if (show_graph) {
+ trg_main_window_add_graph(win, FALSE);
+ } else {
+ priv->graphNotebookIndex = -1;
+ }
return notebook;
}
@@ -943,7 +955,9 @@ on_torrent_get(JsonObject * response, int mode,
update_selected_torrent_notebook(TRG_MAIN_WINDOW(data), first);
trg_status_bar_update(priv->statusBar, &stats);
- trg_torrent_graph_set_speed(priv->graph, &stats);
+
+ if (priv->graphNotebookIndex >= 0)
+ trg_torrent_graph_set_speed(priv->graph, &stats);
if (mode != TORRENT_GET_MODE_INTERACTION)
g_timeout_add_seconds(client->interval, trg_update_torrents_timerfunc, data);
@@ -1641,6 +1655,32 @@ void trg_main_window_remove_status_icon(TrgMainWindow * win)
priv->statusIcon = NULL;
}
+void trg_main_window_add_graph(TrgMainWindow * win, gboolean show)
+{
+ TrgMainWindowPrivate *priv = TRG_MAIN_WINDOW_GET_PRIVATE(win);
+
+ priv->graph = trg_torrent_graph_new(gtk_widget_get_style(priv->notebook));
+ priv->graphNotebookIndex = gtk_notebook_append_page(GTK_NOTEBOOK(priv->notebook),
+ GTK_WIDGET(priv->graph),
+ gtk_label_new(_("Graph")));
+
+ if (show)
+ gtk_widget_show_all(priv->notebook);
+
+ trg_torrent_graph_start(priv->graph);
+}
+
+void trg_main_window_remove_graph(TrgMainWindow * win)
+{
+ TrgMainWindowPrivate *priv = TRG_MAIN_WINDOW_GET_PRIVATE(win);
+
+ if (priv->graphNotebookIndex >= 0)
+ {
+ gtk_notebook_remove_page(GTK_NOTEBOOK(priv->notebook), priv->graphNotebookIndex);
+ priv->graphNotebookIndex = -1;
+ }
+}
+
void trg_main_window_add_status_icon(TrgMainWindow * win)
{
TrgMainWindowPrivate *priv = TRG_MAIN_WINDOW_GET_PRIVATE(win);
diff --git a/src/trg-main-window.h b/src/trg-main-window.h
index d298b48..1019ec1 100644
--- a/src/trg-main-window.h
+++ b/src/trg-main-window.h
@@ -66,6 +66,9 @@ void auto_connect_if_required(TrgMainWindow * win, trg_client * tc);
TrgMainWindow *trg_main_window_new(trg_client * tc);
void trg_main_window_add_status_icon(TrgMainWindow * win);
void trg_main_window_remove_status_icon(TrgMainWindow * win);
+void trg_main_window_add_graph(TrgMainWindow * win, gboolean show);
+void trg_main_window_remove_graph(TrgMainWindow * win);
G_END_DECLS
#endif /* MAIN_WINDOW_H_ */
+
diff --git a/src/trg-preferences-dialog.c b/src/trg-preferences-dialog.c
index 02c831c..a0c51a4 100644
--- a/src/trg-preferences-dialog.c
+++ b/src/trg-preferences-dialog.c
@@ -208,6 +208,14 @@ static GtkWidget *new_entry(GConfClient * gconf, const char *key)
return w;
}
+static void toggle_show_graph(GtkToggleButton * w, gpointer win)
+{
+ if (gtk_toggle_button_get_active(w))
+ trg_main_window_add_graph(TRG_MAIN_WINDOW(win), TRUE);
+ else
+ trg_main_window_remove_graph(TRG_MAIN_WINDOW(win));
+}
+
static void toggle_tray_icon(GtkToggleButton * w, gpointer win)
{
if (gtk_toggle_button_get_active(w))
@@ -224,6 +232,14 @@ static GtkWidget *trg_prefs_desktopPage(GConfClient * gconf,
t = hig_workarea_create();
+ hig_workarea_add_section_title(t, &row, _("Features"));
+
+ w = new_check_button(gconf, _("Show graph"),
+ TRG_GCONF_KEY_SHOW_GRAPH);
+ g_signal_connect(G_OBJECT(w), "toggled",
+ G_CALLBACK(toggle_show_graph), win);
+ hig_workarea_add_wide_control(t, &row, w);
+
hig_workarea_add_section_title(t, &row, _("System Tray"));
tray = new_check_button(gconf, _("Show in system tray"),
diff --git a/src/trg-preferences.h b/src/trg-preferences.h
index b27bdfb..c2c43b4 100644
--- a/src/trg-preferences.h
+++ b/src/trg-preferences.h
@@ -32,6 +32,7 @@
#define TRG_GCONF_KEY_WINDOW_WIDTH "/apps/transmission-remote-gtk/window-width"
#define TRG_GCONF_KEY_WINDOW_HEIGHT "/apps/transmission-remote-gtk/window-height"
#define TRG_GCONF_KEY_SYSTEM_TRAY "/apps/transmission-remote-gtk/system-tray"
+#define TRG_GCONF_KEY_SHOW_GRAPH "/apps/transmission-remote-gtk/show-graph"
#define TRG_GCONF_KEY_SYSTEM_TRAY_MINIMISE "/apps/transmission-remote-gtk/system-tray-minimise"
#endif /* TRG_PREFERENCES_H_ */