aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid <dbphillipsnz@gmail.com>2014-09-28 16:29:05 +1300
committerDavid <dbphillipsnz@gmail.com>2014-09-28 16:29:05 +1300
commit0981cf1a76826538b8b75f6e17ac9b5c8117cc0e (patch)
treec192e03d3011b41ae7db5d31061828eb70f8a0dc
parent21173638ed71c27cb3b92f45acfad62e7874a356 (diff)
downloadparamano-0981cf1a76826538b8b75f6e17ac9b5c8117cc0e.tar.xz
Fixy fixy
-rw-r--r--bat_tray.c2
-rw-r--r--getfreq.c2
-rw-r--r--tray.c92
-rw-r--r--tray.h2
4 files changed, 43 insertions, 55 deletions
diff --git a/bat_tray.c b/bat_tray.c
index aacbccb..06737e1 100644
--- a/bat_tray.c
+++ b/bat_tray.c
@@ -74,7 +74,7 @@ static gboolean update_tooltip(GtkStatusIcon* status_icon,gint x,gint y,gboolean
/***********************************************************************
* Updates the battery tray icon based upon battery percent
**********************************************************************/
-gboolean update_icon(gpointer user_data)
+static gboolean update_icon(gpointer user_data)
{
char *icon_file;
unsigned int rounded;
diff --git a/getfreq.c b/getfreq.c
index ac989fd..f5f9652 100644
--- a/getfreq.c
+++ b/getfreq.c
@@ -77,7 +77,7 @@ void gf_init()
int gf_current(int core)
{
FILE* fd;
- char buff[13]; // TO DO : magic constant
+ char buff[4096];
char* path;
int freq;
diff --git a/tray.c b/tray.c
index 9b8bdfe..52883c6 100644
--- a/tray.c
+++ b/tray.c
@@ -58,18 +58,6 @@ static void gov_menu_item_toggled(GtkCheckMenuItem* item, gpointer data)
si_gov(gov, i);
}
}
-/*
-static gboolean governor_exists(gchar* governor)
-{
- int i = 0;
- for(i = 0; i < gf_number(); ++i)
- {
- if(g_strcmp0(governor, gg_gov(0, i)) == 0)
- return TRUE;
- }
- return FALSE;
-}*/
-
/***********************************************************************
* Destroy a menu item
@@ -220,6 +208,46 @@ static void popup_menu(GtkStatusIcon* statuc_icon,guint button,guint activate_ti
}
+/**********************************************************************
+ * Set icon based on current freq/governor
+ **********************************************************************/
+static void tray_update_icon_percent()
+{
+ char* file;
+ int max_frequency = gf_freqi(0, 0);
+ int adjusted_percent, percent;
+
+ // If max_frequency is 0, we don't want to divide by it,
+ // so give up, call it a day, and have a simple icon
+ if (max_frequency == 0)
+ {
+ adjusted_percent = 0;
+ } else {
+ // Percentages need to be {25,50,75,100}. Round to one of these numbers.
+ // TO DO: round instead of lots of ifs
+ percent = (gf_current(0) * 100)/max_frequency;
+ if(percent == 100) {
+ adjusted_percent = 100;
+ } else if(percent >= 65.5) {
+ adjusted_percent = 75;
+ } else if(percent >= 37.5) {
+ adjusted_percent = 50;
+ } else if(percent >= 12.5) {
+ adjusted_percent = 25;
+ } else {
+ adjusted_percent = 0;
+ }
+ }
+
+ debug("Rounded/adjusted CPU percentage: %d\n",adjusted_percent);
+ asprintf(&file, "%s/cpu-%d.png", DEFAULT_THEME,adjusted_percent);
+ debug("Setting tray icon to '%s'\n",file);
+ gtk_status_icon_set_from_file(tray, file);
+
+ free(file);
+}
+
+
/***********************************************************************
* Update the freq/gov tray icon
**********************************************************************/
@@ -303,46 +331,6 @@ void tray_init()
tray_init_menu();
}
-/**********************************************************************
- * Set icon based on current freq/governor
- **********************************************************************/
-void tray_update_icon_percent()
-{
- char* file;
- gulong max_frequency = gf_freqi(0, 0);
- gint adjusted_percent = 0;
-
- // If max_frequency is 0, we don't want to divide by it,
- // so give up, call it a day, and have a simple icon
- if (max_frequency == 0)
- {
- adjusted_percent = 0;
- } else {
- // Percentages need to be {25,50,75,100}. Round to one of these numbers.
- // TO DO: round instead of lots of ifs
- gint percent = (gf_current(0) * 100)/max_frequency;
- if(percent == 100) {
- adjusted_percent = 100;
- } else if(percent >= 65.5) {
- adjusted_percent = 75;
- } else if(percent >= 37.5) {
- adjusted_percent = 50;
- } else if(percent >= 12.5) {
- adjusted_percent = 25;
- } else {
- adjusted_percent = 0;
- }
- }
-
- debug("Rounded/adjusted CPU percentage: %d\n",adjusted_percent);
- asprintf(&file, "%s/cpu-%d.png", DEFAULT_THEME,adjusted_percent);
- debug("Setting tray icon to '%s'\n",file);
- gtk_status_icon_set_from_file(tray, file);
-
-
- free(file);
-}
-
/***********************************************************************
* Show the tray
diff --git a/tray.h b/tray.h
index 87e377d..c1df8a6 100644
--- a/tray.h
+++ b/tray.h
@@ -22,7 +22,7 @@
void tray_set_defaults();
void tray_init();
void tray_set_tooltip(const char* msg);
-void tray_update_icon_percent();
+//void tray_update_icon_percent();
void tray_show();
void tray_hide();
bool tray_visible();