diff -Nru sensors-applet-3.0.0+git4/configure.ac sensors-applet-3.0.0+git5/configure.ac --- sensors-applet-3.0.0+git4/configure.ac 2013-03-06 09:32:25.000000000 +0000 +++ sensors-applet-3.0.0+git5/configure.ac 2015-06-17 22:13:32.000000000 +0000 @@ -7,7 +7,7 @@ AC_CONFIG_SRCDIR([sensors-applet/main.c]) AM_CONFIG_HEADER([sensors-applet/config.h]) -AM_INIT_AUTOMAKE +AM_INIT_AUTOMAKE([ -Wno-portability]) m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) AM_MAINTAINER_MODE @@ -66,11 +66,11 @@ AC_SUBST(GTK_CFLAGS) AC_SUBST(GTK_LIBS) -PKG_CHECK_MODULES(GNOME, libpanelapplet-4.0 >= $LIBPANEL_REQUIRED) +PKG_CHECK_MODULES(GNOME, libpanel-applet >= $LIBPANEL_REQUIRED) AC_SUBST(GNOME_CFLAGS) AC_SUBST(GNOME_LIBS) -LIBPANEL_APPLET_DIR=`$PKG_CONFIG --variable=libpanel_applet_dir libpanelapplet-4.0` +LIBPANEL_APPLET_DIR=`$PKG_CONFIG --variable=libpanel_applet_dir libpanel-applet` AC_SUBST(LIBPANEL_APPLET_DIR) PKG_CHECK_MODULES(CAIRO, cairo >= $LIBCAIRO_REQUIRED) @@ -127,6 +127,7 @@ AC_SUBST(LIBNOTIFY_CFLAGS) AC_SUBST(LIBNOTIFY_LIBS) +GLIB_GSETTINGS # allow user to specify libsensors support, but support it anyway if possible AC_ARG_WITH(libsensors, diff -Nru sensors-applet-3.0.0+git4/debian/changelog sensors-applet-3.0.0+git5/debian/changelog --- sensors-applet-3.0.0+git4/debian/changelog 2014-11-22 15:22:37.000000000 +0000 +++ sensors-applet-3.0.0+git5/debian/changelog 2015-06-25 09:19:12.000000000 +0000 @@ -1,9 +1,21 @@ -sensors-applet (3.0.0+git4-4ubuntu2) vivid; urgency=medium +sensors-applet (3.0.0+git5-0.1ubuntu1) wily; urgency=low - * Remove all GConf usage, just use default values. - * Port to GAction and libpanel-applet 3.14. + * Merge from Debian unstable, remaining changes: + - debian/rules: + + Enable nvidia compilation flag. + - debian/control: + + Build-depend on nvidia-settings and update description accordingly. - -- Dmitry Shachnev Fri, 21 Nov 2014 17:18:47 +0300 + -- Dmitry Shachnev Thu, 25 Jun 2015 12:16:54 +0300 + +sensors-applet (3.0.0+git5-0.1) unstable; urgency=medium + + * Non-maintainer upload, with maintainer's permission. + * New snapshot from upstream Git repository. + - The only change is port to libpanel-applet, which closes: #772620. + * Build-depend on libpanel-applet-dev instead of libpanel-applet-4-dev. + + -- Dmitry Shachnev Wed, 24 Jun 2015 20:36:00 +0300 sensors-applet (3.0.0+git4-4ubuntu1) utopic; urgency=medium diff -Nru sensors-applet-3.0.0+git4/debian/control sensors-applet-3.0.0+git5/debian/control --- sensors-applet-3.0.0+git4/debian/control 2014-11-22 14:53:03.000000000 +0000 +++ sensors-applet-3.0.0+git5/debian/control 2015-06-25 09:14:11.000000000 +0000 @@ -17,7 +17,7 @@ libglib2.0-dev (>= 2.22.0), libgtk-3-dev (>= 3.0.0), libnotify-dev (>= 0.7.0), - libpanel-applet-dev, + libpanel-applet-dev (>= 3.0.0), libsensors4-dev, libx11-dev, libtool, diff -Nru sensors-applet-3.0.0+git4/debian/patches/libpanel-applet.patch sensors-applet-3.0.0+git5/debian/patches/libpanel-applet.patch --- sensors-applet-3.0.0+git4/debian/patches/libpanel-applet.patch 2014-11-22 15:46:55.000000000 +0000 +++ sensors-applet-3.0.0+git5/debian/patches/libpanel-applet.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,126 +0,0 @@ -Description: port to GAction and libpanel-applet 3.14 -Author: Dmitry Shachnev -Forwarded: yes, https://sourceforge.net/p/sensors-applet/bugs/96/ -Last-Update: 2014-11-22 - ---- a/configure.ac -+++ b/configure.ac -@@ -51,7 +51,6 @@ - - GLIB_REQUIRED=2.22.0 - GTK_REQUIRED=3.4.0 --LIBPANEL_REQUIRED=3.0.0 - LIBNOTIFY_REQUIRED=0.3.0 - LIBCAIRO_REQUIRED=1.0.4 - LIBDBUSGLIB_REQUIRED=0.80 -@@ -65,11 +64,11 @@ - AC_SUBST(GTK_CFLAGS) - AC_SUBST(GTK_LIBS) - --PKG_CHECK_MODULES(GNOME, libpanelapplet-4.0 >= $LIBPANEL_REQUIRED) -+PKG_CHECK_MODULES(GNOME, libpanel-applet) - AC_SUBST(GNOME_CFLAGS) - AC_SUBST(GNOME_LIBS) - --LIBPANEL_APPLET_DIR=`$PKG_CONFIG --variable=libpanel_applet_dir libpanelapplet-4.0` -+LIBPANEL_APPLET_DIR=`$PKG_CONFIG --variable=libpanel_applet_dir libpanel-applet` - AC_SUBST(LIBPANEL_APPLET_DIR) - - PKG_CHECK_MODULES(CAIRO, cairo >= $LIBCAIRO_REQUIRED) ---- a/SensorsApplet.xml -+++ b/SensorsApplet.xml -@@ -1,3 +1,10 @@ -- -- -- -+
-+ -+ _Help -+ sensors-applet.help -+ -+ -+ _About -+ sensors-applet.about -+ -+
---- a/sensors-applet/sensors-applet.c -+++ b/sensors-applet/sensors-applet.c -@@ -52,18 +52,18 @@ - #define DEFAULT_GRAPH_SIZE 42 - - /* callbacks for panel menu */ --static void about_cb(GtkAction *action, -- gpointer data, -- const gchar *verbname) { -+static void about_cb(GSimpleAction *action, -+ GVariant *parameter, -+ gpointer data) { - SensorsApplet *sensors_applet; - sensors_applet = (SensorsApplet *)data; - - about_dialog_open(sensors_applet); - } - --static void help_cb(GtkAction *action, -- gpointer data, -- const gchar *verbname) { -+static void help_cb(GSimpleAction *action, -+ GVariant *parameter, -+ gpointer data) { - - GError *error = NULL; - -@@ -193,13 +193,9 @@ - - } - --static const GtkActionEntry sensors_applet_menu_actions[] = { -- { "Help", GTK_STOCK_HELP, N_("_Help"), -- NULL, NULL, -- G_CALLBACK(help_cb) }, -- { "About", GTK_STOCK_ABOUT, N_("_About"), -- NULL, NULL, -- G_CALLBACK(about_cb) } -+static const GActionEntry sensors_applet_menu_actions[] = { -+ { "help", help_cb }, -+ { "about", about_cb } - }; - - #ifdef HAVE_LIBNOTIFY -@@ -1289,7 +1285,7 @@ - - void sensors_applet_init(SensorsApplet *sensors_applet) { - -- GtkActionGroup *action_group; -+ GSimpleActionGroup *action_group; - gchar *ui_path; - - g_assert(sensors_applet); -@@ -1334,15 +1330,16 @@ - } - - /* only do menu and signal connections if sensors are found */ -- action_group = gtk_action_group_new ("Sensors Applet Actions"); -- gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); -- gtk_action_group_add_actions (action_group, -+ action_group = g_simple_action_group_new (); -+ g_action_map_add_action_entries (G_ACTION_MAP (action_group), - sensors_applet_menu_actions, - G_N_ELEMENTS (sensors_applet_menu_actions), - sensors_applet); - ui_path = g_build_filename (UIDIR, SENSORS_APPLET_MENU_FILE, NULL); -- panel_applet_setup_menu_from_file (sensors_applet->applet, ui_path, action_group); -+ panel_applet_setup_menu_from_file (sensors_applet->applet, ui_path, action_group, GETTEXT_PACKAGE); - g_free (ui_path); -+ gtk_widget_insert_action_group (GTK_WIDGET (sensors_applet->applet), "sensors-applet", -+ G_ACTION_GROUP (action_group)); - g_object_unref (action_group); - - g_signal_connect(sensors_applet->applet, "style-set", ---- a/po/POTFILES.in -+++ b/po/POTFILES.in -@@ -17,3 +17,4 @@ - sensors-applet/sensor-config-dialog.c - sensors-applet/sensors-applet.c - sensors-applet/sensors-applet-gconf.c -+[type: gettext/glade]SensorsApplet.xml diff -Nru sensors-applet-3.0.0+git4/debian/patches/no-gconf.patch sensors-applet-3.0.0+git5/debian/patches/no-gconf.patch --- sensors-applet-3.0.0+git4/debian/patches/no-gconf.patch 2014-11-22 15:22:28.000000000 +0000 +++ sensors-applet-3.0.0+git5/debian/patches/no-gconf.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,371 +0,0 @@ -Description: drop all gconf usage, not allowed with new libpanel-applet -Author: Dmitry Shachnev -Last-Update: 2014-11-22 - ---- a/sensors-applet/Makefile.am -+++ b/sensors-applet/Makefile.am -@@ -27,8 +27,6 @@ - about-dialog.h \ - active-sensor.c \ - active-sensor.h \ -- prefs-dialog.c \ -- prefs-dialog.h \ - sensor-config-dialog.c \ - sensor-config-dialog.h \ - sensors-applet.c \ -@@ -36,8 +34,6 @@ - sensors-applet-sensor.h \ - sensors-applet-plugins.c \ - sensors-applet-plugins.h \ -- sensors-applet-gconf.c \ -- sensors-applet-gconf.h \ - $(libnotify_SRC) - - # install headers for plugins to use ---- a/sensors-applet/active-sensor.c -+++ b/sensors-applet/active-sensor.c -@@ -24,14 +24,14 @@ - #include - #endif /* HAVE_STRING_H */ - --#include - #include - #include - #include - - #include "active-sensor.h" - #include "sensors-applet-plugins.h" --#include "sensors-applet-gconf.h" -+ -+#define DEFAULT_GRAPH_SIZE 42 - - typedef enum { - VERY_LOW_SENSOR_VALUE = 0, -@@ -461,8 +461,7 @@ - - /* need to set size according to orientation */ - orient = panel_applet_get_orient(active_sensor->sensors_applet->applet); -- graph_size = panel_applet_gconf_get_int(active_sensor->sensors_applet->applet, -- GRAPH_SIZE, NULL); -+ graph_size = DEFAULT_GRAPH_SIZE; - - horizontal = ((orient == PANEL_APPLET_ORIENT_UP) || - (orient == PANEL_APPLET_ORIENT_DOWN)); -@@ -528,8 +527,6 @@ - gchar *tooltip = NULL; - gchar *value_tooltip = NULL; - -- /* hidden gconf options */ -- GConfClient *client; - gint font_size = 0; - gboolean hide_units = FALSE; - -@@ -585,28 +582,12 @@ - * note this is not unique */ - sensor_value = -1; - } else { -- /* use hidden gconf key for hide_units */ -- -- if ((client = gconf_client_get_default()) != NULL) { -- hide_units = gconf_client_get_bool(client, -- "/apps/sensors-applet/" HIDE_UNITS, -- &error); -- if (error) { -- g_debug("Could not get hide units from GConf - assuming false"); -- hide_units = FALSE; -- g_error_free(error); -- error = NULL; -- } -- -- g_object_unref(client); -- } -- - /* scale value and set text using this - * value */ - switch (sensor_type) { - case TEMP_SENSOR: - -- scale = (TemperatureScale)panel_applet_gconf_get_int(sensors_applet->applet, TEMPERATURE_SCALE, NULL); -+ scale = (TemperatureScale)CELSIUS; - /* scale value */ - sensor_value = sensors_applet_convert_temperature(sensor_value, - CELSIUS, -@@ -660,24 +641,8 @@ - g_free(value_tooltip); - - /* only do icons and labels / graphs if needed */ -- display_mode = panel_applet_gconf_get_int(sensors_applet->applet, -- DISPLAY_MODE, -- NULL); -- -- /* most users wont have a font size set */ -- if ((client = gconf_client_get_default()) != NULL) { -- font_size = gconf_client_get_int(client, -- "/apps/sensors-applet/" FONT_SIZE, -- &error); -- if (error) { -- g_debug("Could not get font size from GConf - assuming default size"); -- font_size = 0; -- g_error_free(error); -- error = NULL; -- } -+ display_mode = DISPLAY_ICON_WITH_VALUE; - -- g_object_unref(client); -- } - /* do icon if needed */ - if (display_mode == DISPLAY_ICON || - display_mode == DISPLAY_ICON_WITH_VALUE) { ---- a/sensors-applet/sensors-applet.c -+++ b/sensors-applet/sensors-applet.c -@@ -33,7 +33,6 @@ - #include - #include "sensors-applet.h" - #include "active-sensor.h" --#include "sensors-applet-gconf.h" - #include "sensors-applet-plugins.h" - - #ifdef HAVE_LIBNOTIFY -@@ -41,7 +40,6 @@ - #define DEFAULT_NOTIFY_TIMEOUT 3000 - #endif - --#include "prefs-dialog.h" - #include "about-dialog.h" - - #define SENSORS_APPLET_MENU_FILE "SensorsApplet.xml" -@@ -50,22 +48,10 @@ - * real value is stored */ - #define COLUMN_SPACING 2 - #define ROW_SPACING 1 -+#define DEFAULT_TIMEOUT 2000 -+#define DEFAULT_GRAPH_SIZE 42 - - /* callbacks for panel menu */ --static void prefs_cb(GtkAction *action, -- gpointer *data, -- const gchar *verbname) { -- -- SensorsApplet *sensors_applet; -- sensors_applet = (SensorsApplet *)data; -- -- if (sensors_applet->prefs_dialog) { -- gtk_window_present(GTK_WINDOW(sensors_applet->prefs_dialog->dialog)); -- return; -- } -- prefs_dialog_open(sensors_applet); --} -- - static void about_cb(GtkAction *action, - gpointer data, - const gchar *verbname) { -@@ -97,11 +83,6 @@ - - /* destory dialogs, remove timeout and clear sensors tree and finally - * the applet */ -- if (sensors_applet->prefs_dialog != NULL) { -- // destroy's dialog too -- prefs_dialog_close(sensors_applet); -- } -- - if (sensors_applet->timeout_id) { - g_source_remove(sensors_applet->timeout_id); - } -@@ -171,9 +152,7 @@ - - sensors_applet = (SensorsApplet *)data; - -- display_mode = panel_applet_gconf_get_int(sensors_applet->applet, -- DISPLAY_MODE, -- NULL); -+ display_mode = DISPLAY_ICON_WITH_VALUE; - if (sensors_applet->sensors) { - for (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter); not_end_of_interfaces; not_end_of_interfaces = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter)) { - -@@ -215,9 +194,6 @@ - } - - static const GtkActionEntry sensors_applet_menu_actions[] = { -- { "Preferences", GTK_STOCK_PROPERTIES, N_("_Preferences"), -- NULL, NULL, -- G_CALLBACK(prefs_cb) }, - { "Help", GTK_STOCK_HELP, N_("_Help"), - NULL, NULL, - G_CALLBACK(help_cb) }, -@@ -236,57 +212,6 @@ - } - #endif // HAVE_LIBNOTIFY - --void sensors_applet_notify(SensorsApplet *sensors_applet, -- NotifType notif_type) --{ --#ifdef HAVE_LIBNOTIFY -- gchar *message; -- gchar *summary; -- GError *error = NULL; -- g_assert(sensors_applet); -- -- if (!notify_is_initted()) { -- if (!notify_init(PACKAGE)) { -- return; -- } -- } -- -- if (sensors_applet->notification) { -- g_debug("notification already shown, not showing another one..."); -- return; -- } -- -- switch (notif_type) { -- case GCONF_READ_ERROR: -- summary = g_strdup_printf(_("Error restoring saved sensor configuration.")); -- message = g_strdup_printf(_("An error occurred while trying to restore the saved sensor configuration. The previous configuration has been lost and will need to be re-entered.")); -- break; -- -- case GCONF_WRITE_ERROR: -- summary = g_strdup_printf(_("Error saving sensor configuration.")); -- message = g_strdup_printf(_("An error occurred while trying to save the current sensor configuration. ")); -- break; -- } -- -- sensors_applet->notification = notify_notification_new(summary, -- message, -- GTK_STOCK_DIALOG_WARNING); -- g_free(summary); -- g_free(message); -- -- g_signal_connect(sensors_applet->notification, -- "closed", -- G_CALLBACK(notif_closed_cb), -- sensors_applet); -- g_debug("showing notification"); -- if (!notify_notification_show(sensors_applet->notification, &error)) { -- g_debug("Error showing notification: %s", error->message); -- g_error_free(error); -- } --#endif // HAVE_LIBNOTIFY --} -- -- - void sensors_applet_notify_active_sensor(ActiveSensor *active_sensor, NotifType notif_type) { - #ifdef HAVE_LIBNOTIFY - -@@ -310,13 +235,6 @@ - - sensors_applet = active_sensor->sensors_applet; - -- if (!panel_applet_gconf_get_bool(sensors_applet->applet, -- DISPLAY_NOTIFICATIONS, -- NULL)) { -- g_debug("Wanted to display notification, but user has disabled them"); -- return; -- } -- - table_children = gtk_container_get_children(GTK_CONTAINER(sensors_applet->table)); - - if (g_list_find(table_children, active_sensor->icon)) { -@@ -374,9 +292,7 @@ - case TEMP_SENSOR: - unit_type_title = _("Temperature"); - unit_type = _("temperature"); -- temp_scale = (TemperatureScale)panel_applet_gconf_get_int(active_sensor->sensors_applet->applet, -- TEMPERATURE_SCALE, -- NULL); -+ temp_scale = (TemperatureScale)CELSIUS; - - switch (temp_scale) { - case CELSIUS: -@@ -420,9 +336,7 @@ - case SENSOR_INTERFACE_ERROR: - summary = g_strdup_printf(_("Error updating sensor %s"), sensor_label); - message = g_strdup_printf(_("An error occurred while trying to update the value of the sensor %s located at %s."), sensor_label, sensor_path); -- timeout_msecs = panel_applet_gconf_get_int(active_sensor->sensors_applet->applet, -- TIMEOUT, -- NULL); -+ timeout_msecs = DEFAULT_TIMEOUT; - - break; - -@@ -564,10 +478,8 @@ - /* otherwise can acess active_sensors without any worries */ - num_active_sensors = g_list_length(sensors_applet->active_sensors); - -- display_mode = (DisplayMode)panel_applet_gconf_get_int(sensors_applet->applet, -- DISPLAY_MODE, NULL); -- layout_mode = (LayoutMode)panel_applet_gconf_get_int(sensors_applet->applet, -- LAYOUT_MODE, NULL); -+ display_mode = (DisplayMode)DISPLAY_ICON_WITH_VALUE; -+ layout_mode = (LayoutMode)VALUE_BESIDE_LABEL; - - - horizontal = (((panel_applet_get_orient(sensors_applet->applet) == PANEL_APPLET_ORIENT_UP) || -@@ -1309,9 +1221,7 @@ - - if (sensors_applet->active_sensors) { - -- graph_size = panel_applet_gconf_get_int(sensors_applet->applet, -- GRAPH_SIZE, -- NULL); -+ graph_size = DEFAULT_GRAPH_SIZE; - if (panel_applet_get_orient(sensors_applet->applet) == - PANEL_APPLET_ORIENT_UP || - panel_applet_get_orient(sensors_applet->applet) == -@@ -1410,9 +1320,6 @@ - sensors_applet); - - -- /* if not setup, write defaults to gconf */ -- sensors_applet_gconf_setup(sensors_applet); -- - /* now do any setup needed manually */ - sensors_applet_plugins_load_all(sensors_applet); - -@@ -1455,7 +1362,7 @@ - sensors_applet_update_active_sensors(sensors_applet); - sensors_applet_pack_display(sensors_applet); - -- sensors_applet->timeout_id = g_timeout_add_seconds(panel_applet_gconf_get_int(sensors_applet->applet, TIMEOUT, NULL) / 1000, -+ sensors_applet->timeout_id = g_timeout_add_seconds(DEFAULT_TIMEOUT / 1000, - (GSourceFunc)sensors_applet_update_active_sensors, - sensors_applet); - gtk_widget_show_all(GTK_WIDGET(sensors_applet->applet)); ---- a/sensors-applet/sensors-applet.h -+++ b/sensors-applet/sensors-applet.h -@@ -33,8 +33,6 @@ - - typedef struct _ActiveSensor ActiveSensor; - --#include "prefs-dialog.h" -- - #define GRAPH_FRAME_EXTRA_WIDTH 6 - #define SENSORS_APPLET_ICON "sensors-applet" - -@@ -110,8 +108,6 @@ - LOW_ALARM = 0, - HIGH_ALARM, - SENSOR_INTERFACE_ERROR, -- GCONF_READ_ERROR, -- GCONF_WRITE_ERROR, - NUM_NOTIFS - } NotifType; - -@@ -130,8 +126,6 @@ - GHashTable *plugins; - - guint timeout_id; -- /* preferences and about windows (if Gtk < 2.6)*/ -- PrefsDialog *prefs_dialog; - - /* primary table to contain the panel dispay - we pack the - * list of labels and sensor values into this container */ ---- a/sensors-applet/sensor-config-dialog.c -+++ b/sensors-applet/sensor-config-dialog.c -@@ -397,7 +397,7 @@ - header_text = g_strdup_printf("%s - %s", _("Sensor Properties"), sensor_label); - - config_dialog->dialog = gtk_dialog_new_with_buttons(header_text, -- GTK_WINDOW(sensors_applet->prefs_dialog->dialog), -+ NULL, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_HELP, - GTK_RESPONSE_HELP, diff -Nru sensors-applet-3.0.0+git4/debian/patches/series sensors-applet-3.0.0+git5/debian/patches/series --- sensors-applet-3.0.0+git4/debian/patches/series 2014-11-22 14:40:53.000000000 +0000 +++ sensors-applet-3.0.0+git5/debian/patches/series 2015-06-25 09:16:39.000000000 +0000 @@ -1,3 +1 @@ enable-deprecated.patch -no-gconf.patch -libpanel-applet.patch diff -Nru sensors-applet-3.0.0+git4/po/POTFILES.in sensors-applet-3.0.0+git5/po/POTFILES.in --- sensors-applet-3.0.0+git4/po/POTFILES.in 2013-03-06 09:32:25.000000000 +0000 +++ sensors-applet-3.0.0+git5/po/POTFILES.in 2015-06-17 22:13:32.000000000 +0000 @@ -16,4 +16,5 @@ sensors-applet/about-dialog.c sensors-applet/sensor-config-dialog.c sensors-applet/sensors-applet.c -sensors-applet/sensors-applet-gconf.c +sensors-applet/sensors-applet-conf.c +[type: gettext/glade]SensorsApplet.xml diff -Nru sensors-applet-3.0.0+git4/sensors-applet/active-sensor.c sensors-applet-3.0.0+git5/sensors-applet/active-sensor.c --- sensors-applet-3.0.0+git4/sensors-applet/active-sensor.c 2013-03-06 09:32:25.000000000 +0000 +++ sensors-applet-3.0.0+git5/sensors-applet/active-sensor.c 2015-06-17 22:13:32.000000000 +0000 @@ -24,14 +24,13 @@ #include #endif /* HAVE_STRING_H */ -#include #include #include #include #include "active-sensor.h" #include "sensors-applet-plugins.h" -#include "sensors-applet-gconf.h" +#include "sensors-applet-conf.h" typedef enum { VERY_LOW_SENSOR_VALUE = 0, @@ -81,18 +80,21 @@ GPid pid; sensors_applet_notify_active_sensor(active_sensor, notif_type); - g_debug("EXECUTING %s ALARM: %s", - (notif_type == LOW_ALARM ? - "LOW" : "HIGH"), - active_sensor->alarm_command[notif_type]); - g_shell_parse_argv(active_sensor->alarm_command[notif_type], - &argc, &argv, NULL); - ret = g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, - NULL, &pid, NULL); - g_strfreev (argv); - g_debug("Command executed in shell with pid %d", pid); + if (strlen(active_sensor->alarm_command[notif_type])) { + g_debug("EXECUTING %s ALARM: %s", + (notif_type == LOW_ALARM ? + "LOW" : "HIGH"), + active_sensor->alarm_command[notif_type]); + g_shell_parse_argv(active_sensor->alarm_command[notif_type], + &argc, &argv, NULL); + ret = g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, + NULL, &pid, NULL); + g_strfreev (argv); + g_debug("Command executed in shell with pid %d", pid); - return ret; + return ret; + } + return FALSE; } static gboolean active_sensor_execute_low_alarm(ActiveSensor *active_sensor) { @@ -438,6 +440,7 @@ active_sensor = g_new0(ActiveSensor, 1); active_sensor->sensors_applet = sensors_applet; + active_sensor->sensors_applet->settings = panel_applet_settings_new (sensors_applet->applet, SENSORS_APPLET_SCHEMA); active_sensor->sensor_row = sensor_row; @@ -461,8 +464,8 @@ /* need to set size according to orientation */ orient = panel_applet_get_orient(active_sensor->sensors_applet->applet); - graph_size = panel_applet_gconf_get_int(active_sensor->sensors_applet->applet, - GRAPH_SIZE, NULL); + graph_size = g_settings_get_double(active_sensor->sensors_applet->settings, + GRAPH_SIZE); horizontal = ((orient == PANEL_APPLET_ORIENT_UP) || (orient == PANEL_APPLET_ORIENT_DOWN)); @@ -496,7 +499,7 @@ void active_sensor_update(ActiveSensor *active_sensor, SensorsApplet *sensors_applet) { - GtkTreeModel *model; + GtkTreeModel *model; GtkTreeIter iter; GtkTreePath *path; @@ -529,13 +532,13 @@ gchar *value_tooltip = NULL; /* hidden gconf options */ - GConfClient *client; + GSettings *settings; gint font_size = 0; gboolean hide_units = FALSE; g_assert(active_sensor); g_assert(active_sensor->sensor_row); - g_assert(sensors_applet); + g_assert(sensors_applet); model = gtk_tree_row_reference_get_model(active_sensor->sensor_row); path = gtk_tree_row_reference_get_path(active_sensor->sensor_row); @@ -560,8 +563,7 @@ GRAPH_COLOR_COLUMN, &graph_color, -1); - - SensorsAppletPluginGetSensorValue get_sensor_value; + SensorsAppletPluginGetSensorValue get_sensor_value; /* only call function if is in hash table for plugin */ if ((get_sensor_value = sensors_applet_plugins_get_sensor_value_func(sensors_applet, sensor_interface)) != NULL) { sensor_value = get_sensor_value(sensor_path, @@ -581,38 +583,26 @@ g_error_free(error); error = NULL; - /* set sensor value to an error code - + /* set sensor value to an error code - * note this is not unique */ - sensor_value = -1; + sensor_value = -1; } else { - /* use hidden gconf key for hide_units */ - - if ((client = gconf_client_get_default()) != NULL) { - hide_units = gconf_client_get_bool(client, - "/apps/sensors-applet/" HIDE_UNITS, - &error); - if (error) { - g_debug("Could not get hide units from GConf - assuming false"); - hide_units = FALSE; - g_error_free(error); - error = NULL; - } - - g_object_unref(client); - } + /* use hidden config key for hide_units */ + hide_units = g_settings_get_boolean(sensors_applet->settings, HIDE_UNITS); - /* scale value and set text using this + /* scale value and set text using this * value */ switch (sensor_type) { case TEMP_SENSOR: - scale = (TemperatureScale)panel_applet_gconf_get_int(sensors_applet->applet, TEMPERATURE_SCALE, NULL); - /* scale value */ + scale = (TemperatureScale)g_settings_get_int(sensors_applet->settings, TEMPERATURE_SCALE); + /* scale value */ sensor_value = sensors_applet_convert_temperature(sensor_value, - CELSIUS, - scale); + CELSIUS, + scale); - sensor_value = (sensor_value * sensor_multiplier) + sensor_offset; + + sensor_value = (sensor_value * sensor_multiplier) + sensor_offset; switch (scale) { case FAHRENHEIT: value_text = g_strdup_printf("%2.0f %s", sensor_value, (hide_units ? "" : UNITS_FAHRENHEIT)); @@ -659,27 +649,15 @@ tooltip = g_strdup_printf("%s %s", sensor_label, value_tooltip); g_free(value_tooltip); - /* only do icons and labels / graphs if needed */ - display_mode = panel_applet_gconf_get_int(sensors_applet->applet, - DISPLAY_MODE, - NULL); - - /* most users wont have a font size set */ - if ((client = gconf_client_get_default()) != NULL) { - font_size = gconf_client_get_int(client, - "/apps/sensors-applet/" FONT_SIZE, - &error); - if (error) { - g_debug("Could not get font size from GConf - assuming default size"); - font_size = 0; - g_error_free(error); - error = NULL; - } + /* only do icons and labels / graphs if needed */ + display_mode = g_settings_get_int(sensors_applet->settings, + DISPLAY_MODE); - g_object_unref(client); - } - /* do icon if needed */ - if (display_mode == DISPLAY_ICON || + /* most users wont have a font size set */ + font_size = g_settings_get_int(sensors_applet->settings, FONT_SIZE); + + /* do icon if needed */ + if (display_mode == DISPLAY_ICON || display_mode == DISPLAY_ICON_WITH_VALUE) { /* update icon if icon range has changed if no * update has been done before */ @@ -727,9 +705,9 @@ active_sensor_alarm_on(active_sensor, HIGH_ALARM); } - if (sensor_value <= sensor_low_value) { - active_sensor_alarm_on(active_sensor, LOW_ALARM); - } + if (sensor_value <= sensor_low_value) { + active_sensor_alarm_on(active_sensor, LOW_ALARM); + } } else { /* make sure alarms are off */ @@ -772,24 +750,24 @@ gtk_widget_set_tooltip_text(active_sensor->label, tooltip); - } + } - g_free(tooltip); + g_free(tooltip); } else { - g_debug("no get_sensor_value function yet installed for interface %s.", sensor_interface); + g_debug("no get_sensor_value function yet installed for interface %s.", sensor_interface); } g_free(sensor_path); g_free(sensor_id); g_free(sensor_label); - g_free(sensor_interface); - g_free(graph_color); + g_free(sensor_interface); + g_free(graph_color); g_object_unref(icon_pixbuf); } else { g_debug("Error getting iter when updating sensor..."); } - active_sensor->updated = TRUE; + active_sensor->updated = TRUE; } diff -Nru sensors-applet-3.0.0+git4/sensors-applet/main.c sensors-applet-3.0.0+git5/sensors-applet/main.c --- sensors-applet-3.0.0+git4/sensors-applet/main.c 2013-03-06 09:32:25.000000000 +0000 +++ sensors-applet-3.0.0+git5/sensors-applet/main.c 2015-06-17 22:13:32.000000000 +0000 @@ -30,7 +30,7 @@ SensorsApplet *sensors_applet; gboolean retval = FALSE; - if (strcmp(iid, "SensorsApplet") == 0) { + if (strcmp(iid, "SensorsApplet") == 0) { sensors_applet = g_new0(SensorsApplet, 1); sensors_applet->applet = applet; sensors_applet_init(sensors_applet); diff -Nru sensors-applet-3.0.0+git4/sensors-applet/Makefile.am sensors-applet-3.0.0+git5/sensors-applet/Makefile.am --- sensors-applet-3.0.0+git4/sensors-applet/Makefile.am 2013-03-06 09:32:25.000000000 +0000 +++ sensors-applet-3.0.0+git5/sensors-applet/Makefile.am 2015-06-17 22:13:32.000000000 +0000 @@ -36,8 +36,8 @@ sensors-applet-sensor.h \ sensors-applet-plugins.c \ sensors-applet-plugins.h \ - sensors-applet-gconf.c \ - sensors-applet-gconf.h \ + sensors-applet-conf.c \ + sensors-applet-conf.h \ $(libnotify_SRC) # install headers for plugins to use @@ -47,5 +47,18 @@ header_DATA = $(INST_H_FILES) +gsettings_schemas_in_in = \ + org.gnome.sensors-applet.gschema.xml.in.in + +@INTLTOOL_XML_NOMERGE_RULE@ + +gsettings_schemas_in = $(gsettings_schemas_in_in:.xml.in.in=.xml.in) +gsettings_SCHEMAS = $(gsettings_schemas_in:.xml.in=.xml) + +%.gschema.xml.in: %.gschema.xml.in.in Makefile + $(AM_V_GEN) $(SED) -e 's^\@GETTEXT_PACKAGE\@^$(GETTEXT_PACKAGE)^g' < $< > $@ + +@GSETTINGS_RULES@ + # since it is separate EXTRA_DIST = sensors-applet-plugin.h diff -Nru sensors-applet-3.0.0+git4/sensors-applet/org.gnome.sensors-applet.gschema.xml.in.in sensors-applet-3.0.0+git5/sensors-applet/org.gnome.sensors-applet.gschema.xml.in.in --- sensors-applet-3.0.0+git4/sensors-applet/org.gnome.sensors-applet.gschema.xml.in.in 1970-01-01 00:00:00.000000000 +0000 +++ sensors-applet-3.0.0+git5/sensors-applet/org.gnome.sensors-applet.gschema.xml.in.in 2015-06-17 22:13:32.000000000 +0000 @@ -0,0 +1,69 @@ + + + + false + Configuration in-place and active + A flag indicating program has been configured. + + + false + Hide temperature units + Hide temperature units. + + + 10 + Size of the sensors text + Sensors font size. + + + 0 + Sensors info refresh time + How often sensors info is retreived. + + + 0 + Sensors display mode + Icon/label sensors display. + + + false + Print sensors notifications + Prints out notifications about sensors status or alerts. + + + 0 + Sensors layout mode + Orientation of sensors label in regard to icons. + + + 0 + Temperature scale + For temperature related sensors sets the displaying of temperature. + + + 0 + Graph width + Width of the senors graph. + + + false + + + + + false + + + + + "" + Version of the configuration + Binds the config settings to the program version. + + + [] + Array holding sensors data + Serialized data of the sensors info. + + + diff -Nru sensors-applet-3.0.0+git4/sensors-applet/prefs-dialog.c sensors-applet-3.0.0+git5/sensors-applet/prefs-dialog.c --- sensors-applet-3.0.0+git4/sensors-applet/prefs-dialog.c 2013-03-06 09:32:25.000000000 +0000 +++ sensors-applet-3.0.0+git5/sensors-applet/prefs-dialog.c 2015-06-17 22:13:32.000000000 +0000 @@ -21,7 +21,7 @@ #endif /* HAVE_CONFIG_H */ #include -#include "sensors-applet-gconf.h" +#include "sensors-applet-conf.h" #include "prefs-dialog.h" #include "sensor-config-dialog.h" @@ -29,14 +29,14 @@ #define NEW_TEMP_SCALE 1 /* when a user closes the prefs-dialog we assume that applet is now - setup, so store all values in gconf */ + setup, so store all values in confg backend */ void prefs_dialog_close(SensorsApplet *sensors_applet) { - if (sensors_applet->sensors != NULL) { - if (sensors_applet_gconf_save_sensors(sensors_applet)) - panel_applet_gconf_set_bool(sensors_applet->applet, - IS_SETUP, TRUE, NULL); - } + if (sensors_applet->sensors != NULL) { + if (sensors_applet_conf_save_sensors(sensors_applet)) + g_settings_set_boolean(sensors_applet->settings, + IS_SETUP, TRUE); + } if (sensors_applet->prefs_dialog) { gtk_widget_destroy(GTK_WIDGET(sensors_applet->prefs_dialog->dialog)); g_free(sensors_applet->prefs_dialog); @@ -44,7 +44,9 @@ } if (sensors_applet->timeout_id == 0) { - sensors_applet->timeout_id = g_timeout_add_seconds(panel_applet_gconf_get_int(sensors_applet->applet, TIMEOUT, NULL) / 1000, (GSourceFunc)sensors_applet_update_active_sensors, sensors_applet); + sensors_applet->timeout_id = g_timeout_add_seconds( + g_settings_get_int(sensors_applet->settings, TIMEOUT) / 1000, + (GSourceFunc)sensors_applet_update_active_sensors, sensors_applet); } @@ -125,7 +127,7 @@ PrefsDialog *prefs_dialog) { gint value; value = (gint)(gtk_spin_button_get_value(button) * 1000); - panel_applet_gconf_set_int(prefs_dialog->sensors_applet->applet, TIMEOUT, value, NULL); + g_settings_set_int(prefs_dialog->sensors_applet->settings, TIMEOUT, value); } static void prefs_dialog_display_mode_changed(GtkComboBox *display_mode_combo_box, @@ -149,10 +151,9 @@ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->graph_size_spinbutton), (display_mode == DISPLAY_GRAPH)); - panel_applet_gconf_set_int(prefs_dialog->sensors_applet->applet, + g_settings_set_int(prefs_dialog->sensors_applet->settings, DISPLAY_MODE, - gtk_combo_box_get_active(display_mode_combo_box), - NULL); + gtk_combo_box_get_active(display_mode_combo_box)); sensors_applet_display_layout_changed(prefs_dialog->sensors_applet); } @@ -160,10 +161,9 @@ static void prefs_dialog_layout_mode_changed(GtkComboBox *layout_mode_combo_box, PrefsDialog *prefs_dialog) { - panel_applet_gconf_set_int(prefs_dialog->sensors_applet->applet, + g_settings_set_int(prefs_dialog->sensors_applet->settings, LAYOUT_MODE, - gtk_combo_box_get_active(layout_mode_combo_box), - NULL); + gtk_combo_box_get_active(layout_mode_combo_box)); sensors_applet_display_layout_changed(prefs_dialog->sensors_applet); } @@ -175,16 +175,14 @@ TemperatureScale scales[2]; GtkTreeModel *model; - scales[OLD_TEMP_SCALE] = (TemperatureScale)panel_applet_gconf_get_int(prefs_dialog->sensors_applet->applet, - TEMPERATURE_SCALE, - NULL); + scales[OLD_TEMP_SCALE] = (TemperatureScale)g_settings_get_int(prefs_dialog->sensors_applet->settings, + TEMPERATURE_SCALE); scales[NEW_TEMP_SCALE] = (TemperatureScale)gtk_combo_box_get_active(temperature_scale_combo_box); - panel_applet_gconf_set_int(prefs_dialog->sensors_applet->applet, + g_settings_set_int(prefs_dialog->sensors_applet->settings, TEMPERATURE_SCALE, - scales[NEW_TEMP_SCALE], - NULL); + scales[NEW_TEMP_SCALE]); /* now go thru and convert all low and high sensor values in * the tree to either celcius or Fahrenheit */ @@ -205,10 +203,9 @@ gboolean notify; notify = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(display_notifications)); - panel_applet_gconf_set_bool(prefs_dialog->sensors_applet->applet, + g_settings_set_boolean(prefs_dialog->sensors_applet->settings, DISPLAY_NOTIFICATIONS, - notify, - NULL); + notify); if (notify) { sensors_applet_update_active_sensors(prefs_dialog->sensors_applet); @@ -222,7 +219,7 @@ PrefsDialog *prefs_dialog) { gint value; value = (gint)(gtk_spin_button_get_value(button)); - panel_applet_gconf_set_int(prefs_dialog->sensors_applet->applet, GRAPH_SIZE, value, NULL); + g_settings_set_double(prefs_dialog->sensors_applet->settings, GRAPH_SIZE, value); /* notify change of number of samples */ sensors_applet_graph_size_changed(prefs_dialog->sensors_applet); @@ -337,7 +334,7 @@ static void prefs_dialog_sensor_config_button_clicked(GtkButton *button, PrefsDialog *prefs_dialog) { - sensor_config_dialog_create(prefs_dialog->sensors_applet); + sensor_config_dialog_create(prefs_dialog->sensors_applet); } @@ -413,20 +410,20 @@ prefs_dialog->sensors_applet = sensors_applet; - prefs_dialog->dialog = GTK_DIALOG(gtk_dialog_new_with_buttons(_("Sensors Applet Preferences"), - NULL, 0, - GTK_STOCK_HELP, - GTK_RESPONSE_HELP, - GTK_STOCK_CLOSE, - GTK_RESPONSE_CLOSE, - NULL)); - gtk_window_set_icon_name(GTK_WINDOW(prefs_dialog->dialog), - "sensors-applet"); - g_object_set(prefs_dialog->dialog, - "border-width", 12, - "default-width", 480, - "default-height", 350, - NULL); + prefs_dialog->dialog = GTK_DIALOG(gtk_dialog_new_with_buttons(_("Sensors Applet Preferences"), + NULL, 0, + _("_Help"), + GTK_RESPONSE_HELP, + _("_Close"), + GTK_RESPONSE_CLOSE, + NULL)); + gtk_window_set_icon_name(GTK_WINDOW(prefs_dialog->dialog), + "sensors-applet"); + g_object_set(prefs_dialog->dialog, + "border-width", 12, + "default-width", 480, + "default-height", 350, + NULL); content_area = gtk_dialog_get_content_area (prefs_dialog->dialog); gtk_box_set_homogeneous(GTK_BOX(content_area), FALSE); @@ -483,7 +480,7 @@ GTK_COMBO_BOX_TEXT(prefs_dialog->display_mode_combo_box), _("graph only")); - display_mode = panel_applet_gconf_get_int(sensors_applet->applet, DISPLAY_MODE, NULL); + display_mode = g_settings_get_int(sensors_applet->settings, DISPLAY_MODE); gtk_combo_box_set_active(prefs_dialog->display_mode_combo_box, display_mode); g_signal_connect(prefs_dialog->display_mode_combo_box, @@ -516,7 +513,8 @@ gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT(prefs_dialog->layout_mode_combo_box), _("below labels / icons")); - gtk_combo_box_set_active(prefs_dialog->layout_mode_combo_box, panel_applet_gconf_get_int(sensors_applet->applet, LAYOUT_MODE, NULL)); + gtk_combo_box_set_active(prefs_dialog->layout_mode_combo_box, + g_settings_get_int(sensors_applet->settings, LAYOUT_MODE)); g_signal_connect(prefs_dialog->layout_mode_combo_box, "changed", @@ -546,7 +544,7 @@ gtk_combo_box_set_active( prefs_dialog->temperature_scale_combo_box, - panel_applet_gconf_get_int(sensors_applet->applet, TEMPERATURE_SCALE, NULL)); + g_settings_get_int(sensors_applet->settings, TEMPERATURE_SCALE)); g_signal_connect(prefs_dialog->temperature_scale_combo_box, "changed", @@ -560,26 +558,23 @@ "xalign", 0.0, NULL); - prefs_dialog->graph_size_adjust = g_object_new(GTK_TYPE_ADJUSTMENT, - "value", (gdouble)panel_applet_gconf_get_int(sensors_applet->applet, - GRAPH_SIZE, - NULL), - "lower", 1.0, - "upper", 100.0, - "step-increment", 1.0, - "page-increment", 10.0, - "page-size", 0.0, - NULL); - - prefs_dialog->graph_size_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON, - "adjustment", prefs_dialog->graph_size_adjust, - "climb-rate", 1.0, - "digits", 0, - "value", (gdouble)panel_applet_gconf_get_int(sensors_applet->applet, - GRAPH_SIZE, - NULL), - "width-chars", 4, - NULL); + prefs_dialog->graph_size_adjust = g_object_new(GTK_TYPE_ADJUSTMENT, + "value", g_settings_get_double(sensors_applet->settings,GRAPH_SIZE), + "lower", 1.0, + "upper", 100.0, + "step-increment", 1.0, + "page-increment", 10.0, + "page-size", 0.0, + NULL); + + prefs_dialog->graph_size_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON, + "adjustment", prefs_dialog->graph_size_adjust, + "climb-rate", 1.0, + "digits", 0, + "value", g_settings_get_double(sensors_applet->settings, + GRAPH_SIZE), + "width-chars", 4, + NULL); gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->graph_size_spinbutton), (display_mode == DISPLAY_GRAPH)); @@ -622,7 +617,7 @@ "adjustment", prefs_dialog->timeout_adjust, "climb-rate", 0.5, "digits", 1, - "value", (gdouble) panel_applet_gconf_get_int(sensors_applet->applet, TIMEOUT, NULL) / 1000.0, + "value", g_settings_get_int(sensors_applet->settings, TIMEOUT) / 1000.0, "width-chars", 4, NULL); @@ -653,9 +648,8 @@ "label", _("Display _notifications"), NULL); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_dialog->display_notifications), - panel_applet_gconf_get_bool(sensors_applet->applet, - DISPLAY_NOTIFICATIONS, - NULL)); + g_settings_get_boolean(sensors_applet->settings, + DISPLAY_NOTIFICATIONS)); g_signal_connect(prefs_dialog->display_notifications, "toggled", G_CALLBACK(prefs_dialog_display_notifications_toggled), @@ -905,14 +899,18 @@ activated */ /* Create buttons for user to interact with sensors tree */ - prefs_dialog->sensor_up_button = GTK_BUTTON(gtk_button_new_from_stock(GTK_STOCK_GO_UP)); + prefs_dialog->sensor_up_button = GTK_BUTTON(gtk_button_new_with_label(_("Up"))); + gtk_button_set_image(GTK_BUTTON(prefs_dialog->sensor_up_button), + gtk_image_new_from_icon_name("go-up", GTK_ICON_SIZE_BUTTON)); gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_up_button), FALSE); g_signal_connect(prefs_dialog->sensor_up_button, "clicked", G_CALLBACK(prefs_dialog_sensor_up_button_clicked), prefs_dialog); - prefs_dialog->sensor_down_button = GTK_BUTTON(gtk_button_new_from_stock(GTK_STOCK_GO_DOWN)); + prefs_dialog->sensor_down_button = GTK_BUTTON(gtk_button_new_with_label(_("Down"))); + gtk_button_set_image(GTK_BUTTON(prefs_dialog->sensor_down_button), + gtk_image_new_from_icon_name("go-down", GTK_ICON_SIZE_BUTTON)); gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_down_button), FALSE); g_signal_connect(prefs_dialog->sensor_down_button, "clicked", @@ -941,86 +939,87 @@ TRUE, TRUE, 0); /* make sure window takes * up most of room */ - gtk_box_pack_start(prefs_dialog->sensors_hbox, - GTK_WIDGET(prefs_dialog->buttons_box), - FALSE, FALSE, 0); + gtk_box_pack_start(prefs_dialog->sensors_hbox, + GTK_WIDGET(prefs_dialog->buttons_box), + FALSE, FALSE, 0); - /* Sensor Config button */ - /* initially make button insensitive until user selects a row + /* Sensor Config button */ + /* initially make button insensitive until user selects a row from the sensors tree */ - prefs_dialog->sensor_config_button = GTK_BUTTON(gtk_button_new_from_stock(GTK_STOCK_PROPERTIES)); - g_object_set(prefs_dialog->sensor_config_button, - "sensitive", FALSE, - NULL); + prefs_dialog->sensor_config_button = GTK_BUTTON(gtk_button_new_with_label(_("Properties"))); + gtk_button_set_image(GTK_BUTTON(prefs_dialog->sensor_config_button), + gtk_image_new_from_icon_name("document-properties", GTK_ICON_SIZE_BUTTON)); + g_object_set(prefs_dialog->sensor_config_button, + "sensitive", FALSE, + NULL); - g_signal_connect(sensors_applet->selection, - "changed", - G_CALLBACK(prefs_dialog_selection_changed), - prefs_dialog); + g_signal_connect(sensors_applet->selection, + "changed", + G_CALLBACK(prefs_dialog_selection_changed), + prefs_dialog); - /* pass selection to signal handler so we can give user a + /* pass selection to signal handler so we can give user a sensors_applet->prefs_dialog with the selected rows alarm value and enable */ - g_signal_connect(prefs_dialog->sensor_config_button, "clicked", - G_CALLBACK(prefs_dialog_sensor_config_button_clicked), - prefs_dialog); - - prefs_dialog->sensor_config_hbox = g_object_new(GTK_TYPE_BOX, - "orientation", GTK_ORIENTATION_HORIZONTAL, - "border-width", 5, - "homogeneous", FALSE, - "spacing", 0, - NULL); - gtk_box_pack_end(prefs_dialog->sensor_config_hbox, - GTK_WIDGET(prefs_dialog->sensor_config_button), - FALSE, FALSE, 0); - - /* pack sensors_vbox */ - prefs_dialog->sensors_vbox = g_object_new(GTK_TYPE_BOX, - "orientation", GTK_ORIENTATION_VERTICAL, - "border-width", 5, - "homogeneous", FALSE, - "spacing", 0, - NULL); - - gtk_box_pack_start(prefs_dialog->sensors_vbox, - GTK_WIDGET(prefs_dialog->sensors_hbox), - TRUE, TRUE, 0); - gtk_box_pack_start(prefs_dialog->sensors_vbox, - GTK_WIDGET(prefs_dialog->sensor_config_hbox), - FALSE, FALSE, 0); - - prefs_dialog->globals_alignment = g_object_new(GTK_TYPE_ALIGNMENT, - "xalign", 0.5, - "yalign", 0.0, - "top-padding", 12, - "left-padding", 12, - "bottom-padding", 12, - "right-padding", 12, - NULL); - gtk_container_add(GTK_CONTAINER(prefs_dialog->globals_alignment), - GTK_WIDGET(prefs_dialog->globals_table)); - - prefs_dialog->notebook = g_object_new(GTK_TYPE_NOTEBOOK, - NULL); - - gtk_notebook_append_page(prefs_dialog->notebook, - GTK_WIDGET(prefs_dialog->globals_alignment), - gtk_label_new(_("General Options"))); - - gtk_notebook_append_page(prefs_dialog->notebook, - GTK_WIDGET(prefs_dialog->sensors_vbox), - gtk_label_new(_("Sensors"))); + g_signal_connect(prefs_dialog->sensor_config_button, "clicked", + G_CALLBACK(prefs_dialog_sensor_config_button_clicked), + prefs_dialog); + + prefs_dialog->sensor_config_hbox = g_object_new(GTK_TYPE_BOX, + "orientation", GTK_ORIENTATION_HORIZONTAL, + "border-width", 5, + "homogeneous", FALSE, + "spacing", 0, + NULL); + gtk_box_pack_end(prefs_dialog->sensor_config_hbox, + GTK_WIDGET(prefs_dialog->sensor_config_button), + FALSE, FALSE, 0); + + /* pack sensors_vbox */ + prefs_dialog->sensors_vbox = g_object_new(GTK_TYPE_BOX, + "orientation", GTK_ORIENTATION_VERTICAL, + "border-width", 5, + "homogeneous", FALSE, + "spacing", 0, + NULL); + + gtk_box_pack_start(prefs_dialog->sensors_vbox, + GTK_WIDGET(prefs_dialog->sensors_hbox), + TRUE, TRUE, 0); + gtk_box_pack_start(prefs_dialog->sensors_vbox, + GTK_WIDGET(prefs_dialog->sensor_config_hbox), + FALSE, FALSE, 0); + + prefs_dialog->globals_box = g_object_new(GTK_TYPE_BOX, + "xalign", 0.5, + "yalign", 0.0, + "top-padding", 12, + "left-padding", 12, + "bottom-padding", 12, + "right-padding", 12, + NULL); + gtk_container_add(GTK_CONTAINER(prefs_dialog->globals_box), + GTK_WIDGET(prefs_dialog->globals_table)); + + prefs_dialog->notebook = g_object_new(GTK_TYPE_NOTEBOOK, NULL); + + gtk_notebook_append_page(prefs_dialog->notebook, + GTK_WIDGET(prefs_dialog->globals_box), + gtk_label_new(_("General Options"))); + + gtk_notebook_append_page(prefs_dialog->notebook, + GTK_WIDGET(prefs_dialog->sensors_vbox), + gtk_label_new(_("Sensors"))); content_area = gtk_dialog_get_content_area (prefs_dialog->dialog); - /* pack notebook into prefs_dialog */ - gtk_box_pack_start(GTK_BOX(content_area), - GTK_WIDGET(prefs_dialog->notebook), - FALSE, FALSE, - 0); + /* pack notebook into prefs_dialog */ + gtk_box_pack_start(GTK_BOX(content_area), + GTK_WIDGET(prefs_dialog->notebook), + FALSE, FALSE, + 0); - gtk_widget_show_all(GTK_WIDGET(prefs_dialog->dialog)); + gtk_widget_show_all(GTK_WIDGET(prefs_dialog->dialog)); } diff -Nru sensors-applet-3.0.0+git4/sensors-applet/prefs-dialog.h sensors-applet-3.0.0+git5/sensors-applet/prefs-dialog.h --- sensors-applet-3.0.0+git4/sensors-applet/prefs-dialog.h 2013-03-06 09:32:25.000000000 +0000 +++ sensors-applet-3.0.0+git5/sensors-applet/prefs-dialog.h 2015-06-17 22:13:32.000000000 +0000 @@ -24,6 +24,7 @@ #endif #include "sensors-applet.h" +#include typedef struct { SensorsApplet *sensors_applet; @@ -52,7 +53,7 @@ GtkButtonBox *buttons_box; /* holds sensor reorder buttons */ GtkBox *sensors_hbox; /* holds scrolled window and * buttons_vbox */ - GtkAlignment *globals_alignment; + GtkBox *globals_box; GtkBox *sensors_vbox; /* holds sensors_hbox and sensor_config_hbox */ GtkBox *sensor_config_hbox; /* holds config button */ GtkSizeGroup *size_group; /* so comboboxes all diff -Nru sensors-applet-3.0.0+git4/sensors-applet/sensor-config-dialog.c sensors-applet-3.0.0+git5/sensors-applet/sensor-config-dialog.c --- sensors-applet-3.0.0+git4/sensors-applet/sensor-config-dialog.c 2013-03-06 09:32:25.000000000 +0000 +++ sensors-applet-3.0.0+git5/sensors-applet/sensor-config-dialog.c 2015-06-17 22:13:32.000000000 +0000 @@ -34,34 +34,28 @@ /* icon widgets */ GtkLabel *icon_header, *icon_type_label; GtkComboBox *icon_type_combo_box; - GtkAlignment *icon_type_combo_box_aligner; GtkCellRenderer *icon_renderer; /* Graph Color chooser */ GtkColorButton *graph_color_button; - GtkAlignment *graph_color_button_aligner; GtkLabel *graph_color_label, *graph_header; /* multiplier and offset widgets */ GtkLabel *scale_header, *multiplier_label, *offset_label; - GtkAlignment *multiplier_spinbutton_aligner, *offset_spinbutton_aligner; GtkAdjustment *multiplier_adjust, *offset_adjust; GtkSpinButton *multiplier_spinbutton, *offset_spinbutton; GtkLabel *limits_header; GtkLabel *low_value_label, *high_value_label; - GtkAlignment *low_value_spinbutton_aligner, *high_value_spinbutton_aligner; GtkAdjustment *low_value_adjust, *high_value_adjust; GtkSpinButton *low_value_spinbutton, *high_value_spinbutton; /* alarm widgets */ GtkLabel *alarm_header; GtkLabel *low_alarm_command_label, *high_alarm_command_label, *alarm_timeout_label; - GtkAlignment *alarm_timeout_spinbutton_aligner; GtkAdjustment *alarm_timeout_adjust; GtkSpinButton *alarm_timeout_spinbutton; GtkGrid *table; - GtkAlignment *alarm_enable_aligner; GtkCheckButton *alarm_enable_checkbutton; GtkEntry *low_alarm_command_entry, *high_alarm_command_entry; @@ -397,18 +391,18 @@ header_text = g_strdup_printf("%s - %s", _("Sensor Properties"), sensor_label); config_dialog->dialog = gtk_dialog_new_with_buttons(header_text, - GTK_WINDOW(sensors_applet->prefs_dialog->dialog), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_HELP, - GTK_RESPONSE_HELP, - GTK_STOCK_CLOSE, - GTK_RESPONSE_CLOSE, - NULL); - gtk_window_set_icon_name(GTK_WINDOW(config_dialog->dialog), - "sensors-applet"); - - g_free(header_text); - g_free(sensor_label); + GTK_WINDOW(sensors_applet->prefs_dialog->dialog), + GTK_DIALOG_DESTROY_WITH_PARENT, + _("_Help"), + GTK_RESPONSE_HELP, + _("_Close"), + GTK_RESPONSE_CLOSE, + NULL); + gtk_window_set_icon_name(GTK_WINDOW(config_dialog->dialog), + "sensors-applet"); + + g_free(header_text); + g_free(sensor_label); g_object_set(config_dialog->dialog, "border-width", 12, @@ -423,26 +417,21 @@ /* graph stuff */ header_text = g_markup_printf_escaped("%s", _("Graph")); config_dialog->graph_header = g_object_new(GTK_TYPE_LABEL, - "use-markup", TRUE, - "label", header_text, - "xalign", 0.0, - NULL); - g_free(header_text); + "use-markup", TRUE, + "label", header_text, + "xalign", 0.0, + NULL); + g_free(header_text); gdk_rgba_parse(&graph_color, graph_color_string); config_dialog->graph_color_button = GTK_COLOR_BUTTON(gtk_color_button_new_with_rgba(&graph_color)); - config_dialog->graph_color_button_aligner = g_object_new(GTK_TYPE_ALIGNMENT, - "child", config_dialog->graph_color_button, - "xalign", 0.0, - "xscale", 0.0, - NULL); gtk_color_button_set_title(config_dialog->graph_color_button, _("Graph Color")); config_dialog->graph_color_label = g_object_new(GTK_TYPE_LABEL, - "label", _("Graph _color"), + "label", _("Graph _color"), "mnemonic-widget", config_dialog->graph_color_button, "use-underline", TRUE, "xalign", 0.0, @@ -479,12 +468,6 @@ config_dialog->icon_type_combo_box = GTK_COMBO_BOX(gtk_combo_box_new_with_model(GTK_TREE_MODEL(icon_store))); - config_dialog->icon_type_combo_box_aligner = g_object_new(GTK_TYPE_ALIGNMENT, - "child", config_dialog->icon_type_combo_box, - "xalign", 0.0, - "xscale", 0.0, - NULL); - config_dialog->icon_renderer = gtk_cell_renderer_pixbuf_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(config_dialog->icon_type_combo_box), GTK_CELL_RENDERER(config_dialog->icon_renderer), @@ -502,7 +485,7 @@ config_dialog); - + config_dialog->icon_type_label = g_object_new(GTK_TYPE_LABEL, "label", _("Sensor _icon"), "mnemonic-widget", config_dialog->icon_type_combo_box, @@ -536,12 +519,6 @@ "width-chars", SPINBUTTON_WIDTH_CHARS, NULL); - config_dialog->multiplier_spinbutton_aligner = g_object_new(GTK_TYPE_ALIGNMENT, - "child", config_dialog->multiplier_spinbutton, - "xalign", 0.0, - "xscale", 0.0, - NULL); - config_dialog->multiplier_label = g_object_new(GTK_TYPE_LABEL, "label", _("Sensor value _multiplier"), "mnemonic-widget", config_dialog->multiplier_spinbutton, @@ -551,7 +528,7 @@ g_signal_connect(config_dialog->multiplier_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_multiplier_changed), config_dialog); - + config_dialog->offset_adjust = g_object_new(GTK_TYPE_ADJUSTMENT, "value", 0.0, @@ -568,12 +545,6 @@ "value", (gdouble)offset, "width-chars", SPINBUTTON_WIDTH_CHARS, NULL); - - config_dialog->offset_spinbutton_aligner = g_object_new(GTK_TYPE_ALIGNMENT, - "child", config_dialog->offset_spinbutton, - "xalign", 0.0, - "xscale", 0.0, - NULL); config_dialog->offset_label = g_object_new(GTK_TYPE_LABEL, "label", _("Sensor value _offset"), @@ -603,30 +574,22 @@ "page-size", 100.0, NULL); - + config_dialog->low_value_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON, "adjustment", config_dialog->low_value_adjust, "digits", VALUE_DECIMAL_PLACES, "value", low_value, "width-chars", SPINBUTTON_WIDTH_CHARS, - NULL); - - config_dialog->low_value_spinbutton_aligner = g_object_new(GTK_TYPE_ALIGNMENT, - "child", config_dialog->low_value_spinbutton, - "xalign", 0.0, - "xscale", 0.0, - NULL); config_dialog->low_value_label = g_object_new(GTK_TYPE_LABEL, "label", _("Sensor _low value"), "mnemonic-widget", config_dialog->low_value_spinbutton, "use-underline", TRUE, "xalign", 0.0, - NULL); - + g_signal_connect(config_dialog->low_value_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_low_value_changed), config_dialog); config_dialog->high_value_adjust = g_object_new(GTK_TYPE_ADJUSTMENT, @@ -638,21 +601,13 @@ "page-size", 100.0, NULL); - config_dialog->high_value_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON, "adjustment", config_dialog->high_value_adjust, "digits", VALUE_DECIMAL_PLACES, "value", high_value, "width-chars", SPINBUTTON_WIDTH_CHARS, - NULL); - - config_dialog->high_value_spinbutton_aligner = g_object_new(GTK_TYPE_ALIGNMENT, - "child", config_dialog->high_value_spinbutton, - "xalign", 0.0, - "xscale", 0.0, - NULL); - + config_dialog->high_value_label = g_object_new(GTK_TYPE_LABEL, "label", _("Sensor _high value"), "mnemonic-widget", config_dialog->high_value_spinbutton, @@ -688,14 +643,8 @@ "value", (gdouble)alarm_timeout, "width-chars", SPINBUTTON_WIDTH_CHARS, "sensitive", alarm_enable, - NULL); - config_dialog->alarm_timeout_spinbutton_aligner = g_object_new(GTK_TYPE_ALIGNMENT, - "child", config_dialog->alarm_timeout_spinbutton, - "xalign", 0.0, - "xscale", 0.0, - NULL); - + config_dialog->alarm_timeout_label = g_object_new(GTK_TYPE_LABEL, "label", _("Alarm _repeat interval (secs)"), "mnemonic-widget", config_dialog->alarm_timeout_spinbutton, @@ -757,15 +706,9 @@ "active", alarm_enable, "xalign", 0.0, NULL); - - config_dialog->alarm_enable_aligner = g_object_new(GTK_TYPE_ALIGNMENT, - "child", config_dialog->alarm_enable_checkbutton, - "xalign", 0.0, - "xscale", 0.0, - NULL); g_signal_connect(config_dialog->alarm_enable_checkbutton, "toggled", G_CALLBACK(sensor_config_dialog_alarm_toggled), config_dialog); - + config_dialog->size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); @@ -814,16 +757,10 @@ NULL); gtk_grid_attach(config_dialog->table, - GTK_WIDGET(config_dialog->multiplier_spinbutton_aligner), + GTK_WIDGET(config_dialog->multiplier_spinbutton), 2, 1, 1, 1); - g_object_set (G_OBJECT (config_dialog->multiplier_spinbutton_aligner), - "halign", GTK_ALIGN_FILL, - "valign", GTK_ALIGN_FILL, - "vexpand", TRUE, - "hexpand", TRUE, - NULL); - + gtk_grid_attach(config_dialog->table, GTK_WIDGET(config_dialog->offset_label), 1, 2, @@ -836,16 +773,10 @@ NULL); gtk_grid_attach(config_dialog->table, - GTK_WIDGET(config_dialog->offset_spinbutton_aligner), - 2, 2, - 1, 1); - g_object_set (G_OBJECT (config_dialog->offset_spinbutton_aligner), - "halign", GTK_ALIGN_FILL, - "valign", GTK_ALIGN_FILL, - "vexpand", TRUE, - "hexpand", TRUE, - NULL); - + GTK_WIDGET(config_dialog->offset_spinbutton), + 2, 2, + 1, 1); + gtk_grid_attach(config_dialog->table, GTK_WIDGET(config_dialog->limits_header), 0, 3, @@ -870,20 +801,14 @@ NULL); gtk_grid_attach(config_dialog->table, - GTK_WIDGET(config_dialog->low_value_spinbutton_aligner), - 2, 4, - 1, 1); - g_object_set (G_OBJECT (config_dialog->low_value_spinbutton_aligner), - "halign", GTK_ALIGN_FILL, - "valign", GTK_ALIGN_FILL, - "vexpand", TRUE, - "hexpand", TRUE, - NULL); + GTK_WIDGET(config_dialog->low_value_spinbutton), + 2, 4, + 1, 1); gtk_grid_attach(config_dialog->table, - GTK_WIDGET(config_dialog->high_value_label), - 1, 5, - 1, 1); + GTK_WIDGET(config_dialog->high_value_label), + 1, 5, + 1, 1); g_object_set (G_OBJECT (config_dialog->high_value_label), "halign", GTK_ALIGN_FILL, "valign", GTK_ALIGN_FILL, @@ -892,16 +817,16 @@ NULL); gtk_grid_attach(config_dialog->table, - GTK_WIDGET(config_dialog->high_value_spinbutton_aligner), - 2, 5, - 1, 1); - g_object_set (G_OBJECT (config_dialog->high_value_spinbutton_aligner), - "halign", GTK_ALIGN_FILL, - "valign", GTK_ALIGN_FILL, - "vexpand", TRUE, - "hexpand", TRUE, - NULL); - + GTK_WIDGET(config_dialog->high_value_spinbutton), + 2, 5, + 1, 1); + g_object_set (G_OBJECT (config_dialog->high_value_spinbutton), + "halign", GTK_ALIGN_FILL, + "valign", GTK_ALIGN_FILL, + "vexpand", TRUE, + "hexpand", TRUE, + NULL); + gtk_grid_attach(config_dialog->table, GTK_WIDGET(config_dialog->alarm_header), 0, 6, @@ -914,39 +839,27 @@ NULL); gtk_grid_attach(config_dialog->table, - GTK_WIDGET(config_dialog->alarm_enable_aligner), - 1, 7, - 1, 1); - g_object_set (G_OBJECT (config_dialog->alarm_enable_aligner), - "halign", GTK_ALIGN_FILL, - "valign", GTK_ALIGN_FILL, - "vexpand", TRUE, - "hexpand", TRUE, - NULL); + GTK_WIDGET(config_dialog->alarm_enable_checkbutton), + 1, 7, + 1, 1); + g_object_set (G_OBJECT (config_dialog->alarm_enable_checkbutton), + "halign", GTK_ALIGN_FILL, + "valign", GTK_ALIGN_FILL, + "vexpand", TRUE, + "hexpand", TRUE, + NULL); + + gtk_grid_attach(config_dialog->table, + GTK_WIDGET(config_dialog->alarm_timeout_label), + 1, 8, + 1, 1); + + gtk_grid_attach(config_dialog->table, + GTK_WIDGET(config_dialog->alarm_timeout_spinbutton), + 2, 8, + 1, 1); gtk_grid_attach(config_dialog->table, - GTK_WIDGET(config_dialog->alarm_timeout_label), - 1, 8, - 1, 1); - g_object_set (G_OBJECT (config_dialog->alarm_timeout_label), - "halign", GTK_ALIGN_FILL, - "valign", GTK_ALIGN_FILL, - "vexpand", TRUE, - "hexpand", TRUE, - NULL); - - gtk_grid_attach(config_dialog->table, - GTK_WIDGET(config_dialog->alarm_timeout_spinbutton_aligner), - 2, 8, - 1, 1); - g_object_set (G_OBJECT (config_dialog->alarm_timeout_spinbutton_aligner), - "halign", GTK_ALIGN_FILL, - "valign", GTK_ALIGN_FILL, - "vexpand", TRUE, - "hexpand", TRUE, - NULL); - - gtk_grid_attach(config_dialog->table, GTK_WIDGET(config_dialog->low_alarm_command_label), 1, 9, 1, 1); @@ -990,75 +903,39 @@ "hexpand", TRUE, NULL); - gtk_grid_attach(config_dialog->table, - GTK_WIDGET(config_dialog->icon_header), - 0, 11, - 2, 1); - g_object_set (G_OBJECT (config_dialog->icon_header), - "halign", GTK_ALIGN_FILL, - "valign", GTK_ALIGN_FILL, - "vexpand", TRUE, - "hexpand", TRUE, - NULL); + gtk_grid_attach(config_dialog->table, + GTK_WIDGET(config_dialog->icon_header), + 0, 11, + 2, 1); gtk_grid_attach(config_dialog->table, - GTK_WIDGET(config_dialog->icon_type_label), - 1, 12, - 1, 1); - g_object_set (G_OBJECT (config_dialog->icon_type_label), - "halign", GTK_ALIGN_FILL, - "valign", GTK_ALIGN_FILL, - "vexpand", TRUE, - "hexpand", TRUE, - NULL); - - gtk_grid_attach(config_dialog->table, - GTK_WIDGET(config_dialog->icon_type_combo_box_aligner), - 2, 12, - 1, 1); - g_object_set (G_OBJECT (config_dialog->icon_type_combo_box_aligner), - "halign", GTK_ALIGN_FILL, - "valign", GTK_ALIGN_FILL, - "vexpand", TRUE, - "hexpand", TRUE, - NULL); - + GTK_WIDGET(config_dialog->icon_type_label), + 1, 12, + 1, 1); + gtk_grid_attach(config_dialog->table, - GTK_WIDGET(config_dialog->graph_header), - 0, 13, - 2, 1); - g_object_set (G_OBJECT (config_dialog->graph_header), - "halign", GTK_ALIGN_FILL, - "valign", GTK_ALIGN_FILL, - "vexpand", TRUE, - "hexpand", TRUE, - NULL); + GTK_WIDGET(config_dialog->icon_type_combo_box), + 2, 12, + 1, 1); gtk_grid_attach(config_dialog->table, - GTK_WIDGET(config_dialog->graph_color_label), - 1, 14, - 1, 1); - g_object_set (G_OBJECT (config_dialog->graph_color_label), - "halign", GTK_ALIGN_FILL, - "valign", GTK_ALIGN_FILL, - "vexpand", TRUE, - "hexpand", TRUE, - NULL); + GTK_WIDGET(config_dialog->graph_header), + 0, 13, + 2, 1); gtk_grid_attach(config_dialog->table, - GTK_WIDGET(config_dialog->graph_color_button_aligner), - 2, 14, - 1, 1); - g_object_set (G_OBJECT (config_dialog->graph_color_button_aligner), - "halign", GTK_ALIGN_FILL, - "valign", GTK_ALIGN_FILL, - "vexpand", TRUE, - "hexpand", TRUE, - NULL); + GTK_WIDGET(config_dialog->graph_color_label), + 1, 14, + 1, 1); + + gtk_grid_attach(config_dialog->table, + GTK_WIDGET(config_dialog->graph_color_button), + 2, 14, + 1, 1); content_area = gtk_dialog_get_content_area (GTK_DIALOG(config_dialog->dialog)); gtk_box_pack_start(GTK_BOX(content_area), GTK_WIDGET(config_dialog->table), FALSE, FALSE, 0); gtk_widget_show_all(config_dialog->dialog); -} +} diff -Nru sensors-applet-3.0.0+git4/sensors-applet/sensors-applet.c sensors-applet-3.0.0+git5/sensors-applet/sensors-applet.c --- sensors-applet-3.0.0+git4/sensors-applet/sensors-applet.c 2013-03-06 09:32:25.000000000 +0000 +++ sensors-applet-3.0.0+git5/sensors-applet/sensors-applet.c 2015-06-17 22:13:32.000000000 +0000 @@ -33,7 +33,7 @@ #include #include "sensors-applet.h" #include "active-sensor.h" -#include "sensors-applet-gconf.h" +#include "sensors-applet-conf.h" #include "sensors-applet-plugins.h" #ifdef HAVE_LIBNOTIFY @@ -52,12 +52,12 @@ #define ROW_SPACING 1 /* callbacks for panel menu */ -static void prefs_cb(GtkAction *action, - gpointer *data, - const gchar *verbname) { +static void prefs_cb(GSimpleAction *action, + GVariant *parameter, + gpointer data) { - SensorsApplet *sensors_applet; - sensors_applet = (SensorsApplet *)data; + SensorsApplet *sensors_applet; + sensors_applet = (SensorsApplet *)data; if (sensors_applet->prefs_dialog) { gtk_window_present(GTK_WINDOW(sensors_applet->prefs_dialog->dialog)); @@ -66,29 +66,28 @@ prefs_dialog_open(sensors_applet); } -static void about_cb(GtkAction *action, - gpointer data, - const gchar *verbname) { - SensorsApplet *sensors_applet; - sensors_applet = (SensorsApplet *)data; +static void about_cb(GSimpleAction *action, + GVariant *parameter, + gpointer data) { + SensorsApplet *sensors_applet; + sensors_applet = (SensorsApplet *)data; about_dialog_open(sensors_applet); } -static void help_cb(GtkAction *action, - gpointer data, - const gchar *verbname) { +static void help_cb(GSimpleAction *action, + GVariant *parameter, + gpointer data) { + GError *error = NULL; + + gtk_show_uri(NULL, "ghelp:sensors-applet", + gtk_get_current_event_time(), + &error); - GError *error = NULL; - - gtk_show_uri(NULL, "ghelp:sensors-applet", - gtk_get_current_event_time(), - &error); - - if (error) { - g_debug("Could not open help document: %s ",error->message); - g_error_free(error); - } + if (error) { + g_debug("Could not open help document: %s ",error->message); + g_error_free(error); + } } static void destroy_cb(GtkWidget *widget, gpointer data) { @@ -171,9 +170,7 @@ sensors_applet = (SensorsApplet *)data; - display_mode = panel_applet_gconf_get_int(sensors_applet->applet, - DISPLAY_MODE, - NULL); + display_mode = g_settings_get_int(sensors_applet->settings, DISPLAY_MODE); if (sensors_applet->sensors) { for (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter); not_end_of_interfaces; not_end_of_interfaces = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter)) { @@ -214,16 +211,10 @@ } -static const GtkActionEntry sensors_applet_menu_actions[] = { - { "Preferences", GTK_STOCK_PROPERTIES, N_("_Preferences"), - NULL, NULL, - G_CALLBACK(prefs_cb) }, - { "Help", GTK_STOCK_HELP, N_("_Help"), - NULL, NULL, - G_CALLBACK(help_cb) }, - { "About", GTK_STOCK_ABOUT, N_("_About"), - NULL, NULL, - G_CALLBACK(about_cb) } +static const GActionEntry sensors_applet_menu_actions[] = { + { "preferences", prefs_cb, NULL, NULL, NULL }, + { "help", help_cb, NULL, NULL, NULL }, + { "about", about_cb, NULL, NULL, NULL } }; #ifdef HAVE_LIBNOTIFY @@ -270,7 +261,7 @@ sensors_applet->notification = notify_notification_new(summary, message, - GTK_STOCK_DIALOG_WARNING); + "dialog-warning"); g_free(summary); g_free(message); @@ -310,15 +301,14 @@ sensors_applet = active_sensor->sensors_applet; - if (!panel_applet_gconf_get_bool(sensors_applet->applet, - DISPLAY_NOTIFICATIONS, - NULL)) { + if (!g_settings_get_boolean(sensors_applet->settings, + DISPLAY_NOTIFICATIONS)) { g_debug("Wanted to display notification, but user has disabled them"); return; } - + table_children = gtk_container_get_children(GTK_CONTAINER(sensors_applet->table)); - + if (g_list_find(table_children, active_sensor->icon)) { attach = GTK_WIDGET(active_sensor->icon); } else if (g_list_find(table_children, active_sensor->label)) { @@ -332,7 +322,7 @@ return; } g_list_free(table_children); - + path = gtk_tree_row_reference_get_path(active_sensor->sensor_row); if (gtk_tree_model_get_iter(GTK_TREE_MODEL(sensors_applet->sensors), &iter, path)) { @@ -347,7 +337,7 @@ return; } gtk_tree_path_free(path); - + // do different stuff for different notif types switch (notif_type) { case LOW_ALARM: // fall thru @@ -374,9 +364,8 @@ case TEMP_SENSOR: unit_type_title = _("Temperature"); unit_type = _("temperature"); - temp_scale = (TemperatureScale)panel_applet_gconf_get_int(active_sensor->sensors_applet->applet, - TEMPERATURE_SCALE, - NULL); + temp_scale = (TemperatureScale)g_settings_get_int(active_sensor->sensors_applet->settings, + TEMPERATURE_SCALE); switch (temp_scale) { case CELSIUS: @@ -420,9 +409,8 @@ case SENSOR_INTERFACE_ERROR: summary = g_strdup_printf(_("Error updating sensor %s"), sensor_label); message = g_strdup_printf(_("An error occurred while trying to update the value of the sensor %s located at %s."), sensor_label, sensor_path); - timeout_msecs = panel_applet_gconf_get_int(active_sensor->sensors_applet->applet, - TIMEOUT, - NULL); + timeout_msecs = g_settings_get_int(active_sensor->sensors_applet->settings, + TIMEOUT); break; @@ -434,7 +422,7 @@ notif_type, summary, message, - GTK_STOCK_DIALOG_WARNING, + "dialog-warning", timeout_msecs); g_free(sensor_path); @@ -564,10 +552,10 @@ /* otherwise can acess active_sensors without any worries */ num_active_sensors = g_list_length(sensors_applet->active_sensors); - display_mode = (DisplayMode)panel_applet_gconf_get_int(sensors_applet->applet, - DISPLAY_MODE, NULL); - layout_mode = (LayoutMode)panel_applet_gconf_get_int(sensors_applet->applet, - LAYOUT_MODE, NULL); + display_mode = (DisplayMode)g_settings_get_int(sensors_applet->settings, + DISPLAY_MODE); + layout_mode = (LayoutMode)g_settings_get_int(sensors_applet->settings, + LAYOUT_MODE); horizontal = (((panel_applet_get_orient(sensors_applet->applet) == PANEL_APPLET_ORIENT_UP) || @@ -579,7 +567,6 @@ /* get the first active sensor */ first_sensor = (ActiveSensor *)sensors_applet->active_sensors->data; - switch (display_mode) { case DISPLAY_VALUE: gtk_widget_get_preferred_size(GTK_WIDGET(first_sensor->value), @@ -832,7 +819,7 @@ } j++; } else { /* place value below label */ - /* center align labels */ + /* center align labels */ if (((ActiveSensor *)(current_sensor->data))->icon) { gtk_misc_set_alignment(GTK_MISC(((ActiveSensor *)(current_sensor->data))->icon), 0.5, 0.5); } @@ -866,11 +853,9 @@ } else { i++; } - - } /* end column loop */ - + } else { /* not showing labels and icons with values, so just * pack either only icons or values */ for (i = 0; current_sensor != NULL && i < cols; ++i) { @@ -921,7 +906,7 @@ current_sensor = g_list_next(current_sensor); } } - + } if (old_table_children != NULL) { gtk_container_foreach(GTK_CONTAINER(sensors_applet->table), @@ -931,7 +916,7 @@ } gtk_widget_show_all(GTK_WIDGET(sensors_applet->applet)); -} +} /* must unref when done with returned pixbuf */ GdkPixbuf *sensors_applet_load_icon(IconType icon_type) { @@ -940,7 +925,6 @@ GError *error = NULL; /* try to load the icon */ - /* not allowed to unref or ref icon_theme once we have it */ icon_theme = gtk_icon_theme_get_default(); icon = gtk_icon_theme_load_icon(icon_theme, @@ -955,7 +939,7 @@ /* try again with default icon */ icon = gtk_icon_theme_load_icon(icon_theme, - GTK_STOCK_MISSING_IMAGE, + "image-missing", DEFAULT_ICON_SIZE, GTK_ICON_LOOKUP_USE_BUILTIN, &error); @@ -975,11 +959,11 @@ } gboolean sensors_applet_add_sensor(SensorsApplet *sensors_applet, - const gchar *path, - const gchar *id, - const gchar *label, - const gchar *interface, - SensorType type, + const gchar *path, + const gchar *id, + const gchar *label, + const gchar *interface, + SensorType type, gboolean enable, gdouble low_value, gdouble high_value, @@ -991,17 +975,15 @@ gdouble offset, IconType icon_type, const gchar *graph_color) { - - GtkTreeIter interfaces_iter, sensors_iter; gboolean not_empty_tree; - gchar *node_interface; + gchar *node_interface; gboolean not_end_of_interfaces = TRUE, interface_exists = FALSE; gboolean not_end_of_sensors = TRUE; gchar *sensor_id; - gchar *sensor_path; - SensorType sensor_type; + gchar *sensor_path; + SensorType sensor_type; GdkPixbuf *icon; GtkTreePath *tree_path; @@ -1013,7 +995,7 @@ if (NULL == sensors_applet->sensors) { - sensors_applet->sensors = gtk_tree_store_new(N_COLUMNS, + sensors_applet->sensors = gtk_tree_store_new(N_COLUMNS, G_TYPE_STRING, /* path */ G_TYPE_STRING, /* id */ G_TYPE_STRING, /* label */ @@ -1025,62 +1007,65 @@ G_TYPE_DOUBLE, /* low value */ G_TYPE_DOUBLE, /* high type */ G_TYPE_BOOLEAN, /* alarm enable */ - G_TYPE_STRING, /* low alarm command */ - G_TYPE_STRING, /* high alarm command */ + G_TYPE_STRING, /* low alarm command */ + G_TYPE_STRING, /* high alarm command */ G_TYPE_UINT, /* alarm timeout */ G_TYPE_DOUBLE, /* multiplier */ G_TYPE_DOUBLE, /* offset */ G_TYPE_UINT, /* icon type */ GDK_TYPE_PIXBUF, /* icon pixbuf */ G_TYPE_STRING); /* graph color */ - - + + g_debug("Sensor tree created."); /* we know tree is actually empty since we just created it */ not_empty_tree = FALSE; } - + /* search sensor tree for the parent interface to place this * sensor under */ - for (not_empty_tree = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter); not_empty_tree && not_end_of_interfaces && !interface_exists; not_end_of_interfaces = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter)) { + for (not_empty_tree = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sensors_applet->sensors), + &interfaces_iter); + not_empty_tree && not_end_of_interfaces && !interface_exists; + not_end_of_interfaces = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), + &interfaces_iter)) { gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter, - INTERFACE_COLUMN, &node_interface, - -1); + INTERFACE_COLUMN, &node_interface, -1); if (g_ascii_strcasecmp(interface, node_interface) == 0) { /* found interface in tree */ interface_exists = TRUE; - + /* now see if this actual sensor already * exists within this interface - don't want * to add duplicates */ /* see if have children */ for (not_end_of_sensors = gtk_tree_model_iter_children(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter, &interfaces_iter); not_end_of_sensors; not_end_of_sensors = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter)) { - gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter, - PATH_COLUMN, &sensor_path, - ID_COLUMN, &sensor_id, - SENSOR_TYPE_COLUMN, &sensor_type, - -1); + gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), + &sensors_iter, + PATH_COLUMN, &sensor_path, + ID_COLUMN, &sensor_id, + SENSOR_TYPE_COLUMN, &sensor_type,-1); if (g_ascii_strcasecmp(sensor_id, id) == 0 && - g_ascii_strcasecmp(sensor_path, path) == 0 && - sensor_type == type) { + g_ascii_strcasecmp(sensor_path, path) == 0 && + sensor_type == type) { /* sensor already exists so * dont add a second time */ g_debug("sensor with path: %s, id: %s already exists in tree, not adding a second time", sensor_path, sensor_id); g_free(sensor_id); g_free(sensor_path); - g_free(node_interface); + g_free(node_interface); return FALSE; } g_free(sensor_id); - g_free(sensor_path); + g_free(sensor_path); } - g_free(node_interface); + g_free(node_interface); break; } - g_free(node_interface); - } - + g_free(node_interface); + } + if (!interface_exists) { @@ -1106,9 +1091,9 @@ g_debug("Added sensor interface %s to tree", interface); } - icon = sensors_applet_load_icon(icon_type); + icon = sensors_applet_load_icon(icon_type); + - /* then add sensor as a child under interface node - ie assume * we either found it or created it - the inteface node that * is */ @@ -1117,7 +1102,7 @@ gtk_tree_store_append(sensors_applet->sensors, &sensors_iter, &interfaces_iter); - + gtk_tree_store_set(sensors_applet->sensors, &sensors_iter, PATH_COLUMN, path, @@ -1150,31 +1135,31 @@ sensors_applet_sensor_enabled(sensors_applet, tree_path); gtk_tree_path_free(tree_path); } - return TRUE; -} + return TRUE; +} static ActiveSensor *sensors_applet_find_active_sensor(SensorsApplet *sensors_applet, GtkTreePath *path) { GtkTreePath *sensor_tree_path; GList *current_sensor; - + for (current_sensor = sensors_applet->active_sensors; current_sensor != NULL; current_sensor = g_list_next(current_sensor)) { sensor_tree_path = gtk_tree_row_reference_get_path(((ActiveSensor *)(current_sensor->data))->sensor_row); if (gtk_tree_path_compare(path, sensor_tree_path) == 0) { - gtk_tree_path_free(sensor_tree_path); + gtk_tree_path_free(sensor_tree_path); return ((ActiveSensor *)(current_sensor->data)); } - gtk_tree_path_free(sensor_tree_path); + gtk_tree_path_free(sensor_tree_path); } return NULL; } - - + + /* path should be the full path to a file representing the sensor (eg * /dev/hda or /sys/devices/platform/i2c-0/0-0290/temp1_input) */ - + void sensors_applet_display_layout_changed(SensorsApplet *sensors_applet) { /* update sensors since will need to update icons / graphs etc * if weren't displayed before */ @@ -1199,7 +1184,7 @@ active_sensor_alarm_off(active_sensor, notif_type); } } - + void sensors_applet_all_alarms_off(SensorsApplet *sensors_applet, GtkTreePath *path) { sensors_applet_alarm_off(sensors_applet, path, LOW_ALARM); @@ -1214,25 +1199,25 @@ g_assert(sensors_applet); g_assert(path); - active_sensor = active_sensor_new(sensors_applet, - gtk_tree_row_reference_new(GTK_TREE_MODEL(sensors_applet->sensors), path)); - - active_sensor_update(active_sensor, sensors_applet); - - /* keep list sorted */ + active_sensor = active_sensor_new(sensors_applet, + gtk_tree_row_reference_new(GTK_TREE_MODEL(sensors_applet->sensors), path)); + + active_sensor_update(active_sensor, sensors_applet); + + /* keep list sorted */ sensors_applet->active_sensors = g_list_insert_sorted(sensors_applet->active_sensors, - active_sensor, - (GCompareFunc)active_sensor_compare); - - sensors_applet_pack_display(sensors_applet); + active_sensor, + (GCompareFunc)active_sensor_compare); + + sensors_applet_pack_display(sensors_applet); } void sensors_applet_reorder_sensors(SensorsApplet *sensors_applet) { - sensors_applet->active_sensors = g_list_sort(sensors_applet->active_sensors, (GCompareFunc)active_sensor_compare); + sensors_applet->active_sensors = g_list_sort(sensors_applet->active_sensors, (GCompareFunc)active_sensor_compare); sensors_applet_pack_display(sensors_applet); } - + void sensors_applet_sensor_disabled(SensorsApplet *sensors_applet, GtkTreePath *path) { @@ -1244,14 +1229,14 @@ if ((active_sensor = sensors_applet_find_active_sensor(sensors_applet, path)) != NULL) { g_debug("Destroying active sensor..."); - + g_debug("-- removing from list..."); sensors_applet->active_sensors = g_list_remove(sensors_applet->active_sensors, active_sensor); g_debug("-- repacking display...."); sensors_applet_pack_display(sensors_applet); - - active_sensor_destroy(active_sensor); + + active_sensor_destroy(active_sensor); } } @@ -1265,22 +1250,20 @@ if ((active_sensor = sensors_applet_find_active_sensor(sensors_applet, path)) != NULL) { - active_sensor_update(active_sensor, - sensors_applet); + active_sensor_update(active_sensor, sensors_applet); } } void sensors_applet_icon_changed(SensorsApplet *sensors_applet, GtkTreePath *path) { ActiveSensor *active_sensor; - + g_assert(sensors_applet); g_assert(path); - + if ((active_sensor = sensors_applet_find_active_sensor(sensors_applet, path)) != NULL) { - active_sensor_icon_changed(active_sensor, - sensors_applet); + active_sensor_icon_changed(active_sensor, sensors_applet); } } @@ -1289,14 +1272,14 @@ */ gboolean sensors_applet_update_active_sensors(SensorsApplet *sensors_applet) { g_assert(sensors_applet); - - if (sensors_applet->active_sensors) { - g_list_foreach(sensors_applet->active_sensors, - (GFunc)active_sensor_update, - sensors_applet); - return TRUE; - } - return FALSE; + + if (sensors_applet->active_sensors) { + g_list_foreach(sensors_applet->active_sensors, + (GFunc)active_sensor_update, + sensors_applet); + return TRUE; + } + return FALSE; } /** @@ -1309,12 +1292,11 @@ if (sensors_applet->active_sensors) { - graph_size = panel_applet_gconf_get_int(sensors_applet->applet, - GRAPH_SIZE, - NULL); - if (panel_applet_get_orient(sensors_applet->applet) == + graph_size = g_settings_get_int(sensors_applet->settings, + GRAPH_SIZE); + if (panel_applet_get_orient(sensors_applet->applet) == PANEL_APPLET_ORIENT_UP || - panel_applet_get_orient(sensors_applet->applet) == + panel_applet_get_orient(sensors_applet->applet) == PANEL_APPLET_ORIENT_DOWN) { /* is horizontal so set graph_size as width */ dimensions[0] = graph_size; @@ -1331,8 +1313,8 @@ } -gdouble sensors_applet_convert_temperature(gdouble value, - TemperatureScale old, +gdouble sensors_applet_convert_temperature(gdouble value, + TemperatureScale old, TemperatureScale new) { switch (old) { @@ -1379,87 +1361,87 @@ void sensors_applet_init(SensorsApplet *sensors_applet) { - GtkActionGroup *action_group; + GActionGroup *action_group; gchar *ui_path; - - g_assert(sensors_applet); + + g_assert(sensors_applet); g_assert(sensors_applet->applet); + sensors_applet->settings = panel_applet_settings_new (sensors_applet->applet, SENSORS_APPLET_SCHEMA); + /* Have our background automatically painted. */ panel_applet_set_background_widget(PANEL_APPLET(sensors_applet->applet), GTK_WIDGET(sensors_applet->applet)); - /* plugin functions are stored as name -> get_value_function pairs so + /* plugin functions are stored as name -> get_value_function pairs so * use standard string functions on hash table */ - sensors_applet->plugins = g_hash_table_new(g_str_hash, - g_str_equal); + sensors_applet->plugins = g_hash_table_new(g_str_hash, g_str_equal); - sensors_applet->required_plugins = g_hash_table_new_full(g_str_hash, - g_str_equal, - g_free, - NULL); - - /* initialise size */ - sensors_applet->size = DEFAULT_APPLET_SIZE; + sensors_applet->required_plugins = g_hash_table_new_full(g_str_hash, + g_str_equal, g_free, NULL); + + /* initialise size */ + sensors_applet->size = DEFAULT_APPLET_SIZE; - panel_applet_set_flags(sensors_applet->applet, - PANEL_APPLET_EXPAND_MINOR); + panel_applet_set_flags(sensors_applet->applet, + PANEL_APPLET_EXPAND_MINOR); g_signal_connect(sensors_applet->applet, "destroy", - G_CALLBACK(destroy_cb), - sensors_applet); + G_CALLBACK(destroy_cb), sensors_applet); - /* if not setup, write defaults to gconf */ - sensors_applet_gconf_setup(sensors_applet); + /* if not setup, write defaults to configuration backend */ + sensors_applet_conf_setup(sensors_applet); /* now do any setup needed manually */ - sensors_applet_plugins_load_all(sensors_applet); + sensors_applet_plugins_load_all(sensors_applet); - /* should have created sensors tree above, but if have + /* should have created sensors tree above, but if have not was because we couldn't find any sensors */ if (NULL == sensors_applet->sensors) { - GtkWidget *label; + GtkWidget *label; label = gtk_label_new(_("No sensors found!")); gtk_container_add(GTK_CONTAINER(sensors_applet->applet), label); gtk_widget_show_all(GTK_WIDGET(sensors_applet->applet)); return; } - - /* only do menu and signal connections if sensors are found */ - action_group = gtk_action_group_new ("Sensors Applet Actions"); - gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); - gtk_action_group_add_actions (action_group, + + /* only do menu and signal connections if sensors are found */ + action_group = g_simple_action_group_new (); + g_action_map_add_action_entries (G_ACTION_MAP (action_group), sensors_applet_menu_actions, G_N_ELEMENTS (sensors_applet_menu_actions), sensors_applet); ui_path = g_build_filename (UIDIR, SENSORS_APPLET_MENU_FILE, NULL); - panel_applet_setup_menu_from_file (sensors_applet->applet, ui_path, action_group); + panel_applet_setup_menu_from_file (sensors_applet->applet, ui_path, action_group, + GETTEXT_PACKAGE); g_free (ui_path); + + gtk_widget_insert_action_group (GTK_WIDGET (sensors_applet->applet), "sensorsapplet", + G_ACTION_GROUP (action_group)); + +// action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "dialog"); + // g_object_bind_property (applet, "locked-down", action, "enabled", +// + G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE); + g_object_unref (action_group); g_signal_connect(sensors_applet->applet, "style-set", - G_CALLBACK(style_set_cb), - sensors_applet); - - g_signal_connect(G_OBJECT(sensors_applet->applet), "change_orient", - G_CALLBACK(change_orient_cb), - sensors_applet); - - g_signal_connect(G_OBJECT(sensors_applet->applet), "size_allocate", - G_CALLBACK(size_allocate_cb), - sensors_applet); + G_CALLBACK(style_set_cb), sensors_applet); + g_signal_connect(G_OBJECT(sensors_applet->applet), "change_orient", + G_CALLBACK(change_orient_cb), sensors_applet); + g_signal_connect(G_OBJECT(sensors_applet->applet), "size_allocate", + G_CALLBACK(size_allocate_cb), sensors_applet); sensors_applet_update_active_sensors(sensors_applet); sensors_applet_pack_display(sensors_applet); - sensors_applet->timeout_id = g_timeout_add_seconds(panel_applet_gconf_get_int(sensors_applet->applet, TIMEOUT, NULL) / 1000, - (GSourceFunc)sensors_applet_update_active_sensors, - sensors_applet); + sensors_applet->timeout_id = g_timeout_add_seconds( + g_settings_get_int(sensors_applet->settings, TIMEOUT) / 1000, + (GSourceFunc)sensors_applet_update_active_sensors, + sensors_applet); gtk_widget_show_all(GTK_WIDGET(sensors_applet->applet)); } - - diff -Nru sensors-applet-3.0.0+git4/sensors-applet/sensors-applet-conf.c sensors-applet-3.0.0+git5/sensors-applet/sensors-applet-conf.c --- sensors-applet-3.0.0+git4/sensors-applet/sensors-applet-conf.c 1970-01-01 00:00:00.000000000 +0000 +++ sensors-applet-3.0.0+git5/sensors-applet/sensors-applet-conf.c 2015-06-17 22:13:32.000000000 +0000 @@ -0,0 +1,301 @@ +/* + * Copyright (C) 2005-2009 Alex Murray + * + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +#include + +#include "sensors-applet.h" +#include "sensors-applet-conf.h" + +#define DEFAULT_TIMEOUT 2000 +#define DEFAULT_GRAPH_SIZE 42 + +static const gchar * const compatible_versions[] = { + PACKAGE_VERSION, /* always list current version */ + "3.0.0", + "2.2.7", + "2.2.6", + "2.2.5", + "2.2.4", + "2.2.3", + "2.2.2", +}; + +#define NUM_COMPATIBLE_VERSIONS G_N_ELEMENTS(compatible_versions) + +typedef enum { + SENSORS_APPLET_GCONF_ERROR = 0, + SENSORS_APPLET_VERSION_ERROR, +} SensorsAppletGConfError; + +static const gchar * const error_titles[] = { + N_("An error occurred loading the stored sensors data"), + N_("Incompatible sensors configuration found") +}; + +static const gchar * const error_messages[] = { + N_("An error has occurred when loading the stored sensors data. " + "The default values will be used to recover from this error."), + + N_("Unfortunately the previous configuration for GNOME Sensors Applet " + "is not compatible with this version. The existing sensors data " + "will be overwritten with the default values for this new version.") +}; + + +static void sensors_applet_conf_set_defaults(SensorsApplet *sensors_applet) { + g_settings_set_int(sensors_applet->settings, DISPLAY_MODE, DISPLAY_ICON_WITH_VALUE); + g_settings_set_int(sensors_applet->settings, LAYOUT_MODE, VALUE_BESIDE_LABEL); + g_settings_set_int(sensors_applet->settings, TEMPERATURE_SCALE, CELSIUS); + g_settings_set_int(sensors_applet->settings, TIMEOUT, DEFAULT_TIMEOUT); + g_settings_set_double(sensors_applet->settings, GRAPH_SIZE, DEFAULT_GRAPH_SIZE); +#ifdef HAVE_LIBNOTIFY + g_settings_set_boolean(sensors_applet->settings, DISPLAY_NOTIFICATIONS, TRUE); +#endif + g_settings_set_boolean(sensors_applet->settings, IS_SETUP, FALSE); + +} + +/** + * Returns TRUE is old_version is one of the compatible versions + */ +static gboolean sensors_applet_conf_is_compatible(const gchar *old_version) { + guint i; + for (i = 0; i < NUM_COMPATIBLE_VERSIONS; i++) { + if (g_ascii_strcasecmp(old_version, compatible_versions[i]) == 0) { + return TRUE; + } + } + return FALSE; +} + + +void sensors_applet_conf_setup(SensorsApplet *sensors_applet) { + gboolean setup = FALSE; + gchar *old_version; + GError *error = NULL; + + setup = g_settings_get_boolean(sensors_applet->settings, IS_SETUP); + + if (setup) { + /* see if setup version matches */ + old_version = g_settings_get_string(sensors_applet->settings, + SENSORS_APPLET_VERSION); + /* if versions don't match or there is no saved + * version string then need to overwrite old config */ + + if (old_version) { + if (sensors_applet_conf_is_compatible(old_version)) { + /* previously setup and versions match so use + * old values */ + g_debug("Config data is compatible. Trying to set up sensors from config data"); + + if (sensors_applet_conf_setup_sensors(sensors_applet)) { + g_debug("done setting up from config backend"); + } else { + g_debug("Setting conf defaults only"); + sensors_applet_conf_set_defaults(sensors_applet); + } + g_free(old_version); + + return; + + + } + g_free(old_version); + } + sensors_applet_notify(sensors_applet, GCONF_READ_ERROR); + + + } + + /* use defaults */ + g_debug("Setting config defaults only"); + sensors_applet_conf_set_defaults(sensors_applet); +} + + +enum { + PATHS_INDEX = 0, + IDS_INDEX, + LABELS_INDEX, + INTERFACES_INDEX, + SENSOR_TYPES_INDEX, + ENABLES_INDEX, + LOW_VALUES_INDEX, + HIGH_VALUES_INDEX, + ALARM_ENABLES_INDEX, + LOW_ALARM_COMMANDS_INDEX, + HIGH_ALARM_COMMANDS_INDEX, + ALARM_TIMEOUTS_INDEX, + MULTIPLIERS_INDEX, + OFFSETS_INDEX, + ICON_TYPES_INDEX, + GRAPH_COLORS_INDEX, + NUM_KEYS +}; + +const gchar * const keys[NUM_KEYS] = { + PATHS, + IDS, + LABELS, + INTERFACES, + SENSOR_TYPES, + ENABLES, + LOW_VALUES, + HIGH_VALUES, + ALARM_ENABLES, + LOW_ALARM_COMMANDS, + HIGH_ALARM_COMMANDS, + ALARM_TIMEOUTS, + MULTIPLIERS, + OFFSETS, + ICON_TYPES, + GRAPH_COLORS, +}; + +/* gets called if are already setup so we don't have to manually go + through and find sensors etc again */ +gboolean sensors_applet_conf_setup_sensors(SensorsApplet *sensors_applet) { + /* everything gets stored except alarm timeout indexes, which + we set to -1, and visible which we set to false for all + parent nodes and true for all child nodes */ + + GVariantIter *iter; + + gchar *current_path, *current_id, *current_label, *current_interface, + *current_low_alarm_command, *current_high_alarm_command, + *current_graph_color; + gboolean current_enable, current_alarm_enable; + gdouble current_low_value, current_high_value, current_multiplier, + current_offset; + guint32 current_sensor_type, current_alarm_timeout, + current_icon_type; + + g_settings_get (sensors_applet->settings, "slist", "a(ssssbddbssuuddus)", &iter); + + while (g_variant_iter_loop (iter, "(ssssbddbssuuddus)", ¤t_path, ¤t_id, ¤t_label, + ¤t_interface, ¤t_enable, ¤t_low_value, ¤t_high_value, ¤t_alarm_enable, + ¤t_low_alarm_command, ¤t_high_alarm_command, ¤t_alarm_timeout, ¤t_sensor_type, + ¤t_multiplier, ¤t_offset, ¤t_icon_type, ¤t_graph_color)) { + + sensors_applet_add_sensor(sensors_applet, + current_path, current_id, current_label, current_interface, + current_sensor_type, + current_enable, + current_low_value / 1000.0, + current_high_value / 1000.0, + current_alarm_enable, + current_low_alarm_command, + current_high_alarm_command, + current_alarm_timeout, + current_multiplier / 1000.0, + current_offset / 1000.0, + current_icon_type, current_graph_color); + + } + + return TRUE; +} + + +gboolean sensors_applet_conf_save_sensors(SensorsApplet *sensors_applet) { + /* write everything to conf backend except VISIBLE and + ALARM_TIMEOUT_INDEX */ + /* for stepping through GtkTreeStore data structure */ + GtkTreeIter interfaces_iter, sensors_iter; + gboolean not_end_of_interfaces = TRUE, not_end_of_sensors = TRUE; + + gchar *current_path, *current_id, *current_label, *current_interface, + *current_low_alarm_command, *current_high_alarm_command, + *current_graph_color; + gboolean current_enable, current_alarm_enable; + gdouble current_low_value, current_high_value, current_multiplier, + current_offset; + guint32 current_sensor_type, current_icon_type, current_alarm_timeout; + GVariant *vval; + + GVariantBuilder builder; + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ssssbddbssuuddus)")); + + /* now step through the GtkTreeStore sensors to + find which sensors are enabled */ + for (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter); + not_end_of_interfaces; + not_end_of_interfaces = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter)) { + // store a settings key for this interface + gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), + &interfaces_iter, + ID_COLUMN, ¤t_id, + -1); + + g_settings_set_boolean(sensors_applet->settings, current_id, TRUE); + g_free(current_id); + + /* reset sensors sentinel */ + not_end_of_sensors = TRUE; + + for (gtk_tree_model_iter_children(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter, &interfaces_iter); + not_end_of_sensors; + not_end_of_sensors = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter)) { + gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), + &sensors_iter, + PATH_COLUMN, ¤t_path, + ID_COLUMN, ¤t_id, + LABEL_COLUMN, ¤t_label, + INTERFACE_COLUMN, ¤t_interface, + SENSOR_TYPE_COLUMN, ¤t_sensor_type, + ENABLE_COLUMN, ¤t_enable, + LOW_VALUE_COLUMN, ¤t_low_value, + HIGH_VALUE_COLUMN, ¤t_high_value, + ALARM_ENABLE_COLUMN, ¤t_alarm_enable, + LOW_ALARM_COMMAND_COLUMN, ¤t_low_alarm_command, + HIGH_ALARM_COMMAND_COLUMN, ¤t_high_alarm_command, + ALARM_TIMEOUT_COLUMN, ¤t_alarm_timeout, + MULTIPLIER_COLUMN, ¤t_multiplier, + OFFSET_COLUMN, ¤t_offset, + ICON_TYPE_COLUMN, ¤t_icon_type, + GRAPH_COLOR_COLUMN, ¤t_graph_color, + -1); + + vval = g_variant_new("(ssssbddbssuuddus)", g_strdup(current_path), + g_strdup(current_id), g_strdup(current_label), g_strdup(current_interface), + current_enable, current_low_value * 1000, + current_high_value * 1000, current_alarm_enable, + current_low_alarm_command, current_high_alarm_command, + current_alarm_timeout, current_sensor_type, + current_multiplier * 1000, current_offset * 1000, + current_icon_type, g_strdup(current_graph_color)); + g_variant_builder_add_value(&builder, vval); + } + } + + g_settings_set_value (sensors_applet->settings, "slist", + g_variant_builder_end (&builder)); + + /* store current version to identify config data */ + g_settings_set_string(sensors_applet->settings, + SENSORS_APPLET_VERSION, + PACKAGE_VERSION); + + return TRUE; +} diff -Nru sensors-applet-3.0.0+git4/sensors-applet/sensors-applet-conf.h sensors-applet-3.0.0+git5/sensors-applet/sensors-applet-conf.h --- sensors-applet-3.0.0+git4/sensors-applet/sensors-applet-conf.h 1970-01-01 00:00:00.000000000 +0000 +++ sensors-applet-3.0.0+git5/sensors-applet/sensors-applet-conf.h 2015-06-17 22:13:32.000000000 +0000 @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2005-2009 Alex Murray + * + * 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. + */ + +#ifndef SENSORS_APPLET_GCONF_H +#define SENSORS_APPLET_GCONF_H + +#include "sensors-applet.h" + +#define SENSORS_APPLET_SCHEMA "org.gnome.sensors-applet" + +#define FONT_SIZE "font-size" /* hidden gconf option specifying font + * size in points */ + +#define HIDE_UNITS "hide-units" /* hidden gconf option specifying not to + * show sensor units */ + +#define IS_SETUP "setup" /* have we actually set up this instance of + * the applet (gets set to true after + * closing prefences dialog) */ + +#define DISPLAY_MODE "display-mode" /* display icons or text labels?*/ + +#define LAYOUT_MODE "layout-mode" /* value beside or below label */ +#define TEMPERATURE_SCALE "temperature-scale" /* Kelvin, + Celsius or + Fahrenheit */ +#define DISPLAY_NOTIFICATIONS "display-notifications" /* whether to + * display + * notifications */ +#define TIMEOUT "timeout-delay" /* delay (in ms) between refreshes */ +#define GRAPH_SIZE "graph-size" /* the size of the graph in pixels - + * either width if horizontal, or + * height if vertical */ +#define PATHS "paths" /* full paths to filenames */ +#define IDS "ids" /* a list of the sensor device ids */ +#define INTERFACES "interfaces" /* a list of the sensor device + * interface for each sensor */ +#define LABELS "labels" /* user defined labels for each sensor */ +#define ENABLES "sensor_enables" /* list of booleans corresponding to + * the filenames of whether a sensor + * is enabled or not */ +#define LOW_VALUES "low_values" /* stored as ints (1000 * double + * value) for accuracy, since can + * only do ints easily */ +#define HIGH_VALUES "high_values" /* stored as ints (1000 * double + * value) for accuracy, since can + * only do ints easily */ +#define ALARM_ENABLES "alarm_enables" /* list of whether each sensor + * has its alarm enabled */ +#define LOW_ALARM_COMMANDS "low_alarm_commands" /* list of commands to execute + * when each alarm is + * activated */ +#define HIGH_ALARM_COMMANDS "high_alarm_commands" /* list of commands to execute + * when each alarm is + * activated */ + +#define ALARM_TIMEOUTS "alarm_timeouts" /* list of how often each + alarm should be sounded (in + seconds) */ + +#define SENSOR_TYPES "sensor_types" /* used to identify a sensor in a + list */ + +#define MULTIPLIERS "multipliers" +#define OFFSETS "offsets" +#define ICON_TYPES "icon_types" +#define GRAPH_COLORS "graph_colors" + +#define SENSORS_APPLET_VERSION "sensors-applet-version" /* version of + * config + * data */ + +gboolean sensors_applet_gconf_save_sensors(SensorsApplet *sensors_applet); +gboolean sensors_applet_gconf_setup_sensors(SensorsApplet *sensors_applet); +void sensors_applet_conf_setup(SensorsApplet *sensors_applet); + +#endif /* SENSORS_APPLET_GCONF_H*/ diff -Nru sensors-applet-3.0.0+git4/sensors-applet/sensors-applet-gconf.c sensors-applet-3.0.0+git5/sensors-applet/sensors-applet-gconf.c --- sensors-applet-3.0.0+git4/sensors-applet/sensors-applet-gconf.c 2013-03-06 09:32:25.000000000 +0000 +++ sensors-applet-3.0.0+git5/sensors-applet/sensors-applet-gconf.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,494 +0,0 @@ -/* - * Copyright (C) 2005-2009 Alex Murray - * - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include - -#include "sensors-applet.h" -#include "sensors-applet-gconf.h" - -#define DEFAULT_TIMEOUT 2000 -#define DEFAULT_GRAPH_SIZE 42 - -static const gchar * const compatible_versions[] = { - PACKAGE_VERSION, /* always list current version */ - "2.2.7", - "2.2.6", - "2.2.5", - "2.2.4", - "2.2.3", - "2.2.2", -}; - -#define NUM_COMPATIBLE_VERSIONS G_N_ELEMENTS(compatible_versions) - -typedef enum { - SENSORS_APPLET_GCONF_ERROR = 0, - SENSORS_APPLET_VERSION_ERROR, -} SensorsAppletGConfError; - -static const gchar * const error_titles[] = { - N_("An error occurred loading the stored sensors data"), - N_("Incompatible sensors configuration found") -}; - -static const gchar * const error_messages[] = { - N_("An error has occurred when loading the stored sensors data. " - "The default values will be used to recover from this error."), - - N_("Unfortunately the previous configuration for GNOME Sensors Applet " - "is not compatible with this version. The existing sensors data " - "will be overwritten with the default values for this new version.") -}; - -/* function to be called if an error occurs - when loading values from gconf */ -static void sensors_applet_gconf_error_occurred(SensorsAppletGConfError error) { - GtkWidget *dialog; - gchar *markup; - - g_debug("Error occurred: %s", error_titles[error]); - markup = g_markup_printf_escaped("%s\n\n%s", _(error_titles[error]), _(error_messages[error])); - - dialog = gtk_message_dialog_new_with_markup(NULL, /* no parent window */ - GTK_DIALOG_MODAL, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_OK, - "%s", markup); - - g_free(markup); - - /* runs dialog as modal and doesn't return until user clicks - * button */ - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(GTK_WIDGET(dialog)); -} - - -static void sensors_applet_gconf_set_defaults(SensorsApplet *sensors_applet) { - panel_applet_gconf_set_int(sensors_applet->applet, DISPLAY_MODE, DISPLAY_ICON_WITH_VALUE, NULL); - panel_applet_gconf_set_int(sensors_applet->applet, LAYOUT_MODE, VALUE_BESIDE_LABEL, NULL); - panel_applet_gconf_set_int(sensors_applet->applet, TEMPERATURE_SCALE, CELSIUS, NULL); - panel_applet_gconf_set_int(sensors_applet->applet, TIMEOUT, DEFAULT_TIMEOUT, NULL); - panel_applet_gconf_set_int(sensors_applet->applet, GRAPH_SIZE, DEFAULT_GRAPH_SIZE, NULL); -#ifdef HAVE_LIBNOTIFY - panel_applet_gconf_set_bool(sensors_applet->applet, DISPLAY_NOTIFICATIONS, TRUE, NULL); -#endif - panel_applet_gconf_set_bool(sensors_applet->applet, IS_SETUP, FALSE, NULL); - -} - -/** - * Returns TRUE is old_version is one of the compatible versions - */ -static gboolean sensors_applet_gconf_is_compatible(const gchar *old_version) { - guint i; - for (i = 0; i < NUM_COMPATIBLE_VERSIONS; i++) { - if (g_ascii_strcasecmp(old_version, compatible_versions[i]) == 0) { - return TRUE; - } - } - return FALSE; -} - - -void sensors_applet_gconf_setup(SensorsApplet *sensors_applet) { - gboolean setup = FALSE; - gchar *old_version; - GError *error = NULL; - - /* need to convert old num_samples value to new GRAPH_SIZE - * parameter */ - gint num_samples; - if ((num_samples = panel_applet_gconf_get_int(sensors_applet->applet, - "num_samples", - NULL))) { - g_debug("Convering old num_samples value %d into graph_size", num_samples); - panel_applet_gconf_set_int(sensors_applet->applet, - GRAPH_SIZE, - (num_samples + GRAPH_FRAME_EXTRA_WIDTH), - NULL); - /* reset num_samples to zero */ - panel_applet_gconf_set_int(sensors_applet->applet, - "num_samples", - 0, - NULL); - - } - - /* convert old alarm_commands to high and low if exist */ - GSList *alarm_commands; - if ((alarm_commands = panel_applet_gconf_get_list(sensors_applet->applet, - "alarm_commands", - GCONF_VALUE_STRING, - NULL))) { - - g_debug("Converting old alarm commands to new high and low commands"); - - panel_applet_gconf_set_list(sensors_applet->applet, - LOW_ALARM_COMMANDS, - GCONF_VALUE_STRING, - alarm_commands, - NULL); - panel_applet_gconf_set_list(sensors_applet->applet, - HIGH_ALARM_COMMANDS, - GCONF_VALUE_STRING, - alarm_commands, - NULL); - /* reset old list to null */ - panel_applet_gconf_set_list(sensors_applet->applet, - "alarm_commands", - GCONF_VALUE_STRING, - NULL, - NULL); - g_slist_foreach(alarm_commands, (GFunc)g_free, NULL); - g_slist_free(alarm_commands); - - } - - setup = panel_applet_gconf_get_bool(sensors_applet->applet, - IS_SETUP, &error); - if (error) { - g_debug("Previous configuration not found: %s, setting up manually", error->message); - g_error_free(error); - error = NULL; - setup = FALSE; - } - - if (setup) { - /* see if setup version matches */ - old_version = panel_applet_gconf_get_string(sensors_applet->applet, - SENSORS_APPLET_VERSION, - &error); - /* if versions don't match or there is no saved - * version string then need to overwrite old config */ - if (error) { - g_debug("Error getting old version string: %s", error->message); - g_error_free(error); - error = NULL; - old_version = NULL; - } - - if (old_version) { - if (sensors_applet_gconf_is_compatible(old_version)) { - /* previously setup and versions match so use - * old values */ - g_debug("GConf data is compatible. Trying to set up sensors from gconf data"); - - if (sensors_applet_gconf_setup_sensors(sensors_applet)) { - g_debug("done setting up from gconf"); - } else { - g_debug("Setting gconf defaults only"); - sensors_applet_gconf_set_defaults(sensors_applet); - } - g_free(old_version); - - return; - - - } - g_free(old_version); - - } - sensors_applet_notify(sensors_applet, GCONF_READ_ERROR); - - - sensors_applet_gconf_error_occurred(SENSORS_APPLET_VERSION_ERROR); - } - - /* use defaults */ - g_debug("Setting gconf defaults only"); - sensors_applet_gconf_set_defaults(sensors_applet); -} - -enum { - PATHS_INDEX = 0, - IDS_INDEX, - LABELS_INDEX, - INTERFACES_INDEX, - SENSOR_TYPES_INDEX, - ENABLES_INDEX, - LOW_VALUES_INDEX, - HIGH_VALUES_INDEX, - ALARM_ENABLES_INDEX, - LOW_ALARM_COMMANDS_INDEX, - HIGH_ALARM_COMMANDS_INDEX, - ALARM_TIMEOUTS_INDEX, - MULTIPLIERS_INDEX, - OFFSETS_INDEX, - ICON_TYPES_INDEX, - GRAPH_COLORS_INDEX, - NUM_KEYS -}; - -const gchar * const keys[NUM_KEYS] = { - PATHS, - IDS, - LABELS, - INTERFACES, - SENSOR_TYPES, - ENABLES, - LOW_VALUES, - HIGH_VALUES, - ALARM_ENABLES, - LOW_ALARM_COMMANDS, - HIGH_ALARM_COMMANDS, - ALARM_TIMEOUTS, - MULTIPLIERS, - OFFSETS, - ICON_TYPES, - GRAPH_COLORS, -}; - -/* MUST CORRESPOND TO ABOVE KEYS */ -const GConfValueType key_types[NUM_KEYS] = { - GCONF_VALUE_STRING, /* PATHS */ - GCONF_VALUE_STRING, /* IDS, */ - GCONF_VALUE_STRING, /* LABELS */ - GCONF_VALUE_STRING, /* INTERFACES, */ - GCONF_VALUE_INT, /* SENSOR_TYPES, */ - GCONF_VALUE_BOOL, /* ENABLES, */ - GCONF_VALUE_INT, /* LOW_VALUES, */ - GCONF_VALUE_INT, /* HIGH_VALUES, */ - GCONF_VALUE_BOOL, /* ALARM_ENABLES, */ - GCONF_VALUE_STRING, /* LOW_ALARM_COMMANDS, */ - GCONF_VALUE_STRING, /* HIGH_ALARM_COMMANDS, */ - GCONF_VALUE_INT, /* ALARM_TIMEOUTS, */ - GCONF_VALUE_INT, /* MULTIPLIERS, */ - GCONF_VALUE_INT, /* OFFSETS, */ - GCONF_VALUE_INT, /* ICON_TYPES, */ - GCONF_VALUE_STRING /* GRAPH_COLORS, */ -}; - -void sensors_applet_gconf_set_current_to_lists(GSList *current[], - GSList *lists[], - int len) { - for (len--; len >= 0; len--) { - current[len] = lists[len]; - } -} - -int sensors_applet_gconf_current_not_null(GSList *current[], - int len) { - for (len--; len >= 0; len--) { - if (NULL == current[len]) { - return FALSE; - } - } - return TRUE; -} -void sensors_applet_gconf_current_get_next(GSList *current[], - int len) { - for (len--; len >= 0; len--) { - current[len] = g_slist_next(current[len]); - } -} - -void sensors_applet_gconf_free_lists(GSList *lists[], - int len) { - for (len--; len >= 0; len--) { - if (key_types[len] == GCONF_VALUE_STRING) { - g_slist_foreach(lists[len], (GFunc)g_free, NULL); - } - g_slist_free(lists[len]); - } - -} - -/* gets called if are already setup so we don't have to manually go - through and find sensors etc again */ -gboolean sensors_applet_gconf_setup_sensors(SensorsApplet *sensors_applet) { - /* everything gets stored except alarm timeout indexes, which - we set to -1, and visible which we set to false for all - parent nodes and true for all child nodes */ - int i; - GSList *lists[NUM_KEYS] = {NULL}; - - GSList *current[NUM_KEYS] = {NULL}; - - GError *error = NULL; - - for (i = 0; i < NUM_KEYS; i++) { - lists[i] = panel_applet_gconf_get_list(sensors_applet->applet, - keys[i], - key_types[i], - &error); - if (error || NULL == lists[i]) { - sensors_applet_notify(sensors_applet, GCONF_READ_ERROR); - - sensors_applet_gconf_error_occurred(SENSORS_APPLET_GCONF_ERROR); - if (error) { - g_error_free(error); - } - return FALSE; - } - } - - for (sensors_applet_gconf_set_current_to_lists(current, - lists, - NUM_KEYS); - sensors_applet_gconf_current_not_null(current, - NUM_KEYS); - sensors_applet_gconf_current_get_next(current, - NUM_KEYS)) { - - - g_debug("trying to add sensor from gconf data: %s\n", (gchar *)(current[IDS_INDEX]->data)); - /* need to ensure correct order */ - sensors_applet_add_sensor(sensors_applet, - (gchar *)(current[PATHS_INDEX]->data), - (gchar *)(current[IDS_INDEX]->data), - (gchar *)(current[LABELS_INDEX]->data), - (gchar *)(current[INTERFACES_INDEX]->data), - GPOINTER_TO_UINT(current[SENSOR_TYPES_INDEX]->data), - GPOINTER_TO_INT(current[ENABLES_INDEX]->data), - (gdouble)(GPOINTER_TO_INT(current[LOW_VALUES_INDEX]->data) / 1000.0), - (gdouble)(GPOINTER_TO_INT(current[HIGH_VALUES_INDEX]->data) / 1000.0), - GPOINTER_TO_INT(current[ALARM_ENABLES_INDEX]->data), - (gchar *)(current[LOW_ALARM_COMMANDS_INDEX]->data), - (gchar *)(current[HIGH_ALARM_COMMANDS_INDEX]->data), - GPOINTER_TO_INT(current[ALARM_TIMEOUTS_INDEX]->data), - (gdouble)(GPOINTER_TO_INT(current[MULTIPLIERS_INDEX]->data) / 1000.0), - (gdouble)(GPOINTER_TO_INT(current[OFFSETS_INDEX]->data) / 1000.0), - (SensorType)GPOINTER_TO_UINT(current[ICON_TYPES_INDEX]->data), - (gchar *)(current[GRAPH_COLORS_INDEX]->data) - - ); - - } - sensors_applet_gconf_free_lists(lists, - NUM_KEYS); - - return TRUE; -} - - -gboolean sensors_applet_gconf_save_sensors(SensorsApplet *sensors_applet) { - /* write everything to gconf except VISIBLE and - ALARM_TIMEOUT_INDEX */ - /* for stepping through GtkTreeStore data structure */ - GtkTreeIter interfaces_iter, sensors_iter; - gboolean not_end_of_interfaces = TRUE, not_end_of_sensors = TRUE; - - /* make sure all are initialized to null - since list of - * intializers is horter than number of element, rest get set - * to 0 (ie NULL) */ - GSList *lists[NUM_KEYS] = {NULL}; - int i; - gchar *current_path, *current_id, *current_label, *current_interface, - *current_low_alarm_command, *current_high_alarm_command, - *current_graph_color; - gboolean current_enable, current_alarm_enable; - gdouble current_low_value, current_high_value, current_multiplier, - current_offset; - guint current_alarm_timeout, current_sensor_type, - current_icon_type; - - GError *error = NULL; - - /* now step through the GtkTreeStore sensors to - find which sensors are enabled */ - for (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter); not_end_of_interfaces; not_end_of_interfaces = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter)) { - // store a gconf key for this interface - gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), - &interfaces_iter, - ID_COLUMN, ¤t_id, - -1); - - panel_applet_gconf_set_bool(sensors_applet->applet, current_id, TRUE, NULL); - g_free(current_id); - - /* reset sensors sentinel */ - not_end_of_sensors = TRUE; - - for (gtk_tree_model_iter_children(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter, &interfaces_iter); not_end_of_sensors; not_end_of_sensors = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter)) { - gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), - &sensors_iter, - PATH_COLUMN, ¤t_path, - ID_COLUMN, ¤t_id, - LABEL_COLUMN, ¤t_label, - INTERFACE_COLUMN, ¤t_interface, - SENSOR_TYPE_COLUMN, ¤t_sensor_type, - ENABLE_COLUMN, ¤t_enable, - LOW_VALUE_COLUMN, ¤t_low_value, - HIGH_VALUE_COLUMN, ¤t_high_value, - ALARM_ENABLE_COLUMN, ¤t_alarm_enable, - LOW_ALARM_COMMAND_COLUMN, ¤t_low_alarm_command, - HIGH_ALARM_COMMAND_COLUMN, ¤t_high_alarm_command, - ALARM_TIMEOUT_COLUMN, ¤t_alarm_timeout, - MULTIPLIER_COLUMN, ¤t_multiplier, - OFFSET_COLUMN, ¤t_offset, - ICON_TYPE_COLUMN, ¤t_icon_type, - GRAPH_COLOR_COLUMN, ¤t_graph_color, - -1); - - /* prepend values as this is faster then just - reverse list when finished */ - lists[PATHS_INDEX] = g_slist_prepend(lists[PATHS_INDEX], current_path); - lists[IDS_INDEX] = g_slist_prepend(lists[IDS_INDEX], current_id); - lists[LABELS_INDEX] = g_slist_prepend(lists[LABELS_INDEX], current_label); - lists[INTERFACES_INDEX] = g_slist_prepend(lists[INTERFACES_INDEX], current_interface); - lists[ENABLES_INDEX] = g_slist_prepend(lists[ENABLES_INDEX], GINT_TO_POINTER(current_enable)); - lists[LOW_VALUES_INDEX] = g_slist_prepend(lists[LOW_VALUES_INDEX], GINT_TO_POINTER((gint)(current_low_value * 1000))); - lists[HIGH_VALUES_INDEX] = g_slist_prepend(lists[HIGH_VALUES_INDEX], GINT_TO_POINTER((gint)(current_high_value * 1000))); - lists[ALARM_ENABLES_INDEX] = g_slist_prepend(lists[ALARM_ENABLES_INDEX], GINT_TO_POINTER(current_alarm_enable)); - lists[LOW_ALARM_COMMANDS_INDEX] = g_slist_prepend(lists[LOW_ALARM_COMMANDS_INDEX], current_low_alarm_command); - lists[HIGH_ALARM_COMMANDS_INDEX] = g_slist_prepend(lists[HIGH_ALARM_COMMANDS_INDEX], current_high_alarm_command); - lists[ALARM_TIMEOUTS_INDEX] = g_slist_prepend(lists[ALARM_TIMEOUTS_INDEX], GINT_TO_POINTER(current_alarm_timeout)); - lists[SENSOR_TYPES_INDEX] = g_slist_prepend(lists[SENSOR_TYPES_INDEX], GUINT_TO_POINTER(current_sensor_type)); - lists[MULTIPLIERS_INDEX] = g_slist_prepend(lists[MULTIPLIERS_INDEX], GINT_TO_POINTER((gint)(current_multiplier * 1000))); - lists[OFFSETS_INDEX] = g_slist_prepend(lists[OFFSETS_INDEX], GINT_TO_POINTER((gint)(current_offset * 1000))); - lists[ICON_TYPES_INDEX] = g_slist_prepend(lists[ICON_TYPES_INDEX], GUINT_TO_POINTER(current_icon_type)); - lists[GRAPH_COLORS_INDEX] = g_slist_prepend(lists[GRAPH_COLORS_INDEX], current_graph_color); - } - } - - /* keep lists in original order */ - for (i = 0; i < NUM_KEYS; i++) { - if (lists[i] != NULL) { - lists[i] = g_slist_reverse(lists[i]); - - panel_applet_gconf_set_list(sensors_applet->applet, - keys[i], - key_types[i], - lists[i], &error); - if (error) { - sensors_applet_notify(sensors_applet, GCONF_WRITE_ERROR); - - g_error_free(error); - return FALSE; - } - } else { - g_debug("list %s is NULL", keys[i]); - } - - } - - sensors_applet_gconf_free_lists(lists, - NUM_KEYS); - - /* store current version to identify config data */ - panel_applet_gconf_set_string(sensors_applet->applet, - SENSORS_APPLET_VERSION, - PACKAGE_VERSION, &error); - - return TRUE; -} diff -Nru sensors-applet-3.0.0+git4/sensors-applet/sensors-applet-gconf.h sensors-applet-3.0.0+git5/sensors-applet/sensors-applet-gconf.h --- sensors-applet-3.0.0+git4/sensors-applet/sensors-applet-gconf.h 2013-03-06 09:32:25.000000000 +0000 +++ sensors-applet-3.0.0+git5/sensors-applet/sensors-applet-gconf.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2005-2009 Alex Murray - * - * 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. - */ - -#ifndef SENSORS_APPLET_GCONF_H -#define SENSORS_APPLET_GCONF_H - -#include "sensors-applet.h" -#include - -#define FONT_SIZE "font-size" /* hidden gconf option specifying font - * size in points */ - -#define HIDE_UNITS "hide-units" /* hidden gconf option specifying not to - * show sensor units */ - -#define IS_SETUP "setup" /* have we actually set up this instance of - * the applet (gets set to true after - * closing prefences dialog) */ - -#define DISPLAY_MODE "display_mode" /* display icons or text labels?*/ - -#define LAYOUT_MODE "layout_mode" /* value beside or below label */ -#define TEMPERATURE_SCALE "temperature_scale" /* Kelvin, - Celsius or - Fahrenheit */ -#define DISPLAY_NOTIFICATIONS "display_notifications" /* whether to - * display - * notifications */ -#define TIMEOUT "timeout_delay" /* delay (in ms) between refreshes */ -#define GRAPH_SIZE "graph_size" /* the size of the graph in pixels - - * either width if horizontal, or - * height if vertical */ -#define PATHS "paths" /* full paths to filenames */ -#define IDS "ids" /* a list of the sensor device ids */ -#define INTERFACES "interfaces" /* a list of the sensor device - * interface for each sensor */ -#define LABELS "labels" /* user defined labels for each sensor */ -#define ENABLES "sensor_enables" /* list of booleans corresponding to - * the filenames of whether a sensor - * is enabled or not */ -#define LOW_VALUES "low_values" /* stored as ints (1000 * double - * value) for accuracy, since can - * only do ints easily */ -#define HIGH_VALUES "high_values" /* stored as ints (1000 * double - * value) for accuracy, since can - * only do ints easily */ -#define ALARM_ENABLES "alarm_enables" /* list of whether each sensor - * has its alarm enabled */ -#define LOW_ALARM_COMMANDS "low_alarm_commands" /* list of commands to execute - * when each alarm is - * activated */ -#define HIGH_ALARM_COMMANDS "high_alarm_commands" /* list of commands to execute - * when each alarm is - * activated */ - -#define ALARM_TIMEOUTS "alarm_timeouts" /* list of how often each - alarm should be sounded (in - seconds) */ - -#define SENSOR_TYPES "sensor_types" /* used to identify a sensor in a - list */ - -#define MULTIPLIERS "multipliers" -#define OFFSETS "offsets" -#define ICON_TYPES "icon_types" -#define GRAPH_COLORS "graph_colors" - -#define SENSORS_APPLET_VERSION "sensors_applet_version" /* version of - * config - * data */ - -gboolean sensors_applet_gconf_save_sensors(SensorsApplet *sensors_applet); -gboolean sensors_applet_gconf_setup_sensors(SensorsApplet *sensors_applet); -void sensors_applet_gconf_setup(SensorsApplet *sensors_applet); - -#endif /* SENSORS_APPLET_GCONF_H*/ diff -Nru sensors-applet-3.0.0+git4/sensors-applet/sensors-applet.h sensors-applet-3.0.0+git5/sensors-applet/sensors-applet.h --- sensors-applet-3.0.0+git4/sensors-applet/sensors-applet.h 2013-03-06 09:32:25.000000000 +0000 +++ sensors-applet-3.0.0+git5/sensors-applet/sensors-applet.h 2015-06-17 22:13:32.000000000 +0000 @@ -47,7 +47,7 @@ "sensors-applet-chip", "sensors-applet-fan", "sensors-applet-case" -}; +}; #define DEFAULT_ICON_SIZE 22 @@ -71,7 +71,7 @@ ENABLE_COLUMN, VISIBLE_COLUMN, LOW_VALUE_COLUMN, - HIGH_VALUE_COLUMN, + HIGH_VALUE_COLUMN, ALARM_ENABLE_COLUMN, LOW_ALARM_COMMAND_COLUMN, HIGH_ALARM_COMMAND_COLUMN, @@ -137,6 +137,7 @@ * list of labels and sensor values into this container */ GtkWidget *table; GList *active_sensors; + GSettings *settings; #ifdef HAVE_LIBNOTIFY NotifyNotification *notification; #endif // HAVE_LIBNOTIFY diff -Nru sensors-applet-3.0.0+git4/sensors-applet/sensors-applet-plugins.c sensors-applet-3.0.0+git5/sensors-applet/sensors-applet-plugins.c --- sensors-applet-3.0.0+git4/sensors-applet/sensors-applet-plugins.c 2013-03-06 09:32:25.000000000 +0000 +++ sensors-applet-3.0.0+git5/sensors-applet/sensors-applet-plugins.c 2015-06-17 22:13:32.000000000 +0000 @@ -67,36 +67,36 @@ sensor != NULL; sensor = g_list_next(sensor)) { SensorsAppletSensorInfo *sensor_info = (SensorsAppletSensorInfo *)sensor->data; - sensors_applet_add_sensor(sensors_applet, - sensor_info->path, - sensor_info->id, - sensor_info->label, - name_fn(), - sensor_info->type, - sensor_info->enable, - sensor_info->low_value, - sensor_info->high_value, - FALSE, // ALARM OFF - "", // no alarm commands - "", // no alarm commands - 0, // alarm_timeout - sensor_info->multiplier, - sensor_info->offset, - sensor_info->icon, - sensor_info->graph_color); - - g_free(sensor_info->path); - g_free(sensor_info->id); - g_free(sensor_info->label); - g_free(sensor_info->graph_color); - g_free(sensor_info); - } - g_list_free(sensors); - } else { - g_debug("plugin %s could not find any sensors", name_fn()); - if (g_hash_table_lookup(sensors_applet->required_plugins, + sensors_applet_add_sensor(sensors_applet, + sensor_info->path, + sensor_info->id, + sensor_info->label, + name_fn(), + sensor_info->type, + sensor_info->enable, + sensor_info->low_value, + sensor_info->high_value, + FALSE, // ALARM OFF + "", // no alarm commands + "", // no alarm commands + 0, // alarm_timeout + sensor_info->multiplier, + sensor_info->offset, + sensor_info->icon, + sensor_info->graph_color); + + g_free(sensor_info->path); + g_free(sensor_info->id); + g_free(sensor_info->label); + g_free(sensor_info->graph_color); + g_free(sensor_info); + } + g_list_free(sensors); + } else { + g_debug("plugin %s could not find any sensors", name_fn()); + if (g_hash_table_lookup(sensors_applet->required_plugins, name_fn())) - { + { g_debug("plugin %s required - registering even though no sensors detected", name_fn()); g_hash_table_insert(sensors_applet->plugins, g_strdup(name_fn()), @@ -122,30 +122,27 @@ } } -void sensors_applet_plugins_load_all(SensorsApplet *sensors_applet) +void sensors_applet_plugins_load_all(SensorsApplet *sensors_applet) { - const gchar *home; - - if ((home = g_get_home_dir()) != NULL) { - gchar *path; - path = g_build_filename(home, - SENSORS_APPLET_USER_PLUGIN_DIR, - NULL); - load_all_plugins(sensors_applet, path); - g_free(path); - } else { - g_warning("could not get home dir of user"); - } - - - load_all_plugins(sensors_applet, SENSORS_APPLET_PLUGIN_DIR); + const gchar *home; + + if ((home = g_get_home_dir()) != NULL) { + gchar *path; + path = g_build_filename(home, + SENSORS_APPLET_USER_PLUGIN_DIR, NULL); + load_all_plugins(sensors_applet, path); + g_free(path); + } else { + g_warning("could not get home dir of user"); + } + + load_all_plugins(sensors_applet, SENSORS_APPLET_PLUGIN_DIR); } SensorsAppletPluginGetSensorValue sensors_applet_plugins_get_sensor_value_func(SensorsApplet *sensors_applet, const gchar *plugin) { - return g_hash_table_lookup(sensors_applet->plugins, - plugin); + return g_hash_table_lookup(sensors_applet->plugins, plugin); } - + diff -Nru sensors-applet-3.0.0+git4/SensorsApplet.xml sensors-applet-3.0.0+git5/SensorsApplet.xml --- sensors-applet-3.0.0+git4/SensorsApplet.xml 2013-03-06 09:32:25.000000000 +0000 +++ sensors-applet-3.0.0+git5/SensorsApplet.xml 2015-06-17 22:13:32.000000000 +0000 @@ -1,3 +1,14 @@ - - - +
+ + _Preferences + sensorsapplet.preferences + + + _Help + sensorsapplet.help + + + _About + sensorsapplet.about + +