gnome-games r8429 - in trunk: aisleriot libgames-support
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r8429 - in trunk: aisleriot libgames-support
- Date: Tue, 6 Jan 2009 18:18:26 +0000 (UTC)
Author: chpe
Date: Tue Jan 6 18:18:26 2009
New Revision: 8429
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8429&view=rev
Log:
Move aisleriot_util_get_display_filename to libgames-support for use in
the new theme loading code.
Added:
trunk/libgames-support/games-string-utils.c
- copied, changed from r8428, /trunk/aisleriot/util.c
trunk/libgames-support/games-string-utils.h
- copied, changed from r8428, /trunk/aisleriot/util.h
Modified:
trunk/aisleriot/conf.c
trunk/aisleriot/game.c
trunk/aisleriot/sol.c
trunk/aisleriot/util.c
trunk/aisleriot/util.h
trunk/aisleriot/window.c
trunk/libgames-support/Makefile.am
Modified: trunk/aisleriot/conf.c
==============================================================================
--- trunk/aisleriot/conf.c (original)
+++ trunk/aisleriot/conf.c Tue Jan 6 18:18:26 2009
@@ -22,6 +22,8 @@
#include <string.h>
#include <errno.h>
+#include <libgames-support/games-string-utils.h>
+
#include "util.h"
#include "conf.h"
@@ -317,7 +319,7 @@
/* Previous versions used the localised name as key, so try it as fall-back.
* See bug #406267 and bug #525177.
*/
- display_name = aisleriot_util_get_display_filename (game_file);
+ display_name = games_filename_to_display_name (game_file);
game_stat = g_hash_table_lookup (stats, display_name);
g_free (display_name);
}
@@ -378,7 +380,7 @@
if (!game_stat) {
char *localised_name;
- localised_name = aisleriot_util_get_display_filename (game_file);
+ localised_name = games_filename_to_display_name (game_file);
game_stat = g_hash_table_lookup (stats, localised_name);
g_free (localised_name);
}
Modified: trunk/aisleriot/game.c
==============================================================================
--- trunk/aisleriot/game.c (original)
+++ trunk/aisleriot/game.c Tue Jan 6 18:18:26 2009
@@ -36,11 +36,12 @@
#include <clutter/clutter.h>
#endif
+#include <libgames-support/games-runtime.h>
+#include <libgames-support/games-string-utils.h>
+
#include "conf.h"
#include "util.h"
-#include <libgames-support/games-runtime.h>
-
#include "game.h"
#include "board.h"
@@ -1708,7 +1709,7 @@
char *
aisleriot_game_get_name (AisleriotGame *game)
{
- return aisleriot_util_get_display_filename (game->game_file);
+ return games_filename_to_display_name (game->game_file);
}
/**
Modified: trunk/aisleriot/sol.c
==============================================================================
--- trunk/aisleriot/sol.c (original)
+++ trunk/aisleriot/sol.c Tue Jan 6 18:18:26 2009
@@ -60,6 +60,7 @@
#include <libgames-support/games-stock.h>
#include <libgames-support/games-runtime.h>
#include <libgames-support/games-sound.h>
+#include <libgames-support/games-string-utils.h>
#ifdef WITH_SMCLIENT
#include <libgames-support/eggsmclient.h>
@@ -362,7 +363,7 @@
if (game_file != NULL) {
char *game_name;
- game_name = aisleriot_util_get_display_filename (game_file);
+ game_name = games_filename_to_display_name (game_file);
primary = g_strdup_printf (_("Could not show help for â%sâ"), game_name);
g_free (game_name);
} else {
Modified: trunk/aisleriot/util.c
==============================================================================
--- trunk/aisleriot/util.c (original)
+++ trunk/aisleriot/util.c Tue Jan 6 18:18:26 2009
@@ -31,75 +31,6 @@
static AisleriotHelpFunc help_hook;
static gpointer help_hook_data;
-/**
- * aisleriot_util_get_display_filename:
- * @filename:
- *
- * Transforms @filename from filename encoding into a
- * translated string in UTF-8 that can be shown to the
- * user.
- *
- * Returns: a newly allocated UTF-8 string
- */
-char *
-aisleriot_util_get_display_filename (const char *filename)
-{
- char *basename, *display_name, *translated, *p;
- GString *prettified_name;
- gboolean start_of_word, free_segment;
- gunichar c;
- char utf8[7];
- gsize len;
-
- g_return_val_if_fail (filename != NULL, NULL);
-
- basename = g_path_get_basename (filename);
- g_return_val_if_fail (basename != NULL, NULL);
-
- /* Hide extension */
- g_strdelimit (basename, ".", '\0');
- /* Hide undesirable characters */
- g_strdelimit (basename, NULL, ' ');
-
- g_strstrip (basename);
-
- display_name = g_filename_display_name (basename);
- g_free (basename);
-
- g_return_val_if_fail (display_name != NULL, NULL);
-
- /* Now turn the first character in each word to uppercase */
-
- prettified_name = g_string_sized_new (strlen (display_name) + 8);
- start_of_word = TRUE;
- for (p = display_name; p && *p; p = g_utf8_next_char (p)) {
- if (start_of_word) {
- c = g_unichar_toupper (g_utf8_get_char (p));
- } else {
- c = g_utf8_get_char (p);
- }
-
- len = g_unichar_to_utf8 (c, utf8);
- g_string_append_len (prettified_name, utf8, len);
-
- start_of_word = g_unichar_isspace (c);
- }
- g_free (display_name);
-
- translated = gettext (prettified_name->str);
- if (translated != prettified_name->str) {
- display_name = g_strdup (translated);
- free_segment = TRUE;
- } else {
- display_name = prettified_name->str;
- free_segment = FALSE;
- }
-
- g_string_free (prettified_name, free_segment);
-
- return display_name;
-}
-
void
aisleriot_util_set_help_func (AisleriotHelpFunc func,
gpointer user_data)
Modified: trunk/aisleriot/util.h
==============================================================================
--- trunk/aisleriot/util.h (original)
+++ trunk/aisleriot/util.h Tue Jan 6 18:18:26 2009
@@ -24,8 +24,6 @@
G_BEGIN_DECLS
-char *aisleriot_util_get_display_filename (const char *filename);
-
typedef void (*AisleriotHelpFunc) (GtkWindow *, const char *, gpointer);
void aisleriot_util_set_help_func (AisleriotHelpFunc func,
Modified: trunk/aisleriot/window.c
==============================================================================
--- trunk/aisleriot/window.c (original)
+++ trunk/aisleriot/window.c Tue Jan 6 18:18:26 2009
@@ -44,6 +44,7 @@
#include <libgames-support/games-stock.h>
#include <libgames-support/games-runtime.h>
#include <libgames-support/games-sound.h>
+#include <libgames-support/games-string-utils.h>
#include "board.h"
#include "conf.h"
@@ -236,7 +237,7 @@
strcmp (game_file, "sol.scm") == 0)
continue;
- game_name = aisleriot_util_get_display_filename (game_file);
+ game_name = games_filename_to_display_name (game_file);
gtk_list_store_insert_with_values (GTK_LIST_STORE (list), &iter,
-1,
@@ -1405,7 +1406,7 @@
char *game_name, *tooltip;
g_snprintf (actionname, sizeof (actionname), "Recent%d", i);
- game_name = aisleriot_util_get_display_filename (recent_games[i]);
+ game_name = games_filename_to_display_name (recent_games[i]);
#ifdef HAVE_HILDON
tooltip = NULL;
#else
@@ -2747,7 +2748,7 @@
GtkWidget *dialog;
char *name;
- name = aisleriot_util_get_display_filename (data->game_file);
+ name = games_filename_to_display_name (data->game_file);
dialog = gtk_message_dialog_new (GTK_WINDOW (data->window),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
Modified: trunk/libgames-support/Makefile.am
==============================================================================
--- trunk/libgames-support/Makefile.am (original)
+++ trunk/libgames-support/Makefile.am Tue Jan 6 18:18:26 2009
@@ -46,6 +46,8 @@
games-sound.h \
games-stock.c \
games-stock.h \
+ games-string-utils.c \
+ games-string-utils.h \
$(NULL)
if !HAVE_HILDON
Copied: trunk/libgames-support/games-string-utils.c (from r8428, /trunk/aisleriot/util.c)
==============================================================================
--- /trunk/aisleriot/util.c (original)
+++ trunk/libgames-support/games-string-utils.c Tue Jan 6 18:18:26 2009
@@ -26,13 +26,10 @@
#include <gtk/gtk.h>
-#include "util.h"
-
-static AisleriotHelpFunc help_hook;
-static gpointer help_hook_data;
+#include "games-string-utils.h"
/**
- * aisleriot_util_get_display_filename:
+ * games_filename_to_display_name:
* @filename:
*
* Transforms @filename from filename encoding into a
@@ -42,7 +39,7 @@
* Returns: a newly allocated UTF-8 string
*/
char *
-aisleriot_util_get_display_filename (const char *filename)
+games_filename_to_display_name (const char *filename)
{
char *basename, *display_name, *translated, *p;
GString *prettified_name;
@@ -99,49 +96,3 @@
return display_name;
}
-
-void
-aisleriot_util_set_help_func (AisleriotHelpFunc func,
- gpointer user_data)
-{
- help_hook = func;
- help_hook_data = user_data;
-}
-
-void
-aisleriot_display_help (GtkWindow *parent,
- const char *game_file)
-{
- if (!help_hook)
- return;
-
- help_hook (parent, game_file, help_hook_data);
-}
-
-/**
- * aisleriot_util_add_atk_relation:
- * @widget:
- * @other:
- * @type:
- *
- * Adds an AtkRelation of type @type to @other into @widget's
- * AtkRelationSet.
- */
-void
-aisleriot_util_add_atk_relation (GtkWidget *widget,
- GtkWidget *other,
- AtkRelationType type)
-{
-#ifndef HAVE_HILDON
- AtkRelationSet *set;
- AtkRelation *relation;
- AtkObject *object;
-
- object = gtk_widget_get_accessible (other);
- set = atk_object_ref_relation_set (gtk_widget_get_accessible (widget));
- relation = atk_relation_new (&object, 1, type);
- atk_relation_set_add (set, relation);
- g_object_unref (relation);
- g_object_unref (set);
-#endif /* !HAVE_HILDON */
-}
Copied: trunk/libgames-support/games-string-utils.h (from r8428, /trunk/aisleriot/util.h)
==============================================================================
--- /trunk/aisleriot/util.h (original)
+++ trunk/libgames-support/games-string-utils.h Tue Jan 6 18:18:26 2009
@@ -16,27 +16,16 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef UTIL_H
-#define UTIL_H
+#ifndef GAMES_STRING_UTILS_H
+#define GAMES_STRING_UTILS_H
#include <glib.h>
#include <gtk/gtk.h>
G_BEGIN_DECLS
-char *aisleriot_util_get_display_filename (const char *filename);
-
-typedef void (*AisleriotHelpFunc) (GtkWindow *, const char *, gpointer);
-
-void aisleriot_util_set_help_func (AisleriotHelpFunc func,
- gpointer user_data);
-
-void aisleriot_display_help (GtkWindow * parent, const char *game_file);
-
-void aisleriot_util_add_atk_relation (GtkWidget *widget,
- GtkWidget *other,
- AtkRelationType type);
+char *games_filename_to_display_name (const char *filename);
G_END_DECLS
-#endif /* !UTIL_H */
+#endif /* !GAMES_STRING_UTILS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]