File libfm-0.1.16-fix_build_older_gtk.patch of Package libfm

From 79285e8837cd1815ff62e4c9138d6464a091cf41 Mon Sep 17 00:00:00 2001
From: Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
Date: Thu, 11 Aug 2011 14:41:18 +0800
Subject: [PATCH] Add some compatibility headers and files used with min-lib-ver.py for future gtk3 migration.

---
 checks/README              |    6 ++++++
 checks/skip_files          |    8 ++++++++
 checks/skip_symbols        |    1 +
 src/Makefile.am            |   16 ++++++++++++++++
 src/glib-compat.c          |   22 ++++++++++++++++++++++
 src/glib-compat.h          |   30 ++++++++++++++++++++++++++++++
 src/gtk-compat.c           |   22 ++++++++++++++++++++++
 src/gtk-compat.h           |   41 +++++++++++++++++++++++++++++++++++++++++
 src/gtk/fm-dir-tree-view.c |    1 +
 src/gtk/fm-file-menu.c     |    7 ++++---
 10 files changed, 151 insertions(+), 3 deletions(-)
 create mode 100644 checks/README
 create mode 100644 checks/skip_files
 create mode 100644 checks/skip_symbols
 create mode 100644 src/glib-compat.c
 create mode 100644 src/glib-compat.h
 create mode 100644 src/gtk-compat.c
 create mode 100644 src/gtk-compat.h

diff --git a/checks/README b/checks/README
new file mode 100644
index 0000000..b6a2eaf
--- /dev/null
+++ b/checks/README
@@ -0,0 +1,6 @@
+This directory contains files or tools used to check the source code.
+The files inside this directory should not be included in any distributed tarballs.
+
+Files skip_files and skip_symbols are used with min-lib-ver.py in lxde/devtools.
+It's a tool used to check minimal required gtk+ version.
+Usage: min-lib-ver.py -F skip_files -S skip_symbols ../src
diff --git a/checks/skip_files b/checks/skip_files
new file mode 100644
index 0000000..9081ab3
--- /dev/null
+++ b/checks/skip_files
@@ -0,0 +1,8 @@
+base/fm-marshal.c
+base/fm-marshal.h
+gtk/fm-gtk-marshal.c
+gtk/fm-gtk-marshal.h
+gtk-compat.h
+gtk-compat.c
+glib-compat.h
+glib-compat.c
diff --git a/checks/skip_symbols b/checks/skip_symbols
new file mode 100644
index 0000000..960525e
--- /dev/null
+++ b/checks/skip_symbols
@@ -0,0 +1 @@
+gdk_display_get_app_launch_context
diff --git a/src/Makefile.am b/src/Makefile.am
index 5c35443..f95628e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -18,6 +18,17 @@ AM_CPPFLAGS = \
 	-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
 	$(NULL)
 
+glib_compat_SOURCES= \
+	glib-compat.c \
+	glib-compat.h \
+	$(NULL)
+
+gtk_compat_SOURCES= \
+	$(glib_compat_SOURCES) \
+	gtk-compat.c \
+	gtk-compat.h \
+	$(NULL)
+
 if ENABLE_UDISKS
 udisks_SOURCES= \
 	udisks/fm-udisks.c \
@@ -72,6 +83,7 @@ job_SOURCES = \
 
 libfm_SOURCES = \
 	fm.c \
+	$(glib_compat_SOURCES) \
 	$(base_SOURCES) \
 	$(job_SOURCES) \
 	$(udisks_SOURCES) \
@@ -92,6 +104,7 @@ exo_SOURCES = \
 
 libfm_gtk_SOURCES = \
 	fm-gtk.c \
+	$(gtk_compat_SOURCES) \
 	$(exo_SOURCES) \
 	gtk/fm-folder-view.c \
 	gtk/fm-folder-model.c \
@@ -247,6 +260,7 @@ libfm_gtk_la_LDFLAGS = \
 bin_PROGRAMS = libfm-pref-apps
 
 libfm_pref_apps_SOURCES = \
+	$(gtk_compat_SOURCES) \
 	tools/libfm-pref-apps.c \
 	$(NULL)
 
@@ -269,6 +283,7 @@ libfm_pref_apps_LDADD = \
 if ENABLE_DEMO
 bin_PROGRAMS += libfm-demo
 libfm_demo_SOURCES = \
+	$(gtk_compat_SOURCES) \
 	demo/libfm-demo.c \
 	demo/main-win.c demo/main-win.h \
 	$(NULL)
@@ -297,6 +312,7 @@ if !HAVE_SCHEME_HANDLER
 giomodules_LTLIBRARIES = libgiofm.la
 
 libgiofm_la_SOURCES= \
+	$(glib_compat_SOURCES) \
 	gio/module.c \
 	gio/fm-app-lookup.c \
 	gio/fm-app-lookup.h \
