This commit is contained in:
Matthias Clasen 2008-07-22 04:06:18 +00:00
parent 0c5a79267d
commit f743091d43
10 changed files with 7 additions and 4003 deletions

View File

@ -1 +1 @@
gnome-system-monitor-2.23.3.tar.bz2
gnome-system-monitor-2.23.5.tar.bz2

View File

@ -1,22 +0,0 @@
--- gnome-system-monitor-2.12.1/gnome-system-monitor.desktop.in.monitor 2005-11-22 00:58:38.000000000 -0500
+++ gnome-system-monitor-2.12.1/gnome-system-monitor.desktop.in 2005-11-22 00:58:56.000000000 -0500
@@ -8,7 +8,7 @@
Terminal=false
Type=Application
StartupNotify=true
-Categories=Application;System;
+Categories=Application;System;Monitor;X-Red-Hat-Base
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=system-monitor
X-GNOME-Bugzilla-Component=general
--- gnome-system-monitor-2.12.1/gnome-system-monitor.desktop.in.in.monitor 2005-11-22 00:57:34.000000000 -0500
+++ gnome-system-monitor-2.12.1/gnome-system-monitor.desktop.in.in 2005-11-22 00:58:25.000000000 -0500
@@ -8,7 +8,7 @@
Terminal=false
Type=Application
StartupNotify=true
-Categories=Application;System;
+Categories=Application;System;Monitor;X-Red-Hat-Base
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=system-monitor
X-GNOME-Bugzilla-Component=general

View File

