[gitg/wip/sindhus/interactive-rebase] Populate the rebase window with parsed rebase-todo file



commit 48c2182ab0e2746f6c9f70265d746c56dbaaccde
Author: Sindhu S <sindhus live in>
Date:   Tue Sep 10 19:24:37 2013 +0530

    Populate the rebase window with parsed rebase-todo file

 gitg/gitg-application.vala   |    3 +--
 gitg/gitg-rebase-parser.vala |   23 +++++++++++++++--------
 gitg/gitg-rebase-window.vala |   21 +++++++++++++++------
 3 files changed, 31 insertions(+), 16 deletions(-)
---
diff --git a/gitg/gitg-application.vala b/gitg/gitg-application.vala
index 4c77853..5f666d5 100644
--- a/gitg/gitg-application.vala
+++ b/gitg/gitg-application.vala
@@ -165,9 +165,8 @@ public class Application : Gtk.Application
                if (Options.rebase != "")
                {
                        stderr.printf("Starting rebase: %s", Options.rebase);
-//                     var parser = new RebaseParser();
-//                     parser.parse_rebase_todo("/home/sindhus/git-rebase-todo");
                        var rebase_window = new RebaseWindow();
+                       rebase_window.load_rebase_todo("/home/sindhus/git-rebase-todo");
                        rebase_window.show_all();
                        Gtk.main();
                        return 0;
diff --git a/gitg/gitg-rebase-parser.vala b/gitg/gitg-rebase-parser.vala
index 426f8da..94b87f6 100644
--- a/gitg/gitg-rebase-parser.vala
+++ b/gitg/gitg-rebase-parser.vala
@@ -25,12 +25,11 @@ namespace Gitg
                {
                }
 
-               public void parse_rebase_todo(string filename)
+               public Gee.ArrayList<Gee.ArrayList<string>> parse_rebase_todo(string filename)
                {
                        string contents;
                        int line_number=0;
-                       string[,] rebase_array = new string[3,3];
-
+                       Gee.ArrayList<Gee.ArrayList<string>> rebase_array = new 
Gee.ArrayList<Gee.ArrayList<string>> ();
                        try
                        {
                                FileUtils.get_contents(filename, out contents);
@@ -42,13 +41,21 @@ namespace Gitg
                        {
                                string current_line = file_lines[line_number];
                                var line_words = current_line.split(" ");
-                               rebase_array[line_number,0] = line_words[0];
-                               rebase_array[line_number,1] = line_words[1];
-                               rebase_array[line_number,2] = string.joinv(" ", 
line_words[2:line_words.length-1]);
-
-                               stdout.printf("\naction: %s sha: %s msg: %s\n", rebase_array[line_number,0], 
rebase_array[line_number,1], rebase_array[line_number,2]);
+                               Gee.ArrayList<string> rebase_row = new Gee.ArrayList<string>();
+                               rebase_row.add(line_words[0]);
+                               rebase_row.add(line_words[1]);
+                               rebase_row.add(string.joinv(" ", line_words[2:line_words.length-1]));
+                               rebase_array.add(rebase_row);
                                line_number++;
                        }
+
+                       return rebase_array;
+               }
+
+               public string generate_rebase_todo(string[,] rebase_array)
+               {
+                       // Write function to generate rebase todo file back again
+                       return "";
                }
        }
 }
diff --git a/gitg/gitg-rebase-window.vala b/gitg/gitg-rebase-window.vala
index 89fd589..6b7a848 100644
--- a/gitg/gitg-rebase-window.vala
+++ b/gitg/gitg-rebase-window.vala
@@ -17,25 +17,34 @@
  * along with gitg. If not, see <http://www.gnu.org/licenses/>.
  */
 
-
 namespace Gitg
 {
 
 public class RebaseWindow : Gtk.Window
 {
+       private RebaseListBox r_rebase_list_box;
        public RebaseWindow()
        {
                this.title = "gitg Rebase";
                destroy.connect (Gtk.main_quit);
-               var rebase_listbox = new RebaseListBox();
-               rebase_listbox.add_rebase_row("sha1", "msg");
-               rebase_listbox.add_rebase_row("sha2", "msg");
-               rebase_listbox.add_rebase_row("sha3", "msg");
+               r_rebase_list_box = new RebaseListBox();
                var hbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 1);
                hbox.homogeneous = true;
-               hbox.add (rebase_listbox);
+               hbox.add (r_rebase_list_box);
                add (hbox);
        }
+
+       public void load_rebase_todo(string filepath)
+       {
+               var parser = new RebaseParser();
+               var rebase_array = parser.parse_rebase_todo(filepath);
+               foreach (var rebase_row in rebase_array)
+               {
+                       r_rebase_list_box.add_rebase_row(rebase_row[1], rebase_row[2]);
+               }
+       }
 }
 
+
+
 }
\ No newline at end of file


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]