[gbrainy] Use Builder instead of Glade
- From: Jordi Mas <jmas src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gbrainy] Use Builder instead of Glade
- Date: Sat, 9 Jan 2010 17:03:24 +0000 (UTC)
commit c9347913680bf1207de283e6ab8c118230116eab
Author: Jordi Mas <jmas softcatala org>
Date: Sat Jan 9 18:03:42 2010 +0100
Use Builder instead of Glade
configure.ac | 3 +-
po/POTFILES.in | 6 +-
po/POTFILES.skip | 2 +-
src/Clients/Classical/Builder/Builder.cs | 621 ++++++++++
.../Classical/Builder/BuilderConnectFunc.cs | 10 +
.../GtkBeansSharp.BuilderConnectFuncNative.cs | 96 ++
src/Clients/Classical/Builder/ObjectManager.cs | 19 +
.../Dialogs/{GtkDialog.cs => BuilderDialog.cs} | 33 +-
src/Clients/Classical/Dialogs/CustomGameDialog.cs | 10 +-
.../Classical/Dialogs/PlayerHistoryDialog.cs | 18 +-
src/Clients/Classical/Dialogs/PreferencesDialog.cs | 20 +-
.../Classical/Dialogs/ui/CustomGameDialog.ui | 185 +++
.../Classical/Dialogs/ui/PlayerHistoryDialog.ui | 182 +++
.../Classical/Dialogs/ui/PreferencesDialog.ui | 406 +++++++
src/Clients/Classical/Makefile.am | 35 +-
src/Clients/Classical/gbrainy.cs | 67 +-
src/Clients/Classical/gbrainy.glade | 1192 --------------------
src/Clients/Classical/gbrainy.ui | 473 ++++++++
18 files changed, 2094 insertions(+), 1284 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3039a49..a08bb37 100644
--- a/configure.ac
+++ b/configure.ac
@@ -64,8 +64,7 @@ PKG_CHECK_MODULES(GBRAINY_CORE, mono >= $MONO_REQUIRED)
PKG_CHECK_MODULES(GBRAINY,
gtk-sharp-2.0 >= $GTKSHARP_REQUIRED
- gnome-sharp-2.0 >= $GTKSHARP_REQUIRED
- glade-sharp-2.0 >= $GTKSHARP_REQUIRED)
+ gnome-sharp-2.0 >= $GTKSHARP_REQUIRED)
AC_SUBST(GBRAINY_LIBS)
AC_ARG_ENABLE(addins, AC_HELP_STRING([--disable-addins], [Disable mono-addins support]), , enable_addins="yes")
diff --git a/po/POTFILES.in b/po/POTFILES.in
index fc07858..21027c1 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -24,9 +24,11 @@ src/Core/Main/Verbal/AnalogiesFactory.cs
src/Clients/Classical/gbrainy.cs
src/Clients/Classical/Dialogs/AboutDialog.cs
src/Clients/Classical/Dialogs/CustomGameDialog.cs
-src/Clients/Classical/Dialogs/GtkDialog.cs
src/Clients/Classical/Dialogs/PlayerHistoryDialog.cs
src/Clients/Classical/Dialogs/PreferencesDialog.cs
+src/Clients/Classical/Dialogs/ui/CustomGameDialog.ui
+src/Clients/Classical/Dialogs/ui/PlayerHistoryDialog.ui
+src/Clients/Classical/Dialogs/ui/PreferencesDialog.ui
src/Games/Logic/Puzzle3DCube.cs
src/Games/Logic/PuzzleBalance.cs
src/Games/Logic/PuzzleBuildTriangle.cs
@@ -90,5 +92,5 @@ src/Games/Calculation/CalculationPrimes.cs
src/Games/Calculation/CalculationProportions.cs
src/Games/Calculation/CalculationRatio.cs
src/Games/Calculation/CalculationTwoNumbers.cs
-src/Clients/Classical/gbrainy.glade
+src/Clients/Classical/gbrainy.ui
src/Clients/Classical/mono-addins-strings.xml
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 139597f..73fae6e 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -1,2 +1,2 @@
-
+src/Clients/Classical/Builder/Builder.cs
diff --git a/src/Clients/Classical/Builder/Builder.cs b/src/Clients/Classical/Builder/Builder.cs
new file mode 100644
index 0000000..894ed49
--- /dev/null
+++ b/src/Clients/Classical/Builder/Builder.cs
@@ -0,0 +1,621 @@
+// This file was generated by the Gtk# code generator.
+// Any changes made will be lost if regenerated.
+
+namespace GtkBeans {
+
+ using System;
+ using System.Collections;
+ using System.Runtime.InteropServices;
+
+#region Autogenerated code
+ public class Builder : GLib.Object {
+
+ [Obsolete]
+ protected Builder(GLib.GType gtype) : base(gtype) {}
+ public Builder(IntPtr raw) : base(raw) {}
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern IntPtr gtk_builder_new();
+
+ public Builder () : base (IntPtr.Zero)
+ {
+ if (GetType () != typeof (Builder)) {
+ CreateNativeObject (new string [0], new GLib.Value[0]);
+ return;
+ }
+ Raw = gtk_builder_new();
+ }
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern IntPtr gtk_builder_get_translation_domain(IntPtr raw);
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern void gtk_builder_set_translation_domain(IntPtr raw, IntPtr domain);
+
+ [GLib.Property ("translation-domain")]
+ public string TranslationDomain {
+ get {
+ IntPtr raw_ret = gtk_builder_get_translation_domain(Handle);
+ string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
+ return ret;
+ }
+ set {
+ IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
+ gtk_builder_set_translation_domain(Handle, native_value);
+ GLib.Marshaller.Free (native_value);
+ }
+ }
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern unsafe bool gtk_builder_value_from_string(IntPtr raw, IntPtr pspec, IntPtr str1ng, IntPtr value, out IntPtr error);
+
+ public unsafe bool ValueFromString(IntPtr pspec, string str1ng, GLib.Value value) {
+ IntPtr native_str1ng = GLib.Marshaller.StringToPtrGStrdup (str1ng);
+ IntPtr native_value = GLib.Marshaller.StructureToPtrAlloc (value);
+ IntPtr error = IntPtr.Zero;
+ bool raw_ret = gtk_builder_value_from_string(Handle, pspec, native_str1ng, native_value, out error);
+ bool ret = raw_ret;
+ GLib.Marshaller.Free (native_str1ng);
+ value = (GLib.Value) Marshal.PtrToStructure (native_value, typeof (GLib.Value));
+ Marshal.FreeHGlobal (native_value);
+ if (error != IntPtr.Zero) throw new GLib.GException (error);
+ return ret;
+ }
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern void gtk_builder_connect_signals_full(IntPtr raw, GtkBeansSharp.BuilderConnectFuncNative func, IntPtr user_data);
+
+ public void ConnectSignalsFull(GtkBeans.BuilderConnectFunc func) {
+ GtkBeansSharp.BuilderConnectFuncWrapper func_wrapper = new GtkBeansSharp.BuilderConnectFuncWrapper (func);
+ gtk_builder_connect_signals_full(Handle, func_wrapper.NativeDelegate, IntPtr.Zero);
+ }
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern IntPtr gtk_builder_get_type_from_name(IntPtr raw, IntPtr type_name);
+
+ public GLib.GType GetTypeFromName(string type_name) {
+ IntPtr native_type_name = GLib.Marshaller.StringToPtrGStrdup (type_name);
+ IntPtr raw_ret = gtk_builder_get_type_from_name(Handle, native_type_name);
+ GLib.GType ret = new GLib.GType(raw_ret);
+ GLib.Marshaller.Free (native_type_name);
+ return ret;
+ }
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern unsafe uint gtk_builder_add_from_string(IntPtr raw, IntPtr buffer, UIntPtr length, out IntPtr error);
+
+ public unsafe uint AddFromString(string buffer) {
+ IntPtr native_buffer = GLib.Marshaller.StringToPtrGStrdup (buffer);
+ IntPtr error = IntPtr.Zero;
+ uint raw_ret = gtk_builder_add_from_string(Handle, native_buffer, new UIntPtr ((ulong) System.Text.Encoding.UTF8.GetByteCount (buffer)), out error);
+ uint ret = raw_ret;
+ GLib.Marshaller.Free (native_buffer);
+ if (error != IntPtr.Zero) throw new GLib.GException (error);
+ return ret;
+ }
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern unsafe uint gtk_builder_add_objects_from_string(IntPtr raw, IntPtr buffer, UIntPtr length, IntPtr object_ids, out IntPtr error);
+
+ public unsafe uint AddObjectsFromString(string buffer, string object_ids) {
+ IntPtr native_buffer = GLib.Marshaller.StringToPtrGStrdup (buffer);
+ IntPtr error = IntPtr.Zero;
+ uint raw_ret = gtk_builder_add_objects_from_string(Handle, native_buffer, new UIntPtr ((ulong) System.Text.Encoding.UTF8.GetByteCount (buffer)), GLib.Marshaller.StringToPtrGStrdup(object_ids), out error);
+ uint ret = raw_ret;
+ GLib.Marshaller.Free (native_buffer);
+ if (error != IntPtr.Zero) throw new GLib.GException (error);
+ return ret;
+ }
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern unsafe uint gtk_builder_add_from_file(IntPtr raw, IntPtr filename, out IntPtr error);
+
+ public unsafe uint AddFromFile(string filename) {
+ IntPtr native_filename = GLib.Marshaller.StringToPtrGStrdup (filename);
+ IntPtr error = IntPtr.Zero;
+ uint raw_ret = gtk_builder_add_from_file(Handle, native_filename, out error);
+ uint ret = raw_ret;
+ GLib.Marshaller.Free (native_filename);
+ if (error != IntPtr.Zero) throw new GLib.GException (error);
+ return ret;
+ }
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern unsafe bool gtk_builder_value_from_string_type(IntPtr raw, IntPtr type, IntPtr str1ng, IntPtr value, out IntPtr error);
+
+ public unsafe bool ValueFromStringType(GLib.GType type, string str1ng, GLib.Value value) {
+ IntPtr native_str1ng = GLib.Marshaller.StringToPtrGStrdup (str1ng);
+ IntPtr native_value = GLib.Marshaller.StructureToPtrAlloc (value);
+ IntPtr error = IntPtr.Zero;
+ bool raw_ret = gtk_builder_value_from_string_type(Handle, type.Val, native_str1ng, native_value, out error);
+ bool ret = raw_ret;
+ GLib.Marshaller.Free (native_str1ng);
+ value = (GLib.Value) Marshal.PtrToStructure (native_value, typeof (GLib.Value));
+ Marshal.FreeHGlobal (native_value);
+ if (error != IntPtr.Zero) throw new GLib.GException (error);
+ return ret;
+ }
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern IntPtr gtk_builder_get_objects(IntPtr raw);
+
+ public GLib.SList Objects {
+ get {
+ IntPtr raw_ret = gtk_builder_get_objects(Handle);
+ GLib.SList ret = new GLib.SList(raw_ret);
+ return ret;
+ }
+ }
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern IntPtr gtk_builder_get_object(IntPtr raw, IntPtr name);
+
+ public GLib.Object GetObject(string name) {
+ IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
+ IntPtr raw_ret = gtk_builder_get_object(Handle, native_name);
+ GLib.Object ret = GLib.Object.GetObject (raw_ret);
+ GLib.Marshaller.Free (native_name);
+ return ret;
+ }
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern int gtk_builder_error_quark();
+
+ public static int ErrorQuark() {
+ int raw_ret = gtk_builder_error_quark();
+ int ret = raw_ret;
+ return ret;
+ }
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern void gtk_builder_connect_signals(IntPtr raw, IntPtr user_data);
+
+ public void ConnectSignals(IntPtr user_data) {
+ gtk_builder_connect_signals(Handle, user_data);
+ }
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern IntPtr gtk_builder_get_type();
+
+ public static new GLib.GType GType {
+ get {
+ IntPtr raw_ret = gtk_builder_get_type();
+ GLib.GType ret = new GLib.GType(raw_ret);
+ return ret;
+ }
+ }
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern unsafe uint gtk_builder_add_objects_from_file(IntPtr raw, IntPtr filename, IntPtr object_ids, out IntPtr error);
+
+ public unsafe uint AddObjectsFromFile(string filename, string object_ids) {
+ IntPtr native_filename = GLib.Marshaller.StringToPtrGStrdup (filename);
+ IntPtr error = IntPtr.Zero;
+ uint raw_ret = gtk_builder_add_objects_from_file(Handle, native_filename, GLib.Marshaller.StringToPtrGStrdup(object_ids), out error);
+ uint ret = raw_ret;
+ GLib.Marshaller.Free (native_filename);
+ if (error != IntPtr.Zero) throw new GLib.GException (error);
+ return ret;
+ }
+
+
+ static Builder ()
+ {
+ GtkSharp.GtkbeansSharp.ObjectManager.Initialize ();
+ }
+#endregion
+#region Customized extensions
+#line 1 "Builder.custom"
+// Builder.custom - customizations to Gtk.Builder
+//
+// Authors: Stephane Delcroix <stephane delcroix org>
+// The biggest part of this code is adapted from glade#, by
+// Ricardo Fernández Pascual <ric users sourceforge net>
+// Rachel Hestilow <hestilow ximian com>
+//
+// Copyright (c) 2008, 2009 Novell, Inc.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of version 2 of the Lesser GNU General
+// Public License as published by the Free Software Foundation.
+//
+// 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the
+// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+[System.Serializable]
+public class HandlerNotFoundException : SystemException
+{
+ string handler_name;
+ string signal_name;
+ System.Reflection.EventInfo evnt;
+ Type delegate_type;
+
+ public HandlerNotFoundException (string handler_name, string signal_name,
+ System.Reflection.EventInfo evnt, Type delegate_type)
+ : this (handler_name, signal_name, evnt, delegate_type, null)
+ {
+ }
+
+ public HandlerNotFoundException (string handler_name, string signal_name,
+ System.Reflection.EventInfo evnt, Type delegate_type, Exception inner)
+ : base ("No handler " + handler_name + " found for signal " + signal_name,
+ inner)
+ {
+ this.handler_name = handler_name;
+ this.signal_name = signal_name;
+ this.evnt = evnt;
+ this.delegate_type = delegate_type;
+ }
+
+ public HandlerNotFoundException (string message, string handler_name, string signal_name,
+ System.Reflection.EventInfo evnt, Type delegate_type)
+ : base ((message != null) ? message : "No handler " + handler_name + " found for signal " + signal_name,
+ null)
+ {
+ this.handler_name = handler_name;
+ this.signal_name = signal_name;
+ this.evnt = evnt;
+ this.delegate_type = delegate_type;
+ }
+
+ protected HandlerNotFoundException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
+ : base (info, context)
+ {
+ handler_name = info.GetString ("HandlerName");
+ signal_name = info.GetString ("SignalName");
+ evnt = info.GetValue ("Event", typeof (System.Reflection.EventInfo)) as System.Reflection.EventInfo;
+ delegate_type = info.GetValue ("DelegateType", typeof (Type)) as Type;
+ }
+
+ public string HandlerName
+ {
+ get {
+ return handler_name;
+ }
+ }
+
+ public string SignalName
+ {
+ get {
+ return signal_name;
+ }
+ }
+
+ public System.Reflection.EventInfo Event
+ {
+ get {
+ return evnt;
+ }
+ }
+
+ public Type DelegateType
+ {
+ get {
+ return delegate_type;
+ }
+ }
+
+ public override void GetObjectData (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
+ {
+ base.GetObjectData (info, context);
+ info.AddValue ("HandlerName", handler_name);
+ info.AddValue ("SignalName", signal_name);
+ info.AddValue ("Event", evnt);
+ info.AddValue ("DelegateType", delegate_type);
+ }
+}
+
+
+[AttributeUsage (AttributeTargets.Field)]
+public class ObjectAttribute : Attribute
+{
+ private string name;
+ private bool specified;
+
+ public ObjectAttribute (string name)
+ {
+ specified = true;
+ this.name = name;
+ }
+
+ public ObjectAttribute ()
+ {
+ specified = false;
+ }
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ public bool Specified
+ {
+ get { return specified; }
+ }
+}
+
+public IntPtr GetRawObject(string name) {
+ IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
+ IntPtr raw_ret = gtk_builder_get_object(Handle, native_name);
+ GLib.Marshaller.Free (native_name);
+ return raw_ret;
+}
+
+public Builder (System.IO.Stream s) : this (s, null)
+{
+}
+
+public Builder (System.IO.Stream s, string translation_domain)
+{
+ if (s == null)
+ throw new ArgumentNullException ("s");
+
+ int size = (int) s.Length;
+ byte[] buffer = new byte[size];
+ s.Read (buffer, 0, size);
+ s.Close ();
+
+ AddFromString(System.Text.Encoding.UTF8.GetString (buffer));
+
+ TranslationDomain = translation_domain;
+}
+
+public Builder (string resource_name) : this (resource_name, null)
+{
+}
+
+public Builder (string resource_name, string translation_domain) : this (System.Reflection.Assembly.GetEntryAssembly (), resource_name, translation_domain)
+{
+}
+
+public Builder (System.Reflection.Assembly assembly, string resource_name, string translation_domain) : this ()
+{
+ if (GetType() != typeof (Builder))
+ throw new InvalidOperationException ("Cannot chain to this constructor from subclasses.");
+
+ if (assembly == null)
+ assembly = System.Reflection.Assembly.GetCallingAssembly ();
+
+ System.IO.Stream s = assembly.GetManifestResourceStream (resource_name);
+ if (s == null)
+ throw new ArgumentException ("Cannot get resource file '" + resource_name + "'",
+ "resource_name");
+
+ int size = (int) s.Length;
+ byte[] buffer = new byte[size];
+ s.Read (buffer, 0, size);
+ s.Close ();
+
+ AddFromString(System.Text.Encoding.UTF8.GetString (buffer));
+
+ TranslationDomain = translation_domain;
+}
+
+public void Autoconnect (object handler)
+{
+ BindFields (handler);
+ (new SignalConnector (this, handler)).ConnectSignals ();
+}
+
+public void Autoconnect (Type handler_class)
+{
+ BindFields (handler_class);
+ (new SignalConnector (this, handler_class)).ConnectSignals ();
+}
+
+class SignalConnector
+{
+ Builder builder;
+ Type handler_type;
+ object handler;
+
+ public SignalConnector (Builder builder, object handler)
+ {
+ this.builder = builder;
+ this.handler = handler;
+ handler_type = handler.GetType ();
+ }
+
+ public SignalConnector (Builder builder, Type handler_type)
+ {
+ this.builder = builder;
+ this.handler = null;
+ this.handler_type = handler_type;
+ }
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern void gtk_builder_connect_signals_full(IntPtr raw, GtkBeansSharp.BuilderConnectFuncNative func, IntPtr user_data);
+
+ public void ConnectSignals() {
+ GtkBeansSharp.BuilderConnectFuncWrapper func_wrapper = new GtkBeansSharp.BuilderConnectFuncWrapper (new GtkBeans.BuilderConnectFunc (ConnectFunc));
+ gtk_builder_connect_signals_full(builder.Handle, func_wrapper.NativeDelegate, IntPtr.Zero);
+ }
+
+ public void ConnectFunc (Builder builder, GLib.Object objekt, string signal_name, string handler_name, GLib.Object connect_object, GLib.ConnectFlags flags)
+ {
+ /* search for the event to connect */
+ System.Reflection.MemberInfo[] evnts = objekt.GetType ().
+ FindMembers (System.Reflection.MemberTypes.Event,
+ System.Reflection.BindingFlags.Instance
+ | System.Reflection.BindingFlags.Static
+ | System.Reflection.BindingFlags.Public
+ | System.Reflection.BindingFlags.NonPublic,
+ new System.Reflection.MemberFilter (SignalFilter), signal_name);
+ foreach (System.Reflection.EventInfo ei in evnts) {
+ bool connected = false;
+ System.Reflection.MethodInfo add = ei.GetAddMethod ();
+ System.Reflection.ParameterInfo[] addpi = add.GetParameters ();
+ if (addpi.Length == 1) { /* this should be always true, unless there's something broken */
+ Type delegate_type = addpi[0].ParameterType;
+
+ /* look for an instance method */
+ if (connect_object != null || handler != null)
+ try {
+ Delegate d = Delegate.CreateDelegate (delegate_type, connect_object != null ? connect_object : handler, handler_name);
+ add.Invoke (objekt, new object[] { d } );
+ connected = true;
+ } catch (ArgumentException) { /* ignore if there is not such instance method */
+ }
+
+ /* look for a static method if no instance method has been found */
+ if (!connected && handler_type != null)
+ try {
+ Delegate d = Delegate.CreateDelegate (delegate_type, handler_type, handler_name);
+ add.Invoke (objekt, new object[] { d } );
+ connected = true;
+ } catch (ArgumentException) { /* ignore if there is not such static method */
+ }
+
+ if (!connected) {
+ string msg = ExplainError (ei.Name, delegate_type, handler_type, handler_name);
+ throw new HandlerNotFoundException (msg, handler_name, signal_name, ei, delegate_type);
+ }
+ }
+ }
+ }
+
+ static bool SignalFilter (System.Reflection.MemberInfo m, object filterCriteria)
+ {
+ string signame = (filterCriteria as string);
+ object[] attrs = m.GetCustomAttributes (typeof (GLib.SignalAttribute), false);
+ if (attrs.Length > 0)
+ {
+ foreach (GLib.SignalAttribute a in attrs)
+ {
+ if (signame == a.CName)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ else
+ {
+ /* this tries to match the names when no attibutes are present.
+ It is only a fallback. */
+ signame = signame.ToLower ().Replace ("_", "");
+ string evname = m.Name.ToLower ();
+ return signame == evname;
+ }
+ }
+
+ static string GetSignature (System.Reflection.MethodInfo method)
+ {
+ if (method == null)
+ return null;
+
+ System.Reflection.ParameterInfo [] parameters = method.GetParameters ();
+ System.Text.StringBuilder sb = new System.Text.StringBuilder ();
+ sb.Append ('(');
+ foreach (System.Reflection.ParameterInfo info in parameters) {
+ sb.Append (info.ParameterType.ToString ());
+ sb.Append (',');
+ }
+ if (sb.Length != 0)
+ sb.Length--;
+
+ sb.Append (')');
+ return sb.ToString ();
+ }
+
+ static string GetSignature (Type delegate_type)
+ {
+ System.Reflection.MethodInfo method = delegate_type.GetMethod ("Invoke");
+ return GetSignature (method);
+ }
+
+ const System.Reflection.BindingFlags flags = System.Reflection.BindingFlags.NonPublic |
+ System.Reflection.BindingFlags.Public |
+ System.Reflection.BindingFlags.Static |
+ System.Reflection.BindingFlags.Instance;
+ static string GetSignature (Type klass, string method_name)
+ {
+ try {
+ System.Reflection.MethodInfo method = klass.GetMethod (method_name, flags);
+ return GetSignature (method);
+ } catch {
+ // May be more than one method with that name and none matches
+ return null;
+ }
+ }
+
+
+ static string ExplainError (string event_name, Type deleg, Type klass, string method)
+ {
+ if (deleg == null || klass == null || method == null)
+ return null;
+
+ System.Text.StringBuilder sb = new System.Text.StringBuilder ();
+ string expected = GetSignature (deleg);
+ string actual = GetSignature (klass, method);
+ if (actual == null)
+ return null;
+ sb.AppendFormat ("The handler for the event {0} should take '{1}', " +
+ "but the signature of the provided handler ('{2}') is '{3}'\n",
+ event_name, expected, method, actual);
+ return sb.ToString ();
+ }
+
+}
+
+
+void BindFields (object target)
+{
+ BindFields (target, target.GetType ());
+}
+
+void BindFields (Type type)
+{
+ BindFields (null, type);
+}
+
+void BindFields (object target, Type type)
+{
+ System.Reflection.BindingFlags flags = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.DeclaredOnly;
+ if (target != null)
+ flags |= System.Reflection.BindingFlags.Instance;
+ else
+ flags |= System.Reflection.BindingFlags.Static;
+
+ do {
+ System.Reflection.FieldInfo[] fields = type.GetFields (flags);
+ if (fields == null)
+ return;
+
+ foreach (System.Reflection.FieldInfo field in fields)
+ {
+ object[] attrs = field.GetCustomAttributes (typeof (ObjectAttribute), false);
+ if (attrs == null || attrs.Length == 0)
+ continue;
+ // The widget to field binding must be 1:1, so only check
+ // the first attribute.
+ ObjectAttribute attr = (ObjectAttribute) attrs[0];
+ GLib.Object gobject;
+ if (attr.Specified)
+ gobject = GetObject (attr.Name);
+ else
+ gobject = GetObject (field.Name);
+
+ if (gobject != null)
+ try {
+ field.SetValue (target, gobject, flags, null, null);
+ } catch (Exception e) {
+ Console.WriteLine ("Unable to set value for field " + field.Name);
+ throw e;
+ }
+ }
+ type = type.BaseType;
+ }
+ while (type != typeof(object) && type != null);
+}
+
+#endregion
+ }
+}
diff --git a/src/Clients/Classical/Builder/BuilderConnectFunc.cs b/src/Clients/Classical/Builder/BuilderConnectFunc.cs
new file mode 100644
index 0000000..ae4b40e
--- /dev/null
+++ b/src/Clients/Classical/Builder/BuilderConnectFunc.cs
@@ -0,0 +1,10 @@
+// This file was generated by the Gtk# code generator.
+// Any changes made will be lost if regenerated.
+
+namespace GtkBeans {
+
+ using System;
+
+ public delegate void BuilderConnectFunc(GtkBeans.Builder builder, GLib.Object objekt, string signal_name, string handler_name, GLib.Object connect_object, GLib.ConnectFlags flags);
+
+}
diff --git a/src/Clients/Classical/Builder/GtkBeansSharp.BuilderConnectFuncNative.cs b/src/Clients/Classical/Builder/GtkBeansSharp.BuilderConnectFuncNative.cs
new file mode 100644
index 0000000..c3bdb7a
--- /dev/null
+++ b/src/Clients/Classical/Builder/GtkBeansSharp.BuilderConnectFuncNative.cs
@@ -0,0 +1,96 @@
+// This file was generated by the Gtk# code generator.
+// Any changes made will be lost if regenerated.
+
+namespace GtkBeansSharp {
+
+ using System;
+ using System.Runtime.InteropServices;
+
+#region Autogenerated code
+ [GLib.CDeclCallback]
+ internal delegate void BuilderConnectFuncNative(IntPtr builder, IntPtr objekt, IntPtr signal_name, IntPtr handler_name, IntPtr connect_object, int flags, IntPtr user_data);
+
+ internal class BuilderConnectFuncInvoker {
+
+ BuilderConnectFuncNative native_cb;
+ IntPtr __data;
+ GLib.DestroyNotify __notify;
+
+ ~BuilderConnectFuncInvoker ()
+ {
+ if (__notify == null)
+ return;
+ __notify (__data);
+ }
+
+ internal BuilderConnectFuncInvoker (BuilderConnectFuncNative native_cb) : this (native_cb, IntPtr.Zero, null) {}
+
+ internal BuilderConnectFuncInvoker (BuilderConnectFuncNative native_cb, IntPtr data) : this (native_cb, data, null) {}
+
+ internal BuilderConnectFuncInvoker (BuilderConnectFuncNative native_cb, IntPtr data, GLib.DestroyNotify notify)
+ {
+ this.native_cb = native_cb;
+ __data = data;
+ __notify = notify;
+ }
+
+ internal GtkBeans.BuilderConnectFunc Handler {
+ get {
+ return new GtkBeans.BuilderConnectFunc(InvokeNative);
+ }
+ }
+
+ void InvokeNative (GtkBeans.Builder builder, GLib.Object objekt, string signal_name, string handler_name, GLib.Object connect_object, GLib.ConnectFlags flags)
+ {
+ IntPtr native_signal_name = GLib.Marshaller.StringToPtrGStrdup (signal_name);
+ IntPtr native_handler_name = GLib.Marshaller.StringToPtrGStrdup (handler_name);
+ native_cb (builder == null ? IntPtr.Zero : builder.Handle, objekt == null ? IntPtr.Zero : objekt.Handle, native_signal_name, native_handler_name, connect_object == null ? IntPtr.Zero : connect_object.Handle, (int) flags, __data);
+ GLib.Marshaller.Free (native_signal_name);
+ GLib.Marshaller.Free (native_handler_name);
+ }
+ }
+
+ internal class BuilderConnectFuncWrapper {
+
+ public void NativeCallback (IntPtr builder, IntPtr objekt, IntPtr signal_name, IntPtr handler_name, IntPtr connect_object, int flags, IntPtr user_data)
+ {
+ try {
+ managed (GLib.Object.GetObject(builder) as GtkBeans.Builder, GLib.Object.GetObject (objekt), GLib.Marshaller.Utf8PtrToString (signal_name), GLib.Marshaller.Utf8PtrToString (handler_name), GLib.Object.GetObject (connect_object), (GLib.ConnectFlags) flags);
+ if (release_on_call)
+ gch.Free ();
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException (e, false);
+ }
+ }
+
+ bool release_on_call = false;
+ GCHandle gch;
+
+ public void PersistUntilCalled ()
+ {
+ release_on_call = true;
+ gch = GCHandle.Alloc (this);
+ }
+
+ internal BuilderConnectFuncNative NativeDelegate;
+ GtkBeans.BuilderConnectFunc managed;
+
+ public BuilderConnectFuncWrapper (GtkBeans.BuilderConnectFunc managed)
+ {
+ this.managed = managed;
+ if (managed != null)
+ NativeDelegate = new BuilderConnectFuncNative (NativeCallback);
+ }
+
+ public static GtkBeans.BuilderConnectFunc GetManagedDelegate (BuilderConnectFuncNative native)
+ {
+ if (native == null)
+ return null;
+ BuilderConnectFuncWrapper wrapper = (BuilderConnectFuncWrapper) native.Target;
+ if (wrapper == null)
+ return null;
+ return wrapper.managed;
+ }
+ }
+#endregion
+}
diff --git a/src/Clients/Classical/Builder/ObjectManager.cs b/src/Clients/Classical/Builder/ObjectManager.cs
new file mode 100644
index 0000000..706ae8c
--- /dev/null
+++ b/src/Clients/Classical/Builder/ObjectManager.cs
@@ -0,0 +1,19 @@
+// This file was generated by the Gtk# code generator.
+// Any changes made will be lost if regenerated.
+
+namespace GtkSharp.GtkbeansSharp {
+
+ public class ObjectManager {
+
+ static bool initialized = false;
+ // Call this method from the appropriate module init function.
+ public static void Initialize ()
+ {
+ if (initialized)
+ return;
+
+ initialized = true;
+ GLib.GType.Register (GtkBeans.Builder.GType, typeof (GtkBeans.Builder));
+ }
+ }
+}
diff --git a/src/Clients/Classical/Dialogs/GtkDialog.cs b/src/Clients/Classical/Dialogs/BuilderDialog.cs
similarity index 56%
rename from src/Clients/Classical/Dialogs/GtkDialog.cs
rename to src/Clients/Classical/Dialogs/BuilderDialog.cs
index c425a23..eb768d7 100644
--- a/src/Clients/Classical/Dialogs/GtkDialog.cs
+++ b/src/Clients/Classical/Dialogs/BuilderDialog.cs
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Jordi Mas i Hernà ndez <jmas softcatala org>
+ * Copyright (C) 2010 Jordi Mas i Hernà ndez <jmas softcatala org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -18,39 +18,26 @@
*/
using System;
-using Glade;
using Gtk;
-using Mono.Unix;
+using GtkBeans;
namespace gbrainy.Clients.Classical
{
- public class GtkDialog
+ public class BuilderDialog : Gtk.Dialog
{
- public Glade.XML xml;
- public Gtk.Dialog dialog;
- public string dialog_name;
-
- public GtkDialog (string dialog_name)
+ public BuilderDialog (string resourceName, string dialogName) : this (null, resourceName, dialogName)
{
- this.dialog_name = dialog_name;
- xml = new Glade.XML (null, "gbrainy.glade", dialog_name, "gbrainy");
- xml.Autoconnect (this);
- Dialog.IconName = "gbrainy";
- dialog = null;
}
- public ResponseType Run ()
+ public BuilderDialog (System.Reflection.Assembly assembly, string resourceName, string dialogName) :
+ this (new GtkBeans.Builder (assembly, resourceName, null),dialogName)
{
- return (ResponseType) Dialog.Run ();
}
- public Gtk.Dialog Dialog {
- get {
- if (dialog == null)
- dialog = (Gtk.Dialog) xml.GetWidget (dialog_name);
-
- return dialog;
- }
+ public BuilderDialog (GtkBeans.Builder builder, string dialogName) : base (builder.GetRawObject (dialogName))
+ {
+ builder.Autoconnect (this);
+ IconName = "gbrainy";
}
}
}
diff --git a/src/Clients/Classical/Dialogs/CustomGameDialog.cs b/src/Clients/Classical/Dialogs/CustomGameDialog.cs
index 24b62e2..7a931c4 100644
--- a/src/Clients/Classical/Dialogs/CustomGameDialog.cs
+++ b/src/Clients/Classical/Dialogs/CustomGameDialog.cs
@@ -27,12 +27,12 @@ using gbrainy.Core.Libraries;
namespace gbrainy.Clients.Classical
{
- public class CustomGameDialog : GtkDialog
+ public class CustomGameDialog : BuilderDialog
{
static ListStore games_store;
- [Glade.Widget] Gtk.TreeView treeview;
- [Glade.Widget] Box preview_vbox;
- [Glade.Widget] Label preview_question;
+ [GtkBeans.Builder.Object] Gtk.TreeView treeview;
+ [GtkBeans.Builder.Object] Box preview_vbox;
+ [GtkBeans.Builder.Object] Label preview_question;
CairoPreview drawing_area;
GameManager manager;
int ngames, npos;
@@ -41,7 +41,7 @@ namespace gbrainy.Clients.Classical
const int COL_ENABLED = 2;
const int COL_OBJECT = 3;
- public CustomGameDialog (GameManager manager) : base ("customgame")
+ public CustomGameDialog (GameManager manager) : base ("CustomGameDialog.ui", "customgame")
{
Game game;
Type[] games;
diff --git a/src/Clients/Classical/Dialogs/PlayerHistoryDialog.cs b/src/Clients/Classical/Dialogs/PlayerHistoryDialog.cs
index 6acc49f..3e64122 100644
--- a/src/Clients/Classical/Dialogs/PlayerHistoryDialog.cs
+++ b/src/Clients/Classical/Dialogs/PlayerHistoryDialog.cs
@@ -28,19 +28,19 @@ using gbrainy.Core.Views;
namespace gbrainy.Clients.Classical
{
- public class PlayerHistoryDialog : GtkDialog
+ public class PlayerHistoryDialog : BuilderDialog
{
- [Glade.Widget] Box history_preview;
- [Glade.Widget] Label label_playerhistory;
- [Glade.Widget] Gtk.CheckButton checkbutton_total;
- [Glade.Widget] Gtk.CheckButton checkbutton_memory;
- [Glade.Widget] Gtk.CheckButton checkbutton_logic;
- [Glade.Widget] Gtk.CheckButton checkbutton_calculation;
- [Glade.Widget] Gtk.CheckButton checkbutton_verbal;
+ [GtkBeans.Builder.Object] Box history_preview;
+ [GtkBeans.Builder.Object] Label label_playerhistory;
+ [GtkBeans.Builder.Object] Gtk.CheckButton checkbutton_total;
+ [GtkBeans.Builder.Object] Gtk.CheckButton checkbutton_memory;
+ [GtkBeans.Builder.Object] Gtk.CheckButton checkbutton_logic;
+ [GtkBeans.Builder.Object] Gtk.CheckButton checkbutton_calculation;
+ [GtkBeans.Builder.Object] Gtk.CheckButton checkbutton_verbal;
CairoPreview drawing_area;
- public PlayerHistoryDialog (PlayerHistory history) : base ("playerhistory")
+ public PlayerHistoryDialog (PlayerHistory history) : base ("PlayerHistoryDialog.ui", "playerhistory")
{
string label;
diff --git a/src/Clients/Classical/Dialogs/PreferencesDialog.cs b/src/Clients/Classical/Dialogs/PreferencesDialog.cs
index 59db70a..375e144 100644
--- a/src/Clients/Classical/Dialogs/PreferencesDialog.cs
+++ b/src/Clients/Classical/Dialogs/PreferencesDialog.cs
@@ -26,20 +26,20 @@ using gbrainy.Core.Main;
namespace gbrainy.Clients.Classical
{
- public class PreferencesDialog : GtkDialog
+ public class PreferencesDialog : BuilderDialog
{
- [Glade.Widget] Gtk.SpinButton prefspinbutton;
- [Glade.Widget] Gtk.SpinButton maxstoredspinbutton;
- [Glade.Widget] Gtk.SpinButton minplayedspinbutton;
- [Glade.Widget] Gtk.CheckButton prefcheckbutton;
- [Glade.Widget] Gtk.CheckButton colorblindcheckbutton;
- [Glade.Widget] Gtk.RadioButton rb_easy;
- [Glade.Widget] Gtk.RadioButton rb_medium;
- [Glade.Widget] Gtk.RadioButton rb_master;
+ [GtkBeans.Builder.Object] Gtk.SpinButton prefspinbutton;
+ [GtkBeans.Builder.Object] Gtk.SpinButton maxstoredspinbutton;
+ [GtkBeans.Builder.Object] Gtk.SpinButton minplayedspinbutton;
+ [GtkBeans.Builder.Object] Gtk.CheckButton prefcheckbutton;
+ [GtkBeans.Builder.Object] Gtk.CheckButton colorblindcheckbutton;
+ [GtkBeans.Builder.Object] Gtk.RadioButton rb_easy;
+ [GtkBeans.Builder.Object] Gtk.RadioButton rb_medium;
+ [GtkBeans.Builder.Object] Gtk.RadioButton rb_master;
PlayerHistory history;
- public PreferencesDialog (PlayerHistory history) : base ("preferences")
+ public PreferencesDialog (PlayerHistory history) : base ("PreferencesDialog.ui", "preferences")
{
this.history = history;
prefspinbutton.Value = Preferences.GetIntValue (Preferences.MemQuestionTimeKey);
diff --git a/src/Clients/Classical/Dialogs/ui/CustomGameDialog.ui b/src/Clients/Classical/Dialogs/ui/CustomGameDialog.ui
new file mode 100644
index 0000000..c6503a6
--- /dev/null
+++ b/src/Clients/Classical/Dialogs/ui/CustomGameDialog.ui
@@ -0,0 +1,185 @@
+<?xml version="1.0"?>
+<interface>
+ <!-- interface-requires gtk+ 2.12 -->
+ <!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkDialog" id="customgame">
+ <property name="width_request">700</property>
+ <property name="height_request">400</property>
+ <property name="visible">True</property>
+ <property name="border_width">7</property>
+ <property name="title" translatable="yes">Custom Game</property>
+ <property name="default_width">490</property>
+ <property name="default_height">280</property>
+ <property name="type_hint">dialog</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox2">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkHBox" id="hbox8">
+ <property name="visible">True</property>
+ <property name="border_width">5</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkVBox" id="vbox8">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="width_request">400</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHButtonBox" id="hbuttonbox1">
+ <property name="height_request">35</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkButton" id="SelectAll">
+ <property name="label" translatable="yes">Select All</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="OnSelectAll"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="Unselectall">
+ <property name="label" translatable="yes">Unselect all</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="OnUnSelectAll"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox7">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkLabel" id="preview_question">
+ <property name="height_request">50</property>
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="ypad">1</property>
+ <property name="wrap">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="preview_vbox">
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area2">
+ <property name="width_request">0</property>
+ <property name="height_request">0</property>
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="cancelbutton1">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="okbutton">
+ <property name="label" translatable="yes">_Start</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="OnOK"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-6">cancelbutton1</action-widget>
+ <action-widget response="-5">okbutton</action-widget>
+ </action-widgets>
+ </object>
+</interface>
diff --git a/src/Clients/Classical/Dialogs/ui/PlayerHistoryDialog.ui b/src/Clients/Classical/Dialogs/ui/PlayerHistoryDialog.ui
new file mode 100644
index 0000000..2b1ba1c
--- /dev/null
+++ b/src/Clients/Classical/Dialogs/ui/PlayerHistoryDialog.ui
@@ -0,0 +1,182 @@
+<?xml version="1.0"?>
+<interface>
+ <!-- interface-requires gtk+ 2.12 -->
+ <!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkDialog" id="playerhistory">
+ <property name="visible">True</property>
+ <property name="border_width">7</property>
+ <property name="title" translatable="yes">Player's Game History</property>
+ <property name="default_width">450</property>
+ <property name="default_height">450</property>
+ <property name="type_hint">dialog</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox3">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkVBox" id="players_vbox">
+ <property name="visible">True</property>
+ <property name="border_width">5</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel" id="label_playerhistory">
+ <property name="width_request">400</property>
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="xpad">5</property>
+ <property name="wrap">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="history_preview">
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox10">
+ <property name="visible">True</property>
+ <property name="spacing">5</property>
+ <child>
+ <object class="GtkLabel" id="label28">
+ <property name="visible">True</property>
+ <property name="xpad">5</property>
+ <property name="label" translatable="yes">Show:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton_total">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="OnTotalToggled"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton_logic">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="OnLogicToggled"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton_memory">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="OnMemoryToggled"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton_calculation">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="OnCalculationToggled"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton_verbal">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="OnVerbalToggled"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area4">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="okbutton2">
+ <property name="label">gtk-close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-5">okbutton2</action-widget>
+ </action-widgets>
+ </object>
+</interface>
diff --git a/src/Clients/Classical/Dialogs/ui/PreferencesDialog.ui b/src/Clients/Classical/Dialogs/ui/PreferencesDialog.ui
new file mode 100644
index 0000000..bb785b1
--- /dev/null
+++ b/src/Clients/Classical/Dialogs/ui/PreferencesDialog.ui
@@ -0,0 +1,406 @@
+<?xml version="1.0"?>
+<interface>
+ <!-- interface-requires gtk+ 2.12 -->
+ <!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkDialog" id="preferences">
+ <property name="visible">True</property>
+ <property name="border_width">7</property>
+ <property name="title" translatable="yes">Preferences</property>
+ <property name="type_hint">dialog</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="preferencesbox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkVBox" id="vbox13">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel" id="label33">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="label" translatable="yes"><b>General Settings</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="colorblindcheckbutton">
+ <property name="label" translatable="yes">Skip games that use colors (friendly to colorblind users)</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox11">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel" id="label27">
+ <property name="height_request">25</property>
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes"><b>Difficulty Level</b></property>
+ <property name="use_markup">True</property>
+ <property name="single_line_mode">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="rb_easy">
+ <property name="label" translatable="yes">Easy</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="rb_medium">
+ <property name="label" translatable="yes">Medium</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">rb_easy</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="rb_master">
+ <property name="label" translatable="yes">Master</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">rb_easy</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox9">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel" id="label26">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="ypad">5</property>
+ <property name="label" translatable="yes"><b>Memory Games</b></property>
+ <property name="use_markup">True</property>
+ <property name="single_line_mode">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox10">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkHBox" id="hbox9">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkLabel" id="label25">
+ <property name="visible">True</property>
+ <property name="xpad">5</property>
+ <property name="label" translatable="yes">Time in seconds to memorize the challenge:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="prefspinbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="adjustment">adjustment1</property>
+ <property name="climb_rate">1</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="prefcheckbutton">
+ <property name="label" translatable="yes">Show countdown message</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">2</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="padding">2</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox12">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel" id="label29">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="ypad">5</property>
+ <property name="label" translatable="yes"><b>Player's Game History</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox11">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkTable" id="table5">
+ <property name="visible">True</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <child>
+ <object class="GtkLabel" id="label31">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="xpad">5</property>
+ <property name="label" translatable="yes">Minimum number of played games to store the game:</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label32">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="xpad">5</property>
+ <property name="label" translatable="yes">Maximum number of stored games in the player's game history:</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="maxstoredspinbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="adjustment">adjustment2</property>
+ <property name="climb_rate">1</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="minplayedspinbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="adjustment">adjustment3</property>
+ <property name="climb_rate">1</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox12">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkHButtonBox" id="hbuttonbox2">
+ <property name="visible">True</property>
+ <property name="border_width">1</property>
+ <property name="layout_style">start</property>
+ <child>
+ <object class="GtkButton" id="clear_button">
+ <property name="label" translatable="yes">Clear Player's Game History</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="OnCleanHistory"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="padding">5</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area3">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="cancelbutton2">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="okbutton">
+ <property name="label">gtk-apply</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="OnOK"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-6">cancelbutton2</action-widget>
+ <action-widget response="-5">okbutton</action-widget>
+ </action-widgets>
+ </object>
+ <object class="GtkAdjustment" id="adjustment1">
+ <property name="lower">4</property>
+ <property name="upper">60</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment2">
+ <property name="lower">10</property>
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment3">
+ <property name="lower">3</property>
+ <property name="upper">50</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+</interface>
diff --git a/src/Clients/Classical/Makefile.am b/src/Clients/Classical/Makefile.am
index 6589f86..aa4600a 100644
--- a/src/Clients/Classical/Makefile.am
+++ b/src/Clients/Classical/Makefile.am
@@ -1,15 +1,20 @@
EXTRAFLAGS = -unsafe -nowarn:0169 $(CSC_DEFINES)
WRAPPER = gbrainy
+TARGET_CFG = ../../gbrainy.exe.config
GBRAINY_CSDISTFILES = \
$(srcdir)/Defines.cs \
$(srcdir)/gbrainy.cs \
$(srcdir)/GtkSynchronize.cs \
$(srcdir)/SimpleLabel.cs \
+ $(srcdir)/Builder/Builder.cs \
+ $(srcdir)/Builder/BuilderConnectFunc.cs \
+ $(srcdir)/Builder/GtkBeansSharp.BuilderConnectFuncNative.cs \
+ $(srcdir)/Builder/ObjectManager.cs \
$(srcdir)/Dialogs/AboutDialog.cs \
$(srcdir)/Dialogs/CustomGameDialog.cs \
- $(srcdir)/Dialogs/GtkDialog.cs \
+ $(srcdir)/Dialogs/BuilderDialog.cs \
$(srcdir)/Dialogs/PlayerHistoryDialog.cs \
$(srcdir)/Dialogs/PreferencesDialog.cs
@@ -21,7 +26,10 @@ ASSEMBLIES = \
-r:Mono.Posix
RESOURCES = \
--resource:$(srcdir)/gbrainy.glade \
+-resource:$(srcdir)/gbrainy.ui \
+-resource:$(srcdir)/Dialogs/ui/PreferencesDialog.ui \
+-resource:$(srcdir)/Dialogs/ui/PlayerHistoryDialog.ui \
+-resource:$(srcdir)/Dialogs/ui/CustomGameDialog.ui \
-resource:$(top_srcdir)/data/app-graphics/resume-32.png \
-resource:$(top_srcdir)/data/app-graphics/endgame-32.png \
-resource:$(top_srcdir)/data/app-graphics/pause-32.png \
@@ -35,27 +43,38 @@ RESOURCES = \
-resource:$(top_srcdir)/data/app-graphics/gbrainy.svg
gbrainydir = $(libdir)/gbrainy
-gbrainy_SCRIPTS = ../../gbrainy.exe
+gbrainy_SCRIPTS = ../../gbrainy.exe ../../gbrainy.exe.config
bin_SCRIPTS = gbrainy
GBRAINY_CSFILES = $(GBRAINY_CSDISTFILES) \
AssemblyInfo.cs
-../../gbrainy.exe: $(GBRAINY_CSFILES) gbrainy.glade
+../../gbrainy.exe: $(GBRAINY_CSFILES) gbrainy.ui $(srcdir)/Dialogs/ui/PreferencesDialog.ui \
+ $(srcdir)/Dialogs/ui/PlayerHistoryDialog.ui $(srcdir)/Dialogs/ui/CustomGameDialog.ui
$(CSC) -target:winexe -out:$@ $(EXTRAFLAGS) $(GBRAINY_CSFILES) $(ASSEMBLIES) $(RESOURCES)
-all: ../../gbrainy.exe
+$(TARGET_CFG): gbrainy.exe.config.in
+ sed -e "s|\ pkglibdir\@|$(pkglibdir)|" \
+ < $< > $@
+
+all: ../../gbrainy.exe $(TARGET_CFG)
EXTRA_DIST = \
- gbrainy.glade \
- $(srcdir)/mono-addins-strings.xml \
- $(GBRAINY_CSDISTFILES)
+ gbrainy.ui \
+ $(srcdir)/gbrainy.exe.config.in \
+ $(srcdir)/mono-addins-strings.xml \
+ $(srcdir)/gbrainy.ui \
+ $(srcdir)/Dialogs/ui/PreferencesDialog.ui \
+ $(srcdir)/Dialogs/ui/PlayerHistoryDialog.ui \
+ $(srcdir)/Dialogs/ui/CustomGameDialog.ui \
+ $(GBRAINY_CSDISTFILES)
CLEANFILES = \
gbrainy.exe.mdb \
../../gbrainy.exe \
+ ../../gbrainy.exe.config \
gbrainy
diff --git a/src/Clients/Classical/gbrainy.cs b/src/Clients/Classical/gbrainy.cs
index c0a16ff..561f9c2 100644
--- a/src/Clients/Classical/gbrainy.cs
+++ b/src/Clients/Classical/gbrainy.cs
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007-2009 Jordi Mas i Hernà ndez <jmas softcatala org>
+ * Copyright (C) 2007-2010 Jordi Mas i Hernà ndez <jmas softcatala org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -37,22 +37,23 @@ namespace gbrainy.Clients.Classical
{
public class GtkClient: Program
{
- [Glade.Widget("gbrainy")] Gtk.Window app_window;
- [Glade.Widget ("toolbar_item")] Gtk.CheckMenuItem toolbar_menuitem;
- [Glade.Widget] Box drawing_vbox;
- [Glade.Widget] Gtk.VBox question_vbox;
- [Glade.Widget] Gtk.VBox solution_vbox;
- [Glade.Widget] Gtk.Entry answer_entry;
- [Glade.Widget] Gtk.Button answer_button;
- [Glade.Widget] Gtk.Button tip_button;
- [Glade.Widget] Gtk.Button next_button;
- [Glade.Widget] Gtk.Statusbar statusbar;
- [Glade.Widget] Gtk.Toolbar toolbar;
- [Glade.Widget] Gtk.Menu settings_menu;
- [Glade.Widget] Gtk.Menu help_menu;
- [Glade.Widget] Gtk.MenuItem pause_menuitem;
- [Glade.Widget] Gtk.MenuItem finish_menuitem;
- [Glade.Widget] Gtk.MenuItem newgame_menuitem;
+ [GtkBeans.Builder.Object("gbrainy")] Gtk.Window app_window;
+ [GtkBeans.Builder.Object] Gtk.ToggleAction toolbar_menuitem;
+ [GtkBeans.Builder.Object] Box drawing_vbox;
+ [GtkBeans.Builder.Object] Gtk.VBox question_vbox;
+ [GtkBeans.Builder.Object] Gtk.VBox solution_vbox;
+ [GtkBeans.Builder.Object] Gtk.Entry answer_entry;
+ [GtkBeans.Builder.Object] Gtk.Button answer_button;
+ [GtkBeans.Builder.Object] Gtk.Button tip_button;
+ [GtkBeans.Builder.Object] Gtk.Button next_button;
+ [GtkBeans.Builder.Object] Gtk.Statusbar statusbar;
+ [GtkBeans.Builder.Object] Gtk.Toolbar toolbar;
+ [GtkBeans.Builder.Object] Gtk.MenuBar menubar;
+ [GtkBeans.Builder.Object] Gtk.Action help_menu;
+ [GtkBeans.Builder.Object] Gtk.Action pause_menuitem;
+ [GtkBeans.Builder.Object] Gtk.Action finish_menuitem;
+ [GtkBeans.Builder.Object] Gtk.Action newgame_menuitem;
+ [GtkBeans.Builder.Object] Gtk.UIManager uimanager;
DrawingArea drawing_area;
GameSession session;
ToolButton all_tbbutton, logic_tbbutton, calculation_tbbutton, memory_tbbutton, verbal_tbbutton, pause_tbbutton, finish_tbbutton;
@@ -70,8 +71,8 @@ namespace gbrainy.Clients.Classical
Catalog.Init ("gbrainy", Defines.GNOME_LOCALE_DIR);
Unix.FixLocaleInfo ();
- Glade.XML gXML = new Glade.XML (null, "gbrainy.glade", "gbrainy", null);
- gXML.Autoconnect (this);
+ GtkBeans.Builder builder = new GtkBeans.Builder ("gbrainy.ui");
+ builder.Autoconnect (this);
BuildToolBar ();
session = new GameSession ();
@@ -82,7 +83,7 @@ namespace gbrainy.Clients.Classical
session.Difficulty = (Game.Difficulty) Preferences.GetIntValue (Preferences.DifficultyKey);
drawing_area = new DrawingArea ();
drawing_area.ExposeEvent += OnDrawingAreaExposeEvent;
- GameSensitiveUI ();
+ //GameSensitiveUI ();
// For low resolutions, hide the toolbar and made the drawing area smaller
if (drawing_area.Screen.Width> 0 && drawing_area.Screen.Height > 0) {
@@ -99,13 +100,7 @@ namespace gbrainy.Clients.Classical
solution_label = new SimpleLabel ();
solution_label.HeightMargin = 2;
solution_vbox.Add (solution_label);
-
- #if MONO_ADDINS
- item = new Gtk.MenuItem (Catalog.GetString ("Extensions"));
- settings_menu.Append (item);
- item.Activated += delegate (object sender, EventArgs ar) { Mono.Addins.Gui.AddinManagerWindow.Run (app_window);};
- #endif
-
+
drawing_vbox.Add (drawing_area);
app_window.IconName = "gbrainy";
app_window.ShowAll ();
@@ -113,6 +108,13 @@ namespace gbrainy.Clients.Classical
if (Preferences.GetBoolValue (Preferences.ToolbarKey) == false || low_res == true)
toolbar_menuitem.Active = false;
+ MenuItem extensions_menu = uimanager.GetWidget ("/ui/menubar/settings_topmenu/extensionsmenu/") as MenuItem;
+ #if MONO_ADDINS
+ extensions_menu.Activated += delegate (object sender, EventArgs ar) { Mono.Addins.Gui.AddinManagerWindow.Run (app_window);};
+ #else
+ extensions_menu.Visible = false;
+ #endif
+
ActiveInputControls (false);
}
@@ -304,6 +306,7 @@ namespace gbrainy.Clients.Classical
all_tbbutton.Sensitive = calculation_tbbutton.Sensitive = memory_tbbutton.Sensitive = logic_tbbutton.Sensitive = verbal_tbbutton.Sensitive = !playing;
pause_menuitem.Sensitive = finish_menuitem.Sensitive = playing;
newgame_menuitem.Sensitive = !playing;
+ newgame_menuitem.ActionGroup.Visible = false;
}
private void GetNextGame ()
@@ -418,10 +421,10 @@ namespace gbrainy.Clients.Classical
PreferencesDialog dialog;
dialog = new PreferencesDialog (session.PlayerHistory);
- if (dialog.Run () == ResponseType.Ok) {
+ if ((Gtk.ResponseType) dialog.Run () == ResponseType.Ok) {
session.Difficulty = (Game.Difficulty) Preferences.GetIntValue (Preferences.DifficultyKey);
}
- dialog.Dialog.Destroy ();
+ dialog.Destroy ();
}
void OnCustomGame (object sender, EventArgs args)
@@ -430,8 +433,8 @@ namespace gbrainy.Clients.Classical
CustomGameDialog dialog;
dialog = new CustomGameDialog (session.GameManager);
- rslt = dialog.Run ();
- dialog.Dialog.Destroy ();
+ rslt = (Gtk.ResponseType) dialog.Run ();
+ dialog.Destroy ();
if (rslt == ResponseType.Ok && dialog.NumOfGames > 0)
OnNewGame (session.Type = GameSession.Types.Custom);
@@ -522,7 +525,7 @@ namespace gbrainy.Clients.Classical
dialog = new PlayerHistoryDialog (session.PlayerHistory);
dialog.Run ();
- dialog.Dialog.Destroy ();
+ dialog.Destroy ();
}
private void AddIcon (IconFactory stock, string stockid, string resource)
diff --git a/src/Clients/Classical/gbrainy.ui b/src/Clients/Classical/gbrainy.ui
new file mode 100644
index 0000000..e85db9b
--- /dev/null
+++ b/src/Clients/Classical/gbrainy.ui
@@ -0,0 +1,473 @@
+<?xml version="1.0"?>
+<interface>
+ <object class="GtkAdjustment" id="adjustment1">
+ <property name="upper">60</property>
+ <property name="lower">4</property>
+ <property name="page_increment">0</property>
+ <property name="step_increment">1</property>
+ <property name="page_size">0</property>
+ <property name="value">4</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment2">
+ <property name="upper">100</property>
+ <property name="lower">10</property>
+ <property name="page_increment">0</property>
+ <property name="step_increment">1</property>
+ <property name="page_size">0</property>
+ <property name="value">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment3">
+ <property name="upper">50</property>
+ <property name="lower">3</property>
+ <property name="page_increment">0</property>
+ <property name="step_increment">1</property>
+ <property name="page_size">0</property>
+ <property name="value">3</property>
+ </object>
+ <object class="GtkUIManager" id="uimanager">
+ <child>
+ <object class="GtkActionGroup" id="actiongroup1">
+ <child>
+ <object class="GtkAction" id="game_topmenu">
+ <property name="name">game_topmenu</property>
+ <property name="label" translatable="yes">_Game</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="newgame_menuitem">
+ <property name="name">newgame_menuitem</property>
+ <property name="label" translatable="yes">_New Game</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="menuitem3">
+ <property name="name">menuitem3</property>
+ <property name="label" translatable="yes">All Games (Logic, Mental Calculation, Memory and Verbal Analogies)</property>
+ <signal handler="OnAllGames" name="activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="menuitem4">
+ <property name="name">menuitem4</property>
+ <property name="label" translatable="yes">Trainers Only (Mental Calculation and Memory)</property>
+ <signal handler="OnTrainersOnly" name="activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="menuitem5">
+ <property name="name">menuitem5</property>
+ <property name="label" translatable="yes">Logic Puzzles Only</property>
+ <signal handler="OnLogicOnly" name="activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="menuitem6">
+ <property name="name">menuitem6</property>
+ <property name="label" translatable="yes">Mental Calculation Trainers Only</property>
+ <signal handler="OnMathOnly" name="activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="menuitem7">
+ <property name="name">menuitem7</property>
+ <property name="label" translatable="yes">Memory Trainers Only</property>
+ <signal handler="OnMemoryOnly" name="activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="menuitem8">
+ <property name="name">menuitem8</property>
+ <property name="label" translatable="yes">Verbal Analogies Only</property>
+ <signal handler="OnVerbalOnly" name="activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="custom_game">
+ <property name="name">custom_game</property>
+ <property name="label" translatable="yes">Custom Game Selection...</property>
+ <signal handler="OnCustomGame" name="activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="pause_menuitem">
+ <property name="name">pause_menuitem</property>
+ <property name="label" translatable="yes">_Pause Game</property>
+ <signal handler="OnPauseGame" name="activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="finish_menuitem">
+ <property name="name">finish_menuitem</property>
+ <property name="label" translatable="yes">_End Game</property>
+ <signal handler="OnEndGame" name="activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="imagemenuitem2">
+ <property name="stock_id">gtk-quit</property>
+ <property name="name">imagemenuitem2</property>
+ <signal handler="OnQuit" name="activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="view_topmenu">
+ <property name="name">view_topmenu</property>
+ <property name="label" translatable="yes">_View</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkToggleAction" id="toolbar_menuitem">
+ <property name="active">True</property>
+ <property name="name">toolbar_menuitem</property>
+ <property name="label" translatable="yes">Toolbar</property>
+ <signal handler="OnToolbarActivate" name="activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="players_game_history">
+ <property name="name">players_game_history</property>
+ <property name="label" translatable="yes">Player's Game History</property>
+ <signal handler="OnHistory" name="activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="fullscreen">
+ <property name="stock_id">gtk-fullscreen</property>
+ <property name="name">fullscreen</property>
+ <property name="label" translatable="yes">_FullScreen</property>
+ <signal handler="OnFullscreen" name="activate"/>
+ </object>
+ <accelerator key="F11"/>
+ </child>
+ <child>
+ <object class="GtkAction" id="settings_topmenu">
+ <property name="name">settings_topmenu</property>
+ <property name="label" translatable="yes">_Settings</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="preferencesmenu">
+ <property name="stock_id">gtk-preferences</property>
+ <property name="name">preferencesmenu</property>
+ <signal handler="OnPreferences" name="activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="extensionsmenu">
+ <property name="name">extensionsmenu</property>
+ <property name="label" translatable="yes">Extensions</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="help_topmenu">
+ <property name="name">help_topmenu</property>
+ <property name="label" translatable="yes">_Help</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="contentsmenuitem">
+ <property name="stock_id">gtk-help</property>
+ <property name="name">contentsmenuitem</property>
+ <property name="label" translatable="yes">_Contents</property>
+ <signal handler="OnMenuHelp" name="activate"/>
+ </object>
+ <accelerator key="F1"/>
+ </child>
+ <child>
+ <object class="GtkAction" id="extendmenuitem">
+ <property name="name">extendmenuitem</property>
+ <property name="label" translatable="yes">How to Extend gbrainy's Functionality</property>
+ <signal handler="OnExtending" name="activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="imagemenuitem3">
+ <property name="stock_id">gtk-about</property>
+ <property name="name">imagemenuitem3</property>
+ <signal handler="OnMenuAbout" name="activate"/>
+ </object>
+ </child>
+ </object>
+ </child>
+ <ui>
+ <menubar name="menubar">
+ <menu action="game_topmenu">
+ <menu action="newgame_menuitem">
+ <menuitem action="menuitem3"/>
+ <menuitem action="menuitem4"/>
+ <menuitem action="menuitem5"/>
+ <menuitem action="menuitem6"/>
+ <menuitem action="menuitem7"/>
+ <menuitem action="menuitem8"/>
+ <menuitem action="custom_game"/>
+ </menu>
+ <menuitem action="pause_menuitem"/>
+ <menuitem action="finish_menuitem"/>
+ <separator/>
+ <menuitem action="imagemenuitem2"/>
+ </menu>
+ <menu action="view_topmenu">
+ <menuitem action="toolbar_menuitem"/>
+ <menuitem action="players_game_history"/>
+ <menuitem action="fullscreen"/>
+ </menu>
+ <menu action="settings_topmenu">
+ <menuitem action="preferencesmenu"/>
+ <menuitem action="extensionsmenu"/>
+ </menu>
+ <menu action="help_topmenu">
+ <menuitem action="contentsmenuitem"/>
+ <menuitem action="extendmenuitem"/>
+ <menuitem action="imagemenuitem3"/>
+ </menu>
+ </menubar>
+ </ui>
+ </object>
+ <!-- interface-requires gtk+ 2.6 -->
+ <!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkWindow" id="gbrainy">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">gbrainy</property>
+ <signal handler="OnDeleteWindow" name="delete_event"/>
+ <child>
+ <object class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkMenuBar" constructor="uimanager" id="menubar">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolbar" id="toolbar">
+ <property name="visible">True</property>
+ <property name="toolbar_style">both</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="question_vbox">
+ <property name="height_request">55</property>
+ <property name="visible">True</property>
+ <property name="spacing">1</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="drawing_vbox">
+ <property name="height_request">400</property>
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="solution_vbox">
+ <property name="height_request">55</property>
+ <property name="visible">True</property>
+ <property name="spacing">1</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox5">
+ <property name="width_request">500</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkTable" id="table4">
+ <property name="visible">True</property>
+ <property name="n_columns">5</property>
+ <property name="column_spacing">5</property>
+ <child>
+ <object class="GtkLabel" id="label_answer">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="xpad">3</property>
+ <property name="label" translatable="yes">Answer:</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="answer_button">
+ <property name="label">gtk-ok</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_stock">True</property>
+ <signal handler="OnAnswerButtonClicked" name="clicked"/>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="next_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <signal handler="OnNextButtonClicked" name="clicked"/>
+ <child>
+ <object class="GtkAlignment" id="alignment5">
+ <property name="visible">True</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <child>
+ <object class="GtkHBox" id="hbox6">
+ <property name="visible">True</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkImage" id="image5">
+ <property name="visible">True</property>
+ <property name="stock">gtk-go-forward</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label23">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Next</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="right_attach">5</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"/>
+ <property name="x_padding">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="tip_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <signal handler="OnTip" name="clicked"/>
+ <child>
+ <object class="GtkAlignment" id="alignment6">
+ <property name="visible">True</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <child>
+ <object class="GtkHBox" id="hbox7">
+ <property name="visible">True</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkImage" id="image6">
+ <property name="visible">True</property>
+ <property name="stock">gtk-dialog-info</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label24">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Tip</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="answer_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <signal handler="OnAnswerActivate" name="activate"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkStatusbar" id="statusbar">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">6</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]