summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.sources2
-rw-r--r--gtk/gtk_compat.c76
-rw-r--r--gtk/gtk_compat.h35
-rw-r--r--gtk/gtk_download.c3
-rw-r--r--gtk/gtk_scaffolding.c3
-rw-r--r--gtk/sexy_icon_entry.c15
6 files changed, 124 insertions, 10 deletions
diff --git a/Makefile.sources b/Makefile.sources
index 8612e1255..c62af6312 100644
--- a/Makefile.sources
+++ b/Makefile.sources
@@ -61,7 +61,7 @@ S_GTK := font_pango.c gtk_bitmap.c gtk_gui.c gtk_schedule.c \
gtk_completion.c gtk_login.c gtk_throbber.c gtk_selection.c \
gtk_history.c gtk_window.c gtk_filetype.c gtk_download.c \
gtk_menu.c gtk_print.c gtk_save.c gtk_search.c gtk_tabs.c \
- gtk_theme.c gtk_toolbar.c sexy_icon_entry.c \
+ gtk_theme.c gtk_toolbar.c sexy_icon_entry.c gtk_compat.c \
$(addprefix dialogs/,gtk_options.c gtk_about.c gtk_source.c)
S_GTK := $(addprefix gtk/,$(S_GTK)) $(addprefix utils/,container.c)
# code in utils/container.ch is non-universal it seems
diff --git a/gtk/gtk_compat.c b/gtk/gtk_compat.c
new file mode 100644
index 000000000..511515a8b
--- /dev/null
+++ b/gtk/gtk_compat.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2010 Rob Kendrick <rjek@netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * Compatibility functions for older GTK versions (implementation)
+ */
+
+#include "gtk/gtk_compat.h"
+
+gboolean nsgtk_widget_has_focus(GtkWidget *widget)
+{
+ GValue v;
+ g_object_get_property(G_OBJECT(widget), "is-focus", &v);
+
+ return g_value_get_boolean(&v);
+}
+
+gboolean nsgtk_widget_get_visible(GtkWidget *widget)
+{
+ GValue v;
+ g_object_get_property(G_OBJECT(widget), "visible", &v);
+
+ return g_value_get_boolean(&v);
+}
+
+gboolean nsgtk_widget_get_realized(GtkWidget *widget)
+{
+ #if GTK_CHECK_VERSION(2,20,0)
+ return gtk_widget_get_realized(widget);
+ #else
+ return GTK_WIDGET_REALIZED(widget);
+ #endif
+}
+
+gboolean nsgtk_widget_get_mapped(GtkWidget *widget)
+{
+ #if GTK_CHECK_VERSION(2,20,0)
+ return gtk_widget_get_mapped(widget);
+ #else
+ return GTK_WIDGET_MAPPED(widget);
+ #endif
+}
+
+gboolean nsgtk_widget_is_drawable(GtkWidget *widget)
+{
+ #if GTK_CHECK_VERSION(2,18,0)
+ return gtk_widget_is_drawable(widget);
+ #else
+ return GTK_WIDGET_DRAWABLE(widget);
+ #endif
+}
+
+GtkStateType nsgtk_widget_get_state(GtkWidget *widget)
+{
+ #if GTK_CHECK_VERSION(2,18,0)
+ return gtk_widget_get_state(widget);
+ #else
+ return GTK_WIDGET_STATE(widget);
+ #endif
+}
+
diff --git a/gtk/gtk_compat.h b/gtk/gtk_compat.h
new file mode 100644
index 000000000..367d3c522
--- /dev/null
+++ b/gtk/gtk_compat.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2010 Rob Kendrick <rjek@netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * Compatibility functions for older GTK versions (interface)
+ */
+
+#ifndef NETSURF_GTK_COMPAT_H_
+#define NETSURF_GTK_COMPAT_H_
+
+#include <gtk/gtk.h>
+
+gboolean nsgtk_widget_has_focus(GtkWidget *widget);
+gboolean nsgtk_widget_get_visible(GtkWidget *widget);
+gboolean nsgtk_widget_get_realized(GtkWidget *widget);
+gboolean nsgtk_widget_get_mapped(GtkWidget *widget);
+gboolean nsgtk_widget_is_drawable(GtkWidget *widget);
+GtkStateType nsgtk_widget_get_state(GtkWidget *widget);
+
+#endif /* NETSURF_GTK_COMPAT_H */
diff --git a/gtk/gtk_download.c b/gtk/gtk_download.c
index 64da611ad..6b4e326bf 100644
--- a/gtk/gtk_download.c
+++ b/gtk/gtk_download.c
@@ -33,6 +33,7 @@
#include "gtk/options.h"
#include "gtk/gtk_download.h"
#include "gtk/gtk_window.h"
+#include "gtk/gtk_compat.h"
#define UPDATE_RATE 500 /* In milliseconds */
#define GLADE_NAME "downloads.glade"
@@ -438,7 +439,7 @@ void nsgtk_download_do(nsgtk_download_selection_action action)
gboolean nsgtk_download_update(gboolean force_update)
{
/* Be sure we need to update */
- if (!GTK_WIDGET_VISIBLE(nsgtk_download_window))
+ if (!nsgtk_widget_get_visible(GTK_WIDGET(nsgtk_download_window)))
return TRUE;
GList *list;
diff --git a/gtk/gtk_scaffolding.c b/gtk/gtk_scaffolding.c
index 0fd49bd61..358fb7206 100644
--- a/gtk/gtk_scaffolding.c
+++ b/gtk/gtk_scaffolding.c
@@ -69,6 +69,7 @@
#include "gtk/gtk_window.h"
#include "gtk/options.h"
#include "gtk/sexy_icon_entry.h"
+#include "gtk/gtk_compat.h"
#include "image/ico.h"
#include "render/box.h"
#include "render/font.h"
@@ -862,7 +863,7 @@ MULTIHANDLER(selectall)
{
struct browser_window *bw = gui_window_get_browser_window(g->top_level);
- if (GTK_WIDGET_HAS_FOCUS(g->url_bar)) {
+ if (nsgtk_widget_has_focus(GTK_WIDGET(g->url_bar))) {
LOG(("Selecting all URL bar text"));
gtk_editable_select_region(GTK_EDITABLE(g->url_bar), 0, -1);
} else {
diff --git a/gtk/sexy_icon_entry.c b/gtk/sexy_icon_entry.c
index 1dce22e31..adf4abc2c 100644
--- a/gtk/sexy_icon_entry.c
+++ b/gtk/sexy_icon_entry.c
@@ -26,6 +26,7 @@
#include "gtk/sexy_icon_entry.h"
#include <string.h>
#include <gtk/gtk.h>
+#include "gtk/gtk_compat.h"
#define ICON_MARGIN 2
#define MAX_ICONS 2
@@ -209,7 +210,7 @@ sexy_icon_entry_destroy(GtkObject *obj)
static void
sexy_icon_entry_map(GtkWidget *widget)
{
- if (GTK_WIDGET_REALIZED(widget) && !GTK_WIDGET_MAPPED(widget))
+ if (nsgtk_widget_get_realized(widget) && !nsgtk_widget_get_mapped(widget))
{
SexyIconEntry *entry = SEXY_ICON_ENTRY(widget);
int i;
@@ -227,7 +228,7 @@ sexy_icon_entry_map(GtkWidget *widget)
static void
sexy_icon_entry_unmap(GtkWidget *widget)
{
- if (GTK_WIDGET_MAPPED(widget))
+ if (nsgtk_widget_get_mapped(widget))
{
SexyIconEntry *entry = SEXY_ICON_ENTRY(widget);
int i;
@@ -374,7 +375,7 @@ sexy_icon_entry_realize(GtkWidget *widget)
gdk_window_set_user_data(icon_info->window, widget);
gdk_window_set_background(icon_info->window,
- &widget->style->base[GTK_WIDGET_STATE(widget)]);
+ &widget->style->base[nsgtk_widget_get_state(widget)]);
}
gtk_widget_queue_resize(widget);
@@ -471,7 +472,7 @@ sexy_icon_entry_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
GTK_WIDGET_CLASS(parent_class)->size_allocate(widget, allocation);
- if (GTK_WIDGET_REALIZED(widget))
+ if (nsgtk_widget_get_realized(widget))
place_windows(SEXY_ICON_ENTRY(widget), allocation);
}
@@ -558,7 +559,7 @@ draw_icon(GtkWidget *widget, SexyIconEntryPosition icon_pos)
GdkPixbuf *pixbuf;
gint x, y, width, height;
- if (icon_info->icon == NULL || !GTK_WIDGET_REALIZED(widget))
+ if (icon_info->icon == NULL || !nsgtk_widget_get_realized(widget))
return;
if ((pixbuf = get_pixbuf_from_icon(entry, icon_pos)) == NULL)
@@ -622,7 +623,7 @@ sexy_icon_entry_expose(GtkWidget *widget, GdkEventExpose *event)
entry = SEXY_ICON_ENTRY(widget);
- if (GTK_WIDGET_DRAWABLE(widget))
+ if (nsgtk_widget_is_drawable(widget))
{
gboolean found = FALSE;
int i;
@@ -640,7 +641,7 @@ sexy_icon_entry_expose(GtkWidget *widget, GdkEventExpose *event)
gdk_drawable_get_size(icon_info->window, &width, NULL);
gtk_paint_flat_box(widget->style, icon_info->window,
- GTK_WIDGET_STATE(widget), GTK_SHADOW_NONE,
+ nsgtk_widget_get_state(widget), GTK_SHADOW_NONE,
NULL, widget, "entry_bg",
0, 0, width, text_area_alloc.height);