[gbrainy] Load extensions as an option
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy] Load extensions as an option
- Date: Sun, 4 Dec 2011 13:36:58 +0000 (UTC)
commit 3603d033f2cff934e595ecc7e587ce47210a313c
Author: Jordi Mas <jmas softcatala org>
Date: Sun Dec 4 14:35:41 2011 +0100
Load extensions as an option
src/Clients/Classical/Dialogs/PreferencesDialog.cs | 9 +-
.../Classical/Dialogs/ui/PreferencesDialog.ui | 212 ++++++++++++++------
src/Clients/Classical/gbrainy.cs | 14 +-
src/Core/Main/Preferences.cs | 2 +
4 files changed, 169 insertions(+), 68 deletions(-)
---
diff --git a/src/Clients/Classical/Dialogs/PreferencesDialog.cs b/src/Clients/Classical/Dialogs/PreferencesDialog.cs
index 42a54c1..aae408b 100644
--- a/src/Clients/Classical/Dialogs/PreferencesDialog.cs
+++ b/src/Clients/Classical/Dialogs/PreferencesDialog.cs
@@ -37,7 +37,8 @@ namespace gbrainy.Clients.Classical.Dialogs
[GtkBeans.Builder.Object] Gtk.RadioButton rb_medium;
[GtkBeans.Builder.Object] Gtk.RadioButton rb_master;
[GtkBeans.Builder.Object] Gtk.ComboBox themes_combobox;
- [GtkBeans.Builder.Object] Gtk.CheckButton english_checkbutton;
+ [GtkBeans.Builder.Object] Gtk.CheckButton englishcheckbutton;
+ [GtkBeans.Builder.Object] Gtk.CheckButton loadextensionscheckbutton;
const int COLUMN_VALUE = 1;
PlayerHistory history;
@@ -50,7 +51,8 @@ namespace gbrainy.Clients.Classical.Dialogs
maxstoredspinbutton.Value = Preferences.Get <int> (Preferences.MaxStoredGamesKey);
minplayedspinbutton.Value = Preferences.Get <int> (Preferences.MinPlayedGamesKey);
colorblindcheckbutton.Active = Preferences.Get <bool> (Preferences.ColorBlindKey);
- english_checkbutton.Active = Preferences.Get <bool> (Preferences.EnglishKey);
+ englishcheckbutton.Active = Preferences.Get <bool> (Preferences.EnglishKey);
+ loadextensionscheckbutton.Active = Preferences.Get <bool> (Preferences.LoadPlugginsKey);
switch ((GameDifficulty) Preferences.Get <int> (Preferences.DifficultyKey)) {
case GameDifficulty.Easy:
@@ -125,7 +127,8 @@ namespace gbrainy.Clients.Classical.Dialogs
Preferences.Set <int> (Preferences.MaxStoredGamesKey, (int) maxstoredspinbutton.Value);
Preferences.Set <int> (Preferences.MinPlayedGamesKey, (int) minplayedspinbutton.Value);
Preferences.Set <bool> (Preferences.ColorBlindKey, colorblindcheckbutton.Active);
- Preferences.Set <bool> (Preferences.EnglishKey, english_checkbutton.Active);
+ Preferences.Set <bool> (Preferences.EnglishKey, englishcheckbutton.Active);
+ Preferences.Set <bool> (Preferences.LoadPlugginsKey, loadextensionscheckbutton.Active);
TreeIter iter;
themes_combobox.GetActiveIter (out iter);
diff --git a/src/Clients/Classical/Dialogs/ui/PreferencesDialog.ui b/src/Clients/Classical/Dialogs/ui/PreferencesDialog.ui
index 586c6f6..c725069 100644
--- a/src/Clients/Classical/Dialogs/ui/PreferencesDialog.ui
+++ b/src/Clients/Classical/Dialogs/ui/PreferencesDialog.ui
@@ -2,20 +2,88 @@
<interface>
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy toplevel-contextual -->
+ <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>
<object class="GtkDialog" id="preferences">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="border_width">7</property>
<property name="title" translatable="yes">Preferences</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkVBox" id="preferencesbox">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</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_action_appearance">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_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="OnOK" swapped="no"/>
+ </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="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
<child>
<object class="GtkVBox" id="vbox13">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label33">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="label" translatable="yes"><b>General Settings</b></property>
@@ -33,6 +101,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
@@ -43,36 +112,60 @@
</packing>
</child>
<child>
- <object class="GtkCheckButton" id="english_checkbutton">
+ <object class="GtkCheckButton" id="englishcheckbutton">
<property name="label" translatable="yes">Force gbrainy to always use English language (ignore translations)</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
+ <object class="GtkCheckButton" id="loadextensionscheckbutton">
+ <property name="label" translatable="yes">Search and load extensions when starting</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Theme:</property>
</object>
<packing>
<property name="expand">False</property>
+ <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="themes_combobox">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
@@ -81,21 +174,27 @@
</child>
</object>
<packing>
- <property name="position">3</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
</packing>
</child>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox11">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label27">
<property name="height_request">25</property>
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes"><b>Difficulty Level</b></property>
<property name="use_markup">True</property>
@@ -113,6 +212,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
@@ -128,6 +228,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<property name="group">rb_easy</property>
@@ -144,6 +245,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<property name="group">rb_easy</property>
@@ -156,15 +258,19 @@
</child>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox9">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label26">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="ypad">5</property>
@@ -181,12 +287,15 @@
<child>
<object class="GtkVBox" id="vbox10">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
<object class="GtkHBox" id="hbox9">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label25">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xpad">5</property>
<property name="label" translatable="yes">Time in seconds to memorize the challenge:</property>
</object>
@@ -200,22 +309,30 @@
<object class="GtkSpinButton" id="prefspinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
<property name="adjustment">adjustment1</property>
<property name="climb_rate">1</property>
</object>
<packing>
<property name="expand">False</property>
+ <property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
+ <property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
@@ -225,6 +342,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
@@ -237,6 +355,8 @@
</child>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="padding">2</property>
<property name="position">3</property>
</packing>
@@ -244,9 +364,11 @@
<child>
<object class="GtkVBox" id="vbox12">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label29">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="ypad">5</property>
@@ -262,14 +384,17 @@
<child>
<object class="GtkHBox" id="hbox11">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
<object class="GtkTable" id="table5">
<property name="visible">True</property>
+ <property name="can_focus">False</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="can_focus">False</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 session:</property>
@@ -282,6 +407,7 @@
<child>
<object class="GtkLabel" id="label32">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">5</property>
<property name="label" translatable="yes">Maximum number of records in the player's game session history:</property>
@@ -297,6 +423,10 @@
<object class="GtkSpinButton" id="maxstoredspinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
<property name="adjustment">adjustment2</property>
<property name="climb_rate">1</property>
</object>
@@ -312,6 +442,10 @@
<object class="GtkSpinButton" id="minplayedspinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
<property name="adjustment">adjustment3</property>
<property name="climb_rate">1</property>
</object>
@@ -324,20 +458,25 @@
</object>
<packing>
<property name="expand">False</property>
+ <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox12">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
<object class="GtkHButtonBox" id="hbuttonbox2">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="border_width">1</property>
<property name="layout_style">start</property>
<child>
@@ -347,8 +486,9 @@
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
- <signal name="clicked" handler="OnCleanHistory"/>
+ <signal name="clicked" handler="OnCleanHistory" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@@ -358,62 +498,26 @@
</child>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="padding">5</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<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>
@@ -421,22 +525,4 @@
<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/gbrainy.cs b/src/Clients/Classical/gbrainy.cs
index d10f2a6..d65d97f 100644
--- a/src/Clients/Classical/gbrainy.cs
+++ b/src/Clients/Classical/gbrainy.cs
@@ -73,6 +73,7 @@ namespace gbrainy.Clients.Classical
bool full_screen;
GameSession.Types initial_session;
ITranslations translations;
+ static bool pluggins_loaded;
public readonly int MIN_TRANSLATION = 80;
@@ -117,7 +118,12 @@ namespace gbrainy.Clients.Classical
gm.LoadAssemblyGames (Defines.GAME_ASSEMBLY);
gm.LoadVerbalAnalogies (System.IO.Path.Combine (Defines.DATA_DIR, Defines.VERBAL_ANALOGIES));
gm.LoadGamesFromXml (System.IO.Path.Combine (Defines.DATA_DIR, Defines.GAMES_FILE));
- gm.LoadPlugins ();
+
+ if (Preferences.Get <bool> (Preferences.LoadPlugginsKey))
+ {
+ gm.LoadPlugins ();
+ pluggins_loaded = true;
+ }
}
void BuildUI ()
@@ -194,7 +200,11 @@ namespace gbrainy.Clients.Classical
#if MONO_ADDINS
extensions_menuitem.Activated += delegate (object sender, EventArgs ar)
- {
+ {
+ if (pluggins_loaded == false)
+ {
+ session.GameManager.LoadPlugins ();
+ }
Mono.Addins.Gui.AddinManagerWindow.Run (app_window);
GameManagerPreload (session.GameManager);
CustomGameDialog.Clear ();
diff --git a/src/Core/Main/Preferences.cs b/src/Core/Main/Preferences.cs
index 90bebc9..6b30a0f 100644
--- a/src/Core/Main/Preferences.cs
+++ b/src/Core/Main/Preferences.cs
@@ -42,6 +42,7 @@ namespace gbrainy.Core.Main
public const string ThemeKey = "Theme";
public const string EnglishKey = "English";
public const string EnglishVersionKey = "EnglishVersion";
+ public const string LoadPlugginsKey = "LoadExtensions";
static Preferences ()
{
@@ -139,6 +140,7 @@ namespace gbrainy.Core.Main
defaults.Add (ThemeKey, "notebook");
defaults.Add (EnglishVersionKey, string.Empty);
defaults.Add (EnglishKey, false.ToString ());
+ defaults.Add (LoadPlugginsKey, false.ToString ());
}
public static void Load ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]