summaryrefslogtreecommitdiff
path: root/src/trg-main-window.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/trg-main-window.c')
-rw-r--r--src/trg-main-window.c208
1 files changed, 99 insertions, 109 deletions
diff --git a/src/trg-main-window.c b/src/trg-main-window.c
index 53c568e..48b9d6e 100644
--- a/src/trg-main-window.c
+++ b/src/trg-main-window.c
@@ -208,9 +208,13 @@ static gboolean window_state_event(TrgMainWindow * win,
GdkEventWindowState * event,
gpointer trayIcon);
+struct _TrgMainWindow
+{
+ GtkApplicationWindow parent;
+};
-G_DEFINE_TYPE(TrgMainWindow, trg_main_window, GTK_TYPE_WINDOW)
-struct _TrgMainWindowPrivate {
+typedef struct
+{
TrgClient *client;
TrgToolbar *toolBar;
TrgMenuBar *menuBar;
@@ -259,7 +263,9 @@ struct _TrgMainWindowPrivate {
gboolean queuesEnabled;
gchar **args;
-};
+} TrgMainWindowPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE(TrgMainWindow, trg_main_window, GTK_TYPE_WINDOW)
enum {
PROP_0, PROP_CLIENT, PROP_MINIMISE_ON_START
@@ -267,7 +273,7 @@ enum {
static void reset_connect_args(TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (priv->args) {
g_strfreev(priv->args);
priv->args = NULL;
@@ -276,21 +282,18 @@ static void reset_connect_args(TrgMainWindow * win)
static void trg_main_window_init(TrgMainWindow * self)
{
- self->priv =
- G_TYPE_INSTANCE_GET_PRIVATE(self, TRG_TYPE_MAIN_WINDOW,
- TrgMainWindowPrivate);
}
gint trg_mw_get_selected_torrent_id(TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
return priv->selectedTorrentId;
}
static void
update_selected_torrent_notebook(TrgMainWindow * win, gint mode, gint64 id)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgClient *client = priv->client;
gint64 serial = trg_client_get_serial(client);
JsonObject *t;
@@ -324,7 +327,7 @@ torrent_event_notification(TrgTorrentModel * model,
GtkTreeIter * iter, gpointer data)
{
TrgMainWindow *win = TRG_MAIN_WINDOW(data);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgPrefs *prefs = trg_client_get_prefs(priv->client);
gchar *name;
NotifyNotification *notify;
@@ -390,7 +393,7 @@ delete_event(GtkWidget * w, GdkEvent * event G_GNUC_UNUSED,
static void
destroy_window(TrgMainWindow * win, gpointer data G_GNUC_UNUSED)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgPrefs *prefs = trg_client_get_prefs(priv->client);
trg_prefs_set_int(prefs, TRG_PREFS_KEY_WINDOW_HEIGHT, priv->height,
@@ -432,7 +435,7 @@ destroy_window(TrgMainWindow * win, gpointer data G_GNUC_UNUSED)
static void open_props_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgTorrentPropsDialog *dialog;
if (priv->selectedTorrentId < 0)
@@ -458,7 +461,7 @@ torrent_tv_onRowActivated(GtkTreeView * treeview,
static void add_url_cb(GtkWidget * w G_GNUC_UNUSED, gpointer data)
{
TrgMainWindow *win = TRG_MAIN_WINDOW(data);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgTorrentAddUrlDialog *dlg = trg_torrent_add_url_dialog_new(win,
priv->
@@ -469,7 +472,7 @@ static void add_url_cb(GtkWidget * w G_GNUC_UNUSED, gpointer data)
static void add_cb(GtkWidget * w G_GNUC_UNUSED, gpointer data)
{
TrgMainWindow *win = TRG_MAIN_WINDOW(data);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (trg_client_is_connected(priv->client))
trg_torrent_add_dialog(win, priv->client);
@@ -477,7 +480,7 @@ static void add_cb(GtkWidget * w G_GNUC_UNUSED, gpointer data)
static void pause_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (trg_client_is_connected(priv->client))
dispatch_async(priv->client,
@@ -488,7 +491,7 @@ static void pause_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
static void pause_all_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (trg_client_is_connected(priv->client))
dispatch_async(priv->client, torrent_pause(NULL),
@@ -497,7 +500,7 @@ static void pause_all_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
gint trg_add_from_filename(TrgMainWindow * win, gchar ** uris)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgClient *client = priv->client;
TrgPrefs *prefs = trg_client_get_prefs(client);
GSList *filesList = NULL;
@@ -547,7 +550,7 @@ gint trg_add_from_filename(TrgMainWindow * win, gchar ** uris)
static void resume_all_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (trg_client_is_connected(priv->client))
dispatch_async(priv->client, torrent_start(NULL),
@@ -556,7 +559,7 @@ static void resume_all_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
static void resume_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (trg_client_is_connected(priv->client))
dispatch_async(priv->client,
@@ -568,7 +571,7 @@ static void resume_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
static void disconnect_cb(GtkWidget * w G_GNUC_UNUSED, gpointer data)
{
TrgMainWindow *win = TRG_MAIN_WINDOW(data);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
trg_client_inc_connid(priv->client);
trg_main_window_conn_changed(TRG_MAIN_WINDOW(data), FALSE);
@@ -578,7 +581,7 @@ static void disconnect_cb(GtkWidget * w G_GNUC_UNUSED, gpointer data)
void connect_cb(GtkWidget * w, gpointer data)
{
TrgMainWindow *win = TRG_MAIN_WINDOW(data);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgPrefs *prefs = trg_client_get_prefs(priv->client);
JsonObject *currentProfile = trg_prefs_get_profile(prefs);
@@ -635,7 +638,7 @@ void connect_cb(GtkWidget * w, gpointer data)
static void
open_local_prefs_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
GtkWidget *dlg = trg_preferences_dialog_get_instance(win,
priv->client);
@@ -645,7 +648,7 @@ open_local_prefs_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
static void
open_remote_prefs_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (trg_client_is_connected(priv->client))
gtk_widget_show_all(GTK_WIDGET
@@ -657,7 +660,7 @@ static void
main_window_toggle_filter_dirs(GtkCheckMenuItem * w, gpointer data)
{
TrgMainWindow *win = TRG_MAIN_WINDOW(data);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (gtk_widget_is_sensitive(GTK_WIDGET(w)))
trg_state_selector_set_show_dirs(priv->stateSelector,
@@ -669,7 +672,7 @@ static void
main_window_toggle_filter_trackers(GtkCheckMenuItem * w, gpointer data)
{
TrgMainWindow *win = TRG_MAIN_WINDOW(data);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (gtk_widget_is_sensitive(GTK_WIDGET(w)))
trg_state_selector_set_show_trackers(priv->stateSelector,
@@ -679,7 +682,7 @@ main_window_toggle_filter_trackers(GtkCheckMenuItem * w, gpointer data)
static TrgToolbar *trg_main_window_toolbar_new(TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgPrefs *prefs = trg_client_get_prefs(priv->client);
GObject *b_connect, *b_disconnect, *b_add, *b_resume, *b_pause;
@@ -715,7 +718,7 @@ static TrgToolbar *trg_main_window_toolbar_new(TrgMainWindow * win)
static void reannounce_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (trg_client_is_connected(priv->client))
dispatch_async(priv->client,
@@ -726,7 +729,7 @@ static void reannounce_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
static void verify_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (is_ready_for_torrent_action(win))
dispatch_async(priv->client,
@@ -737,7 +740,7 @@ static void verify_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
static void start_now_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (is_ready_for_torrent_action(win))
dispatch_async(priv->client,
@@ -748,7 +751,7 @@ static void start_now_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
static void up_queue_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (priv->queuesEnabled && is_ready_for_torrent_action(win))
dispatch_async(priv->client,
@@ -759,7 +762,7 @@ static void up_queue_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
static void top_queue_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (priv->queuesEnabled && is_ready_for_torrent_action(win))
dispatch_async(priv->client,
@@ -771,7 +774,7 @@ static void top_queue_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
static void
bottom_queue_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (priv->queuesEnabled && is_ready_for_torrent_action(win))
dispatch_async(priv->client,
@@ -782,7 +785,7 @@ bottom_queue_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
static void down_queue_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (priv->queuesEnabled && is_ready_for_torrent_action(win))
dispatch_async(priv->client,
@@ -799,7 +802,7 @@ confirm_action_dialog(GtkWindow * gtk_win,
const gchar * action_stock)
{
TrgMainWindow *win = TRG_MAIN_WINDOW(gtk_win);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
gint selectCount;
gint response;
GtkWidget *dialog = NULL;
@@ -857,14 +860,14 @@ confirm_action_dialog(GtkWindow * gtk_win,
static gboolean is_ready_for_torrent_action(TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
return priv->selectedTorrentId >= 0
&& trg_client_is_connected(priv->client);
}
static void move_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (is_ready_for_torrent_action(win))
gtk_widget_show_all(GTK_WIDGET
@@ -874,7 +877,7 @@ static void move_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
static void remove_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
GtkTreeSelection *selection;
JsonArray *ids;
@@ -897,7 +900,7 @@ static void remove_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
static void delete_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
GtkTreeSelection *selection;
JsonArray *ids;
@@ -922,7 +925,7 @@ static void delete_cb(GtkWidget * w G_GNUC_UNUSED, TrgMainWindow * win)
static void view_stats_toggled_cb(GtkWidget * w, gpointer data)
{
TrgMainWindow *win = TRG_MAIN_WINDOW(data);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (trg_client_is_connected(priv->client)) {
TrgStatsDialog *dlg =
@@ -937,7 +940,7 @@ static void view_stats_toggled_cb(GtkWidget * w, gpointer data)
static void view_rss_toggled_cb(GtkWidget * w, gpointer data)
{
TrgMainWindow *win = TRG_MAIN_WINDOW(data);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (trg_client_is_connected(priv->client)) {
TrgRssWindow *rss =
@@ -952,7 +955,7 @@ static void view_rss_toggled_cb(GtkWidget * w, gpointer data)
static void
view_states_toggled_cb(GtkCheckMenuItem * w, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
trg_widget_set_visible(priv->stateSelectorScroller,
gtk_check_menu_item_get_active(w));
@@ -961,7 +964,7 @@ view_states_toggled_cb(GtkCheckMenuItem * w, TrgMainWindow * win)
static void
view_notebook_toggled_cb(GtkCheckMenuItem * w, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
trg_widget_set_visible(priv->notebook,
gtk_check_menu_item_get_active(w));
@@ -972,7 +975,7 @@ static void
trg_main_window_toggle_graph_cb(GtkCheckMenuItem * w, gpointer data)
{
TrgMainWindow *win = TRG_MAIN_WINDOW(data);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (!gtk_widget_is_sensitive(GTK_WIDGET(w))) {
return;
@@ -988,13 +991,13 @@ trg_main_window_toggle_graph_cb(GtkCheckMenuItem * w, gpointer data)
void
trg_main_window_notebook_set_visible(TrgMainWindow * win, gboolean visible)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
trg_widget_set_visible(priv->notebook, visible);
}
static GtkWidget *trg_main_window_notebook_new(TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgPrefs *prefs = trg_client_get_prefs(priv->client);
GtkWidget *notebook = priv->notebook = gtk_notebook_new();
@@ -1052,7 +1055,7 @@ gboolean on_session_set(gpointer data)
{
trg_response *response = (trg_response *) data;
TrgMainWindow *win = TRG_MAIN_WINDOW(response->cb_data);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (response->status == CURLE_OK
|| response->status == FAIL_RESPONSE_UNSUCCESSFUL)
@@ -1076,7 +1079,7 @@ static gboolean on_session_get_timer(gpointer data)
{
trg_response *response = (trg_response *) data;
TrgMainWindow *win = TRG_MAIN_WINDOW(response->cb_data);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgPrefs *prefs = trg_client_get_prefs(priv->client);
on_session_get(data);
@@ -1094,7 +1097,7 @@ static gboolean on_session_get(gpointer data)
{
trg_response *response = (trg_response *) data;
TrgMainWindow *win = TRG_MAIN_WINDOW(response->cb_data);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgClient *client = priv->client;
gboolean isConnected = trg_client_is_connected(client);
@@ -1179,7 +1182,7 @@ TRANSMISSION_MIN_SUPPORTED, version);
static void
connchange_whatever_statusicon(TrgMainWindow * win, gboolean connected)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgPrefs *prefs = trg_client_get_prefs(priv->client);
gchar *display = connected ?
trg_prefs_get_string(prefs, TRG_PREFS_KEY_PROFILE_NAME,
@@ -1210,7 +1213,7 @@ static void
update_whatever_statusicon(TrgMainWindow * win,
trg_torrent_model_update_stats * stats)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
#ifdef HAVE_LIBAPPINDICATOR
if (!priv->appIndicator && !priv->statusIcon)
@@ -1252,7 +1255,7 @@ static gboolean on_torrent_get(gpointer data, int mode)
{
trg_response *response = (trg_response *) data;
TrgMainWindow *win = TRG_MAIN_WINDOW(response->cb_data);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgClient *client = priv->client;
TrgPrefs *prefs = trg_client_get_prefs(client);
trg_torrent_model_update_stats *stats;
@@ -1356,7 +1359,7 @@ static gboolean on_torrent_get_first(gpointer data)
{
trg_response *response = (trg_response *) data;
TrgMainWindow *win = TRG_MAIN_WINDOW(response->cb_data);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
gboolean result = on_torrent_get(data, TORRENT_GET_MODE_FIRST);
@@ -1381,7 +1384,7 @@ static gboolean on_torrent_get_update(gpointer data)
static gboolean trg_session_update_timerfunc(gpointer data)
{
TrgMainWindow *win = TRG_MAIN_WINDOW(data);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
trg_client_update_session(priv->client, on_session_get_timer, win);
@@ -1396,7 +1399,7 @@ static gboolean trg_update_torrents_timerfunc(gpointer data)
return FALSE;
TrgMainWindow *win = TRG_MAIN_WINDOW(data);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgClient *tc = priv->client;
TrgPrefs *prefs = trg_client_get_prefs(tc);
@@ -1434,7 +1437,7 @@ trg_torrent_tree_view_visible_func(GtkTreeModel * model,
GtkTreeIter * iter, gpointer data)
{
TrgMainWindow *win = TRG_MAIN_WINDOW(data);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
guint flags;
gboolean visible;
const gchar *filterText;
@@ -1501,7 +1504,7 @@ trg_torrent_tree_view_visible_func(GtkTreeModel * model,
void trg_main_window_reload_dir_aliases(TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
trg_torrent_model_reload_dir_aliases(priv->client, GTK_TREE_MODEL
(priv->torrentModel));
}
@@ -1510,7 +1513,7 @@ static TrgTorrentTreeView
* trg_main_window_torrent_tree_view_new(TrgMainWindow * win,
GtkTreeModel * model)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgTorrentTreeView *torrentTreeView =
trg_torrent_tree_view_new(priv->client,
model);
@@ -1527,7 +1530,7 @@ static TrgTorrentTreeView
static gboolean
trg_dialog_error_handler(TrgMainWindow * win, trg_response * response)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (response->status != CURLE_OK) {
GtkWidget *dialog;
@@ -1553,7 +1556,7 @@ static gboolean
torrent_selection_changed(GtkTreeSelection * selection,
TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
GList *selectionList;
GList *firstNode;
gint64 id;
@@ -1588,7 +1591,7 @@ gboolean on_delete_complete(gpointer data)
{
trg_response *response = (trg_response *) data;
TrgMainWindow *win = TRG_MAIN_WINDOW(response->cb_data);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgClient *tc = priv->client;
if (trg_client_is_connected(tc) && response->status == CURLE_OK)
@@ -1599,7 +1602,7 @@ gboolean on_delete_complete(gpointer data)
}
void on_generic_interactive_action(TrgMainWindow *win, trg_response *response) {
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgClient *tc = priv->client;
if (trg_client_is_connected(tc)) {
@@ -1632,7 +1635,7 @@ gboolean on_generic_interactive_action_response(gpointer data)
static void trg_main_window_torrent_scrub(TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
gtk_tree_store_clear(GTK_TREE_STORE(priv->filesModel));
gtk_list_store_clear(GTK_LIST_STORE(priv->trackersModel));
@@ -1647,7 +1650,7 @@ static void trg_main_window_torrent_scrub(TrgMainWindow * win)
static void entry_filter_changed_cb(GtkWidget * w, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
gboolean clearSensitive = gtk_entry_get_text_length(GTK_ENTRY(w)) > 0;
gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER
@@ -1668,7 +1671,7 @@ torrent_state_selection_changed(TrgStateSelector *
static void
trg_main_window_conn_changed(TrgMainWindow * win, gboolean connected)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgClient *tc = priv->client;
trg_toolbar_connected_change(priv->toolBar, connected);
@@ -1715,7 +1718,7 @@ trg_main_window_get_property(GObject * object,
GParamSpec * pspec)
{
TrgMainWindow *win = TRG_MAIN_WINDOW(object);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
switch (property_id) {
case PROP_CLIENT:
@@ -1736,7 +1739,7 @@ trg_main_window_set_property(GObject * object,
const GValue * value, GParamSpec * pspec)
{
TrgMainWindow *win = TRG_MAIN_WINDOW(object);
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
switch (property_id) {
case PROP_CLIENT:
@@ -1758,7 +1761,7 @@ static void quit_cb(GtkWidget * w G_GNUC_UNUSED, gpointer data)
static TrgMenuBar *trg_main_window_menu_bar_new(TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
GObject *b_disconnect, *b_add, *b_resume, *b_pause, *b_verify,
*b_remove, *b_delete, *b_props, *b_local_prefs, *b_remote_prefs,
@@ -1867,7 +1870,7 @@ static void
status_icon_activated(GtkStatusIcon * icon G_GNUC_UNUSED,
TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgPrefs *prefs = trg_client_get_prefs(priv->client);
trg_main_window_set_hidden_to_tray(win,
@@ -1880,7 +1883,7 @@ status_icon_activated(GtkStatusIcon * icon G_GNUC_UNUSED,
static gboolean
trg_status_icon_popup_menu_cb(GtkStatusIcon * icon, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
gtk_menu_popup(priv->iconMenu, NULL, NULL,
#ifdef WIN32
@@ -1897,7 +1900,7 @@ static gboolean
status_icon_button_press_event(GtkStatusIcon * icon,
GdkEventButton * event, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
@@ -1944,7 +1947,7 @@ static GtkWidget *trg_imagemenuitem_new(GtkMenuShell * shell,
static void set_limit_cb(GtkWidget * w, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
GtkWidget *parent = gtk_widget_get_parent(w);
@@ -1977,7 +1980,7 @@ static void set_limit_cb(GtkWidget * w, TrgMainWindow * win)
static void set_priority_cb(GtkWidget * w, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
GtkWidget *parent = gtk_widget_get_parent(w);
@@ -2036,7 +2039,7 @@ static GtkWidget *priority_menu_item_new(TrgMainWindow * win,
static GtkWidget *priority_menu_new(TrgMainWindow * win, JsonArray * ids)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgClient *client = priv->client;
JsonObject *t = NULL;
gint selected_pri = TR_PRI_UNSET;
@@ -2073,7 +2076,7 @@ static GtkWidget *limit_menu_new(TrgMainWindow * win, gchar * title,
gchar * enabledKey, gchar * speedKey,
JsonArray * ids)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgClient *client = priv->client;
JsonObject *current = NULL;
GtkTreeIter iter;
@@ -2141,7 +2144,7 @@ static GtkWidget *limit_menu_new(TrgMainWindow * win, gchar * title,
static void exec_cmd_cb(GtkWidget * w, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
JsonObject *cmd_obj = (JsonObject *) g_object_get_data(G_OBJECT(w),
"cmd-object");
GtkTreeSelection *selection =
@@ -2196,7 +2199,7 @@ static void
trg_torrent_tv_view_menu(GtkWidget * treeview,
GdkEventButton * event, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgPrefs *prefs = trg_client_get_prefs(priv->client);
GtkWidget *menu;
gint n_cmds;
@@ -2322,7 +2325,7 @@ trg_torrent_tv_view_menu(GtkWidget * treeview,
static GtkMenu *trg_status_icon_view_menu(TrgMainWindow * win,
const gchar * msg)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgPrefs *prefs = trg_client_get_prefs(priv->client);
gboolean connected = trg_client_is_connected(priv->client);
GtkWidget *menu, *connect;
@@ -2442,7 +2445,7 @@ static void trg_main_window_set_hidden_to_tray(TrgMainWindow * win,
gboolean hidden)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (hidden) {
gtk_widget_hide(GTK_WIDGET(win));
@@ -2465,7 +2468,7 @@ static gboolean
window_state_event(TrgMainWindow * win,
GdkEventWindowState * event, gpointer trayIcon)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgPrefs *prefs = trg_client_get_prefs(priv->client);
if (priv->statusIcon
@@ -2482,7 +2485,7 @@ window_state_event(TrgMainWindow * win,
void trg_main_window_remove_status_icon(TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
#ifdef HAVE_LIBAPPINDICATOR
if (priv->appIndicator) {
g_object_unref(G_OBJECT(priv->appIndicator));
@@ -2502,7 +2505,7 @@ void trg_main_window_remove_status_icon(TrgMainWindow * win)
#if TRG_WITH_GRAPH
void trg_main_window_add_graph(TrgMainWindow * win, gboolean show)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
priv->graph =
trg_torrent_graph_new(gtk_widget_get_style(priv->notebook));
@@ -2519,7 +2522,7 @@ void trg_main_window_add_graph(TrgMainWindow * win, gboolean show)
void trg_main_window_remove_graph(TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if (priv->graphNotebookIndex >= 0) {
gtk_notebook_remove_page(GTK_NOTEBOOK(priv->notebook),
@@ -2539,7 +2542,7 @@ void trg_main_window_remove_graph(TrgMainWindow * win)
void trg_main_window_add_status_icon(TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
#ifdef HAVE_LIBAPPINDICATOR
if ((priv->appIndicator =
app_indicator_new(PACKAGE_NAME, PACKAGE_NAME,
@@ -2573,7 +2576,7 @@ void trg_main_window_add_status_icon(TrgMainWindow * win)
TrgStateSelector *trg_main_window_get_state_selector(TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
return priv->stateSelector;
}
@@ -2584,7 +2587,7 @@ trg_main_window_config_event(TrgMainWindow * win,
GdkEvent * event,
gpointer user_data G_GNUC_UNUSED)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
priv->width = event->configure.width;
priv->height = event->configure.height;
return FALSE;
@@ -2594,7 +2597,7 @@ static void
trg_client_session_updated_cb(TrgClient * tc,
JsonObject * session, TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
gboolean queuesEnabled;
trg_status_bar_session_update(priv->statusBar, session);
@@ -2654,10 +2657,11 @@ static gboolean window_key_press_handler(GtkWidget * widget,
gpointer user_data)
{
TrgMainWindow *win = TRG_MAIN_WINDOW(widget);
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
if ((event->key.state & GDK_CONTROL_MASK)
&& event->key.keyval == GDK_k) {
- gtk_widget_grab_focus(win->priv->filterEntry);
+ gtk_widget_grab_focus(priv->filterEntry);
return TRUE;
}
@@ -2871,8 +2875,6 @@ static void trg_main_window_class_init(TrgMainWindowClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
- g_type_class_add_private(klass, sizeof(TrgMainWindowPrivate));
-
object_class->constructor = trg_main_window_constructor;
object_class->get_property = trg_main_window_get_property;
object_class->set_property = trg_main_window_set_property;
@@ -2882,15 +2884,9 @@ static void trg_main_window_class_init(TrgMainWindowClass * klass)
g_param_spec_pointer("trg-client",
"TClient",
"Client",
- G_PARAM_READWRITE
- |
- G_PARAM_CONSTRUCT_ONLY
- |
- G_PARAM_STATIC_NAME
- |
- G_PARAM_STATIC_NICK
- |
- G_PARAM_STATIC_BLURB));
+ G_PARAM_READWRITE|
+ G_PARAM_CONSTRUCT_ONLY|
+ G_PARAM_STATIC_STRINGS));
g_object_class_install_property(object_class,
PROP_MINIMISE_ON_START,
@@ -2898,26 +2894,20 @@ static void trg_main_window_class_init(TrgMainWindowClass * klass)
"Min On Start",
"Min On Start",
FALSE,
- G_PARAM_READWRITE
- |
- G_PARAM_CONSTRUCT_ONLY
- |
- G_PARAM_STATIC_NAME
- |
- G_PARAM_STATIC_NICK
- |
- G_PARAM_STATIC_BLURB));
+ G_PARAM_READWRITE|
+ G_PARAM_CONSTRUCT_ONLY|
+ G_PARAM_STATIC_STRINGS));
}
void trg_main_window_set_start_args(TrgMainWindow * win, gchar ** args)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
priv->args = args;
}
void auto_connect_if_required(TrgMainWindow * win)
{
- TrgMainWindowPrivate *priv = win->priv;
+ TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win);
TrgPrefs *prefs = trg_client_get_prefs(priv->client);
gchar *host = trg_prefs_get_string(prefs, TRG_PREFS_KEY_HOSTNAME,
TRG_PREFS_PROFILE);