[gitg/wip/sindhus/interactive-rebase] Added definition for rebase listbox



commit 91cb7dba35874085c05aed9fe9a495a415a870e7
Author: Sindhu S <sindhus live in>
Date:   Mon Sep 9 18:30:27 2013 +0530

    Added definition for rebase listbox

 gitg/gitg-rebase-list-box.vala                |   53 +++++++++++++++++++++++++
 gitg/gitg-rebase-parser.vala                  |   20 +++------
 libgitg/resources/gitg-rebase-list-box-row.ui |   19 +++++++++
 3 files changed, 79 insertions(+), 13 deletions(-)
---
diff --git a/gitg/gitg-rebase-list-box.vala b/gitg/gitg-rebase-list-box.vala
new file mode 100644
index 0000000..ea1611f
--- /dev/null
+++ b/gitg/gitg-rebase-list-box.vala
@@ -0,0 +1,53 @@
+/*
+ * This file is part of gitg
+ *
+ * Copyright (C) 2013 - Sindhu S
+ *
+ * gitg 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.
+ *
+ * gitg 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 gitg. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Gitg
+{
+       public class RepositoryListBox : Gtk.ListBox
+       {
+               [GtkTemplate (ui = "/org/gnome/gitg/gtk/gitg-rebase-list-box-row.ui")]
+               private class Row : Gtk.ListBoxRow
+               {
+                       [GtkChild]
+                       private Gtk.Label r_commit_sha;
+                       [GtkChild]
+                       private Gtk.Label r_commit_msg;
+
+                       public string? commit_sha
+                       {
+                               get { return r_commit_sha.get_text(); }
+                               set { r_commit_sha.set_markup("<b>%s</b>".printf(value)); }
+                       }
+
+                       public string? commit_msg
+                       {
+                               get { return r_commit_msg.get_text(); }
+                               set { r_commit_msg.set_markup("<b>%s</b>".printf(value)); }
+                       }
+
+                       public Row(string commit_sha, string commit_msg)
+                       {
+                               Object(commit_sha: commit_sha, commit_msg: commit_msg);
+                       }
+               }
+       }
+
+}
+
+// ex:ts=4 noet
diff --git a/gitg/gitg-rebase-parser.vala b/gitg/gitg-rebase-parser.vala
index 23d75e9..426f8da 100644
--- a/gitg/gitg-rebase-parser.vala
+++ b/gitg/gitg-rebase-parser.vala
@@ -29,32 +29,26 @@ namespace Gitg
                {
                        string contents;
                        int line_number=0;
-//                     string[,] rebase_array = {};
+                       string[,] rebase_array = new string[3,3];
 
                        try
                        {
                                FileUtils.get_contents(filename, out contents);
                        }
-                       catch(Glib.Error e)
-                       {
-                               stdout.printf("The file does not exist!");
-                       }
+                       catch {}
 
                        var file_lines = contents.split("\n");
                        while (file_lines[line_number][0] != '#' && file_lines[line_number] != "")
                        {
-                               string[] temp_array = new string [3];
                                string current_line = file_lines[line_number];
                                var line_words = current_line.split(" ");
-                               temp_array[0] = line_words[0];
-                               temp_array[1] = line_words[1];
-                               temp_array[2] = string.joinv(" ", line_words[2:line_words.length-1]);
-//                             rebase_array += temp_array;
-                               stdout.printf("\naction: %s sha: %s msg: %s\n", temp_array[0], temp_array[1], 
temp_array[2]);
+                               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]);
                                line_number++;
                        }
-
-
                }
        }
 }
diff --git a/libgitg/resources/gitg-rebase-list-box-row.ui b/libgitg/resources/gitg-rebase-list-box-row.ui
new file mode 100644
index 0000000..73b80a1
--- /dev/null
+++ b/libgitg/resources/gitg-rebase-list-box-row.ui
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.8 -->
+  <template class="GitgRepositoryListBoxRow" parent="GtkListBoxRow">
+    <child>
+      <object class="GtkBox">
+        <property name="orientation">horizontal</property>
+        <child>
+          <object class="GtkLabel" id="r_commit_sha">
+          </object>
+        </child>
+        <child>
+          <object class="GtkLabel" id="r_commit_message">
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>


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