[gnome-builder/wip/gtk4-port: 1248/1774] plugins/vcsui: setup branch from popover selection
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 1248/1774] plugins/vcsui: setup branch from popover selection
- Date: Mon, 11 Jul 2022 22:31:39 +0000 (UTC)
commit 0cb8df30a2d96d7b0b92d83c94485fd30c515253
Author: Christian Hergert <chergert redhat com>
Date: Tue May 31 17:09:05 2022 -0700
plugins/vcsui: setup branch from popover selection
src/plugins/vcsui/gbp-vcsui-clone-page.c | 30 ++++++++++++++++++++++++++++++
src/plugins/vcsui/gbp-vcsui-clone-page.ui | 17 ++++++++++++++++-
2 files changed, 46 insertions(+), 1 deletion(-)
---
diff --git a/src/plugins/vcsui/gbp-vcsui-clone-page.c b/src/plugins/vcsui/gbp-vcsui-clone-page.c
index 580d7c1c4..15ba3feb2 100644
--- a/src/plugins/vcsui/gbp-vcsui-clone-page.c
+++ b/src/plugins/vcsui/gbp-vcsui-clone-page.c
@@ -39,6 +39,7 @@ struct _GbpVcsuiClonePage
AdwEntryRow *author_email_row;
AdwEntryRow *author_name_row;
GtkMenuButton *branch_button;
+ GtkLabel *branch_label;
AdwEntryRow *location_row;
GtkWidget *main;
GtkStack *stack;
@@ -161,6 +162,8 @@ branch_activated_cb (GbpVcsuiClonePage *self,
ide_vcs_clone_request_set_branch_name (self->request, branch_id);
+ gtk_menu_button_popdown (self->branch_button);
+
IDE_EXIT;
}
@@ -178,6 +181,31 @@ branch_popover_show_cb (GbpVcsuiClonePage *self,
IDE_EXIT;
}
+static void
+branch_name_changed_cb (GbpVcsuiClonePage *self,
+ GParamSpec *pspec,
+ IdeVcsCloneRequest *request)
+{
+ const char *branch_name;
+ gboolean empty;
+
+ g_assert (GBP_IS_VCSUI_CLONE_PAGE (self));
+ g_assert (IDE_IS_VCS_CLONE_REQUEST (request));
+
+ branch_name = ide_vcs_clone_request_get_branch_name (request);
+
+ /* Very much a git-ism, but that's all we support right now */
+ if (branch_name != NULL && g_str_has_prefix (branch_name, "refs/heads/"))
+ branch_name += strlen ("refs/heads/");
+
+ empty = ide_str_empty0 (branch_name);
+
+ gtk_widget_set_tooltip_text (GTK_WIDGET (self->branch_label),
+ empty ? NULL : branch_name);
+ gtk_label_set_label (self->branch_label, branch_name);
+ gtk_widget_set_visible (GTK_WIDGET (self->branch_label), !empty);
+}
+
static void
gbp_vcsui_clone_page_root (GtkWidget *widget)
{
@@ -219,6 +247,7 @@ gbp_vcsui_clone_page_class_init (GbpVcsuiClonePageClass *klass)
gtk_widget_class_bind_template_child (widget_class, GbpVcsuiClonePage, author_email_row);
gtk_widget_class_bind_template_child (widget_class, GbpVcsuiClonePage, author_name_row);
gtk_widget_class_bind_template_child (widget_class, GbpVcsuiClonePage, branch_button);
+ gtk_widget_class_bind_template_child (widget_class, GbpVcsuiClonePage, branch_label);
gtk_widget_class_bind_template_child (widget_class, GbpVcsuiClonePage, location_row);
gtk_widget_class_bind_template_child (widget_class, GbpVcsuiClonePage, main);
gtk_widget_class_bind_template_child (widget_class, GbpVcsuiClonePage, request);
@@ -227,6 +256,7 @@ gbp_vcsui_clone_page_class_init (GbpVcsuiClonePageClass *klass)
gtk_widget_class_bind_template_callback (widget_class, location_row_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, branch_activated_cb);
+ gtk_widget_class_bind_template_callback (widget_class, branch_name_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, branch_popover_show_cb);
gtk_widget_class_install_action (widget_class, "clone-page.select-folder", NULL, select_folder_action);
diff --git a/src/plugins/vcsui/gbp-vcsui-clone-page.ui b/src/plugins/vcsui/gbp-vcsui-clone-page.ui
index ba13b60b0..1d3481276 100644
--- a/src/plugins/vcsui/gbp-vcsui-clone-page.ui
+++ b/src/plugins/vcsui/gbp-vcsui-clone-page.ui
@@ -18,6 +18,17 @@
<object class="AdwEntryRow" id="uri_row">
<property name="title" translatable="yes">Repository URL</property>
<property name="text" bind-source="request" bind-property="uri"
bind-flags="sync-create|bidirectional"/>
+ <child type="suffix">
+ <object class="GtkLabel" id="branch_label">
+ <property name="ellipsize">end</property>
+ <property name="selectable">true</property>
+ <property name="max-width-chars">10</property>
+ <property name="visible">false</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ </child>
<child type="suffix">
<object class="GtkMenuButton" id="branch_button">
<style>
@@ -63,8 +74,10 @@
<object class="GtkScrolledWindow">
<property name="propagate-natural-height">true</property>
<property name="propagate-natural-width">true</property>
- <property name="min-content-width">150</property>
+ <property name="min-content-width">400</property>
+ <property name="max-content-width">400</property>
<property name="min-content-height">200</property>
+ <property name="max-content-height">500</property>
<child>
<object class="GtkListView">
<signal name="activate" handler="branch_activated_cb"
swapped="true" object="GbpVcsuiClonePage"/>
@@ -91,6 +104,7 @@
<child>
<object class="GtkLabel">
<property name="xalign">0</property>
+ <property name="ellipsize">end</property>
<property name="hexpand">true</property>
<binding name="label">
<lookup name="name" type="IdeVcsBranch">
@@ -263,5 +277,6 @@
and 2) sticks around to maintain it with me.
-->
<property name="module-name">git</property>
+ <signal name="notify::branch-name" handler="branch_name_changed_cb" swapped="true"
object="GbpVcsuiClonePage"/>
</object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]