@ -1,58 +0,0 @@
--- gnome-system-monitor-2.17.2.1/src/sysinfo.cpp.fedora 2006-11-02 13:45:35.000000000 -0500
+++ gnome-system-monitor-2.17.2.1/src/sysinfo.cpp 2006-11-18 01:09:14.000000000 -0500
@@ -141,10 +141,55 @@
};
+ class RedHatSysInfo
+ : public SysInfo
+ {
+ public:
+ RedHatSysInfo() : SysInfo(_("Unknown distro"))
+ {
+ this->load_redhat_info();
+ }
+
+ private:
+ void load_redhat_info()
+ {
+ gchar *text, *t, *s;
+
+ if (!g_file_get_contents ("/etc/redhat-release", &text, NULL, NULL))
+ return;
+
+ t = strstr (text, " release");
+
+ if (!t)
+ {
+ g_free (text);
+ return;
+ }
+
+ *t = '\0';
+
+ t += strlen (" release");
+
+ while (*t == ' ')
+ t++;
+
+ s = strchr (t, ' ');
+
+ if (s)
+ *s = '\0';
+
+ this->distro_name = text;
+ this->distro_version = t;
+ }
+ };
+
+
SysInfo* get_sysinfo()
{
if (g_file_test("/etc/debian_version", G_FILE_TEST_EXISTS))
return new DebianSysInfo;
+ else if (g_file_test("/etc/redhat-release", G_FILE_TEST_EXISTS))
+ return new RedHatSysInfo;
else
return new SysInfo(_("Unknown distro"));
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,87 +0,0 @@
diff -up gnome-system-monitor-2.22.0/src/procman.h.system-tab-arg gnome-system-monitor-2.22.0/src/procman.h
--- gnome-system-monitor-2.22.0/src/procman.h.system-tab-arg 2008-04-01 17:09:29.000000000 -0400
+++ gnome-system-monitor-2.22.0/src/procman.h 2008-04-01 17:09:29.000000000 -0400
@@ -58,6 +58,7 @@ enum
static const unsigned MIN_UPDATE_INTERVAL = 1 * 1000;
static const unsigned MAX_UPDATE_INTERVAL = 100 * 1000;
+#define SHOW_SYSTEM_TAB_CMD "SHOWSYSTAB" /* elegant, eh */
enum ProcmanTab
{
diff -up gnome-system-monitor-2.22.0/src/procman.cpp.system-tab-arg gnome-system-monitor-2.22.0/src/procman.cpp
--- gnome-system-monitor-2.22.0/src/procman.cpp.system-tab-arg 2008-04-01 17:09:29.000000000 -0400
+++ gnome-system-monitor-2.22.0/src/procman.cpp 2008-04-01 17:10:20.000000000 -0400
@@ -626,14 +626,19 @@ cb_server (const gchar *msg, gpointer us
{
GdkWindow *window;
ProcData *procdata;
- guint32 timestamp;
+ guint32 timestamp = 0;
window = gdk_get_default_root_window ();
procdata = *(ProcData**)user_data;
g_assert (procdata != NULL);
- timestamp = strtoul(msg, NULL, 0);
+ procman_debug("cb_server(%s)", msg);
+ if (msg != NULL && strcmp(SHOW_SYSTEM_TAB_CMD, msg) == 0) {
+ procman_debug("Changing to PROCMAN_TAB_SYSINFO via bacon message");
+ gtk_notebook_set_current_page(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_SYSINFO);
+ } else
+ timestamp = strtoul(msg, NULL, 0);
if (timestamp == 0)
{
@@ -669,12 +674,28 @@ main (int argc, char *argv[])
ProcData *procdata;
BaconMessageConnection *conn;
+ /* Parse commandline arguments */
+ GError *error = NULL;
+ GOptionContext *context;
+ static gboolean show_system_tab = FALSE;
+ static GOptionEntry entries[] =
+ {
+ { "show-system-tab", 's', 0, G_OPTION_ARG_NONE, &show_system_tab, "Show the System tab", NULL },
+ { NULL }
+ };
+
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
startup_timestamp = get_startup_timestamp();
+ context = g_option_context_new("- a simple process and system monitor.");
+ g_option_context_set_ignore_unknown_options(context, TRUE);
+ g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE);
+ g_option_context_parse(context, &argc, &argv, &error);
+ g_option_context_free(context);
+
Gtk::Main kit(&argc, &argv);
procman_debug("post gtk_init");
@@ -691,6 +712,9 @@ main (int argc, char *argv[])
timestamp = g_strdup_printf ("%" G_GUINT32_FORMAT, startup_timestamp);
+ if (show_system_tab)
+ bacon_message_connection_send(conn, SHOW_SYSTEM_TAB_CMD);
+
bacon_message_connection_send (conn, timestamp);
gdk_notify_startup_complete ();
@@ -727,6 +751,11 @@ main (int argc, char *argv[])
g_assert(procdata->app);
+ if (show_system_tab) {
+ procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request");
+ gtk_notebook_set_current_page(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_SYSINFO);
+ }
+
gtk_widget_show(procdata->app);
procman_debug("begin gtk_main");

View File

@ -1,435 +0,0 @@
--- gnome-system-monitor-2.9.90/configure.in.libgnomesu 2005-01-24 09:06:57.000000000 -0500
+++ gnome-system-monitor-2.9.90/configure.in 2005-02-02 15:03:45.000000000 -0500
@@ -19,9 +19,8 @@
LIBGTOP_REQUIRED=2.9.5
GTK_REQUIRED=2.5.0
GNOME_VFS_REQUIRED=2.6.0
-LIBGNOMESU_REQUIRED=0.9.3
-PKG_CHECK_MODULES(PROCMAN, libgnome-2.0 >= $LIBGNOME_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libgtop-2.0 >= $LIBGTOP_REQUIRED libwnck-1.0 >= $LIBWNCK_REQUIRED gtk+-2.0 >= $GTK_REQUIRED gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED libgnomesu-1.0 >= $LIBGNOMESU_REQUIRED)
+PKG_CHECK_MODULES(PROCMAN, libgnome-2.0 >= $LIBGNOME_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libgtop-2.0 >= $LIBGTOP_REQUIRED libwnck-1.0 >= $LIBWNCK_REQUIRED gtk+-2.0 >= $GTK_REQUIRED gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED)
AC_ARG_ENABLE(more-warnings,
--- gnome-system-monitor-2.9.90/src/procdialogs.c.libgnomesu 2005-01-13 19:05:00.000000000 -0500
+++ gnome-system-monitor-2.9.90/src/procdialogs.c 2005-02-02 15:03:45.000000000 -0500
@@ -23,7 +23,6 @@
#include <signal.h>
#include <string.h>
-#include <libgnomesu/libgnomesu.h>
#include "procdialogs.h"
#include "favorites.h"
#include "proctable.h"
@@ -815,13 +814,101 @@
void procdialog_create_root_password_dialog (gint type, ProcData *procdata, gint pid,
gint extra_value, gchar *text)
{
+ GtkWidget *dialog;
+ GtkWidget *error_dialog;
+ GtkWidget *main_vbox;
+ GtkWidget *hbox;
+ GtkWidget *entry;
+ GtkWidget *label;
+ gchar *title = NULL, *button_label;
gchar *command;
+ gchar *password, *blank;
+ gint retval;
+
+ if (type == 0) {
+ if (extra_value == SIGKILL) {
+ title = g_strdup (_("Kill Process"));
+ button_label = g_strdup (_("_Kill Process"));
+ }
+ else {
+ title = g_strdup (_("End Process"));
+ button_label = g_strdup (_("_End Process"));
+ }
+ }
+ else {
+ title = g_strdup (_("Change Priority"));
+ button_label = g_strdup (_("Change _Priority"));
+ }
+
+ dialog = gtk_dialog_new_with_buttons (title, NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ button_label, 100,
+ NULL);
+
+ main_vbox = GTK_DIALOG (dialog)->vbox;
+
+ label = gtk_label_new (_(text));
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_misc_set_padding (GTK_MISC (label), GNOME_PAD, 2 * GNOME_PAD);
+ gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL);
+ gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
+
+ label = gtk_label_new (_("Root Password :"));
+ gtk_misc_set_padding (GTK_MISC (label), GNOME_PAD_SMALL, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, FALSE, 0);
+
+ entry = gtk_entry_new ();
+ gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
+ gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, FALSE, 0);
+ g_signal_connect (G_OBJECT (entry), "activate",
+ G_CALLBACK (entry_activate_cb), dialog);
+
+ gtk_widget_show_all (main_vbox);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+ gtk_widget_grab_focus (entry);
+
+ g_free (title);
+ g_free (button_label);
+
+ retval = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_hide (dialog);
+
+ if (retval == 100) {
+ password = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
+
+ if (!password)
+ password = "";
+ blank = g_strdup (password);
+ if (strlen (blank))
+ memset (blank, ' ', strlen (blank));
+
+ gtk_entry_set_text (GTK_ENTRY (entry), blank);
+ gtk_entry_set_text (GTK_ENTRY (entry), "");
+ g_free (blank);
+
+ if (type == 0)
+ command = g_strdup_printf ("kill -s %d %d", extra_value, pid);
+ else
+ command = g_strdup_printf ("renice %d %d", extra_value, pid);
+
+ if (su_run_with_password (command, password) == -1) {
+ error_dialog = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ "%s",
+ _("Wrong Password."));
+ gtk_dialog_run (GTK_DIALOG (error_dialog));
+ gtk_widget_destroy (error_dialog);
+ }
+ g_free (command);
+
+ }
+ gtk_widget_destroy (dialog);
- if (type == 0)
- command = g_strdup_printf ("kill -s %d %d", extra_value, pid);
- else
- command = g_strdup_printf ("renice %d %d", extra_value, pid);
- gnomesu_exec (command);
- g_free (command);
}
--- gnome-system-monitor-2.9.90/src/util.c.libgnomesu 2005-01-08 17:43:35.000000000 -0500
+++ gnome-system-monitor-2.9.90/src/util.c 2005-02-02 15:08:57.000000000 -0500
@@ -1,10 +1,294 @@
-#include "util.h"
+#define _GNU_SOURCE
#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <pwd.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/wait.h>
+
+
+#ifdef __FreeBSD__
+# include <errno.h>
+# include <libutil.h>
+#endif
+
+#ifdef __sun
+# include <errno.h>
+# include <unistd.h>
+# include <stropts.h>
+# include <sys/stream.h>
+# include <sys/termios.h>
+# include <sys/ptem.h>
+#endif
+
+#include "util.h"
+
#include <gnome.h>
-#include <stddef.h>
+/* ABORT() kills GTK if we're not root, else it just exits.
+ */
+#define ABORT(root) \
+ if (root == 0) \
+ GTK_ABORT(); \
+ else \
+ _exit(-1)
+
+/* GTK_ABORT() is supposed to kill GTK and exit.
+ */
+#define GTK_ABORT() do { \
+ gtk_main_quit(); \
+ _exit(0); \
+ } while (0)
+
+/* OPEN_TTY() is supposed to return a file descriptor to a pseudo-terminal.
+ */
+#define OPEN_TTY() getpt()
+
+#ifdef __FreeBSD__
+/* FreeBSD doesn't have getpt(). This function emulates it's behaviour. */
+int getpt (void);
+
+int
+getpt ()
+{
+ int master, slave;
+
+ if (openpty (&master, &slave, NULL, NULL, NULL) < 0) {
+ /* Simulate getpt()'s only error condition. */
+ errno = ENOENT;
+ return -1;
+ }
+ return master;
+}
+#endif
+
+#ifdef __sun
+/* Sun doesn't have getpt(). This function emulates it's behavior. */
+int getpt (void);
+
+int
+getpt ()
+{
+ int fdm, fds;
+ extern int errno;
+ char *slavename;
+ /* extern char *ptsname(); */
+
+ /* open master */
+ fdm = open("/dev/ptmx", O_RDWR);
+ if ( fdm < 0 ) {
+ /* Simulate getpt()'s only error condition. */
+ errno = ENOENT;
+ return -1;
+ }
+ if ( grantpt(fdm) < 0 ) { /* change permission ofslave */
+ /* Simulate getpt()'s only error condition. */
+ errno = ENOENT;
+ return -1;
+ }
+ if ( unlockpt(fdm) < 0 ) { /* unlock slave */
+ /* Simulate getpt()'s only error condition. */
+ errno = ENOENT;
+ return -1;
+ }
+ slavename = ptsname(fdm); /* get name of slave */
+ if ( slavename == NULL ) {
+ /* Simulate getpt()'s only error condition. */
+ errno = ENOENT;
+ return -1;
+ }
+ fds = open(slavename, O_RDWR); /* open slave */
+ if ( fds < 0 ) {
+ /* Simulate getpt()'s only error condition. */
+ errno = ENOENT;
+ return -1;
+ }
+ ioctl(fds, I_PUSH, "ptem"); /* push ptem * /
+ ioctl(fds, I_PUSH, "ldterm"); /* push ldterm */
+
+ return fds;
+}
+
+/* Handle the fact that solaris doesn't have an asprintf */
+/* pinched from
+http://samba.anu.edu.au/rsync/doxygen/head/snprintf_8c-source.html */
+
+#ifndef HAVE_VASPRINTF
+int vasprintf(char **ptr, const char *format, va_list ap)
+{
+ int ret;
+
+ ret = vsnprintf(NULL, 0, format, ap);
+ if (ret <= 0) return ret;
+
+ (*ptr) = (char *)malloc(ret+1);
+ if (!*ptr) return -1;
+ ret = vsnprintf(*ptr, ret+1, format, ap);
+
+ return ret;
+}
+#endif
+
+
+#ifndef HAVE_ASPRINTF
+ int asprintf(char **ptr, const char *format, ...)
+{
+ va_list ap;
+ int ret;
+
+ va_start(ap, format);
+ ret = vasprintf(ptr, format, ap);
+ va_end(ap);
+
+ return ret;
+}
+#endif
+#endif
+
+static int root = 0; /* if we are root, no password is
+ required */
+
+static gint
+exec_su (gchar *exec_path, gchar *user, gchar *pwd)
+{
+ gchar *exec_p, *user_p; /* command to execute, user name */
+ pid_t pid;
+ int t_fd;
+
+ exec_p = g_strdup (exec_path);
+
+#if 0
+ if (asprintf (&exec_p, "%s&", exec_path) < 0) {
+ perror ("Unable to allocate memory chunk");
+ g_free (exec_p);
+ return 0;
+ }
+#endif
+
+ user_p = (user ? user : "root");
+
+ if ((pwd == NULL) || (*pwd == '\0')) {
+ g_free (exec_p);
+ return 0;
+ }
+
+ /*
+ * Make su think we're sending the password from a terminal:
+ */
+
+ if (((t_fd = OPEN_TTY()) < 0) || (grantpt(t_fd) < 0) || (unlockpt(t_fd) < 0)) {
+ fprintf (stderr, "Unable to open a terminal\n");
+ ABORT (root);
+ }
+
+ if ((pid = fork()) < 0) {
+ perror ("Unable to fork a new process");
+ ABORT (root);
+ }
+
+ if (pid > 0) { /* parent process */
+ int status;
+
+ sleep(1);
+
+ /* su(1) won't want a password if we're already root.
+ */
+ if (root == 0) {
+ write (t_fd, pwd, strlen(pwd));
+
+ /* Need the \n to flush the password */
+ write (t_fd, "\n", 1);
+ }
+
+ waitpid (pid, &status, 0);
+
+ if (WIFEXITED (status) && WEXITSTATUS (status) && (WEXITSTATUS(status) < 255)) {
+/* error_box (_("Incorrect password.")); */
+ g_free (exec_p);
+ return -1;
+ }
+ else {
+ memset (pwd, 0, strlen (pwd));
+ }
+ }
+ else { /* child process */
+ struct passwd *pw;
+ char *env, *home, *pts;
+
+ /* We have rights to run X (obviously). We need to ensure the
+ * destination user has the right stuff in the environment
+ * to be able to continue to run X.
+ * su will change $HOME to the new users home, so we will
+ * need an XAUTHORITY / ICEAUTHORITY pointing to the
+ * authorization files.
+ */
+
+ if ((home = getenv ("HOME")) == NULL) {
+ if ((env = getenv ("USER")) == NULL)
+ pw = getpwuid(getuid());
+ else
+ pw = getpwnam(env);
+ if (pw)
+ home = pw->pw_dir;
+ else {
+ perror ("Unable to find home directory");
+ _exit (-1);
+ }
+ }
+
+ if ((env = getenv ("XAUTHORITY")) == NULL) {
+ if (asprintf (&env, "XAUTHORITY=%s/.Xauthority", home) > 0)
+ putenv (env);
+ else {
+ perror ("Unable to allocate memory chunk");
+ _exit (-1);
+ }
+ }
+
+ if ((env = getenv ("ICEAUTHORITY")) == NULL) {
+ if (asprintf (&env, "ICEAUTHORITY=%s/.ICEauthority", home) > 0)
+ putenv (env);
+ else {
+ perror ("Unable to allocate memory chunk");
+ _exit (-1);
+ }
+ }
+
+ if(((pts = ptsname(t_fd)) == NULL) || ((t_fd = open(pts, O_RDWR | O_NOCTTY)) < 0)) {
+ perror ("Unable to open pseudo slave terminal");
+ _exit (-1);
+ }
+ dup2 (t_fd, 0);
+
+#if 0
+ freopen ("/dev/null", "w", stderr);
+ freopen ("/dev/null", "w", stdout);
+#endif
+
+ execlp ("su", "su", "-m", user_p, "-c", exec_p, NULL);
+ _exit (0);
+
+ }
+
+ g_free (exec_p);
+
+ return 0;
+}
+
+gint
+su_run_with_password (gchar *exec_path, gchar *password)
+{
+ return exec_su (exec_path, "root", password);
+}
+
+#if 1
void _procman_array_gettext_init(const char * strings[], size_t n)
{
size_t i;
@@ -15,3 +299,4 @@
strings[i] = _(strings[i]);
}
}
+#endif

