aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid <dbphillipsnz@gmail.com>2014-04-30 13:07:39 +1200
committerDavid <dbphillipsnz@gmail.com>2014-04-30 13:07:39 +1200
commit4ec5aa223ec7c1e727ea2497936cbab5e3e57463 (patch)
tree842cf6bbac21617a0361fd5cd1a7dec5c039566b
parentb7d55116cc2c6a53891ea0d20686c79a6dd803bd (diff)
downloadparamano-4ec5aa223ec7c1e727ea2497936cbab5e3e57463.tar.xz
General tidy-up
-rw-r--r--bat_tray/bat_tray.h9
-rw-r--r--common.c18
-rw-r--r--common.h14
-rw-r--r--config_file.h8
-rw-r--r--defaults.h4
-rw-r--r--freq_tray/getcore.h4
-rw-r--r--freq_tray/getfreq.c1
-rw-r--r--freq_tray/getfreq.h14
-rw-r--r--freq_tray/getgov.h10
-rw-r--r--tray.h27
-rw-r--r--trayfreq.c7
-rw-r--r--trayfreq_set/trayfreq_set.c2
-rw-r--r--trayfreq_set/trayfreq_set_interface.h4
-rw-r--r--widget_manager.h2
14 files changed, 63 insertions, 61 deletions
diff --git a/bat_tray/bat_tray.h b/bat_tray/bat_tray.h
index c20a833..8992b32 100644
--- a/bat_tray/bat_tray.h
+++ b/bat_tray/bat_tray.h
@@ -17,7 +17,7 @@
************************************************************************/
#ifndef BAT_TRAY_H
-#define BAT_TRAY_H 1
+#define BAT_TRAY_H
#include <glib.h>
@@ -33,8 +33,7 @@
void bat_tray_init();
void bat_tray_show();
void bat_tray_hide();
+int get_battery_state();
+int get_bat_num();
-int get_battery_state();
-int get_bat_num();
-
-#endif /* ifndef BAT_TRAY_H */ \ No newline at end of file
+#endif /* ifndef BAT_TRAY_H */
diff --git a/common.c b/common.c
index ae858a9..d4d2869 100644
--- a/common.c
+++ b/common.c
@@ -18,16 +18,8 @@
#include "common.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#define TRUE true
-#define FALSE false
-
/***********************************************************************
- * Gets integer value from file
+ * Gets integer value from first line in file
**********************************************************************/
int get_int_value_from_file(const char* filename)
{
@@ -47,7 +39,7 @@ int get_int_value_from_file(const char* filename)
/***********************************************************************
- * Return true/false if a file has specified line or not
+ * Return true/false if a file has specified line of text
**********************************************************************/
bool file_has_line(const char *filename, const char *line)
{
@@ -71,14 +63,14 @@ bool file_has_line(const char *filename, const char *line)
/***********************************************************************
- * Fetches first number from a string
+ * Fetches first number (ie the 35 of "35 123") from a
+ * string
**********************************************************************/
int get_int(const char* string)
{
- char numbers[] = "1234567890";
char* first_num;
- first_num = strpbrk(string, numbers);
+ first_num = strpbrk(string, "0123456789");
if(first_num)
return atoi(first_num);
diff --git a/common.h b/common.h
index bf59513..6bb7a40 100644
--- a/common.h
+++ b/common.h
@@ -17,12 +17,16 @@
************************************************************************/
#ifndef COMMON_H
-#define COMMON_H 1
+#define COMMON_H
-#include <stdbool.h>
+#include "bool.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
-int get_int_value_from_file(const char* filename);
+
+int get_int_value_from_file(const char* filename);
+int get_int(const char* string);
bool file_has_line(const char *filename, const char *line);
-int get_int(const char* string);
-#endif \ No newline at end of file
+#endif
diff --git a/config_file.h b/config_file.h
index cb491d4..d8e150b 100644
--- a/config_file.h
+++ b/config_file.h
@@ -17,7 +17,7 @@
************************************************************************/
#ifndef CONFIG_FILE_H
-#define CONFIG_FILE_H 1
+#define CONFIG_FILE_H
#include <glib.h>
@@ -28,7 +28,7 @@ struct config_file
};
gboolean config_open(struct config_file* config_file);
-void config_close(struct config_file* config_file);
-gchar* config_get_key(struct config_file* config_file, const gchar* group_name, const gchar* key_name);
+void config_close(struct config_file* config_file);
+gchar* config_get_key(struct config_file* config_file, const gchar* group_name, const gchar* key_name);
-#endif /* ifndef CONFIG_FILE_H */ \ No newline at end of file
+#endif /* ifndef CONFIG_FILE_H */
diff --git a/defaults.h b/defaults.h
index c959cbb..b92859c 100644
--- a/defaults.h
+++ b/defaults.h
@@ -17,7 +17,7 @@
************************************************************************/
#ifndef DEFAULTS_H
-#define DEFAULTS_H 1
+#define DEFAULTS_H
#include <glib.h>
@@ -27,4 +27,4 @@ char* _DEFAULT_PROG;
char* _DEFAULT_BAT_GOV;
char* _DEFAULT_AC_GOV;
-#endif /* ifndef DEFAULTS_H */ \ No newline at end of file
+#endif /* ifndef DEFAULTS_H */
diff --git a/freq_tray/getcore.h b/freq_tray/getcore.h
index 541d789..fc1fc8d 100644
--- a/freq_tray/getcore.h
+++ b/freq_tray/getcore.h
@@ -17,9 +17,9 @@
************************************************************************/
#ifndef GETCORE_H
-#define GETCORE_H 1
+#define GETCORE_H
void gc_init();
-int gc_number();
+int gc_number();
#endif
diff --git a/freq_tray/getfreq.c b/freq_tray/getfreq.c
index 7ac2181..02970b4 100644
--- a/freq_tray/getfreq.c
+++ b/freq_tray/getfreq.c
@@ -16,7 +16,6 @@
* <http://www.gnu.org/licenses/>. *
************************************************************************/
-#include "string.h"
#include "getfreq.h"
#include "getcore.h"
#include "math.h"
diff --git a/freq_tray/getfreq.h b/freq_tray/getfreq.h
index a1cbd92..8df9eca 100644
--- a/freq_tray/getfreq.h
+++ b/freq_tray/getfreq.h
@@ -17,15 +17,15 @@
************************************************************************/
#ifndef GETFREQ_H
-#define GETFREQ_H 1
+#define GETFREQ_H
-void gf_init();
-int gf_current(int core);
-int gf_available(int core, char* out, int size);
-void gf_get_frequency_label(int freq, char* out);
+void gf_init();
+int gf_current(int core);
+int gf_available(int core, char* out, int size);
+void gf_get_frequency_label(int freq, char* out);
char* gf_freqa(int core, int index);
-int gf_freqi(int core, int index);
-int gf_number();
+int gf_freqi(int core, int index);
+int gf_number();
#endif
diff --git a/freq_tray/getgov.h b/freq_tray/getgov.h
index b4fdc29..fca341d 100644
--- a/freq_tray/getgov.h
+++ b/freq_tray/getgov.h
@@ -17,12 +17,12 @@
************************************************************************/
#ifndef GETGOV_H
-#define GETGOV_H 1
+#define GETGOV_H
-void gg_init();
-int gg_current(int core, char* out, int size);
-int gg_available(int core, char* out, int size);
+void gg_init();
+int gg_current(int core, char* out, int size);
+int gg_available(int core, char* out, int size);
char* gg_gov(int core, int index);
-int gg_number();
+int gg_number();
#endif
diff --git a/tray.h b/tray.h
index afad163..223ac26 100644
--- a/tray.h
+++ b/tray.h
@@ -17,15 +17,30 @@
************************************************************************/
#ifndef TRAY_H
-#define TRAY_H 1
+#define TRAY_H
#include <glib.h>
-void tray_init();
-void tray_set_tooltip(const gchar* msg);
-void tray_update_icon_percent();
-void tray_show();
-void tray_hide();
+#include "widget_manager.h"
+#include "freq_tray/getfreq.h"
+#include "freq_tray/getcore.h"
+#include "freq_tray/getgov.h"
+#include "trayfreq_set/trayfreq_set_interface.h"
+#include "bat_tray/bat_tray.h"
+#include "defaults.h"
+
+#include <gtk/gtk.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <libintl.h>
+
+
+void tray_init();
+void tray_set_tooltip(const gchar* msg);
+void tray_update_icon_percent();
+void tray_show();
+void tray_hide();
gboolean tray_visible();
gboolean tray_embedded();
diff --git a/trayfreq.c b/trayfreq.c
index 4b15360..e7c8933 100644
--- a/trayfreq.c
+++ b/trayfreq.c
@@ -16,8 +16,6 @@
* <http://www.gnu.org/licenses/>. *
************************************************************************/
-#include "strings.h"
-
#include "widget_manager.h"
#include "tray.h"
#include "bat_tray/bat_tray.h"
@@ -68,16 +66,12 @@ void config_init()
return;
}
- gchar * def_prog = config_get_key(&config, "events", "activate");
gchar * def_gov = config_get_key(&config, "governor", "default");
gchar * def_freq = config_get_key(&config, "frequency", "default");
gchar * show_bat = config_get_key(&config, "battery", "show");
gchar * bat_gov = config_get_key (&config, "battery", "governor");
gchar * ac_gov = config_get_key (&config, "ac", "governor");
- if(def_prog)
- _DEFAULT_PROG = def_prog;
-
if(def_gov)
_DEFAULT_GOV = def_gov;
@@ -112,7 +106,6 @@ int main(int argc, char** argv)
g_error(_("GTK Error: gtk_init_check returned FALSE.\nBailing.") );
return 1;
}
-
config_init();
gc_init();
gg_init();
diff --git a/trayfreq_set/trayfreq_set.c b/trayfreq_set/trayfreq_set.c
index a9de8c1..cd0cd4e 100644
--- a/trayfreq_set/trayfreq_set.c
+++ b/trayfreq_set/trayfreq_set.c
@@ -31,7 +31,7 @@ char file_path[100];
void prepare_path(const char* file, const char* core)
{
- // Sanatise core to make sure there's not monkey business going on -- it's only an integer
+ // Sanatise core to make sure there's not monkey business going on
int core_i = atoi(core);
sprintf(file_path, "/sys/devices/system/cpu/cpu%d/cpufreq/%s", core_i, file);
diff --git a/trayfreq_set/trayfreq_set_interface.h b/trayfreq_set/trayfreq_set_interface.h
index 3f1cdbc..bdbf652 100644
--- a/trayfreq_set/trayfreq_set_interface.h
+++ b/trayfreq_set/trayfreq_set_interface.h
@@ -17,9 +17,9 @@
************************************************************************/
#ifndef TRAYFREQ_SET_INTERFACE_H
-#define TRAYFREQ_SET_INTERFACE_H 1
+#define TRAYFREQ_SET_INTERFACE_H
void si_gov(char* gov, int core);
void si_freq(int freq, int core);
-#endif \ No newline at end of file
+#endif
diff --git a/widget_manager.h b/widget_manager.h
index 264c79d..d6c2d10 100644
--- a/widget_manager.h
+++ b/widget_manager.h
@@ -17,7 +17,7 @@
************************************************************************/
#ifndef WIDGET_MANAGER_H
-#define WIDGET_MANAGER_H 1
+#define WIDGET_MANAGER_H
#include <gtk/gtk.h>
#include <glib.h>