2 Copyright (C) 2010-2011 wpitchoune@gmail.com
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 #include <libappindicator/app-indicator.h>
29 #include "ui_appindicator.h"
32 static void cb_appindicator_show(gpointer data,
36 struct ui_psensor *ui = (struct ui_psensor *)data;
38 gtk_window_present(GTK_WINDOW(ui->main_window));
41 static void cb_appindicator_quit(gpointer data,
45 ui_psensor_exit(data);
48 static void cb_appindicator_preferences(gpointer data,
52 #ifdef HAVE_APPINDICATOR_029
56 ui_pref_dialog_run((struct ui_psensor *)data);
58 #ifdef HAVE_APPINDICATOR_029
63 static GtkItemFactoryEntry menu_items[] = {
65 NULL, cb_appindicator_show, 0, "<Item>"},
67 NULL, cb_appindicator_preferences, 0, "<Item>"},
69 NULL, NULL, 0, "<Separator>"},
71 "", cb_appindicator_quit, 0, "<StockItem>", GTK_STOCK_QUIT},
74 static gint nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
75 GtkWidget *ui_appindicator_get_menu(struct ui_psensor *ui)
77 GtkItemFactory *item_factory;
79 item_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
81 gtk_item_factory_create_items(item_factory,
82 nmenu_items, menu_items, ui);
83 return gtk_item_factory_get_widget(item_factory, "<main>");
86 void ui_appindicator_update(struct ui_psensor *ui)
88 struct psensor **sensor_cur = ui->sensors;
89 AppIndicatorStatus status;
96 struct psensor *s = *sensor_cur;
98 if (s->alarm_enabled && s->alarm_raised) {
106 status = app_indicator_get_status(ui->indicator);
108 if (!attention && status == APP_INDICATOR_STATUS_ATTENTION)
109 app_indicator_set_status
110 (ui->indicator, APP_INDICATOR_STATUS_ACTIVE);
112 if (attention && status == APP_INDICATOR_STATUS_ACTIVE)
113 app_indicator_set_status
114 (ui->indicator, APP_INDICATOR_STATUS_ATTENTION);
117 void ui_appindicator_init(struct ui_psensor *ui)
119 GtkWidget *indicatormenu;
122 = app_indicator_new("psensor",
124 APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
126 app_indicator_set_status(ui->indicator, APP_INDICATOR_STATUS_ACTIVE);
127 app_indicator_set_attention_icon(ui->indicator, "psensor_hot");
129 indicatormenu = ui_appindicator_get_menu(ui);
130 app_indicator_set_menu(ui->indicator, GTK_MENU(indicatormenu));