[gitg] Do not use selection mode for commit list



commit 7b78f2f6ad7e5af068a5f7e1b0aea6a41613c9b7
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Sun Aug 9 20:36:20 2015 +0200

    Do not use selection mode for commit list

 gitg/history/gitg-history-paned.vala           |   23 ---
 gitg/history/gitg-history.vala                 |  175 +++++++++++-------------
 gitg/resources/ui/gitg-create-branch-dialog.ui |    2 +-
 gitg/resources/ui/gitg-create-tag-dialog.ui    |    2 +-
 4 files changed, 80 insertions(+), 122 deletions(-)
---
diff --git a/gitg/history/gitg-history-paned.vala b/gitg/history/gitg-history-paned.vala
index 7453aae..c1705c0 100644
--- a/gitg/history/gitg-history-paned.vala
+++ b/gitg/history/gitg-history-paned.vala
@@ -120,29 +120,6 @@ class Paned : Gitg.AnimatedPaned
                d_paned_panels.slide(child, Gitg.SlideDirection.OUT);
        }
 
-       private GitgExt.SelectionMode d_selectable_mode;
-
-       public GitgExt.SelectionMode selectable_mode
-       {
-               get { return d_selectable_mode; }
-               set
-               {
-                       if (d_selectable_mode != value)
-                       {
-                               d_selectable_mode = value;
-
-                               if (d_selectable_mode == GitgExt.SelectionMode.NORMAL)
-                               {
-                                       slide_in();
-                               }
-                               else
-                               {
-                                       slide_out();
-                               }
-                       }
-               }
-       }
-
        private void store_paned_position(Gitg.AnimatedPaned paned, Settings settings, string key)
        {
                if (paned.is_animating)
diff --git a/gitg/history/gitg-history.vala b/gitg/history/gitg-history.vala
index 8eedfbb..7571802 100644
--- a/gitg/history/gitg-history.vala
+++ b/gitg/history/gitg-history.vala
@@ -29,7 +29,7 @@ namespace GitgHistory
        /* The main history view. This view shows the equivalent of git log, but
         * in a nice way with lanes, merges, ref labels etc.
         */
-       public class Activity : Object, GitgExt.UIElement, GitgExt.Activity, GitgExt.Selectable, 
GitgExt.Searchable, GitgExt.History
+       public class Activity : Object, GitgExt.UIElement, GitgExt.Activity, GitgExt.Searchable, 
GitgExt.History
        {
                // Do this to pull in config.h before glib.h (for gettext...)
                private const string version = Gitg.Config.VERSION;
@@ -547,11 +547,6 @@ namespace GitgHistory
                                                  BindingFlags.DEFAULT |
                                                  BindingFlags.SYNC_CREATE);
 
-                       bind_property("selectable-mode",
-                                     d_main,
-                                     "selectable-mode",
-                                     BindingFlags.BIDIRECTIONAL);
-
                        d_main.commit_list_view.set_search_equal_func(search_filter_func);
                }
 
@@ -613,7 +608,7 @@ namespace GitgHistory
 
                        if (ret == null)
                        {
-                               selectable_mode = GitgExt.SelectionMode.SELECTION;
+                               ret = popup_menu_for_commit(event);
                        }
 
                        return ret;
@@ -628,6 +623,82 @@ namespace GitgHistory
                        }
                }
 
+               private Gtk.Menu? popup_menu_for_commit(Gdk.EventButton? event)
+               {
+                       int cell_x;
+                       int cell_y;
+                       Gtk.TreePath path;
+                       Gtk.TreeViewColumn column;
+
+                       if (!d_main.commit_list_view.get_path_at_pos((int)event.x,
+                                                                    (int)event.y,
+                                                                    out path,
+                                                                    out column,
+                                                                    out cell_x,
+                                                                    out cell_y))
+                       {
+                               return null;
+                       }
+
+                       var commit = d_commit_list_model.commit_from_path(path);
+
+                       if (commit == null)
+                       {
+                               return null;
+                       }
+
+                       d_main.commit_list_view.get_selection().select_path(path);
+
+                       var af = new ActionInterface(application, d_main.refs_list);
+
+                       var actions = new Gee.LinkedList<GitgExt.CommitAction>();
+
+                       add_commit_action(actions,
+                                         new Gitg.CommitActionCreateBranch(application,
+                                                                           af,
+                                                                           commit));
+
+                       add_commit_action(actions,
+                                         new Gitg.CommitActionCreateTag(application,
+                                                                        af,
+                                                                        commit));
+
+                       add_commit_action(actions,
+                                         new Gitg.CommitActionCreatePatch(application,
+                                                                          af,
+                                                                          commit));
+
+                       var exts = new Peas.ExtensionSet(Gitg.PluginsEngine.get_default(),
+                                                        typeof(GitgExt.CommitAction),
+                                                        "application",
+                                                        application,
+                                                        "action_interface",
+                                                        af,
+                                                        "commit",
+                                                        commit);
+
+                       exts.foreach((extset, info, extension) => {
+                               add_commit_action(actions, extension as GitgExt.CommitAction);
+                       });
+
+                       if (actions.size == 0)
+                       {
+                               return null;
+                       }
+
+                       Gtk.Menu menu = new Gtk.Menu();
+
+                       foreach (var ac in actions)
+                       {
+                               ac.populate_menu(menu);
+                       }
+
+                       // To keep actions alive as long as the menu is alive
+                       menu.set_data("gitg-ext-actions", actions);
+
+                       return menu;
+               }
+
                private Gtk.Menu? popup_menu_for_ref(Gitg.Ref reference)
                {
                        var actions = new Gee.LinkedList<GitgExt.RefAction>();
@@ -828,16 +899,6 @@ namespace GitgHistory
                        d_commit_list_model.reload();
                }
 