diff --git a/src/glib-compat.c b/src/glib-compat.c
new file mode 100644
index 0000000..7f3f6d1
--- /dev/null
+++ b/src/glib-compat.c
@@ -0,0 +1,22 @@
+/*
+ *      glib-compat.c
+ *
+ *      Copyright 2011 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
+ *
+ *      This program 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; either version 2 of the License, or
+ *      (at your option) any later version.
+ *
+ *      This program 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, write to the Free Software
+ *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ *      MA 02110-1301, USA.
+ */
+
+#include "glib-compat.h"
diff --git a/src/glib-compat.h b/src/glib-compat.h
new file mode 100644
index 0000000..40ce3bf
--- /dev/null
+++ b/src/glib-compat.h
@@ -0,0 +1,30 @@
+/*
+ *      glib-compat.h
+ *
+ *      Copyright 2011 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
+ *
+ *      This program 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; either version 2 of the License, or
+ *      (at your option) any later version.
+ *
+ *      This program 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, write to the Free Software
+ *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ *      MA 02110-1301, USA.
+ */
+
+#ifndef __GLIB_COMPAT_H__
+#define __GLIB_COMPAT_H__
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+G_END_DECLS
+
+#endif
diff --git a/src/gtk-compat.c b/src/gtk-compat.c
new file mode 100644
index 0000000..5c56439
--- /dev/null
+++ b/src/gtk-compat.c
@@ -0,0 +1,22 @@
+/*
+ *      gtk-compat.c
+ *
+ *      Copyright 2011 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
+ *
+ *      This program 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; either version 2 of the License, or
+ *      (at your option) any later version.
+ *
+ *      This program 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, write to the Free Software
+ *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ *      MA 02110-1301, USA.
+ */
+
+#include "gtk-compat.h"
diff --git a/src/gtk-compat.h b/src/gtk-compat.h
new file mode 100644
index 0000000..1b30289
--- /dev/null
+++ b/src/gtk-compat.h
@@ -0,0 +1,41 @@
+/*
+ *      gtk-compat.h
+ *
+ *      Copyright 2011 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
+ *
+ *      This program 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; either version 2 of the License, or
+ *      (at your option) any later version.
+ *
+ *      This program 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, write to the Free Software
+ *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ *      MA 02110-1301, USA.
+ */
+
+#ifndef __GTK_COMPAT_H__
+#define __GTK_COMPAT_H__
+#include <gtk/gtk.h>
+#include "glib-compat.h"
+
+G_BEGIN_DECLS
+
+/* for gtk+ 3.0 migration */
+#if !GTK_CHECK_VERSION(3, 0, 0)
+    #define gdk_display_get_app_launch_context(dpy) gdk_app_launch_context_new()
+#endif
+
+#if !GTK_CHECK_VERSION(2, 21, 0)
+    #define GDK_KEY_Left    GDK_Left
+    #define GDK_KEY_Right   GDK_Right
+#endif
+
+G_END_DECLS
+
+#endif
diff --git a/src/gtk/fm-dir-tree-view.c b/src/gtk/fm-dir-tree-view.c
index 5b1e934..f3e5ec1 100644
--- a/src/gtk/fm-dir-tree-view.c
+++ b/src/gtk/fm-dir-tree-view.c
@@ -19,6 +19,7 @@
 
 #include "fm-dir-tree-view.h"
 #include "fm-dir-tree-model.h"
+#include "../gtk-compat.h"
 #include <gdk/gdkkeysyms.h>
 #include <string.h>
 
diff --git a/src/gtk/fm-file-menu.c b/src/gtk/fm-file-menu.c
index 4eace51..113cae0 100644
--- a/src/gtk/fm-file-menu.c
+++ b/src/gtk/fm-file-menu.c
@@ -24,6 +24,7 @@
 #endif
 
 #include <glib/gi18n-lib.h>
+#include "../gtk-compat.h"
 
 #include "fm.h"
 #include "fm-config.h"
@@ -450,7 +451,7 @@ void on_compress(GtkAction* action, gpointer user_data)
     FmArchiver* archiver = fm_archiver_get_default();
     if(archiver)
     {
-        GAppLaunchContext* ctx = gdk_app_launch_context_new();
+        GAppLaunchContext* ctx = gdk_display_get_app_launch_context(gdk_display_get_default());
         files = fm_path_list_new_from_file_info_list(data->file_infos);
         fm_archiver_create_archive(archiver, ctx, files);
         fm_list_unref(files);
@@ -465,7 +466,7 @@ void on_extract_here(GtkAction* action, gpointer user_data)
     FmArchiver* archiver = fm_archiver_get_default();
     if(archiver)
     {
-        GAppLaunchContext* ctx = gdk_app_launch_context_new();
+        GAppLaunchContext* ctx = gdk_display_get_app_launch_context(gdk_display_get_default());
         files = fm_path_list_new_from_file_info_list(data->file_infos);
         fm_archiver_extract_archives_to(archiver, ctx, files, data->cwd);
         fm_list_unref(files);
@@ -480,7 +481,7 @@ void on_extract_to(GtkAction* action, gpointer user_data)
     FmArchiver* archiver = fm_archiver_get_default();
     if(archiver)
     {
-        GAppLaunchContext* ctx = gdk_app_launch_context_new();
+        GAppLaunchContext* ctx = gdk_display_get_app_launch_context(gdk_display_get_default());
         files = fm_path_list_new_from_file_info_list(data->file_infos);
         fm_archiver_extract_archives(archiver, ctx, files);
         fm_list_unref(files);
-- 
1.7.0.1

openSUSE Build Service is sponsored by