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

commit b94f79a1d1bbcc1e1ce956f14dc6228ff1fd8d43
Author: bouleetbil <bouleet...@frogdev.info>
Date:   Thu Dec 30 23:41:17 2010 +0100

*switch to gtk instead glade for now
*fixes daemon
*added new module for see available update
* http://dors.frugalware.org/download/update.png
* pacman-g2 vala binding begin to works ^^ :p

diff --git a/frugal-tweak-vala/MainClient.vala 
b/frugal-tweak-vala/MainClient.vala
index 2b50a33..7b2fc7d 100644
--- a/frugal-tweak-vala/MainClient.vala
+++ b/frugal-tweak-vala/MainClient.vala
@@ -18,23 +18,32 @@
*/

using Gtk;
+using Tree;

int main (string[] args) {
-
-       //GTK
Gtk.init (ref args);

-       try {
-               var builder = new Builder ();
-               builder.add_from_file ("DATA/MainGUI.ui");
-               builder.connect_signals (null);
-               var window = builder.get_object ("MainWindow") as Window;
-               window.show_all ();
-               Gtk.main ();
-               } catch (Error e) {
-               stderr.printf ("Could not load UI: %s\n", e.message);
-               return 1;
-       }
+       var window = new Window ();
+       window.title = "Frugalware Tweak";
+       window.set_default_size (400, 300);
+       window.position = WindowPosition.CENTER;
+       window.destroy.connect (Gtk.main_quit);

-       return 0;
+/*
+       var button = new Button.with_label ("Click me!");
+       button.clicked.connect (() => {
+       button.label = "Thank you";
+       });
+
+       window.add (button);
+*/
+       //added treeview for modules
+       var view = new TreeView ();
+        Tree.setup_treeviewModule (view);
+       window.add(view);
+
+       window.show_all ();
+
+    Gtk.main ();
+    return 0;
}
diff --git a/frugal-tweak-vala/Makefile b/frugal-tweak-vala/Makefile
index c00b2a3..8bc53c9 100644
--- a/frugal-tweak-vala/Makefile
+++ b/frugal-tweak-vala/Makefile
@@ -5,14 +5,20 @@ VALAFLAG = DEBUG=1
DAEMONSOURCES = daemon.vala pacman.vala tools.vala DbusServer.vala
TERMINALSOURCES = terminal.vala mainwindow.vala
BROWSERSOURCES = browser.vala
-FRUGALTWEAKSOURCES = MainClient.vala
+PACMANUPDATESOURCES = Tree.vala Pacman-update.vala pacman.vala tools.vala
+
+#for start modules
+FRUGALTWEAKSOURCES = MainClient.vala Tree.vala
VALAC = valac

all: daemon terminal browser frugalwaretweak

frugalwaretweak:
-       gtk-builder-convert DATA/MainGUI.glade DATA/MainGUI.ui
-       $(VALAC) --define=$(VALAFLAG) --pkg gio-2.0 --pkg gtk+-2.0 --pkg 
gmodule-2.0 $(FRUGALTWEAKSOURCES) -o frugalware-tweak
+       #gtk-builder-convert DATA/MainGUI.glade DATA/MainGUI.ui
+       $(VALAC) --define=$(VALAFLAG) --pkg gio-2.0 --pkg gtk+-2.0 --pkg 
gmodule-2.0 --pkg pacman $(FRUGALTWEAKSOURCES) -o frugalware-tweak
+
+pacmanupdate:
+       $(VALAC) --define=$(VALAFLAG) --pkg gio-2.0 --pkg gtk+-2.0 --pkg 
gmodule-2.0  --pkg pacman $(PACMANUPDATESOURCES) -o 
frugalware-tweak-pacman-update