View File

@ -1,446 +0,0 @@
diff -up gnome-system-monitor-2.22.1/src/load-graph.cpp.graph-cpu gnome-system-monitor-2.22.1/src/load-graph.cpp
--- gnome-system-monitor-2.22.1/src/load-graph.cpp.graph-cpu 2008-04-18 09:09:18.000000000 -0400
+++ gnome-system-monitor-2.22.1/src/load-graph.cpp 2008-04-18 09:09:49.000000000 -0400
@@ -63,87 +63,84 @@ unsigned LoadGraph::num_bars() const
void draw_background(LoadGraph *g) {
double dash[2] = { 1.0, 2.0 };
cairo_t *cr;
- cairo_t* tmp_cr;
guint i;
unsigned num_bars;
char *caption;
cairo_text_extents_t extents;
-
num_bars = g->num_bars();
g->graph_dely = (g->draw_height - 15) / num_bars; /* round to int to avoid AA blur */
g->real_draw_height = g->graph_dely * num_bars;
g->graph_delx = (g->draw_width - 2.0 - g->rmargin - g->indent) / (LoadGraph::NUM_POINTS - 3);
g->graph_buffer_offset = (int) (1.5 * g->graph_delx) + FRAME_WIDTH ;
- cr = cairo_create (g->buffer);
- g->background_buffer = cairo_surface_create_similar (cairo_get_target (cr),
- CAIRO_CONTENT_COLOR_ALPHA,
- g->draw_width + (2*FRAME_WIDTH),
- g->draw_height + (2*FRAME_WIDTH)); // ** We need the whole area as we are now setting the background colour here
+ g->background = gdk_pixmap_new (GDK_DRAWABLE (g->disp->window),
+ g->disp->allocation.width,
+ g->disp->allocation.height,
+ -1);
+ cr = gdk_cairo_create (g->background);
- tmp_cr = cairo_create (g->background_buffer);
-
// set the background colour
GtkStyle *style = gtk_widget_get_style (ProcData::get_instance()->notebook);
- gdk_cairo_set_source_color (tmp_cr, &style->bg[GTK_STATE_NORMAL]);
- cairo_paint (tmp_cr);
+ gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_NORMAL]);
+ cairo_paint (cr);
/* draw frame */
- cairo_translate (tmp_cr, FRAME_WIDTH, FRAME_WIDTH);
+ cairo_translate (cr, FRAME_WIDTH, FRAME_WIDTH);
/* Draw background rectangle */
- cairo_set_source_rgb (tmp_cr, 1.0, 1.0, 1.0);
- cairo_rectangle (tmp_cr, g->rmargin + g->indent, 0,
+ cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+ cairo_rectangle (cr, g->rmargin + g->indent, 0,
g->draw_width - g->rmargin - g->indent, g->real_draw_height);
- cairo_fill(tmp_cr);
+ cairo_fill(cr);
- cairo_set_line_width (tmp_cr, 1.0);
- cairo_set_dash (tmp_cr, dash, 2, 0);
- cairo_set_font_size (tmp_cr, g->fontsize);
+ cairo_set_line_width (cr, 1.0);
+ cairo_set_dash (cr, dash, 2, 0);
+ cairo_set_font_size (cr, g->fontsize);
for (i = 0; i <= num_bars; ++i) {
double y;
if (i == 0)
- y = 0.5 + g->fontsize / 2.0;
+ y = 0.5 + g->fontsize / 2.0;
else if (i == num_bars)
- y = i * g->graph_dely + 0.5;
+ y = i * g->graph_dely + 0.5;
else
- y = i * g->graph_dely + g->fontsize / 2.0;
- gdk_cairo_set_source_color (tmp_cr, &style->fg[GTK_STATE_NORMAL]);
+ y = i * g->graph_dely + g->fontsize / 2.0;
+
+ gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
if (g->type == LOAD_GRAPH_NET) {
// operation orders matters so it's 0 if i == num_bars
unsigned rate = g->net.max - (i * g->net.max / num_bars);
const std::string caption(procman::format_rate(rate, g->net.max));
- cairo_text_extents (tmp_cr, caption.c_str(), &extents);
- cairo_move_to (tmp_cr, g->indent - extents.width + 20, y);
- cairo_show_text (tmp_cr, caption.c_str());
+ cairo_text_extents (cr, caption.c_str(), &extents);
+ cairo_move_to (cr, g->indent - extents.width + 20, y);
+ cairo_show_text (cr, caption.c_str());
} else {
// operation orders matters so it's 0 if i == num_bars
caption = g_strdup_printf("%d %%", 100 - i * (100 / num_bars));
- cairo_text_extents (tmp_cr, caption, &extents);
- cairo_move_to (tmp_cr, g->indent - extents.width + 20, y);
- cairo_show_text (tmp_cr, caption);
+ cairo_text_extents (cr, caption, &extents);
+ cairo_move_to (cr, g->indent - extents.width + 20, y);
+ cairo_show_text (cr, caption);
g_free (caption);
}
- cairo_set_source_rgba (tmp_cr, 0, 0, 0, 0.75);
- cairo_move_to (tmp_cr, g->rmargin + g->indent - 3, i * g->graph_dely + 0.5);
- cairo_line_to (tmp_cr, g->draw_width - 0.5, i * g->graph_dely + 0.5);
+ cairo_set_source_rgba (cr, 0, 0, 0, 0.75);
+ cairo_move_to (cr, g->rmargin + g->indent - 3, i * g->graph_dely + 0.5);
+ cairo_line_to (cr, g->draw_width - 0.5, i * g->graph_dely + 0.5);
}
- cairo_stroke (tmp_cr);
+ cairo_stroke (cr);
- cairo_set_dash (tmp_cr, dash, 2, 1.5);
+ cairo_set_dash (cr, dash, 2, 1.5);
const unsigned total_seconds = g->speed * (LoadGraph::NUM_POINTS - 2) / 1000;
for (unsigned int i = 0; i < 7; i++) {
double x = (i) * (g->draw_width - g->rmargin - g->indent) / 6;
- cairo_set_source_rgba (tmp_cr, 0, 0, 0, 0.75);
- cairo_move_to (tmp_cr, (ceil(x) + 0.5) + g->rmargin + g->indent, 0.5);
- cairo_line_to (tmp_cr, (ceil(x) + 0.5) + g->rmargin + g->indent, g->real_draw_height + 4.5);
- cairo_stroke(tmp_cr);
+ cairo_set_source_rgba (cr, 0, 0, 0, 0.75);
+ cairo_move_to (cr, (ceil(x) + 0.5) + g->rmargin + g->indent, 0.5);
+ cairo_line_to (cr, (ceil(x) + 0.5) + g->rmargin + g->indent, g->real_draw_height + 4.5);
+ cairo_stroke(cr);
unsigned seconds = total_seconds - i * total_seconds / 6;
const char* format;
if (i == 0)
@@ -151,89 +148,26 @@ void draw_background(LoadGraph *g) {
else
format = "%u";
caption = g_strdup_printf(format, seconds);
- cairo_text_extents (tmp_cr, caption, &extents);
- cairo_move_to (tmp_cr, ((ceil(x) + 0.5) + g->rmargin + g->indent) - (extents.width/2), g->draw_height);
- gdk_cairo_set_source_color (tmp_cr, &style->fg[GTK_STATE_NORMAL]);
- cairo_show_text (tmp_cr, caption);
+ cairo_text_extents (cr, caption, &extents);
+ cairo_move_to (cr, ((ceil(x) + 0.5) + g->rmargin + g->indent) - (extents.width/2), g->draw_height);
+ gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
+ cairo_show_text (cr, caption);
g_free (caption);
}
- cairo_stroke (tmp_cr);
- cairo_destroy (tmp_cr);
- cairo_destroy (cr);
+ cairo_stroke (cr);
+ cairo_destroy (cr);
}
/* Redraws the backing buffer for the load graph and updates the window */
void
load_graph_draw (LoadGraph *g)
{
- cairo_t *cr;
- guint i, j;
- gdouble tmp;
-
- cr = cairo_create (g->buffer);
-
- /* draw the graph */
- if ((g->render_counter == 0)) {
- cairo_surface_destroy(g->graph_buffer);
- cairo_t* tmp_cr;
-
- g->graph_buffer = cairo_surface_create_similar (cairo_get_target (cr),
- CAIRO_CONTENT_COLOR_ALPHA,
- g->draw_width,
- g->draw_height);
- tmp_cr = cairo_create (g->graph_buffer);
-
- cairo_set_line_width (tmp_cr, 1.5);
- cairo_set_line_cap (tmp_cr, CAIRO_LINE_CAP_ROUND);
- cairo_set_line_join (tmp_cr, CAIRO_LINE_JOIN_ROUND);
-
- for (j = 0; j < g->n; ++j) {
- cairo_move_to (tmp_cr,
- g->draw_width - 2.0,
- (1.0f - g->data[0][j]) * g->real_draw_height);
- gdk_cairo_set_source_color (tmp_cr, &(g->colors [j]));
-
- for (i = 1; i < LoadGraph::NUM_POINTS; ++i) {
- if (g->data[i][j] == -1.0f)
- continue;
-
- cairo_curve_to (tmp_cr,
- (g->draw_width - (i-1) * g->graph_delx) - (g->graph_delx/2),
- (1.0f - g->data[i-1][j]) * g->real_draw_height,
- (g->draw_width - i * g->graph_delx) + (g->graph_delx/2),
- (1.0f - g->data[i][j]) * g->real_draw_height,
- g->draw_width - i * g->graph_delx,
- (1.0f - g->data[i][j]) * g->real_draw_height);
- }
-
- cairo_stroke (tmp_cr);
-
- }
- cairo_destroy (tmp_cr);
- }
-
- /* Composite and clip the surfaces together */
- if (g->background_buffer == NULL) {
- draw_background(g);
- }
- cairo_set_source_surface (cr, g->background_buffer, 0, 0);
- cairo_paint (cr);
-
- tmp = (float)(g->draw_width - g->rmargin - g->indent) / (float)LoadGraph::NUM_POINTS;
- tmp = tmp / g->frames_per_unit;
- tmp = tmp * g->render_counter;
- cairo_set_source_surface (cr, g->graph_buffer, g->graph_buffer_offset - tmp, FRAME_WIDTH);
- cairo_rectangle (cr, g->rmargin + g->indent + FRAME_WIDTH + 1, FRAME_WIDTH - 1,
- g->draw_width - g->rmargin - g->indent - 1 , g->real_draw_height + FRAME_WIDTH - 1);
- cairo_fill (cr);
- cairo_destroy (cr);
-
/* repaint */
gtk_widget_queue_draw (g->disp);
}
-static int load_graph_update (gpointer user_data); // predeclare load_graph_update so we can compile ;)
+static int load_graph_update (gpointer user_data); // predeclare load_graph_update so we can compile ;)
static gboolean
load_graph_configure (GtkWidget *widget,
@@ -241,37 +175,16 @@ load_graph_configure (GtkWidget *widget,
gpointer data_ptr)
{
LoadGraph * const g = static_cast<LoadGraph*>(data_ptr);
- cairo_t *cr;
-
g->draw_width = widget->allocation.width - 2 * FRAME_WIDTH;
g->draw_height = widget->allocation.height - 2 * FRAME_WIDTH;
- // FIXME:
- // g->frames_per_unit = g->draw_width/(LoadGraph::NUM_POINTS);
- // knock FRAMES down to 5 until cairo gets faster
-
- if(g->timer_index) {
- g_source_remove (g->timer_index);
- g->timer_index = g_timeout_add (g->speed / g->frames_per_unit,
- load_graph_update,
- g);
+ if (g->background) {
+ g_object_unref (g->background);
+ g->background = NULL;
}
- cr = gdk_cairo_create (widget->window);
-
- if (g->buffer)
- cairo_surface_destroy (g->buffer);
-
- g->buffer = cairo_surface_create_similar (cairo_get_target (cr),
- CAIRO_CONTENT_COLOR,
- widget->allocation.width,
- widget->allocation.height);
-
- cairo_destroy (cr);
-
- if (g->background_buffer != NULL) {
- cairo_surface_destroy(g->background_buffer);
- g->background_buffer = NULL;
+ if (g->gc == NULL) {
+ g->gc = gdk_gc_new (GDK_DRAWABLE (widget->window));
}
load_graph_draw (g);
@@ -285,13 +198,60 @@ load_graph_expose (GtkWidget *widget,
gpointer data_ptr)
{
LoadGraph * const g = static_cast<LoadGraph*>(data_ptr);
- cairo_t *cr;
- cr = gdk_cairo_create(widget->window);
+ guint i, j;
+ gdouble tmp, x_offset;
+
+ if (g->background == NULL) {
+ draw_background(g);
+ }
+ gdk_draw_drawable (g->disp->window,
+ g->gc,
+ g->background,
+ 0, 0, 0, 0,
+ g->disp->allocation.width,
+ g->disp->allocation.height);
+
+ tmp = (float)(g->draw_width - g->rmargin - g->indent) / (float)LoadGraph::NUM_POINTS;
+ tmp = tmp / g->frames_per_unit;
+ tmp = tmp * (g->render_counter + 1);
+
+ /* draw the graph */
+ cairo_t* cr;
+
+ cr = gdk_cairo_create (g->disp->window);
+
+ cairo_set_line_width (cr, 1);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
+ cairo_rectangle (cr, g->rmargin + g->indent + FRAME_WIDTH + 1, FRAME_WIDTH - 1,
+ g->draw_width - g->rmargin - g->indent - 1 , g->real_draw_height + FRAME_WIDTH - 1);
+ cairo_clip(cr);
+
+ x_offset = g->rmargin - tmp;
- cairo_set_source_surface(cr, g->buffer, 0, 0);
- cairo_paint(cr);
- cairo_destroy(cr);
+ for (j = 0; j < g->n; ++j) {
+ cairo_move_to (cr,
+ x_offset + g->draw_width - 2.0,
+ (1.0f - g->data[0][j]) * g->real_draw_height);
+ gdk_cairo_set_source_color (cr, &(g->colors [j]));
+
+ for (i = 1; i < LoadGraph::NUM_POINTS; ++i) {
+ if (g->data[i][j] == -1.0f)
+ continue;
+ cairo_curve_to (cr,
+ x_offset + (g->draw_width - (i-1) * g->graph_delx) - (g->graph_delx/2),
+ (1.0f - g->data[i-1][j]) * g->real_draw_height+3.5,
+ x_offset + (g->draw_width - i * g->graph_delx) + (g->graph_delx/2),
+ (1.0f - g->data[i][j]) * g->real_draw_height+3.5,
+ x_offset + g->draw_width - i * g->graph_delx,
+ (1.0f - g->data[i][j]) * g->real_draw_height+3.5);
+ }
+ cairo_stroke (cr);
+
+ }
+
+ cairo_destroy (cr);
return TRUE;
}
@@ -478,12 +438,6 @@ net_scale (LoadGraph *g, unsigned din, u
procman_debug("dmax = %u max = %u new_max = %u", dmax, g->net.max, new_max);
g->net.max = new_max;
-
- // force the graph background to be redrawn now that scale has changed
- if (g->background_buffer != NULL) {
- cairo_surface_destroy(g->background_buffer);
- g->background_buffer = NULL;
- }
}
static void
@@ -559,7 +513,7 @@ load_graph_update (gpointer user_data)
{
LoadGraph * const g = static_cast<LoadGraph*>(user_data);
- if (g->render_counter == 0) {
+ if (g->render_counter == 4) {
std::rotate(&g->data[0], &g->data[LoadGraph::NUM_POINTS - 1], &g->data[LoadGraph::NUM_POINTS]);
switch (g->type) {
@@ -597,10 +551,8 @@ LoadGraph::~LoadGraph()
if (this->timer_index)
g_source_remove(this->timer_index);
- if (this->buffer) {
- cairo_surface_destroy(this->buffer);
- this->buffer = NULL;
- }
+ if (this->background)
+ g_object_unref (this->background);
}
@@ -633,9 +585,8 @@ LoadGraph::LoadGraph(guint type)
graph_buffer_offset(0),
main_widget(NULL),
disp(NULL),
- buffer(NULL),
- graph_buffer(NULL),
- background_buffer(NULL),
+ gc(NULL),
+ background(NULL),
timer_index(0),
draw(FALSE),
mem_color_picker(NULL),
@@ -643,6 +594,9 @@ LoadGraph::LoadGraph(guint type)
{
LoadGraph * const g = this;
+ // FIXME:
+ // on configure, g->frames_per_unit = g->draw_width/(LoadGraph::NUM_POINTS);
+ // knock FRAMES down to 5 until cairo gets faster
g->frames_per_unit = 5; // this will be changed but needs initialising
g->fontsize = 8.0;
g->rmargin = 3.5 * g->fontsize;
@@ -700,9 +654,7 @@ LoadGraph::LoadGraph(guint type)
}
g->timer_index = 0;
- g->render_counter = g->frames_per_unit;
- g->background_buffer = NULL;
- g->graph_buffer = NULL;
+ g->render_counter = (g->frames_per_unit - 1);
g->draw = FALSE;
g->main_widget = gtk_vbox_new (FALSE, FALSE);
@@ -730,10 +682,6 @@ LoadGraph::LoadGraph(guint type)
g->data[i] = &g->data_block[0] + i * g->n;
gtk_widget_show_all (g->main_widget);
-
- load_graph_start(g);
- load_graph_stop(g);
-
}
void
@@ -767,17 +715,9 @@ load_graph_change_speed (LoadGraph *g,
g->speed = new_speed;
- g_assert(g->timer_index);
-
- if(g->timer_index) {
- g_source_remove (g->timer_index);
- g->timer_index = g_timeout_add (g->speed / g->frames_per_unit,
- load_graph_update,
- g);
- }
- if (g->background_buffer != NULL) {
- cairo_surface_destroy(g->background_buffer);
- g->background_buffer = NULL;
+ if (g->background != NULL) {
+ g_object_unref(g->background);
+ g->background = NULL;
}
}
diff -up gnome-system-monitor-2.22.1/src/load-graph.h.graph-cpu gnome-system-monitor-2.22.1/src/load-graph.h
--- gnome-system-monitor-2.22.1/src/load-graph.h.graph-cpu 2008-04-18 09:09:47.000000000 -0400
+++ gnome-system-monitor-2.22.1/src/load-graph.h 2008-04-18 09:09:49.000000000 -0400
@@ -65,9 +65,8 @@ struct LoadGraph {
GtkWidget *main_widget;
GtkWidget *disp;
- cairo_surface_t *buffer;
- cairo_surface_t *graph_buffer;
- cairo_surface_t *background_buffer;
+ GdkGC *gc;
+ GdkDrawable *background;
guint timer_index;

View File

@ -12,8 +12,8 @@
Summary: Simple process monitor
Name: gnome-system-monitor
Version: 2.23.3
Release: 2%{?dist}
Version: 2.23.5
Release: 1%{?dist}
License: GPLv2+
Group: Applications/System
URL: http://www.gnome.org/
@ -122,6 +122,9 @@ scrollkeeper-update -q
%changelog
* Tue Jul 22 2008 Matthias Clasen <mclasen@redhat.com> - 2.23.5-1
- Update to 2.23.5
* Thu Jun 05 2008 Than Ngo <than@redhat.com> 2.23.3-2
- don't show it in KDE menu

View File

@ -1 +1 @@
dc800bbb06c24f70614f31173f3b79bc gnome-system-monitor-2.23.3.tar.bz2
77bcef6336fa72e1f96a920d3070ad17 gnome-system-monitor-2.23.5.tar.bz2