summaryrefslogtreecommitdiff
path: root/baobab
diff options
context:
space:
mode:
Diffstat (limited to 'baobab')
-rw-r--r--baobab/src/baobab-chart.c63
-rw-r--r--baobab/src/baobab-remote-connect-dialog.c2
-rw-r--r--baobab/src/baobab.c6
3 files changed, 63 insertions, 8 deletions
diff --git a/baobab/src/baobab-chart.c b/baobab/src/baobab-chart.c
index dce8bfb6..2aaedfe2 100644
--- a/baobab/src/baobab-chart.c
+++ b/baobab/src/baobab-chart.c
@@ -35,6 +35,11 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
+#if GTK_CHECK_VERSION (3, 0, 0)
+/* needed for floor and ceil */
+#include <math.h>
+#endif
+
#include "baobab-chart.h"
#define BAOBAB_CHART_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
@@ -144,7 +149,11 @@ static void baobab_chart_rows_reordered (GtkTreeModel *model,
gint *new_order,
gpointer data);
static gboolean baobab_chart_expose (GtkWidget *chart,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_t *cr);
+#else
GdkEventExpose *event);
+#endif
static void baobab_chart_interpolate_colors (BaobabChartColor *color,
BaobabChartColor colora,
BaobabChartColor colorb,
@@ -186,7 +195,11 @@ baobab_chart_class_init (BaobabChartClass *class)
/* GtkWidget signals */
widget_class->realize = baobab_chart_realize;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ widget_class->draw = baobab_chart_expose;
+#else
widget_class->expose_event = baobab_chart_expose;
+#endif
widget_class->size_allocate = baobab_chart_size_allocate;
widget_class->scroll_event = baobab_chart_scroll;
@@ -316,10 +329,16 @@ baobab_chart_realize (GtkWidget *widget)
attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
+#if !GTK_CHECK_VERSION (3, 0, 0)
attributes.colormap = gtk_widget_get_colormap (widget);
+#endif
attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
+#else
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+#endif
window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes,
@@ -753,9 +772,15 @@ baobab_chart_rows_reordered (GtkTreeModel *model,
}
static gboolean
+#if GTK_CHECK_VERSION (3, 0, 0)
+baobab_chart_expose (GtkWidget *chart, cairo_t *cr)
+#else
baobab_chart_expose (GtkWidget *chart, GdkEventExpose *event)
+#endif
{
+#if !GTK_CHECK_VERSION (3, 0, 0)
cairo_t *cr;
+#endif
BaobabChartPrivate *priv;
gint w, h;
gdouble p, sx, sy;
@@ -763,6 +788,16 @@ baobab_chart_expose (GtkWidget *chart, GdkEventExpose *event)
GtkTreePath *current_path = NULL;
GtkAllocation allocation;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRectangle area;
+ gdouble x1, y1, x2, y2;
+ cairo_clip_extents (cr, &x1, &y1, &x2, &y2);
+ area.x = floor (x1);
+ area.y = floor (y1);
+ area.width = ceil (x2) - area.x;
+ area.height = ceil (y2) - area.y;
+#endif
+
priv = BAOBAB_CHART (chart)->priv;
/* the columns are not set we paint nothing */
@@ -773,8 +808,13 @@ baobab_chart_expose (GtkWidget *chart, GdkEventExpose *event)
cr = gdk_cairo_create (gtk_widget_get_window (chart));
cairo_rectangle (cr,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ area.x, area.y,
+ area.width, area.height);
+#else
event->area.x, event->area.y,
event->area.width, event->area.height);
+#endif
/* there is no model we can not paint */
if ((priv->is_frozen) || (priv->model == NULL))
@@ -840,10 +880,16 @@ baobab_chart_expose (GtkWidget *chart, GdkEventExpose *event)
gtk_tree_path_free (root_path);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ baobab_chart_draw (chart, cr, area);
+#else
baobab_chart_draw (chart, cr, event->area);
+#endif
}
+#if !GTK_CHECK_VERSION (3, 0, 0)
cairo_destroy (cr);
+#endif
return FALSE;
}
@@ -1178,10 +1224,17 @@ baobab_chart_get_pixbuf (GtkWidget *widget)
gdk_drawable_get_size(gtk_widget_get_window(widget), &w, &h);
#endif
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+ pixbuf = gdk_pixbuf_get_from_window (
+#else
pixbuf = gdk_pixbuf_get_from_drawable (NULL,
+#endif
gtk_widget_get_window (widget),
+#if !GTK_CHECK_VERSION(3, 0, 0)
gdk_colormap_get_system (),
0, 0,
+#endif
0, 0,
w, h);
@@ -1751,10 +1804,10 @@ baobab_chart_save_snapshot (GtkWidget *chart)
label,
FALSE, FALSE, 0);
- opt_menu = gtk_combo_box_new_text ();
- gtk_combo_box_append_text (GTK_COMBO_BOX (opt_menu), "png");
- gtk_combo_box_append_text (GTK_COMBO_BOX (opt_menu), "jpeg");
- gtk_combo_box_append_text (GTK_COMBO_BOX (opt_menu), "bmp");
+ opt_menu = gtk_combo_box_text_new ();
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (opt_menu), "png");
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (opt_menu), "jpeg");
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (opt_menu), "bmp");
gtk_combo_box_set_active (GTK_COMBO_BOX (opt_menu), 0);
gtk_box_pack_start (GTK_BOX (hbox), opt_menu, TRUE, TRUE, 0);
@@ -1764,7 +1817,7 @@ baobab_chart_save_snapshot (GtkWidget *chart)
if (gtk_dialog_run (GTK_DIALOG (fs_dlg)) == GTK_RESPONSE_ACCEPT)
{
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fs_dlg));
- sel_type = gtk_combo_box_get_active_text (GTK_COMBO_BOX (opt_menu));
+ sel_type = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (opt_menu));
if (! g_str_has_suffix (filename, sel_type))
{
gchar *tmp;
diff --git a/baobab/src/baobab-remote-connect-dialog.c b/baobab/src/baobab-remote-connect-dialog.c
index 2068936c..50faa2d7 100644
--- a/baobab/src/baobab-remote-connect-dialog.c
+++ b/baobab/src/baobab-remote-connect-dialog.c
@@ -641,7 +641,9 @@ baobab_remote_connect_dialog_init (BaobabRemoteConnectDialog *dialog)
dialog->details = g_new0 (BaobabRemoteConnectDialogDetails, 1);
gtk_window_set_title (GTK_WINDOW (dialog), _("Connect to Server"));
+#if !GTK_CHECK_VERSION (3, 0, 0)
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+#endif
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
diff --git a/baobab/src/baobab.c b/baobab/src/baobab.c
index 58e7c3c3..253355ce 100644
--- a/baobab/src/baobab.c
+++ b/baobab/src/baobab.c
@@ -1137,10 +1137,10 @@ initialize_charts (void)
baobab.chart_frame, TRUE, TRUE);
gtk_paned_set_position (GTK_PANED (hpaned_main), 480);
- baobab.chart_type_combo = gtk_combo_box_new_text ();
- gtk_combo_box_append_text (GTK_COMBO_BOX (baobab.chart_type_combo),
+ baobab.chart_type_combo = gtk_combo_box_text_new ();
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (baobab.chart_type_combo),
_("View as Rings Chart"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (baobab.chart_type_combo),
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (baobab.chart_type_combo),
_("View as Treemap Chart"));
gtk_widget_show (baobab.chart_type_combo);
g_signal_connect (baobab.chart_type_combo,