[gnome-nibbles] Move scores from /var/games to home directory



commit 6001f6815345e17833d20261f0958aa17cc6235a
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Thu Nov 7 23:29:14 2013 -0600

    Move scores from /var/games to home directory
    
    The score system was originally designed for multi-user systems where
    storing scores in a central location allowed different users on the same
    computer at different times to compete amongst each other for high
    scores. This might still be fun in a computer lab, but nowadays most
    users have individual machines, and we are more concerned about ensuring
    a user's scores are his own data, on his home partition, to remain even
    after blowing away / for an OS upgrade.
    
    All of the modernized games have already switched to scores in the home
    directory: time for the rest to do so as well.
    
    Also, I get to delete a lot of code, and that's fun.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=690430

 Makefile.am                |   15 --
 configure.ac               |   44 ----
 data/Makefile.am           |    5 -
 src/Makefile.am            |    8 -
 src/games-score.c          |   25 --
 src/games-score.h          |    2 -
 src/games-scores-backend.c |   95 ++++-----
 src/games-scores-backend.h |    4 -
 src/games-scores-dialog.c  |  112 +---------
 src/games-scores.c         |   79 -------
 src/games-scores.h         |    2 -
 src/games-setgid-io.c      |  558 --------------------------------------------
 src/games-setgid-io.h      |   38 ---
 13 files changed, 47 insertions(+), 940 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 98e9d63..cadee0c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,20 +1,5 @@
 SUBDIRS = data help po src
 
-SCOREFILES = 4.0 3.0 2.0 1.0 4.1 3.1 2.1 1.1
-
-install-data-local:
-       -$(mkinstalldirs) $(DESTDIR)$(scoredir)
-       -for i in ${SCOREFILES} ; do \
-          touch $(DESTDIR)$(scoredir)/gnome-nibbles.$$i.scores; \
-          chown $(scores_user):$(scores_group) $(DESTDIR)$(scoredir)/gnome-nibbles.$$i.scores; \
-          chmod 664 $(DESTDIR)$(scoredir)/gnome-nibbles.$$i.scores; \
-        done
-
-uninstall-local:
-       -for i in ${SCOREFILES} ; do \
-          rm -f $(DESTDIR)$(scoredir)/gnome-nibbles.$$i.scores; \
-        done
-
 MAINTAINERCLEANFILES = \
        $(GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL) \
        $(GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN)
diff --git a/configure.ac b/configure.ac
index f0670db..daa581c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,50 +10,6 @@ AM_PROG_CC_C_O
 GLIB_GSETTINGS
 
 dnl ###########################################################################
-dnl setgid checks
-dnl ###########################################################################
-
-AC_ARG_ENABLE([setgid],
-  [AS_HELP_STRING([--disable-setgid],
-    [Disable the use of setgid binaries])],
-  [case "${enableval}" in
-    yes) setgid=true ;;
-    no)  setgid=false ;;
-    *) AC_MSG_ERROR([bad value ${enableval} for --disable-setgid]) ;;
-   esac],
-  [if test "$platform_win32" = "yes"; then
-     enable_setgid=no
-     setgid=false
-   else
-     enable_setgid=yes
-     setgid=true
-   fi])
-
-scoredir='${localstatedir}/games'
-scores_group=games
-scores_user=games
-
-if test "$enable_setgid" = "yes"; then
-  AC_DEFINE([ENABLE_SETGID],[1],[Define if use of setgid binaries is enabled])
-
-  AC_ARG_WITH(scores-group,
-    AS_HELP_STRING([--with-scores-group=group],
-      [Group for the high score tables and binaries]),
-    scores_group="$withval",scores_group="games")
-  AC_ARG_WITH(scores-user,
-    AS_HELP_STRING([--with-scores-user=user],
-      [User for the high score tables]),
-    scores_user="$withval",scores_user="games")
-fi
-
-AM_CONDITIONAL([ENABLE_SETGID],[test "$enable_setgid" = "yes"])
-
-AC_SUBST(setgid)
-AC_SUBST(scores_group)
-AC_SUBST(scores_user)
-AC_SUBST(scoredir)
-
-dnl ###########################################################################
 dnl Dependencies
 dnl ###########################################################################
 