daemon:
$(VALAC) --define=$(VALAFLAG) --pkg pacman --pkg gio-2.0 $(DAEMONSOURCES) -o 
frugalware-tweak-daemon
diff --git a/frugal-tweak-vala/Pacman-update.vala 
b/frugal-tweak-vala/Pacman-update.vala
new file mode 100644
index 0000000..b76d970
--- /dev/null
+++ b/frugal-tweak-vala/Pacman-update.vala
@@ -0,0 +1,41 @@
+/*
+ *
+ * (C) 2010 bouleetbil <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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  
USA
+ */
+
+using Gtk;
+using Tree;
+
+int main (string[] args) {
+       Gtk.init (ref args);
+
+       var window = new Window ();
+       window.title = "Update packages";
+       window.set_default_size (400, 300);
+       window.position = WindowPosition.CENTER;
+       window.destroy.connect (Gtk.main_quit);
+
+       //added treeview for modules
+       var view = new TreeView ();
+        Tree.setup_treeviewPacmanUpdate (view);
+       window.add(view);
+
+       window.show_all ();
+
+    Gtk.main ();
+    return 0;
+}
diff --git a/frugal-tweak-vala/Tree.vala b/frugal-tweak-vala/Tree.vala
new file mode 100644
index 0000000..6e5df36
--- /dev/null
+++ b/frugal-tweak-vala/Tree.vala
@@ -0,0 +1,90 @@
+/*
+ *
+ * (C) 2010 bouleetbil <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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  
USA
+ */
+
+using Gtk;
+using Pacman;
+using pacman;
+
+public static class Tree {
+
+       public static void setup_treeviewModule(TreeView view) {
+
+       var listmodel = new ListStore (4, typeof (string), typeof (string),
+                                         typeof (string), typeof (string));
+       view.set_model (listmodel);
+
+       view.insert_column_with_attributes (-1, "Module", new CellRendererText 
(), "text", 0);
+       view.insert_column_with_attributes (-1, "Type", new CellRendererText 
(), "text", 1);
+
+       var cell = new CellRendererText ();
+       cell.set ("foreground_set", true);
+       view.insert_column_with_attributes (-1, "Balance", cell, "text", 2, 
"foreground", 3);
+
+       TreeIter iter;
+       listmodel.append (out iter);
+       listmodel.set (iter, 0, "System", 1, "test", 2, "102,10", 3, "red");
+
+       }
+
+public static void setup_treeviewPacmanUpdate(TreeView view) {
+
+       var listmodel = new ListStore (3, typeof (string), typeof (string),
+                                         typeof (string));
+       view.set_model (listmodel);
+
+       view.insert_column_with_attributes (-1, "Package", new CellRendererText 
(), "text", 0);
+       view.insert_column_with_attributes (-1, "Version", new CellRendererText 
(), "text", 1);
+       view.insert_column_with_attributes (-1, "Description", new 
CellRendererText (), "text", 2);
+
+       pacman pacmang2 = new pacman();
+       PM_LIST *i = null;
+
+               if (pacman_trans_init(Pacman.OptionTrans.TYPE_SYNC, 0, null, 
null, null) == -1) {
+                       Tools.ConsoleDebug("pacman_trans_init  failed \n");
+                       return ;
+               }
+
+               if (Pacman.pacman_trans_sysupgrade() == -1)
+               {
+                       Tools.ConsoleDebug("pacman_trans_sysupgrade failed \n");
+                       return ;
+               }
+               packages = pacman_trans_getinfo (OptionPM.PACKAGES);
+               if (packages == null)
+               {
+                       Tools.ConsoleDebug("No new updates are available\n");
+               }
+               else
+               {
+                       Tools.ConsoleDebug("Updates are available\n");
+                       TreeIter iter;
+
+                       for 
(i=pacman_list_first(packages);i!=null;i=pacman_list_next(i)) {
+                                       PM_SYNCPKG *spkg = pacman_list_getdata 
(i);
+                                       PM_PKG *pkg = pacman_sync_getinfo 
(spkg, OptionPMSYNC.PKG);
+                                       
Tools.ConsoleDebug((string)pacman_pkg_getinfo(pkg,OptionPMPKG.NAME)+"\n");
+                                       listmodel.append (out iter);
+                                       listmodel.set (iter, 0, 
(string)pacman_pkg_getinfo(pkg,OptionPMPKG.NAME), 1, 
(string)pacman_pkg_getinfo(pkg,OptionPMPKG.VERSION), 2, 
(string)pacman_pkg_getinfo(pkg,OptionPMPKG.DESC), 3);
+                               }
+
+               }
+               pacman_trans_release ();
+       }
+
+}
diff --git a/frugal-tweak-vala/daemon.vala b/frugal-tweak-vala/daemon.vala
index 79b1145..415e8ab 100644
--- a/frugal-tweak-vala/daemon.vala
+++ b/frugal-tweak-vala/daemon.vala
@@ -37,12 +37,12 @@ class Deamon : GLib.Object {
while(true)
{
#if DEBUG==1
-                       Thread.usleep(120000000); // 2minutes for tested
+                       Thread.usleep(120000); // 2minutes for tested
#else
Thread.usleep(1800000000);      //1/2 hour
Thread.usleep(1800000000); //1/2 hour
-                       UpdateAllDatabase();
#endif
+               UpdateAllDatabase();

}
}
diff --git a/frugal-tweak-vala/pacman.vala b/frugal-tweak-vala/pacman.vala
index 0038974..807708e 100644
--- a/frugal-tweak-vala/pacman.vala
+++ b/frugal-tweak-vala/pacman.vala
@@ -29,7 +29,7 @@ public class pacman
private static const string FW_STABLE                           ="frugalware";
private static const string FW_LOCAL                            ="local";
private static unowned Pacman.PM_DB sync_db     = null;
-       private static Pacman.PM_LIST *packages                 = null;
+       public static Pacman.PM_LIST *packages                  = null;
private static string[] repos                                            = new 
string[0];

public pacman()
@@ -89,7 +89,7 @@ public class pacman

}

-       public void bool CheckUpdate()
+       public void CheckUpdate()
{
PM_LIST *i = null;
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to