[gnome-builder/wip/gtk4-port: 1311/1774] create-project: Port to AdwComboRow
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 1311/1774] create-project: Port to AdwComboRow
- Date: Mon, 11 Jul 2022 22:31:41 +0000 (UTC)
commit 35f236c9dc9a3aefb3a16f083010eb0819d41891
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Wed Jun 1 22:41:29 2022 +0400
create-project: Port to AdwComboRow
.../create-project/gbp-create-project-widget.c | 60 +++----
.../create-project/gbp-create-project-widget.ui | 187 ++-------------------
2 files changed, 37 insertions(+), 210 deletions(-)
---
diff --git a/src/plugins/create-project/gbp-create-project-widget.c
b/src/plugins/create-project/gbp-create-project-widget.c
index 6dd597d2c..0b2946881 100644
--- a/src/plugins/create-project/gbp-create-project-widget.c
+++ b/src/plugins/create-project/gbp-create-project-widget.c
@@ -38,9 +38,6 @@ struct _GbpCreateProjectWidget
GtkWidget *main;
IdeTemplateInput *input;
- GtkMenuButton *template_button;
- GtkMenuButton *language_button;
- GtkMenuButton *licenses_button;
GtkImage *directory_clash;
AdwEntryRow *app_id_row;
@@ -72,61 +69,49 @@ gbp_create_project_widget_check_ready (GbpCreateProjectWidget *self)
}
static void
-template_activated_cb (GbpCreateProjectWidget *self,
- guint position,
- GtkListView *list_view)
+template_changed_cb (GbpCreateProjectWidget *self,
+ GParamSpec *pspec,
+ AdwComboRow *row)
{
- g_autoptr(IdeProjectTemplate) template = NULL;
+ IdeProjectTemplate *template;
g_autofree char *id = NULL;
- GListModel *model;
g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
- g_assert (GTK_IS_LIST_VIEW (list_view));
+ g_assert (ADW_IS_COMBO_ROW (row));
- model = G_LIST_MODEL (gtk_list_view_get_model (list_view));
- template = g_list_model_get_item (model, position);
-
- gtk_menu_button_popdown (self->template_button);
+ template = adw_combo_row_get_selected_item (row);
id = ide_project_template_get_id (template);
ide_template_input_set_template (self->input, id);
}
static void
-language_activated_cb (GbpCreateProjectWidget *self,
- guint position,
- GtkListView *list_view)
+language_changed_cb (GbpCreateProjectWidget *self,
+ GParamSpec *pspec,
+ AdwComboRow *row)
{
- g_autoptr(GtkStringObject) string = NULL;
- GListModel *model;
+ GtkStringObject *string;
g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
- g_assert (GTK_IS_LIST_VIEW (list_view));
-
- model = G_LIST_MODEL (gtk_list_view_get_model (list_view));
- string = g_list_model_get_item (model, position);
+ g_assert (ADW_IS_COMBO_ROW (row));
- gtk_menu_button_popdown (self->language_button);
+ string = adw_combo_row_get_selected_item (row);
ide_template_input_set_language (self->input,
gtk_string_object_get_string (string));
}
static void
-license_activated_cb (GbpCreateProjectWidget *self,
- guint position,
- GtkListView *list_view)
+license_changed_cb (GbpCreateProjectWidget *self,
+ GParamSpec *pspec,
+ AdwComboRow *row)
{
- g_autoptr(GtkStringObject) string = NULL;
- GListModel *model;
+ GtkStringObject *string;
g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
- g_assert (GTK_IS_LIST_VIEW (list_view));
-
- model = G_LIST_MODEL (gtk_list_view_get_model (list_view));
- string = g_list_model_get_item (model, position);
+ g_assert (ADW_IS_COMBO_ROW (row));
- gtk_menu_button_popdown (self->licenses_button);
+ string = adw_combo_row_get_selected_item (row);
ide_template_input_set_license_name (self->input,
gtk_string_object_get_string (string));
@@ -370,18 +355,15 @@ gbp_create_project_widget_class_init (GbpCreateProjectWidgetClass *klass)
gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, app_id_row);
gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, directory_clash);
gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, input);
- gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, language_button);
gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, language_row);
- gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, licenses_button);
gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, location_row);
gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, main);
gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, name_row);
- gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, template_button);
gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, template_row);
- gtk_widget_class_bind_template_callback (widget_class, template_activated_cb);
- gtk_widget_class_bind_template_callback (widget_class, language_activated_cb);
- gtk_widget_class_bind_template_callback (widget_class, license_activated_cb);
+ gtk_widget_class_bind_template_callback (widget_class, template_changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, language_changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, license_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, location_row_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, input_notify_cb);
diff --git a/src/plugins/create-project/gbp-create-project-widget.ui
b/src/plugins/create-project/gbp-create-project-widget.ui
index b5fb9821a..23acb26d3 100644
--- a/src/plugins/create-project/gbp-create-project-widget.ui
+++ b/src/plugins/create-project/gbp-create-project-widget.ui
@@ -97,141 +97,17 @@
<child>
<object class="AdwPreferencesGroup">
<child>
- <object class="AdwActionRow" id="language_row">
+ <object class="AdwComboRow" id="language_row">
<property name="title" translatable="yes">Language</property>
- <child type="suffix">
- <object class="GtkMenuButton" id="language_button">
- <property name="valign">center</property>
- <property name="label" bind-source="input" bind-property="language"
bind-flags="sync-create"/>
- <style>
- <class name="flat"/>
- </style>
- <property name="popover">
- <object class="GtkPopover">
- <style>
- <class name="menu"/>
- </style>
- <child>
- <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-height">200</property>
- <child>
- <object class="GtkListView">
- <signal name="activate" handler="language_activated_cb" swapped="true"
object="GbpCreateProjectWidget"/>
- <property name="model">
- <object class="GtkSingleSelection">
- <property name="model" bind-source="input"
bind-property="languages-model" bind-flags="sync-create"/>
- </object>
- </property>
- <property name="orientation">vertical</property>
- <property name="single-click-activate">true</property>
- <property name="factory">
- <object class="GtkBuilderListItemFactory">
- <property name="bytes"><![CDATA[
-<?xml version="1.0" encoding="UTF-8"?>
-<interface>
- <template class="GtkListItem">
- <property name="child">
- <object class="GtkBox">
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel">
- <property name="xalign">0</property>
- <property name="hexpand">true</property>
- <binding name="label">
- <lookup name="string" type="GtkStringObject">
- <lookup name="item">GtkListItem</lookup>
- </lookup>
- </binding>
- </object>
- </child>
- </object>
- </property>
- </template>
-</interface>
-]]>
- </property>
- </object>
- </property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </property>
- </object>
- </child>
+ <property name="model" bind-source="input" bind-property="languages-model"
bind-flags="sync-create"/>
+ <signal name="notify::selected-item" handler="language_changed_cb" swapped="true"
object="GbpCreateProjectWidget"/>
</object>
</child>
<child>
- <object class="AdwActionRow">
+ <object class="AdwComboRow">
<property name="title" translatable="yes">License</property>
- <child type="suffix">
- <object class="GtkMenuButton" id="licenses_button">
- <property name="valign">center</property>
- <property name="label" bind-source="input" bind-property="license-name"
bind-flags="sync-create"/>
- <style>
- <class name="flat"/>
- </style>
- <property name="popover">
- <object class="GtkPopover">
- <style>
- <class name="menu"/>
- </style>
- <child>
- <object class="GtkScrolledWindow">
- <property name="propagate-natural-height">true</property>
- <property name="propagate-natural-width">true</property>
- <property name="min-content-width">200</property>
- <property name="min-content-height">200</property>
- <child>
- <object class="GtkListView">
- <signal name="activate" handler="license_activated_cb" swapped="true"
object="GbpCreateProjectWidget"/>
- <property name="model">
- <object class="GtkSingleSelection">
- <property name="model" bind-source="input"
bind-property="licenses-model" bind-flags="sync-create"/>
- </object>
- </property>
- <property name="orientation">vertical</property>
- <property name="single-click-activate">true</property>
- <property name="factory">
- <object class="GtkBuilderListItemFactory">
- <property name="bytes"><![CDATA[
-<?xml version="1.0" encoding="UTF-8"?>
-<interface>
- <template class="GtkListItem">
- <property name="child">
- <object class="GtkBox">
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel">
- <property name="xalign">0</property>
- <property name="hexpand">true</property>
- <binding name="label">
- <lookup name="string" type="GtkStringObject">
- <lookup name="item">GtkListItem</lookup>
- </lookup>
- </binding>
- </object>
- </child>
- </object>
- </property>
- </template>
-</interface>
-]]>
- </property>
- </object>
- </property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </property>
- </object>
- </child>
+ <property name="model" bind-source="input" bind-property="licenses-model"
bind-flags="sync-create"/>
+ <signal name="notify::selected-item" handler="license_changed_cb" swapped="true"
object="GbpCreateProjectWidget"/>
</object>
</child>
<child>
@@ -246,39 +122,16 @@
</object>
</child>
<child>
- <object class="AdwActionRow" id="template_row">
+ <object class="AdwComboRow" id="template_row">
<property name="title" translatable="yes">Template</property>
- <child type="suffix">
- <object class="GtkMenuButton" id="template_button">
- <property name="valign">center</property>
- <property name="label" bind-source="input" bind-property="template-name"
bind-flags="sync-create"/>
- <style>
- <class name="flat"/>
- </style>
- <property name="popover">
- <object class="GtkPopover">
- <style>
- <class name="menu"/>
- </style>
- <child>
- <object class="GtkScrolledWindow">
- <property name="propagate-natural-height">true</property>
- <property name="propagate-natural-width">true</property>
- <property name="min-content-width">300</property>
- <property name="min-content-height">200</property>
- <child>
- <object class="GtkListView">
- <signal name="activate" handler="template_activated_cb" swapped="true"
object="GbpCreateProjectWidget"/>
- <property name="model">
- <object class="GtkSingleSelection">
- <property name="model" bind-source="input"
bind-property="templates-model" bind-flags="sync-create"/>
- </object>
- </property>
- <property name="orientation">vertical</property>
- <property name="single-click-activate">true</property>
- <property name="factory">
- <object class="GtkBuilderListItemFactory">
- <property name="bytes"><![CDATA[
+ <property name="model" bind-source="input" bind-property="templates-model"
bind-flags="sync-create"/>
+ <property name="expression">
+ <lookup name="name" type="IdeProjectTemplate"/>
+ </property>
+ <signal name="notify::selected-item" handler="template_changed_cb" swapped="true"
object="GbpCreateProjectWidget"/>
+ <property name="list-factory">
+ <object class="GtkBuilderListItemFactory">
+ <property name="bytes"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
@@ -316,17 +169,9 @@
</template>
</interface>
]]>
- </property>
- </object>
- </property>
- </object>
- </child>
- </object>
- </child>
- </object>
</property>
</object>
- </child>
+ </property>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]