diff --git a/data/Makefile.am b/data/Makefile.am
index c653acf..3a3c545 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -37,11 +37,6 @@ CLEANFILES = \
        $(appdata_DATA) \
        $(desktop_DATA)
 
-install-exec-hook:
-       -if test "$(setgid)" = "true"; then \
-         chgrp $(scores_group) $(DESTDIR)$(bindir)/gnome-nibbles && chmod 2555 
$(DESTDIR)$(bindir)/gnome-nibbles ;\
-       fi
-
 check-local: $(appdata_DATA) $(desktop_DATA)
        $(APPDATA_VALIDATE) $(appdata_DATA)
        $(DESKTOP_FILE_VALIDATE) $(desktop_DATA)
diff --git a/src/Makefile.am b/src/Makefile.am
index 93a9470..89c3dae 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -21,8 +21,6 @@ gnome_nibbles_SOURCES = \
        games-scores-dialog.h   \
        games-scores-backend.c  \
        games-scores-backend.h  \
-       games-setgid-io.c \
-       games-setgid-io.h \
        gnibbles.h \
        gnibbles.c \
        properties.h \
@@ -49,15 +47,9 @@ gnome_nibbles_CFLAGS = \
        -DSOUND_DIRECTORY=\"$(datadir)/gnome-nibbles/sounds\" \
        -DLOCALEDIR=\"$(datadir)/locale\" \
        -DICON_THEME_DIRECTORY="\"$(datadir)/icons\"" \
-       -DSCORESDIR="\"$(scoredir)\""                           \
        $(GNOME_NIBBLES_CFLAGS)
 
 gnome_nibbles_LDADD = \
        $(GNOME_NIBBLES_LIBS)
 
-install-exec-hook:
-       -if test "$(setgid)" = "true"; then \
-         chgrp $(scores_group) $(DESTDIR)$(bindir)/gnome-nibbles && chmod 2555 
$(DESTDIR)$(bindir)/gnome-nibbles ;\
-       fi
-
 -include $(top_srcdir)/git.mk
diff --git a/src/games-score.c b/src/games-score.c
index 392d471..cbcc6cd 100644
--- a/src/games-score.c
+++ b/src/games-score.c
@@ -29,7 +29,6 @@ struct GamesScorePrivate {
     gdouble time_double;               /* minutes.seconds */
   } value;
   time_t time;
-  gchar *name;
 };
 
 /**
@@ -77,19 +76,6 @@ games_score_new_time (gdouble value)
   return score;
 }
 
-const gchar *
-games_score_get_name (GamesScore *score)
-{
-  return score->priv->name;
-}
-
-void
-games_score_set_name (GamesScore *score, const gchar *name)
-{
-  g_free (score->priv->name);
-  score->priv->name = g_strdup (name);
-}
-
 time_t
 games_score_get_time (GamesScore *score)
 {
@@ -156,8 +142,6 @@ games_score_finalize (GObject * object)
 {
   GamesScore *score = GAMES_SCORE (object);
 
-  g_free (score->priv->name);
-
   G_OBJECT_CLASS (games_score_parent_class)->finalize (object);
 }
 
@@ -179,13 +163,4 @@ games_score_init (GamesScore *score)
   score->priv = G_TYPE_INSTANCE_GET_PRIVATE (score, GAMES_TYPE_SCORE, GamesScorePrivate);
 
   score->priv->time = time (NULL);
-  /* FIXME: We don't handle the "Unknown" case. */
-  name = g_get_real_name ();
-  if (name[0] == '\0' || g_utf8_validate (name, -1, NULL) != TRUE) {
-    name = g_get_user_name ();
-    if (g_utf8_validate (name, -1, NULL) != TRUE) {
-      name = "";
-    }
-  }
-  score->priv->name = g_strdup (name);
 }
