summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gsm_color_button.c43
-rw-r--r--src/interface.cpp9
-rw-r--r--src/load-graph.cpp38
-rw-r--r--src/load-graph.h4
-rw-r--r--src/lsof.cpp1
-rw-r--r--src/openfiles.cpp2
-rw-r--r--src/procdialogs.cpp8
-rw-r--r--src/sysinfo.cpp16
8 files changed, 98 insertions, 23 deletions
diff --git a/src/gsm_color_button.c b/src/gsm_color_button.c
index 0d69889..34826f6 100644
--- a/src/gsm_color_button.c
+++ b/src/gsm_color_button.c
@@ -81,8 +81,13 @@ static void gsm_color_button_get_property (GObject * object, guint param_id,
GValue * value,
GParamSpec * pspec);
static void gsm_color_button_realize (GtkWidget * widget);
+#if GTK_CHECK_VERSION(3,0,0)
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width);
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height);
+#else
static void gsm_color_button_size_request (GtkWidget * widget,
GtkRequisition * requisition);
+#endif
static void gsm_color_button_size_allocate (GtkWidget * widget,
GtkAllocation * allocation);
static void gsm_color_button_unrealize (GtkWidget * widget);
@@ -171,7 +176,12 @@ gsm_color_button_class_init (GSMColorButtonClass * klass)
gobject_class->set_property = gsm_color_button_set_property;
gobject_class->finalize = gsm_color_button_finalize;
widget_class->state_changed = gsm_color_button_state_changed;
+#if GTK_CHECK_VERSION(3,0,0)
+ widget_class->get_preferred_width = gsm_color_button_get_preferred_width;
+ widget_class->get_preferred_height = gsm_color_button_get_preferred_height;
+#else
widget_class->size_request = gsm_color_button_size_request;
+#endif
widget_class->size_allocate = gsm_color_button_size_allocate;
widget_class->realize = gsm_color_button_realize;
widget_class->unrealize = gsm_color_button_unrealize;
@@ -440,8 +450,11 @@ render (GtkWidget * widget)
}
/* Handle exposure events for the color picker's drawing area */
-static gint
-expose_event (GtkWidget * widget, GdkEventExpose * event, gpointer data)
+#if GTK_CHECK_VERSION(3,0,0)
+static gboolean expose_event (GtkWidget * widget, cairo_t * cr, gpointer data)
+#else
+static gboolean expose_event (GtkWidget * widget, GdkEventExpose * event, gpointer data)
+#endif
{
render (GTK_WIDGET (data));
@@ -455,6 +468,24 @@ gsm_color_button_realize (GtkWidget * widget)
render (widget);
}
+#if GTK_CHECK_VERSION(3,0,0)
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width)
+{
+ g_return_if_fail (widget != NULL && minimum_width != NULL && natural_width != NULL);
+ g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+ *minimum_width = GSMCP_MIN_WIDTH;
+ *natural_width = GSMCP_MIN_WIDTH;
+}
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height)
+{
+ g_return_if_fail (widget != NULL && minimum_height != NULL && natural_height != NULL);
+ g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+ *minimum_height = GSMCP_MIN_HEIGHT;
+ *natural_height = GSMCP_MIN_HEIGHT;
+}
+#else
static void
gsm_color_button_size_request (GtkWidget * widget,
GtkRequisition * requisition)
@@ -465,6 +496,7 @@ gsm_color_button_size_request (GtkWidget * widget,
requisition->width = GSMCP_MIN_WIDTH;
requisition->height = GSMCP_MIN_HEIGHT;
}
+#endif
static void
gsm_color_button_size_allocate (GtkWidget * widget,
@@ -630,8 +662,11 @@ gsm_color_button_init (GSMColorButton * color_button)
gtk_widget_set_tooltip_text (GTK_WIDGET(color_button), _("Click to set graph colors"));
- g_signal_connect (color_button, "expose-event",
- G_CALLBACK (expose_event), color_button);
+#if GTK_CHECK_VERSION(3,0,0)
+ g_signal_connect (color_button, "draw", G_CALLBACK (expose_event), color_button);
+#else
+ g_signal_connect (color_button, "expose-event", G_CALLBACK (expose_event), color_button);
+#endif
}
static void
diff --git a/src/interface.cpp b/src/interface.cpp
index b12301b..ab201d5 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -618,12 +618,17 @@ create_main_window (ProcData *procdata)
app = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(app), _("System Monitor"));
+ /* use rgba colormap, if available */
GdkScreen* screen = gtk_widget_get_screen(app);
+#if GTK_CHECK_VERSION(3,0,0)
+ GdkVisual* visual = gdk_screen_get_rgba_visual(screen);
+ if (visual)
+ gtk_widget_set_visual(app, visual);
+#else
GdkColormap* colormap = gdk_screen_get_rgba_colormap(screen);
-
- /* use rgba colormap, if available */
if (colormap)
gtk_widget_set_default_colormap(colormap);
+#endif
main_box = gtk_vbox_new (FALSE, 0);
gtk_container_add(GTK_CONTAINER(app), main_box);
diff --git a/src/load-graph.cpp b/src/load-graph.cpp
index 3cf8683..752a4d4 100644
--- a/src/load-graph.cpp
+++ b/src/load-graph.cpp
@@ -32,7 +32,11 @@
void LoadGraph::clear_background()
{
if (this->background) {
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_surface_destroy (this->background);
+#else
g_object_unref(this->background);
+#endif
this->background = NULL;
}
}
@@ -66,7 +70,7 @@ unsigned LoadGraph::num_bars() const
#define FRAME_WIDTH 4
-void draw_background(LoadGraph *g) {
+static void draw_background(LoadGraph *g) {
GtkAllocation allocation;
double dash[2] = { 1.0, 2.0 };
cairo_t *cr;
@@ -82,11 +86,13 @@ void draw_background(LoadGraph *g) {
g->graph_buffer_offset = (int) (1.5 * g->graph_delx) + FRAME_WIDTH ;
gtk_widget_get_allocation (g->disp, &allocation);
- g->background = gdk_pixmap_new (GDK_DRAWABLE (gtk_widget_get_window (g->disp)),
- allocation.width,
- allocation.height,
- -1);
+#if GTK_CHECK_VERSION(3,0,0)
+ g->background = gdk_window_create_similar_surface (gtk_widget_get_window (g->disp), CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height);
+ cr = cairo_create (g->background);
+#else
+ g->background = gdk_pixmap_new (GDK_DRAWABLE (gtk_widget_get_window (g->disp)), allocation.width, allocation.height, -1);
cr = gdk_cairo_create (g->background);
+#endif
// set the background colour
GtkStyle *style = gtk_widget_get_style (ProcData::get_instance()->notebook);
@@ -196,10 +202,11 @@ load_graph_configure (GtkWidget *widget,
return TRUE;
}
-static gboolean
-load_graph_expose (GtkWidget *widget,
- GdkEventExpose *event,
- gpointer data_ptr)
+#if GTK_CHECK_VERSION(3,0,0)
+static gboolean load_graph_expose (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+#else
+static gboolean load_graph_expose (GtkWidget *widget, GdkEventExpose *event, gpointer data_ptr)
+#endif
{
LoadGraph * const g = static_cast<LoadGraph*>(data_ptr);
GtkAllocation allocation;
@@ -213,7 +220,13 @@ load_graph_expose (GtkWidget *widget,
if (g->background == NULL) {
draw_background(g);
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_pattern_t *pattern = cairo_pattern_create_for_surface (g->background);
+ gdk_window_set_background_pattern (window, pattern);
+ cairo_pattern_destroy (pattern);
+#else
gdk_window_set_back_pixmap (window, g->background, FALSE);
+#endif
}
/* Number of pixels wide for one graph point */
@@ -687,8 +700,11 @@ LoadGraph::LoadGraph(guint type)
g->disp = gtk_drawing_area_new ();
gtk_widget_show (g->disp);
- g_signal_connect (G_OBJECT (g->disp), "expose_event",
- G_CALLBACK (load_graph_expose), g);
+#if GTK_CHECK_VERSION(3,0,0)
+ g_signal_connect (G_OBJECT (g->disp), "draw", G_CALLBACK (load_graph_expose), g);
+#else
+ g_signal_connect (G_OBJECT (g->disp), "expose_event", G_CALLBACK (load_graph_expose), g);
+#endif
g_signal_connect (G_OBJECT(g->disp), "configure_event",
G_CALLBACK (load_graph_configure), g);
g_signal_connect (G_OBJECT(g->disp), "destroy",
diff --git a/src/load-graph.h b/src/load-graph.h
index 9dd28bb..a120b92 100644
--- a/src/load-graph.h
+++ b/src/load-graph.h
@@ -66,7 +66,11 @@ struct LoadGraph {
GtkWidget *main_widget;
GtkWidget *disp;
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_surface_t *background;
+#else
GdkDrawable *background;
+#endif
guint timer_index;
diff --git a/src/lsof.cpp b/src/lsof.cpp
index 7773eff..4be9405 100644
--- a/src/lsof.cpp
+++ b/src/lsof.cpp
@@ -1,6 +1,7 @@
#include <config.h>
#include <gtkmm/messagedialog.h>
+#include <glibmm/regex.h>
#include <glib/gi18n.h>
#include <glibtop/procopenfiles.h>
diff --git a/src/openfiles.cpp b/src/openfiles.cpp
index 7bce479..2047e21 100644
--- a/src/openfiles.cpp
+++ b/src/openfiles.cpp
@@ -336,7 +336,9 @@ create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
NULL);
gtk_window_set_resizable (GTK_WINDOW (openfilesdialog), TRUE);
gtk_window_set_default_size (GTK_WINDOW (openfilesdialog), 575, 400);
+#if !GTK_CHECK_VERSION(2,22,0)
g_object_set(G_OBJECT(openfilesdialog), "has-separator", FALSE, NULL);
+#endif
gtk_container_set_border_width (GTK_CONTAINER (openfilesdialog), 5);
vbox = gtk_dialog_get_content_area (GTK_DIALOG (openfilesdialog));
diff --git a/src/procdialogs.cpp b/src/procdialogs.cpp
index 8c395ab..1d4edbc 100644
--- a/src/procdialogs.cpp
+++ b/src/procdialogs.cpp
@@ -159,7 +159,11 @@ procdialog_create_renice_dialog (ProcData *procdata)
GtkWidget *label;
GtkWidget *priority_label;
GtkWidget *table;
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkAdjustment *renice_adj;
+#else
GtkObject *renice_adj;
+#endif
GtkWidget *hscale;
GtkWidget *button;
GtkWidget *align;
@@ -178,7 +182,9 @@ procdialog_create_renice_dialog (ProcData *procdata)
NULL);
renice_dialog = dialog;
gtk_window_set_resizable (GTK_WINDOW (renice_dialog), FALSE);
+#if !GTK_CHECK_VERSION(2,22,0)
g_object_set (G_OBJECT (renice_dialog), "has-separator", FALSE, NULL);
+#endif
gtk_container_set_border_width (GTK_CONTAINER (renice_dialog), 5);
button = gtk_button_new ();
@@ -503,7 +509,9 @@ procdialog_create_preferences_dialog (ProcData *procdata)
/* any function to set list height by contents/items inside it. */
gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 420);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+#if !GTK_CHECK_VERSION(2,22,0)
g_object_set (G_OBJECT (dialog), "has-separator", FALSE, NULL);
+#endif
prefs_dialog = dialog;
main_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
diff --git a/src/sysinfo.cpp b/src/sysinfo.cpp
index 9ddf31c..2cc163d 100644
--- a/src/sysinfo.cpp
+++ b/src/sysinfo.cpp
@@ -411,10 +411,11 @@ namespace {
#define LOGO_H 351
#define RADIUS 5
-static gboolean
-sysinfo_logo_expose (GtkWidget *widget,
- GdkEventExpose *event,
- gpointer data_ptr)
+#if GTK_CHECK_VERSION(3,0,0)
+static gboolean sysinfo_logo_expose (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+#else
+static gboolean sysinfo_logo_expose (GtkWidget *widget, GdkEventExpose *event, gpointer data_ptr)
+#endif
{
GtkAllocation allocation;
GtkStyle *style;
@@ -546,8 +547,11 @@ procman_create_sysinfo_view(void)
gtk_misc_set_padding(GTK_MISC(logo), 5, 12);
gtk_box_pack_start(GTK_BOX(hbox), logo, FALSE, FALSE, 0);
- g_signal_connect(G_OBJECT(logo), "expose-event",
- G_CALLBACK(sysinfo_logo_expose), NULL);
+#if GTK_CHECK_VERSION(3,0,0)
+ g_signal_connect(G_OBJECT(logo), "draw", G_CALLBACK(sysinfo_logo_expose), NULL);
+#else
+ g_signal_connect(G_OBJECT(logo), "expose-event", G_CALLBACK(sysinfo_logo_expose), NULL);
+#endif
vbox = gtk_vbox_new(FALSE, 12);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);