projects
/
psensor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixed style
[psensor.git]
/
src
/
ui_status.c
diff --git
a/src/ui_status.c
b/src/ui_status.c
index
618b7ee
..
bb46c2b
100644
(file)
--- a/
src/ui_status.c
+++ b/
src/ui_status.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (C) 2010-201
1
jeanfi@gmail.com
+ * Copyright (C) 2010-201
4
jeanfi@gmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@
-16,17
+16,19
@@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
-#include
"log.h"
+#include
<plog.h>
#include "ui_status.h"
#include "ui_status.h"
+static const char *ICON = "psensor_normal";
+static const char *ATTENTION_ICON = "psensor_hot";
+
static GtkStatusIcon *status;
static GtkStatusIcon *status;
-static unsigned status_attention;
+static unsigned
int
status_attention;
static void cb_activate(GtkStatusIcon *icon,
gpointer data)
{
log_debug("cb_activate()");
static void cb_activate(GtkStatusIcon *icon,
gpointer data)
{
log_debug("cb_activate()");
-
ui_window_show((struct ui_psensor *)data);
}
ui_window_show((struct ui_psensor *)data);
}
@@
-41,13
+43,13
@@
static void cb_popup_menu(GtkStatusIcon *icon,
void ui_status_init(struct ui_psensor *ui)
{
if (status)
void ui_status_init(struct ui_psensor *ui)
{
if (status)
- return
;
+ return;
log_debug("ui_status_create()");
status = gtk_status_icon_new();
log_debug("ui_status_create()");
status = gtk_status_icon_new();
- gtk_status_icon_set_from_icon_name(status,
"psensor_normal"
);
-
gtk_status_icon_set_visible(status, TRUE
);
+ gtk_status_icon_set_from_icon_name(status,
ICON
);
+
ui_status_set_visible(0
);
g_signal_connect(G_OBJECT(status),
"popup-menu",
g_signal_connect(G_OBJECT(status),
"popup-menu",
@@
-60,15
+62,15
@@
void ui_status_init(struct ui_psensor *ui)
ui);
}
ui);
}
-int is_status_supported()
+int is_status_supported(
void
)
{
return status && gtk_status_icon_is_embedded(status);
}
{
return status && gtk_status_icon_is_embedded(status);
}
-void ui_status_cleanup()
+void ui_status_cleanup(
void
)
{
log_debug("ui_status_cleanup()");
{
log_debug("ui_status_cleanup()");
-
+
if (status) {
g_object_unref(G_OBJECT(status));
status = NULL;
if (status) {
g_object_unref(G_OBJECT(status));
status = NULL;
@@
-80,9
+82,9
@@
void ui_status_update(struct ui_psensor *ui, unsigned int attention)
log_debug("ui_status_update()");
if (status_attention && !attention)
log_debug("ui_status_update()");
if (status_attention && !attention)
- gtk_status_icon_set_from_icon_name(status,
"psensor_normal"
);
+ gtk_status_icon_set_from_icon_name(status,
ICON
);
else if (!status_attention && attention)
else if (!status_attention && attention)
- gtk_status_icon_set_from_icon_name(status,
"psensor_hot"
);
+ gtk_status_icon_set_from_icon_name(status,
ATTENTION_ICON
);
status_attention = attention;
}
status_attention = attention;
}
@@
-94,3
+96,15
@@
GtkStatusIcon *ui_status_get_icon(struct ui_psensor *ui)
return status;
}
return status;
}
+
+void ui_status_set_visible(unsigned int visible)
+{
+ log_debug("ui_status_set_visible(%d)", visible);
+
+ if (status) {
+ if (visible)
+ gtk_status_icon_set_visible(status, TRUE);
+ else
+ gtk_status_icon_set_visible(status, FALSE);
+ }
+}