Author: jerome
Date: 2009-07-28 16:38:12 +0200 (Tue, 28 Jul 2009)
New Revision: 5212

Modified:
   
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.dcu
   
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.dfm
   
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.pas
Log:
* Updated the way to store / read TuxBox properties.

Modified: 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.dcu
===================================================================
(Binary files differ)

Modified: 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.dfm
===================================================================
--- 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.dfm
 2009-07-28 14:37:42 UTC (rev 5211)
+++ 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.dfm
 2009-07-28 14:38:12 UTC (rev 5212)
@@ -60,6 +60,7 @@
     Width = 955
     Height = 619
     TabOrder = 0
+    Silent = False
     RegisterAsBrowser = True
     RegisterAsDropTarget = False
     OnDocumentComplete = EmbeddedWB1DocumentComplete

Modified: 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.pas
===================================================================
--- 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.pas
 2009-07-28 14:37:42 UTC (rev 5211)
+++ 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.pas
 2009-07-28 14:38:12 UTC (rev 5212)
@@ -134,12 +134,13 @@
     procedure ShowBalloonTips(mess : string);
     procedure DeleteSysTrayIcon();
     procedure HideBalloonTips();
-    procedure setBalloonCanShow(showable : boolean);
+    procedure setBalloonCanShow(showable : string);
     procedure updateCaptions();
 
-    function isBalloonCanShow() : boolean;
+    function isBalloonCanShow() : string;
     function GetAllUsersDir() : string;
     function GetTuxDroidDataBaseDirectory() : string;
+    procedure saveProperties();
 
 
   private
@@ -163,6 +164,8 @@
   AppIcon          : TIcon;
   started          : boolean;
   balloonShowed    : boolean;
+  properties       : TStringList;
+  reduce_balloon   : boolean;
 
 implementation
 
@@ -176,10 +179,24 @@
 //Form initialization.
 procedure TForm1.FormCreate(Sender: TObject);
 begin
-
+  reduce_balloon := false;
   url := 'http://127.0.0.1:270/user/';
   TUXBOX_CONF_FILE := Form1.GetTuxDroidDataBaseDirectory
                       + '\configurations\TuxBox2.0.conf';
+
+  properties := TStringList.Create;
+
+  if FileExists(TUXBOX_CONF_FILE) then
+    begin
+      properties.LoadFromFile(TUXBOX_CONF_FILE);
+    end
+  else
+    begin
+      properties.CommaText := 'show_balloon=true, language=en';
+    end;
+
+  language := properties.Values['language'];
+
   started := false;
 
   //Setting app icon.
@@ -198,7 +215,7 @@
   EmbeddedWB1.Go('about:blank');
 
   //Initialization of GnuGetText object and updating language.
-  gnugettext.UseLanguage('en');
+  gnugettext.UseLanguage(language);
   TP_GlobalIgnoreClassProperty(TEmbeddedWB, 'StatusText');
   TP_Ignore(self, '.StatusText');
   TranslateComponent(self);
@@ -229,8 +246,14 @@
 begin
   if sender.ClassName = 'TForm1' then
     begin
-      if Form1.isBalloonCanShow() then
+      if isBalloonCanShow() = 'true' then
+        showmessage('true')
+      else
+        showmessage('false');
+
+      if Form1.isBalloonCanShow() = 'true' then
         begin
+          reduce_balloon := true;
           Form1.ShowBalloonTips(gettext(TUX_BOX_HIDDEN_0) + slinebreak +
                                 gettext(TUX_BOX_HIDDEN_1) + slinebreak +
                                 gettext(TUX_BOX_HIDDEN_2));
@@ -247,6 +270,8 @@
 procedure TForm1.WMQueryEndSession(var Message: TWMQueryEndSession);
 begin
   inherited;
+  Form1.saveProperties;
+  properties.Free;
   ConnectionChecker.Enabled := false;
   TuxUtils.stopServer();
   Shell_NotifyIcon(Nim_DELETE, @IconData);
@@ -328,6 +353,8 @@
 begin
   if TuxUtils.stopServer() then
     begin
+      Form1.saveProperties;
+      properties.Free;
       ConnectionChecker.Enabled := false;
       ConnectionChecker.Free;
       AppIcon.Free;
@@ -407,9 +434,10 @@
       PostMessage(Handle, WM_NULL, 0, 0);
     end
 
-  else if msg.LParam = NIN_BALLOONUSERCLICK then
+  else if (msg.LParam = NIN_BALLOONUSERCLICK) and (reduce_balloon) then
     begin
-      setBalloonCanShow(false);
+      setBalloonCanShow('false');
+      reduce_balloon := false;
     end
 
 end;
@@ -641,60 +669,23 @@
 
 
 { Return true if the balloon can be showed. }
-function TForm1.isBalloonCanShow() : boolean;
-var
-  res  : string;
-  F    : TextFile;
-  beginPos : Integer;
+function TForm1.isBalloonCanShow() : string;
 begin
-  if not FileExists(TUXBOX_CONF_FILE) then
-    begin
-      //Creating state file.
-      Form1.setBalloonCanShow(true);
-      result := true;
-    end
-  else
-    begin
-      try
-        AssignFile(F, TUXBOX_CONF_FILE);
-        reset(F);
-        readLn(F, res);
-        closeFile(F);
-        beginPos := Pos('show_balloon=', res) + Length('show_balloon=');
-        if(beginPos <> 0) then
-          begin
-            try
-              result := strtobool(Copy(res, beginPos, SizeOf(res) - 1))
-            except
-              on e : Exception do
-                result := true;
-            end;
-          end
-        else
-          result := true;
-
-      except
-        result := true;
-      end;
-    end;
+  result := properties.Values['show_balloon'];
 end;
 
 
 { Set the balloon visible or not }
-procedure TForm1.setBalloonCanShow(showable : boolean);
-var
-  F : TextFile;
+procedure TForm1.setBalloonCanShow(showable : string);
 begin
-  {$i+}
-  try
-    AssignFile(F, TUXBOX_CONF_FILE);
-    rewrite(F);
-    writeLn(F, 'show_balloon=' + booltostr(showable));
-    closeFile(F);
-  except
+  properties.Values['show_balloon'] := showable;
+end;
 
-  end;
-  {$i-}
+
+{#### Saving properties to the conf file ####}
+procedure TForm1.saveProperties();
+begin
+  properties.SaveToFile(TUXBOX_CONF_FILE);
 end;
 
 


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to