[gnome-system-monitor] Use real widget types, eliminate downcasting
- From: Benoît Dejean <bdejean src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-monitor] Use real widget types, eliminate downcasting
- Date: Thu, 22 Sep 2016 08:14:37 +0000 (UTC)
commit 5bc512120f3363f76f4bc09101926725f7899ae8
Author: Artem Vorotnikov <artem vorotnikov me>
Date: Sun Sep 4 10:46:05 2016 +0300
Use real widget types, eliminate downcasting
Right now for some mysterious reason GSM's GtkBuilder code
dumbs down all widgets to GtkWidget*.
This leads to extensive downcasting and code that is
heavy-on-paper - it is not possible to determine widget type
by just looking at the GsmApplication class definition.
With this patch widgets reclaim their real types.
Upcasting is provided for where it is necessary to use widgets
as GtkWidget*.
src/application.cpp | 4 +-
src/application.h | 25 +++---
src/disks.cpp | 10 +-
src/gsm_color_button.c | 14 ++--
src/gsm_color_button.h | 2 +-
src/interface.cpp | 192 ++++++++++++++++++++++++------------------------
src/load-graph.cpp | 94 ++++++++++++------------
src/load-graph.h | 29 ++++----
src/lsof.cpp | 24 +++---
src/memmaps.cpp | 36 +++++-----
src/openfiles.cpp | 34 ++++----
src/prefsdialog.cpp | 44 ++++++------
src/procactions.cpp | 16 ++--
src/procdialogs.cpp | 34 ++++----
src/procproperties.cpp | 60 ++++++++--------
src/proctable.cpp | 26 +++---
src/proctable.h | 3 +-
src/treeview.c | 18 ++--
src/treeview.h | 2 +-
src/util.cpp | 10 +-
src/util.h | 2 +-
21 files changed, 341 insertions(+), 338 deletions(-)
---
diff --git a/src/application.cpp b/src/application.cpp
index 3f8fb94..b650cc7 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -286,7 +286,7 @@ GsmApplication::save_config ()
gtk_window_get_size (GTK_WINDOW (main_window), &width, &height);
gtk_window_get_position (GTK_WINDOW (main_window), &xpos, &ypos);
- maximized = gdk_window_get_state (gtk_widget_get_window (main_window)) & GDK_WINDOW_STATE_MAXIMIZED;
+ maximized = gdk_window_get_state (gtk_widget_get_window (GTK_WIDGET (main_window))) &
GDK_WINDOW_STATE_MAXIMIZED;
g_settings_set (settings, GSM_SETTING_WINDOW_STATE, "(iiii)",
width, height, xpos, ypos);
@@ -431,6 +431,6 @@ void GsmApplication::on_startup()
add_accelerator ("<Alt>3", "win.show-page", g_variant_new_string ("disks"));
add_accelerator ("<Primary>r", "win.refresh", NULL);
- gtk_widget_show (main_window);
+ gtk_widget_show (GTK_WIDGET (main_window));
}
diff --git a/src/application.h b/src/application.h
index 247ba02..895321e 100644
--- a/src/application.h
+++ b/src/application.h
@@ -12,6 +12,7 @@ struct LoadGraph;
#include "smooth_refresh.h"
#include "prettytable.h"
+#include "treeview.h"
#include "util.h"
static const unsigned MIN_UPDATE_INTERVAL = 1 * 1000;
@@ -201,17 +202,17 @@ public:
void save_config();
void shutdown();
- GtkWidget *tree;
- GtkWidget *proc_actionbar_revealer;
- GtkWidget *popup_menu;
- GtkWidget *disk_list;
- GtkWidget *stack;
- GtkWidget *refresh_button;
- GtkWidget *process_menu_button;
- GtkWidget *end_process_button;
- GtkWidget *search_button;
- GtkWidget *search_entry;
- GtkWidget *search_bar;
+ GsmTreeView *tree;
+ GtkRevealer *proc_actionbar_revealer;
+ GtkMenu *popup_menu;
+ GsmTreeView *disk_list;
+ GtkStack *stack;
+ GtkButton *refresh_button;
+ GtkMenuButton *process_menu_button;
+ GtkButton *end_process_button;
+ GtkButton *search_button;
+ GtkSearchEntry *search_entry;
+ GtkSearchBar *search_bar;
ProcConfig config;
LoadGraph *cpu_graph;
LoadGraph *mem_graph;
@@ -229,7 +230,7 @@ public:
PrettyTable *pretty_table;
GSettings *settings;
- GtkWidget *main_window;
+ GtkApplicationWindow *main_window;
unsigned frequency;
diff --git a/src/disks.cpp b/src/disks.cpp
index d6a8c25..4d4803b 100644
--- a/src/disks.cpp
+++ b/src/disks.cpp
@@ -349,8 +349,8 @@ cb_show_all_fs_changed (GSettings *settings, const gchar *key, gpointer data)
void
create_disk_view(GsmApplication *app, GtkBuilder *builder)
{
- GtkWidget *scrolled;
- GtkWidget *disk_tree;
+ GtkScrolledWindow *scrolled;
+ GsmTreeView *disk_tree;
GtkListStore *model;
GtkTreeViewColumn *col;
GtkCellRenderer *cell;
@@ -369,7 +369,7 @@ create_disk_view(GsmApplication *app, GtkBuilder *builder)
GSettings * settings = g_settings_get_child (app->settings, GSM_SETTINGS_CHILD_DISKS);
- scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"));
+ scrolled = GTK_SCROLLED_WINDOW (gtk_builder_get_object (builder, "disks_scrolled"));
model = gtk_list_store_new(DISK_N_COLUMNS, /* n columns */
G_TYPE_STRING, /* DISK_DEVICE */
@@ -387,7 +387,7 @@ create_disk_view(GsmApplication *app, GtkBuilder *builder)
g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL);
app->disk_list = disk_tree;
- gtk_container_add(GTK_CONTAINER(scrolled), disk_tree);
+ gtk_container_add(GTK_CONTAINER(scrolled), GTK_WIDGET (disk_tree));
g_object_unref(G_OBJECT(model));
/* icon + device */
@@ -481,5 +481,5 @@ create_disk_view(GsmApplication *app, GtkBuilder *builder)
g_signal_connect (app->settings, "changed::" GSM_SETTING_SHOW_ALL_FS,
G_CALLBACK (cb_show_all_fs_changed), app);
- gtk_widget_show (disk_tree);
+ gtk_widget_show (GTK_WIDGET (disk_tree));
}
diff --git a/src/gsm_color_button.c b/src/gsm_color_button.c
index cf0299d..e23e9b6 100644
--- a/src/gsm_color_button.c
+++ b/src/gsm_color_button.c
@@ -29,7 +29,7 @@
typedef struct
{
- GtkWidget *cc_dialog; /* Color chooser dialog */
+ GtkColorChooserDialog *cc_dialog; /* Color chooser dialog */
gchar *title; /* Title for the color selection window */
@@ -545,7 +545,7 @@ gsm_color_button_finalize (GObject * object)
GsmColorButtonPrivate *priv = gsm_color_button_get_instance_private (color_button);
if (priv->cc_dialog != NULL)
- gtk_widget_destroy (priv->cc_dialog);
+ gtk_widget_destroy (GTK_WIDGET (priv->cc_dialog));
priv->cc_dialog = NULL;
g_free (priv->title);
@@ -557,7 +557,7 @@ gsm_color_button_finalize (GObject * object)
G_OBJECT_CLASS (gsm_color_button_parent_class)->finalize (object);
}
-GtkWidget *
+GsmColorButton *
gsm_color_button_new (const GdkRGBA * color, guint type)
{
return g_object_new (GSM_TYPE_COLOR_BUTTON, "color", color, "type", type,
@@ -576,7 +576,7 @@ dialog_response (GtkWidget * widget, GtkResponseType response, gpointer data)
gtk_color_chooser_get_rgba (color_chooser, &priv->color);
- gtk_widget_hide (priv->cc_dialog);
+ gtk_widget_hide (GTK_WIDGET (priv->cc_dialog));
gtk_widget_queue_draw (GTK_WIDGET (color_button));
@@ -587,7 +587,7 @@ dialog_response (GtkWidget * widget, GtkResponseType response, gpointer data)
g_object_thaw_notify (G_OBJECT (color_button));
}
else /* (response == GTK_RESPONSE_CANCEL) */
- gtk_widget_hide (priv->cc_dialog);
+ gtk_widget_hide (GTK_WIDGET (priv->cc_dialog));
}
static gboolean
@@ -610,14 +610,14 @@ gsm_color_button_clicked (GtkWidget * widget, GdkEventButton * event)
if (!priv->cc_dialog)
{
/* Create the dialog and connects its buttons */
- GtkWidget *cc_dialog;
+ GtkColorChooserDialog *cc_dialog;
GtkWidget *parent;
parent = gtk_widget_get_toplevel (GTK_WIDGET (color_button));
if (!gtk_widget_is_toplevel (parent))
parent = NULL;
- cc_dialog = gtk_color_chooser_dialog_new (priv->title, GTK_WINDOW (parent));
+ cc_dialog = GTK_COLOR_CHOOSER_DIALOG (gtk_color_chooser_dialog_new (priv->title, GTK_WINDOW (parent)));
gtk_window_set_modal (GTK_WINDOW (cc_dialog), TRUE);
diff --git a/src/gsm_color_button.h b/src/gsm_color_button.h
index 5a2b999..385dd14 100644
--- a/src/gsm_color_button.h
+++ b/src/gsm_color_button.h
@@ -62,7 +62,7 @@ struct _GsmColorButtonClass
};
GType gsm_color_button_get_type (void);
-GtkWidget * gsm_color_button_new (const GdkRGBA * color, guint type);
+GsmColorButton * gsm_color_button_new (const GdkRGBA * color, guint type);
void gsm_color_button_set_color (GsmColorButton * color_button, const GdkRGBA * color);
void gsm_color_button_set_fraction (GsmColorButton * color_button, const gdouble fraction);
void gsm_color_button_set_cbtype (GsmColorButton * color_button, guint type);
diff --git a/src/interface.cpp b/src/interface.cpp
index 809de89..57ba4b1 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -67,25 +67,25 @@ search_text_changed (GtkEditable *entry, gpointer data)
static void
create_proc_view(GsmApplication *app, GtkBuilder * builder)
{
- GtkWidget *proctree;
- GtkWidget *scrolled;
+ GsmTreeView *proctree;
+ GtkScrolledWindow *scrolled;
proctree = proctable_new (app);
- scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "processes_scrolled"));
+ scrolled = GTK_SCROLLED_WINDOW (gtk_builder_get_object (builder, "processes_scrolled"));
- gtk_container_add (GTK_CONTAINER (scrolled), proctree);
+ gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (proctree));
- app->proc_actionbar_revealer = GTK_WIDGET (gtk_builder_get_object (builder, "proc_actionbar_revealer"));
+ app->proc_actionbar_revealer = GTK_REVEALER (gtk_builder_get_object (builder,
"proc_actionbar_revealer"));
/* create popup_menu for the processes tab */
GMenuModel *menu_model = G_MENU_MODEL (gtk_builder_get_object (builder, "process-popup-menu"));
- app->popup_menu = gtk_menu_new_from_model (menu_model);
- gtk_menu_attach_to_widget (GTK_MENU (app->popup_menu), app->main_window, NULL);
+ app->popup_menu = GTK_MENU (gtk_menu_new_from_model (menu_model));
+ gtk_menu_attach_to_widget (app->popup_menu, GTK_WIDGET (app->main_window), NULL);
- app->search_bar = GTK_WIDGET (gtk_builder_get_object (builder, "proc_searchbar"));
- app->search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "proc_searchentry"));
+ app->search_bar = GTK_SEARCH_BAR (gtk_builder_get_object (builder, "proc_searchbar"));
+ app->search_entry = GTK_SEARCH_ENTRY (gtk_builder_get_object (builder, "proc_searchentry"));
- gtk_search_bar_connect_entry (GTK_SEARCH_BAR(app->search_bar), GTK_ENTRY (app->search_entry));
+ gtk_search_bar_connect_entry (app->search_bar, GTK_ENTRY (app->search_entry));
g_signal_connect (app->main_window, "key-press-event",
G_CALLBACK (cb_window_key_press_event), app->search_bar);
@@ -171,11 +171,11 @@ cb_net_out_color_changed (GsmColorButton *cp, gpointer data)
static void
create_sys_view (GsmApplication *app, GtkBuilder * builder)
{
- GtkWidget *cpu_graph_box, *mem_graph_box, *net_graph_box;
- GtkWidget *label,*cpu_label;
- GtkWidget *table;
- GtkWidget *color_picker;
- GtkWidget *picker_alignment;
+ GtkBox *cpu_graph_box, *mem_graph_box, *net_graph_box;
+ GtkLabel *label,*cpu_label;
+ GtkGrid *table;
+ GsmColorButton *color_picker;
+ GtkAlignment *picker_alignment;
LoadGraph *cpu_graph, *mem_graph, *net_graph;
gint i;
@@ -188,33 +188,33 @@ create_sys_view (GsmApplication *app, GtkBuilder * builder)
/* The CPU BOX */
- cpu_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_graph_box"));
+ cpu_graph_box = GTK_BOX (gtk_builder_get_object (builder, "cpu_graph_box"));
cpu_graph = new LoadGraph(LOAD_GRAPH_CPU);
- gtk_box_pack_start (GTK_BOX (cpu_graph_box),
- load_graph_get_widget(cpu_graph),
+ gtk_box_pack_start (cpu_graph_box,
+ GTK_WIDGET (load_graph_get_widget(cpu_graph)),
TRUE,
TRUE,
0);
- GtkWidget* cpu_table = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_table"));
+ GtkGrid* cpu_table = GTK_GRID (gtk_builder_get_object (builder, "cpu_table"));
gint cols = 4;
for (i=0;i<app->config.num_cpus; i++) {
- GtkWidget *temp_hbox;
+ GtkBox *temp_hbox;
- temp_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_widget_show (temp_hbox);
+ temp_hbox = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0));
+ gtk_widget_show (GTK_WIDGET (temp_hbox));
if (i < cols) {
- gtk_grid_insert_column(GTK_GRID(cpu_table), i%cols);
+ gtk_grid_insert_column(cpu_table, i%cols);
}
if ((i+1)%cols ==cols) {
- gtk_grid_insert_row(GTK_GRID(cpu_table), (i+1)/cols);
+ gtk_grid_insert_row(cpu_table, (i+1)/cols);
}
- gtk_grid_attach(GTK_GRID (cpu_table), temp_hbox, i%cols, i/cols, 1, 1);
+ gtk_grid_attach(cpu_table, GTK_WIDGET (temp_hbox), i%cols, i/cols, 1, 1);
color_picker = gsm_color_button_new (&cpu_graph->colors.at(i), GSMCP_TYPE_CPU);
g_signal_connect (G_OBJECT (color_picker), "color-set",
G_CALLBACK (cb_cpu_color_changed), GINT_TO_POINTER (i));
- gtk_box_pack_start (GTK_BOX (temp_hbox), color_picker, FALSE, TRUE, 0);
+ gtk_box_pack_start (temp_hbox, GTK_WIDGET (color_picker), FALSE, TRUE, 0);
gtk_widget_set_size_request(GTK_WIDGET(color_picker), 32, -1);
if(app->config.num_cpus == 1) {
label_text = g_strdup (_("CPU"));
@@ -222,19 +222,19 @@ create_sys_view (GsmApplication *app, GtkBuilder * builder)
label_text = g_strdup_printf (_("CPU%d"), i+1);
}
title_text = g_strdup_printf(title_template, label_text);
- label = gtk_label_new (label_text);
- gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+ label = GTK_LABEL (gtk_label_new (label_text));
+ gsm_color_button_set_title(color_picker, title_text);
g_free(title_text);
- gtk_box_pack_start (GTK_BOX (temp_hbox), label, FALSE, FALSE, 6);
- gtk_widget_show (label);
+ gtk_box_pack_start (temp_hbox, GTK_WIDGET (label), FALSE, FALSE, 6);
+ gtk_widget_show (GTK_WIDGET (label));
g_free (label_text);
- cpu_label = gtk_label_new (NULL);
+ cpu_label = GTK_LABEL (gtk_label_new (NULL));
- gtk_widget_set_valign (cpu_label, GTK_ALIGN_CENTER);
- gtk_widget_set_halign (cpu_label, GTK_ALIGN_START);
- gtk_box_pack_start (GTK_BOX (temp_hbox), cpu_label, FALSE, FALSE, 0);
- gtk_widget_show (cpu_label);
+ gtk_widget_set_valign (GTK_WIDGET (cpu_label), GTK_ALIGN_CENTER);
+ gtk_widget_set_halign (GTK_WIDGET (cpu_label), GTK_ALIGN_START);
+ gtk_box_pack_start (temp_hbox, GTK_WIDGET (cpu_label), FALSE, FALSE, 0);
+ gtk_widget_show (GTK_WIDGET (cpu_label));
load_graph_get_labels(cpu_graph)->cpu[i] = cpu_label;
}
@@ -243,28 +243,28 @@ create_sys_view (GsmApplication *app, GtkBuilder * builder)
/** The memory box */
- mem_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "mem_graph_box"));
+ mem_graph_box = GTK_BOX (gtk_builder_get_object (builder, "mem_graph_box"));
mem_graph = new LoadGraph(LOAD_GRAPH_MEM);
- gtk_box_pack_start (GTK_BOX (mem_graph_box),
- load_graph_get_widget(mem_graph),
+ gtk_box_pack_start (mem_graph_box,
+ GTK_WIDGET (load_graph_get_widget(mem_graph)),
TRUE,
TRUE,
0);
- table = GTK_WIDGET (gtk_builder_get_object (builder, "mem_table"));
+ table = GTK_GRID (gtk_builder_get_object (builder, "mem_table"));
color_picker = load_graph_get_mem_color_picker(mem_graph);
g_signal_connect (G_OBJECT (color_picker), "color-set",
G_CALLBACK (cb_mem_color_changed), app);
title_text = g_strdup_printf(title_template, _("Memory"));
- gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+ gsm_color_button_set_title(color_picker, title_text);
g_free(title_text);
- label = GTK_WIDGET(gtk_builder_get_object(builder, "memory_label"));
+ label = GTK_LABEL (gtk_builder_get_object(builder, "memory_label"));
- gtk_grid_attach_next_to (GTK_GRID (table), color_picker, label, GTK_POS_LEFT, 1, 2);
- gtk_grid_attach_next_to (GTK_GRID (table), load_graph_get_labels(mem_graph)->memory, label,
GTK_POS_BOTTOM, 1, 1);
+ gtk_grid_attach_next_to (table, GTK_WIDGET (color_picker), GTK_WIDGET (label), GTK_POS_LEFT, 1, 2);
+ gtk_grid_attach_next_to (table, GTK_WIDGET (load_graph_get_labels(mem_graph)->memory), GTK_WIDGET
(label), GTK_POS_BOTTOM, 1, 1);
color_picker = load_graph_get_swap_color_picker(mem_graph);
g_signal_connect (G_OBJECT (color_picker), "color-set",
@@ -273,56 +273,56 @@ create_sys_view (GsmApplication *app, GtkBuilder * builder)
gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
g_free(title_text);
- label = GTK_WIDGET(gtk_builder_get_object(builder, "swap_label"));
+ label = GTK_LABEL (gtk_builder_get_object(builder, "swap_label"));
- gtk_grid_attach_next_to (GTK_GRID (table), color_picker, label, GTK_POS_LEFT, 1, 2);
- gtk_grid_attach_next_to (GTK_GRID (table), load_graph_get_labels(mem_graph)->swap, label,
GTK_POS_BOTTOM, 1, 1);
+ gtk_grid_attach_next_to (table, GTK_WIDGET (color_picker), GTK_WIDGET (label), GTK_POS_LEFT, 1, 2);
+ gtk_grid_attach_next_to (table, GTK_WIDGET (load_graph_get_labels(mem_graph)->swap), GTK_WIDGET (label),
GTK_POS_BOTTOM, 1, 1);
app->mem_graph = mem_graph;
/* The net box */
- net_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "net_graph_box"));
+ net_graph_box = GTK_BOX (gtk_builder_get_object (builder, "net_graph_box"));
net_graph = new LoadGraph(LOAD_GRAPH_NET);
- gtk_box_pack_start (GTK_BOX (net_graph_box),
- load_graph_get_widget(net_graph),
+ gtk_box_pack_start (net_graph_box,
+ GTK_WIDGET (load_graph_get_widget(net_graph)),
TRUE,
TRUE,
0);
- table = GTK_WIDGET (gtk_builder_get_object (builder, "net_table"));
+ table = GTK_GRID (gtk_builder_get_object (builder, "net_table"));
color_picker = gsm_color_button_new (
&net_graph->colors.at(0), GSMCP_TYPE_NETWORK_IN);
g_signal_connect (G_OBJECT (color_picker), "color-set",
G_CALLBACK (cb_net_in_color_changed), app);
title_text = g_strdup_printf(title_template, _("Receiving"));
- gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+ gsm_color_button_set_title(color_picker, title_text);
g_free(title_text);
- picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "receiving_picker_alignment"));
- gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+ picker_alignment = GTK_ALIGNMENT (gtk_builder_get_object (builder, "receiving_picker_alignment"));
+ gtk_container_add (GTK_CONTAINER (picker_alignment), GTK_WIDGET (color_picker));
- label = GTK_WIDGET (gtk_builder_get_object(builder, "receiving_label"));
- gtk_grid_attach_next_to (GTK_GRID (table), load_graph_get_labels(net_graph)->net_in, label,
GTK_POS_RIGHT, 1, 1);
- label = GTK_WIDGET (gtk_builder_get_object(builder, "total_received_label"));
- gtk_grid_attach_next_to (GTK_GRID (table), load_graph_get_labels(net_graph)->net_in_total, label,
GTK_POS_RIGHT, 1, 1);
+ label = GTK_LABEL (gtk_builder_get_object(builder, "receiving_label"));
+ gtk_grid_attach_next_to (table, GTK_WIDGET (load_graph_get_labels(net_graph)->net_in), GTK_WIDGET
(label), GTK_POS_RIGHT, 1, 1);
+ label = GTK_LABEL (gtk_builder_get_object(builder, "total_received_label"));
+ gtk_grid_attach_next_to (table, GTK_WIDGET (load_graph_get_labels(net_graph)->net_in_total), GTK_WIDGET
(label), GTK_POS_RIGHT, 1, 1);
color_picker = gsm_color_button_new (
&net_graph->colors.at(1), GSMCP_TYPE_NETWORK_OUT);
g_signal_connect (G_OBJECT (color_picker), "color-set",
G_CALLBACK (cb_net_out_color_changed), app);
title_text = g_strdup_printf(title_template, _("Sending"));
- gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+ gsm_color_button_set_title(color_picker, title_text);
g_free(title_text);
- picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "sending_picker_alignment"));
- gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+ picker_alignment = GTK_ALIGNMENT (gtk_builder_get_object (builder, "sending_picker_alignment"));
+ gtk_container_add (GTK_CONTAINER (picker_alignment), GTK_WIDGET (color_picker));
- label = GTK_WIDGET (gtk_builder_get_object(builder, "sending_label"));
- gtk_grid_attach_next_to (GTK_GRID (table), load_graph_get_labels(net_graph)->net_out, label,
GTK_POS_RIGHT, 1, 1);
- label = GTK_WIDGET (gtk_builder_get_object(builder, "total_sent_label"));
- gtk_grid_attach_next_to (GTK_GRID (table), load_graph_get_labels(net_graph)->net_out_total, label,
GTK_POS_RIGHT, 1, 1);
+ label = GTK_LABEL (gtk_builder_get_object(builder, "sending_label"));
+ gtk_grid_attach_next_to (table, GTK_WIDGET (load_graph_get_labels(net_graph)->net_out), GTK_WIDGET
(label), GTK_POS_RIGHT, 1, 1);
+ label = GTK_LABEL (gtk_builder_get_object(builder, "total_sent_label"));
+ gtk_grid_attach_next_to (table, GTK_WIDGET (load_graph_get_labels(net_graph)->net_out_total), GTK_WIDGET
(label), GTK_POS_RIGHT, 1, 1);
app->net_graph = net_graph;
g_free (title_template);
@@ -458,10 +458,10 @@ on_activate_search (GSimpleAction *action, GVariant *parameter, gpointer data)
GsmApplication *app = (GsmApplication *) data;
GVariant *state = g_action_get_state (G_ACTION (action));
gboolean is_search_shortcut = g_variant_get_boolean (parameter);
- gboolean is_search_bar = gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (app->search_bar));
- gtk_widget_set_visible (app->search_bar, is_search_bar || is_search_shortcut);
+ gboolean is_search_bar = gtk_search_bar_get_search_mode (app->search_bar);
+ gtk_widget_set_visible (GTK_WIDGET (app->search_bar), is_search_bar || is_search_shortcut);
if (is_search_shortcut && is_search_bar) {
- gtk_widget_grab_focus (app->search_entry);
+ gtk_widget_grab_focus (GTK_WIDGET (app->search_entry));
} else {
g_action_change_state (G_ACTION (action), g_variant_new_boolean (!g_variant_get_boolean (state)));
}
@@ -523,7 +523,7 @@ change_priority_state (GSimpleAction *action, GVariant *state, gpointer data)
void
update_page_activities (GsmApplication *app)
{
- const char *current_page = gtk_stack_get_visible_child_name (GTK_STACK (app->stack));
+ const char *current_page = gtk_stack_get_visible_child_name (app->stack);
if (strcmp (current_page, "processes") == 0) {
GAction *search_action = g_action_map_lookup_action (G_ACTION_MAP (app->main_window),
@@ -531,22 +531,22 @@ update_page_activities (GsmApplication *app)
proctable_update (app);
proctable_thaw (app);
- gtk_widget_show (app->end_process_button);
- gtk_widget_show (app->search_button);
- gtk_widget_show (app->process_menu_button);
+ gtk_widget_show (GTK_WIDGET (app->end_process_button));
+ gtk_widget_show (GTK_WIDGET (app->search_button));
+ gtk_widget_show (GTK_WIDGET (app->process_menu_button));
update_sensitivity (app);
if (g_variant_get_boolean (g_action_get_state (search_action)))
- gtk_widget_grab_focus (app->search_entry);
+ gtk_widget_grab_focus (GTK_WIDGET (app->search_entry));
else
- gtk_widget_grab_focus (app->tree);
+ gtk_widget_grab_focus (GTK_WIDGET (app->tree));
} else {
proctable_freeze (app);
- gtk_widget_hide (app->end_process_button);
- gtk_widget_hide (app->search_button);
- gtk_widget_hide (app->process_menu_button);
+ gtk_widget_hide (GTK_WIDGET (app->end_process_button));
+ gtk_widget_hide (GTK_WIDGET (app->search_button));
+ gtk_widget_hide (GTK_WIDGET (app->process_menu_button));
update_sensitivity (app);
}
@@ -623,9 +623,9 @@ cb_main_window_state_changed (GtkWidget *window, GdkEventWindowState *event, gpo
void
create_main_window (GsmApplication *app)
{
- GtkWidget *main_window;
- GtkWidget *stack;
- GtkWidget *process_menu_button;
+ GtkApplicationWindow *main_window;
+ GtkStack *stack;
+ GtkMenuButton *process_menu_button;
GMenuModel *process_menu_model;
const char* session;
@@ -636,22 +636,22 @@ create_main_window (GsmApplication *app)
gtk_builder_add_from_resource (builder, "/org/gnome/gnome-system-monitor/data/interface.ui", NULL);
gtk_builder_add_from_resource (builder, "/org/gnome/gnome-system-monitor/data/menus.ui", NULL);
- main_window = GTK_WIDGET (gtk_builder_get_object (builder, "main_window"));
+ main_window = GTK_APPLICATION_WINDOW (gtk_builder_get_object (builder, "main_window"));
gtk_window_set_application (GTK_WINDOW (main_window), app->gobj());
- gtk_widget_set_name (main_window, "gnome-system-monitor");
+ gtk_widget_set_name (GTK_WIDGET (main_window), "gnome-system-monitor");
app->main_window = main_window;
session = g_getenv ("XDG_CURRENT_DESKTOP");
if (session && !strstr (session, "GNOME")){
- GtkWidget *mainbox;
- GtkWidget *headerbar;
+ GtkBox *mainbox;
+ GtkHeaderBar *headerbar;
- mainbox = GTK_WIDGET (gtk_builder_get_object (builder, "main_box"));
- headerbar = GTK_WIDGET (gtk_builder_get_object (builder, "header_bar"));
- gtk_style_context_remove_class (gtk_widget_get_style_context (headerbar), "titlebar");
+ mainbox = GTK_BOX (gtk_builder_get_object (builder, "main_box"));
+ headerbar = GTK_HEADER_BAR (gtk_builder_get_object (builder, "header_bar"));
+ gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (headerbar)), "titlebar");
gtk_window_set_titlebar (GTK_WINDOW (main_window), NULL);
- gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (headerbar), FALSE);
- gtk_box_pack_start (GTK_BOX(mainbox), headerbar, FALSE, FALSE, 0);
+ gtk_header_bar_set_show_close_button (headerbar, FALSE);
+ gtk_box_pack_start (mainbox, GTK_WIDGET (headerbar), FALSE, FALSE, 0);
}
g_settings_get (app->settings, GSM_SETTING_WINDOW_STATE, "(iiii)",
@@ -664,13 +664,13 @@ create_main_window (GsmApplication *app)
if (g_settings_get_boolean (app->settings, GSM_SETTING_MAXIMIZED))
gtk_window_maximize (GTK_WINDOW (main_window));
- app->process_menu_button = process_menu_button = GTK_WIDGET (gtk_builder_get_object (builder,
"process_menu_button"));
+ app->process_menu_button = process_menu_button = GTK_MENU_BUTTON (gtk_builder_get_object (builder,
"process_menu_button"));
process_menu_model = G_MENU_MODEL (gtk_builder_get_object (builder, "process-window-menu"));
- gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (process_menu_button), process_menu_model);
+ gtk_menu_button_set_menu_model (process_menu_button, process_menu_model);
- app->end_process_button = GTK_WIDGET (gtk_builder_get_object (builder, "end_process_button"));
+ app->end_process_button = GTK_BUTTON (gtk_builder_get_object (builder, "end_process_button"));
- app->search_button = GTK_WIDGET (gtk_builder_get_object (builder, "search_button"));
+ app->search_button = GTK_BUTTON (gtk_builder_get_object (builder, "search_button"));
GActionEntry win_action_entries[] = {
{ "about", on_activate_about, NULL, NULL, NULL },
@@ -694,15 +694,15 @@ create_main_window (GsmApplication *app)
G_N_ELEMENTS (win_action_entries),
app);
- GdkScreen* screen = gtk_widget_get_screen(main_window);
+ GdkScreen* screen = gtk_widget_get_screen(GTK_WIDGET (main_window));
GdkVisual* visual = gdk_screen_get_rgba_visual(screen);
/* use visual, if available */
if (visual)
- gtk_widget_set_visual(main_window, visual);
+ gtk_widget_set_visual(GTK_WIDGET (main_window), visual);
/* create the main stack */
- app->stack = stack = GTK_WIDGET (gtk_builder_get_object (builder, "stack"));
+ app->stack = stack = GTK_STACK (gtk_builder_get_object (builder, "stack"));
create_proc_view(app, builder);
@@ -734,7 +734,7 @@ create_main_window (GsmApplication *app)
g_action_change_state (action,
g_settings_get_value (app->settings, GSM_SETTING_SHOW_WHOSE_PROCESSES));
- gtk_widget_show (main_window);
+ gtk_widget_show (GTK_WIDGET (main_window));
update_page_activities (app);
diff --git a/src/load-graph.cpp b/src/load-graph.cpp
index a644e4e..85264fe 100644
--- a/src/load-graph.cpp
+++ b/src/load-graph.cpp
@@ -71,14 +71,14 @@ void draw_background(LoadGraph *graph) {
graph->graph_delx = (graph->draw_width - 2.0 - graph->indent) / (LoadGraph::NUM_POINTS - 3);
graph->graph_buffer_offset = (int) (1.5 * graph->graph_delx) + FRAME_WIDTH ;
- gtk_widget_get_allocation (graph->disp, &allocation);
- surface = gdk_window_create_similar_surface (gtk_widget_get_window (graph->disp),
+ gtk_widget_get_allocation (GTK_WIDGET (graph->disp), &allocation);
+ surface = gdk_window_create_similar_surface (gtk_widget_get_window (GTK_WIDGET (graph->disp)),
CAIRO_CONTENT_COLOR_ALPHA,
allocation.width,
allocation.height);
cr = cairo_create (surface);
- GtkStyleContext *context = gtk_widget_get_style_context (GsmApplication::get()->stack);
+ GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (GsmApplication::get()->stack));
gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &fg);
@@ -178,7 +178,7 @@ void
load_graph_queue_draw (LoadGraph *graph)
{
/* repaint */
- gtk_widget_queue_draw (graph->disp);
+ gtk_widget_queue_draw (GTK_WIDGET (graph->disp));
}
static int load_graph_update (gpointer user_data); // predeclare load_graph_update so we can compile ;)
@@ -718,49 +718,49 @@ LoadGraph::LoadGraph(guint type)
n = GsmApplication::get()->config.num_cpus;
for(guint i = 0; i < G_N_ELEMENTS(labels.cpu); ++i)
- labels.cpu[i] = gtk_label_new(NULL);
+ labels.cpu[i] = GTK_LABEL (gtk_label_new(NULL));
break;
case LOAD_GRAPH_MEM:
n = 2;
- labels.memory = gtk_label_new(NULL);
- gtk_widget_set_valign (labels.memory, GTK_ALIGN_CENTER);
- gtk_widget_set_halign (labels.memory, GTK_ALIGN_START);
- gtk_widget_show (labels.memory);
- labels.swap = gtk_label_new(NULL);
- gtk_widget_set_valign (labels.swap, GTK_ALIGN_CENTER);
- gtk_widget_set_halign (labels.swap, GTK_ALIGN_START);
- gtk_widget_show (labels.swap);
+ labels.memory = GTK_LABEL (gtk_label_new(NULL));
+ gtk_widget_set_valign (GTK_WIDGET (labels.memory), GTK_ALIGN_CENTER);
+ gtk_widget_set_halign (GTK_WIDGET (labels.memory), GTK_ALIGN_START);
+ gtk_widget_show (GTK_WIDGET (labels.memory));
+ labels.swap = GTK_LABEL (gtk_label_new(NULL));
+ gtk_widget_set_valign (GTK_WIDGET (labels.swap), GTK_ALIGN_CENTER);
+ gtk_widget_set_halign (GTK_WIDGET (labels.swap), GTK_ALIGN_START);
+ gtk_widget_show (GTK_WIDGET (labels.swap));
break;
case LOAD_GRAPH_NET:
memset(&net, 0, sizeof net);
n = 2;
net.max = 1;
- labels.net_in = gtk_label_new(NULL);
- gtk_label_set_width_chars(GTK_LABEL(labels.net_in), 10);
- gtk_widget_set_valign (labels.net_in, GTK_ALIGN_CENTER);
- gtk_widget_set_halign (labels.net_in, GTK_ALIGN_END);
- gtk_widget_show (labels.net_in);
-
- labels.net_in_total = gtk_label_new(NULL);
- gtk_widget_set_valign (labels.net_in_total, GTK_ALIGN_CENTER);
- gtk_widget_set_halign (labels.net_in_total, GTK_ALIGN_END);
- gtk_label_set_width_chars(GTK_LABEL(labels.net_in_total), 10);
- gtk_widget_show (labels.net_in_total);
-
- labels.net_out = gtk_label_new(NULL);
- gtk_widget_set_valign (labels.net_out, GTK_ALIGN_CENTER);
- gtk_widget_set_halign (labels.net_out, GTK_ALIGN_END);
- gtk_label_set_width_chars(GTK_LABEL(labels.net_out), 10);
- gtk_widget_show (labels.net_out);
-
- labels.net_out_total = gtk_label_new(NULL);
- gtk_widget_set_valign (labels.net_out_total, GTK_ALIGN_CENTER);
- gtk_widget_set_halign (labels.net_out, GTK_ALIGN_END);
- gtk_label_set_width_chars(GTK_LABEL(labels.net_out_total), 10);
- gtk_widget_show (labels.net_out_total);
+ labels.net_in = GTK_LABEL (gtk_label_new(NULL));
+ gtk_label_set_width_chars(labels.net_in, 10);
+ gtk_widget_set_valign (GTK_WIDGET (labels.net_in), GTK_ALIGN_CENTER);
+ gtk_widget_set_halign (GTK_WIDGET (labels.net_in), GTK_ALIGN_END);
+ gtk_widget_show (GTK_WIDGET (labels.net_in));
+
+ labels.net_in_total = GTK_LABEL (gtk_label_new(NULL));
+ gtk_widget_set_valign (GTK_WIDGET (labels.net_in_total), GTK_ALIGN_CENTER);
+ gtk_widget_set_halign (GTK_WIDGET (labels.net_in_total), GTK_ALIGN_END);
+ gtk_label_set_width_chars(labels.net_in_total, 10);
+ gtk_widget_show (GTK_WIDGET (labels.net_in_total));
+
+ labels.net_out = GTK_LABEL (gtk_label_new(NULL));
+ gtk_widget_set_valign (GTK_WIDGET (labels.net_out), GTK_ALIGN_CENTER);
+ gtk_widget_set_halign (GTK_WIDGET (labels.net_out), GTK_ALIGN_END);
+ gtk_label_set_width_chars(labels.net_out, 10);
+ gtk_widget_show (GTK_WIDGET (labels.net_out));
+
+ labels.net_out_total = GTK_LABEL (gtk_label_new(NULL));
+ gtk_widget_set_valign (GTK_WIDGET (labels.net_out_total), GTK_ALIGN_CENTER);
+ gtk_widget_set_halign (GTK_WIDGET (labels.net_out), GTK_ALIGN_END);
+ gtk_label_set_width_chars(labels.net_out_total, 10);
+ gtk_widget_show (GTK_WIDGET (labels.net_out_total));
break;
}
@@ -792,12 +792,12 @@ LoadGraph::LoadGraph(guint type)
render_counter = (frames_per_unit - 1);
draw = FALSE;
- main_widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_widget_set_size_request(main_widget, -1, LoadGraph::GRAPH_MIN_HEIGHT);
- gtk_widget_show (main_widget);
+ main_widget = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 6));
+ gtk_widget_set_size_request(GTK_WIDGET (main_widget), -1, LoadGraph::GRAPH_MIN_HEIGHT);
+ gtk_widget_show (GTK_WIDGET (main_widget));
- disp = gtk_drawing_area_new ();
- gtk_widget_show (disp);
+ disp = GTK_DRAWING_AREA (gtk_drawing_area_new ());
+ gtk_widget_show (GTK_WIDGET (disp));
g_signal_connect (G_OBJECT (disp), "draw",
G_CALLBACK (load_graph_draw), graph);
g_signal_connect (G_OBJECT(disp), "configure_event",
@@ -807,9 +807,9 @@ LoadGraph::LoadGraph(guint type)
g_signal_connect (G_OBJECT(disp), "state-flags-changed",
G_CALLBACK (load_graph_state_changed), graph);
- gtk_widget_set_events (disp, GDK_EXPOSURE_MASK);
+ gtk_widget_set_events (GTK_WIDGET (disp), GDK_EXPOSURE_MASK);
- gtk_box_pack_start (GTK_BOX (main_widget), disp, TRUE, TRUE, 0);
+ gtk_box_pack_start (main_widget, GTK_WIDGET (disp), TRUE, TRUE, 0);
/* Allocate data in a contiguous block */
@@ -818,7 +818,7 @@ LoadGraph::LoadGraph(guint type)
for (guint i = 0; i < LoadGraph::NUM_POINTS; ++i)
data[i] = &data_block[0] + i * n;
- gtk_widget_show_all (main_widget);
+ gtk_widget_show_all (GTK_WIDGET (main_widget));
}
void
@@ -869,19 +869,19 @@ load_graph_get_labels (LoadGraph *graph)
return &graph->labels;
}
-GtkWidget*
+GtkBox*
load_graph_get_widget (LoadGraph *graph)
{
return graph->main_widget;
}
-GtkWidget*
+GsmColorButton*
load_graph_get_mem_color_picker(LoadGraph *graph)
{
return graph->mem_color_picker;
}
-GtkWidget*
+GsmColorButton*
load_graph_get_swap_color_picker(LoadGraph *graph)
{
return graph->swap_color_picker;
diff --git a/src/load-graph.h b/src/load-graph.h
index c726945..07f8035 100644
--- a/src/load-graph.h
+++ b/src/load-graph.h
@@ -5,6 +5,7 @@
#include <glib.h>
#include <glibtop/cpu.h>
+#include "gsm_color_button.h"
#include "util.h"
enum
@@ -23,13 +24,13 @@ enum
struct LoadGraphLabels
{
- GtkWidget *cpu[GLIBTOP_NCPU];
- GtkWidget *memory;
- GtkWidget *swap;
- GtkWidget *net_in;
- GtkWidget *net_in_total;
- GtkWidget *net_out;
- GtkWidget *net_out_total;
+ GtkLabel *cpu[GLIBTOP_NCPU];
+ GtkLabel *memory;
+ GtkLabel *swap;
+ GtkLabel *net_in;
+ GtkLabel *net_in_total;
+ GtkLabel *net_out;
+ GtkLabel *net_out_total;
};
struct LoadGraph
@@ -64,8 +65,8 @@ struct LoadGraph
std::vector<float> data_block;
gfloat* data[NUM_POINTS];
- GtkWidget *main_widget;
- GtkWidget *disp;
+ GtkBox *main_widget;
+ GtkDrawingArea *disp;
cairo_surface_t *background;
@@ -74,8 +75,8 @@ struct LoadGraph
gboolean draw;
LoadGraphLabels labels;
- GtkWidget *mem_color_picker;
- GtkWidget *swap_color_picker;
+ GsmColorButton *mem_color_picker;
+ GsmColorButton *swap_color_picker;
/* union { */
struct
@@ -121,13 +122,13 @@ load_graph_reset (LoadGraph *g);
LoadGraphLabels*
load_graph_get_labels (LoadGraph *g) G_GNUC_CONST;
-GtkWidget*
+GtkBox*
load_graph_get_widget (LoadGraph *g) G_GNUC_CONST;
-GtkWidget*
+GsmColorButton*
load_graph_get_mem_color_picker(LoadGraph *g) G_GNUC_CONST;
-GtkWidget*
+GsmColorButton*
load_graph_get_swap_color_picker(LoadGraph *g) G_GNUC_CONST;
#endif /* _GSM_LOAD_GRAPH_H_ */
diff --git a/src/lsof.cpp b/src/lsof.cpp
index 869cef5..1b27eed 100644
--- a/src/lsof.cpp
+++ b/src/lsof.cpp
@@ -84,7 +84,7 @@ namespace
struct GUI : private procman::NonCopyable {
GtkListStore *model;
- GtkEntry *entry;
+ GtkSearchEntry *entry;
GtkWindow *window;
GtkLabel *count;
GsmApplication *app;
@@ -126,7 +126,7 @@ namespace
string pattern() const
{
- return gtk_entry_get_text(this->entry);
+ return gtk_entry_get_text(GTK_ENTRY (this->entry));
}
@@ -222,7 +222,7 @@ void procman_lsof(GsmApplication *app)
G_TYPE_STRING // PROCMAN_LSOF_COL_FILENAME
);
- GtkWidget *tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+ GtkTreeView *tree = GTK_TREE_VIEW (gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)));
g_object_unref(model);
GtkTreeViewColumn *column;
@@ -275,29 +275,29 @@ void procman_lsof(GsmApplication *app)
gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
- GtkWidget *dialog;
+ GtkWindow *dialog;
GtkBuilder *builder = gtk_builder_new ();
gtk_builder_add_from_resource (builder, "/org/gnome/gnome-system-monitor/data/lsof.ui", NULL);
- dialog = GTK_WIDGET (gtk_builder_get_object (builder, "lsof_dialog"));
+ dialog = GTK_WINDOW (gtk_builder_get_object (builder, "lsof_dialog"));
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (app->main_window));
- GtkWidget *entry = GTK_WIDGET (gtk_builder_get_object (builder, "entry"));
+ GtkSearchEntry *entry = GTK_SEARCH_ENTRY (gtk_builder_get_object (builder, "entry"));
- GtkWidget *case_button = GTK_WIDGET (gtk_builder_get_object (builder, "case_button"));
+ GtkCheckButton *case_button = GTK_CHECK_BUTTON (gtk_builder_get_object (builder, "case_button"));
// Scrolled TreeView
- GtkWidget *scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "scrolled"));
+ GtkScrolledWindow *scrolled = GTK_SCROLLED_WINDOW (gtk_builder_get_object (builder, "scrolled"));
- gtk_container_add(GTK_CONTAINER(scrolled), tree);
+ gtk_container_add(GTK_CONTAINER(scrolled), GTK_WIDGET (tree));
GUI *gui = new GUI; // wil be deleted by the close button or delete-event
gui->app = app;
gui->model = model;
- gui->window = GTK_WINDOW(dialog);
- gui->entry = GTK_ENTRY(entry);
+ gui->window = dialog;
+ gui->entry = entry;
gui->case_insensitive = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (case_button));
g_signal_connect(G_OBJECT(entry), "search-changed",
@@ -310,7 +310,7 @@ void procman_lsof(GsmApplication *app)
gtk_builder_connect_signals (builder, NULL);
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (GsmApplication::get()->main_window));
- gtk_widget_show_all(dialog);
+ gtk_widget_show_all(GTK_WIDGET (dialog));
gui->search ();
g_object_unref (G_OBJECT (builder));
diff --git a/src/memmaps.cpp b/src/memmaps.cpp
index 0fa7aa9..9de7a3c 100644
--- a/src/memmaps.cpp
+++ b/src/memmaps.cpp
@@ -123,24 +123,24 @@ namespace
{
public:
guint timer;
- GtkWidget *tree;
+ GsmTreeView *tree;
ProcInfo *info;
OffsetFormater format;
mutable InodeDevices devices;
- MemMapsData(GtkWidget *a_tree)
+ MemMapsData(GsmTreeView *a_tree)
: timer(),
tree(a_tree),
info(NULL),
format(),
devices()
{
- gsm_tree_view_load_state (GSM_TREE_VIEW (this->tree));
+ gsm_tree_view_load_state (this->tree);
}
~MemMapsData()
{
- gsm_tree_view_save_state (GSM_TREE_VIEW (this->tree));
+ gsm_tree_view_save_state (this->tree);
}
};
}
@@ -299,7 +299,7 @@ dialog_response (GtkDialog * dialog, gint response_id, gpointer data)
static MemMapsData*
create_memmapsdata (GsmApplication *app)
{
- GtkWidget *tree;
+ GsmTreeView *tree;
GtkListStore *model;
guint i;
@@ -422,10 +422,10 @@ create_single_memmaps_dialog (GtkTreeModel *model, GtkTreePath *path,
{
GsmApplication *app = static_cast<GsmApplication *>(data);
MemMapsData *mmdata;
- GtkWidget *memmapsdialog;
- GtkWidget *dialog_vbox;
- GtkWidget *label;
- GtkWidget *scrolled;
+ GtkDialog *memmapsdialog;
+ GtkBox *dialog_box;
+ GtkLabel *label;
+ GtkScrolledWindow *scrolled;
ProcInfo *info;
gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
@@ -436,7 +436,7 @@ create_single_memmaps_dialog (GtkTreeModel *model, GtkTreePath *path,
mmdata = create_memmapsdata (app);
mmdata->info = info;
- memmapsdialog = GTK_WIDGET (g_object_new (GTK_TYPE_DIALOG,
+ memmapsdialog = GTK_DIALOG (g_object_new (GTK_TYPE_DIALOG,
"title", _("Memory Maps"),
"use-header-bar", TRUE,
"destroy-with-parent", TRUE, NULL));
@@ -445,34 +445,34 @@ create_single_memmaps_dialog (GtkTreeModel *model, GtkTreePath *path,
gtk_window_set_default_size(GTK_WINDOW(memmapsdialog), 620, 400);
gtk_container_set_border_width(GTK_CONTAINER(memmapsdialog), 5);
- dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG(memmapsdialog));
- gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+ dialog_box = GTK_BOX (gtk_dialog_get_content_area (memmapsdialog));
+ gtk_container_set_border_width (GTK_CONTAINER (dialog_box), 5);
label = procman_make_label_for_mmaps_or_ofiles (
_("_Memory maps for process \"%s\" (PID %u):"),
info->name,
info->pid);
- gtk_box_pack_start (GTK_BOX (dialog_vbox), label, FALSE, TRUE, 0);
+ gtk_box_pack_start (dialog_box, GTK_WIDGET (label), FALSE, TRUE, 0);
- scrolled = gtk_scrolled_window_new (NULL, NULL);
+ scrolled = GTK_SCROLLED_WINDOW (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_container_add (GTK_CONTAINER (scrolled), mmdata->tree);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), mmdata->tree);
+ gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (mmdata->tree));
+ gtk_label_set_mnemonic_widget (label, GTK_WIDGET (mmdata->tree));
- gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+ gtk_box_pack_start (dialog_box, GTK_WIDGET (scrolled), TRUE, TRUE, 0);
g_signal_connect(G_OBJECT(memmapsdialog), "response",
G_CALLBACK(dialog_response), mmdata);
gtk_window_set_transient_for (GTK_WINDOW (memmapsdialog), GTK_WINDOW
(GsmApplication::get()->main_window));
- gtk_widget_show_all (memmapsdialog);
+ gtk_widget_show_all (GTK_WIDGET (memmapsdialog));
mmdata->timer = g_timeout_add_seconds (5, memmaps_timer, mmdata);
update_memmaps_dialog (mmdata);
diff --git a/src/openfiles.cpp b/src/openfiles.cpp
index f8f64ee..9505da5 100644
--- a/src/openfiles.cpp
+++ b/src/openfiles.cpp
@@ -167,7 +167,7 @@ compare_open_files(gconstpointer a, gconstpointer b)
static void
-update_openfiles_dialog (GtkWidget *tree)
+update_openfiles_dialog (GsmTreeView *tree)
{
ProcInfo *info;
GtkTreeModel *model;
@@ -221,10 +221,10 @@ update_openfiles_dialog (GtkWidget *tree)
static void
close_openfiles_dialog (GtkDialog *dialog, gint id, gpointer data)
{
- GtkWidget *tree = static_cast<GtkWidget*>(data);
+ GsmTreeView *tree = static_cast<GsmTreeView*>(data);
guint timer;
- gsm_tree_view_save_state (GSM_TREE_VIEW (tree));
+ gsm_tree_view_save_state (tree);
timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
g_source_remove (timer);
@@ -235,10 +235,10 @@ close_openfiles_dialog (GtkDialog *dialog, gint id, gpointer data)
}
-static GtkWidget *
+static GsmTreeView *
create_openfiles_tree (GsmApplication *app)
{
- GtkWidget *tree;
+ GsmTreeView *tree;
GtkListStore *model;
GtkTreeViewColumn *column;
GtkCellRenderer *cell;
@@ -294,7 +294,7 @@ create_openfiles_tree (GsmApplication *app)
static gboolean
openfiles_timer (gpointer data)
{
- GtkWidget *tree = static_cast<GtkWidget*>(data);
+ GsmTreeView* tree = static_cast<GsmTreeView*>(data);
GtkTreeModel *model;
model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
@@ -311,11 +311,11 @@ create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
GtkTreeIter *iter, gpointer data)
{
GsmApplication *app = static_cast<GsmApplication *>(data);
- GtkWidget *openfilesdialog;
- GtkWidget *cmd_grid;
- GtkWidget *label;
- GtkWidget *scrolled;
- GtkWidget *tree;
+ GtkDialog *openfilesdialog;
+ GtkGrid *cmd_grid;
+ GtkLabel *label;
+ GtkScrolledWindow *scrolled;
+ GsmTreeView *tree;
ProcInfo *info;
guint timer;
@@ -327,9 +327,9 @@ create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
GtkBuilder *builder = gtk_builder_new();
gtk_builder_add_from_resource (builder, "/org/gnome/gnome-system-monitor/data/openfiles.ui", NULL);
- openfilesdialog = GTK_WIDGET (gtk_builder_get_object (builder, "openfiles_dialog"));
+ openfilesdialog = GTK_DIALOG (gtk_builder_get_object (builder, "openfiles_dialog"));
- cmd_grid = GTK_WIDGET (gtk_builder_get_object (builder, "cmd_grid"));
+ cmd_grid = GTK_GRID (gtk_builder_get_object (builder, "cmd_grid"));
label = procman_make_label_for_mmaps_or_ofiles (
@@ -337,12 +337,12 @@ create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
info->name,
info->pid);
- gtk_container_add (GTK_CONTAINER (cmd_grid), label);
+ gtk_container_add (GTK_CONTAINER (cmd_grid), GTK_WIDGET (label));
- scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "scrolled"));
+ scrolled = GTK_SCROLLED_WINDOW (gtk_builder_get_object (builder, "scrolled"));
tree = create_openfiles_tree (app);
- gtk_container_add (GTK_CONTAINER (scrolled), tree);
+ gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (tree));
g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
g_signal_connect (G_OBJECT (openfilesdialog), "response",
@@ -351,7 +351,7 @@ create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
gtk_builder_connect_signals (builder, NULL);
gtk_window_set_transient_for (GTK_WINDOW (openfilesdialog), GTK_WINDOW
(GsmApplication::get()->main_window));
- gtk_widget_show_all (openfilesdialog);
+ gtk_widget_show_all (GTK_WIDGET (openfilesdialog));
timer = g_timeout_add_seconds (5, openfiles_timer, tree);
g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
diff --git a/src/prefsdialog.cpp b/src/prefsdialog.cpp
index 0484253..ecee87b 100644
--- a/src/prefsdialog.cpp
+++ b/src/prefsdialog.cpp
@@ -14,7 +14,7 @@
#include "systemd.h"
#include "util.h"
-static GtkWidget *prefs_dialog = NULL;
+static GtkDialog *prefs_dialog = NULL;
static void
prefs_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
@@ -110,7 +110,7 @@ disk_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
}
static void
-create_field_page(GtkBuilder* builder, GtkWidget *tree, const gchar *widgetname)
+create_field_page(GtkBuilder* builder, GtkTreeView *tree, const gchar *widgetname)
{
GtkTreeView *treeview;
GList *it, *columns;
@@ -203,11 +203,11 @@ create_preferences_dialog (GsmApplication *app)
static SBU graph_interval_updater("graph-update-interval");
static SBU disks_interval_updater("disks-interval");
- GtkWidget *notebook;
+ GtkNotebook *notebook;
GtkAdjustment *adjustment;
- GtkWidget *spin_button;
- GtkWidget *check_button;
- GtkWidget *smooth_button;
+ GtkSpinButton *spin_button;
+ GtkCheckButton *check_button;
+ GtkCheckButton *smooth_button;
GtkBuilder *builder;
gfloat update;
@@ -217,11 +217,11 @@ create_preferences_dialog (GsmApplication *app)
builder = gtk_builder_new();
gtk_builder_add_from_resource (builder, "/org/gnome/gnome-system-monitor/data/preferences.ui", NULL);
- prefs_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "preferences_dialog"));
+ prefs_dialog = GTK_DIALOG (gtk_builder_get_object (builder, "preferences_dialog"));
- notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
+ notebook = GTK_NOTEBOOK (gtk_builder_get_object (builder, "notebook"));
- spin_button = GTK_WIDGET (gtk_builder_get_object (builder, "processes_interval_spinner"));
+ spin_button = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "processes_interval_spinner"));
update = (gfloat) app->config.update_interval;
adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(spin_button));
@@ -235,43 +235,43 @@ create_preferences_dialog (GsmApplication *app)
g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
G_CALLBACK (SBU::callback), &interval_updater);
- smooth_button = GTK_WIDGET (gtk_builder_get_object (builder, "smooth_button"));
+ smooth_button = GTK_CHECK_BUTTON (gtk_builder_get_object (builder, "smooth_button"));
g_settings_bind(app->settings, SmoothRefresh::KEY.c_str(), smooth_button, "active",
G_SETTINGS_BIND_DEFAULT);
- check_button = GTK_WIDGET (gtk_builder_get_object (builder, "check_button"));
+ check_button = GTK_CHECK_BUTTON (gtk_builder_get_object (builder, "check_button"));
g_settings_bind (app->settings, GSM_SETTING_SHOW_KILL_DIALOG,
check_button, "active",
G_SETTINGS_BIND_DEFAULT);
- GtkWidget *solaris_button = GTK_WIDGET (gtk_builder_get_object (builder, "solaris_button"));
+ GtkCheckButton *solaris_button = GTK_CHECK_BUTTON (gtk_builder_get_object (builder, "solaris_button"));
g_settings_bind (app->settings, GSM_SETTING_SOLARIS_MODE,
solaris_button, "active",
G_SETTINGS_BIND_DEFAULT);
- GtkWidget *draw_stacked_button = GTK_WIDGET (gtk_builder_get_object (builder, "draw_stacked_button"));
+ GtkCheckButton *draw_stacked_button = GTK_CHECK_BUTTON (gtk_builder_get_object (builder,
"draw_stacked_button"));
g_settings_bind (app->settings, GSM_SETTING_DRAW_STACKED,
draw_stacked_button, "active",
G_SETTINGS_BIND_DEFAULT);
- create_field_page (builder, app->tree, "proctree");
+ create_field_page (builder, GTK_TREE_VIEW (app->tree), "proctree");
update = (gfloat) app->config.graph_update_interval;
- spin_button = GTK_WIDGET (gtk_builder_get_object (builder, "resources_interval_spinner"));
- adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(spin_button));
+ spin_button = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "resources_interval_spinner"));
+ adjustment = gtk_spin_button_get_adjustment (spin_button);
gtk_adjustment_configure (adjustment, update / 1000.0, 0.25,
100.0, 0.25, 1.0, 0);
g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
G_CALLBACK(SBU::callback),
&graph_interval_updater);
- GtkWidget *bits_button = GTK_WIDGET (gtk_builder_get_object (builder, "bits_button"));
+ GtkCheckButton *bits_button = GTK_CHECK_BUTTON (gtk_builder_get_object (builder, "bits_button"));
g_settings_bind(app->settings, GSM_SETTING_NETWORK_IN_BITS,
bits_button, "active",
G_SETTINGS_BIND_DEFAULT);
update = (gfloat) app->config.disks_update_interval;
- spin_button = GTK_WIDGET (gtk_builder_get_object (builder, "devices_interval_spinner"));
- adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(spin_button));
+ spin_button = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "devices_interval_spinner"));
+ adjustment = gtk_spin_button_get_adjustment (spin_button);
gtk_adjustment_configure (adjustment, update / 1000.0, 1.0,
100.0, 1.0, 1.0, 0);
g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
@@ -279,16 +279,16 @@ create_preferences_dialog (GsmApplication *app)
&disks_interval_updater);
- check_button = GTK_WIDGET (gtk_builder_get_object (builder, "all_devices_check"));
+ check_button = GTK_CHECK_BUTTON (gtk_builder_get_object (builder, "all_devices_check"));
g_settings_bind (app->settings, GSM_SETTING_SHOW_ALL_FS,
check_button, "active",
G_SETTINGS_BIND_DEFAULT);
- create_field_page (builder, app->disk_list, "disktreenew");
+ create_field_page (builder, GTK_TREE_VIEW (app->disk_list), "disktreenew");
gtk_window_set_transient_for (GTK_WINDOW (prefs_dialog), GTK_WINDOW
(GsmApplication::get()->main_window));
- gtk_widget_show_all (prefs_dialog);
+ gtk_widget_show_all (GTK_WIDGET (prefs_dialog));
g_signal_connect (G_OBJECT (prefs_dialog), "response",
G_CALLBACK (prefs_dialog_button_pressed), app);
diff --git a/src/procactions.cpp b/src/procactions.cpp
index b0c8b0d..6868d25 100644
--- a/src/procactions.cpp
+++ b/src/procactions.cpp
@@ -40,7 +40,7 @@ renice_single_process (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter
gint error;
int saved_errno;
gchar *error_msg;
- GtkWidget *dialog;
+ GtkMessageDialog *dialog;
gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
@@ -76,15 +76,15 @@ renice_single_process (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter
"%s"),
info->pid, args->arg_value, g_strerror(saved_errno));
- dialog = gtk_message_dialog_new (
+ dialog = GTK_MESSAGE_DIALOG (gtk_message_dialog_new (
NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
- "%s", error_msg);
+ "%s", error_msg));
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
g_free (error_msg);
}
@@ -119,7 +119,7 @@ kill_single_process (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter,
ProcInfo *info;
int error;
int saved_errno;
- GtkWidget *dialog;
+ GtkMessageDialog *dialog;
gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
@@ -154,15 +154,15 @@ kill_single_process (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter,
"%s"),
info->pid, args->arg_value, g_strerror(saved_errno));
- dialog = gtk_message_dialog_new (
+ dialog = GTK_MESSAGE_DIALOG (gtk_message_dialog_new (
NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
- "%s", error_msg);
+ "%s", error_msg));
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
g_free (error_msg);
}
diff --git a/src/procdialogs.cpp b/src/procdialogs.cpp
index e9a7467..cec89dc 100644
--- a/src/procdialogs.cpp
+++ b/src/procdialogs.cpp
@@ -36,7 +36,7 @@
#include "gsm_pkexec.h"
#include "cgroups.h"
-static GtkWidget *renice_dialog = NULL;
+static GtkDialog *renice_dialog = NULL;
static gint new_nice_value = 0;
@@ -56,7 +56,7 @@ kill_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
void
procdialog_create_kill_dialog (GsmApplication *app, int signal)
{
- GtkWidget *kill_alert_dialog;
+ GtkMessageDialog *kill_alert_dialog;
gchar *primary, *secondary, *button_text;
struct ProcActionArgs *kargs;
@@ -137,15 +137,15 @@ procdialog_create_kill_dialog (GsmApplication *app, int signal)
break;
}
- kill_alert_dialog = gtk_message_dialog_new (GTK_WINDOW (app->main_window),
+ kill_alert_dialog = GTK_MESSAGE_DIALOG (gtk_message_dialog_new (GTK_WINDOW (app->main_window),
static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL |
GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_MESSAGE_WARNING,
GTK_BUTTONS_NONE,
"%s",
- primary);
+ primary));
g_free (primary);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (kill_alert_dialog),
+ gtk_message_dialog_format_secondary_text (kill_alert_dialog,
"%s",
secondary);
@@ -160,17 +160,17 @@ procdialog_create_kill_dialog (GsmApplication *app, int signal)
g_signal_connect (G_OBJECT (kill_alert_dialog), "response",
G_CALLBACK (kill_dialog_button_pressed), kargs);
- gtk_widget_show_all (kill_alert_dialog);
+ gtk_widget_show_all (GTK_WIDGET (kill_alert_dialog));
}
static void
renice_scale_changed (GtkAdjustment *adj, gpointer data)
{
- GtkWidget *label = GTK_WIDGET (data);
+ GtkLabel *label = GTK_LABEL (data);
new_nice_value = int(gtk_adjustment_get_value (adj));
gchar* text = g_strdup(procman::get_nice_level_with_priority (new_nice_value));
- gtk_label_set_text (GTK_LABEL (label), text);
+ gtk_label_set_text (label, text);
g_free(text);
}
@@ -194,8 +194,8 @@ procdialog_create_renice_dialog (GsmApplication *app)
{
ProcInfo *info;
- GtkWidget *label;
- GtkWidget *priority_label;
+ GtkLabel *label;
+ GtkLabel *priority_label;
GtkAdjustment *renice_adj;
GtkBuilder *builder;
gchar *text;
@@ -213,7 +213,7 @@ procdialog_create_renice_dialog (GsmApplication *app)
builder = gtk_builder_new();
gtk_builder_add_from_resource (builder, "/org/gnome/gnome-system-monitor/data/renice.ui", NULL);
- renice_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "renice_dialog"));
+ renice_dialog = GTK_DIALOG (gtk_builder_get_object (builder, "renice_dialog"));
if ( selected_count == 1 ) {
dialog_title = g_strdup_printf (_("Change Priority of Process “%s” (PID: %u)"),
info->name, info->pid);
@@ -234,15 +234,15 @@ procdialog_create_renice_dialog (GsmApplication *app)
new_nice_value = 0;
- priority_label = GTK_WIDGET (gtk_builder_get_object (builder, "priority_label"));
- gtk_label_set_label (GTK_LABEL(priority_label), procman::get_nice_level_with_priority (info->nice));
+ priority_label = GTK_LABEL (gtk_builder_get_object (builder, "priority_label"));
+ gtk_label_set_label (priority_label, procman::get_nice_level_with_priority (info->nice));
text = g_strconcat("<small><i><b>", _("Note:"), "</b> ",
_("The priority of a process is given by its nice value. A lower nice value
corresponds to a higher priority."),
"</i></small>", NULL);
- label = GTK_WIDGET (gtk_builder_get_object (builder, "note_label"));
- gtk_label_set_label (GTK_LABEL(label), _(text));
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ label = GTK_LABEL (gtk_builder_get_object (builder, "note_label"));
+ gtk_label_set_label (label, _(text));
+ gtk_label_set_line_wrap (label, TRUE);
g_free (text);
g_signal_connect (G_OBJECT (renice_dialog), "response",
@@ -251,7 +251,7 @@ procdialog_create_renice_dialog (GsmApplication *app)
G_CALLBACK (renice_scale_changed), priority_label);
gtk_window_set_transient_for (GTK_WINDOW (renice_dialog), GTK_WINDOW
(GsmApplication::get()->main_window));
- gtk_widget_show_all (renice_dialog);
+ gtk_widget_show_all (GTK_WIDGET (renice_dialog));
gtk_builder_connect_signals (builder, NULL);
diff --git a/src/procproperties.cpp b/src/procproperties.cpp
index 54212dc..02b0c1c 100644
--- a/src/procproperties.cpp
+++ b/src/procproperties.cpp
@@ -53,7 +53,7 @@ format_memsize(guint64 size)
}
static void
-fill_proc_properties (GtkWidget *tree, ProcInfo *info)
+fill_proc_properties (GtkTreeView *tree, ProcInfo *info)
{
guint i;
GtkListStore *store;
@@ -88,7 +88,7 @@ fill_proc_properties (GtkWidget *tree, ProcInfo *info)
{ NULL, NULL}
};
- store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)));
+ store = GTK_LIST_STORE(gtk_tree_view_get_model(tree));
for (i = 0; proc_props[i].prop; i++) {
GtkTreeIter iter;
@@ -103,7 +103,7 @@ fill_proc_properties (GtkWidget *tree, ProcInfo *info)
}
static void
-update_procproperties_dialog (GtkWidget *tree)
+update_procproperties_dialog (GtkTreeView *tree)
{
ProcInfo *info;
@@ -116,7 +116,7 @@ update_procproperties_dialog (GtkWidget *tree)
static void
close_procprop_dialog (GtkDialog *dialog, gint id, gpointer data)
{
- GtkWidget *tree = static_cast<GtkWidget*>(data);
+ GtkTreeView *tree = static_cast<GtkTreeView*>(data);
guint timer;
timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
@@ -125,10 +125,10 @@ close_procprop_dialog (GtkDialog *dialog, gint id, gpointer data)
gtk_widget_destroy (GTK_WIDGET (dialog));
}
-static GtkWidget *
+static GtkTreeView *
create_procproperties_tree (GsmApplication *app, ProcInfo *info)
{
- GtkWidget *tree;
+ GtkTreeView *tree;
GtkListStore *model;
GtkTreeViewColumn *column;
GtkCellRenderer *cell;
@@ -139,7 +139,7 @@ create_procproperties_tree (GsmApplication *app, ProcInfo *info)
G_TYPE_STRING /* Value */
);
- tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+ tree = GTK_TREE_VIEW (gtk_tree_view_new_with_model (GTK_TREE_MODEL (model)));
g_object_unref (G_OBJECT (model));
for (i = 0; i < NUM_COLS; i++) {
@@ -150,10 +150,10 @@ create_procproperties_tree (GsmApplication *app, ProcInfo *info)
"text", i,
NULL);
gtk_tree_view_column_set_resizable (column, TRUE);
- gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+ gtk_tree_view_append_column (tree, column);
}
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(tree), FALSE);
+ gtk_tree_view_set_headers_visible (tree, FALSE);
fill_proc_properties(tree, info);
return tree;
@@ -162,10 +162,10 @@ create_procproperties_tree (GsmApplication *app, ProcInfo *info)
static gboolean
procprop_timer (gpointer data)
{
- GtkWidget *tree = static_cast<GtkWidget*>(data);
+ GtkTreeView *tree = static_cast<GtkTreeView*>(data);
GtkTreeModel *model;
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+ model = gtk_tree_view_get_model (tree);
g_assert(model);
update_procproperties_dialog (tree);
@@ -179,12 +179,12 @@ create_single_procproperties_dialog (GtkTreeModel *model, GtkTreePath *path,
{
GsmApplication *app = static_cast<GsmApplication *>(data);
- GtkWidget *procpropdialog;
- GtkWidget *dialog_vbox, *vbox;
- GtkWidget *cmd_hbox;
+ GtkDialog *procpropdialog;
+ GtkBox *dialog_vbox, *vbox;
+ GtkBox *cmd_hbox;
gchar *label;
- GtkWidget *scrolled;
- GtkWidget *tree;
+ GtkScrolledWindow *scrolled;
+ GtkTreeView *tree;
ProcInfo *info;
guint timer;
@@ -193,7 +193,7 @@ create_single_procproperties_dialog (GtkTreeModel *model, GtkTreePath *path,
if (!info)
return;
- procpropdialog = GTK_WIDGET (g_object_new (GTK_TYPE_DIALOG,
+ procpropdialog = GTK_DIALOG (g_object_new (GTK_TYPE_DIALOG,
"use-header-bar", TRUE, NULL));
label = g_strdup_printf( _("%s (PID %u)"), info->name, info->pid);
@@ -206,36 +206,36 @@ create_single_procproperties_dialog (GtkTreeModel *model, GtkTreePath *path,
gtk_window_set_default_size (GTK_WINDOW (procpropdialog), 575, 400);
gtk_container_set_border_width (GTK_CONTAINER (procpropdialog), 5);
- vbox = gtk_dialog_get_content_area (GTK_DIALOG (procpropdialog));
- gtk_box_set_spacing (GTK_BOX (vbox), 2);
+ vbox = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (procpropdialog)));
+ gtk_box_set_spacing (vbox, 2);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
- dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ dialog_vbox = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 6));
gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
- gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+ gtk_box_pack_start (vbox, GTK_WIDGET (dialog_vbox), TRUE, TRUE, 0);
- cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+ cmd_hbox = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12));
+ gtk_box_pack_start (dialog_vbox, GTK_WIDGET (cmd_hbox), FALSE, FALSE, 0);
- scrolled = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+ scrolled = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new (NULL, NULL));
+ gtk_scrolled_window_set_policy (scrolled,
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+ gtk_scrolled_window_set_shadow_type (scrolled,
GTK_SHADOW_IN);
tree = create_procproperties_tree (app, info);
- gtk_container_add (GTK_CONTAINER (scrolled), tree);
+ gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (tree));
g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
- gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
- gtk_widget_show_all (scrolled);
+ gtk_box_pack_start (dialog_vbox, GTK_WIDGET (scrolled), TRUE, TRUE, 0);
+ gtk_widget_show_all (GTK_WIDGET (scrolled));
g_signal_connect (G_OBJECT (procpropdialog), "response",
G_CALLBACK (close_procprop_dialog), tree);
gtk_window_set_transient_for (GTK_WINDOW (procpropdialog), GTK_WINDOW
(GsmApplication::get()->main_window));
- gtk_widget_show_all (procpropdialog);
+ gtk_widget_show_all (GTK_WIDGET (procpropdialog));
timer = g_timeout_add_seconds (5, procprop_timer, tree);
g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
diff --git a/src/proctable.cpp b/src/proctable.cpp
index 3f34633..33c0dfb 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -79,7 +79,7 @@ cb_save_tree_state(gpointer, gpointer data)
{
GsmApplication * const app = static_cast<GsmApplication *>(data);
- gsm_tree_view_save_state (GSM_TREE_VIEW (app->tree));
+ gsm_tree_view_save_state (app->tree);
}
static void
@@ -320,10 +320,10 @@ cb_show_whose_processes_changed (GSettings *settings, const gchar *key, gpointer
}
}
-GtkWidget *
+GsmTreeView *
proctable_new (GsmApplication * const app)
{
- GtkWidget *proctree;
+ GsmTreeView *proctree;
GtkTreeStore *model;
GtkTreeModelFilter *model_filter;
GtkTreeModelSort *model_sort;
@@ -428,7 +428,7 @@ proctable_new (GsmApplication * const app)
gtk_tree_view_column_set_min_width (column, 1);
gtk_tree_view_column_set_reorderable(column, TRUE);
- gsm_tree_view_append_and_bind_column (GSM_TREE_VIEW (proctree), column);
+ gsm_tree_view_append_and_bind_column (proctree, column);
gtk_tree_view_set_expander_column (GTK_TREE_VIEW (proctree), column);
for (i = COL_USER; i <= COL_PRIORITY; i++) {
@@ -450,7 +450,7 @@ proctable_new (GsmApplication * const app)
gtk_tree_view_column_set_resizable(col, TRUE);
gtk_tree_view_column_set_sort_column_id(col, i);
gtk_tree_view_column_set_reorderable(col, TRUE);
- gsm_tree_view_append_and_bind_column (GSM_TREE_VIEW (proctree), col);
+ gsm_tree_view_append_and_bind_column (proctree, col);
// type
switch (i) {
@@ -564,20 +564,20 @@ proctable_new (GsmApplication * const app)
app->last_vscroll_value = 0;
if (!cgroups_enabled ())
- gsm_tree_view_add_excluded_column (GSM_TREE_VIEW (proctree), COL_CGROUP);
+ gsm_tree_view_add_excluded_column (proctree, COL_CGROUP);
if (!procman::systemd_logind_running())
{
- gsm_tree_view_add_excluded_column (GSM_TREE_VIEW (proctree), COL_UNIT);
- gsm_tree_view_add_excluded_column (GSM_TREE_VIEW (proctree), COL_SESSION);
- gsm_tree_view_add_excluded_column (GSM_TREE_VIEW (proctree), COL_SEAT);
- gsm_tree_view_add_excluded_column (GSM_TREE_VIEW (proctree), COL_OWNER);
+ gsm_tree_view_add_excluded_column (proctree, COL_UNIT);
+ gsm_tree_view_add_excluded_column (proctree, COL_SESSION);
+ gsm_tree_view_add_excluded_column (proctree, COL_SEAT);
+ gsm_tree_view_add_excluded_column (proctree, COL_OWNER);
}
if (!can_show_security_context_column ())
- gsm_tree_view_add_excluded_column (GSM_TREE_VIEW (proctree), COL_SECURITYCONTEXT);
+ gsm_tree_view_add_excluded_column (proctree, COL_SECURITYCONTEXT);
- gsm_tree_view_load_state (GSM_TREE_VIEW (proctree));
+ gsm_tree_view_load_state (proctree);
GtkIconTheme* theme = gtk_icon_theme_get_default();
g_signal_connect(G_OBJECT (theme), "changed", G_CALLBACK (cb_refresh_icons), app);
@@ -609,7 +609,7 @@ proctable_new (GsmApplication * const app)
g_signal_connect (app->settings, "changed::" GSM_SETTING_SHOW_WHOSE_PROCESSES,
G_CALLBACK (cb_show_whose_processes_changed), app);
- gtk_widget_show (proctree);
+ gtk_widget_show (GTK_WIDGET (proctree));
return proctree;
}
diff --git a/src/proctable.h b/src/proctable.h
index 7a9ea1f..2254d70 100644
--- a/src/proctable.h
+++ b/src/proctable.h
@@ -23,6 +23,7 @@
#include <glib.h>
#include <gtk/gtk.h>
#include "application.h"
+#include "treeview.h"
enum
{
@@ -56,7 +57,7 @@ enum
};
-GtkWidget* proctable_new (GsmApplication *app);
+GsmTreeView* proctable_new (GsmApplication *app);
void proctable_update (GsmApplication *app);
void proctable_free_table (GsmApplication *app);
void proctable_freeze (GsmApplication *app);
diff --git a/src/treeview.c b/src/treeview.c
index 819ecbd..cd2b6ee 100644
--- a/src/treeview.c
+++ b/src/treeview.c
@@ -137,7 +137,7 @@ gsm_tree_view_load_state (GsmTreeView *tree_view)
sort_type);
if (priv->store_column_order) {
- GtkWidget *header_menu = gtk_menu_new ();
+ GtkMenu *header_menu = GTK_MENU (gtk_menu_new ());
GList *columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree_view));
GList *iter;
GVariantIter *var_iter;
@@ -147,8 +147,8 @@ gsm_tree_view_load_state (GsmTreeView *tree_view)
for (iter = columns; iter != NULL; iter = iter->next) {
const char *title;
char *key;
- GtkWidget *button;
- GtkWidget *column_item;
+ GtkButton *button;
+ GtkCheckMenuItem *column_item;
col = GTK_TREE_VIEW_COLUMN (iter->data);
sort_id = gtk_tree_view_column_get_sort_column_id (col);
@@ -161,17 +161,17 @@ gsm_tree_view_load_state (GsmTreeView *tree_view)
title = gtk_tree_view_column_get_title (col);
- button = gtk_tree_view_column_get_button (col);
+ button = GTK_BUTTON (gtk_tree_view_column_get_button (col));
g_signal_connect (button, "button-press-event",
G_CALLBACK (cb_column_header_clicked),
header_menu);
- column_item = gtk_check_menu_item_new_with_label (title);
+ column_item = GTK_CHECK_MENU_ITEM (gtk_check_menu_item_new_with_label (title));
g_object_bind_property (col, "visible",
column_item, "active",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
- gtk_menu_shell_append (GTK_MENU_SHELL (header_menu), column_item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (header_menu), GTK_WIDGET (column_item));
key = g_strdup_printf ("col-%d-width", sort_id);
gtk_tree_view_column_set_fixed_width (col, g_settings_get_int (priv->settings, key));
@@ -184,7 +184,7 @@ gsm_tree_view_load_state (GsmTreeView *tree_view)
g_list_free (columns);
- gtk_widget_show_all (header_menu);
+ gtk_widget_show_all (GTK_WIDGET (header_menu));
g_settings_get (priv->settings, "columns-order", "ai", &var_iter);
last = NULL;
@@ -272,7 +272,7 @@ gsm_tree_view_append_and_bind_column (GsmTreeView *tree_view, GtkTreeViewColumn
}
-GtkWidget *
+GsmTreeView *
gsm_tree_view_new (GSettings *settings, gboolean store_column_order)
{
GsmTreeView *self = g_object_new (GSM_TYPE_TREE_VIEW, NULL);
@@ -281,5 +281,5 @@ gsm_tree_view_new (GSettings *settings, gboolean store_column_order)
priv->settings = settings;
priv->store_column_order = store_column_order;
- return GTK_WIDGET (self);
+ return self;
}
diff --git a/src/treeview.h b/src/treeview.h
index 4ca9e5c..7223ab1 100644
--- a/src/treeview.h
+++ b/src/treeview.h
@@ -27,7 +27,7 @@ struct _GsmTreeViewClass
};
GType gsm_tree_view_get_type (void) G_GNUC_CONST;
-GtkWidget * gsm_tree_view_new (GSettings *settings,
+GsmTreeView * gsm_tree_view_new (GSettings *settings,
gboolean store_column_order);
void gsm_tree_view_save_state (GsmTreeView *tree_view);
void gsm_tree_view_load_state (GsmTreeView *tree_view);
diff --git a/src/util.cpp b/src/util.cpp
index 93e080c..5650930 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -111,19 +111,19 @@ procman::format_duration_for_display(unsigned centiseconds)
-GtkWidget*
+GtkLabel*
procman_make_label_for_mmaps_or_ofiles(const char *format,
const char *process_name,
unsigned pid)
{
- GtkWidget *label;
+ GtkLabel* label;
char *name, *title;
name = mnemonic_safe_process_name (process_name);
title = g_strdup_printf(format, name, pid);
- label = gtk_label_new_with_mnemonic (title);
- gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
- gtk_widget_set_halign (label, GTK_ALIGN_START);
+ label = GTK_LABEL (gtk_label_new_with_mnemonic (title));
+ gtk_widget_set_valign (GTK_WIDGET (label), GTK_ALIGN_CENTER);
+ gtk_widget_set_halign (GTK_WIDGET (label), GTK_ALIGN_START);
g_free (title);
g_free (name);
diff --git a/src/util.h b/src/util.h
index 5a5ac84..083f247 100644
--- a/src/util.h
+++ b/src/util.h
@@ -8,7 +8,7 @@
using std::string;
-GtkWidget*
+GtkLabel*
procman_make_label_for_mmaps_or_ofiles(const char *format,
const char *process_name,
unsigned pid);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]