[gnome-builder] vcsup: add "Push Branch" menu item
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] vcsup: add "Push Branch" menu item
- Date: Mon, 6 May 2019 04:53:34 +0000 (UTC)
commit 780b92478cdde84e68a5836ae235988fb2e95292
Author: Christian Hergert <chergert redhat com>
Date: Sun May 5 21:50:08 2019 -0700
vcsup: add "Push Branch" menu item
This is going to change, but it gives us something to start with
to push changes to the remote. Nothing special at the moment.
src/plugins/vcsui/gbp-vcsui-tree-addin.c | 47 ++++++++++++++++++++++++++++++++
src/plugins/vcsui/gtk/menus.ui | 16 +++++++----
2 files changed, 58 insertions(+), 5 deletions(-)
---
diff --git a/src/plugins/vcsui/gbp-vcsui-tree-addin.c b/src/plugins/vcsui/gbp-vcsui-tree-addin.c
index 2702a237c..260b8ed34 100644
--- a/src/plugins/vcsui/gbp-vcsui-tree-addin.c
+++ b/src/plugins/vcsui/gbp-vcsui-tree-addin.c
@@ -125,7 +125,50 @@ gbp_vcsui_tree_addin_switch_branch (GSimpleAction *action,
NULL,
gbp_vcsui_tree_addin_switch_branch_cb,
g_object_ref (self));
+}
+
+static void
+gbp_vcsui_tree_addin_push_branch_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ IdeVcs *vcs = (IdeVcs *)object;
+ g_autoptr(GError) error = NULL;
+
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (IDE_IS_VCS (vcs));
+ g_assert (G_IS_ASYNC_RESULT (result));
+
+ if (!ide_vcs_push_branch_finish (vcs, result, &error))
+ ide_object_warning (vcs, "%s", error->message);
+}
+
+static void
+gbp_vcsui_tree_addin_push_branch (GSimpleAction *action,
+ GVariant *param,
+ gpointer user_data)
+{
+ GbpVcsuiTreeAddin *self = user_data;
+ g_autoptr(IdeContext) context = NULL;
+ IdeVcsBranch *branch;
+ IdeTreeNode *node;
+
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_VCSUI_TREE_ADDIN (self));
+
+ if (self->vcs == NULL ||
+ !(node = ide_tree_get_selected_node (self->tree)) ||
+ !ide_tree_node_holds (node, IDE_TYPE_VCS_BRANCH))
+ return;
+
+ branch = ide_tree_node_get_item (node);
+ context = ide_object_ref_context (IDE_OBJECT (self->vcs));
+ ide_vcs_push_branch_async (self->vcs,
+ branch,
+ NULL,
+ gbp_vcsui_tree_addin_push_branch_cb,
+ g_object_ref (self));
}
static void
@@ -141,6 +184,7 @@ gbp_vcsui_tree_addin_load (IdeTreeAddin *addin,
IdeVcs *vcs;
static const GActionEntry actions[] = {
{ "switch-branch", gbp_vcsui_tree_addin_switch_branch },
+ { "push-branch", gbp_vcsui_tree_addin_push_branch },
};
g_assert (IDE_IS_MAIN_THREAD ());
@@ -225,6 +269,9 @@ gbp_vcsui_tree_addin_selection_changed (IdeTreeAddin *addin,
dzl_gtk_widget_action_set (GTK_WIDGET (self->tree), "vcsui", "switch-branch",
"enabled", is_branch,
NULL);
+ dzl_gtk_widget_action_set (GTK_WIDGET (self->tree), "vcsui", "push-branch",
+ "enabled", is_branch,
+ NULL);
}
static void
diff --git a/src/plugins/vcsui/gtk/menus.ui b/src/plugins/vcsui/gtk/menus.ui
index e0fb8e448..831ece3ea 100644
--- a/src/plugins/vcsui/gtk/menus.ui
+++ b/src/plugins/vcsui/gtk/menus.ui
@@ -4,10 +4,17 @@
<section id="project-tree-menu-vcs">
<submenu id="project-tree-menu-version-control">
<attribute name="label" translatable="yes">Version Control</attribute>
- <item>
- <attribute name="label" translatable="yes">Switch Branch</attribute>
- <attribute name="action">vcsui.switch-branch</attribute>
- </item>
+ <section id="project-tree-vcsui-branches">
+ <item>
+ <attribute name="label" translatable="yes">Switch Branch</attribute>
+ <attribute name="action">vcsui.switch-branch</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Push Branch</attribute>
+ <attribute name="action">vcsui.push-branch</attribute>
+ </item>
+ </section>
+ </submenu>
<!--
<item>
<attribute name="label" translatable="yes">Restore File</attribute>
@@ -18,7 +25,6 @@
<attribute name="action">vcsui.browse-history</attribute>
</item>
-->
- </submenu>
</section>
</menu>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]