[gitg] dash: move clone and add buttons to the header bar
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] dash: move clone and add buttons to the header bar
- Date: Mon, 25 Jan 2016 20:44:25 +0000 (UTC)
commit 3d8d076d037e40c44b50ff5b9c9759df302fd513
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Mon Jan 25 20:46:22 2016 +0100
dash: move clone and add buttons to the header bar
gitg/gitg-dash-view.vala | 85 ++++++-----------------------------
gitg/gitg-window.vala | 66 +++++++++++++++++++++++++++
gitg/resources/ui/gitg-dash-view.ui | 34 --------------
gitg/resources/ui/gitg-window.ui | 32 +++++++++++++
4 files changed, 112 insertions(+), 105 deletions(-)
---
diff --git a/gitg/gitg-dash-view.vala b/gitg/gitg-dash-view.vala
index 37716cd..292ec09 100644
--- a/gitg/gitg-dash-view.vala
+++ b/gitg/gitg-dash-view.vala
@@ -45,9 +45,6 @@ class DashView : Gtk.Grid, GitgExt.UIElement, GitgExt.Activity, GitgExt.Selectab
[GtkChild( name = "repository_list_box" )]
private RepositoryListBox d_repository_list_box;
- [GtkChild( name = "action_bar" )]
- private Gtk.ActionBar d_action_bar;
-
public GitgExt.SelectionMode selectable_mode
{
get
@@ -76,11 +73,9 @@ class DashView : Gtk.Grid, GitgExt.UIElement, GitgExt.Activity, GitgExt.Selectab
{
case GitgExt.SelectionMode.NORMAL:
d_repository_list_box.mode = Gitg.SelectionMode.NORMAL;
- d_action_bar.visible = true;
break;
case GitgExt.SelectionMode.SELECTION:
d_repository_list_box.mode = Gitg.SelectionMode.SELECTION;
- d_action_bar.visible = false;
break;
}
@@ -216,7 +211,6 @@ class DashView : Gtk.Grid, GitgExt.UIElement, GitgExt.Activity, GitgExt.Selectab
d_repository_list_box.notify["mode"].connect(() => {
if (!d_setting_mode)
{
- d_action_bar.visible = (selectable_mode == GitgExt.SelectionMode.NORMAL);
notify_property("selectable-mode");
}
});
@@ -362,7 +356,7 @@ class DashView : Gtk.Grid, GitgExt.UIElement, GitgExt.Activity, GitgExt.Selectab
return repository;
}
- private void clone_repository(string url, File location, bool is_bare)
+ public void clone_repository(string url, File location, bool is_bare)
{
// create subfolder
var pos = url.last_index_of_char('/');
@@ -406,23 +400,6 @@ class DashView : Gtk.Grid, GitgExt.UIElement, GitgExt.Activity, GitgExt.Selectab
});
}
- [GtkCallback]
- private void clone_repository_clicked()
- {
- var dlg = new CloneDialog(application as Gtk.Window);
-
- dlg.response.connect((d, id) => {
- if (id == Gtk.ResponseType.OK)
- {
- clone_repository(dlg.url, dlg.location, dlg.is_bare);
- }
-
- d.destroy();
- });
-
- dlg.show();
- }
-
private void finish_add_repository(Repository repo)
{
var row = add_repository(repo);
@@ -596,54 +573,20 @@ class DashView : Gtk.Grid, GitgExt.UIElement, GitgExt.Activity, GitgExt.Selectab
dlg.get_window().set_cursor(new Gdk.Cursor.for_display(get_display(), Gdk.CursorType.WATCH));
}
- [GtkCallback]
- private void add_repository_clicked()
+ public void add_repository_from_location(File location, bool scan_all)
{
- var chooser = new Gtk.FileChooserDialog(_("Add Repository"),
- application as Gtk.Window,
- Gtk.FileChooserAction.SELECT_FOLDER,
- _("_Cancel"), Gtk.ResponseType.CANCEL,
- _("_Add"), Gtk.ResponseType.OK);
-
- var scan_all = new Gtk.CheckButton.with_mnemonic(_("_Scan for all git repositories from this
directory"));
-
- scan_all.halign = Gtk.Align.END;
- scan_all.hexpand = true;
- scan_all.show();
-
- chooser.extra_widget = scan_all;
-
- chooser.modal = true;
- chooser.set_default_response(Gtk.ResponseType.OK);
-
- chooser.response.connect((c, id) => {
- if (id == Gtk.ResponseType.OK)
- {
- var file = chooser.get_file();
-
- if (file == null)
- {
- file = chooser.get_current_folder_file();
- }
-
- if (scan_all.active)
- {
- add_repositories_scan(file);
- }
- else if (!looks_like_git(file))
- {
- query_create_repository(file);
- }
- else
- {
- do_add_repository(file, true);
- }
- }
-
- c.destroy();
- });
-
- chooser.show();
+ if (scan_all)
+ {
+ add_repositories_scan(location);
+ }
+ else if (!looks_like_git(location))
+ {
+ query_create_repository(location);
+ }
+ else
+ {
+ do_add_repository(location, true);
+ }
}
}
diff --git a/gitg/gitg-window.vala b/gitg/gitg-window.vala
index 9aa545e..2165dae 100644
--- a/gitg/gitg-window.vala
+++ b/gitg/gitg-window.vala
@@ -71,6 +71,10 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
[GtkChild]
private Gtk.Button d_dash_button;
[GtkChild]
+ private Gtk.Button d_clone_button;
+ [GtkChild]
+ private Gtk.Button d_add_button;
+ [GtkChild]
private Gtk.Image dash_image;
[GtkChild]
private Gtk.StackSwitcher d_activities_switcher;
@@ -161,6 +165,62 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
}
[GtkCallback]
+ private void clone_repository_clicked()
+ {
+ var dlg = new CloneDialog(this);
+
+ dlg.response.connect((d, id) => {
+ if (id == Gtk.ResponseType.OK)
+ {
+ d_dash_view.clone_repository(dlg.url, dlg.location, dlg.is_bare);
+ }
+
+ d.destroy();
+ });
+
+ dlg.show();
+ }
+
+ [GtkCallback]
+ private void add_repository_clicked()
+ {
+ var chooser = new Gtk.FileChooserDialog(_("Add Repository"),
+ this,
+ Gtk.FileChooserAction.SELECT_FOLDER,
+ _("_Cancel"), Gtk.ResponseType.CANCEL,
+ _("_Add"), Gtk.ResponseType.OK);
+
+ var scan_all = new Gtk.CheckButton.with_mnemonic(_("_Scan for all git repositories from this
directory"));
+
+ scan_all.halign = Gtk.Align.END;
+ scan_all.hexpand = true;
+ scan_all.show();
+
+ chooser.extra_widget = scan_all;
+
+ chooser.modal = true;
+ chooser.set_default_response(Gtk.ResponseType.OK);
+
+ chooser.response.connect((c, id) => {
+ if (id == Gtk.ResponseType.OK)
+ {
+ var file = chooser.get_file();
+
+ if (file == null)
+ {
+ file = chooser.get_current_folder_file();
+ }
+
+ d_dash_view.add_repository_from_location(file, scan_all.active);
+ }
+
+ c.destroy();
+ });
+
+ chooser.show();
+ }
+
+ [GtkCallback]
private void search_button_toggled(Gtk.ToggleButton button)
{
var searchable = current_activity as GitgExt.Searchable;
@@ -447,6 +507,8 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
d_main_stack.set_visible_child(d_stack_activities);
d_activities_switcher.show();
d_dash_button.show();
+ d_clone_button.hide();
+ d_add_button.hide();
d_dash_view.add_repository(d_repository);
d_gear_menu.menu_model = d_activities_model;
d_gear_menu.show();
@@ -459,6 +521,8 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
d_main_stack.set_visible_child(d_dash_view);
d_activities_switcher.hide();
d_dash_button.hide();
+ d_clone_button.show();
+ d_add_button.show();
d_gear_menu.menu_model = d_dash_model;
d_gear_menu.hide();
}
@@ -1111,6 +1175,8 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
d_gear_menu.visible = !issel && d_repository != null;
d_select_button.visible = !issel;
d_dash_button.visible = !issel && d_repository != null;
+ d_clone_button.visible = !issel && d_repository == null;
+ d_add_button.visible = !issel && d_repository == null;
d_activities_switcher.visible = !issel && d_repository != null;
d_select_cancel_button.visible = issel;
diff --git a/gitg/resources/ui/gitg-dash-view.ui b/gitg/resources/ui/gitg-dash-view.ui
index a1959f4..e982ec9 100644
--- a/gitg/resources/ui/gitg-dash-view.ui
+++ b/gitg/resources/ui/gitg-dash-view.ui
@@ -127,39 +127,5 @@
<property name="height">1</property>
</packing>
</child>
- <child>
- <object class="GtkActionBar" id="action_bar">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkButton" id="add_repository">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Add repository</property>
- <property name="use_underline">True</property>
- <signal name="clicked" handler="add_repository_clicked" swapped="no"/>
- </object>
- <packing>
- <property name="pack_type">end</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="clone_repository">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Clone repository</property>
- <property name="use_underline">True</property>
- <signal name="clicked" handler="clone_repository_clicked" swapped="no"/>
- </object>
- <packing>
- <property name="pack_type">end</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
</template>
</interface>
diff --git a/gitg/resources/ui/gitg-window.ui b/gitg/resources/ui/gitg-window.ui
index 7882273..60c28de 100644
--- a/gitg/resources/ui/gitg-window.ui
+++ b/gitg/resources/ui/gitg-window.ui
@@ -38,6 +38,38 @@
</packing>
</child>
<child>
+ <object class="GtkButton" id="d_clone_button">
+ <property name="visible">False</property>
+ <property name="valign">center</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Clone…</property>
+ <property name="tooltip-text" translatable="yes">Clone repository</property>
+ <signal name="clicked" handler="clone_repository_clicked" swapped="no"/>
+ <style>
+ <class name="text-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="pack_type">start</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="d_add_button">
+ <property name="visible">False</property>
+ <property name="valign">center</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Add…</property>
+ <property name="tooltip-text" translatable="yes">Add repository</property>
+ <signal name="clicked" handler="add_repository_clicked" swapped="no"/>
+ <style>
+ <class name="text-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="pack_type">start</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkStackSwitcher" id="d_activities_switcher">
<property name="visible">False</property>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]