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

commit 7c3566ee58a1112cac1906a26f1d5b5f475c5d44
Author: bouleetbil <bouleet...@frogdev.info>
Date:   Thu Sep 23 22:54:11 2010 +0200

*added grub entrys

diff --git a/frugal-irc/IconSummaryBody.cs b/frugal-irc/IconSummaryBody.cs
new file mode 100644
index 0000000..41fe597
--- /dev/null
+++ b/frugal-irc/IconSummaryBody.cs
@@ -0,0 +1,175 @@
+/*
+ *  Copyright (C) 2010 by Gaetan Gourdin <bouleet...@frogdev.info>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU 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.
+ */
+
+using System;
+using Notifications;
+
+public class IconSummaryBody
+{
+       enum Capability {
+               CAP_ACTIONS = 0,
+               CAP_BODY,
+               CAP_BODY_HYPERLINKS,
+               CAP_BODY_IMAGES,
+               CAP_BODY_MARKUP,
+               CAP_ICON_MULTI,
+               CAP_ICON_STATIC,
+               CAP_SOUND,
+               CAP_IMAGE_SVG,
+               CAP_SYNCHRONOUS,
+               CAP_APPEND,
+               CAP_LAYOUT_ICON_ONLY,
+               CAP_MAX}
+
+       bool[] m_capabilities = {false,  // actions
+                                       false,  // body
+                                       false,  // body-hyperlinks
+                                       false,  // body-imges
+                                       false,  // body-markup
+                                       false,  // icon-multi
+                                       false,  // icon-static
+                                       false,  // sound
+                                       false,  // image/svg+xml
+                                       false,  // synchronous-hint
+                                       false,  // append-hint
+                                       false}; // icon-only-hint
+
+       private void InitCaps ()
+       {
+
+               if (Global.Capabilities == null)
+                       return;
+
+               if (Array.IndexOf (Global.Capabilities, "actions") > -1)
+                       m_capabilities[(int) Capability.CAP_ACTIONS] = true;
+
+               if (Array.IndexOf (Global.Capabilities, "body") > -1)
+                       m_capabilities[(int) Capability.CAP_BODY] = true;
+
+               if (Array.IndexOf (Global.Capabilities, "body-hyperlinks") > -1)
+                       m_capabilities[(int) Capability.CAP_BODY_HYPERLINKS] = 
true;
+
+               if (Array.IndexOf (Global.Capabilities, "body-images") > -1)
+                       m_capabilities[(int) Capability.CAP_BODY_IMAGES] = true;
+
+               if (Array.IndexOf (Global.Capabilities, "body-markup") > -1)
+                       m_capabilities[(int) Capability.CAP_BODY_MARKUP] = true;
+
+               if (Array.IndexOf (Global.Capabilities, "icon-multi") > -1)
+                       m_capabilities[(int) Capability.CAP_ICON_MULTI] = true;
+
+               if (Array.IndexOf (Global.Capabilities, "icon-static") > -1)
+                       m_capabilities[(int) Capability.CAP_ICON_STATIC] = true;
+
+               if (Array.IndexOf (Global.Capabilities, "sound") > -1)
+                       m_capabilities[(int) Capability.CAP_SOUND] = true;
+
+               if (Array.IndexOf (Global.Capabilities, "image/svg+xml") > -1)
+                       m_capabilities[(int) Capability.CAP_IMAGE_SVG] = true;
+
+               if (Array.IndexOf (Global.Capabilities, "private-synchronous") 
> -1)
+                       m_capabilities[(int) Capability.CAP_SYNCHRONOUS] = true;
+
+               if (Array.IndexOf (Global.Capabilities, "append") > -1)
+                       m_capabilities[(int) Capability.CAP_APPEND] = true;
+
+               if (Array.IndexOf (Global.Capabilities, "private-icon-only") > 
-1)
+                       m_capabilities[(int) Capability.CAP_LAYOUT_ICON_ONLY] = 
true;
+       }
+
+       private void PrintCaps ()
+       {
+               Console.WriteLine ("Name:          "
+                                  + Global.ServerInformation.Name);
+               Console.WriteLine ("Vendor:        "
+                                  + Global.ServerInformation.Vendor);
+               Console.WriteLine ("Version:       "
+                                  + Global.ServerInformation.Version);
+               Console.WriteLine ("Spec. Version: "
+                                  + Global.ServerInformation.SpecVersion);
+
+               Console.WriteLine ("Supported capabilities/hints:");
+               if (m_capabilities[(int) Capability.CAP_ACTIONS])
+                       Console.WriteLine ("\tactions");
+               if (m_capabilities[(int) Capability.CAP_BODY])
+                       Console.WriteLine ("\tbody");
+               if (m_capabilities[(int) Capability.CAP_BODY_HYPERLINKS])
+                       Console.WriteLine ("\tbody-hyperlinks");
+               if (m_capabilities[(int) Capability.CAP_BODY_IMAGES])
+                       Console.WriteLine ("\tbody-images");
+               if (m_capabilities[(int) Capability.CAP_BODY_MARKUP])
+                       Console.WriteLine ("\tbody-markup");
+               if (m_capabilities[(int) Capability.CAP_ICON_MULTI])
+                       Console.WriteLine ("\ticon-multi");
+               if (m_capabilities[(int) Capability.CAP_ICON_STATIC])
+                       Console.WriteLine ("\ticon-static");
+               if (m_capabilities[(int) Capability.CAP_SOUND])
+                       Console.WriteLine ("\tsound");
+               if (m_capabilities[(int) Capability.CAP_IMAGE_SVG])
+                       Console.WriteLine ("\timage/svg+xml");
+               if (m_capabilities[(int) Capability.CAP_SYNCHRONOUS])
+                       Console.WriteLine ("\tprivate-synchronous");
+               if (m_capabilities[(int) Capability.CAP_APPEND])
+                       Console.WriteLine ("\tappend");
+               if (m_capabilities[(int) Capability.CAP_LAYOUT_ICON_ONLY])
+                       Console.WriteLine ("\tprivate-icon-only");
+
+               Console.WriteLine ("Notes:");
+               if (Global.ServerInformation.Name == "notify-osd")
+               {
+                       Console.WriteLine ("\tx- and y-coordinates hints are 
ignored");
+                       Console.WriteLine ("\texpire-timeout is ignored");
+                       Console.WriteLine ("\tbody-markup is accepted but 
filtered");
+               }
+               else
+                       Console.WriteLine ("\tnone");
+       }
+
+
+       public IconSummaryBody()
+       {
+               try{
+               // call this so we can savely use the m_capabilities array later
+               InitCaps ();
+
+               // show what's supported
+               PrintCaps ();
+               }
+               catch{}
+       }
+
+       public void ShowMessage (string title,string message)
+       {
+               try{
+               Notification n = new Notification(title,message,
+                                                  
"notification-message-IM");//TODO : use an icon
+               n.Show ();
+               }
+               catch{}
+       }
+
+       public void ShowMessage (string title,string message,Gdk.Pixbuf image )
+       {
+               try{
+               Notification n = new Notification(title,message,
+                                                 image);
+               n.Show ();
+               }
+               catch{}
+       }
+}
diff --git a/frugal-mono-tools/Fen_Menu.cs b/frugal-mono-tools/Fen_Menu.cs
index 9eba4ae..145d25a 100644
--- a/frugal-mono-tools/Fen_Menu.cs
+++ b/frugal-mono-tools/Fen_Menu.cs
@@ -214,6 +214,7 @@ namespace frugalmonotools
this.fen_grub= new WID_Grub();
this.HBOX_Details.PackStart(fen_grub);
this.HBOX_Details.ShowAll();
+                                                       
this.fen_grub.InitGrub();
break;

case cch_logs:
diff --git a/frugal-mono-tools/Grub.cs b/frugal-mono-tools/Grub.cs
index 5e8dfb5..a5c6d0b 100644
--- a/frugal-mono-tools/Grub.cs
+++ b/frugal-mono-tools/Grub.cs
@@ -23,14 +23,30 @@ namespace frugalmonotools
{
public struct GrubEntry
{
-               public string tittle;
-               public string root;
-               public string kernel;
-               public string initrd;
+               public string title;
+               public string options;

}
public class Grub
{
+               /*
+               default=0
+               timeout=5
+               gfxmenu (hd0,2)/boot/grub/message
+
+               title Frugalware 1.3.1340.g8af1a28 (Haven) - 2.6.35-fw2
+                       kernel (hd0,2)/boot/vmlinuz root=/dev/sda3 ro quiet 
resume=/dev/sda4
+
+               title Windows Seven
+               rootnoverify (hd0,0)
+               savedefault
+               makeactive
+               chainloader +1
+
+               title Memtest86+
+                       kernel (hd0,2)/boot/memtest.bin*/
+
+
private int _default=0;
public int GetDefault()
{
@@ -40,21 +56,53 @@ namespace frugalmonotools
{
_default=value;
}
-               public List<string> Entrys = new List<string>();
+               private int _timeout=0;
+               public int GetTimeout()
+               {
+                       return _timeout;
+               }
+               public void SetTimeOut(int value)
+               {
+                       _timeout=value;
+               }
+
+               private string _gfx="";
+               public string GetGfx()
+               {
+                       return _gfx;
+               }
+               public void SetGfx(string value)
+               {
+                       _gfx=value;
+               }
+
+               private string _options="";
+               public string GetOptions()
+               {
+                       return _options;
+               }
+               public void SetOptions(string value)
+               {
+                       _options=value;
+               }
+
+               public List<GrubEntry> Entrys = new List<GrubEntry>();

private const string cch_FileMenu = @"/boot/grub/menu.lst";

public Grub ()
{
+                       GrubEntry grubEntry = new GrubEntry();
+                       bool bo_entry = false;
string str_MenuLst = Outils.ReadFile(cch_FileMenu);
string[] lines = str_MenuLst.Split('\n');
//search default
foreach (string line in lines)
{
-                               if (line.IndexOf("default")==0)
+                               if (line.IndexOf("default=0")>=0)
{
//default entry find
-                                               string str_default = 
line.Replace("default","");
+                                               string str_default = 
line.Replace("default=","");
str_default=str_default.Trim();
try{
this.SetDefault(int.Parse(str_default));
@@ -63,6 +111,52 @@ namespace frugalmonotools
this.SetDefault(0);
}
}
+                               if (line.IndexOf("timeout=")>=0)
+                                   {
+                                               string str_time = 
line.Replace("timeout=","");
+                                               str_time=str_time.Trim();
+                                               try{
+                                                               
this.SetTimeOut(int.Parse(str_time));
+                                               }
+                                               catch{
+                                                               
this.SetTimeOut(0);
+                                               }
+                                       }
+                               if (line.IndexOf("gfxmenu")>=0)
+                                   {
+                                               string str_gfx = 
line.Replace("gfxmenu","");
+                                               str_gfx=str_gfx.Trim();
+                                               try{
+                                                               
this.SetGfx(str_gfx);
+                                               }
+                                               catch{
+                                                               this.SetGfx("");
+                                               }
+                                       }
+                               if (line.IndexOf("title")>=0)
+                               {
+                                       if(bo_entry)
+                                       {
+                                               Entrys.Add(grubEntry);
+                                               bo_entry=false;
+                                       }
+
+                                       bo_entry=true;
+                                       grubEntry = new GrubEntry();
+                                       
grubEntry.title=line.Replace("title","").Trim();
+
+                               }
+                               if (line.Trim()=="")
+                               {
+                                       if(bo_entry)
+                                               Entrys.Add(grubEntry);
+                                       bo_entry=false;
+                               }
+                               if ((line.Trim()!="") && 
(line.IndexOf("title")<0) &&(bo_entry))
+                               {
+                                       
grubEntry.options+=line.Replace("\t","").TrimEnd()+"\n";
+                               }
+
}
}
}
diff --git a/frugal-mono-tools/WID_Grub.cs b/frugal-mono-tools/WID_Grub.cs
index 30d5544..648a481 100644
--- a/frugal-mono-tools/WID_Grub.cs
+++ b/frugal-mono-tools/WID_Grub.cs
@@ -15,16 +15,48 @@
//  *  along with this program; if not, write to the Free Software
//  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
USA.
//  */
-using System;
+using System;
+using System.Collections.Generic;
+using Gtk;
+
namespace frugalmonotools
{
[System.ComponentModel.ToolboxItem(true)]
public partial class WID_Grub : Gtk.Bin
-       {
+       {
+               ListStore model = new ListStore (typeof (string),typeof (int));
+
public WID_Grub ()
{
this.Build ();
-               }
+               }
+               public void InitGrub()
+               {
+                       CBO_Entry.Model=model;
+                       int i = 0;
+                       TreeIter iter =new TreeIter();
+                       foreach (GrubEntry entry in MainClass.grub.Entrys)
+                       {
+                               string titre=entry.title;
+                               iter=model.AppendValues(titre,i);
+                               if(i==0)
+                                       CBO_Entry.SetActiveIter(iter);
+                               i++;
+                       }
+
+               }
+               protected virtual void OnCBOEntryChanged (object sender, 
System.EventArgs e)
+               {
+                       TreeIter iter;
+                       if ((sender as ComboBox).GetActiveIter (out iter))
+                       {
+                               int id =(int)model.GetValue (iter,1);
+                               
this.TXT_Options.Buffer.Text=MainClass.grub.Entrys[id].options;
+                               
this.SAI_Title.Text=MainClass.grub.Entrys[id].title;
+                       }
+               }
+
+
}
}

diff --git a/frugal-mono-tools/gtk-gui/frugalmonotools.WID_Grub.cs 
b/frugal-mono-tools/gtk-gui/frugalmonotools.WID_Grub.cs
index e941143..06cc8b9 100644
--- a/frugal-mono-tools/gtk-gui/frugalmonotools.WID_Grub.cs
+++ b/frugal-mono-tools/gtk-gui/frugalmonotools.WID_Grub.cs
@@ -112,6 +112,7 @@ namespace frugalmonotools
this.Child.ShowAll ();
}
this.Hide ();
+                       this.CBO_Entry.Changed += new 
global::System.EventHandler (this.OnCBOEntryChanged);
}
}
}
diff --git a/frugal-mono-tools/gtk-gui/gui.stetic 
b/frugal-mono-tools/gtk-gui/gui.stetic
index 79b7743..1909998 100644
--- a/frugal-mono-tools/gtk-gui/gui.stetic
+++ b/frugal-mono-tools/gtk-gui/gui.stetic
@@ -2850,6 +2850,7 @@ Public License instead of this License.
<property name="MemberName" />
<property name="IsTextCombo">True</property>
<property name="Items" translatable="yes" />
+            <signal name="Changed" handler="OnCBOEntryChanged" />
</widget>
<packing>
<property name="Position">0</property>
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to