-               public GitgExt.SelectionMode selectable_mode
-               {
-                       get; set;
-               }
-
-               public bool selectable_available
-               {
-                       get { return true; }
-               }
-
                public bool search_available
                {
                        get { return true; }
@@ -849,86 +910,6 @@ namespace GitgHistory
                        if (action != null && action.available)
                        {
                                actions.add(action);
-                               action.finished.connect(() => {
-                                       selectable_mode = GitgExt.SelectionMode.NORMAL;
-                               });
-                       }
-               }
-
-               public Gtk.Widget? action_widget
-               {
-                       owned get
-                       {
-                               Gitg.Commit? commit = null;
-
-                               foreach_selected((c) => {
-                                       commit = (Gitg.Commit)c;
-                                       return false;
-                               });
-
-                               var af = new ActionInterface(application, d_main.refs_list);
-
-                               var actions = new Gee.LinkedList<GitgExt.CommitAction>();
-
-                               add_commit_action(actions,
-                                                 new Gitg.CommitActionCreateBranch(application,
-                                                                                   af,
-                                                                                   commit));
-
-                               add_commit_action(actions,
-                                                 new Gitg.CommitActionCreateTag(application,
-                                                                                af,
-                                                                                commit));
-
-                               add_commit_action(actions,
-                                                 new Gitg.CommitActionCreatePatch(application,
-                                                                                  af,
-                                                                                  commit));
-
-                               var exts = new Peas.ExtensionSet(Gitg.PluginsEngine.get_default(),
-                                                                typeof(GitgExt.CommitAction),
-                                                                "application",
-                                                                application,
-                                                                "action_interface",
-                                                                af,
-                                                                "commit",
-                                                                commit);
-
-                               exts.foreach((extset, info, extension) => {
-                                       add_commit_action(actions, extension as GitgExt.CommitAction);
-                               });
-
-                               var ab = new Gtk.ActionBar();
-                               ab.show();
-
-                               var box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 6);
-                               box.margin = 6;
-                               box.homogeneous = true;
-                               box.show();
-
-                               foreach (var action in actions)
-                               {
-                                       var widget = action.widget;
-
-                                       if (widget == null)
-                                       {
-                                               var button = new Gtk.Button.with_label(action.display_name);
-                                               button.tooltip_text = action.description;
-
-                                               button.clicked.connect(() => {
-                                                       action.activate();
-                                               });
-
-                                               widget = button;
-                                       }
-
-                                       widget.show();
-                                       box.add(widget);
-                               }
-
-                               ab.set_center_widget(box);
-
-                               return ab;
                        }
                }
 
diff --git a/gitg/resources/ui/gitg-create-branch-dialog.ui b/gitg/resources/ui/gitg-create-branch-dialog.ui
index 15f3da2..6fad903 100644
--- a/gitg/resources/ui/gitg-create-branch-dialog.ui
+++ b/gitg/resources/ui/gitg-create-branch-dialog.ui
@@ -3,7 +3,7 @@
   <!-- interface-requires gtk+ 3.0 -->
   <template class="GitgCreateBranchDialog" parent="GtkDialog">
     <property name="can_focus">False</property>
-    <property name="border_width">5</property>
+    <property name="border_width">12</property>
     <property name="title" translatable="yes">Create Branch</property>
     <property name="resizable">False</property>
     <property name="modal">True</property>
diff --git a/gitg/resources/ui/gitg-create-tag-dialog.ui b/gitg/resources/ui/gitg-create-tag-dialog.ui
index 493da9a..221a1b1 100644
--- a/gitg/resources/ui/gitg-create-tag-dialog.ui
+++ b/gitg/resources/ui/gitg-create-tag-dialog.ui
@@ -3,7 +3,7 @@
   <!-- interface-requires gtk+ 3.12 -->
   <template class="GitgCreateTagDialog" parent="GtkDialog">
     <property name="can_focus">False</property>
-    <property name="border_width">5</property>
+    <property name="border_width">12</property>
     <property name="title" translatable="yes">Create Tag</property>
     <property name="resizable">True</property>
     <property name="modal">True</property>


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