summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/transmission-remote-gtk.schemas23
-rw-r--r--src/trg-main-window.c72
-rw-r--r--src/trg-peers-model.c28
-rw-r--r--src/trg-preferences-dialog.c28
-rw-r--r--src/trg-preferences.h7
-rw-r--r--src/trg-status-bar.c24
-rw-r--r--src/trg-status-bar.h2
7 files changed, 133 insertions, 51 deletions
diff --git a/src/transmission-remote-gtk.schemas b/src/transmission-remote-gtk.schemas
index f5f7615..dbd08aa 100644
--- a/src/transmission-remote-gtk.schemas
+++ b/src/transmission-remote-gtk.schemas
@@ -15,11 +15,24 @@
</schema>
<schema>
+ <key>/schemas/apps/transmission-remote-gtk/system-tray-minimise</key>
+ <applyto>/apps/transmission-remote-gtk/system-tray-minimise</applyto>
+ <owner>transmission-remote-gtk</owner>
+ <type>bool</type>
+ <default>1</default>
+
+ <locale name="C">
+ <short>Minimise to system tray</short>
+ <long>Minimise to system tray</long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/transmission-remote-gtk/system-tray</key>
<applyto>/apps/transmission-remote-gtk/system-tray</applyto>
<owner>transmission-remote-gtk</owner>
<type>bool</type>
- <default>0</default>
+ <default>1</default>
<locale name="C">
<short>Show system tray icon</short>
@@ -28,8 +41,8 @@
</schema>
<schema>
- <key>/schemas/apps/transmission-remote-gtk/window_height</key>
- <applyto>/apps/transmission-remote-gtk/window_height</applyto>
+ <key>/schemas/apps/transmission-remote-gtk/window-height</key>
+ <applyto>/apps/transmission-remote-gtk/window-height</applyto>
<owner>transmission-remote-gtk</owner>
<type>int</type>
<default>600</default>
@@ -41,8 +54,8 @@
</schema>
<schema>
- <key>/schemas/apps/transmission-remote-gtk/window_width</key>
- <applyto>/apps/transmission-remote-gtk/window_width</applyto>
+ <key>/schemas/apps/transmission-remote-gtk/window-width</key>
+ <applyto>/apps/transmission-remote-gtk/window-width</applyto>
<owner>transmission-remote-gtk</owner>
<type>int</type>
<default>800</default>
diff --git a/src/trg-main-window.c b/src/trg-main-window.c
index c161085..3f8e9fd 100644
--- a/src/trg-main-window.c
+++ b/src/trg-main-window.c
@@ -203,7 +203,7 @@ static void on_torrent_completed(TrgTorrentModel * model,
priv = TRG_MAIN_WINDOW_GET_PRIVATE(data);
- if (!gtk_status_icon_is_embedded(priv->statusIcon))
+ if (priv->statusIcon == NULL || !gtk_status_icon_is_embedded(priv->statusIcon))
return;
gtk_tree_model_get(GTK_TREE_MODEL(model), iter,
@@ -1104,6 +1104,7 @@ static TrgMenuBar *trg_main_window_menu_bar_new(TrgMainWindow * win)
static void status_icon_activated(GtkStatusIcon * icon G_GNUC_UNUSED, gpointer data)
{
+ gtk_window_deiconify(GTK_WINDOW(data));
gtk_window_present(GTK_WINDOW(data));
}
@@ -1264,6 +1265,36 @@ static gboolean torrent_tv_popup_menu_cb(GtkWidget * treeview,
return TRUE;
}
+static void status_bar_text_pushed(GtkStatusbar *statusbar, guint context_id, gchar *text, gpointer user_data)
+{
+ TrgMainWindowPrivate *priv = TRG_MAIN_WINDOW_GET_PRIVATE(user_data);
+
+ if (priv->statusIcon != NULL)
+ gtk_status_icon_set_tooltip(priv->statusIcon, text);
+}
+
+static gboolean window_state_event (GtkWidget *widget, GdkEventWindowState *event, gpointer trayIcon)
+{
+ TrgMainWindowPrivate *priv = TRG_MAIN_WINDOW_GET_PRIVATE(widget);
+
+ if(priv->statusIcon != NULL && event->changed_mask == GDK_WINDOW_STATE_ICONIFIED && (event->new_window_state == GDK_WINDOW_STATE_ICONIFIED || event->new_window_state == (GDK_WINDOW_STATE_ICONIFIED | GDK_WINDOW_STATE_MAXIMIZED)))
+ {
+ GError *error = NULL;
+ gboolean tray_min = gconf_client_get_bool(priv->client->gconf, TRG_GCONF_KEY_SYSTEM_TRAY_MINIMISE, &error);
+
+ if (error)
+ {
+ g_error_free(error);
+ tray_min = TRUE;
+ }
+
+ if (tray_min)
+ gtk_widget_hide (GTK_WIDGET(widget));
+ }
+
+ return TRUE;
+}
+
static GObject *trg_main_window_constructor(GType type,
guint
n_construct_properties,
@@ -1278,6 +1309,8 @@ static GObject *trg_main_window_constructor(GType type,
GtkIconTheme *theme;
GdkPixbuf *icon;
gint width, height;
+ GError *error = NULL;
+ gboolean tray;
self = TRG_MAIN_WINDOW(G_OBJECT_CLASS
(trg_main_window_parent_class)->constructor
@@ -1298,6 +1331,7 @@ static GObject *trg_main_window_constructor(GType type,
G_CALLBACK(delete_event), NULL);
g_signal_connect(G_OBJECT(self), "destroy", G_CALLBACK(destroy_window),
NULL);
+ g_signal_connect (G_OBJECT (self), "window-state-event", G_CALLBACK (window_state_event), NULL);
priv->torrentModel = trg_torrent_model_new();
g_signal_connect(priv->torrentModel, "torrent-completed",
@@ -1325,7 +1359,6 @@ static GObject *trg_main_window_constructor(GType type,
g_signal_connect(priv->torrentTreeView, "button-press-event",
G_CALLBACK(torrent_tv_button_pressed_cb), self);
-
outerVbox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(self), outerVbox);
@@ -1392,17 +1425,32 @@ static GObject *trg_main_window_constructor(GType type,
priv->notebook = trg_main_window_notebook_new(self);
gtk_paned_pack2(GTK_PANED(priv->vpaned), priv->notebook, FALSE, FALSE);
- priv->statusIcon = gtk_status_icon_new_from_pixbuf(icon);
- gtk_status_icon_set_screen(priv->statusIcon,
+ tray = gconf_client_get_bool(priv->client->gconf, TRG_GCONF_KEY_SYSTEM_TRAY, &error);
+ if (error)
+ {
+ g_error_free(error);
+ tray = TRUE;
+ }
+
+ if (tray)
+ {
+ priv->statusIcon = gtk_status_icon_new_from_pixbuf(icon);
+ gtk_status_icon_set_screen(priv->statusIcon,
gtk_window_get_screen(GTK_WINDOW(self)));
- g_signal_connect(priv->statusIcon, "activate",
- G_CALLBACK(status_icon_activated), self);
- g_signal_connect(priv->statusIcon, "button-press-event",
- G_CALLBACK(status_icon_button_press_event), self);
- g_signal_connect(priv->statusIcon, "popup-menu",
- G_CALLBACK(trg_status_icon_popup_menu_cb), self);
-
- priv->statusBar = trg_status_bar_new(priv->statusIcon);
+ g_signal_connect(priv->statusIcon, "activate",
+ G_CALLBACK(status_icon_activated), self);
+ g_signal_connect(priv->statusIcon, "button-press-event",
+ G_CALLBACK(status_icon_button_press_event), self);
+ g_signal_connect(priv->statusIcon, "popup-menu",
+ G_CALLBACK(trg_status_icon_popup_menu_cb), self);
+ }
+ else
+ {
+ priv->statusIcon = NULL;
+ }
+
+ priv->statusBar = trg_status_bar_new();
+ g_signal_connect(priv->statusBar, "text-pushed", G_CALLBACK(status_bar_text_pushed), self);
gtk_box_pack_start(GTK_BOX(outerVbox), GTK_WIDGET(priv->statusBar),
FALSE, FALSE, 2);
diff --git a/src/trg-peers-model.c b/src/trg-peers-model.c
index 8627422..9119678 100644
--- a/src/trg-peers-model.c
+++ b/src/trg-peers-model.c
@@ -38,9 +38,21 @@
G_DEFINE_TYPE(TrgPeersModel, trg_peers_model, GTK_TYPE_LIST_STORE)
+#define TRG_PEERS_MODEL_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_PEERS_MODEL, TrgPeersModelPrivate))
+
+typedef struct _TrgPeersModelPrivate TrgPeersModelPrivate;
+
+struct _TrgPeersModelPrivate {
+#ifdef HAVE_GEOIP
+ GeoIP *geoip;
+#endif
+};
+
static void
trg_peers_model_class_init(TrgPeersModelClass * klass G_GNUC_UNUSED)
{
+ g_type_class_add_private (klass, sizeof (TrgPeersModelPrivate));
}
gboolean
@@ -114,6 +126,8 @@ static void resolved_dns_cb(GObject * source_object,
void trg_peers_model_update(TrgPeersModel * model, gint64 updateSerial,
JsonObject * t, gboolean first)
{
+ TrgPeersModelPrivate *priv = TRG_PEERS_MODEL_GET_PRIVATE(model);
+
JsonArray *peers;
GtkTreeIter peerIter;
guint j;
@@ -128,7 +142,6 @@ void trg_peers_model_update(TrgPeersModel * model, gint64 updateSerial,
JsonObject *peer;
const gchar *address=NULL, *flagStr;
#if HAVE_GEOIP
- GeoIP *gi;
const gchar *country = NULL;
#endif
peer = json_node_get_object(json_array_get_element(peers, j));
@@ -139,8 +152,8 @@ void trg_peers_model_update(TrgPeersModel * model, gint64 updateSerial,
address = peer_get_address(peer);
#if HAVE_GEOIP
- if ((gi = g_object_get_data(G_OBJECT(model), "geoip")) != NULL)
- country = GeoIP_country_name_by_addr(gi, address);
+ if (priv->geoip != NULL)
+ country = GeoIP_country_name_by_addr(priv->geoip, address);
#endif
gtk_list_store_set(GTK_LIST_STORE(model), &peerIter,
PEERSCOL_ICON, GTK_STOCK_NETWORK,
@@ -197,6 +210,8 @@ void trg_peers_model_update(TrgPeersModel * model, gint64 updateSerial,
static void trg_peers_model_init(TrgPeersModel * self)
{
+ TrgPeersModelPrivate *priv = TRG_PEERS_MODEL_GET_PRIVATE(self);
+
GType column_types[PEERSCOL_COLUMNS];
column_types[PEERSCOL_ICON] = G_TYPE_STRING;
@@ -216,11 +231,8 @@ static void trg_peers_model_init(TrgPeersModel * self)
PEERSCOL_COLUMNS, column_types);
#if HAVE_GEOIP
- if (g_file_test(TRG_GEOIP_DATABASE, G_FILE_TEST_EXISTS) == TRUE) {
- GeoIP *gi = GeoIP_open(TRG_GEOIP_DATABASE,
- GEOIP_STANDARD | GEOIP_CHECK_CACHE);
- g_object_set_data(G_OBJECT(self), "geoip", gi);
- }
+ if (g_file_test(TRG_GEOIP_DATABASE, G_FILE_TEST_EXISTS) == TRUE)
+ priv->geoip = GeoIP_open(TRG_GEOIP_DATABASE, GEOIP_STANDARD | GEOIP_CHECK_CACHE);
#endif
}
diff --git a/src/trg-preferences-dialog.c b/src/trg-preferences-dialog.c
index cd8f51f..8a88205 100644
--- a/src/trg-preferences-dialog.c
+++ b/src/trg-preferences-dialog.c
@@ -28,6 +28,7 @@
#include "hig.h"
#include "trg-preferences-dialog.h"
+#include "trg-json-widgets.h"
#include "trg-preferences.h"
#define TRG_PREFERENCES_DIALOG_GET_PRIVATE(object) \
@@ -193,6 +194,29 @@ static GtkWidget *new_entry(GConfClient * gconf, const char *key)
return w;
}
+static GtkWidget *trg_prefs_desktopPage(GConfClient *gconf)
+{
+ GtkWidget *tray, *tray_min, *t;
+ gint row = 0;
+
+ t = hig_workarea_create();
+
+ hig_workarea_add_section_title(t, &row, "System Tray");
+
+ tray = new_check_button(gconf, "Show in system tray",
+ TRG_GCONF_KEY_SYSTEM_TRAY);
+ hig_workarea_add_wide_control(t, &row, tray);
+
+ tray_min = new_check_button(gconf, "Minimise to system tray",
+ TRG_GCONF_KEY_SYSTEM_TRAY_MINIMISE);
+ gtk_widget_set_sensitive(tray_min, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tray)));
+ g_signal_connect(G_OBJECT(tray), "toggled",
+ G_CALLBACK(toggle_active_arg_is_sensitive), tray_min);
+ hig_workarea_add_wide_control(t, &row, tray_min);
+
+ return t;
+}
+
static GtkWidget *trg_prefs_serverPage(GConfClient * gconf)
{
GtkWidget *w, *t;
@@ -259,6 +283,10 @@ static GObject *trg_preferences_dialog_constructor(GType type,
trg_prefs_serverPage(priv->gconf),
gtk_label_new("Connection"));
+ gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
+ trg_prefs_desktopPage(priv->gconf),
+ gtk_label_new("Desktop"));
+
gtk_container_set_border_width(GTK_CONTAINER(notebook), GUI_PAD);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(object)->vbox), notebook,
diff --git a/src/trg-preferences.h b/src/trg-preferences.h
index 49b95a7..7c01cf6 100644
--- a/src/trg-preferences.h
+++ b/src/trg-preferences.h
@@ -25,8 +25,9 @@
#define TRG_GCONF_KEY_USERNAME "/apps/transmission-remote-gtk/username"
#define TRG_GCONF_KEY_PASSWORD "/apps/transmission-remote-gtk/password"
#define TRG_GCONF_KEY_AUTO_CONNECT "/apps/transmission-remote-gtk/auto-connect"
-#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_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_SYSTEM_TRAY_MINIMISE "/apps/transmission-remote-gtk/system-tray-minimise"
#endif /* TRG_PREFERENCES_H_ */
diff --git a/src/trg-status-bar.c b/src/trg-status-bar.c
index d6e4cab..5e463ad 100644
--- a/src/trg-status-bar.c
+++ b/src/trg-status-bar.c
@@ -33,7 +33,6 @@ typedef struct _TrgStatusBarPrivate TrgStatusBarPrivate;
struct _TrgStatusBarPrivate {
guint connectionCtx;
guint countSpeedsCtx;
- GtkStatusIcon *icon;
};
static void trg_status_bar_class_init(TrgStatusBarClass * klass)
@@ -59,7 +58,6 @@ void trg_status_bar_push_connection_msg(TrgStatusBar * sb,
priv = TRG_STATUS_BAR_GET_PRIVATE(sb);
- gtk_status_icon_set_tooltip(priv->icon, msg);
gtk_statusbar_pop(GTK_STATUSBAR(sb), priv->connectionCtx);
gtk_statusbar_push(GTK_STATUSBAR(sb), priv->connectionCtx, msg);
}
@@ -75,7 +73,6 @@ void trg_status_bar_connect(TrgStatusBar * sb, JsonObject * session)
g_printf("%s\n", statusMsg);
trg_status_bar_push_connection_msg(sb, statusMsg);
g_free(statusMsg);
-
}
void trg_status_bar_update(TrgStatusBar * sb,
@@ -101,27 +98,10 @@ void trg_status_bar_update(TrgStatusBar * sb,
gtk_statusbar_push(GTK_STATUSBAR(sb),
priv->countSpeedsCtx, statusBarUpdate);
g_free(statusBarUpdate);
-
- if (priv->icon != NULL) {
- gchar *toolTipUpdate =
- g_strdup_printf("%d torrents: %s down/%s up",
- stats->count, downRateTotalString,
- upRateTotalString);
- gtk_status_icon_set_tooltip(priv->icon, toolTipUpdate);
- g_free(toolTipUpdate);
- }
}
-TrgStatusBar *trg_status_bar_new(GtkStatusIcon * icon)
+TrgStatusBar *trg_status_bar_new()
{
- TrgStatusBarPrivate *priv;
- GObject *obj;
-
- obj = g_object_new(TRG_TYPE_STATUS_BAR, NULL);
-
- priv = TRG_STATUS_BAR_GET_PRIVATE(obj);
- priv->icon = icon;
-
- return TRG_STATUS_BAR(obj);
+ return TRG_STATUS_BAR(g_object_new(TRG_TYPE_STATUS_BAR, NULL));
}
diff --git a/src/trg-status-bar.h b/src/trg-status-bar.h
index ae99199..3baf5bc 100644
--- a/src/trg-status-bar.h
+++ b/src/trg-status-bar.h
@@ -48,7 +48,7 @@ typedef struct {
GType trg_status_bar_get_type(void);
-TrgStatusBar *trg_status_bar_new(GtkStatusIcon * icon);
+TrgStatusBar *trg_status_bar_new();
G_END_DECLS
void trg_status_bar_update(TrgStatusBar * sb,