[gnome-system-monitor] Implement timeout API for proctable
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-monitor] Implement timeout API for proctable
- Date: Wed, 24 Jul 2013 19:53:38 +0000 (UTC)
commit 9256c45e004fe3e0d6158211ab920ccd5bfedfe5
Author: Stefano Facchini <stefano facchini gmail com>
Date: Wed Jul 24 18:12:47 2013 +0200
Implement timeout API for proctable
Since this was the last remaining step, this commit also removes
callbacks.{cpp,h} for good
https://bugzilla.gnome.org/show_bug.cgi?id=704800
src/Makefile.am | 1 -
src/callbacks.cpp | 57 ---------------------------------------------------
src/callbacks.h | 29 --------------------------
src/disks.cpp | 1 -
src/interface.cpp | 13 +---------
src/procactions.cpp | 14 ++++--------
src/procdialogs.cpp | 1 -
src/procman-app.cpp | 9 +------
src/proctable.cpp | 43 +++++++++++++++++++++++++++++++++++++-
src/proctable.h | 3 ++
10 files changed, 54 insertions(+), 117 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 8d4a2e6..7969980 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,7 +14,6 @@ BUILT_SOURCES = gsm-resources.c
gnome_system_monitor_cpp_files = \
argv.cpp \
interface.cpp \
- callbacks.cpp \
load-graph.cpp \
proctable.cpp \
prettytable.cpp \
diff --git a/src/disks.cpp b/src/disks.cpp
index 9a42a37..c528540 100644
--- a/src/disks.cpp
+++ b/src/disks.cpp
@@ -8,7 +8,6 @@
#include <glib/gi18n.h>
#include "procman-app.h"
-#include "callbacks.h"
#include "disks.h"
#include "util.h"
#include "interface.h"
diff --git a/src/interface.cpp b/src/interface.cpp
index 870a58e..363cea0 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -30,7 +30,6 @@
#include <gdk/gdkkeysyms.h>
#include <math.h>
-#include "callbacks.h"
#include "interface.h"
#include "proctable.h"
#include "procactions.h"
@@ -507,21 +506,13 @@ update_page_activities (ProcmanApp *app)
int current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (app->notebook));
if (current_page == PROCMAN_TAB_PROCESSES) {
- cb_timeout (app);
-
- if (!app->timeout) {
- app->timeout = g_timeout_add (app->config.update_interval,
- cb_timeout, app);
- }
+ proctable_thaw (app);
update_sensitivity (app);
gtk_widget_grab_focus (app->tree);
} else {
- if (app->timeout) {
- g_source_remove (app->timeout);
- app->timeout = 0;
- }
+ proctable_freeze (app);
update_sensitivity (app);
}
diff --git a/src/procactions.cpp b/src/procactions.cpp
index db91b2f..969b5ed 100644
--- a/src/procactions.cpp
+++ b/src/procactions.cpp
@@ -29,7 +29,6 @@
#include "procman-app.h"
#include "proctable.h"
#include "procdialogs.h"
-#include "callbacks.h"
static void
@@ -99,14 +98,12 @@ renice (ProcmanApp *app, int nice)
** occurs if you first kill a process and the tree node is removed while
** still in the foreach function
*/
- g_source_remove(app->timeout);
+ proctable_freeze (app);
gtk_tree_selection_selected_foreach(app->selection, renice_single_process,
&args);
- app->timeout = g_timeout_add(app->config.update_interval,
- cb_timeout,
- app);
+ proctable_thaw (app);
proctable_update_all (app);
}
@@ -179,13 +176,12 @@ kill_process (ProcmanApp *app, int sig)
** occurs if you first kill a process and the tree node is removed while
** still in the foreach function
*/
- g_source_remove (app->timeout);
+ proctable_freeze (app);
gtk_tree_selection_selected_foreach (app->selection, kill_single_process,
&args);
- app->timeout = g_timeout_add (app->config.update_interval,
- cb_timeout,
- app);
+ proctable_thaw (app);
+
proctable_update_all (app);
}
diff --git a/src/procdialogs.cpp b/src/procdialogs.cpp
index b5548eb..146981b 100644
--- a/src/procdialogs.cpp
+++ b/src/procdialogs.cpp
@@ -28,7 +28,6 @@
#include "procdialogs.h"
#include "proctable.h"
-#include "callbacks.h"
#include "prettytable.h"
#include "procactions.h"
#include "util.h"
diff --git a/src/procman-app.cpp b/src/procman-app.cpp
index b2e0354..1846569 100644
--- a/src/procman-app.cpp
+++ b/src/procman-app.cpp
@@ -8,13 +8,13 @@
#include "procdialogs.h"
#include "interface.h"
#include "proctable.h"
-#include "callbacks.h"
#include "load-graph.h"
#include "settings-keys.h"
#include "argv.h"
#include "util.h"
#include "cgroups.h"
#include "lsof.h"
+#include "disks.h"
static void
mount_changed(const Glib::RefPtr<Gio::Mount>&, ProcmanApp *app)
@@ -100,12 +100,7 @@ timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
app->smooth_refresh->reset();
- if(app->timeout) {
- g_source_remove (app->timeout);
- app->timeout = g_timeout_add (app->config.update_interval,
- cb_timeout,
- app);
- }
+ proctable_reset_timeout (app);
}
else if (g_str_equal (key, "graph-update-interval")){
app->config.graph_update_interval = g_settings_get_int (settings, key);
diff --git a/src/proctable.cpp b/src/proctable.cpp
index 50f423a..38a2a64 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -55,7 +55,6 @@
#include "procman-app.h"
#include "proctable.h"
-#include "callbacks.h"
#include "prettytable.h"
#include "util.h"
#include "interface.h"
@@ -257,6 +256,24 @@ cb_row_selected (GtkTreeSelection *selection, gpointer data)
update_sensitivity(app);
}
+static gint
+cb_timeout (gpointer data)
+{
+ ProcmanApp *app = (ProcmanApp *) data;
+ guint new_interval;
+
+ proctable_update_all (app);
+
+ if (app->smooth_refresh->get(new_interval)) {
+ app->timeout = g_timeout_add(new_interval,
+ cb_timeout,
+ app);
+ return G_SOURCE_REMOVE;
+ }
+
+ return G_SOURCE_CONTINUE;
+}
+
static void
cb_refresh_icons (GtkIconTheme *theme, gpointer data)
{
@@ -1191,3 +1208,27 @@ ProcInfo::set_icon(Glib::RefPtr<Gdk::Pixbuf> icon)
COL_PIXBUF, (this->pixbuf ? this->pixbuf->gobj() : NULL),
-1);
}
+
+void
+proctable_freeze (ProcmanApp *app)
+{
+ if (app->timeout) {
+ g_source_remove (app->timeout);
+ app->timeout = 0;
+ }
+}
+
+void
+proctable_thaw (ProcmanApp *app)
+{
+ app->timeout = g_timeout_add (app->config.update_interval,
+ cb_timeout,
+ app);
+}
+
+void
+proctable_reset_timeout (ProcmanApp *app)
+{
+ proctable_freeze (app);
+ proctable_thaw (app);
+}
diff --git a/src/proctable.h b/src/proctable.h
index e6b01ab..c32aa3b 100644
--- a/src/proctable.h
+++ b/src/proctable.h
@@ -62,6 +62,9 @@ void proctable_update_list (ProcmanApp *app);
void proctable_update_all (ProcmanApp *app);
void proctable_clear_tree (ProcmanApp *app);
void proctable_free_table (ProcmanApp *app);
+void proctable_freeze (ProcmanApp *app);
+void proctable_thaw (ProcmanApp *app);
+void proctable_reset_timeout (ProcmanApp *app);
GSList* proctable_get_columns_order(GtkTreeView *treeview);
void proctable_set_columns_order(GtkTreeView *treeview, GSList *order);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]