summaryrefslogtreecommitdiff
path: root/multiload
diff options
context:
space:
mode:
Diffstat (limited to 'multiload')
-rw-r--r--multiload/global.h7
-rw-r--r--multiload/load-graph.c49
-rw-r--r--multiload/main.c19
-rw-r--r--multiload/properties.c85
4 files changed, 22 insertions, 138 deletions
diff --git a/multiload/global.h b/multiload/global.h
index 8971df2c..f3ef24f3 100644
--- a/multiload/global.h
+++ b/multiload/global.h
@@ -30,18 +30,11 @@ struct _LoadGraph {
guint allocated;
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkRGBA *colors;
-#else
- GdkColor *colors;
-#endif
gint **data;
guint data_size;
guint *pos;
-#if !GTK_CHECK_VERSION (3, 0, 0)
- gint colors_allocated;
-#endif
GtkWidget *main_widget;
GtkWidget *frame, *box, *disp;
cairo_surface_t *surface;
diff --git a/multiload/load-graph.c b/multiload/load-graph.c
index c0403e85..a98a81ab 100644
--- a/multiload/load-graph.c
+++ b/multiload/load-graph.c
@@ -15,10 +15,6 @@
#include "global.h"
-#if GTK_CHECK_VERSION (3, 0, 0)
-#define gtk_vbox_new(X,Y) gtk_box_new(GTK_ORIENTATION_VERTICAL,Y)
-#endif
-
/*
Shifts data right
@@ -73,11 +69,7 @@ load_graph_draw (LoadGraph *g)
for (j = 0; j < g->n; j++)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
gdk_cairo_set_source_rgba (cr, &(g->colors [j]));
-#else
- gdk_cairo_set_source_color (cr, &(g->colors [j]));
-#endif
for (i = 0; i < g->draw_width; i++) {
if (g->data [i][j] != 0) {
@@ -192,29 +184,14 @@ load_graph_configure (GtkWidget *widget, GdkEventConfigure *event,
static gint
load_graph_expose (GtkWidget *widget,
-#if GTK_CHECK_VERSION (3, 0, 0)
cairo_t *cr,
-#else
- GdkEventExpose *event,
-#endif
gpointer data_ptr)
{
LoadGraph *g = (LoadGraph *) data_ptr;
-#if !GTK_CHECK_VERSION (3, 0, 0)
- cairo_t *cr;
- cr = gdk_cairo_create (event->window);
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
-#endif
-
cairo_set_source_surface (cr, g->surface, 0, 0);
cairo_paint (cr);
-#if !GTK_CHECK_VERSION (3, 0, 0)
- cairo_destroy (cr);
-#endif
-
return FALSE;
}
@@ -264,39 +241,21 @@ load_graph_leave_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
static void
load_graph_load_config (LoadGraph *g)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
gchar *name, *temp;
-#else
- gchar name [BUFSIZ], *temp;
-#endif
guint i;
if (!g->colors)
-#if GTK_CHECK_VERSION (3, 0, 0)
g->colors = g_new0(GdkRGBA, g->n);
-#else
- g->colors = g_new0(GdkColor, g->n);
-#endif
for (i = 0; i < g->n; i++)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
name = g_strdup_printf ("%s-color%u", g->name, i);
-#else
- g_snprintf(name, sizeof(name), "%s-color%u", g->name, i);
-#endif
temp = g_settings_get_string(g->multiload->settings, name);
if (!temp)
temp = g_strdup ("#000000");
-#if GTK_CHECK_VERSION (3, 0, 0)
gdk_rgba_parse(&(g->colors[i]), temp);
-#else
- gdk_color_parse(temp, &(g->colors[i]));
-#endif
g_free(temp);
-#if GTK_CHECK_VERSION (3, 0, 0)
g_free(name);
-#endif
}
}
@@ -322,9 +281,9 @@ load_graph_new (MultiloadApplet *ma, guint n, const gchar *label,
g->show_frame = TRUE;
g->multiload = ma;
- g->main_widget = gtk_vbox_new (FALSE, 0);
+ g->main_widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- g->box = gtk_vbox_new (FALSE, 0);
+ g->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
orient = mate_panel_applet_get_orient (g->multiload->applet);
switch (orient)
@@ -375,11 +334,7 @@ load_graph_new (MultiloadApplet *ma, guint n, const gchar *label,
GDK_LEAVE_NOTIFY_MASK |
GDK_BUTTON_PRESS_MASK);
-#if GTK_CHECK_VERSION (3, 0, 0)
g_signal_connect (G_OBJECT (g->disp), "draw",
-#else
- g_signal_connect (G_OBJECT (g->disp), "expose_event",
-#endif
G_CALLBACK (load_graph_expose), g);
g_signal_connect (G_OBJECT(g->disp), "configure_event",
G_CALLBACK (load_graph_configure), g);
diff --git a/multiload/main.c b/multiload/main.c
index 9915bed1..e26cd596 100644
--- a/multiload/main.c
+++ b/multiload/main.c
@@ -27,11 +27,6 @@
#include <mate-panel-applet.h>
#include <mate-panel-applet-gsettings.h>
-#if GTK_CHECK_VERSION (3, 0, 0)
-#define gtk_vbox_new(X,Y) gtk_box_new(GTK_ORIENTATION_VERTICAL,Y)
-#define gtk_hbox_new(X,Y) gtk_box_new(GTK_ORIENTATION_HORIZONTAL,Y)
-#endif
-
#include "global.h"
static void
@@ -101,9 +96,7 @@ start_procman (MultiloadApplet *ma)
GDesktopAppInfo *appinfo;
gchar *monitor;
GdkAppLaunchContext *launch_context;
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkDisplay *display;
-#endif
GAppInfo *app_info;
GdkScreen *screen;
@@ -119,12 +112,8 @@ start_procman (MultiloadApplet *ma)
GdkScreen *screen;
GdkAppLaunchContext *context;
screen = gtk_widget_get_screen (GTK_WIDGET (ma->applet));
-#if GTK_CHECK_VERSION (3, 0, 0)
display = gdk_screen_get_display (screen);
context = gdk_display_get_app_launch_context (display);
-#else
- context = gdk_app_launch_context_new ();
-#endif
gdk_app_launch_context_set_screen (context, screen);
g_app_info_launch (G_APP_INFO (appinfo), NULL, G_APP_LAUNCH_CONTEXT (context), &error);
g_object_unref (context);
@@ -137,12 +126,8 @@ start_procman (MultiloadApplet *ma)
&error);
if (!error) {
-#if GTK_CHECK_VERSION (3, 0, 0)
display = gdk_screen_get_display (screen);
launch_context = gdk_display_get_app_launch_context (display);
-#else
- launch_context = gdk_app_launch_context_new ();
-#endif
gdk_app_launch_context_set_screen (launch_context, screen);
g_app_info_launch (app_info, NULL, G_APP_LAUNCH_CONTEXT (launch_context), &error);
@@ -440,10 +425,10 @@ multiload_applet_refresh(MultiloadApplet *ma)
if ( (orientation == MATE_PANEL_APPLET_ORIENT_UP) ||
(orientation == MATE_PANEL_APPLET_ORIENT_DOWN) ) {
- ma->box = gtk_hbox_new(FALSE, 0);
+ ma->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
}
else
- ma->box = gtk_vbox_new(FALSE, 0);
+ ma->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add(GTK_CONTAINER(ma->applet), ma->box);
diff --git a/multiload/properties.c b/multiload/properties.c
index b00635d8..47fb235e 100644
--- a/multiload/properties.c
+++ b/multiload/properties.c
@@ -33,11 +33,6 @@
#define HIG_IDENTATION " "
#define NEVER_SENSITIVE "never_sensitive"
-#if GTK_CHECK_VERSION (3, 0, 0)
-#define gtk_vbox_new(X,Y) gtk_box_new(GTK_ORIENTATION_VERTICAL,Y)
-#define gtk_hbox_new(X,Y) gtk_box_new(GTK_ORIENTATION_HORIZONTAL,Y)
-#endif
-
/* set sensitive and setup NEVER_SENSITIVE appropriately */
static void
hard_set_sensitive (GtkWidget *w, gboolean sensitivity)
@@ -203,10 +198,8 @@ add_page(GtkWidget *notebook, gchar *label)
GtkWidget *page;
GtkWidget *page_label;
- page = gtk_hbox_new(TRUE, 0);
-#if GTK_CHECK_VERSION (3, 0, 0)
+ page = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous (GTK_BOX (page), TRUE);
-#endif
page_label = gtk_label_new(label);
gtk_container_set_border_width(GTK_CONTAINER(page), 6);
@@ -217,21 +210,11 @@ add_page(GtkWidget *notebook, gchar *label)
/* save the selected color to gsettings and apply it on the applet */
static void
-#if GTK_CHECK_VERSION (3, 0, 0)
color_picker_set_cb(GtkColorChooser *color_picker, gchar *key)
-#else
-color_picker_set_cb(GtkColorButton *color_picker, gchar *key)
-#endif
{
-#if GTK_CHECK_VERSION (3, 0, 0)
gchar *color_string;
guint8 prop_type;
GdkRGBA color;
-#else
- gchar color_string[8];
- guint8 prop_type;
- GdkColor color;
-#endif
MultiloadApplet *ma;
ma = g_object_get_data (G_OBJECT (color_picker), "MultiloadApplet");
@@ -251,7 +234,6 @@ color_picker_set_cb(GtkColorButton *color_picker, gchar *key)
else
g_assert_not_reached();
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_color_chooser_get_rgba(color_picker, &color);
color_string = gdk_rgba_to_string (&color);
@@ -259,21 +241,7 @@ color_picker_set_cb(GtkColorButton *color_picker, gchar *key)
gdk_rgba_parse(&(ma->graphs[prop_type]->colors[g_ascii_digit_value(key[strlen(key) - 1]) ]),
color_string);
-#else
- gtk_color_button_get_color(color_picker, &color);
-
- snprintf(color_string, 8, "#%02X%02X%02X",
- color.red / 256, color.green / 256, color.blue / 256);
- g_settings_set_string(ma->settings, key, color_string);
- gdk_color_parse(color_string,
- &(ma->graphs[prop_type]->colors[g_ascii_digit_value(key[strlen(key) - 1]) ]) );
-#endif
-
-#if !GTK_CHECK_VERSION (3, 0, 0)
- ma->graphs[prop_type]->colors_allocated = FALSE;
-#endif
-
return;
}
@@ -284,29 +252,16 @@ add_color_selector(GtkWidget *page, gchar *name, gchar *key, MultiloadApplet *ma
GtkWidget *vbox;
GtkWidget *label;
GtkWidget *color_picker;
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkRGBA color;
-#else
- GdkColor color;
-#endif
gchar *color_string;
color_string = g_settings_get_string (ma->settings, key);
if (!color_string)
color_string = g_strdup ("#000000");
-#if GTK_CHECK_VERSION (3, 0, 0)
gdk_rgba_parse (&color, color_string);
-#else
- color.red = (g_ascii_xdigit_value(color_string[1]) * 16
- + g_ascii_xdigit_value(color_string[2])) * 256;
- color.green = (g_ascii_xdigit_value(color_string[3]) * 16
- + g_ascii_xdigit_value(color_string[4])) * 256;
- color.blue = (g_ascii_xdigit_value(color_string[5]) * 16
- + g_ascii_xdigit_value(color_string[6])) * 256;
-#endif
g_free (color_string);
- vbox = gtk_vbox_new (FALSE, 6);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
label = gtk_label_new_with_mnemonic(name);
color_picker = gtk_color_button_new();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), color_picker);
@@ -318,11 +273,7 @@ add_color_selector(GtkWidget *page, gchar *name, gchar *key, MultiloadApplet *ma
g_object_set_data (G_OBJECT (color_picker), "MultiloadApplet", ma);
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(color_picker), &color);
-#else
- gtk_color_button_set_color(GTK_COLOR_BUTTON(color_picker), &color);
-#endif
g_signal_connect(G_OBJECT(color_picker), "color_set", G_CALLBACK(color_picker_set_cb), key);
@@ -352,18 +303,18 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
gchar *label_text;
gchar *title;
- vbox = gtk_vbox_new (FALSE, 0);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
gtk_widget_show (vbox);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), vbox,
TRUE, TRUE, 0);
- categories_vbox = gtk_vbox_new (FALSE, 18);
+ categories_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
gtk_box_pack_start (GTK_BOX (vbox), categories_vbox, TRUE, TRUE, 0);
gtk_widget_show (categories_vbox);
- category_vbox = gtk_vbox_new (FALSE, 6);
+ category_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (categories_vbox), category_vbox, TRUE, TRUE, 0);
gtk_widget_show (category_vbox);
@@ -379,7 +330,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
gtk_box_pack_start (GTK_BOX (category_vbox), label, FALSE, FALSE, 0);
g_free (title);
- hbox = gtk_hbox_new (FALSE, 0);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start (GTK_BOX (category_vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox);
@@ -388,11 +339,11 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
gtk_box_pack_start (GTK_BOX (hbox), indent, FALSE, FALSE, 0);
gtk_widget_show (indent);
- control_vbox = gtk_vbox_new (FALSE, 6);
+ control_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (hbox), control_vbox, TRUE, TRUE, 0);
gtk_widget_show (control_vbox);
- control_hbox = gtk_hbox_new (FALSE, 12);
+ control_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_box_pack_start (GTK_BOX (control_vbox), control_hbox, TRUE, TRUE, 0);
gtk_widget_show (control_hbox);
@@ -472,7 +423,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
G_CALLBACK (property_toggled_cb), "view-diskload");
gtk_box_pack_start (GTK_BOX (control_hbox), check_box, FALSE, FALSE, 0);
- category_vbox = gtk_vbox_new (FALSE, 6);
+ category_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (categories_vbox), category_vbox, TRUE, TRUE, 0);
gtk_widget_show (category_vbox);
@@ -489,7 +440,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
gtk_widget_show (label);
g_free (title);
- hbox = gtk_hbox_new (FALSE, 0);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start (GTK_BOX (category_vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox);
@@ -498,11 +449,11 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
gtk_box_pack_start (GTK_BOX (hbox), indent, FALSE, FALSE, 0);
gtk_widget_show (indent);
- control_vbox = gtk_vbox_new (FALSE, 6);
+ control_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (hbox), control_vbox, TRUE, TRUE, 0);
gtk_widget_show (control_vbox);
- control_hbox = gtk_hbox_new (FALSE, 12);
+ control_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_box_pack_start (GTK_BOX (control_vbox), control_hbox, TRUE, TRUE, 0);
gtk_widget_show (control_hbox);
@@ -523,7 +474,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
gtk_size_group_add_widget (label_size, label);
gtk_box_pack_start (GTK_BOX (control_hbox), label, FALSE, FALSE, 0);
- hbox = gtk_hbox_new (FALSE, 6);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start (GTK_BOX (control_hbox), hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox);
@@ -555,7 +506,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
#endif
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- control_hbox = gtk_hbox_new (FALSE, 12);
+ control_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_box_pack_start (GTK_BOX (control_vbox), control_hbox, TRUE, TRUE, 0);
gtk_widget_show (control_hbox);
@@ -568,7 +519,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
gtk_size_group_add_widget (label_size, label);
gtk_box_pack_start (GTK_BOX (control_hbox), label, FALSE, FALSE, 0);
- hbox = gtk_hbox_new (FALSE, 6);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start (GTK_BOX (control_hbox), hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox);
@@ -600,7 +551,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
g_free(label_text);
- category_vbox = gtk_vbox_new (FALSE, 6);
+ category_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (categories_vbox), category_vbox, TRUE, TRUE, 0);
gtk_widget_show (category_vbox);
@@ -617,7 +568,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
gtk_widget_show (label);
g_free (title);
- hbox = gtk_hbox_new (FALSE, 0);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start (GTK_BOX (category_vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox);
@@ -626,7 +577,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
gtk_box_pack_start (GTK_BOX (hbox), indent, FALSE, FALSE, 0);
gtk_widget_show (indent);
- control_vbox = gtk_vbox_new (FALSE, 6);
+ control_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (hbox), control_vbox, TRUE, TRUE, 0);
gtk_widget_show (control_vbox);