diff --git a/src/games-score.h b/src/games-score.h
index 7b039a5..f9f30b3 100644
--- a/src/games-score.h
+++ b/src/games-score.h
@@ -55,8 +55,6 @@ GType        games_score_get_type           (void);
 GamesScore  *games_score_new                (void);
 GamesScore  *games_score_new_plain          (guint32 value);
 GamesScore  *games_score_new_time           (gdouble value);
-const gchar *games_score_get_name           (GamesScore *score);
-void         games_score_set_name           (GamesScore *score, const gchar *name);
 time_t       games_score_get_time           (GamesScore *score);
 void         games_score_set_time           (GamesScore *score, time_t time);
 guint32      games_score_get_value_as_plain (GamesScore *score);
diff --git a/src/games-scores-backend.c b/src/games-scores-backend.c
index f574713..5b22534 100644
--- a/src/games-scores-backend.c
+++ b/src/games-scores-backend.c
@@ -23,21 +23,19 @@
 #include <glib.h>
 #include <glib-object.h>
 
+#include <errno.h>
+#include <fcntl.h>
 #include <string.h>
 #include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "games-score.h"
 #include "games-scores.h"
 #include "games-scores-backend.h"
 
-#ifdef ENABLE_SETGID
-#include "games-setgid-io.h"
-#endif
-
 struct GamesScoresBackendPrivate {
-#ifdef ENABLE_SETGID
-  gboolean setgid_io_initialized;
-#endif
   GList *scores_list;
   GamesScoreStyle style;
   time_t timestamp;
@@ -50,9 +48,7 @@ G_DEFINE_TYPE (GamesScoresBackend, games_scores_backend, G_TYPE_OBJECT);
 void
 games_scores_backend_startup (void)
 {
-#ifdef ENABLE_SETGID
-  setgid_io_init ();
-#endif
+  /* Retained for compatibility */
 }
 
 static void
@@ -90,28 +86,27 @@ games_scores_backend_new (GamesScoreStyle style,
                           char *name)
 {
   GamesScoresBackend *backend;
-  gchar *fullname;
+  char *pkguserdatadir;
 
   backend = GAMES_SCORES_BACKEND (g_object_new (GAMES_TYPE_SCORES_BACKEND,
                                                 NULL));
 
-  if (name[0] == '\0')                /* Name is "" */
-    fullname = g_strjoin (".", base_name, "scores", NULL);
-  else
-    fullname = g_strjoin (".", base_name, name, "scores", NULL);
-
   backend->priv->timestamp = 0;
   backend->priv->style = style;
   backend->priv->scores_list = NULL;
-  backend->priv->filename = g_build_filename (SCORESDIR, fullname, NULL);
-  g_free (fullname);
+  pkguserdatadir = g_build_filename (g_get_user_data_dir (), base_name, NULL);
+  backend->priv->filename = g_build_filename (pkguserdatadir, name, NULL);
 
+  if (access (pkguserdatadir, O_RDWR) == -1) {
+    /* Don't return NULL because games-scores.c does not
+     * expect it, and can't do anything about it anyway. */
+    mkdir (pkguserdatadir, 0775);
+  }
   backend->priv->fd = -1;
 
   return backend;
 }
 
-#ifdef ENABLE_SETGID
 
 /* Get a lock on the scores file. Block until it is available. 
  * This also supplies the file descriptor we need. The return value
@@ -120,23 +115,29 @@ static gboolean
 games_scores_backend_get_lock (GamesScoresBackend * self)
 {
   gint error;
+  struct flock lock;
 
   if (self->priv->fd != -1) {
     /* Assume we already have the lock and rewind the file to
      * the beginning. */
-    setgid_io_seek (self->priv->fd, 0, SEEK_SET);
+    lseek (self->priv->fd, 0, SEEK_SET);
     return TRUE;                /* Assume we already have the lock. */
   }
 
