summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-07-18 19:06:21 +0200
committerraveit65 <[email protected]>2020-08-07 17:56:04 +0200
commit36309af730e239289925ea5701edf9ec8452bae3 (patch)
treea36c296d3abae082836278ec95c33f8ddac99cad
parentde05d11aadbb0881613df6dbf13717781930a22b (diff)
downloadmate-applets-36309af730e239289925ea5701edf9ec8452bae3.tar.bz2
mate-applets-36309af730e239289925ea5701edf9ec8452bae3.tar.xz
battstat: Rewrite preference dialog from scratch
To manage the settings stored by GSettings. The preference dialog is a subclass of GtkDialog, and the ui file is a template. There is more info available in the "GTK+ Overview" chapter of "GTK+ 3 Reference Manual": "Building applications - A preference dialog" https://developer.gnome.org/gtk3/stable/ch01s04.html
-rw-r--r--battstat/Makefile.am89
-rw-r--r--battstat/battstat-preferences.c343
-rw-r--r--battstat/battstat-preferences.h39
-rw-r--r--battstat/battstat-preferences.ui335
-rw-r--r--battstat/battstat-resources.gresource.xml7
-rw-r--r--battstat/battstat.h16
-rw-r--r--battstat/battstat_applet.c45
-rw-r--r--battstat/battstat_applet.ui345
-rw-r--r--battstat/properties.c338
-rw-r--r--po/POTFILES.in4
10 files changed, 809 insertions, 752 deletions
diff --git a/battstat/Makefile.am b/battstat/Makefile.am
index 35ed3aa9..7606ab4d 100644
--- a/battstat/Makefile.am
+++ b/battstat/Makefile.am
@@ -1,5 +1,4 @@
-
-builder_DATA = battstat_applet.ui
+NULL =
ACPIINC= @ACPIINC@
@@ -7,7 +6,7 @@ if NEED_LIBAPM
if HAVE_LIBAPM
APMLIB = -lapm
APMDIR =
-APMINC =
+APMINC =
else
APMLIB = apmlib/libapm.a
APMDIR = apmlib
@@ -16,7 +15,7 @@ endif
else
APMLIB =
APMDIR =
-APMINC =
+APMINC =
endif
SUBDIRS = docs sounds $(APMDIR)
@@ -31,31 +30,40 @@ AM_CPPFLAGS = \
$(APMINC) \
$(ACPIINC) \
-DG_LOG_DOMAIN=\"battstat_applet\" \
- -DBATTSTAT_MENU_UI_DIR=\""$(uidir)"\"
-
+ -DBATTSTAT_RESOURCE_PATH=\""/org/mate/mate-applets/battstat/"\" \
+ $(NULL)
libexec_PROGRAMS = battstat-applet
-
-battstat_applet_SOURCES = \
- battstat.h \
- properties.c \
- battstat_applet.c \
- power-management.c \
- acpi-linux.c \
- acpi-linux.h \
- acpi-freebsd.c \
- acpi-freebsd.h \
- battstat-upower.c \
- battstat-upower.h
-
-
-battstat_applet_LDADD = \
- $(MATE_APPLETS4_LIBS) \
- $(LIBNOTIFY_LIBS) \
- $(APMLIB) \
- $(UPOWER_LIBS) \
- -lm
+BUILT_SOURCES = battstat-resources.c battstat-resources.h
+nodist_battstat_applet_SOURCES = $(BUILT_SOURCES)
+battstat_applet_SOURCES = \
+ battstat.h \
+ battstat_applet.c \
+ battstat-preferences.c \
+ battstat-preferences.h \
+ power-management.c \
+ acpi-linux.c \
+ acpi-linux.h \
+ acpi-freebsd.c \
+ acpi-freebsd.h \
+ battstat-upower.c \
+ battstat-upower.h \
+ $(NULL)
+
+battstat_applet_LDADD = \
+ $(MATE_APPLETS4_LIBS) \
+ $(LIBNOTIFY_LIBS) \
+ $(APMLIB) \
+ $(UPOWER_LIBS) \
+ -lm \
+ $(NULL)
+
+battstat-resources.c: battstat-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/battstat-resources.gresource.xml)
+ $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name battstat $<
+
+battstat-resources.h: battstat-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/battstat-resources.gresource.xml)
+ $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name battstat $<
batstat_gschema_in_files = org.mate.panel.applet.battstat.gschema.xml.in
gsettings_SCHEMAS = $(batstat_gschema_in_files:.xml.in=.xml)
@@ -83,17 +91,22 @@ org.mate.panel.applet.BattstatAppletFactory.service: $(service_in_files)
-e "s|\@LIBEXECDIR\@|$(libexecdir)|" \
$< > $@
-CLEANFILES = $(applet_DATA) $(applet_in_files) $(service_DATA) $(gsettings_SCHEMAS) *.gschema.valid
-
-uidir = $(datadir)/mate/ui
-ui_DATA = battstat-applet-menu.xml
-
-EXTRA_DIST = \
- $(builder_DATA) \
- $(ui_DATA) \
- $(applet_in_files).in \
- $(service_in_files) \
- $(batstat_gschema_in_files)
-
+CLEANFILES = \
+ $(applet_DATA) \
+ $(applet_in_files) \
+ $(service_DATA) \
+ $(gsettings_SCHEMAS) \
+ $(BUILT_SOURCES) \
+ *.gschema.valid \
+ $(NULL)
+
+EXTRA_DIST = \
+ battstat-applet-menu.xml \
+ battstat-preferences.ui \
+ battstat-resources.gresource.xml \
+ $(applet_in_files).in \
+ $(service_in_files) \
+ $(batstat_gschema_in_files) \
+ $(NULL)
-include $(top_srcdir)/git.mk
diff --git a/battstat/battstat-preferences.c b/battstat/battstat-preferences.c
new file mode 100644
index 00000000..40d38f42
--- /dev/null
+++ b/battstat/battstat-preferences.c
@@ -0,0 +1,343 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
+/* 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
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ $Id$
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+
+#include <sys/file.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#ifdef HAVE_SYS_SYSCTL_H
+#include <sys/sysctl.h>
+#endif
+
+#ifdef HAVE_ERR_H
+#include <err.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+#include <gtk/gtk.h>
+
+#include <gio/gio.h>
+
+#include "battstat-preferences.h"
+
+enum {
+ PROP_0,
+ PROP_PROGRESS_DATA
+};
+
+struct _BattstatPreferences
+{
+ GtkDialog parent;
+
+ GtkWidget *radio_text_1;
+ GtkWidget *radio_text_2;
+ GtkWidget *check_text;
+ GtkWidget *check_text_ptr;
+ GtkWidget *lowbatt_toggle;
+ GtkWidget *full_toggle;
+ GtkWidget *hbox_ptr;
+ GtkWidget *combo_ptr;
+ GtkWidget *spin_ptr;
+
+ ProgressData *battstat;
+};
+
+G_DEFINE_TYPE (BattstatPreferences, battstat_preferences, GTK_TYPE_DIALOG);
+
+static void
+combo_ptr_cb (GtkWidget *combo_ptr,
+ gpointer data)
+{
+ BattstatPreferences *dialog = data;
+
+ if (gtk_combo_box_get_active (GTK_COMBO_BOX (combo_ptr)))
+ dialog->battstat->red_value_is_time = TRUE;
+ else
+ dialog->battstat->red_value_is_time = FALSE;
+
+ g_settings_set_boolean (dialog->battstat->settings,
+ "red-value-is-time",
+ dialog->battstat->red_value_is_time);
+}
+
+static void
+spin_ptr_cb (GtkWidget *spin_ptr,
+ gpointer data)
+{
+ BattstatPreferences *dialog = data;
+
+ dialog->battstat->red_val = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin_ptr));
+ /* automatically calculate orangle and yellow values from the
+ * red value
+ */
+ dialog->battstat->orange_val = dialog->battstat->red_val * ORANGE_MULTIPLIER;
+ dialog->battstat->orange_val = MIN (dialog->battstat->orange_val, 100);
+
+ dialog->battstat->yellow_val = dialog->battstat->red_val * YELLOW_MULTIPLIER;
+ dialog->battstat->yellow_val = MIN (dialog->battstat->yellow_val, 100);
+
+ g_settings_set_int (dialog->battstat->settings,
+ "red-value",
+ dialog->battstat->red_val);
+}
+
+static void
+show_text_toggled (GtkToggleButton *button,
+ gpointer data)
+{
+ BattstatPreferences *dialog = data;
+ gboolean show_text_active;
+
+ show_text_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->check_text));
+ if (show_text_active) {
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->radio_text_1)))
+ dialog->battstat->showtext = APPLET_SHOW_TIME;
+ else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->radio_text_2)))
+ dialog->battstat->showtext = APPLET_SHOW_PERCENT;
+ else
+ dialog->battstat->showtext = APPLET_SHOW_NONE;
+ } else {
+ dialog->battstat->showtext = APPLET_SHOW_NONE;
+ }
+
+ dialog->battstat->refresh_label = TRUE;
+
+ reconfigure_layout (dialog->battstat);
+
+ g_settings_set_int (dialog->battstat->settings,
+ "show-text",
+ dialog->battstat->showtext);
+}
+
+static void
+lowbatt_toggled (GtkToggleButton *button,
+ gpointer data)
+{
+ BattstatPreferences *dialog = data;
+
+ dialog->battstat->lowbattnotification = gtk_toggle_button_get_active (button);
+}
+
+static void
+full_toggled (GtkToggleButton *button,
+ gpointer data)
+{
+ BattstatPreferences *dialog = data;
+
+ dialog->battstat->fullbattnot = gtk_toggle_button_get_active (button);
+}
+
+static void
+response_cb (GtkDialog *dialog,
+ gint id,
+ gpointer data)
+{
+ BattstatPreferences *self = data;
+
+ if (id == GTK_RESPONSE_HELP)
+ battstat_show_help (self->battstat, "battstat-appearance");
+ else
+ gtk_widget_hide (GTK_WIDGET (dialog));
+}
+
+static void
+battstat_preferences_update (BattstatPreferences *dialog)
+{
+ gboolean check_text_active = TRUE;
+
+ if (!g_settings_is_writable (dialog->battstat->settings, "low-battery-notification")) {
+ gtk_widget_set_sensitive (dialog->lowbatt_toggle, FALSE);
+ }
+
+ gtk_widget_set_sensitive (dialog->hbox_ptr, dialog->battstat->lowbattnotification);
+
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->spin_ptr), dialog->battstat->red_val);
+
+ if (dialog->battstat->red_value_is_time)
+ gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->combo_ptr), 1);
+ else
+ gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->combo_ptr), 0);
+
+ if (!g_settings_is_writable (dialog->battstat->settings, "full-battery-notification"))
+ gtk_widget_set_sensitive (dialog->full_toggle, FALSE);
+
+ if (dialog->battstat->fullbattnot)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->full_toggle), TRUE);
+
+ if (dialog->battstat->lowbattnotification)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->lowbatt_toggle), TRUE);
+
+ if (!g_settings_is_writable (dialog->battstat->settings, "show-text"))
+ {
+ gtk_widget_set_sensitive (dialog->check_text, FALSE);
+ check_text_active = FALSE;
+ }
+ switch (dialog->battstat->showtext) {
+ case APPLET_SHOW_PERCENT:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->check_text), TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->radio_text_2), TRUE);
+ break;
+ case APPLET_SHOW_TIME:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->check_text), TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->radio_text_1), TRUE);
+ break;
+ case APPLET_SHOW_NONE:
+ default:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->check_text), FALSE);
+ check_text_active = FALSE;
+ }
+ gtk_widget_set_sensitive (dialog->check_text_ptr, check_text_active);
+}
+
+static void
+battstat_preferences_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ BattstatPreferences *dialog;
+
+ dialog = BATTSTAT_PREFERENCES (object);
+
+ switch (prop_id) {
+ case PROP_PROGRESS_DATA:
+ dialog->battstat = g_value_get_pointer (value);
+ break;
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+battstat_preferences_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ BattstatPreferences *dialog;
+
+ dialog = BATTSTAT_PREFERENCES (object);
+
+ switch (prop_id) {
+ case PROP_PROGRESS_DATA:
+ g_value_set_pointer (value, dialog->battstat);
+ break;
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+battstat_preferences_init (BattstatPreferences *dialog)
+{
+ gtk_widget_init_template (GTK_WIDGET (dialog));
+
+ g_object_bind_property (dialog->check_text, "active",
+ dialog->check_text_ptr, "sensitive",
+ G_BINDING_DEFAULT);
+
+ g_object_bind_property (dialog->lowbatt_toggle, "active",
+ dialog->hbox_ptr, "sensitive",
+ G_BINDING_DEFAULT);
+}
+
+static GObject*
+battstat_preferences_constructor (GType type,
+ guint n_construct_params,
+ GObjectConstructParam *construct_params)
+{
+ GObject *object;
+ BattstatPreferences *self;
+
+ object = G_OBJECT_CLASS (battstat_preferences_parent_class)->
+ constructor (type, n_construct_params, construct_params);
+ self = BATTSTAT_PREFERENCES (object);
+
+ battstat_preferences_update (self);
+
+ g_settings_bind (self->battstat->settings, "low-battery-notification",
+ self->lowbatt_toggle, "active",
+ G_SETTINGS_BIND_DEFAULT);
+
+ g_settings_bind (self->battstat->settings, "full-battery-notification",
+ self->full_toggle, "active",
+ G_SETTINGS_BIND_DEFAULT);
+
+ return object;
+}
+
+GtkWidget*
+battstat_preferences_new (ProgressData *battstat)
+{
+ return g_object_new (BATTSTAT_TYPE_PREFERENCES,
+ "progress-data", battstat,
+ NULL);
+}
+
+static void
+battstat_preferences_class_init (BattstatPreferencesClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->set_property = battstat_preferences_set_property;
+ object_class->get_property = battstat_preferences_get_property;
+ object_class->constructor = battstat_preferences_constructor;
+
+ g_object_class_install_property (object_class,
+ PROP_PROGRESS_DATA,
+ g_param_spec_pointer ("progress-data",
+ "Progress Data",
+ "The Progress Data",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ gtk_widget_class_set_template_from_resource (widget_class,
+ BATTSTAT_RESOURCE_PATH "battstat-preferences.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, BattstatPreferences, check_text);
+ gtk_widget_class_bind_template_child (widget_class, BattstatPreferences, check_text_ptr);
+ gtk_widget_class_bind_template_child (widget_class, BattstatPreferences, radio_text_1);
+ gtk_widget_class_bind_template_child (widget_class, BattstatPreferences, radio_text_2);
+ gtk_widget_class_bind_template_child (widget_class, BattstatPreferences, lowbatt_toggle);
+ gtk_widget_class_bind_template_child (widget_class, BattstatPreferences, full_toggle);
+ gtk_widget_class_bind_template_child (widget_class, BattstatPreferences, hbox_ptr);
+ gtk_widget_class_bind_template_child (widget_class, BattstatPreferences, combo_ptr);
+ gtk_widget_class_bind_template_child (widget_class, BattstatPreferences, spin_ptr);
+
+ gtk_widget_class_bind_template_callback (widget_class, lowbatt_toggled);
+ gtk_widget_class_bind_template_callback (widget_class, combo_ptr_cb);
+ gtk_widget_class_bind_template_callback (widget_class, spin_ptr_cb);
+ gtk_widget_class_bind_template_callback (widget_class, full_toggled);
+ gtk_widget_class_bind_template_callback (widget_class, show_text_toggled);
+ gtk_widget_class_bind_template_callback (widget_class, response_cb);
+}
diff --git a/battstat/battstat-preferences.h b/battstat/battstat-preferences.h
new file mode 100644
index 00000000..d3cc882d
--- /dev/null
+++ b/battstat/battstat-preferences.h
@@ -0,0 +1,39 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
+/* 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
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ $Id$
+ */
+
+#ifndef __BATTSTAT_PREFERENCES_H__
+#define __BATTSTAT_PREFERENCES_H__
+
+#include <glib.h>
+
+#include "battstat.h"
+
+G_BEGIN_DECLS
+
+#define BATTSTAT_TYPE_PREFERENCES battstat_preferences_get_type ()
+G_DECLARE_FINAL_TYPE (BattstatPreferences, battstat_preferences,
+ BATTSTAT, PREFERENCES, GtkDialog)
+
+GtkWidget *battstat_preferences_new (ProgressData *battstat);
+
+G_END_DECLS
+
+#endif /* __BATTSTAT_PREFERENCES_H__ */
diff --git a/battstat/battstat-preferences.ui b/battstat/battstat-preferences.ui
new file mode 100644
index 00000000..424f0b9c
--- /dev/null
+++ b/battstat/battstat-preferences.ui
@@ -0,0 +1,335 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.36.0 -->
+<interface>
+ <requires lib="gtk+" version="3.22"/>
+ <object class="GtkAdjustment" id="adjustment1">
+ <property name="upper">25</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">5</property>
+ </object>
+ <object class="GtkImage" id="close_img">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">window-close</property>
+ </object>
+ <object class="GtkImage" id="help_img">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">help-browser</property>
+ </object>
+ <template class="BattstatPreferences" parent="GtkDialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">12</property>
+ <property name="title" translatable="yes">Battery Charge Monitor Preferences</property>
+ <property name="type_hint">dialog</property>
+ <signal name="response" handler="response_cb" swapped="no"/>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="help_btn">
+ <property name="label" translatable="yes">_Help</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">help_img</property>
+ <property name="use_underline">True</property>
+ <property name="always_show_image">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="close_btn">
+ <property name="label" translatable="yes">_Close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">close_img</property>
+ <property name="use_underline">True</property>
+ <property name="always_show_image">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkFrame">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">6</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkCheckButton" id="check_text">
+ <property name="label" translatable="yes">_Show time/percentage:</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="show_text_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="check_text_ptr">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_start">12</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkRadioButton" id="radio_text_1">
+ <property name="label" translatable="yes">Show _time remaining</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="show_text_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="radio_text_2">
+ <property name="label" translatable="yes">Show _percentage remaining</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">radio_text_1</property>
+ <signal name="toggled" handler="show_text_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Appearance</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">6</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkCheckButton" id="lowbatt_toggle">
+ <property name="label" translatable="yes">_Warn when battery charge drops to:</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="lowbatt_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="hbox_ptr">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_start">12</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkSpinButton" id="spin_ptr">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="halign">start</property>
+ <property name="adjustment">adjustment1</property>
+ <signal name="value-changed" handler="spin_ptr_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="combo_ptr">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <items>
+ <item translatable="yes">Percent</item>
+ <item translatable="yes">Minutes Remaining</item>
+ </items>
+ <signal name="changed" handler="combo_ptr_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="full_toggle">
+ <property name="label" translatable="yes">_Notify when battery is fully recharged</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="full_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Notifications</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-11">help_btn</action-widget>
+ <action-widget response="-7">close_btn</action-widget>
+ </action-widgets>
+ <child type="titlebar">
+ <placeholder/>
+ </child>
+ </template>
+</interface>
diff --git a/battstat/battstat-resources.gresource.xml b/battstat/battstat-resources.gresource.xml
new file mode 100644
index 00000000..8be5403e
--- /dev/null
+++ b/battstat/battstat-resources.gresource.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/mate/mate-applets/battstat">
+ <file compressed="true">battstat-applet-menu.xml</file>
+ <file compressed="true">battstat-preferences.ui</file>
+ </gresource>
+</gresources>
diff --git a/battstat/battstat.h b/battstat/battstat.h
index 9e45e56b..d0d4e402 100644
--- a/battstat/battstat.h
+++ b/battstat/battstat.h
@@ -41,7 +41,7 @@
typedef enum
{
- APPLET_SHOW_NONE,
+ APPLET_SHOW_NONE = 0,
APPLET_SHOW_PERCENT,
APPLET_SHOW_TIME
} AppletTextType;
@@ -87,14 +87,6 @@ typedef struct
typedef struct _ProgressData {
GtkWidget *applet;
- /* these are used by properties.c */
- GtkWidget *radio_text_1;
- GtkWidget *radio_text_2;
- GtkWidget *check_text;
- GtkWidget *lowbatt_toggle;
- GtkWidget *full_toggle;
- GtkWidget *hbox_ptr;
-
/* flags set from gsettings or the properties dialog */
GSettings *settings;
guint red_val;
@@ -118,7 +110,7 @@ typedef struct _ProgressData {
GtkWidget *percent;
/* dialog boxes that might be displayed */
- GtkDialog *prop_win;
+ GtkWidget *prop_win;
GtkWidget *battery_low_dialog;
/* text label inside the low battery dialog */
@@ -149,12 +141,10 @@ typedef struct _ProgressData {
gboolean last_present;
} ProgressData;
-/* properties.c */
-void prop_cb (GtkAction *, ProgressData *);
-
/* battstat_applet.c */
void reconfigure_layout( ProgressData *battstat );
void battstat_show_help( ProgressData *battstat, const char *section );
+void prop_cb (GtkAction *, ProgressData *);
/* power-management.c */
const char *power_management_getinfo( BatteryStatus *status );
diff --git a/battstat/battstat_applet.c b/battstat/battstat_applet.c
index e951c71c..16755717 100644
--- a/battstat/battstat_applet.c
+++ b/battstat/battstat_applet.c
@@ -45,10 +45,7 @@
#endif
#include "battstat.h"
-
-#ifndef gettext_noop
-#define gettext_noop(String) (String)
-#endif
+#include "battstat-preferences.h"
#define BATTSTAT_SCHEMA "org.mate.panel.applet.battstat"
@@ -759,7 +756,8 @@ destroy_applet( GtkWidget *widget, ProgressData *battstat )
* button in the preferences dialog.
*/
void
-battstat_show_help( ProgressData *battstat, const char *section )
+battstat_show_help (ProgressData *battstat,
+ const char *section)
{
GError *error = NULL;
char *uri;
@@ -770,21 +768,21 @@ battstat_show_help( ProgressData *battstat, const char *section )
uri = g_strdup ("help:mate-battstat");
gtk_show_uri_on_window (NULL,
- uri,
- gtk_get_current_event_time (),
- &error);
+ uri,
+ gtk_get_current_event_time (),
+ &error);
g_free (uri);
- if( error )
+ if (error)
{
char *message;
- message = g_strdup_printf( _("There was an error displaying help: %s"),
+ message = g_strdup_printf (_("There was an error displaying help: %s"),
error->message );
- battstat_error_dialog( battstat->applet, message );
- g_error_free( error );
- g_free( message );
+ battstat_error_dialog (battstat->applet, message);
+ g_error_free (error);
+ g_free (message);
}
}
@@ -1098,6 +1096,20 @@ create_layout(ProgressData *battstat)
return FALSE;
}
+void
+prop_cb (GtkAction *action,
+ ProgressData *battstat)
+{
+ if (battstat->prop_win) {
+ gtk_window_set_screen (GTK_WINDOW (battstat->prop_win),
+ gtk_widget_get_screen (battstat->applet));
+ gtk_window_present (GTK_WINDOW (battstat->prop_win));
+ } else {
+ battstat->prop_win = battstat_preferences_new (battstat);
+ gtk_widget_show_all (GTK_WIDGET (battstat->prop_win));
+ }
+}
+
/* Called by the factory to fill in the fields for the applet.
*/
static gboolean
@@ -1145,9 +1157,10 @@ battstat_applet_fill (MatePanelApplet *applet)
battstat_menu_actions,
G_N_ELEMENTS (battstat_menu_actions),
battstat);
- mate_panel_applet_setup_menu_from_file (MATE_PANEL_APPLET (battstat->applet),
- BATTSTAT_MENU_UI_DIR G_DIR_SEPARATOR_S "battstat-applet-menu.xml",
- action_group);
+
+ mate_panel_applet_setup_menu_from_resource (MATE_PANEL_APPLET (battstat->applet),
+ BATTSTAT_RESOURCE_PATH "battstat-applet-menu.xml",
+ action_group);
if (mate_panel_applet_get_locked_down (MATE_PANEL_APPLET (battstat->applet))) {
GtkAction *action;
diff --git a/battstat/battstat_applet.ui b/battstat/battstat_applet.ui
deleted file mode 100644
index 5b892502..00000000
--- a/battstat/battstat_applet.ui
+++ /dev/null
@@ -1,345 +0,0 @@
-<?xml version="1.0"?>
-<interface>
- <requires lib="gtk+" version="2.16"/>
- <!-- interface-naming-policy toplevel-contextual -->
- <object class="GtkAdjustment" id="adjustment1">
- <property name="value">1</property>
- <property name="lower">1</property>
- <property name="upper">25</property>
- <property name="step_increment">1</property>
- <property name="page_increment">5</property>
- </object>
- <object class="GtkDialog" id="battstat_properties">
- <property name="border_width">5</property>
- <property name="title" translatable="yes">Battery Charge Monitor Preferences</property>
- <property name="type_hint">dialog</property>
- <child internal-child="vbox">
- <object class="GtkVBox" id="dialog_vbox">
- <property name="visible">True</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkVBox" id="vbox6">
- <property name="visible">True</property>
- <property name="border_width">5</property>
- <property name="spacing">18</property>
- <child>
- <object class="GtkVBox" id="vbox17">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="label15">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Appearance</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="hbox8">
- <property name="visible">True</property>
- <child>
- <object class="GtkLabel" id="label21">
- <property name="visible">True</property>
- <property name="label"> </property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vbox19">
- <property name="visible">True</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkVBox" id="vbox22">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkCheckButton" id="show_text_remaining">
- <property name="label" translatable="yes">_Show time/percentage:</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="hbox9">
- <property name="visible">True</property>
- <child>
- <object class="GtkLabel" id="label22">
- <property name="visible">True</property>
- <property name="label"> </property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vbox20">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkRadioButton" id="show_text_radio">
- <property name="label" translatable="yes">Show _time remaining</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkRadioButton" id="show_text_radio_2">
- <property name="label" translatable="yes">Show _percentage remaining</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <property name="group">show_text_radio</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vbox12">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="label18">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Notifications</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="hbox5">
- <property name="visible">True</property>
- <child>
- <object class="GtkLabel" id="label17">
- <property name="visible">True</property>
- <property name="label"> </property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vbox13">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkCheckButton" id="lowbatt_toggle">
- <property name="label" translatable="yes" comments="TRANSLATOR: This is the beginning of the sentence 'Warn when battery charge drops to: [XX] percent/minutes remaining'">_Warn when battery charge drops to:</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="hbox_ptr">
- <property name="visible">True</property>
- <property name="spacing">5</property>
- <child>
- <object class="GtkLabel" id="label23">
- <property name="visible">True</property>
- <property name="label"> </property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="spin_ptr">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="adjustment">adjustment1</property>
- <property name="climb_rate">1</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="combo_ptr">
- <property name="visible">True</property>
- </object>
- <packing>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="full_toggle">
- <property name="label" translatable="yes">_Notify when battery is fully recharged</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="hbuttonbox1">
- <property name="visible">True</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="button1">
- <property name="label">gtk-help</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="button2">
- <property name="label">gtk-close</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="-11">button1</action-widget>
- <action-widget response="-7">button2</action-widget>
- </action-widgets>
- </object>
-</interface>
diff --git a/battstat/properties.c b/battstat/properties.c
deleted file mode 100644
index b2b6db62..00000000
--- a/battstat/properties.c
+++ /dev/null
@@ -1,338 +0,0 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
-/* 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
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- $Id$
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-
-#include <sys/file.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#ifdef HAVE_SYS_SYSCTL_H
-#include <sys/sysctl.h>
-#endif
-
-#ifdef HAVE_ERR_H
-#include <err.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <gtk/gtk.h>
-
-#include <gio/gio.h>
-
-#include "battstat.h"
-
-#ifndef gettext_noop
-#define gettext_noop(String) (String)
-#endif
-
-#define NEVER_SENSITIVE "never_sensitive"
-
-/* set sensitive and setup NEVER_SENSITIVE appropriately */
-static void
-hard_set_sensitive (GtkWidget *w, gboolean sensitivity)
-{
- gtk_widget_set_sensitive (w, sensitivity);
- g_object_set_data (G_OBJECT (w), NEVER_SENSITIVE,
- GINT_TO_POINTER ( ! sensitivity));
-}
-
-
-#if 0
-/* set sensitive, but always insensitive if NEVER_SENSITIVE is set */
-static void
-soft_set_sensitive (GtkWidget *w, gboolean sensitivity)
-{
- if (g_object_get_data (G_OBJECT (w), NEVER_SENSITIVE))
- gtk_widget_set_sensitive (w, FALSE);
- else
- gtk_widget_set_sensitive (w, sensitivity);
-}
-#endif /* 0 */
-
-static void
-combo_ptr_cb (GtkWidget *combo_ptr, gpointer data)
-{
- ProgressData *battstat = data;
-
- if (gtk_combo_box_get_active (GTK_COMBO_BOX (combo_ptr)))
- battstat->red_value_is_time = TRUE;
- else
- battstat->red_value_is_time = FALSE;
-
- g_settings_set_boolean (battstat->settings,
- "red-value-is-time",
- battstat->red_value_is_time);
-}
-
-static void
-spin_ptr_cb (GtkWidget *spin_ptr, gpointer data)
-{
- ProgressData *battstat = data;
-
- battstat->red_val = gtk_spin_button_get_value_as_int (
- GTK_SPIN_BUTTON (spin_ptr));
- /* automatically calculate orangle and yellow values from the
- * red value
- */
- battstat->orange_val = battstat->red_val * ORANGE_MULTIPLIER;
- battstat->orange_val = CLAMP (battstat->orange_val, 0, 100);
-
- battstat->yellow_val = battstat->red_val * YELLOW_MULTIPLIER;
- battstat->yellow_val = CLAMP (battstat->yellow_val, 0, 100);
-
- g_settings_set_int (battstat->settings,
- "red-value",
- battstat->red_val);
-}
-
-static void
-show_text_toggled (GtkToggleButton *button, gpointer data)
-{
- ProgressData *battstat = data;
-
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (battstat->radio_text_2))
- && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (battstat->check_text)))
- battstat->showtext = APPLET_SHOW_PERCENT;
- else if (gtk_toggle_button_get_active (
- GTK_TOGGLE_BUTTON (battstat->radio_text_1)) &&
- gtk_toggle_button_get_active (
- GTK_TOGGLE_BUTTON (battstat->check_text)))
- battstat->showtext = APPLET_SHOW_TIME;
- else
- battstat->showtext = APPLET_SHOW_NONE;
-
- battstat->refresh_label = TRUE;
-
- reconfigure_layout( battstat );
-
- gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_1),
- battstat->showtext);
- gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_2),
- battstat->showtext);
-
- g_settings_set_int (battstat->settings, "show-text", battstat->showtext);
-}
-
-static void
-lowbatt_toggled (GtkToggleButton *button, gpointer data)
-{
- ProgressData *battstat = data;
-
- battstat->lowbattnotification = gtk_toggle_button_get_active (button);
- g_settings_set_boolean (battstat->settings, "low-battery-notification",
- battstat->lowbattnotification);
-
- hard_set_sensitive (battstat->hbox_ptr, battstat->lowbattnotification);
-}
-
-static void
-full_toggled (GtkToggleButton *button, gpointer data)
-{
- ProgressData *battstat = data;
-
- battstat->fullbattnot = gtk_toggle_button_get_active (button);
- g_settings_set_boolean (battstat->settings, "full-battery-notification",
- battstat->fullbattnot);
-}
-
-static void
-response_cb (GtkDialog *dialog, gint id, gpointer data)
-{
- ProgressData *battstat = data;
-
- if (id == GTK_RESPONSE_HELP)
- battstat_show_help (battstat, "battstat-appearance");
- else
- gtk_widget_hide (GTK_WIDGET (battstat->prop_win));
-}
-
-void
-prop_cb (GtkAction *action,
- ProgressData *battstat)
-{
- GtkBuilder *builder;
- GtkWidget *combo_ptr, *spin_ptr;
- GtkListStore *liststore;
- GtkCellRenderer *renderer;
- GtkTreeIter iter;
-
- if (DEBUG) g_print("prop_cb()\n");
-
- if (battstat->prop_win) {
- gtk_window_set_screen (GTK_WINDOW (battstat->prop_win),
- gtk_widget_get_screen (battstat->applet));
- gtk_window_present (GTK_WINDOW (battstat->prop_win));
- return;
- }
-
- builder = gtk_builder_new ();
- gtk_builder_add_from_file (builder, GTK_BUILDERDIR"/battstat_applet.ui", NULL);
-
- battstat->prop_win = GTK_DIALOG (gtk_builder_get_object (builder,
- "battstat_properties"));
- gtk_window_set_screen (GTK_WINDOW (battstat->prop_win),
- gtk_widget_get_screen (battstat->applet));
-
- g_signal_connect (G_OBJECT (battstat->prop_win), "delete_event",
- G_CALLBACK (gtk_true), NULL);
-
- battstat->lowbatt_toggle = GTK_WIDGET (gtk_builder_get_object (builder, "lowbatt_toggle"));
- g_signal_connect (G_OBJECT (battstat->lowbatt_toggle), "toggled",
- G_CALLBACK (lowbatt_toggled), battstat);
-
- if (!g_settings_is_writable (battstat->settings,
- "low-battery-notification"))
- {
- hard_set_sensitive (battstat->lowbatt_toggle, FALSE);
- }
-
- battstat->hbox_ptr = GTK_WIDGET (gtk_builder_get_object (builder, "hbox_ptr"));
- hard_set_sensitive (battstat->hbox_ptr, battstat->lowbattnotification);
-
- combo_ptr = GTK_WIDGET (gtk_builder_get_object (builder, "combo_ptr"));
- g_signal_connect (G_OBJECT (combo_ptr), "changed",
- G_CALLBACK (combo_ptr_cb), battstat);
-
- liststore = gtk_list_store_new (1, G_TYPE_STRING);
- gtk_combo_box_set_model (GTK_COMBO_BOX (combo_ptr),
- GTK_TREE_MODEL (liststore));
- gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo_ptr));
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_ptr),
- renderer, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_ptr),
- renderer,
- "text", 0,
- NULL);
- gtk_list_store_append (liststore, &iter);
- /* TRANSLATOR: this is a selectable item in a drop-down menu to end
- * this sentence:
- * "Warn when battery charge drops to: [XX] percent".
- */
- gtk_list_store_set (liststore, &iter, 0, _("Percent"), -1);
- gtk_list_store_append (liststore, &iter);
- /* TRANSLATOR: this is a selectable item in a drop-down menu to end
- * this sentence:
- * "Warn when battery charge drops to: [XX] minutes remaining"
- */
- gtk_list_store_set (liststore, &iter, 0, _("Minutes Remaining"), -1);
-
- spin_ptr = GTK_WIDGET (gtk_builder_get_object (builder, "spin_ptr"));
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin_ptr),
- battstat->red_val);
- g_signal_connect (G_OBJECT (spin_ptr), "value-changed",
- G_CALLBACK (spin_ptr_cb), battstat);
-
- if (battstat->red_value_is_time)
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo_ptr), 1);
- else
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo_ptr), 0);
-
- battstat->full_toggle = GTK_WIDGET (gtk_builder_get_object (builder, "full_toggle"));
- g_signal_connect (G_OBJECT (battstat->full_toggle), "toggled",
- G_CALLBACK (full_toggled), battstat);
-
- if (!g_settings_is_writable (battstat->settings,
- "full-battery-notification"))
- {
- hard_set_sensitive (battstat->full_toggle, FALSE);
- }
- if (battstat->fullbattnot)
- {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (battstat->full_toggle),
- TRUE);
- }
- if (battstat->lowbattnotification)
- {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (battstat->lowbatt_toggle),
- TRUE);
- }
-
- battstat->radio_text_1 = GTK_WIDGET (gtk_builder_get_object (builder, "show_text_radio"));
- battstat->radio_text_2 = GTK_WIDGET (gtk_builder_get_object (builder,
- "show_text_radio_2"));
- battstat->check_text = GTK_WIDGET (gtk_builder_get_object (builder,
- "show_text_remaining"));
-
- g_object_unref (builder);
-
- g_signal_connect (G_OBJECT (battstat->radio_text_1), "toggled",
- G_CALLBACK (show_text_toggled), battstat);
- g_signal_connect (G_OBJECT (battstat->radio_text_2), "toggled",
- G_CALLBACK (show_text_toggled), battstat);
- g_signal_connect (G_OBJECT (battstat->check_text), "toggled",
- G_CALLBACK (show_text_toggled), battstat);
-
- if (!g_settings_is_writable (battstat->settings, "show-text"))
- {
- hard_set_sensitive (battstat->check_text, FALSE);
- hard_set_sensitive (battstat->radio_text_1, FALSE);
- hard_set_sensitive (battstat->radio_text_2, FALSE);
- }
-
- if (battstat->showtext == APPLET_SHOW_PERCENT)
- {
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (battstat->check_text), TRUE);
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (battstat->radio_text_2), TRUE);
- gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_1),
- TRUE);
- gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_2),
- TRUE);
- }
- else if (battstat->showtext == APPLET_SHOW_TIME)
- {
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (battstat->check_text),
- TRUE);
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (battstat->radio_text_1),
- TRUE);
- gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_1),
- TRUE);
- gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_2),
- TRUE);
- }
- else /* APPLET_SHOW_NONE */
- {
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (battstat->check_text), FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_1),
- FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_2),
- FALSE);
- }
-
- gtk_dialog_set_default_response (GTK_DIALOG (battstat->prop_win),
- GTK_RESPONSE_CLOSE);
- gtk_window_set_resizable (GTK_WINDOW (battstat->prop_win), FALSE);
- g_signal_connect (G_OBJECT (battstat->prop_win), "response",
- G_CALLBACK (response_cb), battstat);
- gtk_widget_show_all (GTK_WIDGET (battstat->prop_win));
-}
diff --git a/po/POTFILES.in b/po/POTFILES.in
index d2fc5000..4c140cc9 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,10 +4,10 @@
accessx-status/applet.c
accessx-status/org.mate.applets.AccessxStatusApplet.mate-panel-applet.desktop.in.in
battstat/battstat_applet.c
-battstat/battstat_applet.ui
+battstat/battstat-preferences.c
+battstat/battstat-preferences.ui
battstat/org.mate.applets.BattstatApplet.mate-panel-applet.desktop.in.in
battstat/org.mate.panel.applet.battstat.gschema.xml.in
-battstat/properties.c
battstat/sounds/mate-battstat_applet.soundlist.desktop.in
charpick/charpick.c
charpick/org.mate.applets.CharpickerApplet.mate-panel-applet.desktop.in.in