[Goodies-commits] r5533 - in xfce4-sensors-plugin/trunk: . include lib panel-plugin src
Fabian Nowak
timystery at xfce.org
Wed Oct 8 00:49:40 CEST 2008
Author: timystery
Date: 2008-10-07 22:49:40 +0000 (Tue, 07 Oct 2008)
New Revision: 5533
Modified:
xfce4-sensors-plugin/trunk/configure.in.in
xfce4-sensors-plugin/trunk/include/acpi.h
xfce4-sensors-plugin/trunk/include/configuration.h
xfce4-sensors-plugin/trunk/include/hddtemp.h
xfce4-sensors-plugin/trunk/include/lmsensors.h
xfce4-sensors-plugin/trunk/include/middlelayer.h
xfce4-sensors-plugin/trunk/include/sensors-interface-common.h
xfce4-sensors-plugin/trunk/include/sensors-interface.h
xfce4-sensors-plugin/trunk/include/types.h
xfce4-sensors-plugin/trunk/lib/acpi.c
xfce4-sensors-plugin/trunk/lib/configuration.c
xfce4-sensors-plugin/trunk/lib/hddtemp.c
xfce4-sensors-plugin/trunk/lib/lmsensors.c
xfce4-sensors-plugin/trunk/lib/middlelayer.c
xfce4-sensors-plugin/trunk/lib/sensors-interface-common.c
xfce4-sensors-plugin/trunk/lib/sensors-interface.c
xfce4-sensors-plugin/trunk/panel-plugin/Makefile.am
xfce4-sensors-plugin/trunk/panel-plugin/sensors-plugin.c
xfce4-sensors-plugin/trunk/panel-plugin/sensors-plugin.h
xfce4-sensors-plugin/trunk/src/Makefile.am
xfce4-sensors-plugin/trunk/src/actions.c
xfce4-sensors-plugin/trunk/src/callbacks.c
xfce4-sensors-plugin/trunk/src/callbacks.h
xfce4-sensors-plugin/trunk/src/interface.c
xfce4-sensors-plugin/trunk/src/interface.h
xfce4-sensors-plugin/trunk/src/main.c
Log:
further ported and repaired previously moved and ported files to have a separate libray that is independent of libxfce4panel, but bundles all common stuff for sensors-viewer and panel-plugin
Modified: xfce4-sensors-plugin/trunk/configure.in.in
===================================================================
--- xfce4-sensors-plugin/trunk/configure.in.in 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/configure.in.in 2008-10-07 22:49:40 UTC (rev 5533)
@@ -6,7 +6,7 @@
dnl 2007 Benedikt Meurer <benny at xfce.org>, Fabian Nowak <timystery at arcor.de>
dnl
-m4_define([plugin_version],[0.10.99.5])
+m4_define([plugin_version],[0.10.99.6])
AC_INIT([xfce4-sensors-plugin], [plugin_version], [timystery at arcor.de])
AC_PREREQ([2.50])
Modified: xfce4-sensors-plugin/trunk/include/acpi.h
===================================================================
--- xfce4-sensors-plugin/trunk/include/acpi.h 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/include/acpi.h 2008-10-07 22:49:40 UTC (rev 5533)
@@ -31,10 +31,13 @@
#define ACPI_INFO "info_"
-#include <glib/garray.h>
+/* Gtk/Glib includes */
+#include <glib.h>
+/* Global includes */
#include <dirent.h> /* directory listing and reading */
+/* Package/local includes */
#include "types.h"
/*
Modified: xfce4-sensors-plugin/trunk/include/configuration.h
===================================================================
--- xfce4-sensors-plugin/trunk/include/configuration.h 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/include/configuration.h 2008-10-07 22:49:40 UTC (rev 5533)
@@ -22,6 +22,10 @@
#ifndef XFCE4_SENSORS_CONFIGURATION_H
#define XFCE4_SENSORS_CONFIGURATION_H
+/* Gtk/Glib includes */
+#include <glib.h>
+
+/* Local includes */
#include "sensors-interface-common.h"
gint get_Id_from_address (gint chipnumber, gint addr, t_sensors *sensors);
Modified: xfce4-sensors-plugin/trunk/include/hddtemp.h
===================================================================
--- xfce4-sensors-plugin/trunk/include/hddtemp.h 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/include/hddtemp.h 2008-10-07 22:49:40 UTC (rev 5533)
@@ -20,9 +20,10 @@
#ifndef XFCE4_SENSORS_HDDTEMP_H
#define XFCE4_SENSORS_HDDTEMP_H
-#include <glib/garray.h>
+/* Gtk/Glib includes */
+#include <glib.h>
+/* #include <gtk/gtk.h> */
-
#define ZERO_KELVIN -273 /*.15 */
Modified: xfce4-sensors-plugin/trunk/include/lmsensors.h
===================================================================
--- xfce4-sensors-plugin/trunk/include/lmsensors.h 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/include/lmsensors.h 2008-10-07 22:49:40 UTC (rev 5533)
@@ -1,3 +1,24 @@
+/* $Id$ */
+
+/* Copyright 2007,2008 Fabian Nowak (timystery at arcor.de)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/* Note for programmers and editors: Try to use 4 spaces instead of Tab! */
+
#ifndef XFCE4_SENSORS_LMSENSORS_H
#define XFCE4_SENSORS_LMSENSORS_H
@@ -5,10 +26,13 @@
#include "config.h"
#endif
-#include <glib/garray.h>
+/* Gtk/Glib includes */
+#include <glib.h>
+/* Global includes */
#include <sensors/sensors.h>
+/* Package/local includes */
#include "types.h"
/*
Modified: xfce4-sensors-plugin/trunk/include/middlelayer.h
===================================================================
--- xfce4-sensors-plugin/trunk/include/middlelayer.h 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/include/middlelayer.h 2008-10-07 22:49:40 UTC (rev 5533)
@@ -22,10 +22,11 @@
#ifndef XFCE4_SENSORS_MIDDLELAYER_H
#define XFCE4_SENSORS_MIDDLELAYER_H
+/* Package/Local includes */
#include "types.h"
-#include <glib/garray.h>
-#include <glib/gtypes.h>
+/* Gtk/Glib includes */
+#include <glib.h>
#define NO_VALID_HDDTEMP -2
Modified: xfce4-sensors-plugin/trunk/include/sensors-interface-common.h
===================================================================
--- xfce4-sensors-plugin/trunk/include/sensors-interface-common.h 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/include/sensors-interface-common.h 2008-10-07 22:49:40 UTC (rev 5533)
@@ -26,9 +26,8 @@
/* Glib/Gtk includes */
#include <gtk/gtk.h>
-#include <glib/garray.h>
-#include <glib/gprintf.h>
-#include <glib/gtypes.h>
+#include <glib.h>
+/* #include <glib/gprintf.h> */
/* Xfce includes */
#include <libxfce4panel/xfce-panel-plugin.h>
@@ -186,6 +185,8 @@
/* ACPI thermal zones */
/*GPtrArray *acpi_zones;
gint num_acpi_zones; */
+
+ gchar *plugin_config_file;
}
t_sensors;
@@ -223,8 +224,42 @@
}
t_sensors_dialog;
-t_sensors * sensors_new (XfcePanelPlugin *plugin);
+
+/* Extern functions that need to be re-implemented in the sensors-viewer and
+ * the panel code. */
+extern void
+sensor_entry_changed (GtkWidget *widget, t_sensors_dialog *sd);
+
+extern void
+list_cell_text_edited (GtkCellRendererText *cellrenderertext,
+ gchar *path_str, gchar *new_text, t_sensors_dialog *sd);
+
+extern void
+list_cell_toggle (GtkCellRendererToggle *cell, gchar *path_str,
+ t_sensors_dialog *sd);
+
+extern void
+list_cell_color_edited (GtkCellRendererText *cellrenderertext, gchar *path_str,
+ gchar *new_color, t_sensors_dialog *sd);
+
+extern void
+minimum_changed (GtkCellRendererText *cellrenderertext, gchar *path_str,
+ gchar *new_value, t_sensors_dialog *sd);
+
+extern void
+maximum_changed (GtkCellRendererText *cellrenderertext, gchar *path_str,
+ gchar *new_value, t_sensors_dialog *sd);
+
+extern void
+temperature_unit_change (GtkWidget *widget, t_sensors_dialog *sd);
+
+/* Regularly included functions in library */
+t_sensors * sensors_new (XfcePanelPlugin *plugin, gchar * plugin_config_file);
+
void sensors_init_default_values (t_sensors *sensors, XfcePanelPlugin *plugin);
+void format_sensor_value (t_tempscale scale, t_chipfeature *chipfeature,
+ double sensorFeature, gchar **help);
+
#endif /* XFCE4_SENSORS_INTERFACE_COMMON_H */
Modified: xfce4-sensors-plugin/trunk/include/sensors-interface.h
===================================================================
--- xfce4-sensors-plugin/trunk/include/sensors-interface.h 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/include/sensors-interface.h 2008-10-07 22:49:40 UTC (rev 5533)
@@ -21,19 +21,22 @@
#define XFCE4_SENSORS_INTERFACE_H
/* Gtk includes */
-#include <gtk/gtkwidget.h>
+#include <gtk/gtk.h>
/* Local includes */
#include "sensors-interface-common.h"
-extern void add_sensors_frame (GtkWidget * notebook, t_sensors_dialog * sd);
+void fill_gtkTreeStore (GtkTreeStore *model, t_chip *chip, t_tempscale scale);
-void init_widgets (t_sensors_dialog *sd);
-
void add_sensor_settings_box ( GtkWidget * vbox, t_sensors_dialog * sd);
void add_type_box (GtkWidget * vbox, t_sensors_dialog * sd);
void add_temperature_unit_box (GtkWidget *vbox, t_sensors_dialog *sd);
+void add_sensors_frame (GtkWidget * notebook, t_sensors_dialog * sd);
+
+void init_widgets (t_sensors_dialog *sd);
+
+
#endif /* XFCE4_SENSORS_INTERFACE_H */
Modified: xfce4-sensors-plugin/trunk/include/types.h
===================================================================
--- xfce4-sensors-plugin/trunk/include/types.h 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/include/types.h 2008-10-07 22:49:40 UTC (rev 5533)
@@ -22,13 +22,14 @@
#ifndef XFCE4_SENSORS_TYPES_H
#define XFCE4_SENSORS_TYPES_H
-#include <glib/garray.h>
-#include <glib/gtypes.h>
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+/* Glib includes */
+#include <glib.h>
+
+/* Xfce includes */
#include <libxfce4util/libxfce4util.h>
#ifdef HAVE_LIBSENSORS
Modified: xfce4-sensors-plugin/trunk/lib/acpi.c
===================================================================
--- xfce4-sensors-plugin/trunk/lib/acpi.c 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/lib/acpi.c 2008-10-07 22:49:40 UTC (rev 5533)
@@ -17,14 +17,14 @@
/* Note for programmers and editors: Try to use 4 spaces instead of Tab! */
+/* Package includes */
#include <acpi.h>
#include <types.h>
-#include <glib/gmessages.h>
-#include <glib/gmem.h>
-#include <glib/gprintf.h>
-#include <glib/gstrfuncs.h>
+/* Glib includes */
+#include <glib.h>
+/* Global includes */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Modified: xfce4-sensors-plugin/trunk/lib/configuration.c
===================================================================
--- xfce4-sensors-plugin/trunk/lib/configuration.c 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/lib/configuration.c 2008-10-07 22:49:40 UTC (rev 5533)
@@ -23,8 +23,14 @@
#include <stdlib.h>
#include <unistd.h>
+/* Xfce includes */
+#include <libxfce4util/libxfce4util.h>
+#include <libxfce4panel/xfce-panel-plugin.h>
+
/* Package includes */
#include <configuration.h>
+#include <sensors-interface.h>
+#include <types.h>
gint
@@ -64,7 +70,7 @@
TRACE ("enters sensors_write_config");
- if (!(file = xfce_panel_plugin_save_location (plugin, TRUE))) {
+ if ( ! (file = sensors->plugin_config_file) ) {
TRACE ("leaves sensors_write_config: No file location specified.");
return;
}
@@ -232,7 +238,7 @@
if (plugin==NULL)
return;
- if (!(file = xfce_panel_plugin_lookup_rc_file (plugin)))
+ if (!(file = sensors->plugin_config_file))
return;
rc = xfce_rc_simple_open (file, TRUE);
@@ -265,7 +271,7 @@
TRACE ("enters sensors_read_config");
- if (!(file = xfce_panel_plugin_lookup_rc_file (plugin)))
+ if (!(file = sensors->plugin_config_file))
return;
rc = xfce_rc_simple_open (file, TRUE);
Modified: xfce4-sensors-plugin/trunk/lib/hddtemp.c
===================================================================
--- xfce4-sensors-plugin/trunk/lib/hddtemp.c 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/lib/hddtemp.c 2008-10-07 22:49:40 UTC (rev 5533)
@@ -17,26 +17,29 @@
/* Note for programmers and editors: Try to use 4 spaces instead of Tab! */
+/* Package includes */
#include <config.h>
#include <hddtemp.h>
#include <middlelayer.h>
#include <types.h>
-#include <glib/garray.h>
+/* Gtk/Glib includes */
+#include <glib.h>
+/* #include <glib/garray.h>
#include <glib/gdir.h>
#include <glib/gerror.h>
#include <glib/gmem.h>
#include <glib/gmessages.h>
#include <glib/gprintf.h>
#include <glib/gspawn.h>
-#include <glib/gstrfuncs.h>
-
-#include <gtk/gtkbox.h>
-#include <gtk/gtkcheckbutton.h>
+#include <glib/gstrfuncs.h> */
+#include <gtk/gtk.h>
+/* #include <gtk/gtkcheckbutton.h>
#include <gtk/gtkmessagedialog.h>
#include <gtk/gtklabel.h>
-#include <gtk/gtkstock.h>
+#include <gtk/gtkstock.h> */
+/* Global includes */
/* #include <stdio.h> */
#include <stdlib.h>
#include <string.h>
Modified: xfce4-sensors-plugin/trunk/lib/lmsensors.c
===================================================================
--- xfce4-sensors-plugin/trunk/lib/lmsensors.c 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/lib/lmsensors.c 2008-10-07 22:49:40 UTC (rev 5533)
@@ -1,16 +1,39 @@
+/* $Id$ */
+/* Copyright 2007,2008 Fabian Nowak (timystery at arcor.de)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/* Note for programmers and editors: Try to use 4 spaces instead of Tab! */
+
+/* Package includes */
#include <lmsensors.h>
#include <middlelayer.h>
#include <types.h>
-#include <errno.h>
-
-#include <glib/garray.h>
-#include <glib/gmessages.h>
-#include <glib/gmem.h>
+/* Gtk/Glib includes */
+#include <glib.h>
+/* #include <glib/gmessages.h>
+#include <glib/gstrfuncs.h>
+#include <glib/gmem.h> */
#include <glib/gprintf.h>
-#include <glib/gstrfuncs.h>
+
+/* Global includes */
+#include <errno.h>
#include <stdio.h>
#include <string.h>
Modified: xfce4-sensors-plugin/trunk/lib/middlelayer.c
===================================================================
--- xfce4-sensors-plugin/trunk/lib/middlelayer.c 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/lib/middlelayer.c 2008-10-07 22:49:40 UTC (rev 5533)
@@ -27,14 +27,17 @@
#include <sys/utsname.h>
#endif
-#include <glib/gdir.h>
-#include <glib/gerror.h>
+/* Gtk/Glib includes */
+#include <glib.h>
+/* #include <glib/gerror.h>
#include <glib/gmem.h>
#include <glib/gmessages.h>
-#include <glib/gprintf.h>
+#include <glib/gprintf.h> */
+/* Global includes */
#include <string.h>
+/* Package includes */
#include <middlelayer.h>
#ifdef HAVE_LIBSENSORS
Modified: xfce4-sensors-plugin/trunk/lib/sensors-interface-common.c
===================================================================
--- xfce4-sensors-plugin/trunk/lib/sensors-interface-common.c 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/lib/sensors-interface-common.c 2008-10-07 22:49:40 UTC (rev 5533)
@@ -26,7 +26,7 @@
#include <middlelayer.h>
t_sensors *
-sensors_new (XfcePanelPlugin *plugin)
+sensors_new (XfcePanelPlugin *plugin, gchar *plugin_config_file)
{
t_sensors *sensors;
gint result;
@@ -36,6 +36,7 @@
TRACE ("enters sensors_new");
sensors = g_new (t_sensors, 1);
+ sensors->plugin_config_file = plugin_config_file; /* important as we check against NULL frequently */
/* init xfce sensors stuff width default values */
sensors_init_default_values (sensors, plugin);
@@ -93,16 +94,14 @@
sensors->bars_created = FALSE;
sensors->font_size = "medium";
sensors->font_size_numerical = 2;
- if (plugin!=NULL)
- sensors->panel_size = xfce_panel_plugin_get_size (plugin);
+
sensors->show_colored_bars = TRUE;
sensors->sensors_refresh_time = 60;
sensors->scale = CELSIUS;
sensors->plugin = plugin; // we prefer storing NULL in here in case it is NULL.
- if (plugin!=NULL)
- sensors->orientation = xfce_panel_plugin_get_orientation (plugin);
+
/* double-click improvement */
sensors->exec_command = TRUE;
sensors->command_name = g_strdup("xsensors");
@@ -118,3 +117,46 @@
TRACE ("leaves sensors_init_default_values");
}
+
+void
+format_sensor_value (t_tempscale scale, t_chipfeature *chipfeature,
+ double sensorFeature, gchar **help)
+{
+ /* TRACE ("enters format_sensor_value"); */
+
+ switch (chipfeature->class) {
+ case TEMPERATURE:
+ if (scale == FAHRENHEIT) {
+ *help = g_strdup_printf(_("%5.1f °F"),
+ (float) (sensorFeature * 9/5 + 32) );
+ } else { /* Celsius */
+ *help = g_strdup_printf(_("%5.1f °C"), sensorFeature);
+ }
+ break;
+
+ case VOLTAGE:
+ *help = g_strdup_printf(_("%+5.2f V"), sensorFeature);
+ break;
+
+ case ENERGY:
+ *help = g_strdup_printf(_("%.0f mWh"), sensorFeature);
+ break;
+
+ case STATE:
+ if (sensorFeature==0.0)
+ *help = g_strdup (_("off"));
+ else
+ *help = g_strdup (_("on"));
+ break;
+
+ case SPEED:
+ *help = g_strdup_printf(_("%5.0f rpm"), sensorFeature);
+ break;
+
+ default:
+ *help = g_strdup_printf("%+5.2f", sensorFeature);
+ break;
+ } /* end switch */
+
+ /* TRACE ("leaves format_sensor_value"); */
+}
Modified: xfce4-sensors-plugin/trunk/lib/sensors-interface.c
===================================================================
--- xfce4-sensors-plugin/trunk/lib/sensors-interface.c 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/lib/sensors-interface.c 2008-10-07 22:49:40 UTC (rev 5533)
@@ -23,7 +23,7 @@
/* #include <stdlib.h> */
/* Glib/Gtk includes */
-#include <glib/gtree.h>
+#include <glib.h>
#include <gtk/gtk.h>
/* Xfce includes */
@@ -32,96 +32,60 @@
/* Package includes */
#include <sensors-interface-common.h>
#include <sensors-interface.h>
+#include <middlelayer.h>
void
-add_sensors_frame (GtkWidget * notebook, t_sensors_dialog * sd)
+fill_gtkTreeStore (GtkTreeStore *model, t_chip *chip, t_tempscale scale)
{
- GtkWidget *_vbox, *_label;
-
- TRACE ("enters add_sensors_frame");
-
- _vbox = gtk_vbox_new (FALSE, 4);
- gtk_container_set_border_width (GTK_CONTAINER(_vbox), 4);
- gtk_widget_show (_vbox);
-
- _label = gtk_label_new_with_mnemonic(_("_Sensors"));
- gtk_widget_show (_label);
-
- gtk_container_set_border_width (GTK_CONTAINER (_vbox), BORDER<<1);
-
- gtk_notebook_append_page (GTK_NOTEBOOK(notebook), _vbox, _label);
-
- add_type_box (_vbox, sd);
-
- add_sensor_settings_box (_vbox, sd);
-
- add_temperature_unit_box (_vbox, sd);
-
- TRACE ("leaves add_sensors_frame");
-}
-
-void
-init_widgets (t_sensors_dialog *sd)
-{
- int chipindex;
- t_chip *chip;
+ int featureindex, res;
+ double sensorFeature;
t_chipfeature *chipfeature;
GtkTreeIter *iter;
- t_sensors *sensors;
- GtkTreeStore *model;
- TRACE ("enters init_widgets");
+ TRACE ("enters fill_gtkTreeStore");
- sensors = sd->sensors;
+ for (featureindex=0; featureindex < chip->num_features; featureindex++)
+ {
+ chipfeature = (t_chipfeature *) g_ptr_array_index (chip->chip_features, featureindex);
+ g_assert (chipfeature!=NULL);
- for (chipindex=0; chipindex < sensors->num_sensorchips; chipindex++) {
- sd->myListStore[chipindex] = gtk_tree_store_new (6, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING,
- G_TYPE_FLOAT, G_TYPE_FLOAT);
+ iter = g_new0 (GtkTreeIter, 1);
- chip = (t_chip *) g_ptr_array_index (sensors->chips, chipindex);
- gtk_combo_box_append_text ( GTK_COMBO_BOX(sd->myComboBox),
- chip->sensorId );
- model = GTK_TREE_STORE (sd->myListStore[chipindex]);
-
- fill_gtkTreeStore (model, chip, sensors->scale);
+ if ( chipfeature->valid == TRUE ) {
+ res = sensor_get_value
+ (chip, chipfeature->address, &sensorFeature);
+ if ( res!=0) {
+ DBG ( _("Xfce Hardware Sensors Plugin:\n"
+ "Seems like there was a problem reading a sensor "
+ "feature value.\nProper proceeding cannot be "
+ "guaranteed.\n") );
+ /* FIXME: Better popup a window or DBG message or quit plugin. */
+ break;
+ }
+ g_free (chipfeature->formatted_value);
+ chipfeature->formatted_value = g_new (gchar, 0);
+ format_sensor_value (scale, chipfeature, sensorFeature,
+ &(chipfeature->formatted_value));
+ chipfeature->raw_value = sensorFeature;
+ gtk_tree_store_append (model, iter, NULL);
+ gtk_tree_store_set ( model, iter,
+ 0, chipfeature->name,
+ 1, chipfeature->formatted_value,
+ 2, chipfeature->show,
+ 3, chipfeature->color,
+ 4, chipfeature->min_value,
+ 5, chipfeature->max_value,
+ -1);
+ } /* end if sensors-valid */
+ /* g_free(iter); ??? */
}
- if(sd->sensors->num_sensorchips == 0) {
- chip = (t_chip *) g_ptr_array_index(sensors->chips, 0);
- g_assert (chip!=NULL);
- gtk_combo_box_append_text ( GTK_COMBO_BOX(sd->myComboBox),
- chip->sensorId );
- sd->myListStore[0] = gtk_tree_store_new (6, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_BOOLEAN,
- G_TYPE_STRING, G_TYPE_DOUBLE,
- G_TYPE_DOUBLE);
- chipfeature = (t_chipfeature *) g_ptr_array_index (chip->chip_features, 0);
- g_assert (chipfeature!=NULL);
+ TRACE ("leaves fill_gtkTreeStore");
+}
- g_free(chipfeature->formatted_value);
- chipfeature->formatted_value = g_strdup ("0.0");
- chipfeature->raw_value = 0.0;
- iter = g_new0 (GtkTreeIter, 1);
- gtk_tree_store_append ( GTK_TREE_STORE (sd->myListStore[0]),
- iter, NULL);
- gtk_tree_store_set ( GTK_TREE_STORE (sd->myListStore[0]),
- iter,
- 0, chipfeature->name,
- 1, "0.0", /* chipfeature->formatted_value */
- 2, False, /* chipfeature->show */
- 3, "#000000", /* chipfeature->color */
- 3, "#000000", /* chipfeature->color */
- 4, 0.0, /* chipfeature->min_value */
- 5, 0.0, /* chipfeature->max_value */
- -1);
- }
- TRACE ("leaves init_widgets");
-}
-
void
add_type_box (GtkWidget * vbox, t_sensors_dialog * sd)
{
@@ -300,3 +264,94 @@
TRACE ("leaves add_temperature_unit_box");
}
+
+
+
+void
+add_sensors_frame (GtkWidget * notebook, t_sensors_dialog * sd)
+{
+ GtkWidget *_vbox, *_label;
+
+ TRACE ("enters add_sensors_frame");
+
+ _vbox = gtk_vbox_new (FALSE, 4);
+ gtk_container_set_border_width (GTK_CONTAINER(_vbox), 4);
+ gtk_widget_show (_vbox);
+
+ _label = gtk_label_new_with_mnemonic(_("_Sensors"));
+ gtk_widget_show (_label);
+
+ gtk_container_set_border_width (GTK_CONTAINER (_vbox), BORDER<<1);
+
+ gtk_notebook_append_page (GTK_NOTEBOOK(notebook), _vbox, _label);
+
+ add_type_box (_vbox, sd);
+
+ add_sensor_settings_box (_vbox, sd);
+
+ add_temperature_unit_box (_vbox, sd);
+
+ TRACE ("leaves add_sensors_frame");
+}
+
+
+void
+init_widgets (t_sensors_dialog *sd)
+{
+ int chipindex;
+ t_chip *chip;
+ t_chipfeature *chipfeature;
+ GtkTreeIter *iter;
+ t_sensors *sensors;
+ GtkTreeStore *model;
+
+ TRACE ("enters init_widgets");
+
+ sensors = sd->sensors;
+
+ for (chipindex=0; chipindex < sensors->num_sensorchips; chipindex++) {
+ sd->myListStore[chipindex] = gtk_tree_store_new (6, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING,
+ G_TYPE_FLOAT, G_TYPE_FLOAT);
+
+ chip = (t_chip *) g_ptr_array_index (sensors->chips, chipindex);
+ gtk_combo_box_append_text ( GTK_COMBO_BOX(sd->myComboBox),
+ chip->sensorId );
+ model = GTK_TREE_STORE (sd->myListStore[chipindex]);
+
+ fill_gtkTreeStore (model, chip, sensors->scale);
+ }
+
+ if(sd->sensors->num_sensorchips == 0) {
+ chip = (t_chip *) g_ptr_array_index(sensors->chips, 0);
+ g_assert (chip!=NULL);
+ gtk_combo_box_append_text ( GTK_COMBO_BOX(sd->myComboBox),
+ chip->sensorId );
+ sd->myListStore[0] = gtk_tree_store_new (6, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_BOOLEAN,
+ G_TYPE_STRING, G_TYPE_DOUBLE,
+ G_TYPE_DOUBLE);
+ chipfeature = (t_chipfeature *) g_ptr_array_index (chip->chip_features, 0);
+ g_assert (chipfeature!=NULL);
+
+ g_free(chipfeature->formatted_value);
+ chipfeature->formatted_value = g_strdup ("0.0");
+ chipfeature->raw_value = 0.0;
+
+ iter = g_new0 (GtkTreeIter, 1);
+ gtk_tree_store_append ( GTK_TREE_STORE (sd->myListStore[0]),
+ iter, NULL);
+ gtk_tree_store_set ( GTK_TREE_STORE (sd->myListStore[0]),
+ iter,
+ 0, chipfeature->name,
+ 1, "0.0", /* chipfeature->formatted_value */
+ 2, False, /* chipfeature->show */
+ 3, "#000000", /* chipfeature->color */
+ 3, "#000000", /* chipfeature->color */
+ 4, 0.0, /* chipfeature->min_value */
+ 5, 0.0, /* chipfeature->max_value */
+ -1);
+ }
+ TRACE ("leaves init_widgets");
+}
+
Modified: xfce4-sensors-plugin/trunk/panel-plugin/Makefile.am
===================================================================
--- xfce4-sensors-plugin/trunk/panel-plugin/Makefile.am 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/panel-plugin/Makefile.am 2008-10-07 22:49:40 UTC (rev 5533)
@@ -23,7 +23,10 @@
-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
@LIBSENSORS_CFLAGS@
-xfce4_sensors_plugin_LDFLAGS = \
+xfce4_sensors_plugin_LDFLAGS = \
+ $(top_builddir)/lib/libxfce4sensors.la
+
+xfce4_sensors_plugin_LDADD = \
@GTK_LIBS@ \
@GLIB_LIBS@ \
@LIBXFCE4PANEL_LIBS@ \
Modified: xfce4-sensors-plugin/trunk/panel-plugin/sensors-plugin.c
===================================================================
--- xfce4-sensors-plugin/trunk/panel-plugin/sensors-plugin.c 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/panel-plugin/sensors-plugin.c 2008-10-07 22:49:40 UTC (rev 5533)
@@ -28,9 +28,21 @@
/* Global includes */
#include <math.h>
#include <stdlib.h>
+#include <string.h>
+/* Gtk/Glib includes */
+#include <glib.h>
+#include <glib/gprintf.h> /* ain't included in glib.h! */
+
+/* Xfce includes */
+#include <libxfce4util/libxfce4util.h>
+#include <libxfcegui4/libxfcegui4.h>
+
/* Package includes */
#include <configuration.h>
+#include <sensors-interface.h>
+#include <sensors-interface-common.h>
+#include <middlelayer.h>
/* Local includes */
#include "sensors-plugin.h"
@@ -521,6 +533,7 @@
return itemsToDisplay;
}
+
/* draw label with sensor values into panel's vbox */
static gboolean
sensors_show_text_display (t_sensors *sensors)
@@ -551,50 +564,6 @@
}
-static void
-format_sensor_value (t_tempscale scale, t_chipfeature *chipfeature,
- double sensorFeature, gchar **help)
-{
- /* TRACE ("enters format_sensor_value"); */
-
- switch (chipfeature->class) {
- case TEMPERATURE:
- if (scale == FAHRENHEIT) {
- *help = g_strdup_printf(_("%5.1f °F"),
- (float) (sensorFeature * 9/5 + 32) );
- } else { /* Celsius */
- *help = g_strdup_printf(_("%5.1f °C"), sensorFeature);
- }
- break;
-
- case VOLTAGE:
- *help = g_strdup_printf(_("%+5.2f V"), sensorFeature);
- break;
-
- case ENERGY:
- *help = g_strdup_printf(_("%.0f mWh"), sensorFeature);
- break;
-
- case STATE:
- if (sensorFeature==0.0)
- *help = g_strdup (_("off"));
- else
- *help = g_strdup (_("on"));
- break;
-
- case SPEED:
- *help = g_strdup_printf(_("%5.0f rpm"), sensorFeature);
- break;
-
- default:
- *help = g_strdup_printf("%+5.2f", sensorFeature);
- break;
- } /* end switch */
-
- /* TRACE ("leaves format_sensor_value"); */
-}
-
-
/* create tooltip
Updates the sensor values, see lines 440 and following */
static gboolean
@@ -887,6 +856,7 @@
g_ptr_array_foreach (sensors->chips, free_chip, NULL);
g_ptr_array_free (sensors->chips, TRUE);
+ g_free (sensors->plugin_config_file);
g_free (sensors);
TRACE ("leaves sensors_free");
@@ -983,7 +953,7 @@
}
-static void
+void
sensor_entry_changed (GtkWidget *widget, t_sensors_dialog *sd)
{
gint gtk_combo_box_active;
@@ -1028,56 +998,8 @@
}
-static void
-fill_gtkTreeStore (GtkTreeStore *model, t_chip *chip, t_tempscale scale)
-{
- int featureindex, res;
- double sensorFeature;
- t_chipfeature *chipfeature;
- GtkTreeIter *iter;
- TRACE ("enters fill_gtkTreeStore");
- for (featureindex=0; featureindex < chip->num_features; featureindex++)
- {
- chipfeature = (t_chipfeature *) g_ptr_array_index (chip->chip_features, featureindex);
- g_assert (chipfeature!=NULL);
-
- iter = g_new0 (GtkTreeIter, 1);
-
- if ( chipfeature->valid == TRUE ) {
- res = sensor_get_value
- (chip, chipfeature->address, &sensorFeature);
- if ( res!=0) {
- DBG ( _("Xfce Hardware Sensors Plugin:\n"
- "Seems like there was a problem reading a sensor "
- "feature value.\nProper proceeding cannot be "
- "guaranteed.\n") );
- /* FIXME: Better popup a window or DBG message or quit plugin. */
- break;
- }
- g_free (chipfeature->formatted_value);
- chipfeature->formatted_value = g_new (gchar, 0);
- format_sensor_value (scale, chipfeature, sensorFeature,
- &(chipfeature->formatted_value));
- chipfeature->raw_value = sensorFeature;
- gtk_tree_store_append (model, iter, NULL);
- gtk_tree_store_set ( model, iter,
- 0, chipfeature->name,
- 1, chipfeature->formatted_value,
- 2, chipfeature->show,
- 3, chipfeature->color,
- 4, chipfeature->min_value,
- 5, chipfeature->max_value,
- -1);
- } /* end if sensors-valid */
- /* g_free(iter); ??? */
- }
-
- TRACE ("leaves fill_gtkTreeStore");
-}
-
-
static void
reload_listbox (t_sensors_dialog *sd)
{
@@ -1103,7 +1025,7 @@
}
-static void
+void
temperature_unit_change (GtkWidget *widget, t_sensors_dialog *sd)
{
TRACE ("enters temperature_unit_change ");
@@ -1196,7 +1118,7 @@
}
-static void
+void
minimum_changed (GtkCellRendererText *cellrenderertext, gchar *path_str,
gchar *new_value, t_sensors_dialog *sd)
{
@@ -1244,7 +1166,7 @@
}
-static void
+void
maximum_changed (GtkCellRendererText *cellrenderertext, gchar *path_str,
gchar *new_value, t_sensors_dialog *sd)
{
@@ -1292,7 +1214,7 @@
}
-static void
+void
list_cell_color_edited (GtkCellRendererText *cellrenderertext, gchar *path_str,
gchar *new_color, t_sensors_dialog *sd)
{
@@ -1347,7 +1269,7 @@
}
-static void
+void
list_cell_text_edited (GtkCellRendererText *cellrenderertext,
gchar *path_str, gchar *new_text, t_sensors_dialog *sd)
{
@@ -1397,7 +1319,7 @@
}
-static void
+void
list_cell_toggle (GtkCellRendererToggle *cell, gchar *path_str,
t_sensors_dialog *sd)
{
@@ -1830,7 +1752,12 @@
g_free(sd->sensors->command_name);
sd->sensors->command_name =
g_strdup ( gtk_entry_get_text(GTK_ENTRY(sd->myCommandName_Entry)) );
- sensors_write_config (sd->sensors->plugin, sd->sensors);
+
+ if (! sd->sensors->plugin_config_file)
+ sd->sensors->plugin_config_file = xfce_panel_plugin_save_location (plugin, TRUE)
+
+ if (sd->sensors->plugin_config_file)
+ sensors_write_config (sd->sensors->plugin, sd->sensors);
}
gtk_widget_destroy (sd->dialog);
@@ -1943,11 +1870,17 @@
create_sensors_control (XfcePanelPlugin *plugin)
{
t_sensors *sensors;
+ gchar *tmp;
TRACE ("enters create_sensors_control");
- sensors = sensors_new (plugin);
+ tmp = xfce_panel_plugin_lookup_rc_file(plugin);
+ sensors = sensors_new (plugin, tmp);
+ /* need/want to encapsulate/wrap that ? */
+ sensors->orientation = xfce_panel_plugin_get_orientation (plugin);
+ sensors->panel_size = xfce_panel_plugin_get_size (plugin);
+
add_event_box (sensors);
/* Add tooltip to show extended current sensors status */
@@ -1985,6 +1918,7 @@
sensors = create_sensors_control (plugin);
+ sd->sensors->plugin_config_file = xfce_panel_plugin_lookup_rc_file(plugin);
sensors_read_config (plugin, sensors);
/* Try to resize the sensors to fit the user settings.
@@ -1997,6 +1931,7 @@
g_signal_connect (plugin, "free-data", G_CALLBACK (sensors_free), sensors);
+ sensors->plugin_config_file = xfce_panel_plugin_save_location (plugin, TRUE)
g_signal_connect (plugin, "save", G_CALLBACK (sensors_write_config),
sensors);
Modified: xfce4-sensors-plugin/trunk/panel-plugin/sensors-plugin.h
===================================================================
--- xfce4-sensors-plugin/trunk/panel-plugin/sensors-plugin.h 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/panel-plugin/sensors-plugin.h 2008-10-07 22:49:40 UTC (rev 5533)
@@ -24,24 +24,9 @@
#include <config.h>
#endif
-/* #endif */
-#include <glib/garray.h>
-#include <glib/gprintf.h>
-#include <libxfce4util/libxfce4util.h>
-#include <libxfcegui4/libxfcegui4.h>
-
-#include <string.h>
-
-#include <middlelayer.h>
-#include <sensors-interface-common.h>
-/* #include <types.h> */
-
#define APP_NAME N_("Sensors Plugin")
-
-
-
#endif /* XFCE4_SENSORS_SENSORS_H */
Modified: xfce4-sensors-plugin/trunk/src/Makefile.am
===================================================================
--- xfce4-sensors-plugin/trunk/src/Makefile.am 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/src/Makefile.am 2008-10-07 22:49:40 UTC (rev 5533)
@@ -31,8 +31,8 @@
# @LIBXFCE4PANEL_CFLAGS@
-#xfce4_sensors_LDFLAGS = \
-# $(top_builddir)/lib/libxfce4sensors.la
+xfce4_sensors_LDFLAGS = \
+ $(top_builddir)/lib/libxfce4sensors.la
xfce4_sensors_LDADD = \
@GTK_LIBS@ \
Modified: xfce4-sensors-plugin/trunk/src/actions.c
===================================================================
--- xfce4-sensors-plugin/trunk/src/actions.c 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/src/actions.c 2008-10-07 22:49:40 UTC (rev 5533)
@@ -18,3 +18,6 @@
*/
/* Note for programmers and editors: Try to use 4 spaces instead of Tab! */
+
+/* Local includes */
+#include "actions.h"
Modified: xfce4-sensors-plugin/trunk/src/callbacks.c
===================================================================
--- xfce4-sensors-plugin/trunk/src/callbacks.c 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/src/callbacks.c 2008-10-07 22:49:40 UTC (rev 5533)
@@ -18,3 +18,110 @@
*/
/* Note for programmers and editors: Try to use 4 spaces instead of Tab! */
+
+/* Global includes */
+#include <stdlib.h>
+
+/* Xfce includes */
+#include <libxfcegui4/libxfcegui4.h>
+
+/* Package includes */
+#include <sensors-interface.h>
+
+/* Local includes */
+#include "callbacks.h"
+
+void
+sensor_entry_changed (GtkWidget *widget, t_sensors_dialog *sd)
+{
+ gint gtk_combo_box_active;
+ t_chip *chip;
+
+ TRACE ("enters sensor_entry_changed");
+
+ gtk_combo_box_active = gtk_combo_box_get_active(GTK_COMBO_BOX (widget));
+
+ chip = (t_chip *) g_ptr_array_index (sd->sensors->chips,
+ gtk_combo_box_active);
+ /*
+ gtk_label_set_label (GTK_LABEL(sd->mySensorLabel), chip->description);
+ * */
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (sd->myTreeView),
+ GTK_TREE_MODEL ( sd->myListStore[gtk_combo_box_active] ) );
+
+ TRACE ("leaves sensor_entry_changed");
+}
+
+
+void
+list_cell_text_edited (GtkCellRendererText *cellrenderertext,
+ gchar *path_str, gchar *new_text, t_sensors_dialog *sd)
+{
+ gint gtk_combo_box_active;
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ t_chip *chip;
+ t_chipfeature *chipfeature;
+
+ TRACE ("enters list_cell_text_edited");
+
+ /* if (sd->sensors->display_values_graphically == TRUE) {
+ DBG("removing graphical panel");
+ sensors_remove_graphical_panel(sd->sensors);
+ DBG("done removing grap. panel");
+ } */
+ /* better send a D-BUS message instead */
+
+ gtk_combo_box_active =
+ gtk_combo_box_get_active(GTK_COMBO_BOX (sd->myComboBox));
+
+ model =
+ (GtkTreeModel *) sd->myListStore [gtk_combo_box_active];
+ path = gtk_tree_path_new_from_string (path_str);
+
+ /* get model iterator */
+ gtk_tree_model_get_iter (model, &iter, path);
+
+ /* set new value */
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 0, new_text, -1);
+ chip = (t_chip *) g_ptr_array_index(sd->sensors->chips, gtk_combo_box_active);
+
+ /* if (chip->type!=ACPI) { */ /* No Bug. The cryptic filesystem names are
+ needed for the update in ACPI and hddtemp. */
+ chipfeature = (t_chipfeature *) g_ptr_array_index (chip->chip_features,
+ atoi(path_str));
+ g_free(chipfeature->name);
+ chipfeature->name = g_strdup (new_text);
+ /* } */
+
+ /* clean up */
+ gtk_tree_path_free (path);
+
+ /* update panel */
+ /* sensors_show_panel ((gpointer) sd->sensors); */
+ /* better send a D-BUS message instead or alter the configuration file */
+
+ TRACE ("leaves list_cell_text_edited");
+}
+
+
+void
+list_cell_toggle (GtkCellRendererToggle *cell, gchar *path_str,
+ t_sensors_dialog *sd) {}
+
+void
+list_cell_color_edited (GtkCellRendererText *cellrenderertext, gchar *path_str,
+ gchar *new_color, t_sensors_dialog *sd) {}
+
+void
+minimum_changed (GtkCellRendererText *cellrenderertext, gchar *path_str,
+ gchar *new_value, t_sensors_dialog *sd) {}
+
+void
+maximum_changed (GtkCellRendererText *cellrenderertext, gchar *path_str,
+ gchar *new_value, t_sensors_dialog *sd) {}
+
+void
+temperature_unit_change (GtkWidget *widget, t_sensors_dialog *sd) {}
Modified: xfce4-sensors-plugin/trunk/src/callbacks.h
===================================================================
--- xfce4-sensors-plugin/trunk/src/callbacks.h 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/src/callbacks.h 2008-10-07 22:49:40 UTC (rev 5533)
@@ -18,3 +18,24 @@
*/
/* Note for programmers and editors: Try to use 4 spaces instead of Tab! */
+
+/* Package includes */
+#include <sensors-interface-common.h>
+
+/* Global includes */
+/* #include <glib.h> */
+#include <gtk/gtk.h>
+
+/*
+void sensor_entry_changed (GtkWidget *widget, t_sensors_dialog *sd);
+
+void list_cell_text_edited (GtkCellRendererText *cellrenderertext,
+ gchar *path_str, gchar *new_text, t_sensors_dialog *sd);
+*/
+
+/* there should also be some "private" callbacks such as closing/qutting
+ * the application.
+ */
+void close_window_requested ();
+
+
Modified: xfce4-sensors-plugin/trunk/src/interface.c
===================================================================
--- xfce4-sensors-plugin/trunk/src/interface.c 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/src/interface.c 2008-10-07 22:49:40 UTC (rev 5533)
@@ -18,3 +18,56 @@
*/
/* Note for programmers and editors: Try to use 4 spaces instead of Tab! */
+
+/* Xfce includes */
+#include <libxfcegui4/libxfcegui4.h>
+
+/* Package includes */
+#include <sensors-interface.h>
+#include <sensors-interface-common.h>
+
+/* Local includes */
+#include "interface.h"
+
+
+GtkWidget *
+create_main_window (t_sensors_dialog *sd)
+{
+
+ GtkWidget *dlg, *header, *vbox, *notebook;
+
+
+ /* start and populate */
+ dlg = (GtkWidget *) gtk_dialog_new_with_buttons (_("Xfce 4 Sensors Viewer"),
+ NULL, // anciently: GTK_WINDOW(gtk_get_toplevel(plugin));
+ GTK_DIALOG_NO_SEPARATOR, // anciently: | GTK_DIALOG_DESTROY_WITH_PARENT
+ GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 2);
+
+ header = (GtkWidget *) xfce_create_header (NULL, _("View sensor values"));
+ gtk_widget_set_size_request (GTK_BIN (header)->child, -1, 32);
+ gtk_container_set_border_width (GTK_CONTAINER (header), BORDER-2);
+ gtk_widget_show (header);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), header,
+ FALSE, TRUE, 0);
+
+ vbox = GTK_DIALOG (dlg)->vbox;
+
+ sd->dialog = dlg;
+
+ sd->myComboBox = gtk_combo_box_new_text();
+
+ init_widgets (sd);
+
+ gtk_combo_box_set_active (GTK_COMBO_BOX(sd->myComboBox), 0);
+
+ notebook = gtk_notebook_new ();
+
+ gtk_box_pack_start (GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
+ gtk_widget_show(notebook);
+
+ add_sensors_frame (notebook, sd);
+
+ return dlg;
+}
Modified: xfce4-sensors-plugin/trunk/src/interface.h
===================================================================
--- xfce4-sensors-plugin/trunk/src/interface.h 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/src/interface.h 2008-10-07 22:49:40 UTC (rev 5533)
@@ -18,3 +18,11 @@
*/
/* Note for programmers and editors: Try to use 4 spaces instead of Tab! */
+
+/* Gtk/Glib includes */
+#include <gtk/gtk.h>
+
+/* Package includes */
+#include <sensors-interface-common.h>
+
+GtkWidget * create_main_window (t_sensors_dialog *sd);
Modified: xfce4-sensors-plugin/trunk/src/main.c
===================================================================
--- xfce4-sensors-plugin/trunk/src/main.c 2008-10-07 20:00:57 UTC (rev 5532)
+++ xfce4-sensors-plugin/trunk/src/main.c 2008-10-07 22:49:40 UTC (rev 5533)
@@ -31,10 +31,15 @@
#include <config.h>
/* #endif */
-#include <sensors-interface-common.h>
+/* Package includes */
#include <sensors-interface.h>
-#include <types.h>
+#include <sensors-interface-common.h>
+/* Local includes */
+#include "actions.h"
+#include "callbacks.h"
+#include "interface.h"
+
void
print_usage ()
{
@@ -52,8 +57,8 @@
int
main (int argc, char **argv)
{
+ GtkWidget *window;
t_sensors_dialog *sd;
- GtkWidget *dlg, *header, *vbox, *notebook;
t_sensors *sensors;
if ( argc > 1 && (strcmp(argv[1], "--help")==0 || strcmp(argv[1], "-h")==0) )
@@ -62,46 +67,22 @@
return 0;
}
- /* initialize */
- sensors = sensors_new (NULL);
+ /* initialize sensor stuff */
+ sensors = sensors_new (NULL, NULL);
+ sd = g_new0 (t_sensors_dialog, 1);
sd->sensors = sensors;
- sd = g_new0 (t_sensors_dialog, 1);
+ /* build main application */
+ window = create_main_window (sd);
- /* start and populate */
- dlg = (GtkWidget *) gtk_dialog_new_with_buttons (_("Xfce 4 Sensors Viewer"),
- NULL, // anciently: GTK_WINDOW(gtk_get_toplevel(plugin));
- GTK_DIALOG_NO_SEPARATOR, // anciently: | GTK_DIALOG_DESTROY_WITH_PARENT
- GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL);
-
- gtk_container_set_border_width (GTK_CONTAINER (dlg), 2);
-
- header = (GtkWidget *) xfce_create_header (NULL, _("View sensor values"));
- gtk_widget_set_size_request (GTK_BIN (header)->child, -1, 32);
- gtk_container_set_border_width (GTK_CONTAINER (header), BORDER-2);
- gtk_widget_show (header);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), header,
- FALSE, TRUE, 0);
-
- vbox = GTK_DIALOG (dlg)->vbox;
-
- sd->dialog = dlg;
-
- sd->myComboBox = gtk_combo_box_new_text();
-
- init_widgets (sd);
-
- gtk_combo_box_set_active (GTK_COMBO_BOX(sd->myComboBox), 0);
-
- notebook = gtk_notebook_new ();
-
- gtk_box_pack_start (GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
- gtk_widget_show(notebook);
-
- add_sensors_frame (notebook, sd);
-
/* show window and run forever */
gtk_main();
+ /* do the cleaning? */
+ /*
+ gtk_widget_destroy(window);
+ g_free (window);
+ */
+
return 0;
}
More information about the Goodies-commits
mailing list