diff options
author | Alan Fitton <ajf@eth0.org.uk> | 2011-09-08 13:35:17 +0000 |
---|---|---|
committer | Alan Fitton <ajf@eth0.org.uk> | 2011-09-08 13:35:17 +0000 |
commit | 8828a8bcd4ca9d1c53038af0e5d6138920c42b6b (patch) | |
tree | dd1e11331902c721f52d4e0d819a46c409b9c8be /src | |
parent | 9d4f57555411c56b3fa8daf5b072eeca82b7a666 (diff) |
issue 42 - start in tray argument. fix state selector persisting of selection (was out by 1).
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 13 | ||||
-rw-r--r-- | src/trg-main-window.c | 28 | ||||
-rw-r--r-- | src/trg-main-window.h | 2 | ||||
-rw-r--r-- | src/trg-state-selector.c | 4 |
4 files changed, 40 insertions, 7 deletions
@@ -79,6 +79,16 @@ message_received_cb(UniqueApp * app G_GNUC_UNUSED, } #endif +static gboolean should_be_minimised(int argc, char *argv[]) +{ + int i; + for(i = 1; i < argc; i++) + if (!g_strcmp0(argv[i], "-m") || !g_strcmp0(argv[i], "--minimised")) + return TRUE; + + return FALSE; +} + int main(int argc, char *argv[]) { int returnValue = EXIT_SUCCESS; @@ -139,7 +149,8 @@ int main(int argc, char *argv[]) curl_global_init(CURL_GLOBAL_ALL); - window = trg_main_window_new(client); + + window = trg_main_window_new(client, should_be_minimised(argc, argv)); #ifdef HAVE_LIBUNIQUE if (withUnique) { diff --git a/src/trg-main-window.c b/src/trg-main-window.c index d752347..1fef6bb 100644 --- a/src/trg-main-window.c +++ b/src/trg-main-window.c @@ -208,10 +208,11 @@ struct _TrgMainWindowPrivate { GtkWidget *filterEntry, *filterEntryClearButton; gint width, height; + gboolean min_on_start; }; enum { - PROP_0, PROP_CLIENT + PROP_0, PROP_CLIENT, PROP_MINIMISE_ON_START }; static void trg_main_window_init(TrgMainWindow * self G_GNUC_UNUSED) { @@ -1112,6 +1113,9 @@ static void trg_main_window_get_property(GObject * object, guint property_id, case PROP_CLIENT: g_value_set_pointer(value, priv->client); break; + case PROP_MINIMISE_ON_START: + g_value_set_boolean(value, priv->min_on_start); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); } @@ -1124,6 +1128,9 @@ static void trg_main_window_set_property(GObject * object, guint property_id, case PROP_CLIENT: priv->client = g_value_get_pointer(value); break; + case PROP_MINIMISE_ON_START: + priv->min_on_start = g_value_get_boolean(value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); } @@ -1744,6 +1751,9 @@ static GObject *trg_main_window_constructor(GType type, trg_widget_set_visible(priv->notebook, trg_prefs_get_bool(prefs, TRG_PREFS_KEY_SHOW_NOTEBOOK, TRG_PREFS_GLOBAL)); + if (tray && priv->min_on_start) + gtk_widget_hide(GTK_WIDGET(self)); + return G_OBJECT(self); } @@ -1766,6 +1776,18 @@ static void trg_main_window_class_init(TrgMainWindowClass * klass) { G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); + + g_object_class_install_property( + object_class, + PROP_MINIMISE_ON_START, + g_param_spec_boolean( + "min-on-start", + "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)); } void auto_connect_if_required(TrgMainWindow * win, TrgClient * tc) { @@ -1782,6 +1804,6 @@ void auto_connect_if_required(TrgMainWindow * win, TrgClient * tc) { } } -TrgMainWindow *trg_main_window_new(TrgClient * tc) { - return g_object_new(TRG_TYPE_MAIN_WINDOW, "trg-client", tc, NULL); +TrgMainWindow *trg_main_window_new(TrgClient * tc, gboolean minonstart) { + return g_object_new(TRG_TYPE_MAIN_WINDOW, "trg-client", tc, "min-on-start", minonstart, NULL); } diff --git a/src/trg-main-window.h b/src/trg-main-window.h index 89eb12a..ed28f04 100644 --- a/src/trg-main-window.h +++ b/src/trg-main-window.h @@ -62,7 +62,7 @@ void on_session_set(JsonObject * response, int status, gpointer data); void on_generic_interactive_action(JsonObject * response, int status, gpointer data); void auto_connect_if_required(TrgMainWindow * win, TrgClient * tc); -TrgMainWindow *trg_main_window_new(TrgClient * tc); +TrgMainWindow *trg_main_window_new(TrgClient * tc, gboolean minonstart); 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); diff --git a/src/trg-state-selector.c b/src/trg-state-selector.c index 8b324f1..eefb8db 100644 --- a/src/trg-state-selector.c +++ b/src/trg-state-selector.c @@ -72,7 +72,7 @@ static void state_selection_changed(GtkTreeSelection * selection, gpointer data) GtkTreeIter iter; GtkTreeView *tv; GtkTreeModel *stateModel; - guint index; + guint index = 0; priv = TRG_STATE_SELECTOR_GET_PRIVATE(data); @@ -367,7 +367,7 @@ static void trg_state_selector_add_state(GtkListStore * model, gtk_list_store_set(model, iter, STATE_SELECTOR_ICON, icon, STATE_SELECTOR_NAME, name, STATE_SELECTOR_BIT, flag, STATE_SELECTOR_INDEX, - gtk_tree_model_iter_n_children(GTK_TREE_MODEL(model), NULL), -1); + gtk_tree_model_iter_n_children(GTK_TREE_MODEL(model), NULL)-1, -1); } static void remove_row_ref_and_free(GtkTreeRowReference * rr) { |