Accepting request 49370 from home:vuntz:branches:GNOME:Factory

thanks

OBS-URL: https://build.opensuse.org/request/show/49370
OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/gnome-system-monitor?expand=0&rev=47
This commit is contained in:
Dominique Leuenberger 2010-09-28 19:25:22 +00:00 committed by Git OBS Bridge
parent 20fe67b907
commit 7285afd4db
6 changed files with 27 additions and 1032 deletions

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:25b2566af336c44dc279afd7a522e3616b68047f1a1a34c8a5024a52f894429b
size 2335360

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b628edfd39e3a6b374ce133f367d3568475eb4e981a367f4f9d62a9784e5ae59
size 2432252

View File

@ -1,579 +0,0 @@
Index: configure.in
===================================================================
--- configure.in.orig
+++ configure.in
@@ -37,7 +37,7 @@ LIBXML_REQUIRED=2.0
RSVG_REQUIRED=2.12
DBUS_REQUIRED=0.7
-PKG_CHECK_MODULES(PROCMAN, glib-2.0 >= $GLIB_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libgtop-2.0 >= $LIBGTOP_REQUIRED libwnck-1.0 >= $LIBWNCK_REQUIRED gtk+-2.0 >= $GTK_REQUIRED gnome-icon-theme >= $GNOME_ICON_THEME_REQUIRED gtkmm-2.4 >= $GTKMM_REQUIRED libxml-2.0 >= $LIBXML_REQUIRED librsvg-2.0 >= $RSVG_REQUIRED glibmm-2.4 >= $GLIBMM_REQUIRED giomm-2.4 >= $GIOMM_REQUIRED dbus-glib-1 >= $DBUS_REQUIRED)
+PKG_CHECK_MODULES(PROCMAN, glib-2.0 >= $GLIB_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libgtop-2.0 >= $LIBGTOP_REQUIRED libwnck-1.0 >= $LIBWNCK_REQUIRED gtk+-2.0 >= $GTK_REQUIRED gnome-icon-theme >= $GNOME_ICON_THEME_REQUIRED gtkmm-2.4 >= $GTKMM_REQUIRED libxml-2.0 >= $LIBXML_REQUIRED librsvg-2.0 >= $RSVG_REQUIRED glibmm-2.4 >= $GLIBMM_REQUIRED giomm-2.4 >= $GIOMM_REQUIRED dbus-glib-1 >= $DBUS_REQUIRED hal hwinfo)
AC_ARG_ENABLE(more-warnings,
Index: src/hardware.h
===================================================================
--- /dev/null
+++ src/hardware.h
@@ -0,0 +1,32 @@
+/* Gnome System Monitor - hardware.h
+ * Copyright (C) 2008 Novell, Inc.
+ *
+ * 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 Library 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.
+ *
+ */
+
+
+
+
+#ifndef _GSM_HARDWARE_H_
+#define _GSM_HARDWARE_H_
+
+#include <gtk/gtkwidget.h>
+
+
+GtkWidget* create_hardware_view();
+
+
+#endif
Index: src/hardware.cpp
===================================================================
--- /dev/null
+++ src/hardware.cpp
@@ -0,0 +1,293 @@
+/* Gnome System Monitor - hardware.cpp
+ * Copyright (C) 2008 Novell, Inc.
+ *
+ * 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 Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+
+#include <glib/gi18n.h>
+
+#include <gtk/gtkvbox.h>
+#include <gtk/gtkscrolledwindow.h>
+
+#include <sigc++/bind.h>
+#include <gtkmm/treeiter.h>
+
+#include <hd.h>
+
+#include "hardware.h"
+#include "interface.h"
+
+enum HwColumns
+{
+ HW_DEVICE,
+ HW_TYPE,
+ HW_ICON,
+ HW_N_COLUMNS
+};
+
+
+struct hw_map_data_t {
+ hd_hw_item_t key;
+ const char * icon;
+ const char * type_label;
+};
+
+typedef std::map<hd_hw_item_t, const hw_map_data_t*> hw_map_t;
+
+static const hw_map_t & get_map_data()
+{
+ static hw_map_t s_map;
+ static const hw_map_data_t _s_map_data[] = {
+ { hw_sys, "system", "" },
+ { hw_cpu, "", _("CPU") },
+ { hw_keyboard, "keyboard", _("Keyboard") },
+ { hw_braille, "braille", _("Braille device") },
+ { hw_mouse, "mouse", _("Mouse") },
+ { hw_joystick, "joystick", _("Joystick") },
+ { hw_printer, "printer", _("Printer") },
+ { hw_scanner, "scanner", _("Scanner") },
+ { hw_chipcard, "", "chipcard??" },
+ { hw_monitor, "display", _("Monitor") },
+ { hw_tv, "", _("TV") },
+ { hw_framebuffer, "", _("Framebuffer") },
+ { hw_camera, "camera", _("Camera") },
+ { hw_sound, "audio-card", _("Sound card") },
+ { hw_storage_ctrl, "", _("Storage controller") },
+ { hw_network_ctrl, "", _("Network controller") },
+ { hw_isdn, "", _("ISDN adapter") },
+ { hw_modem, "modem", _("Modem") },
+ { hw_network, "network-wired", _("Network interface") },
+ { hw_disk, "drive-harddisk", _("Hard drive") },
+ { hw_partition, "", _("Partition") },
+ { hw_cdrom, "drive-cdrom", _("CDROM Drive") },
+ { hw_floppy, "media-floppy", _("Floppy Drive") },
+ { hw_manual, "", "manual???" },
+ { hw_usb_ctrl, "", _("USB Controller") },
+ { hw_usb, "", _("USB Device") },
+ { hw_bios, "", _("BIOS") },
+ { hw_pci, "", _("PCI Device") },
+ { hw_isapnp, "", _("ISA PnP Device") },
+ { hw_bridge, "", _("Bridge") },
+ { hw_hub, "", _("Hub") },
+ { hw_scsi, "", _("SCSI Device") },
+ { hw_ide, "", _("IDE Device") },
+ { hw_memory, "", _("Memory") },
+ { hw_dvb, "", _("DV-B Receiver") },
+ { hw_pcmcia, "", _("PCMCIA Card") },
+ { hw_pcmcia_ctrl, "", _("PCMCIA Controller") },
+ { hw_ieee1394, "", _("Firewire Device") },
+ { hw_ieee1394_ctrl, "", _("Firewire Controller") },
+ { hw_hotplug, "", _("Hotplug Device") },
+ { hw_hotplug_ctrl, "", _("Hotplug Controller") },
+ { hw_zip, "media-zip", _("Zip Drive") },
+ { hw_pppoe, "", _("PPPoE Interface") },
+ { hw_wlan, "", _("WLAN Interface") },
+ { hw_redasd, "", "redasd??" },
+ { hw_dsl, "", _("DSL Modem") },
+ { hw_block, "", _("Block Device") },
+ { hw_tape, "media-tape", _("Tape Drive") },
+ { hw_vbe, "", _("vbe???") },
+ { hw_bluetooth, "", _("Bluetooth Device") },
+ { hw_fingerprint, "", _("Fingerprint Reader") },
+
+ { hw_none, NULL, NULL }
+ };
+ if (s_map.empty()) {
+ const struct hw_map_data_t *p = _s_map_data;
+ while ((p->key != hw_none) && (p->key != hw_bridge)) {
+ s_map.insert(std::make_pair(p->key, p));
+ p++;
+ }
+ }
+ return s_map;
+}
+
+static
+const char * get_hardware_type(hd_hw_item_t hwclass)
+{
+ const hw_map_t & hw_map(get_map_data());
+
+ hw_map_t::const_iterator iter = hw_map.find(hwclass);
+ if(iter != hw_map.end() && iter->second) {
+ return iter->second->type_label;
+ }
+ return NULL;
+}
+
+
+static
+Glib::RefPtr<Gdk::Pixbuf> get_hardware_icon(hd_hw_item_t hwclass)
+{
+ Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+
+ Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default();
+
+ const hw_map_t & hw_map(get_map_data());
+
+ hw_map_t::const_iterator iter = hw_map.find(hwclass);
+ if(iter != hw_map.end() && iter->second && iter->second->icon
+ && *iter->second->icon) {
+ pixbuf = icon_theme->load_icon(iter->second->icon, 16,
+ Gtk::ICON_LOOKUP_USE_BUILTIN);
+ }
+
+ return pixbuf;
+}
+
+static
+void populate_hardware_view(GtkTreeStore * model)
+{
+ hd_data_t *hd_data;
+ hd_t *hd;
+
+ g_object_freeze_notify(G_OBJECT(model));
+
+ std::map<std::string, Gtk::TreeIter> item_map;
+ std::list<Gtk::TreeIter> unparented;
+ hd_data = (hd_data_t *)calloc(1, sizeof *hd_data);
+
+ hd = hd_list(hd_data, hw_all, 1, NULL);
+ for(; hd; hd = hd->next) {
+ const char * name = hd->model;
+ hd_hw_item_t iclass = hd->hw_class;
+ // for now skip network interfaces.
+ if(iclass == hw_network)
+ continue;
+ GtkTreeIter *parent = NULL;
+ if(hd->parent_id) {
+ std::map<std::string, Gtk::TreeIter>::iterator iter;
+ iter = item_map.find(hd->parent_id);
+ if(iter != item_map.end()) {
+ parent = iter->second.gobj();
+ }
+ }
+
+ Glib::RefPtr<Gdk::Pixbuf> pixbuf = get_hardware_icon(iclass);
+ const char * device_type = get_hardware_type(iclass);
+ if(name && *name) {
+ Gtk::TreeIter iter;
+ gtk_tree_store_append(model, iter.gobj(), parent);
+ gtk_tree_store_set(model, iter.gobj(), HW_DEVICE, name,
+ HW_ICON, pixbuf ? pixbuf->gobj() : NULL,
+ HW_TYPE, device_type ? device_type : "",
+ -1);
+ item_map[hd->unique_id] = iter;
+ if(hd->parent_id && !parent) {
+ // has a parent id but no parent found
+ unparented.push_front(iter);
+ }
+ }
+ }
+
+ while(!unparented.empty()) {
+ Gtk::TreeIter treeiter(unparented.front());
+
+ printf("TODO reparent\n");
+ // reparent
+ unparented.pop_front();
+ }
+
+
+ hd_free_hd_list(hd); /* free it */
+ hd_free_hd_data(hd_data);
+ free(hd_data);
+ free(hd);
+ g_object_thaw_notify(G_OBJECT(model));
+ g_object_unref(model);
+}
+
+
+
+GtkWidget* create_hardware_view()
+{
+ GtkWidget *vbox;
+ GtkWidget *label;
+ GtkWidget *scrolled;
+ GtkWidget *hw_tree;
+ GtkTreeStore *model;
+ GtkTreeViewColumn *col;
+ GtkCellRenderer *cell;
+
+ const gchar * const titles[] = {
+ N_("Device"),
+ N_("Type")
+ };
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
+ label = make_title_label(_("Hardware"));
+ gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
+
+ scrolled = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled),
+ GTK_SHADOW_IN);
+
+ gtk_box_pack_start(GTK_BOX(vbox), scrolled, TRUE, TRUE, 0);
+
+ model = gtk_tree_store_new(HW_N_COLUMNS, /* n columns */
+ G_TYPE_STRING, /* HW_DEVICE */
+ G_TYPE_STRING, /* HW_TYPE */
+ GDK_TYPE_PIXBUF /* HW_ICON */
+ );
+
+ hw_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+ gtk_container_add(GTK_CONTAINER(scrolled), hw_tree);
+ gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(hw_tree), TRUE);
+ g_object_unref(G_OBJECT(model));
+
+ /* icon + device */
+
+ col = gtk_tree_view_column_new();
+ cell = gtk_cell_renderer_pixbuf_new();
+ gtk_tree_view_column_pack_start(col, cell, FALSE);
+ gtk_tree_view_column_set_attributes(col, cell, "pixbuf", HW_ICON,
+ NULL);
+ cell = gtk_cell_renderer_text_new();
+ gtk_tree_view_column_pack_start(col, cell, FALSE);
+ gtk_tree_view_column_set_attributes(col, cell, "text", HW_DEVICE,
+ NULL);
+ gtk_tree_view_column_set_title(col, titles[HW_DEVICE]);
+ gtk_tree_view_column_set_sort_column_id(col, HW_DEVICE);
+ gtk_tree_view_column_set_reorderable(col, TRUE);
+ gtk_tree_view_column_set_resizable(col, TRUE);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(hw_tree), col);
+
+ /* type */
+ col = gtk_tree_view_column_new();
+ cell = gtk_cell_renderer_text_new();
+ gtk_tree_view_column_pack_start(col, cell, FALSE);
+ gtk_tree_view_column_set_attributes(col, cell, "text", HW_TYPE,
+ NULL);
+ gtk_tree_view_column_set_title(col, titles[HW_TYPE]);
+ gtk_tree_view_column_set_sort_column_id(col, HW_TYPE);
+ gtk_tree_view_column_set_reorderable(col, TRUE);
+ gtk_tree_view_column_set_resizable(col, TRUE);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(hw_tree), col);
+
+ if(!Glib::thread_supported())
+ Glib::thread_init();
+ Glib::Thread::create(sigc::bind(&populate_hardware_view, GTK_TREE_STORE(g_object_ref(model))), false);
+
+ gtk_widget_show_all(vbox);
+
+ return vbox;
+}
+
+
Index: src/interface.cpp
===================================================================
--- src/interface.cpp.orig
+++ src/interface.cpp
@@ -1,5 +1,6 @@
/* Procman - main window
* Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2008 Novell, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -40,6 +41,7 @@
#include "disks.h"
#include "sysinfo.h"
#include "gsm_color_button.h"
+#include "hardware.h"
static void cb_toggle_tree (GtkAction *action, gpointer data);
@@ -610,9 +612,9 @@ create_main_window (ProcData *procdata)
GtkWidget *menubar;
GtkWidget *main_box;
GtkWidget *notebook;
- GtkWidget *tab_label1, *tab_label2, *tab_label3;
+ GtkWidget *tab_label1, *tab_label2, *tab_label3 , *tab_label4;
GtkWidget *vbox1;
- GtkWidget *sys_box, *devices_box;
+ GtkWidget *sys_box, *devices_box, *hardware_box;
GtkWidget *sysinfo_box, *sysinfo_label;
app = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@@ -702,6 +704,10 @@ create_main_window (ProcData *procdata)
tab_label3 = gtk_label_new (_("File Systems"));
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), devices_box, tab_label3);
+ hardware_box = create_hardware_view ();
+ tab_label4 = gtk_label_new (_("Hardware"));
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), hardware_box, tab_label4);
+
g_signal_connect (G_OBJECT (notebook), "switch-page",
G_CALLBACK (cb_switch_page), procdata);
g_signal_connect (G_OBJECT (notebook), "change-current-page",
Index: src/Makefile.am
===================================================================
--- src/Makefile.am.orig
+++ src/Makefile.am
@@ -24,6 +24,7 @@ gnome_system_monitor_SOURCES = \
smooth_refresh.cpp smooth_refresh.h \
defaulttable.h \
disks.cpp disks.h \
+ hardware.cpp hardware.h \
selinux.h selinux.cpp \
procman_gnomesu.h procman_gnomesu.cpp \
procman_gksu.h procman_gksu.cpp \
Index: src/sysinfo.cpp
===================================================================
--- src/sysinfo.cpp.orig
+++ src/sysinfo.cpp
@@ -14,6 +14,8 @@
#include <glibtop/mem.h>
#include <glibtop/sysinfo.h>
+#include <libhal.h>
+
#include <unistd.h>
#include <netdb.h>
#include <sys/socket.h>
@@ -38,6 +40,18 @@ using std::vector;
namespace {
+ string get_hal_property(LibHalContext * ctx, const char *udi, const char *prop_name,
+ DBusError * error)
+ {
+ string prop_val;
+ char * property;
+ property = libhal_device_get_property_string(ctx, udi, prop_name, error);
+ if(property) {
+ prop_val = property;
+ libhal_free_string(property);
+ }
+ return prop_val;
+ }
class SysInfo
{
@@ -53,6 +67,12 @@ namespace {
guint n_processors;
vector<string> processors;
+ /* system info */
+ string bios_version;
+ string bios_date;
+ string machine_type_model;
+ string system_serial;
+ string system_board_serial;
SysInfo()
{
@@ -61,6 +81,7 @@ namespace {
this->load_disk_info();
this->load_uname_info();
this->load_gnome_version();
+ this->load_system_info();
}
virtual ~SysInfo()
@@ -195,6 +216,49 @@ namespace {
this->gnome_version = values[0] + '.' + values[1] + '.' + values[2];
}
+
+ void load_system_info()
+ {
+ //
+ DBusError error;
+ DBusConnection *connection;
+
+ dbus_error_init (&error);
+ connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
+
+ LibHalContext * ctx = libhal_ctx_new();
+
+ if(ctx) {
+ libhal_ctx_set_dbus_connection (ctx, connection);
+ if(!libhal_ctx_init (ctx, &error)) {
+ printf("ctx init failed\n");
+ if (dbus_error_is_set (&error)) {
+ dbus_error_free (&error);
+ return;
+ }
+ }
+
+ this->bios_version = get_hal_property(ctx, "/org/freedesktop/Hal/devices/computer",
+ "system.firmware.version", NULL);
+ this->bios_date = get_hal_property(ctx, "/org/freedesktop/Hal/devices/computer",
+ "system.firmware.release_date", NULL);
+ this->machine_type_model = get_hal_property(ctx, "/org/freedesktop/Hal/devices/computer",
+ "system.product", NULL);
+ if(this->machine_type_model.empty()) {
+ dbus_error_init(&error);
+ this->machine_type_model = get_hal_property(ctx, "/org/freedesktop/Hal/devices/computer",
+ "system.hardware.product", NULL);
+ }
+ this->system_serial = get_hal_property(ctx, "/org/freedesktop/Hal/devices/computer",
+ "system.hardware.serial", NULL);
+ this->system_board_serial = get_hal_property(ctx, "/org/freedesktop/Hal/devices/computer",
+ "system.hardware.uuid", NULL);
+
+ libhal_ctx_shutdown (ctx, &error);
+ libhal_ctx_free(ctx);
+ }
+ dbus_error_free(&error);
+ }
};
@@ -524,6 +588,10 @@ procman_create_sysinfo_view(void)
GtkWidget *memory_label;
GtkWidget *processor_label;
+ GtkWidget *bios_table;
+ GtkWidget *bios_version_label;
+ GtkWidget *bios_date_label;
+
GtkWidget *disk_space_table;
GtkWidget *disk_space_label;
@@ -611,15 +679,19 @@ procman_create_sysinfo_view(void)
/* hardware section */
markup = g_strdup_printf(_("<b>Hardware</b>"));
- hardware_table = add_section(GTK_BOX(vbox), markup, data->processors.size(), 2, NULL);
+ hardware_table = add_section(GTK_BOX(vbox), markup, data->processors.size() + 4, 2, NULL);
g_free(markup);
+ add_row(GTK_TABLE(hardware_table), _("Machine model:"),
+ data->machine_type_model.c_str(), 0);
+
markup = procman::format_size(data->memory_bytes);
memory_label = add_row(GTK_TABLE(hardware_table), _("Memory:"),
- markup, 0);
+ markup, 1);
g_free(markup);
- for (guint i = 0; i < data->processors.size(); ++i) {
+ guint i;
+ for (i = 0; i < data->processors.size(); ++i) {
const gchar * t;
if (data->processors.size() > 1) {
markup = g_strdup_printf(_("Processor %d:"), i);
@@ -631,20 +703,33 @@ procman_create_sysinfo_view(void)
}
processor_label = add_row(GTK_TABLE(hardware_table), t,
- data->processors[i].c_str(), 1 + i);
+ data->processors[i].c_str(), 2 + i);
if(markup)
g_free(markup);
}
- /* disk space section */
- markup = g_strdup_printf(_("<b>System Status</b>"));
- disk_space_table = add_section(GTK_BOX(vbox), markup, 1, 2, NULL);
- g_free(markup);
+ add_row(GTK_TABLE(hardware_table), _("Serial number:"),
+ data->system_serial.c_str(), 2 + i);
+ add_row(GTK_TABLE(hardware_table), _("System UUID:"),
+ data->system_board_serial.c_str(), 3 + i);
+
+ /* bios section */
+
+ bios_table = add_section(GTK_BOX(vbox), _("<b>BIOS</b>"), 2, 2, NULL);
+
+ bios_version_label = add_row(GTK_TABLE(bios_table), _("BIOS version:"),
+ data->bios_version.c_str(), 0);
+ bios_date_label = add_row(GTK_TABLE(bios_table), _("BIOS date:"),
+ data->bios_date.c_str(), 1);
+
+ /* disk space section */
+ disk_space_table = add_section(GTK_BOX(vbox), _("<b>System Status</b>"),
+ 1, 2, NULL);
markup = procman::format_size(data->free_space_bytes);
- disk_space_label = add_row(GTK_TABLE(disk_space_table),
+ disk_space_label = add_row(GTK_TABLE(disk_space_table),
_("Available disk space:"), markup,
0);
g_free(markup);

View File

@ -1,437 +0,0 @@
Index: gnome-system-monitor-2.26.0.1/src/Makefile.am
===================================================================
--- gnome-system-monitor-2.26.0.1.orig/src/Makefile.am
+++ gnome-system-monitor-2.26.0.1/src/Makefile.am
@@ -25,6 +25,7 @@ gnome_system_monitor_SOURCES = \
defaulttable.h \
disks.cpp disks.h \
hardware.cpp hardware.h \
+ acpiview.cpp acpiview.h \
selinux.h selinux.cpp \
procman_gnomesu.h procman_gnomesu.cpp \
procman_gksu.h procman_gksu.cpp \
Index: gnome-system-monitor-2.26.0.1/src/acpiview.cpp
===================================================================
--- /dev/null
+++ gnome-system-monitor-2.26.0.1/src/acpiview.cpp
@@ -0,0 +1,310 @@
+/* Gnome System Monitor - acpiview.cpp
+ * Copyright (C) 2008 Novell, Inc.
+ *
+ * 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 Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <glib/gi18n.h>
+
+#include <gtk/gtkvbox.h>
+#include <gtk/gtktable.h>
+#include <gtk/gtkmisc.h>
+#include <gtk/gtklabel.h>
+
+#include "interface.h"
+#include "acpiview.h"
+
+#define PROC_ACPI_IBM_DIR "/proc/acpi/ibm/"
+
+#define UNSUPPORTED -1
+#define DISABLED 0
+#define ENABLED 1
+#define OFF 0
+#define ON 1
+
+AcpiData *acpi_data_new ()
+{
+ AcpiData * d = (AcpiData *)calloc(sizeof(AcpiData), 1);
+ d->bluetooth = -1;
+ d->fan = -1;
+ d->brightness = -1;
+ d->in_dock = -1;
+ d->thinklight = -1;
+ d->cpu_temp = -1;
+ d->gpu_temp = -1;
+ d->battery_temp = -1;
+ return d;
+}
+
+static
+const char * enabled_value_to_string(int v)
+{
+ if (v == DISABLED)
+ {
+ return _("disabled");
+ }
+ else if (v == ENABLED)
+ {
+ return _("enabled");
+ }
+ return _("unsupported");
+}
+
+static
+const char * onoff_value_to_string(int v)
+{
+ if (v == ON)
+ {
+ return _("on");
+ }
+ else if (v == OFF)
+ {
+ return _("off");
+ }
+ return _("unsupported");
+}
+
+
+static
+char * read_value(const char *value, const char * format,
+ char * buffer)
+{
+ int ret;
+ char * rvalue = NULL;
+ FILE *file = fopen(value, "r");
+ if (file)
+ {
+ ret = fscanf (file, format, buffer);
+ if(ret == 1)
+ {
+ rvalue = buffer;
+ }
+ ret = fclose(file);
+ }
+ return rvalue;
+}
+
+/* MUST free() the return value */
+static
+char * read_value_line(const char *value)
+{
+ int ret;
+ char * rvalue = NULL;
+ size_t len = 0;
+ FILE *file = fopen(value, "r");
+ if (file)
+ {
+ ret = getline (&rvalue, &len, file);
+ ret = fclose(file);
+ }
+ return rvalue;
+}
+
+static int get_bluetooth ()
+{
+ int value = -1;
+ char s[10] = "";
+ char * svalue = read_value(PROC_ACPI_IBM_DIR "bluetooth", "status: %9s", s);
+ if(svalue)
+ {
+ if(strcmp(s,"enabled") == 0)
+ {
+ value = ENABLED;
+ }
+ else
+ {
+ value = DISABLED;
+ }
+ }
+ return value;
+}
+
+
+static int get_fan ()
+{
+ int value = -1;
+ char s[10] = "";
+ char * svalue = read_value(PROC_ACPI_IBM_DIR "fan", "status: %9s", s);
+ if(svalue)
+ {
+ if(strcmp(s,"enabled") == 0)
+ {
+ value = ENABLED;
+ }
+ else
+ {
+ value = DISABLED;
+ }
+ }
+ return value;
+}
+
+
+static int get_brightness ()
+{
+ int value = -1;
+ int ret;
+ char rvalue[512];
+ char *prvalue = rvalue;
+ size_t len = 512;
+ FILE *file = fopen("/proc/acpi/video/VID1/LCD0/brightness", "r");
+ if (file)
+ {
+ ret = getline (&prvalue, &len, file);
+ ret = fscanf (file, "current: %d", &value);
+ ret = fclose(file);
+ }
+
+ return value;
+}
+
+static int get_in_dock ()
+{
+ return -1;
+}
+
+static int get_thinklight ()
+{
+ int value = -1;
+ char s[10] = "";
+ char * svalue = read_value(PROC_ACPI_IBM_DIR "light", "status: %9s", s);
+ if(svalue)
+ {
+ if(strcmp(s,"on") == 0)
+ {
+ value = ON;
+ }
+ else
+ {
+ value = OFF;
+ }
+ }
+ return value;
+}
+
+static void get_temps (int & cpu, int & gpu, int & batt)
+{
+ cpu = gpu = batt = -1;
+ char * svalue = read_value_line(PROC_ACPI_IBM_DIR "thermal");
+ if(svalue)
+ {
+ int t1, t2, t3, t4, t5, t6, t7, t8,
+ t9, t10, t11, t12, t13, t14, t15, t16;
+
+// printf("svalue -> %s\n", svalue);
+ sscanf(svalue, "temperatures: %d %d %d %d %d %d %d %d %d "
+ "%d %d %d %d %d %d %d", &t1, &t2, &t3, &t4, &t5,
+ &t6, &t7, &t8, &t9, &t10, &t11, &t12, &t13, &t14,
+ &t15, &t16);
+ // I'm not sure which one is what.
+ cpu = t1;
+ gpu = t2;
+ batt = t4;
+ free (svalue);
+ }
+}
+
+
+void acpi_data_init (AcpiData * d)
+{
+ d->bluetooth = get_bluetooth ();
+ d->fan = get_fan ();
+ d->brightness = get_brightness ();
+ d->in_dock = get_in_dock();
+ d->thinklight = get_thinklight ();
+ get_temps (d->cpu_temp, d->gpu_temp, d->battery_temp);
+}
+
+void acpi_data_free (AcpiData * d)
+{
+ free(d);
+}
+
+
+bool is_thinkpad ()
+{
+ struct stat s;
+ int r = stat(PROC_ACPI_IBM_DIR, &s);
+ return ((r == 0) && S_ISDIR(s.st_mode));
+}
+
+static
+void add_row (GtkTable *table, int row,
+ const gchar * label, const gchar * value)
+{
+ GtkWidget *header = gtk_label_new(label);
+ gtk_misc_set_alignment(GTK_MISC(header), 0.0, 0.5);
+ gtk_table_attach(
+ table, header,
+ 0, 1, row, row + 1,
+ GTK_FILL, GTK_FILL, 6, 6
+ );
+
+ GtkWidget *label_widget = gtk_label_new(value);
+ gtk_misc_set_alignment(GTK_MISC(label_widget), 0.0, 0.5);
+ gtk_table_attach(
+ table, label_widget,
+ 1, 2, row, row + 1,
+ GTK_FILL, GTK_FILL, 6, 6
+ );
+}
+
+GtkWidget* create_acpi_view (AcpiData * d)
+{
+ GtkWidget *table;
+ GtkWidget *vbox;
+ GtkWidget *label;
+
+ vbox = gtk_vbox_new(FALSE, 6);
+ gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
+
+ label = make_title_label(_("ThinkPad"));
+ gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
+
+ table = gtk_table_new(5, 2, FALSE);
+
+ gtk_table_set_row_spacings(GTK_TABLE(table), 6);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 6);
+ gtk_container_set_border_width(GTK_CONTAINER(table), 6);
+ gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, TRUE, 0);
+
+ int row = 0;
+ char buf[32];
+ add_row(GTK_TABLE(table), row++, _("Bluetooth"),
+ enabled_value_to_string (d->bluetooth));
+ add_row(GTK_TABLE(table), row++, _("Fan"),
+ enabled_value_to_string (d->fan));
+ snprintf(buf, 32, "%d", d->brightness);
+ add_row(GTK_TABLE(table), row++, _("Screen brightness"), buf);
+ add_row(GTK_TABLE(table), row++, _("In Docking station"), _("no"));
+ add_row(GTK_TABLE(table), row++, _("Lenovo ThinkLight"),
+ onoff_value_to_string (d->thinklight));
+
+ snprintf(buf, 32, "%d C", d->cpu_temp);
+ add_row(GTK_TABLE(table), row++, _("CPU Temp"), buf);
+ snprintf(buf, 32, "%d C", d->gpu_temp);
+ add_row(GTK_TABLE(table), row++, _("GPU Temp"), buf);
+ snprintf(buf, 32, "%d C", d->battery_temp);
+ add_row(GTK_TABLE(table), row++, _("Battery Temp"), buf);
+
+ return vbox;
+}
Index: gnome-system-monitor-2.26.0.1/src/acpiview.h
===================================================================
--- /dev/null
+++ gnome-system-monitor-2.26.0.1/src/acpiview.h
@@ -0,0 +1,45 @@
+/* Gnome System Monitor - acpiview.h
+ * Copyright (C) 2008 Novell, Inc.
+ *
+ * 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 Library 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.
+ *
+ */
+
+#ifndef _GSM_ACPIVIEW_H_
+#define _GSM_ACPIVIEW_H_
+
+#include <gtk/gtkwidget.h>
+
+
+struct AcpiData
+{
+ int bluetooth;
+ int fan;
+ int brightness;
+ int in_dock;
+ int thinklight;
+ int cpu_temp;
+ int gpu_temp;
+ int battery_temp;
+};
+
+AcpiData *acpi_data_new ();
+void acpi_data_init (AcpiData *);
+void acpi_data_free (AcpiData *);
+
+bool is_thinkpad ();
+GtkWidget* create_acpi_view (AcpiData *);
+
+#endif
Index: gnome-system-monitor-2.26.0.1/src/interface.cpp
===================================================================
--- gnome-system-monitor-2.26.0.1.orig/src/interface.cpp
+++ gnome-system-monitor-2.26.0.1/src/interface.cpp
@@ -42,6 +42,7 @@
#include "sysinfo.h"
#include "gsm_color_button.h"
#include "hardware.h"
+#include "acpiview.h"
static void cb_toggle_tree (GtkAction *action, gpointer data);
@@ -612,9 +613,9 @@ create_main_window (ProcData *procdata)
GtkWidget *menubar;
GtkWidget *main_box;
GtkWidget *notebook;
- GtkWidget *tab_label1, *tab_label2, *tab_label3 , *tab_label4;
+ GtkWidget *tab_label1, *tab_label2, *tab_label3, *tab_label4, *tab_label5;
GtkWidget *vbox1;
- GtkWidget *sys_box, *devices_box, *hardware_box;
+ GtkWidget *sys_box, *devices_box, *hardware_box, *acpi_box;
GtkWidget *sysinfo_box, *sysinfo_label;
app = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@@ -708,6 +709,15 @@ create_main_window (ProcData *procdata)
tab_label4 = gtk_label_new (_("Hardware"));
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), hardware_box, tab_label4);
+ if (is_thinkpad ())
+ {
+ procdata->acpi = acpi_data_new ();
+ acpi_data_init (procdata->acpi);
+ acpi_box = create_acpi_view (procdata->acpi);
+ tab_label5 = gtk_label_new (_("ThinkPad"));
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), acpi_box, tab_label5);
+ }
+
g_signal_connect (G_OBJECT (notebook), "switch-page",
G_CALLBACK (cb_switch_page), procdata);
g_signal_connect (G_OBJECT (notebook), "change-current-page",
Index: gnome-system-monitor-2.26.0.1/src/procman.h
===================================================================
--- gnome-system-monitor-2.26.0.1.orig/src/procman.h
+++ gnome-system-monitor-2.26.0.1/src/procman.h
@@ -36,6 +36,7 @@
struct ProcInfo;
struct ProcData;
struct LoadGraph;
+struct AcpiData;
#include "smooth_refresh.h"
#include "prettytable.h"
@@ -216,6 +217,7 @@ struct ProcData
guint64 cpu_total_time;
guint64 cpu_total_time_last;
+ AcpiData* acpi;
private:
ProcData();
/* undefined */ ProcData(const ProcData &);

View File

@ -1,3 +1,24 @@
-------------------------------------------------------------------
Tue Sep 28 13:29:13 CEST 2010 - vuntz@opensuse.org
- Update to version 2.28.2:
+ Remove use of deprecated GTK+ API.
+ Fix build with -DGSEAL_ENABLE.
+ Updated translations.
-------------------------------------------------------------------
Fri May 28 00:45:03 CEST 2010 - vuntz@opensuse.org
- Drop gnome-system-monitor-fate302198.diff and
gnome-system-monitor-fate304741.diff: those patches were not
accepted upstream. One depends on HAL (which we don't want) and
provides an UI that is suboptimal to list the hardware; the other
one is specific to thinkpads and doesn't bring enough benefits to
be kept.
- Drop hal-devel and hwinfo-devel BuildRequires.
- Remove autoreconf call, and remove non-existing --enable-pcrecpp
configure option.
-------------------------------------------------------------------
Tue Mar 30 19:45:52 CEST 2010 - vuntz@opensuse.org

View File

@ -1,5 +1,5 @@
#
# spec file for package gnome-system-monitor (Version 2.28.1)
# spec file for package gnome-system-monitor (Version 2.28.2)
#
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
@ -33,17 +33,11 @@ BuildRequires: librsvg-devel
BuildRequires: libwnck-devel
BuildRequires: libxml2-devel
BuildRequires: update-desktop-files
BuildRequires: hal-devel
BuildRequires: hwinfo-devel
License: GPLv2+
Group: System/GUI/GNOME
Version: 2.28.1
Version: 2.28.2
Release: 1
Source0: ftp://ftp.gnome.org/pub/GNOME/sources/gnome-system-monitor/2.24/%{name}-%{version}.tar.bz2
# PATCH-FEATURE-OPENSUSE gnome-system-monitor-fate302198.diff FATE#302198 bgo582311 hfiguiere@novell.com -- Add a hardware tab
Patch1: gnome-system-monitor-fate302198.diff
# PATCH-FEATURE-OPENSUSE gnome-system-monitor-fate304741.diff FATE#304741 bgo582312 hfiguiere@novell.com -- Add a thinkpad tab
Patch2: gnome-system-monitor-fate304741.diff
Url: http://www.gnome.org
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Summary: A Simple Process Monitor
@ -66,14 +60,10 @@ Authors:
%lang_package
%prep
%setup -q
%patch1
%patch2 -p1
%build
autoreconf -si
%configure \
--disable-scrollkeeper \
--enable-pcrecpp
--disable-scrollkeeper
%__make %{?jobs:-j%jobs}
%install