-  self->priv->fd = setgid_io_open (self->priv->filename, O_RDWR);
+  self->priv->fd = open (self->priv->filename, O_RDWR | O_CREAT, 0755);
   if (self->priv->fd == -1) {
     return FALSE;
   }
 
-  error = setgid_io_lock (self->priv->fd);
+  lock.l_type = F_WRLCK;
+  lock.l_whence = SEEK_SET;
+  lock.l_start = 0;
+  lock.l_len = 0;
+
+  error = fcntl (self->priv->fd, F_SETLKW, &lock);
 
   if (error == -1) {
-    setgid_io_close (self->priv->fd);
+    close (self->priv->fd);
     self->priv->fd = -1;
     return FALSE;
   }
@@ -149,19 +150,24 @@ games_scores_backend_get_lock (GamesScoresBackend * self)
 static void
 games_scores_backend_release_lock (GamesScoresBackend * self)
 {
+  struct flock lock;
+
   /* We don't have a lock, ignore this call. */
   if (self->priv->fd == -1)
     return;
 
-  setgid_io_unlock (self->priv->fd);
+  lock.l_type = F_UNLCK;
+  lock.l_whence = SEEK_SET;
+  lock.l_start = 0;
+  lock.l_len = 0;
 
-  setgid_io_close (self->priv->fd);
+  fcntl (self->priv->fd, F_SETLKW, &lock);
+
+  close (self->priv->fd);
 
   self->priv->fd = -1;
 }
 
-#endif /* ENABLE_SETGID */
-
 /**
  * games_scores_backend_get_scores:
  * @self: the backend to get the scores from
@@ -175,12 +181,10 @@ games_scores_backend_release_lock (GamesScoresBackend * self)
 GList *
 games_scores_backend_get_scores (GamesScoresBackend * self)
 {
-#ifdef ENABLE_SETGID
   gchar *buffer;
   gchar *eol;
   gchar *scorestr;
   gchar *timestr;
-  gchar *namestr;
   GamesScore *newscore;
   struct stat info;
   int error;
@@ -188,11 +192,12 @@ games_scores_backend_get_scores (GamesScoresBackend * self)
   GList *t;
   
   /* Check for a change in the scores file and update if necessary. */
-  error = setgid_io_stat (self->priv->filename, &info);
+  error = stat (self->priv->filename, &info);
 
   /* If an error occurs then we give up on the file and return NULL. */
-  if (error != 0)
+  if (error != 0) {
     return NULL;
+  }
 
   if ((info.st_mtime > self->priv->timestamp) || (self->priv->scores_list == NULL)) {
     self->priv->timestamp = info.st_mtime;
@@ -220,7 +225,7 @@ games_scores_backend_get_scores (GamesScoresBackend * self)
     length = 0;
     do {
       target -= length;
-      length = setgid_io_read (self->priv->fd, buffer, info.st_size);
+      length = read (self->priv->fd, buffer, info.st_size);
       if (length == -1) {
         games_scores_backend_release_lock (self);
         g_free (buffer);
@@ -243,11 +248,7 @@ games_scores_backend_get_scores (GamesScoresBackend * self)
       if (timestr == NULL)
         break;
       *timestr++ = '\0';
-      namestr = strchr (timestr, ' ');
-      if (namestr == NULL)
-        break;
-      *namestr++ = '\0';
-      /* At this point we have three strings, all null terminated. All
+      /* At this point we have two strings, both null terminated. All
        * part of the original buffer. */
       switch (self->priv->style) {
       case GAMES_SCORES_STYLE_PLAIN_DESCENDING:
@@ -261,7 +262,6 @@ games_scores_backend_get_scores (GamesScoresBackend * self)
       default:
         g_assert_not_reached ();
       }
-      games_score_set_name (newscore, namestr);
       games_score_set_time (newscore, g_ascii_strtoull (timestr, NULL, 10));
       self->priv->scores_list = g_list_append (self->priv->scores_list, newscore);
       /* Setup again for the next time around. */
@@ -275,15 +275,11 @@ games_scores_backend_get_scores (GamesScoresBackend * self)
   /* FIXME: Sort the scores! We shouldn't rely on the file being sorted. */
 
   return self->priv->scores_list;
-#else
-  return NULL;
-#endif /* ENABLE_SETGID */
 }
 
 gboolean
 games_scores_backend_set_scores (GamesScoresBackend * self, GList * list)
 {
-#ifdef ENABLE_SETGID
   GList *s;
   GamesScore *d;
   gchar *buffer;
@@ -299,7 +295,6 @@ games_scores_backend_set_scores (GamesScoresBackend * self, GList * list)
   while (s != NULL) {
     gdouble rscore;
     guint64 rtime;
-    const gchar *rname;
 
     d = (GamesScore *) s->data;
     rscore = 0.0;
@@ -316,12 +311,11 @@ games_scores_backend_set_scores (GamesScoresBackend * self, GList * list)
       g_assert_not_reached ();
     }
     rtime = games_score_get_time (d);
-    rname = games_score_get_name(d);
 
-    buffer = g_strdup_printf ("%s %"G_GUINT64_FORMAT" %s\n",
+    buffer = g_strdup_printf ("%s %"G_GUINT64_FORMAT"\n",
                               g_ascii_dtostr (dtostrbuf, sizeof (dtostrbuf),
-                                              rscore), rtime, rname);
-    setgid_io_write (self->priv->fd, buffer, strlen (buffer));
+                                              rscore), rtime);
+    write (self->priv->fd, buffer, strlen (buffer));
     output_length += strlen (buffer);
     /* Ignore any errors and blunder on. */
     g_free (buffer);
@@ -330,7 +324,7 @@ games_scores_backend_set_scores (GamesScoresBackend * self, GList * list)
   }
 
   /* Remove any content in the file that hasn't yet been overwritten. */
-  setgid_io_truncate (self->priv->fd, output_length--);
+  ftruncate (self->priv->fd, output_length--);
 
   /* Update the timestamp so we don't reread the scores unnecessarily. */
   self->priv->timestamp = time (NULL);
@@ -338,15 +332,10 @@ games_scores_backend_set_scores (GamesScoresBackend * self, GList * list)
   games_scores_backend_release_lock (self);
 
   return TRUE;
-#else
-  return FALSE;
-#endif /* ENABLE_SETGID */
 }
 
 void
 games_scores_backend_discard_scores (GamesScoresBackend * self)
 {
-#ifdef ENABLE_SETGID
   games_scores_backend_release_lock (self);
-#endif
 }
diff --git a/src/games-scores-backend.h b/src/games-scores-backend.h
index 131fb4b..c094431 100644
--- a/src/games-scores-backend.h
+++ b/src/games-scores-backend.h
@@ -28,10 +28,6 @@
 
 #include "games-score.h"
 
-#ifdef ENABLE_SETGID
-#include "games-setgid-io.h"
-#endif
-
 G_BEGIN_DECLS
 
 #define GAMES_TYPE_SCORES_BACKEND (games_scores_backend_get_type ())
diff --git a/src/games-scores-dialog.c b/src/games-scores-dialog.c
index 86062c6..fab8fb0 100644
--- a/src/games-scores-dialog.c
+++ b/src/games-scores-dialog.c
@@ -36,18 +36,14 @@ struct GamesScoresDialogPrivate {
   GtkWidget *catbar;
   GtkListStore *list;
   GtkTreeView *treeview;
-  GtkCellRenderer *namerenderer;
   GtkTreeViewColumn *column;
-  GtkTreeViewColumn *namecolumn;
   GtkTreeViewColumn *timecolumn;
   GamesScores *scores;
   GHashTable *categories;
   GHashTable *catindices;
   gint catcounter;
   gint hilight;
-  gint sethilight;
   gboolean preservehilight;
-  gulong cursor_handler_id;
 
   /* FIXME: This should be a property. */
   gint style;
@@ -199,83 +195,6 @@ GtkWidget * games_scores_dialog_new (GtkWindow *parent_window, GamesScores *scor
   return (GtkWidget *)dialog;
 }
 
-/* Retrieve the edited name from a new high score. */
-static void games_scores_dialog_name_edited (GtkCellRendererText *cell, 
-                                            gchar *path, gchar *new_text, 
-                                            GamesScoresDialog *self)
-{
-  GtkTreeIter iter;
-  gchar *old_name = NULL;
-
-  gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (self->priv->list), 
-                                      &iter, path);
-
-  /* Get old name for comparison */
-  gtk_tree_model_get (GTK_TREE_MODEL (self->priv->list),
-                      &iter, 0, &old_name, -1);
-                           
-  gtk_list_store_set (self->priv->list, &iter, 0, new_text, -1);
-
-  games_scores_update_score_name (self->priv->scores, new_text, old_name);
-}
-
-/* Prevent editing of any cell in the high score list but the one we set. */
-static void games_scores_dialog_cursor_changed (GtkTreeView *treeview, 
-                                               GamesScoresDialog *self)
-{
-  g_object_set (self->priv->namerenderer, "editable", FALSE, NULL);
-}    
-
-/* These contortions are to ensure that only the single most-recent
- * entry can be edited. */
-static gboolean games_scores_dialog_set_edit (GamesScoresDialog *self)
-{
-  GtkTreePath *path;
-  GtkTreeSelection *selection;
-
-  /* Just in case we've been closed as soon as we're created. */
-  if (!gtk_widget_get_realized (GTK_WIDGET (self)))
-    return FALSE;
-
-  /* Temporarily disable the code that prevents editing when the
-   * cursor changes position. */
-  g_signal_handler_block (self->priv->treeview, 
-                           self->priv->cursor_handler_id); 
-  g_object_set (self->priv->namerenderer, "editable", TRUE, NULL);
-  selection = gtk_tree_view_get_selection (self->priv->treeview);
-  path = gtk_tree_path_new_from_indices (self->priv->hilight - 1, -1);
-  gtk_tree_selection_select_path (selection, path);
-  gtk_tree_view_set_cursor (self->priv->treeview, path, 
-                             self->priv->namecolumn, TRUE);
-  g_signal_handler_unblock (self->priv->treeview, 
-                             self->priv->cursor_handler_id); 
-  gtk_tree_path_free (path);
-
-  return FALSE;
-}
-
-/* Yet another part of the puzzle that lets the correct high-score be
- * editable. */
-static void games_scores_dialog_set_hilight_private (GamesScoresDialog *self) 
-{
-  if (self->priv->hilight == 0) {
-    g_object_set (self->priv->namerenderer, "editable", FALSE, NULL);
-    return;
-  }
-
-  if (self->priv->hilight == self->priv->sethilight)
-    return;
-
-  self->priv->sethilight = self->priv->hilight;
-
-  /* We can't set the hilight editable immediately in case we are
-   * still in the process of being created and the editing subwindow
-   * gets put in the wrong place. Attaching to the expose signal
-   * doesn't seem to have the desired effect, so instead we just
-   * wait until all other work is done. */
-  g_idle_add ((GSourceFunc)games_scores_dialog_set_edit, self);
-}
-
 /* Load up the list with the current set of scores. */
 static void games_scores_dialog_redraw (GamesScoresDialog *self) {
   GtkTreeIter iter;
@@ -293,7 +212,6 @@ static void games_scores_dialog_redraw (GamesScoresDialog *self) {
   scorelist = games_scores_get (self->priv->scores);
 
   while (scorelist) {
-    name = games_score_get_name ((GamesScore *)scorelist->data);
     timestamp = games_score_get_time ((GamesScore *)scorelist->data);
     datetime = g_date_time_new_from_unix_local (timestamp);
     time = g_date_time_format (datetime,"%d/%m/%y");
@@ -314,13 +232,11 @@ static void games_scores_dialog_redraw (GamesScoresDialog *self) {
       ss = g_strdup_printf ("%d", score);
     }
     gtk_list_store_append (self->priv->list, &iter);
-    gtk_list_store_set (self->priv->list, &iter, 0, name, 1, time, 2, ss, -1);
+    gtk_list_store_set (self->priv->list, &iter, 0, time, 1, ss, -1);
     g_free (ss);
     g_free (time);
     scorelist = g_list_next (scorelist);
   }
-    
-  games_scores_dialog_set_hilight_private (self);
 }
 
 /* Change the currently viewed score category. There is a little bit
@@ -430,7 +346,6 @@ void games_scores_dialog_set_hilight (GamesScoresDialog *self, guint pos)
     return;
 
   self->priv->hilight = pos;
-  games_scores_dialog_set_hilight_private (self);
 }
 
 static void games_scores_dialog_init (GamesScoresDialog *self) 
@@ -457,7 +372,6 @@ static void games_scores_dialog_init (GamesScoresDialog *self)
   self->priv->catindices = g_hash_table_new (g_direct_hash, g_direct_equal);
   self->priv->catcounter = 0;
   self->priv->hilight = 0;
-  self->priv->sethilight = -1;
   gtk_container_set_border_width (GTK_CONTAINER (self), 5);
   gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), 2);
 
@@ -475,7 +389,7 @@ static void games_scores_dialog_init (GamesScoresDialog *self)
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_AUTOMATIC);
-  gtk_widget_set_size_request (scroll, 250, 265);
+  gtk_widget_set_size_request (scroll, 200, 265);
   gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
                                         GTK_SHADOW_ETCHED_IN);
   gtk_box_pack_end (GTK_BOX (vbox), scroll, TRUE, TRUE, 0);
@@ -506,32 +420,16 @@ static void games_scores_dialog_init (GamesScoresDialog *self)
   g_signal_connect (G_OBJECT (self->priv->combo), "changed", 
                      G_CALLBACK (games_scores_dialog_change_category), self);
 
-  self->priv->list = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+  self->priv->list = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
 
   listview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (self->priv->list));
   self->priv->treeview = GTK_TREE_VIEW (listview);
-  self->priv->cursor_handler_id = 
-    g_signal_connect (G_OBJECT (self->priv->treeview), 
-                       "cursor-changed", 
-                       G_CALLBACK (games_scores_dialog_cursor_changed), self);
-  
-  self->priv->namerenderer = gtk_cell_renderer_text_new ();
-  g_signal_connect (self->priv->namerenderer, "edited", 
-                     G_CALLBACK (games_scores_dialog_name_edited), self);
-
-  self->priv->namecolumn = gtk_tree_view_column_new_with_attributes (/* Score dialog column header for the 
name of the player who recorded the score */
-                                                                     C_("score-dialog", "Name"),
-                                                                     self->priv->namerenderer,
-                                                                     "text", 0,
-                                                                     NULL);
-  gtk_tree_view_append_column (GTK_TREE_VIEW (listview),
-                                GTK_TREE_VIEW_COLUMN (self->priv->namecolumn));
 
   timerenderer = gtk_cell_renderer_text_new ();
   timecolumn = gtk_tree_view_column_new_with_attributes (/* Score dialog column header for the date the 
score was recorded */
                                                          _("Date"),
                                                          timerenderer,
-                                                         "text", 1,
+                                                         "text", 0,
                                                          NULL);
   g_object_set (G_OBJECT (timerenderer), "xalign", 1.0, NULL);
   gtk_tree_view_append_column (GTK_TREE_VIEW (listview),
@@ -539,7 +437,7 @@ static void games_scores_dialog_init (GamesScoresDialog *self)
   self->priv->timecolumn = timecolumn;
 
   renderer = gtk_cell_renderer_text_new ();
-  column = gtk_tree_view_column_new_with_attributes ("", renderer, "text", 2, NULL);
+  column = gtk_tree_view_column_new_with_attributes ("", renderer, "text", 1, NULL);
   g_object_set (G_OBJECT (renderer), "xalign", 1.0, NULL);
   gtk_tree_view_append_column (GTK_TREE_VIEW (listview),
                                 GTK_TREE_VIEW_COLUMN (column));
diff --git a/src/games-scores.c b/src/games-scores.c
index 8b097e4..fe9d718 100644
--- a/src/games-scores.c
+++ b/src/games-scores.c
@@ -315,85 +315,6 @@ games_scores_add_time_score (GamesScores * self, gdouble value)
 }
 
 /**
- * games_scores_update_score_name:
- * @self: A scores object.
- * @new_name: The new name to use.
- * @old_name: (allow-none):
- *
- * By default add_score uses the current user name. This routine updates
- * that name. There are a few wrinkles: the score may have moved since we
- * got the original score. Use in normal code is discouraged, it is here 
- * to be used by GamesScoresDialog.
- *
- **/
-void
-games_scores_update_score_name (GamesScores * self, gchar * new_name, gchar * old_name)
-{
-  GamesScoresPrivate *priv = self->priv;
-  GamesScoresCategoryInternal *cat;
-  GList *s, *scores_list;
-  gint n, place;
-  GamesScore *sc;
-
-  g_return_if_fail (self != NULL);
-
-  place = priv->last_score_position;
-
-  if (place == 0)
-    return;
-
-  if (old_name)
-      old_name = g_strdup (old_name); /* Make copy so we can free it later */
-  else
-      old_name = g_strdup (g_get_real_name ());
-
-  cat = games_scores_get_current (self);
-
-  scores_list = games_scores_backend_get_scores (cat->backend);
-
-  s = g_list_last (scores_list);
-  n = g_list_length (scores_list);
-
-  /* We hunt backwards down the list until we find the last entry with
-   * a matching user and score. */
-  /* The check that we haven't gone back before place isn't just a
-   * pointless optimisation. It also catches the case where our score
-   * has been dropped from the high-score list in the meantime. */
-
-  while ((n >= place) && (s != NULL)) {
-    sc = (GamesScore *) (s->data);
-    if ((games_score_compare (priv->style, sc, priv->last_score) ==
-        0) && (g_utf8_collate (old_name, games_score_get_name (sc)) == 0)) {
-      games_score_set_name (sc, new_name);
-    }
-
-    s = g_list_previous (s);
-    n--;
-  }
-
-  games_scores_backend_set_scores (cat->backend, scores_list);
-
-  g_free (old_name);
-}
-
-/**
- * games_scores_update_score:
- * @self: A scores object.
- * @new_name: The new name to use.
- *
- * By default add_score uses the current user name. This routine updates
- * that name. There are a few wrinkles: the score may have moved since we
- * got the original score. Use in normal code is discouraged, it is here 
- * to be used by GamesScoresDialog.
- *
- **/
-void
-games_scores_update_score (GamesScores * self, gchar * new_name)
-{
-    games_scores_update_score_name (self, new_name, NULL);
-}
-
-/**
  * games_scores_get:
  * @self: A scores object.
  *
diff --git a/src/games-scores.h b/src/games-scores.h
index 02e31c6..f9180fd 100644
--- a/src/games-scores.h
+++ b/src/games-scores.h
@@ -75,8 +75,6 @@ void            games_scores_set_category      (GamesScores * self, const gchar
 gint            games_scores_add_score         (GamesScores * self, GamesScore *score);
 gint            games_scores_add_plain_score   (GamesScores * self, guint32 value);
 gint            games_scores_add_time_score    (GamesScores * self, gdouble value);
-void            games_scores_update_score      (GamesScores * self, gchar * new_name);
-void            games_scores_update_score_name (GamesScores * self, gchar * new_name, gchar * old_name);
 GList *         games_scores_get               (GamesScores * self);
 void            _games_scores_category_foreach (GamesScores * self,
                                                 GamesScoresCategoryForeachFunc func,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]