[gitg/wip/sindhus/interactive-rebase] Set values of rebase action combo box appropriately



commit 658efbc6ccf9c4b39336e4a253e760e64fa1075f
Author: Sindhu S <sindhus live in>
Date:   Tue Sep 10 20:17:47 2013 +0530

    Set values of rebase action combo box appropriately

 gitg/gitg-rebase-list-box.vala             |   35 ++++++++++++++++++++++++---
 gitg/gitg-rebase-window.vala               |    2 +-
 gitg/resources/gitg-rebase-list-box-row.ui |    2 +-
 3 files changed, 33 insertions(+), 6 deletions(-)
---
diff --git a/gitg/gitg-rebase-list-box.vala b/gitg/gitg-rebase-list-box.vala
index c0d35cd..2a87c9c 100644
--- a/gitg/gitg-rebase-list-box.vala
+++ b/gitg/gitg-rebase-list-box.vala
@@ -28,6 +28,8 @@ namespace Gitg
                        private Gtk.Label r_commit_sha;
                        [GtkChild]
                        private Gtk.Label r_commit_msg;
+                       [GtkChild]
+                       private Gtk.ComboBox r_commit_action;
 
                        public string? commit_sha
                        {
@@ -41,15 +43,40 @@ namespace Gitg
                                set { r_commit_msg.set_markup("<b>%s</b>".printf(value)); }
                        }
 
-                       public Row(string commit_sha, string commit_msg)
+                       public string? commit_action
+                       {
+                               get {
+                                               Gtk.TreeIter selected_iter;
+                                               r_commit_action.get_active_iter(out selected_iter);
+                                               Value action_name;
+                                               r_commit_action.get_model().get_value(selected_iter, 0, out 
action_name);
+                                               return action_name.get_string();
+                               }
+                               set {
+                                               var action_id = 0;
+                                               switch (value)
+                                               {
+                                                       case "pick": action_id = 0;
+                                                                                break;
+                                                       case "squash": action_id = 1;
+                                                                                  break;
+                                                       case "fixup": action_id = 2;
+                                                                                 break;
+                                               }
+
+                                               r_commit_action.set_active(action_id);
+                                       }
+                       }
+
+                       public Row(string commit_action, string commit_sha, string commit_msg)
                        {
-                               Object(commit_sha: commit_sha, commit_msg: commit_msg);
+                               Object(commit_action: commit_action, commit_sha: commit_sha, commit_msg: 
commit_msg);
                        }
                }
 
-               public void add_rebase_row(string sha, string msg)
+               public void add_rebase_row(string action, string sha, string msg)
                {
-                       var row = new Row (sha, msg);
+                       var row = new Row (action, sha, msg);
                        row.show();
                        add(row);
                }
diff --git a/gitg/gitg-rebase-window.vala b/gitg/gitg-rebase-window.vala
index 6b7a848..94dd426 100644
--- a/gitg/gitg-rebase-window.vala
+++ b/gitg/gitg-rebase-window.vala
@@ -40,7 +40,7 @@ public class RebaseWindow : Gtk.Window
                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]);
+                       r_rebase_list_box.add_rebase_row(rebase_row[0], rebase_row[1], rebase_row[2]);
                }
        }
 }
diff --git a/gitg/resources/gitg-rebase-list-box-row.ui b/gitg/resources/gitg-rebase-list-box-row.ui
index ebc4a59..3b624f3 100644
--- a/gitg/resources/gitg-rebase-list-box-row.ui
+++ b/gitg/resources/gitg-rebase-list-box-row.ui
@@ -22,7 +22,7 @@
       <object class="GtkBox" id="r_gtk_box">
         <property name="orientation">horizontal</property>
         <child>
-          <object class="GtkComboBox" id="r_action_combo">
+          <object class="GtkComboBox" id="r_commit_action">
             <property name="active_id">0</property>
             <property name="active">0</property>
             <property name="visible">True</property>


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