summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--battstat/Makefile.am6
-rw-r--r--battstat/acpi-linux.c206
-rw-r--r--geyes/Makefile.am2
-rw-r--r--geyes/themes.c102
-rw-r--r--mixer/Makefile.am6
-rw-r--r--multiload/Makefile.am4
-rw-r--r--stickynotes/stickynotes.c6
-rw-r--r--stickynotes/stickynotes_applet.h8
8 files changed, 177 insertions, 163 deletions
diff --git a/battstat/Makefile.am b/battstat/Makefile.am
index 9a121cdd..093db421 100644
--- a/battstat/Makefile.am
+++ b/battstat/Makefile.am
@@ -51,9 +51,9 @@ battstat_applet_2_SOURCES = \
battstat_applet_2_LDADD = \
- $(MATE_APPLETS3_LIBS) \
- $(LIBMATENOTIFY_LIBS) \
- $(HAL_LIBS) \
+ $(MATE_APPLETS3_LIBS) \
+ $(LIBMATENOTIFY_LIBS) \
+ $(HAL_LIBS) \
$(APMLIB) \
-lm
diff --git a/battstat/acpi-linux.c b/battstat/acpi-linux.c
index d982f6cc..0e1ba94e 100644
--- a/battstat/acpi-linux.c
+++ b/battstat/acpi-linux.c
@@ -1,4 +1,4 @@
-/* battstat A MATE battery meter for laptops.
+/* battstat A MATE battery meter for laptops.
* Copyright (C) 2000 by J�rgen Pehrson <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
@@ -24,7 +24,7 @@
*/
#ifdef HAVE_CONFIG_H
-#include <config.h>
+ #include <config.h>
#endif
#ifdef __linux__
@@ -44,54 +44,65 @@
#include <dirent.h>
#include "acpi-linux.h"
-static GHashTable *
-read_file (const char *file, char *buf, size_t bufsize)
+static GHashTable* read_file(const char* file, char* buf, size_t bufsize)
{
- GHashTable *hash = NULL;
-
- int fd, len, i;
- char *key, *value;
- gboolean reading_key;
-
- fd = open (file, O_RDONLY);
-
- if (fd == -1) {
- return hash;
- }
-
- len = read (fd, buf, bufsize);
-
- close (fd);
-
- if (len < 0) {
- if (getenv ("BATTSTAT_DEBUG"))
- g_message ("Error reading %s: %s", file, g_strerror (errno));
- return hash;
- }
-
- hash = g_hash_table_new (g_str_hash, g_str_equal);
-
- for (i = 0, value = key = buf, reading_key = TRUE; i < len; i++) {
- if (buf[i] == ':' && reading_key) {
- reading_key = FALSE;
- buf[i] = '\0';
- value = buf + i + 1;
- } else if (buf[i] == '\n') {
- reading_key = TRUE;
- buf[i] = '\0';
- /* g_message ("Read: %s => %s\n", key, value); */
- g_hash_table_insert (hash, key, g_strstrip (value));
- key = buf + i + 1;
- } else if (reading_key) {
- /* in acpi 20020214 it switched to lower-case proc
- * entries. fixing this up here simplifies the
- * code.
- */
- buf[i] = g_ascii_tolower (buf[i]);
- }
- }
-
- return hash;
+ GHashTable* hash = NULL;
+
+ int fd, len, i;
+ char* key;
+ char* value;
+ gboolean reading_key;
+
+ fd = open(file, O_RDONLY);
+
+ if (fd == -1)
+ {
+ return hash;
+ }
+
+ len = read(fd, buf, bufsize);
+
+ close (fd);
+
+ if (len < 0)
+ {
+ if (getenv("BATTSTAT_DEBUG"))
+ {
+ g_message("Error reading %s: %s", file, g_strerror(errno));
+ }
+
+ return hash;
+ }
+
+ hash = g_hash_table_new(g_str_hash, g_str_equal);
+
+ for (i = 0, value = key = buf, reading_key = TRUE; i < len; i++)
+ {
+ if (buf[i] == ':' && reading_key)
+ {
+ reading_key = FALSE;
+ buf[i] = '\0';
+ value = buf + i + 1;
+ }
+ else if (buf[i] == '\n')
+ {
+ reading_key = TRUE;
+ buf[i] = '\0';
+ /* g_message ("Read: %s => %s\n", key, value); */
+ g_hash_table_insert(hash, key, g_strstrip(value));
+ key = buf + i + 1;
+ }
+ else if (reading_key)
+ {
+ /* in acpi 20020214 it switched to lower-case proc
+ * entries. fixing this up here simplifies the
+ * code.
+ */
+ buf[i] = g_ascii_tolower(buf[i]);
+ }
+ }
+
+ return hash;
}
#if 0
@@ -111,13 +122,13 @@ read_bool (GHashTable *hash, const char *key)
static long
read_long (GHashTable *hash, const char *key)
{
- char *s;
+ char* s;
- g_return_val_if_fail (hash, 0);
- g_return_val_if_fail (key, 0);
+ g_return_val_if_fail(hash, 0);
+ g_return_val_if_fail(key, 0);
- s = g_hash_table_lookup (hash, key);
- return s ? strtol (s, NULL, 10) : 0;
+ s = g_hash_table_lookup(hash, key);
+ return s ? strtol(s, NULL, 10) : 0;
}
static gulong
@@ -190,44 +201,47 @@ static gboolean update_ac_info(struct acpi_info * acpiinfo)
/* Reads the ACPI info for the system batteries, and finds
* the total capacity, which is stored in acpiinfo. */
-static gboolean update_battery_info(struct acpi_info * acpiinfo)
+static gboolean update_battery_info(struct acpi_info* acpiinfo)
{
- gchar* batt_info = NULL;
- GHashTable *hash;
- DIR * procdir;
- struct dirent * procdirentry;
- char buf[BUFSIZ];
-
- acpiinfo->max_capacity = 0;
- acpiinfo->low_capacity = 0;
- acpiinfo->critical_capacity = 0;
-
- procdir=opendir("/proc/acpi/battery/");
- if (!procdir)
- return FALSE;
-
- while ((procdirentry=readdir(procdir)))
- {
- if (procdirentry->d_name[0]!='.')
- {
- batt_info = g_strconcat("/proc/acpi/battery/",
- procdirentry->d_name,
- "/info",
- NULL);
- hash = read_file (batt_info, buf, sizeof (buf));
- if (hash)
- {
- acpiinfo->max_capacity += read_long (hash, "last full capacity");
- acpiinfo->low_capacity += read_long (hash, "design capacity warning");
- acpiinfo->critical_capacity += read_long (hash, "design capacity low");
- g_hash_table_destroy (hash);
- }
- g_free(batt_info);
- }
- }
- closedir(procdir);
-
- return TRUE;
+ gchar* batt_info = NULL;
+ GHashTable* hash;
+ DIR* procdir;
+ struct dirent* procdirentry;
+ char buf[BUFSIZ];
+
+ acpiinfo->max_capacity = 0;
+ acpiinfo->low_capacity = 0;
+ acpiinfo->critical_capacity = 0;
+
+ procdir = opendir("/proc/acpi/battery/");
+
+ if (!procdir)
+ {
+ return FALSE;
+ }
+
+ while ((procdirentry = readdir(procdir)))
+ {
+ if (procdirentry->d_name[0] != '.')
+ {
+ batt_info = g_strconcat("/proc/acpi/battery/", procdirentry->d_name, "/info", NULL);
+ hash = read_file(batt_info, buf, sizeof(buf));
+
+ if (hash)
+ {
+ acpiinfo->max_capacity += read_long(hash, "last full capacity");
+ acpiinfo->low_capacity += read_long(hash, "design capacity warning");
+ acpiinfo->critical_capacity += read_long(hash, "design capacity low");
+
+ g_hash_table_destroy(hash);
+ }
+ g_free(batt_info);
+ }
+ }
+
+ closedir(procdir);
+
+ return TRUE;
}
@@ -267,7 +281,7 @@ gboolean acpi_linux_init(struct acpi_info * acpiinfo)
if (!update_battery_info(acpiinfo) || !update_ac_info(acpiinfo))
return FALSE;
-
+
fd = open("/proc/acpi/event", 0);
if (fd >= 0) {
acpiinfo->event_fd = fd;
@@ -314,7 +328,7 @@ void acpi_linux_cleanup(struct acpi_info * acpiinfo)
* to the next event. */
static int parse_acpi_event(GString *buffer)
{
-
+
if (strstr(buffer->str, "ac_adapter"))
return ACPI_EVENT_AC;
if (strstr(buffer->str, "battery") )
@@ -336,7 +350,7 @@ gboolean acpi_process_event(struct acpi_info * acpiinfo)
buffer=g_string_new(NULL);
g_io_channel_read_line_string ( acpiinfo->channel,buffer,&i,&gerror);
-
+
evt = parse_acpi_event(buffer);
switch (evt) {
case ACPI_EVENT_AC:
@@ -377,7 +391,7 @@ gboolean acpi_linux_read(struct apm_info *apminfo, struct acpi_info * acpiinfo)
* apminfo.battery_percentage must contain batter charge percentage
* apminfo.battery_flags & 0x8 must be nonzero when charging
*/
-
+
g_assert(apminfo);
charging = FALSE;
@@ -436,4 +450,4 @@ gboolean acpi_linux_read(struct apm_info *apminfo, struct acpi_info * acpiinfo)
}
-#endif
+#endif /* __linux__ */
diff --git a/geyes/Makefile.am b/geyes/Makefile.am
index 1ec106fb..509110a3 100644
--- a/geyes/Makefile.am
+++ b/geyes/Makefile.am
@@ -15,7 +15,7 @@ geyes_applet2_SOURCES = \
themes.c \
geyes.h
-geyes_applet2_LDADD = \
+geyes_applet2_LDADD = \
$(MATE_APPLETS3_LIBS) \
-lm
diff --git a/geyes/themes.c b/geyes/themes.c
index 10fb31f0..7334a318 100644
--- a/geyes/themes.c
+++ b/geyes/themes.c
@@ -1,20 +1,20 @@
/*
* Copyright (C) 1999 Dave Camp <[email protected]>
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
+ *
*/
#include <config.h>
@@ -38,14 +38,14 @@ enum {
TOTAL_COLS
};
-void theme_dirs_create(void)
+void theme_dirs_create (void)
{
static gboolean themes_created = FALSE;
-
+
if (themes_created == TRUE)
return;
- theme_directories[0] = g_build_filename(GEYES_THEMES_DIR);
+ theme_directories[0] = g_build_filename(GEYES_THEMES_DIR, NULL);
theme_directories[1] = g_build_filename(g_get_home_dir(), ".config", "mate", "geyes-themes", NULL);
themes_created = TRUE;
@@ -59,13 +59,13 @@ parse_theme_file (EyesApplet *eyes_applet, FILE *theme_file)
fgets (line_buf, 512, theme_file);
while (!feof (theme_file)) {
token = strtok (line_buf, "=");
- if (strncmp (token, "wall-thickness",
+ if (strncmp (token, "wall-thickness",
strlen ("wall-thickness")) == 0) {
token += strlen ("wall-thickness");
while (!isdigit (*token)) {
token++;
}
- sscanf (token, "%d", &eyes_applet->wall_thickness);
+ sscanf (token, "%d", &eyes_applet->wall_thickness);
} else if (strncmp (token, "num-eyes", strlen ("num-eyes")) == 0) {
token += strlen ("num-eyes");
while (!isdigit (*token)) {
@@ -76,24 +76,24 @@ parse_theme_file (EyesApplet *eyes_applet, FILE *theme_file)
eyes_applet->num_eyes = MAX_EYES;
} else if (strncmp (token, "eye-pixmap", strlen ("eye-pixmap")) == 0) {
token = strtok (NULL, "\"");
- token = strtok (NULL, "\"");
- if (eyes_applet->eye_filename != NULL)
+ token = strtok (NULL, "\"");
+ if (eyes_applet->eye_filename != NULL)
g_free (eyes_applet->eye_filename);
eyes_applet->eye_filename = g_strdup_printf ("%s%s",
eyes_applet->theme_dir,
token);
} else if (strncmp (token, "pupil-pixmap", strlen ("pupil-pixmap")) == 0) {
token = strtok (NULL, "\"");
- token = strtok (NULL, "\"");
- if (eyes_applet->pupil_filename != NULL)
+ token = strtok (NULL, "\"");
+ if (eyes_applet->pupil_filename != NULL)
g_free (eyes_applet->pupil_filename);
- eyes_applet->pupil_filename
+ eyes_applet->pupil_filename
= g_strdup_printf ("%s%s",
eyes_applet->theme_dir,
- token);
+ token);
}
fgets (line_buf, 512, theme_file);
- }
+ }
}
int
@@ -140,7 +140,7 @@ load_theme (EyesApplet *eyes_applet, const gchar *theme_dir)
fclose (theme_file);
eyes_applet->theme_name = g_strdup (theme_dir);
-
+
if (eyes_applet->eye_image)
g_object_unref (eyes_applet->eye_image);
eyes_applet->eye_image = gdk_pixbuf_new_from_file (eyes_applet->eye_filename, NULL);
@@ -152,9 +152,9 @@ load_theme (EyesApplet *eyes_applet, const gchar *theme_dir)
eyes_applet->eye_width = gdk_pixbuf_get_width (eyes_applet->eye_image);
eyes_applet->pupil_height = gdk_pixbuf_get_height (eyes_applet->pupil_image);
eyes_applet->pupil_width = gdk_pixbuf_get_width (eyes_applet->pupil_image);
-
+
g_free (file_name);
-
+
return TRUE;
}
@@ -163,14 +163,14 @@ destroy_theme (EyesApplet *eyes_applet)
{
/* Dunno about this - to unref or not to unref? */
if (eyes_applet->eye_image != NULL) {
- g_object_unref (eyes_applet->eye_image);
+ g_object_unref (eyes_applet->eye_image);
eyes_applet->eye_image = NULL;
}
if (eyes_applet->pupil_image != NULL) {
- g_object_unref (eyes_applet->pupil_image);
+ g_object_unref (eyes_applet->pupil_image);
eyes_applet->pupil_image = NULL;
}
-
+
g_free (eyes_applet->theme_dir);
g_free (eyes_applet->theme_name);
}
@@ -202,29 +202,29 @@ theme_selected_cb (GtkTreeSelection *selection, gpointer data)
GtkTreeIter iter;
gchar *theme;
gchar *theme_dir;
-
+
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
return;
-
+
gtk_tree_model_get (model, &iter, COL_THEME_DIR, &theme, -1);
-
+
g_return_if_fail (theme);
-
+
theme_dir = g_strdup_printf ("%s/", theme);
if (!g_ascii_strncasecmp (theme_dir, eyes_applet->theme_dir, strlen (theme_dir))) {
g_free (theme_dir);
return;
}
g_free (theme_dir);
-
+
destroy_eyes (eyes_applet);
destroy_theme (eyes_applet);
load_theme (eyes_applet, theme);
setup_eyes (eyes_applet);
-
+
mate_panel_applet_mateconf_set_string (
eyes_applet->applet, "theme_path", theme, NULL);
-
+
g_free (theme);
}
@@ -290,7 +290,7 @@ properties_cb (GtkAction *action,
gchar *filename;
#endif
gchar *title;
-
+
if (eyes_applet->prop_box.pbox) {
gtk_window_set_screen (
GTK_WINDOW (eyes_applet->prop_box.pbox),
@@ -307,7 +307,7 @@ properties_cb (GtkAction *action,
gtk_window_set_screen (GTK_WINDOW (pbox),
gtk_widget_get_screen (GTK_WIDGET (eyes_applet->applet)));
-
+
gtk_widget_set_size_request (GTK_WIDGET (pbox), 300, 200);
gtk_dialog_set_default_response(GTK_DIALOG (pbox), GTK_RESPONSE_CLOSE);
gtk_dialog_set_has_separator (GTK_DIALOG (pbox), FALSE);
@@ -317,11 +317,11 @@ properties_cb (GtkAction *action,
g_signal_connect (pbox, "response",
G_CALLBACK (presponse_cb),
eyes_applet);
-
+
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
gtk_widget_show (vbox);
-
+
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (pbox))), vbox,
TRUE, TRUE, 0);
@@ -332,7 +332,7 @@ properties_cb (GtkAction *action,
category_vbox = gtk_vbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (categories_vbox), category_vbox, TRUE, TRUE, 0);
gtk_widget_show (category_vbox);
-
+
title = g_strconcat ("<span weight=\"bold\">", _("Themes"), "</span>", NULL);
label = gtk_label_new (_(title));
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
@@ -340,20 +340,20 @@ properties_cb (GtkAction *action,
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
gtk_box_pack_start (GTK_BOX (category_vbox), label, FALSE, FALSE, 0);
g_free (title);
-
+
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (category_vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox);
-
+
indent = gtk_label_new (HIG_IDENTATION);
gtk_label_set_justify (GTK_LABEL (indent), GTK_JUSTIFY_LEFT);
gtk_box_pack_start (GTK_BOX (hbox), indent, FALSE, FALSE, 0);
gtk_widget_show (indent);
-
+
control_vbox = gtk_vbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (hbox), control_vbox, TRUE, TRUE, 0);
gtk_widget_show (control_vbox);
-
+
label = gtk_label_new_with_mnemonic (_("_Select a theme:"));
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
gtk_box_pack_start (GTK_BOX (control_vbox), label, FALSE, FALSE, 0);
@@ -371,12 +371,12 @@ properties_cb (GtkAction *action,
g_object_unref (model);
gtk_container_add (GTK_CONTAINER (scrolled), tree);
-
+
cell = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("not used", cell,
"text", COL_THEME_NAME, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
-
+
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
g_signal_connect (selection, "changed",
G_CALLBACK (theme_selected_cb),
@@ -394,7 +394,7 @@ properties_cb (GtkAction *action,
gchar *theme_dir;
gchar *theme_name;
#ifdef PATH_MAX
- strcpy (filename,
+ strcpy (filename,
theme_directories[i]);
strcat (filename, dp->d_name);
#else
@@ -402,20 +402,20 @@ properties_cb (GtkAction *action,
#endif
theme_dir = g_strdup_printf ("%s/", filename);
theme_name = g_path_get_basename (filename);
-
+
gtk_list_store_append (model, &iter);
gtk_list_store_set (model, &iter,
COL_THEME_DIR, &filename,
COL_THEME_NAME, theme_name,
-1);
-
+
if (!g_ascii_strncasecmp (eyes_applet->theme_dir, theme_dir, strlen (theme_dir))) {
GtkTreePath *path;
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (model),
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (model),
&iter);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree),
- path,
- NULL,
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree),
+ path,
+ NULL,
FALSE);
gtk_tree_path_free (path);
}
@@ -429,13 +429,13 @@ properties_cb (GtkAction *action,
#ifndef PATH_MAX
g_free (filename);
#endif
-
+
gtk_box_pack_start (GTK_BOX (control_vbox), scrolled, TRUE, TRUE, 0);
-
+
gtk_widget_show_all (pbox);
-
+
eyes_applet->prop_box.pbox = pbox;
-
+
return;
}
diff --git a/mixer/Makefile.am b/mixer/Makefile.am
index e499183b..0278e7eb 100644
--- a/mixer/Makefile.am
+++ b/mixer/Makefile.am
@@ -20,9 +20,9 @@ noinst_HEADERS = \
keys.h \
preferences.h
-mixer_applet2_LDADD = \
- $(MIXER_LIBS) \
- $(MATE_APPLETS3_LIBS) \
+mixer_applet2_LDADD = \
+ $(MIXER_LIBS) \
+ $(MATE_APPLETS3_LIBS) \
$(MATEDESKTOP_LIBS) \
-lm
diff --git a/multiload/Makefile.am b/multiload/Makefile.am
index cafc5ff3..f3901510 100644
--- a/multiload/Makefile.am
+++ b/multiload/Makefile.am
@@ -22,8 +22,8 @@ multiload_applet_2_SOURCES = \
autoscaler.h
multiload_applet_2_LDADD = \
- $(MATE_APPLETS3_LIBS) \
- $(GTOP_APPLETS_LIBS) \
+ $(MATE_APPLETS3_LIBS) \
+ $(GTOP_APPLETS_LIBS) \
$(MATEDESKTOP_LIBS) \
-lm
diff --git a/stickynotes/stickynotes.c b/stickynotes/stickynotes.c
index 880a1933..fc273943 100644
--- a/stickynotes/stickynotes.c
+++ b/stickynotes/stickynotes.c
@@ -840,13 +840,13 @@ stickynotes_save_now (void)
}
/* The XML file is $HOME/.config/mate/stickynotes_applet, most probably */
- //{
+ {
gchar* file = g_build_filename(g_get_home_dir(), ".config", "mate", "stickynotes-applet.xml", NULL);
xmlSaveFormatFile(file, doc, 1);
g_free(file);
- //}
+ }
xmlFreeDoc(doc);
@@ -884,7 +884,7 @@ stickynotes_load (GdkScreen *screen)
if (g_file_test(file, G_FILE_TEST_EXISTS))
{
/* load file */
- doc = xmlParseFile(file);
+ doc = xmlParseFile(file);
}
else
{
diff --git a/stickynotes/stickynotes_applet.h b/stickynotes/stickynotes_applet.h
index 6939ca0c..5a351502 100644
--- a/stickynotes/stickynotes_applet.h
+++ b/stickynotes/stickynotes_applet.h
@@ -41,7 +41,7 @@
/* Global Sticky Notes instance */
typedef struct
{
- GtkBuilder *builder;
+ GtkBuilder *builder;
GtkWidget *w_prefs; /* The prefs dialog */
GtkAdjustment *w_prefs_width;
@@ -57,7 +57,7 @@ typedef struct
GList *notes; /* Linked-List of all the sticky notes */
GList *applets; /* Linked-List of all the applets */
-
+
GdkPixbuf *icon_normal; /* Normal applet icon */
GdkPixbuf *icon_prelight; /* Prelighted applet icon */
@@ -84,7 +84,7 @@ typedef struct
GtkWidget *w_image; /* The applet icon */
GtkWidget *destroy_all_dialog; /* The applet it's destroy all dialog */
-
+
gboolean prelighted; /* Whether applet is prelighted */
gboolean pressed; /* Whether applet is pressed */
@@ -94,7 +94,7 @@ typedef struct
GtkActionGroup *action_group;
GtkWidget *menu_tip;
} StickyNotesApplet;
-
+
typedef enum
{
STICKYNOTES_NEW = 0,