Commit e9738332 authored by Christian Persch's avatar Christian Persch

libgames-support: Remove obsolete version checks

All games that use libgames-support already require gtk3 and the latest glib,
so there's no need for those version checks and compat headers anymore.
parent 4486b6fd
......@@ -18,8 +18,6 @@ libgames_support_la_SOURCES = \
games-conf.h \
games-debug.c \
games-debug.h \
games-glib-compat.h \
games-gtk-compat.h \
games-help.c \
games-help.h \
games-profile.c \
......
......@@ -11,7 +11,6 @@
#include <config.h>
#include "games-clock.h"
#include "games-glib-compat.h"
G_DEFINE_TYPE (GamesClock, games_clock, GTK_TYPE_LABEL)
......
......@@ -23,13 +23,6 @@
#include <gtk/gtk.h>
#if GTK_CHECK_VERSION (2, 90, 7)
#define GDK_KEY(symbol) GDK_KEY_##symbol
#else
#include <gdk/gdkkeysyms.h>
#define GDK_KEY(symbol) GDK_##symbol
#endif
#ifdef HAVE_GNOME
#include <gconf/gconf-client.h>
#else
......@@ -37,8 +30,6 @@
#endif
#include "games-debug.h"
#include "games-glib-compat.h"
#include "games-gtk-compat.h"
#include "games-marshal.h"
#include "games-conf.h"
......@@ -1106,14 +1097,10 @@ games_conf_get_double (const char *group, const char *key,
g_free (key_name);
return value;
#elif GLIB_CHECK_VERSION (2, 12, 0)
#else
GamesConfPrivate *priv = instance->priv;
return g_key_file_get_double (priv->key_file, group ? group : priv->main_group, key, error);
#else
#warning games_conf_get_double not implemented on glib < 2.12!
/* Not supported */
return 0.0;
#endif /* HAVE_GNOME */
}
......@@ -1135,13 +1122,11 @@ games_conf_set_double (const char *group, const char *key, double value)
key_name = get_gconf_key_name (group, key);
gconf_client_set_float (priv->gconf_client, key_name, value, NULL);
g_free (key_name);
#elif GLIB_CHECK_VERSION (2, 12, 0)
#else
GamesConfPrivate *priv = instance->priv;
g_key_file_set_double (priv->key_file, group ? group : priv->main_group, key, value);
g_signal_emit (instance, signals[VALUE_CHANGED], 0, group, key);
#else
#warning games_conf_set_double not implemented on glib < 2.12!
#endif /* HAVE_GNOME */
}
......@@ -1165,7 +1150,7 @@ games_conf_get_keyval (const char *group, const char *key,
#ifdef HAVE_GNOME
GConfValueType type;
char *key_name, *value;
guint keyval = GDK_KEY (VoidSymbol);
guint keyval = GDK_KEY_VoidSymbol;
key_name = get_gconf_key_name (group, key);
type = get_gconf_value_type_from_schema (key_name);
......@@ -1174,7 +1159,7 @@ games_conf_get_keyval (const char *group, const char *key,
if (type == GCONF_VALUE_STRING) {
value = gconf_client_get_string (priv->gconf_client, key_name, error);
if (!value) {
keyval = GDK_KEY (VoidSymbol);
keyval = GDK_KEY_VoidSymbol;
} else {
keyval = gdk_keyval_from_name (value);
g_free (value);
......@@ -1182,7 +1167,7 @@ games_conf_get_keyval (const char *group, const char *key,
} else if (type == GCONF_VALUE_INT) {
keyval = gconf_client_get_int (priv->gconf_client, key_name, error);
if (*error || keyval == 0)
keyval = GDK_KEY (VoidSymbol);
keyval = GDK_KEY_VoidSymbol;
} else {
g_warning ("Unknown value type for key %s\n", key_name);
}
......@@ -1192,7 +1177,7 @@ games_conf_get_keyval (const char *group, const char *key,
return keyval;
#else
char *value;
guint keyval = GDK_KEY (VoidSymbol);
guint keyval = GDK_KEY_VoidSymbol;
value = g_key_file_get_string (priv->key_file, group, key, error);
if (value) {
......@@ -1227,7 +1212,7 @@ games_conf_get_keyval_with_default (const char *group, const char *key,
g_error_free (error);
value = default_keyval;
}
if (value == GDK_KEY (VoidSymbol)) {
if (value == GDK_KEY_VoidSymbol) {
value = default_keyval;
}
......@@ -1251,7 +1236,7 @@ games_conf_set_keyval (const char *group, const char *key, guint value)
GConfValueType type;
char *key_name, *name;
if (value == GDK_KEY (VoidSymbol))
if (value == GDK_KEY_VoidSymbol)
return;
key_name = get_gconf_key_name (group, key);
......@@ -1271,7 +1256,7 @@ games_conf_set_keyval (const char *group, const char *key, guint value)
#else
char *name;
if (value == GDK_KEY (VoidSymbol))
if (value == GDK_KEY_VoidSymbol)
return;
name = gdk_keyval_name (value);
......
......@@ -49,12 +49,6 @@ _games_debug_init (void)
env = g_getenv ("GAMES_DEBUG");
#if !GLIB_CHECK_VERSION (2, 16, 0)
/* g_parse_debug_string is only NULL-safe since 2.16 */
if (env == NULL)
return;
#endif
_games_debug_flags = g_parse_debug_string (env, keys, G_N_ELEMENTS (keys));
#endif /* GNOME_ENABLE_DEBUG */
}
/*
* Copyright © 2009 Thomas H.P. Andersen <phomes@gmail.com>
* Copyright © 2010 Christian Persch
*
* This runtime is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1, or (at your option)
* any later version.
*
* This runtime is distributed in the hope runtime 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 Lesser General Public License
* along with this runtime; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef GAMES_GLIB_COMPAT_H
#define GAMES_GLIB_COMPAT_H
#include <glib.h>
#include <glib-object.h>
G_BEGIN_DECLS
#if !GLIB_CHECK_VERSION (2, 10, 0)
#define g_slice_new(T) g_new (T, 1)
#define g_slice_new0(T) g_new0 (T, 1)
#define g_slice_free(T,ptr) g_free (ptr)
#define g_intern_static_string (string) g_quark_to_string(g_quark_from_static_string(string))
#endif /* GLIB < 2.10 */
#if !GLIB_CHECK_VERSION (2, 14, 0)
#define G_PARAM_STATIC_STRINGS (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)
#define g_timeout_add_seconds(timeout,callback,data) g_timeout_add ((timeout)*1000, callback, data)
#define gdk_threads_add_timeout_seconds(timeout,callback,data) g_timeout_add ((timeout)*1000, callback, data)
#endif /* GLIB < 2.14 */
#if !GLIB_CHECK_VERSION (2, 20, 0)
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
#define G_PASTE(identifier1,identifier2) G_PASTE_ARGS (identifier1, identifier2)
#define G_STATIC_ASSERT(expr) typedef struct { char Compile_Time_Assertion[(expr) ? 1 : -1]; } G_PASTE (_GStaticAssert_, __LINE__)
#endif /* GLIB < 2.20 */
G_END_DECLS
#endif /* !GAMES_GLIB_COMPAT_H */
......@@ -28,7 +28,6 @@
#include <glib/gi18n.h>
#include "games-gridframe.h"
#include "games-gtk-compat.h"
enum {
PROP_0,
......
/*
* Copyright © 2009 Thomas H.P. Andersen <phomes@gmail.com>
*
* This runtime is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1, or (at your option)
* any later version.
*
* This runtime is distributed in the hope runtime 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 Lesser General Public License
* along with this runtime; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef GAMES_GTK_COMPAT_H
#define GAMES_GTK_COMPAT_H
G_BEGIN_DECLS
#if !GTK_CHECK_VERSION (2, 21, 1)
#define gdk_visual_get_depth(widget) ((widget)->depth)
#endif /* GTK < 2.21.1 */
#if !GTK_CHECK_VERSION (2, 20, 0)
#define gtk_widget_get_realized(widget) (GTK_WIDGET_REALIZED(widget))
#define gtk_widget_set_realized(w,realized) ((realized) ? (GTK_WIDGET_SET_FLAGS (w, GTK_REALIZED)) : (GTK_WIDGET_UNSET_FLAGS (w, GTK_REALIZED)))
#define gtk_widget_get_mapped(widget) (GTK_WIDGET_MAPPED(widget))
#endif /* GTK < 2.20.0 */
#if !GTK_CHECK_VERSION (2, 18, 0)
#define gtk_widget_set_allocation(widget, alloc) ((widget)->allocation=*(alloc))
#define gtk_widget_get_allocation(widget, alloc) (*(alloc)=(widget)->allocation)
#define gtk_widget_set_window(widget, window_arg) ((widget)->window=window_arg)
#define gtk_widget_has_focus(widget) (GTK_WIDGET_HAS_FOCUS (widget))
#define gtk_widget_get_state(widget) ((widget)->state)
#define gtk_widget_get_visible(widget) (GTK_WIDGET_VISIBLE (widget))
#define gtk_widget_is_drawable(widget) (GTK_WIDGET_DRAWABLE (widget))
#define gtk_widget_set_can_focus(w,can_focus) ((can_focus) ? (GTK_WIDGET_SET_FLAGS (w, GTK_CAN_FOCUS)) : (GTK_WIDGET_UNSET_FLAGS (w, GTK_CAN_FOCUS)))
#endif /* GTK < 2.18.0 */
#if !GTK_CHECK_VERSION (2, 14, 0)
#define gtk_dialog_get_content_area(dialog) ((dialog)->vbox)
#define gtk_widget_get_window(widget) ((widget)->window)
#endif /* GTK < 2.14.0 */
G_END_DECLS
#endif /* !GAMES_GTK_COMPAT_H */
......@@ -59,16 +59,11 @@ games_help_display_full (GtkWidget *window,
#if defined(WITH_HELP_METHOD_GHELP)
if (section != NULL) {
#if GLIB_CHECK_VERSION (2, 16, 0)
char *escaped_section;
escaped_section = g_uri_escape_string (section, NULL, TRUE);
help_uri = g_strdup_printf ("ghelp:%s?%s", doc_module, escaped_section);
g_free (escaped_section);
#else
/* Not ideal, but the best we can do */
help_uri = g_strdup_printf ("ghelp:%s?%s", doc_module, section);
#endif /* GLIB >= 2.16.0 */
} else {
help_uri = g_strdup_printf ("ghelp:%s", doc_module);
}
......
......@@ -251,54 +251,6 @@ static const DerivedDirectory derived_directories[] = {
typedef int _assertion[G_N_ELEMENTS (derived_directories) + GAMES_RUNTIME_FIRST_DERIVED_DIRECTORY == GAMES_RUNTIME_LAST_DIRECTORY ? 1 : -1];
#if !GTK_CHECK_VERSION (2, 17, 0)
/* Since version 2.17.0, gtk has default about dialogue hook functions
* using gtk_show_uri(). For earlier versions, we need to implement
* our own hooks.
*/
static void
about_url_hook (GtkAboutDialog *about,
const char *uri,
gpointer user_data)
{
GdkScreen *screen;
GError *error = NULL;
screen = gtk_widget_get_screen (GTK_WIDGET (about));
if (!games_show_uri (screen, uri, gtk_get_current_event_time (), &error)) {
games_show_error (GTK_WIDGET (about),
error,
"%s", _("Could not show link"));
g_error_free (error);
}
}
static void
about_email_hook (GtkAboutDialog *about,
const char *email_address,
gpointer user_data)
{
char *uri;
#if GLIB_CHECK_VERSION (2, 16, 0)
char *escaped_email_address;
escaped_email_address = g_uri_escape_string (email_address, NULL, FALSE);
uri = g_strdup_printf ("mailto:%s", escaped_email_address);
g_free (escaped_email_address);
#else
/* Not really correct, but the best we can do */
uri = g_strdup_printf ("mailto:%s", email_address);
#endif
about_url_hook (about, uri, user_data);
g_free (uri);
}
#endif /* GTK < 2.17.0 */
/* public API */
/**
......@@ -391,11 +343,6 @@ games_runtime_init (const char *name)
gpl_version = 2;
}
#if !GTK_CHECK_VERSION (2, 17, 0)
gtk_about_dialog_set_url_hook (about_url_hook, NULL, NULL);
gtk_about_dialog_set_email_hook (about_email_hook, NULL, NULL);
#endif
_games_profile_end ("games_runtime_init");
return retval;
......
......@@ -25,7 +25,6 @@
#include <gtk/gtk.h>
#include "games-scores-dialog.h"
#include "games-gtk-compat.h"
G_DEFINE_TYPE (GamesScoresDialog, games_scores_dialog, GTK_TYPE_DIALOG);
......
......@@ -22,14 +22,6 @@
#include <gtk/gtk.h>
#if GTK_CHECK_VERSION (2, 90, 7)
#define GDK_KEY(symbol) GDK_KEY_##symbol
#else
#include <gdk/gdkkeysyms.h>
#define GDK_KEY(symbol) GDK_##symbol
#endif
#include "games-gtk-compat.h"
#include "games-debug.h"
#define I_(string) g_intern_static_string (string)
......@@ -211,7 +203,7 @@ variant_to_keyval (GVariant *value,
KeyEntry *entry)
{
if (value == NULL) {
entry->keyval = GDK_KEY (VoidSymbol);
entry->keyval = GDK_KEY_VoidSymbol;
entry->modifiers = 0;
return TRUE;
}
......
......@@ -75,39 +75,7 @@ games_show_uri (GdkScreen *screen,
return TRUE;
#else /* !G_OS_WIN32 */
#if GTK_CHECK_VERSION (2, 14, 0)
return gtk_show_uri (screen, uri, timestamp, error);
#else /* GTK+ < 2.14 */
char *argv[3] = { (char *) "xdg-open", (char *) uri, NULL };
if (gdk_spawn_on_screen (screen,
NULL /* working directory */,
argv,
NULL /* environment */,
G_SPAWN_SEARCH_PATH,
NULL, NULL,
NULL,
error))
return TRUE;
g_clear_error (error);
/* Try falling back to gnome-open */
argv[0] = (char *) "gnome-open";
if (gdk_spawn_on_screen (screen,
NULL /* working directory */,
argv,
NULL /* environment */,
G_SPAWN_SEARCH_PATH,
NULL, NULL,
NULL,
error))
return TRUE;
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
"%s", "Failed to show help");
return FALSE;
#endif /* GTK+ >= 2.14 */
#endif /* G_OS_WIN32 */
#endif /* HAVE_MAEMO */
}
......
......@@ -27,13 +27,6 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#if GTK_CHECK_VERSION (2, 90, 7)
#define GDK_KEY(symbol) GDK_KEY_##symbol
#else
#include <gdk/gdkkeysyms.h>
#define GDK_KEY(symbol) GDK_##symbol
#endif
#include "games-runtime.h"
#include "games-stock.h"
......@@ -95,13 +88,7 @@ menu_item_select_cb (GtkWidget * widget, GtkStatusbar * statusbar)
context_id = gtk_statusbar_get_context_id (statusbar, "games-tooltip");
#if GTK_CHECK_VERSION (2, 16, 0)
action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (widget));
#elif GTK_CHECK_VERSION (2, 10, 0)
action = gtk_widget_get_action (widget);
#else
action = g_object_get_data (G_OBJECT (widget), "gtk-action");
#endif
g_return_if_fail (action != NULL);
g_object_get (action, "tooltip", &tooltip, NULL);
......@@ -245,12 +232,10 @@ games_stock_init (void)
{ GAMES_STOCK_START_NEW_GAME, GTK_STOCK_NEW },
{ GAMES_STOCK_RESET, GTK_STOCK_CLEAR },
{ GAMES_STOCK_RESTART_GAME, GTK_STOCK_REFRESH },
#if GTK_CHECK_VERSION (2, 8, 0)
/* This is used on hildon too, but only exists since 2.8 */
{ GAMES_STOCK_FULLSCREEN, GTK_STOCK_FULLSCREEN },
/* This is used on maemo 5 */
{ GAMES_STOCK_LEAVE_FULLSCREEN, GTK_STOCK_LEAVE_FULLSCREEN },
#endif /* GTK+ >= 2.8.0 */
#ifdef HAVE_GTK_ICON_FACTORY_ADD_ALIAS
{ GAMES_STOCK_REDO_MOVE, GTK_STOCK_REDO },
{ GAMES_STOCK_UNDO_MOVE, GTK_STOCK_UNDO },
......@@ -293,27 +278,27 @@ games_stock_init (void)
#endif
static const GtkStockItem games_stock_items[] = {
{ GAMES_STOCK_CONTENTS, N_("_Contents"), 0, STOCK_ACCEL (GDK_KEY (F1), 0), NULL },
{ GAMES_STOCK_FULLSCREEN, N_("_Fullscreen"), 0, STOCK_ACCEL (GDK_KEY (F11), GDK_KEY (F6)), NULL },
{ GAMES_STOCK_HINT, N_("_Hint"), STOCK_ACCEL (GDK_CONTROL_MASK, 0), STOCK_ACCEL ('h', GDK_KEY (Return)), NULL },
{ GAMES_STOCK_CONTENTS, N_("_Contents"), 0, STOCK_ACCEL (GDK_KEY_F1, 0), NULL },
{ GAMES_STOCK_FULLSCREEN, N_("_Fullscreen"), 0, STOCK_ACCEL (GDK_KEY_F11, GDK_KEY_F6), NULL },
{ GAMES_STOCK_HINT, N_("_Hint"), STOCK_ACCEL (GDK_CONTROL_MASK, 0), STOCK_ACCEL ('h', GDK_KEY_Return), NULL },
/* Translators: This "_New" is for the menu item 'Game->New', implies "New Game" */
{ GAMES_STOCK_NEW_GAME, N_("_New"), STOCK_ACCEL (GDK_CONTROL_MASK, 0), STOCK_ACCEL ('n', 0), NULL },
/* Translators: This "_New Game" is for the game-over dialogue */
{ GAMES_STOCK_START_NEW_GAME, N_("_New Game"), 0, 0, NULL },
{ GAMES_STOCK_REDO_MOVE, N_("_Redo Move"), STOCK_ACCEL (GDK_CONTROL_MASK | GDK_SHIFT_MASK, 0), STOCK_ACCEL ('z', GDK_KEY (F7)), NULL },
{ GAMES_STOCK_REDO_MOVE, N_("_Redo Move"), STOCK_ACCEL (GDK_CONTROL_MASK | GDK_SHIFT_MASK, 0), STOCK_ACCEL ('z', GDK_KEY_F7), NULL },
/* Translators: this is the "Reset" scores button in a scores dialogue */
{ GAMES_STOCK_RESET, N_("_Reset"), 0, 0, NULL },
/* Translators: "_Restart" is the menu item 'Game->Restart', implies "Restart Game" */
{ GAMES_STOCK_RESTART_GAME, N_("_Restart"), 0, 0, NULL },
{ GAMES_STOCK_UNDO_MOVE, N_("_Undo Move"), STOCK_ACCEL (GDK_CONTROL_MASK, 0), STOCK_ACCEL ('z', GDK_KEY (F8)), NULL },
{ GAMES_STOCK_UNDO_MOVE, N_("_Undo Move"), STOCK_ACCEL (GDK_CONTROL_MASK, 0), STOCK_ACCEL ('z', GDK_KEY_F8), NULL },
{ GAMES_STOCK_DEAL_CARDS, N_("_Deal"), GDK_CONTROL_MASK, 'd', NULL },
#ifndef HAVE_HILDON
{ GAMES_STOCK_LEAVE_FULLSCREEN, N_("_Leave Fullscreen"), 0, GDK_KEY (F11), NULL },
{ GAMES_STOCK_LEAVE_FULLSCREEN, N_("_Leave Fullscreen"), 0, GDK_KEY_F11, NULL },
{ GAMES_STOCK_NETWORK_GAME, N_("Network _Game"), GDK_CONTROL_MASK, 'g', NULL },
{ GAMES_STOCK_NETWORK_LEAVE, N_("L_eave Game"), GDK_CONTROL_MASK, 'e', NULL },
{ GAMES_STOCK_PLAYER_LIST, N_("Player _List"), GDK_CONTROL_MASK, 'l', NULL },
{ GAMES_STOCK_PAUSE_GAME, N_("_Pause"), 0, GDK_KEY (Pause), NULL },
{ GAMES_STOCK_RESUME_GAME, N_("Res_ume"), 0, GDK_KEY (Pause), NULL },
{ GAMES_STOCK_PAUSE_GAME, N_("_Pause"), 0, GDK_KEY_Pause, NULL },
{ GAMES_STOCK_RESUME_GAME, N_("Res_ume"), 0, GDK_KEY_Pause, NULL },
{ GAMES_STOCK_SCORES, N_("_Scores"), 0, 0, NULL },
{ GAMES_STOCK_END_GAME, N_("_End Game"), 0, 0, NULL },
#endif
......@@ -407,28 +392,6 @@ games_get_license_version (const gchar * game_name,
else
license_trans = g_strjoin ("\n\n", _(license0), _(license1), _(license2), NULL);
#if !GTK_CHECK_VERSION (2, 8, 0)
/* We have to manually wrap the text, since the about dialogue cannot
* do it itself before gtk 2.8.
*/
{
char *p;
gsize line_length;
line_length = 0;
for (p = license_trans; *p; ++p) {
if (*p == ' ' && line_length > 42) {
*p = '\n';
line_length = 0;
} else if (*p == '\n') {
line_length = 0;
} else {
++line_length;
}
}
}
#endif /* ! GTK+ 2.8.0 */
license_str =
g_strdup_printf (license_trans, game_name, version, game_name, game_name);
g_free (license_trans);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment