Bug#885037: Port to Gio::Settings

Yavor Doganov yavor at gnu.org
Sun Oct 21 20:16:26 BST 2018


tags 885037 + patch
thanks

Attached are patches which remove the libgnome and gconfmm
dependencies.  (I know nothing about C++ so please bear with me.  The
code appears to work but is likely to have some issues like memory
management bugs.)

Apart from removing libgnome2-dev and libgconfmm-2.6-dev from B-D,
please consider adding gconf2 to Recommends; see #907826.
-------------- next part --------------
Description: Eliminate libgnome dependency.
Bug-Debian: https://bugs.debian.org/885037
Author: Yavor Doganov <yavor at gnu.org>
Forwarded: no
Last-Update: 2018-10-21
---

--- monster-masher-1.8.1.orig/configure.ac
+++ monster-masher-1.8.1/configure.ac
@@ -14,8 +14,7 @@
 AC_PROG_CXX
 
 dnl checks for libraries
-PKG_CHECK_MODULES(DEPS, libgnome-2.0 >= 2.0.0 \
-                        gconfmm-2.6 >= 2.6.0 \
+PKG_CHECK_MODULES(DEPS, gconfmm-2.6 >= 2.6.0 \
                         gtkmm-2.4 >= 2.6.0 \
                         libgnomecanvasmm-2.6 >= 2.6.0 \
 			libglademm-2.4 >= 2.4.0 \
--- monster-masher-1.8.1.orig/src/main.cpp
+++ monster-masher-1.8.1/src/main.cpp
@@ -29,9 +29,6 @@
 #include <gconfmm/init.h>
 #include <gtkmm/main.h>
 
-#include <libgnome/gnome-program.h>
-#include <libgnome/gnome-init.h>
-
 #include <sigc++/slot.h>
 
 #include "main-window.hpp"
@@ -40,11 +37,10 @@
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main main(argc, argv);
+  Glib::OptionContext ctxt;
+  Gtk::Main main(argc, argv, ctxt);
   Gnome::Conf::init();
   Gnome::Canvas::init();
-  
-  gnome_program_init(PACKAGE, VERSION, LIBGNOME_MODULE, argc, argv, NULL);
 
   try {
     // i18n
-------------- next part --------------
Description: Port to Gio::Settings.
Debian-Bug: https://bugs.debian.org/885037
Author: Yavor Doganov <yavor at gnu.org>
Forwarded: no
Last-Update: 2018-10-21
---

--- monster-masher-1.8.1.orig/Makefile.am
+++ monster-masher-1.8.1/Makefile.am
@@ -6,11 +6,12 @@
 desktop_DATA 		= $(desktop_in_files:.desktop.in=.desktop)
 @INTLTOOL_DESKTOP_RULE@
 
-# GConf schema
-schema_in_files = monster-masher.schemas.in
-schemadir = $(sysconfdir)/gconf/schemas
-schema_DATA = $(schema_in_files:.schemas.in=.schemas)
- at INTLTOOL_SCHEMAS_RULE@
+data_convertdir = $(datadir)/GConf/gsettings
+dist_data_convert_DATA = monster-masher.convert
+
+# GSettings schema
+gsettings_SCHEMAS = dk.iola.olau.monster-masher.gschema.xml
+ at GSETTINGS_RULES@
 
 # icon
 icondir = $(datadir)/pixmaps
@@ -18,14 +19,7 @@
 
 pixmapdir = $(datadir)/$(PACKAGE)/pixmaps/
 
-EXTRA_DIST = $(desktop_in_files) $(schema_in_files) \
+EXTRA_DIST = $(desktop_in_files) $(gsettings_SCHEMAS) \
              $(desktop_DATA) $(icon_DATA) \
              intltool-merge.in intltool-extract.in intltool-update.in \
              MAINTAINERS
-
-install-data-local:
-	if test -z "$(DESTDIR)" ; then \
-	for p in $(schema_DATA) ; do \
-	GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_builddir)/$$p; \
-	done \
-        fi
--- monster-masher-1.8.1.orig/configure.ac
+++ monster-masher-1.8.1/configure.ac
@@ -14,8 +14,7 @@
 AC_PROG_CXX
 
 dnl checks for libraries
-PKG_CHECK_MODULES(DEPS, gconfmm-2.6 >= 2.6.0 \
-                        gtkmm-2.4 >= 2.6.0 \
+PKG_CHECK_MODULES(DEPS, gtkmm-2.4 >= 2.6.0 \
                         libgnomecanvasmm-2.6 >= 2.6.0 \
 			libglademm-2.4 >= 2.4.0 \
 			libcanberra)
@@ -23,15 +22,7 @@
 AC_SUBST(DEPS_LIBS)
 
 	
-dnl GConf
-AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
-
-if test x"$GCONFTOOL" = xno; then
-AC_MSG_ERROR([gconftool-2 executable not found in your path - should be installed with GConf])
-fi
-
-AM_GCONF_SOURCE_2
-
+GLIB_GSETTINGS
 
 dnl i18n
 ALL_LINGUAS="ar az bg ca cs cy da de dz el en_CA en_GB es eu fi fr ga gu hr hu it ka lt lv nb ne nl oc pa pl pt pt_BR rw sl sq sr sr at Latn sv ta tr uk vi zh_CN zh_HK zh_TW"
--- /dev/null
+++ monster-masher-1.8.1/monster-masher.convert
@@ -0,0 +1,24 @@
+[dk.iola.olau.monster-masher]
+fullscreen = /apps/monster-masher/fullscreen
+
+[dk.iola.olau.monster-masher.player1]
+left-key = /apps/monster-masher/player1/left_key
+left-up-key = /apps/monster-masher/player1/left_up_key
+up-key = /apps/monster-masher/player1/up_key
+right-up-key = /apps/monster-masher/player1/right_up_key
+right-key = /apps/monster-masher/player1/right_key
+right-down-key = /apps/monster-masher/player1/right_down_key
+down-key = /apps/monster-masher/player1/down_key
+left-down-key = /apps/monster-masher/player1/left_down_key
+pull-key = /apps/monster-masher/player1/pull_key
+
+[dk.iola.olau.monster-masher.player2]
+left-key = /apps/monster-masher/player2/left_key
+left-up-key = /apps/monster-masher/player2/left_up_key
+up-key = /apps/monster-masher/player2/up_key
+right-up-key = /apps/monster-masher/player2/right_up_key
+right-key = /apps/monster-masher/player2/right_key
+right-down-key = /apps/monster-masher/player2/right_down_key
+down-key = /apps/monster-masher/player2/down_key
+left-down-key = /apps/monster-masher/player2/left_down_key
+pull-key = /apps/monster-masher/player2/pull_key
--- /dev/null
+++ monster-masher-1.8.1/dk.iola.olau.monster-masher.gschema.xml
@@ -0,0 +1,104 @@
+<schemalist gettext-domain="monster-masher">
+  <schema id="dk.iola.olau.monster-masher" path="/dk/iola/olau/monster-masher/">
+    <key name="fullscreen" type="b">
+      <default>true</default>
+      <summary>Use fullscreen</summary>
+    </key>
+    <child name="player1" schema="dk.iola.olau.monster-masher.player1"/>
+    <child name="player2" schema="dk.iola.olau.monster-masher.player2"/>
+  </schema>
+  <schema id="dk.iola.olau.monster-masher.player1" path="/dk/iola/olau/monster-masher/player1/">
+    <key name="left-key" type="s">
+      <default>'KP_Left'</default>
+      <summary>Key for moving to the left</summary>
+      <description>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</description>
+    </key>
+    <key name="left-up-key" type="s">
+      <default>'KP_Home'</default>
+      <summary>Key for moving to the left and up</summary>
+      <description>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</description>
+    </key>
+    <key name="up-key" type="s">
+      <default>'KP_Up'</default>
+      <summary>Key for moving up</summary>
+      <description>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</description>
+    </key>
+    <key name="right-up-key" type="s">
+      <default>'KP_Page_Up'</default>
+      <summary>Key for moving to the right and up</summary>
+      <description>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</description>
+    </key>
+    <key name="right-key" type="s">
+      <default>'KP_Right'</default>
+      <summary>Key for moving to the right</summary>
+      <description>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</description>
+    </key>
+    <key name="right-down-key" type="s">
+      <default>'KP_Page_Down'</default>
+      <summary>Key for moving to the right and down</summary>
+      <description>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</description>
+    </key>
+    <key name="down-key" type="s">
+      <default>'KP_Down'</default>
+      <summary>Key for moving down</summary>
+      <description>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</description>
+    </key>
+    <key name="left-down-key" type="s">
+      <default>'KP_End'</default>
+      <summary>Key for moving to the left and down</summary>
+      <description>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</description>
+    </key>
+    <key name="pull-key" type="s">
+      <default>'Control_R'</default>
+      <summary>Key for activating pulling of blocks</summary>
+      <description>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</description>
+    </key>
+  </schema>
+  <schema id="dk.iola.olau.monster-masher.player2" path="/dk/iola/olau/monster-masher/player2/">
+    <key name="left-key" type="s">
+      <default>'d'</default>
+      <summary>Key for moving to the left</summary>
+      <description>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</description>
+    </key>
+    <key name="left-up-key" type="s">
+      <default>'e'</default>
+      <summary>Key for moving to the left and up</summary>
+      <description>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</description>
+    </key>
+    <key name="up-key" type="s">
+      <default>'r'</default>
+      <summary>Key for moving up</summary>
+      <description>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</description>
+    </key>
+    <key name="right-up-key" type="s">
+      <default>'t'</default>
+      <summary>Key for moving to the right and up</summary>
+      <description>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</description>
+    </key>
+    <key name="right-key" type="s">
+      <default>'g'</default>
+      <summary>Key for moving to the right</summary>
+      <description>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</description>
+    </key>
+    <key name="right-down-key" type="s">
+      <default>'b'</default>
+      <summary>Key for moving to the right and down</summary>
+      <description>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</description>
+    </key>
+    <key name="down-key" type="s">
+      <default>'v'</default>
+      <summary>Key for moving down</summary>
+      <description>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</description>
+    </key>
+    <key name="left-down-key" type="s">
+      <default>'c'</default>
+      <summary>Key for moving to the left and down</summary>
+      <description>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</description>
+    </key>
+    <key name="pull-key" type="s">
+      <default>'Control_L'</default>
+      <summary>Key for activating pulling of blocks</summary>
+      <description>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</description>
+    </key>
+  </schema>
+</schemalist>
--- monster-masher-1.8.1.orig/src/main-window.cpp
+++ monster-masher-1.8.1/src/main-window.cpp
@@ -60,7 +60,6 @@
 }
 
 MainWindow::MainWindow()
-  : gconf_dir("/apps/monster-masher")
 {
   // load icon
   std::string icon_name = GNOMEICONDIR "/monster-masher.png";
@@ -76,8 +75,9 @@
   }
 
   // setup gconf
-  gconf_client = Gnome::Conf::Client::get_default_client();
-  gconf_client->add_dir(gconf_dir);
+  settings = Gio::Settings::create("dk.iola.olau.monster-masher");
+  p1_settings = settings->get_child("player1");
+  p2_settings = settings->get_child("player2");
 
   // start constructing window
   ui = get_glade_xml("main_window");
@@ -96,7 +96,7 @@
   level_label->set_text("");
   
   // setup window
-  fullscreen = gconf_client->get_bool(gconf_dir + "/fullscreen");
+  fullscreen = settings->get_boolean("fullscreen");
   if (fullscreen)
     window->fullscreen();
   
@@ -113,8 +113,8 @@
   generate_main_menu();
 
   // connect GConf
-  gconf_client->notify_add(gconf_dir + "/fullscreen",
-			   sigc::mem_fun(*this, &MainWindow::fullscreen_listener));
+  settings->signal_changed()
+    .connect(sigc::mem_fun(*this, &MainWindow::fullscreen_listener));
 
   // connect various
   window->signal_key_press_event()
@@ -301,13 +301,9 @@
 
 // callbacks
 
-void MainWindow::fullscreen_listener(unsigned int,
-				     Gnome::Conf::Entry entry)
+void MainWindow::fullscreen_listener(const Glib::ustring &key)
 {
-  if (entry.get_value().get_type() != Gnome::Conf::VALUE_BOOL)
-    return;
-
-  bool b = entry.get_value().get_bool();
+  bool b = settings->get_boolean(key);
 
   if (b != fullscreen) {
     if (b)
--- monster-masher-1.8.1.orig/src/main-window.hpp
+++ monster-masher-1.8.1/src/main-window.hpp
@@ -30,8 +30,7 @@
 
 #include <sigc++/trackable.h>
 
-#include <gconfmm/client.h>
-#include <gconfmm/entry.h>
+#include <giomm/settings.h>
 
 #include "helpers.hpp"
 #include "vector.hpp"
@@ -67,8 +66,9 @@
   
   Gtk::Window &get_window();
   
-  Glib::RefPtr<Gnome::Conf::Client> gconf_client;
-  const Glib::ustring gconf_dir;
+  Glib::RefPtr<Gio::Settings> settings;
+  Glib::RefPtr<Gio::Settings> p1_settings;
+  Glib::RefPtr<Gio::Settings> p2_settings;
 
 private:
   MainWindow();
@@ -90,7 +90,7 @@
   void calculate_tile_size();
 
   // GConf callbacks
-  void fullscreen_listener(unsigned int, Gnome::Conf::Entry entry);
+  void fullscreen_listener(const Glib::ustring &key);
   
   // callbacks for main menu
   void on_new_game_activated();
--- monster-masher-1.8.1.orig/src/preferences-window.hpp
+++ monster-masher-1.8.1/src/preferences-window.hpp
@@ -27,7 +27,7 @@
 #include <gtkmm/checkbutton.h>
 #include <gtkmm/window.h>
 
-#include <gconfmm/entry.h>
+#include <giomm/settings.h>
 
 #include <sigc++/trackable.h>
 #include <sigc++/connection.h>
@@ -53,14 +53,21 @@
   sigc::connection grab_connection;
 
   bool on_key_press_event(GdkEventKey* event, Gtk::Button *button,
+			  Glib::RefPtr<Gio::Settings> &settings,
 			  Glib::ustring key);
   
-  void setup_button(const Glib::ustring &widget, const Glib::ustring &key);
-  void on_button_pressed(Gtk::Button *button, Glib::ustring key);
-  void button_listener(unsigned int, Gnome::Conf::Entry conf_entry,
-		       Gtk::Button *button);
+  void setup_button(const Glib::ustring &widget,
+                    Glib::RefPtr<Gio::Settings> &settings,
+                    const Glib::ustring &key);
+  void on_button_pressed(Gtk::Button *button,
+                         Glib::RefPtr<Gio::Settings> &settings,
+                         Glib::ustring key);
+  void button_listener(const Glib::ustring &key,
+                       Glib::RefPtr<Gio::Settings> &settings,
+                       Gtk::Button *button);
   void on_fullscreen_toggled();
-  void fullscreen_listener(unsigned int, Gnome::Conf::Entry entry);
+  void fullscreen_listener(const Glib::ustring &key,
+                           Glib::RefPtr<Gio::Settings> &settings);
 
   void on_close_clicked();
   bool on_closed(GdkEventAny *);
--- monster-masher-1.8.1.orig/src/main.cpp
+++ monster-masher-1.8.1/src/main.cpp
@@ -26,20 +26,64 @@
 #include <libintl.h>
 
 #include <libgnomecanvasmm/init.h>
-#include <gconfmm/init.h>
-#include <gtkmm/main.h>
+#include <gtkmm.h>
 
 #include <sigc++/slot.h>
 
 #include "main-window.hpp"
 #include "i18n.hpp"
 
+static void
+migrate_gconf_settings(const Glib::ustring &name)
+{
+  Glib::KeyFile kf;
+  Glib::ustring msg;
+  std::string path;
+  bool needed = true;
+
+  if (!kf.load_from_data_dirs("gsettings-data-convert", path))
+    return;
+
+  Glib::ArrayHandle<Glib::ustring> list
+    = kf.get_string_list("State", "converted");
+
+  for (Glib::ArrayHandle<Glib::ustring>::iterator it = list.begin();
+       it < list.end(); it++)
+    if (!name.compare(*it)) {
+        needed = false;
+        break;
+    }
+
+  if (needed) {
+    Gtk::MessageDialog dialog(_("GConf Migration"));
+
+    try {
+      Glib::spawn_command_line_sync("gsettings-data-convert");
+      msg = _("Old GConf settings were migrated successfully.");
+
+      /* Allow some time for the GSettings backend to record the
+         changes, otherwise the default values from the new schema
+         might be set.  */
+      sleep (1);
+    }
+    catch(const Glib::Error &ex) {
+      msg = Glib::ustring::compose(_("Could not migrate old GConf settings: %1"
+                                     "\nPlease make sure that GConf is "
+                                     "installed and the gsettings-data-convert"
+                                     " tool is in your PATH.\nAlternatively, "
+                                     "ignore this message and convert your "
+                                     "old settings manually."), ex.what());
+    }
+
+    dialog.set_secondary_text(msg);
+    dialog.run();
+  }
+}
 
 int main(int argc, char *argv[])
 {
   Glib::OptionContext ctxt;
   Gtk::Main main(argc, argv, ctxt);
-  Gnome::Conf::init();
   Gnome::Canvas::init();
 
   try {
@@ -50,6 +94,8 @@
 
     g_set_application_name(_("Monster Masher"));
 
+    migrate_gconf_settings("monster-masher.convert");
+
     std::srand(std::time(0));
 
     main.run(MainWindow::instance().get_window());
--- monster-masher-1.8.1.orig/src/player.cpp
+++ monster-masher-1.8.1/src/player.cpp
@@ -167,19 +167,19 @@
   
   if (keyval == lookup_key("left"))
     hero->order_move(make_vector(-1, 0), pull_pressed);
-  if (keyval == lookup_key("left_up"))
+  if (keyval == lookup_key("left-up"))
     hero->order_move(make_vector(-1, -1), pull_pressed);
   if (keyval == lookup_key("up"))
     hero->order_move(make_vector(0, -1), pull_pressed);
-  if (keyval == lookup_key("right_up"))
+  if (keyval == lookup_key("right-up"))
     hero->order_move(make_vector(1, -1), pull_pressed);
   if (keyval == lookup_key("right"))
     hero->order_move(make_vector(1, 0), pull_pressed);
-  if (keyval == lookup_key("right_down"))
+  if (keyval == lookup_key("right-down"))
     hero->order_move(make_vector(1, 1), pull_pressed);
   if (keyval == lookup_key("down"))
     hero->order_move(make_vector(0, 1), pull_pressed);
-  if (keyval == lookup_key("left_down"))
+  if (keyval == lookup_key("left-down"))
     hero->order_move(make_vector(-1, 1), pull_pressed);
 }
 
@@ -191,12 +191,16 @@
 
 unsigned int Player::lookup_key(const Glib::ustring &key)
 {
-  Glib::RefPtr<Gnome::Conf::Client> &client
-    = MainWindow::instance().gconf_client;
+  Glib::RefPtr<Gio::Settings> settings;
+
+  if (player_no == 1)
+    settings = MainWindow::instance().p1_settings;
+  else
+    settings = MainWindow::instance().p2_settings;
+
   Glib::ustring path = 
-    String::ucompose("%1/player%2/%3_key",
-		     MainWindow::instance().gconf_dir, player_no, key);
+    String::ucompose("%1-key", key);
 
-  return gdk_keyval_from_name(client->get_string(path).c_str());
+  return gdk_keyval_from_name(settings->get_string(path).c_str());
 }
 
--- monster-masher-1.8.1.orig/src/preferences-window.cpp
+++ monster-masher-1.8.1/src/preferences-window.cpp
@@ -42,37 +42,42 @@
   // setup fullscreen check button
   ui->get_widget("fullscreen_checkbutton", fullscreen_checkbutton);
   
-  Glib::RefPtr<Gnome::Conf::Client> &client
-    = MainWindow::instance().gconf_client;
-  Glib::ustring dir = MainWindow::instance().gconf_dir;
+  Glib::RefPtr<Gio::Settings> &main
+    = MainWindow::instance().settings;
+  Glib::RefPtr<Gio::Settings> &p1
+    = MainWindow::instance().p1_settings;
+  Glib::RefPtr<Gio::Settings> &p2
+    = MainWindow::instance().p2_settings;
   
-  fullscreen_listener(0, client->get_entry(dir + "/fullscreen"));
+  fullscreen_listener("fullscreen", main);
 
   fullscreen_checkbutton->signal_toggled()
     .connect(sigc::mem_fun(*this, &PreferencesWindow::on_fullscreen_toggled));
-  client->notify_add(dir + "/fullscreen",
-		     sigc::mem_fun(*this, &PreferencesWindow::fullscreen_listener));
+  main->signal_changed()
+    .connect(sigc::bind(sigc::mem_fun(*this,
+                                      &PreferencesWindow::fullscreen_listener),
+                        main));
   
   // setup player keys
-  setup_button("player1_left", "/player1/left_key");
-  setup_button("player1_left_up", "/player1/left_up_key");
-  setup_button("player1_up", "/player1/up_key");
-  setup_button("player1_right_up", "/player1/right_up_key");
-  setup_button("player1_right", "/player1/right_key");
-  setup_button("player1_right_down", "/player1/right_down_key");
-  setup_button("player1_down", "/player1/down_key");
-  setup_button("player1_left_down", "/player1/left_down_key");
-  setup_button("player1_pull_block", "/player1/pull_key");
-
-  setup_button("player2_left", "/player2/left_key");
-  setup_button("player2_left_up", "/player2/left_up_key");
-  setup_button("player2_up", "/player2/up_key");
-  setup_button("player2_right_up", "/player2/right_up_key");
-  setup_button("player2_right", "/player2/right_key");
-  setup_button("player2_right_down", "/player2/right_down_key");
-  setup_button("player2_down", "/player2/down_key");
-  setup_button("player2_left_down", "/player2/left_down_key");
-  setup_button("player2_pull_block", "/player2/pull_key");
+  setup_button("player1_left", p1, "left-key");
+  setup_button("player1_left_up", p1, "left-up-key");
+  setup_button("player1_up", p1, "up-key");
+  setup_button("player1_right_up", p1, "right-up-key");
+  setup_button("player1_right", p1, "right-key");
+  setup_button("player1_right_down", p1, "right-down-key");
+  setup_button("player1_down", p1, "down-key");
+  setup_button("player1_left_down", p1, "left-down-key");
+  setup_button("player1_pull_block", p1, "pull-key");
+
+  setup_button("player2_left", p2, "left-key");
+  setup_button("player2_left_up", p2, "left-up-key");
+  setup_button("player2_up", p2, "up-key");
+  setup_button("player2_right_up", p2, "right-up-key");
+  setup_button("player2_right", p2, "right-key");
+  setup_button("player2_right_down", p2, "right-down-key");
+  setup_button("player2_down", p2, "down-key");
+  setup_button("player2_left_down", p2, "left-down-key");
+  setup_button("player2_pull_block", p2, "pull-key");
 
   Gtk::Button *button;
   ui->get_widget("close_button", button);
@@ -100,47 +105,42 @@
 }
 
 void PreferencesWindow::setup_button(const Glib::ustring &widget,
+				     Glib::RefPtr<Gio::Settings> &settings,
 				     const Glib::ustring &key)
 {
-  Glib::RefPtr<Gnome::Conf::Client> &client
-    = MainWindow::instance().gconf_client;
-  Glib::ustring dir = MainWindow::instance().gconf_dir;
-
   Gtk::Button *button;
   
   ui->get_widget(widget, button);
   button->set_use_underline(false);
-  button->set_label(client->get_string(dir + key));
+  button->set_label(settings->get_string(key));
   button->signal_clicked()
     .connect(sigc::bind(sigc::mem_fun(*this,
 				   &PreferencesWindow::on_button_pressed),
-			button, key));
-  client->notify_add(dir + key,
-		     sigc::bind(sigc::mem_fun(*this, &PreferencesWindow
-					   ::button_listener),
-				button));
+                        button, settings, key));
+  settings->signal_changed(key)
+    .connect(sigc::bind(sigc::mem_fun(*this,
+                                      &PreferencesWindow::button_listener),
+                        settings, button));
 }
 
 
 bool PreferencesWindow::on_key_press_event(GdkEventKey* event,
 					   Gtk::Button *button,
+					   Glib::RefPtr<Gio::Settings> &settings,
 					   Glib::ustring key)
 {
-  Glib::RefPtr<Gnome::Conf::Client> &client
-    = MainWindow::instance().gconf_client;
-  Glib::ustring dir = MainWindow::instance().gconf_dir;
-
   grab_connection.disconnect();
   button->remove_modal_grab();
 
   Glib::ustring name = gdk_keyval_name(event->keyval);
   button->set_label(name);
-  client->set(dir + key, name);
+  settings->set_string(key, name);
 
   return true;
 }
 
 void PreferencesWindow::on_button_pressed(Gtk::Button *button,
+					  Glib::RefPtr<Gio::Settings> &settings,
 					  Glib::ustring key)
 {
   button->set_label("   ");
@@ -149,14 +149,14 @@
   grab_connection = button->signal_key_press_event()
     .connect(sigc::bind(sigc::mem_fun(*this, &PreferencesWindow
 				   ::on_key_press_event),
-			button, key));
+	                button, settings, key));
 }
 
-void PreferencesWindow::button_listener(unsigned int,
-					Gnome::Conf::Entry conf_entry,
+void PreferencesWindow::button_listener(const Glib::ustring &key,
+					Glib::RefPtr<Gio::Settings> &settings,
 					Gtk::Button *button)
 {
-  button->set_label(conf_entry.get_value().get_string());
+  button->set_label(settings->get_string(key));
 }
 
 
@@ -164,20 +164,16 @@
 {
   bool b = fullscreen_checkbutton->get_active();
   
-  Glib::RefPtr<Gnome::Conf::Client> &client
-    = MainWindow::instance().gconf_client;
-  Glib::ustring dir = MainWindow::instance().gconf_dir;
+  Glib::RefPtr<Gio::Settings> &main
+    = MainWindow::instance().settings;
 
-  client->set(dir + "/fullscreen", b);
+  main->set_boolean("fullscreen", b);
 }
 
-void PreferencesWindow::fullscreen_listener(unsigned int,
-					    Gnome::Conf::Entry entry)
+void PreferencesWindow::fullscreen_listener(const Glib::ustring &key,
+					    Glib::RefPtr<Gio::Settings> &settings)
 {
-  if (entry.get_value().get_type() != Gnome::Conf::VALUE_BOOL)
-    return;
-  
-  bool b = entry.get_value().get_bool();
+  bool b = settings->get_boolean(key);
   if (fullscreen_checkbutton->get_active() != b)
     fullscreen_checkbutton->set_active(b);
 }
--- monster-masher-1.8.1.orig/monster-masher.schemas.in
+++ /dev/null
@@ -1,214 +0,0 @@
-<?xml version="1.0"?>
-<gconfschemafile>
-  <schemalist>
-    <schema>
-      <key>/schemas/apps/monster-masher/fullscreen</key>
-      <applyto>/apps/monster-masher/fullscreen</applyto>
-      <owner>monster-masher</owner>
-      <type>bool</type>
-      <default>true</default>
-      <locale name="C">
-        <short>Use fullscreen</short>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/apps/monster-masher/player1/left_key</key>
-      <applyto>/apps/monster-masher/player1/left_key</applyto>
-      <owner>monster-masher</owner>
-      <type>string</type>
-      <default>KP_Left</default>
-      <locale name="C">
-        <short>Key for moving to the left</short>
-        <long>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/apps/monster-masher/player1/left_up_key</key>
-      <applyto>/apps/monster-masher/player1/left_up_key</applyto>
-      <owner>monster-masher</owner>
-      <type>string</type>
-      <default>KP_Home</default>
-      <locale name="C">
-        <short>Key for moving to the left and up</short>
-        <long>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/apps/monster-masher/player1/up_key</key>
-      <applyto>/apps/monster-masher/player1/up_key</applyto>
-      <owner>monster-masher</owner>
-      <type>string</type>
-      <default>KP_Up</default>
-      <locale name="C">
-        <short>Key for moving up</short>
-        <long>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/apps/monster-masher/player1/right_up_key</key>
-      <applyto>/apps/monster-masher/player1/right_up_key</applyto>
-      <owner>monster-masher</owner>
-      <type>string</type>
-      <default>KP_Page_Up</default>
-      <locale name="C">
-        <short>Key for moving to the right and up</short>
-        <long>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/apps/monster-masher/player1/right_key</key>
-      <applyto>/apps/monster-masher/player1/right_key</applyto>
-      <owner>monster-masher</owner>
-      <type>string</type>
-      <default>KP_Right</default>
-      <locale name="C">
-        <short>Key for moving to the right</short>
-        <long>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/apps/monster-masher/player1/right_down_key</key>
-      <applyto>/apps/monster-masher/player1/right_down_key</applyto>
-      <owner>monster-masher</owner>
-      <type>string</type>
-      <default>KP_Page_Down</default>
-      <locale name="C">
-        <short>Key for moving to the right and down</short>
-        <long>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/apps/monster-masher/player1/down_key</key>
-      <applyto>/apps/monster-masher/player1/down_key</applyto>
-      <owner>monster-masher</owner>
-      <type>string</type>
-      <default>KP_Down</default>
-      <locale name="C">
-        <short>Key for moving down</short>
-        <long>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/apps/monster-masher/player1/left_down_key</key>
-      <applyto>/apps/monster-masher/player1/left_down_key</applyto>
-      <owner>monster-masher</owner>
-      <type>string</type>
-      <default>KP_End</default>
-      <locale name="C">
-        <short>Key for moving to the left and down</short>
-        <long>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/apps/monster-masher/player1/pull_key</key>
-      <applyto>/apps/monster-masher/player1/pull_key</applyto>
-      <owner>monster-masher</owner>
-      <type>string</type>
-      <default>Control_R</default>
-      <locale name="C">
-        <short>Key for activating pulling of blocks</short>
-        <long>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</long>
-      </locale>
-    </schema>
-    
-    <schema>
-      <key>/schemas/apps/monster-masher/player2/left_key</key>
-      <applyto>/apps/monster-masher/player2/left_key</applyto>
-      <owner>monster-masher</owner>
-      <type>string</type>
-      <default>d</default>
-      <locale name="C">
-        <short>Key for moving to the left</short>
-        <long>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/apps/monster-masher/player2/left_up_key</key>
-      <applyto>/apps/monster-masher/player2/left_up_key</applyto>
-      <owner>monster-masher</owner>
-      <type>string</type>
-      <default>e</default>
-      <locale name="C">
-        <short>Key for moving to the left and up</short>
-        <long>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/apps/monster-masher/player2/up_key</key>
-      <applyto>/apps/monster-masher/player2/up_key</applyto>
-      <owner>monster-masher</owner>
-      <type>string</type>
-      <default>r</default>
-      <locale name="C">
-        <short>Key for moving up</short>
-        <long>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/apps/monster-masher/player2/right_up_key</key>
-      <applyto>/apps/monster-masher/player2/right_up_key</applyto>
-      <owner>monster-masher</owner>
-      <type>string</type>
-      <default>t</default>
-      <locale name="C">
-        <short>Key for moving to the right and up</short>
-        <long>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/apps/monster-masher/player2/right_key</key>
-      <applyto>/apps/monster-masher/player2/right_key</applyto>
-      <owner>monster-masher</owner>
-      <type>string</type>
-      <default>g</default>
-      <locale name="C">
-        <short>Key for moving to the right</short>
-        <long>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/apps/monster-masher/player2/right_down_key</key>
-      <applyto>/apps/monster-masher/player2/right_down_key</applyto>
-      <owner>monster-masher</owner>
-      <type>string</type>
-      <default>b</default>
-      <locale name="C">
-        <short>Key for moving to the right and down</short>
-        <long>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/apps/monster-masher/player2/down_key</key>
-      <applyto>/apps/monster-masher/player2/down_key</applyto>
-      <owner>monster-masher</owner>
-      <type>string</type>
-      <default>v</default>
-      <locale name="C">
-        <short>Key for moving down</short>
-        <long>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/apps/monster-masher/player2/left_down_key</key>
-      <applyto>/apps/monster-masher/player2/left_down_key</applyto>
-      <owner>monster-masher</owner>
-      <type>string</type>
-      <default>c</default>
-      <locale name="C">
-        <short>Key for moving to the left and down</short>
-        <long>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/apps/monster-masher/player2/pull_key</key>
-      <applyto>/apps/monster-masher/player2/pull_key</applyto>
-      <owner>monster-masher</owner>
-      <type>string</type>
-      <default>Control_L</default>
-      <locale name="C">
-        <short>Key for activating pulling of blocks</short>
-        <long>The string should be the GDK name of the key value to use (can be found in gdk/gdkkeynames.c).</long>
-      </locale>
-    </schema>
-  </schemalist>
-</gconfschemafile>
--- monster-masher-1.8.1.orig/po/POTFILES.in
+++ monster-masher-1.8.1/po/POTFILES.in
@@ -9,4 +9,4 @@
 src/ui.glade
 
 monster-masher.desktop.in
-monster-masher.schemas.in
+[type: gettext/gsettings]dk.iola.olau.monster-masher.gschema.xml


More information about the Pkg-games-devel mailing list