Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=frugal-tweak.git;a=commitdiff;h=87af7bdda5a34902214da8112203528c891fb3d2

commit 87af7bdda5a34902214da8112203528c891fb3d2
Author: bouleetbil <bouleet...@frogdev.info>
Date:   Fri Sep 17 22:36:34 2010 +0200

*added timeconfig

diff --git a/frugal-mono-tools/ConfSystem.cs b/frugal-mono-tools/ConfSystem.cs
index 399e2be..fc9e52b 100644
--- a/frugal-mono-tools/ConfSystem.cs
+++ b/frugal-mono-tools/ConfSystem.cs
@@ -29,12 +29,18 @@ namespace frugalmonotools
const string cch_release=@"/etc/frugalware-release";
const string cch_locale=@"/etc/profile.d/lang.sh";
const string cch_keymap=@"/etc/sysconfig/keymap";
+               const string cch_time=@"/etc/hardwareclock";
+               const string cch_LocalTime="localtime";
+               const string cch_UTC="UTC";
+
private string _hostname;
private string _locale;
private string _distribution; //can't change it
private string _keymap;
+               private string _localTime;
public List<string>  LocaleSystem = new List<string>();
public List<string>  KeymapSystem = new List<string>();
+               public List<string>  LocalTimeSystem = new List<string>();
public string GetHostname()
{
return _hostname;
@@ -90,15 +96,45 @@ namespace frugalmonotools
catch{  }
return "";
}
+
public void SetKeymap(string keymap) {
_keymap=keymap;
}
+
+               public string GetLocalTime()
+               {
+                       try{
+                               string content = Outils.ReadFile(cch_keymap);
+                               string[] lines = content.Split('\n');
+                               foreach (string line in lines)
+                               {
+                                        if (Regex.Matches(line, 
cch_LocalTime).Count>0)
+                                               {
+                                                       
_localTime=cch_LocalTime;
+                                                       return _localTime;
+                                               }
+                                       if (Regex.Matches(line, 
cch_UTC).Count>0)
+                                               {
+                                                       _localTime=cch_UTC;
+                                                       return _localTime;
+                                               }
+                               }
+                       }
+                       catch{  }
+                       return cch_LocalTime;
+               }
+               public void SetTime(string time) {
+                       _localTime=time;
+               }
+
public ConfSystem ()
{
this.SetHostname(Outils.ReadFile(cch_hostname).ToString().Replace("\n",""));
this._distribution=Outils.ReadFile(cch_release).ToString().Replace("\n","");
_findLocaleSystem();
_findKeymapSystem();
+                       LocalTimeSystem.Add(cch_LocalTime);
+                       LocalTimeSystem.Add(cch_UTC);
}
private void _findKeymapSystem()
{
@@ -130,6 +166,7 @@ namespace frugalmonotools
{
try
{
+
//save hostname
StreamWriter FileConf = new StreamWriter(cch_hostname);
FileConf.WriteLine(this.GetHostname());
@@ -183,6 +220,12 @@ namespace frugalmonotools
}
FileConf.Close();

+                               //save localtime
+                               FileConf = new StreamWriter(cch_time);
+                               FileConf.WriteLine("# /etc/hardwareclock");
+                               FileConf.WriteLine("# this file is generated by 
timeconfig");
+                               FileConf.WriteLine(this.GetLocalTime());
+                               FileConf.Close();
}
catch(Exception exe)
{
diff --git a/frugal-mono-tools/WID_System.cs b/frugal-mono-tools/WID_System.cs
index 7e6507f..3ec5341 100644
--- a/frugal-mono-tools/WID_System.cs
+++ b/frugal-mono-tools/WID_System.cs
@@ -25,6 +25,7 @@ namespace frugalmonotools
private ConfSystem  confSystem = new ConfSystem();
ListStore modelLocale = new ListStore (typeof (string));
ListStore modelKeymap = new ListStore (typeof (string));
+               ListStore modelTime = new ListStore (typeof (string));
private Gtk.TreeIter iter;

public WID_System ()
@@ -54,16 +55,25 @@ namespace frugalmonotools
foreach (string keymap in  confSystem.KeymapSystem)
{
iter=modelKeymap.AppendValues(keymap);
-                               //Console.WriteLine("compare 
"+confSystem.GetKeymap()+" "+keymap);
if(confSystem.GetKeymap()==keymap)
CBO_Keymap.SetActiveIter(iter);
}
+
+                       CBO_Time.Model=modelTime;
+                       foreach (string time in  confSystem.LocalTimeSystem)
+                       {
+                               iter=modelTime.AppendValues(time);
+                               if(confSystem.GetLocalTime()==time)
+                                       CBO_Time.SetActiveIter(iter);
+                       }

}
protected virtual void OnBTNSystemClicked (object sender, System.EventArgs e)
{
confSystem.SetHostname(SAI_Host.Text);
confSystem.SetLocale(CBO_Locale.Entry.Text);
+                       confSystem.SetKeymap(CBO_Keymap.Entry.Text);
+                       confSystem.SetTime(CBO_Time.Entry.Text);
confSystem.Save();
}

diff --git a/frugal-mono-tools/gtk-gui/frugalmonotools.WID_System.cs 
b/frugal-mono-tools/gtk-gui/frugalmonotools.WID_System.cs
index acec353..eccfe75 100644
--- a/frugal-mono-tools/gtk-gui/frugalmonotools.WID_System.cs
+++ b/frugal-mono-tools/gtk-gui/frugalmonotools.WID_System.cs
@@ -48,6 +48,12 @@ namespace frugalmonotools

private global::Gtk.ComboBoxEntry CBO_Keymap;

+               private global::Gtk.HBox hbox2;
+
+               private global::Gtk.Label label18;
+
+               private global::Gtk.ComboBoxEntry CBO_Time;
+
private global::Gtk.HBox hbox29;

private global::Gtk.Button BTN_System;
@@ -254,6 +260,32 @@ namespace frugalmonotools
w21.Expand = false;
w21.Fill = false;
// Container child vbox11.Gtk.Box+BoxChild
+                       this.hbox2 = new global::Gtk.HBox ();
+                       this.hbox2.Name = "hbox2";
+                       this.hbox2.Spacing = 6;
+                       // Container child hbox2.Gtk.Box+BoxChild
+                       this.label18 = new global::Gtk.Label ();
+                       this.label18.Name = "label18";
+                       this.label18.LabelProp = 
global::Mono.Unix.Catalog.GetString ("Time config");
+                       this.hbox2.Add (this.label18);
+                       global::Gtk.Box.BoxChild w22 = 
((global::Gtk.Box.BoxChild)(this.hbox2[this.label18]));
+                       w22.Position = 0;
+                       w22.Expand = false;
+                       w22.Fill = false;
+                       // Container child hbox2.Gtk.Box+BoxChild
+                       this.CBO_Time = global::Gtk.ComboBoxEntry.NewText ();
+                       this.CBO_Time.Name = "CBO_Time";
+                       this.hbox2.Add (this.CBO_Time);
+                       global::Gtk.Box.BoxChild w23 = 
((global::Gtk.Box.BoxChild)(this.hbox2[this.CBO_Time]));
+                       w23.Position = 2;
+                       w23.Expand = false;
+                       w23.Fill = false;
+                       this.vbox11.Add (this.hbox2);
+                       global::Gtk.Box.BoxChild w24 = 
((global::Gtk.Box.BoxChild)(this.vbox11[this.hbox2]));
+                       w24.Position = 7;
+                       w24.Expand = false;
+                       w24.Fill = false;
+                       // Container child vbox11.Gtk.Box+BoxChild
this.hbox29 = new global::Gtk.HBox ();
this.hbox29.Name = "hbox29";
this.hbox29.Spacing = 6;
@@ -264,15 +296,15 @@ namespace frugalmonotools
this.BTN_System.UseUnderline = true;
this.BTN_System.Label = global::Mono.Unix.Catalog.GetString ("Apply");
this.hbox29.Add (this.BTN_System);
-                       global::Gtk.Box.BoxChild w22 = 
((global::Gtk.Box.BoxChild)(this.hbox29[this.BTN_System]));
-                       w22.Position = 2;
-                       w22.Expand = false;
-                       w22.Fill = false;
+                       global::Gtk.Box.BoxChild w25 = 
((global::Gtk.Box.BoxChild)(this.hbox29[this.BTN_System]));
+                       w25.Position = 2;
+                       w25.Expand = false;
+                       w25.Fill = false;
this.vbox11.Add (this.hbox29);
-                       global::Gtk.Box.BoxChild w23 = 
((global::Gtk.Box.BoxChild)(this.vbox11[this.hbox29]));
-                       w23.Position = 7;
-                       w23.Expand = false;
-                       w23.Fill = false;
+                       global::Gtk.Box.BoxChild w26 = 
((global::Gtk.Box.BoxChild)(this.vbox11[this.hbox29]));
+                       w26.Position = 8;
+                       w26.Expand = false;
+                       w26.Fill = false;
this.Add (this.vbox11);
if ((this.Child != null)) {
this.Child.ShowAll ();
diff --git a/frugal-mono-tools/gtk-gui/gui.stetic 
b/frugal-mono-tools/gtk-gui/gui.stetic
index a73f70e..ccc1017 100644
--- a/frugal-mono-tools/gtk-gui/gui.stetic
+++ b/frugal-mono-tools/gtk-gui/gui.stetic
@@ -622,7 +622,7 @@
</widget>
</child>
</widget>
-  <widget class="Gtk.Bin" id="frugalmonotools.WID_System" design-size="477 
465">
+  <widget class="Gtk.Bin" id="frugalmonotools.WID_System" design-size="477 
498">
<property name="MemberName" />
<property name="Visible">False</property>
<child>
@@ -909,6 +909,46 @@
</packing>
</child>
<child>
+          <widget class="Gtk.HBox" id="hbox2">
+            <property name="MemberName" />
+            <property name="Spacing">6</property>
+            <child>
+              <widget class="Gtk.Label" id="label18">
+                <property name="MemberName" />
+                <property name="LabelProp" translatable="yes">Time 
config</property>
+              </widget>
+              <packing>
+                <property name="Position">0</property>
+                <property name="AutoSize">True</property>
+                <property name="Expand">False</property>
+                <property name="Fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <placeholder />
+            </child>
+            <child>
+              <widget class="Gtk.ComboBoxEntry" id="CBO_Time">
+                <property name="MemberName" />
+                <property name="IsTextCombo">True</property>
+                <property name="Items" translatable="yes" />
+              </widget>
+              <packing>
+                <property name="Position">2</property>
+                <property name="AutoSize">True</property>
+                <property name="Expand">False</property>
+                <property name="Fill">False</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="Position">7</property>
+            <property name="AutoSize">True</property>
+            <property name="Expand">False</property>
+            <property name="Fill">False</property>
+          </packing>
+        </child>
+        <child>
<widget class="Gtk.HBox" id="hbox29">
<property name="MemberName" />
<property name="Spacing">6</property>
@@ -936,7 +976,7 @@
</child>
</widget>
<packing>
-            <property name="Position">7</property>
+            <property name="Position">8</property>
<property name="AutoSize">True</property>
<property name="Expand">False</property>
<property name="Fill">False</property>
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to