From 85c2ac4475d8e9815c96b09299f1b03ae8071da3 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Mon, 25 Apr 2011 11:43:56 +0000 Subject: [PATCH] added support of enable/disable unity launcher count src/cfg.c config_get_string renamed to static get_string --- NEWS | 1 + src/cfg.c | 18 ++++++++++++++---- src/cfg.h | 2 ++ src/main.c | 3 ++- src/ui_pref.c | 11 ++++++++++- src/unity/ui_unity.c | 16 ++++++++++++++-- src/unity/ui_unity.h | 3 ++- 7 files changed, 45 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 3465c34..3c65747 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ ** added missing french translation ** added different sizes of psensor.png ** psensor: added menu +** psensor: added enable/disable unity launcher counter * v0.6.2.7 diff --git a/src/cfg.c b/src/cfg.c index 2baadf5..6f3ed3c 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -55,10 +55,12 @@ #define KEY_INTERFACE_MENU_BAR_DISABLED \ "/apps/psensor/interface/menu_bar_disabled" +#define KEY_INTERFACE_UNITY_LAUNCHER_COUNT_DISABLED \ +"/apps/psensor/interface/unity_launcher_count_disabled" GConfClient *client; -char *config_get_string(char *key, char *default_value) +static char *get_string(char *key, char *default_value) { char *value = gconf_client_get_string(client, key, @@ -76,7 +78,7 @@ char *config_get_string(char *key, char *default_value) struct color *config_get_background_color() { - char *scolor = config_get_string(KEY_GRAPH_BACKGROUND_COLOR, + char *scolor = get_string(KEY_GRAPH_BACKGROUND_COLOR, DEFAULT_GRAPH_BACKGROUND_COLOR); struct color *c = string_to_color(scolor); @@ -91,8 +93,8 @@ struct color *config_get_background_color() struct color *config_get_foreground_color() { - char *scolor = config_get_string(KEY_GRAPH_FOREGROUND_COLOR, - DEFAULT_GRAPH_FOREGROUND_COLOR); + char *scolor = get_string(KEY_GRAPH_FOREGROUND_COLOR, + DEFAULT_GRAPH_FOREGROUND_COLOR); struct color *c = string_to_color(scolor); @@ -438,6 +440,11 @@ struct config *config_load() KEY_INTERFACE_MENU_BAR_DISABLED, NULL); + cfg->unity_launcher_count_disabled = gconf_client_get_bool + (client, + KEY_INTERFACE_UNITY_LAUNCHER_COUNT_DISABLED, + NULL); + return cfg; } @@ -466,4 +473,7 @@ void config_save(struct config *cfg) KEY_INTERFACE_MENU_BAR_DISABLED, cfg->menu_bar_disabled, NULL); + gconf_client_set_bool(client, + KEY_INTERFACE_UNITY_LAUNCHER_COUNT_DISABLED, + cfg->unity_launcher_count_disabled, NULL); } diff --git a/src/cfg.h b/src/cfg.h index 00331d9..b61a469 100644 --- a/src/cfg.h +++ b/src/cfg.h @@ -51,6 +51,8 @@ struct config { int sensor_update_interval; int menu_bar_disabled; + + int unity_launcher_count_disabled; }; /* diff --git a/src/main.c b/src/main.c index 6afbfa2..3ebac43 100644 --- a/src/main.c +++ b/src/main.c @@ -175,7 +175,8 @@ gboolean ui_refresh_thread(gpointer data) #endif #ifdef HAVE_UNITY - ui_unity_launcher_entry_update(ui->sensors); + ui_unity_launcher_entry_update(ui->sensors, + !cfg->unity_launcher_count_disabled); #endif if (ui->graph_update_interval != cfg->graph_update_interval) { diff --git a/src/ui_pref.c b/src/ui_pref.c index 32cc35f..1f480b8 100644 --- a/src/ui_pref.c +++ b/src/ui_pref.c @@ -52,7 +52,7 @@ void ui_pref_dialog_run(struct ui_psensor *ui) *w_s_update_interval; GtkComboBox *w_sensorlist_pos; GtkToggleButton *w_hide_window_decoration, *w_keep_window_below, - *w_enable_menu; + *w_enable_menu, *w_enable_launcher_counter; cfg = ui->config; @@ -125,6 +125,11 @@ void ui_pref_dialog_run(struct ui_psensor *ui) gtk_toggle_button_set_active(w_enable_menu, !cfg->menu_bar_disabled); + w_enable_launcher_counter = GTK_TOGGLE_BUTTON + (gtk_builder_get_object(builder, + "enable_launcher_counter")); + gtk_toggle_button_set_active(w_enable_launcher_counter, + !cfg->unity_launcher_count_disabled); result = gtk_dialog_run(diag); @@ -162,6 +167,10 @@ void ui_pref_dialog_run(struct ui_psensor *ui) cfg->menu_bar_disabled = !gtk_toggle_button_get_active(w_enable_menu); + cfg->unity_launcher_count_disabled + = !gtk_toggle_button_get_active + (w_enable_launcher_counter); + gtk_window_set_decorated(GTK_WINDOW(ui->main_window), cfg->window_decoration_enabled); diff --git a/src/unity/ui_unity.c b/src/unity/ui_unity.c index 8b790f5..cb62458 100644 --- a/src/unity/ui_unity.c +++ b/src/unity/ui_unity.c @@ -23,17 +23,29 @@ static int initialized; static UnityLauncherEntry *psensor_entry; +static unsigned int last_visible = -1; -void ui_unity_launcher_entry_update(struct psensor **sensors) +void ui_unity_launcher_entry_update(struct psensor **sensors, + unsigned int show) { if (!initialized) { psensor_entry = unity_launcher_entry_get_for_desktop_file ("psensor.desktop"); - unity_launcher_entry_set_count_visible(psensor_entry, TRUE); + unity_launcher_entry_set_count(psensor_entry, 0); initialized = 1; } + if (last_visible != show) { + if (show) + unity_launcher_entry_set_count_visible(psensor_entry, + TRUE); + else + unity_launcher_entry_set_count_visible(psensor_entry, + FALSE); + last_visible = show; + } + if (sensors && *sensors) { struct psensor *s = *sensors; double v = psensor_get_current_value(s); diff --git a/src/unity/ui_unity.h b/src/unity/ui_unity.h index be55b3b..9ec3ddf 100644 --- a/src/unity/ui_unity.h +++ b/src/unity/ui_unity.h @@ -22,6 +22,7 @@ #include "psensor.h" -void ui_unity_launcher_entry_update(struct psensor **sensors); +void ui_unity_launcher_entry_update(struct psensor **sensors, + unsigned int show); #endif -- 2.7.4