[gnome-builder/wip/gtk4-port: 721/1774] plugins/create-project: port to GTK 4
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 721/1774] plugins/create-project: port to GTK 4
- Date: Mon, 11 Jul 2022 22:31:21 +0000 (UTC)
commit a1778e6e73940827192f38a43c5dcc73aa24673b
Author: Christian Hergert <chergert redhat com>
Date: Tue Apr 26 12:44:42 2022 -0700
plugins/create-project: port to GTK 4
This still needs the redesign of the create-project widget, as that will
result in us not using ThreeGrid anymore (which doesn't clamp correctly
currently in GTK 4 due to label changes).
We also need some general styling updates and moving to AdwEntryRow.
.../create-project/create-project.gresource.xml | 2 +-
.../gbp-create-project-application-addin.c | 5 +-
.../create-project/gbp-create-project-surface.h | 39 ---
.../gbp-create-project-template-icon.c | 54 ++--
.../gbp-create-project-template-icon.h | 4 +-
.../gbp-create-project-template-icon.ui | 19 +-
...oject-surface.c => gbp-create-project-widget.c} | 336 +++++++++++----------
.../create-project/gbp-create-project-widget.h | 39 +++
...ect-surface.ui => gbp-create-project-widget.ui} | 204 +++++--------
.../gbp-create-project-workspace-addin.c | 31 +-
src/plugins/create-project/meson.build | 2 +-
src/plugins/meson.build | 2 +-
12 files changed, 362 insertions(+), 375 deletions(-)
---
diff --git a/src/plugins/create-project/create-project.gresource.xml
b/src/plugins/create-project/create-project.gresource.xml
index cd061bf4e..65f7c7f82 100644
--- a/src/plugins/create-project/create-project.gresource.xml
+++ b/src/plugins/create-project/create-project.gresource.xml
@@ -2,7 +2,7 @@
<gresources>
<gresource prefix="/plugins/create-project">
<file preprocess="xml-stripblanks">gtk/menus.ui</file>
- <file preprocess="xml-stripblanks">gbp-create-project-surface.ui</file>
+ <file preprocess="xml-stripblanks">gbp-create-project-widget.ui</file>
<file preprocess="xml-stripblanks">gbp-create-project-template-icon.ui</file>
<file>create-project.plugin</file>
<file>themes/shared.css</file>
diff --git a/src/plugins/create-project/gbp-create-project-application-addin.c
b/src/plugins/create-project/gbp-create-project-application-addin.c
index d99dd8220..0a28aa276 100644
--- a/src/plugins/create-project/gbp-create-project-application-addin.c
+++ b/src/plugins/create-project/gbp-create-project-application-addin.c
@@ -23,6 +23,7 @@
#include "config.h"
#include <glib/gi18n.h>
+
#include <libide-greeter.h>
#include <libide-gui.h>
@@ -81,7 +82,7 @@ gbp_create_project_application_addin_handle_command_line (IdeApplicationAddin
workspace = ide_greeter_workspace_new (app);
ide_workbench_add_workspace (workbench, IDE_WORKSPACE (workspace));
- ide_workspace_set_visible_surface_name (IDE_WORKSPACE (workspace), "create-project");
+ ide_greeter_workspace_set_page_name (workspace, "create-project");
ide_workbench_focus_workspace (workbench, IDE_WORKSPACE (workspace));
}
}
@@ -103,7 +104,7 @@ create_project_cb (GSimpleAction *action,
workspace = ide_greeter_workspace_new (IDE_APPLICATION_DEFAULT);
ide_workbench_add_workspace (workbench, IDE_WORKSPACE (workspace));
- ide_workspace_set_visible_surface_name (IDE_WORKSPACE (workspace), "create-project");
+ ide_greeter_workspace_set_page_name (workspace, "create-project");
ide_workbench_focus_workspace (workbench, IDE_WORKSPACE (workspace));
}
diff --git a/src/plugins/create-project/gbp-create-project-template-icon.c
b/src/plugins/create-project/gbp-create-project-template-icon.c
index 0642c460d..875b09639 100644
--- a/src/plugins/create-project/gbp-create-project-template-icon.c
+++ b/src/plugins/create-project/gbp-create-project-template-icon.c
@@ -18,11 +18,15 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
+#define G_LOG_DOMAIN "gbp-create-project-template"
+
+#include "config.h"
+
#include "gbp-create-project-template-icon.h"
struct _GbpCreateProjectTemplateIcon
{
- GtkBin parent;
+ AdwBin parent_instance;
GtkImage *template_icon;
GtkLabel *template_name;
@@ -36,9 +40,9 @@ enum {
N_PROPS
};
-static GParamSpec *properties [N_PROPS];
+G_DEFINE_FINAL_TYPE (GbpCreateProjectTemplateIcon, gbp_create_project_template_icon, ADW_TYPE_BIN)
-G_DEFINE_FINAL_TYPE (GbpCreateProjectTemplateIcon, gbp_create_project_template_icon, GTK_TYPE_BIN)
+static GParamSpec *properties [N_PROPS];
static void
gbp_create_project_template_icon_get_property (GObject *object,
@@ -66,25 +70,30 @@ gbp_create_project_template_icon_set_property (GObject *object,
GParamSpec *pspec)
{
GbpCreateProjectTemplateIcon *self = GBP_CREATE_PROJECT_TEMPLATE_ICON (object);
- g_autofree gchar *icon_name = NULL;
- g_autofree gchar *name = NULL;
- g_autofree gchar *description = NULL;
switch (prop_id)
{
case PROP_TEMPLATE:
- self->template = g_value_dup_object (value);
-
- icon_name = ide_project_template_get_icon_name (self->template);
- name = ide_project_template_get_name (self->template);
- description = ide_project_template_get_description (self->template);
-
- g_object_set (self->template_icon,
- "icon-name", icon_name,
- NULL);
- gtk_label_set_text (self->template_name, name);
- if (!ide_str_empty0 (description))
- gtk_widget_set_tooltip_text (GTK_WIDGET (self), description);
+ {
+ g_autofree gchar *icon_name = NULL;
+ g_autofree gchar *name = NULL;
+ g_autofree gchar *description = NULL;
+
+ self->template = g_value_dup_object (value);
+
+ icon_name = ide_project_template_get_icon_name (self->template);
+ name = ide_project_template_get_name (self->template);
+ description = ide_project_template_get_description (self->template);
+
+ g_object_set (self->template_icon,
+ "icon-name", icon_name,
+ NULL);
+
+ gtk_label_set_text (self->template_name, name);
+
+ if (!ide_str_empty0 (description))
+ gtk_widget_set_tooltip_text (GTK_WIDGET (self), description);
+ }
break;
default:
@@ -93,13 +102,13 @@ gbp_create_project_template_icon_set_property (GObject *object,
}
static void
-gbp_create_project_template_icon_destroy (GtkWidget *widget)
+gbp_create_project_template_icon_dispose (GObject *object)
{
- GbpCreateProjectTemplateIcon *self = (GbpCreateProjectTemplateIcon *)widget;
+ GbpCreateProjectTemplateIcon *self = (GbpCreateProjectTemplateIcon *)object;
g_clear_object (&self->template);
- GTK_WIDGET_CLASS (gbp_create_project_template_icon_parent_class)->destroy (widget);
+ G_OBJECT_CLASS (gbp_create_project_template_icon_parent_class)->dispose (object);
}
static void
@@ -108,11 +117,10 @@ gbp_create_project_template_icon_class_init (GbpCreateProjectTemplateIconClass *
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ object_class->dispose = gbp_create_project_template_icon_dispose;
object_class->set_property = gbp_create_project_template_icon_set_property;
object_class->get_property = gbp_create_project_template_icon_get_property;
- widget_class->destroy = gbp_create_project_template_icon_destroy;
-
properties [PROP_TEMPLATE] =
g_param_spec_object ("template",
"Template",
diff --git a/src/plugins/create-project/gbp-create-project-template-icon.h
b/src/plugins/create-project/gbp-create-project-template-icon.h
index d20fde05a..7c6a43fa2 100644
--- a/src/plugins/create-project/gbp-create-project-template-icon.h
+++ b/src/plugins/create-project/gbp-create-project-template-icon.h
@@ -20,13 +20,15 @@
#pragma once
+#include <adwaita.h>
+
#include <libide-projects.h>
G_BEGIN_DECLS
#define GBP_TYPE_CREATE_PROJECT_TEMPLATE_ICON (gbp_create_project_template_icon_get_type())
-G_DECLARE_FINAL_TYPE (GbpCreateProjectTemplateIcon, gbp_create_project_template_icon, GBP,
CREATE_PROJECT_TEMPLATE_ICON, GtkBin)
+G_DECLARE_FINAL_TYPE (GbpCreateProjectTemplateIcon, gbp_create_project_template_icon, GBP,
CREATE_PROJECT_TEMPLATE_ICON, AdwBin)
IdeProjectTemplate *gbp_create_project_template_icon_get_template (GbpCreateProjectTemplateIcon *self);
diff --git a/src/plugins/create-project/gbp-create-project-template-icon.ui
b/src/plugins/create-project/gbp-create-project-template-icon.ui
index 3cd0932d1..c331e6137 100644
--- a/src/plugins/create-project/gbp-create-project-template-icon.ui
+++ b/src/plugins/create-project/gbp-create-project-template-icon.ui
@@ -1,24 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <template class="GbpCreateProjectTemplateIcon" parent="GtkBin">
- <property name="border-width">12</property>
+ <template class="GbpCreateProjectTemplateIcon" parent="AdwBin">
+ <property name="margin-start">12</property>
+ <property name="margin-end">12</property>
+ <property name="margin-top">12</property>
+ <property name="margin-bottom">12</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
- <property name="expand">true</property>
+ <property name="hexpand">true</property>
+ <property name="vexpand">true</property>
<property name="spacing">6</property>
- <property name="visible">true</property>
<child>
<object class="GtkImage" id="template_icon">
- <property name="expand">true</property>
+ <property name="hexpand">true</property>
+ <property name="vexpand">true</property>
<property name="pixel-size">98</property>
- <property name="visible">true</property>
</object>
</child>
<child>
<object class="GtkLabel" id="template_name">
- <property name="expand">true</property>
- <property name="visible">true</property>
+ <property name="hexpand">true</property>
+ <property name="vexpand">true</property>
</object>
</child>
</object>
diff --git a/src/plugins/create-project/gbp-create-project-surface.c
b/src/plugins/create-project/gbp-create-project-widget.c
similarity index 72%
rename from src/plugins/create-project/gbp-create-project-surface.c
rename to src/plugins/create-project/gbp-create-project-widget.c
index c5eb4c1bf..98abd23d0 100644
--- a/src/plugins/create-project/gbp-create-project-surface.c
+++ b/src/plugins/create-project/gbp-create-project-widget.c
@@ -1,4 +1,4 @@
-/* gbp-create-project-surface.c
+/* gbp-create-project-widget.c
*
* Copyright 2016-2019 Christian Hergert <christian hergert me>
*
@@ -18,35 +18,38 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
-#define G_LOG_DOMAIN "gbp-create-project-surface"
+#define G_LOG_DOMAIN "gbp-create-project-widget"
+
+#include "config.h"
-#include <dazzle.h>
#include <glib/gi18n.h>
-#include <libide-greeter.h>
-#include <libide-projects.h>
-#include <libide-vcs.h>
#include <libpeas/peas.h>
#include <stdlib.h>
#include <string.h>
+#include <libide-greeter.h>
+#include <libide-gtk.h>
+#include <libide-projects.h>
+#include <libide-vcs.h>
+
#include "ide-greeter-private.h"
#include "gbp-create-project-template-icon.h"
-#include "gbp-create-project-surface.h"
+#include "gbp-create-project-widget.h"
-struct _GbpCreateProjectSurface
+struct _GbpCreateProjectWidget
{
- IdeSurface parent;
+ GtkWidget parent_instance;
PeasExtensionSet *providers;
GtkEntry *app_id_entry;
GtkEntry *project_name_entry;
- DzlFileChooserEntry *project_location_entry;
- DzlRadioBox *project_language_chooser;
+ IdeFileChooserEntry *project_location_entry;
+ IdeRadioBox *project_language_chooser;
GtkFlowBox *project_template_chooser;
GtkSwitch *versioning_switch;
- DzlRadioBox *license_chooser;
+ IdeRadioBox *license_chooser;
GtkLabel *destination_label;
GtkButton *create_button;
@@ -61,7 +64,7 @@ enum {
static GParamSpec *properties [N_PROPS];
-G_DEFINE_FINAL_TYPE (GbpCreateProjectSurface, gbp_create_project_surface, IDE_TYPE_SURFACE)
+G_DEFINE_FINAL_TYPE (GbpCreateProjectWidget, gbp_create_project_widget, GTK_TYPE_WIDGET)
static gboolean
is_preferred (const gchar *name)
@@ -90,7 +93,7 @@ sort_by_name (gconstpointer a,
}
static void
-gbp_create_project_surface_add_languages (GbpCreateProjectSurface *self,
+gbp_create_project_widget_add_languages (GbpCreateProjectWidget *self,
const GList *templates)
{
g_autoptr(GHashTable) languages = NULL;
@@ -98,7 +101,7 @@ gbp_create_project_surface_add_languages (GbpCreateProjectSurface *self,
const GList *iter;
guint len;
- g_assert (GBP_IS_CREATE_PROJECT_SURFACE (self));
+ g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
languages = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
@@ -118,7 +121,7 @@ gbp_create_project_surface_add_languages (GbpCreateProjectSurface *self,
keys = (const gchar **)g_hash_table_get_keys_as_array (languages, &len);
qsort (keys, len, sizeof (gchar *), sort_by_name);
for (guint i = 0; keys[i]; i++)
- dzl_radio_box_add_item (self->project_language_chooser, keys[i], keys[i]);
+ ide_radio_box_add_item (self->project_language_chooser, keys[i], keys[i]);
}
static gboolean
@@ -130,7 +133,12 @@ validate_name (const gchar *name)
if (g_unichar_isdigit (g_utf8_get_char (name)))
return FALSE;
- // meson reserved this as keyword and therefore its not allowed as project name
+ /* Meson reserved this as keyword and therefore it is
+ * not allowed as project name.
+ *
+ * FIXME: We could query the project template for valid naming
+ * requirements to display error message to the user.
+ */
if (ide_str_equal0 (name, "test"))
return FALSE;
@@ -149,16 +157,16 @@ validate_name (const gchar *name)
}
static gboolean
-directory_exists (GbpCreateProjectSurface *self,
+directory_exists (GbpCreateProjectWidget *self,
const gchar *name)
{
g_autoptr(GFile) directory = NULL;
g_autoptr(GFile) child = NULL;
- g_assert (GBP_IS_CREATE_PROJECT_SURFACE (self));
+ g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
g_assert (name != NULL);
- directory = dzl_file_chooser_entry_get_file (self->project_location_entry);
+ directory = ide_file_chooser_entry_get_file (self->project_location_entry);
child = g_file_get_child (directory, name);
self->invalid_directory = g_file_query_exists (child, NULL);
@@ -167,53 +175,53 @@ directory_exists (GbpCreateProjectSurface *self,
}
static void
-gbp_create_project_surface_create_cb (GObject *object,
+gbp_create_project_widget_create_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
- GbpCreateProjectSurface *self = (GbpCreateProjectSurface *)object;
+ GbpCreateProjectWidget *self = (GbpCreateProjectWidget *)object;
g_autoptr(GError) error = NULL;
- g_assert (GBP_IS_CREATE_PROJECT_SURFACE (self));
+ g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (user_data == NULL);
- if (!gbp_create_project_surface_create_finish (self, result, &error))
+ if (!gbp_create_project_widget_create_finish (self, result, &error))
{
g_warning ("Failed to create project: %s", error->message);
}
}
static void
-gbp_create_project_surface_create_clicked (GbpCreateProjectSurface *self,
- GtkButton *button)
+gbp_create_project_widget_create_clicked (GbpCreateProjectWidget *self,
+ GtkButton *button)
{
GCancellable *cancellable;
GtkWidget *workspace;
- g_assert (GBP_IS_CREATE_PROJECT_SURFACE (self));
+ g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
g_assert (GTK_IS_BUTTON (button));
workspace = gtk_widget_get_ancestor (GTK_WIDGET (self), IDE_TYPE_WORKSPACE);
cancellable = ide_workspace_get_cancellable (IDE_WORKSPACE (workspace));
- gbp_create_project_surface_create_async (self,
+ gbp_create_project_widget_create_async (self,
cancellable,
- gbp_create_project_surface_create_cb,
+ gbp_create_project_widget_create_cb,
NULL);
}
static void
-gbp_create_project_surface_name_changed (GbpCreateProjectSurface *self,
+gbp_create_project_widget_name_changed (GbpCreateProjectWidget *self,
GtkEntry *entry)
{
g_autofree gchar *project_name = NULL;
const gchar *text;
- g_assert (GBP_IS_CREATE_PROJECT_SURFACE (self));
+ g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
g_assert (GTK_IS_ENTRY (entry));
- text = gtk_entry_get_text (entry);
+ text = gtk_editable_get_text (GTK_EDITABLE (entry));
project_name = g_strstrip (g_strdup (text));
if (ide_str_empty0 (project_name) || !validate_name (project_name))
@@ -236,7 +244,7 @@ gbp_create_project_surface_name_changed (GbpCreateProjectSurface *self,
else
{
g_autofree gchar *formatted = NULL;
- g_autoptr(GFile) file = dzl_file_chooser_entry_get_file (self->project_location_entry);
+ g_autoptr(GFile) file = ide_file_chooser_entry_get_file (self->project_location_entry);
g_autoptr(GFile) child = g_file_get_child (file, project_name);
g_autofree gchar *path = g_file_get_path (child);
g_autofree gchar *collapsed = ide_path_collapse (path);
@@ -285,15 +293,15 @@ application_id_is_valid (const char *app_id)
}
static void
-gbp_create_project_surface_app_id_changed (GbpCreateProjectSurface *self,
+gbp_create_project_widget_app_id_changed (GbpCreateProjectWidget *self,
GtkEntry *entry)
{
const gchar *app_id;
- g_assert (GBP_IS_CREATE_PROJECT_SURFACE (self));
+ g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
g_assert (GTK_IS_ENTRY (entry));
- app_id = gtk_entry_get_text (entry);
+ app_id = gtk_editable_get_text (GTK_EDITABLE (entry));
if (app_id[0] && !application_id_is_valid (app_id))
g_object_set (self->app_id_entry,
@@ -310,82 +318,69 @@ gbp_create_project_surface_app_id_changed (GbpCreateProjectSurface *self,
}
static void
-gbp_create_project_surface_location_changed (GbpCreateProjectSurface *self,
+gbp_create_project_widget_location_changed (GbpCreateProjectWidget *self,
GParamSpec *pspec,
- DzlFileChooserEntry *chooser)
+ IdeFileChooserEntry *chooser)
{
- g_assert (GBP_IS_CREATE_PROJECT_SURFACE (self));
- g_assert (DZL_IS_FILE_CHOOSER_ENTRY (chooser));
+ g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
+ g_assert (IDE_IS_FILE_CHOOSER_ENTRY (chooser));
/* Piggyback on the name changed signal to update things */
- gbp_create_project_surface_name_changed (self, self->project_name_entry);
+ gbp_create_project_widget_name_changed (self, self->project_name_entry);
}
static void
-update_language_sensitivity (GtkWidget *widget,
- gpointer data)
+gbp_create_project_widget_refilter (GbpCreateProjectWidget *self)
{
- GbpCreateProjectSurface *self = data;
- GbpCreateProjectTemplateIcon *template_icon;
- IdeProjectTemplate *template;
- g_auto(GStrv) template_languages = NULL;
- const gchar *language;
- gboolean sensitive = FALSE;
- gint i;
+ const char *language;
- g_assert (GBP_IS_CREATE_PROJECT_SURFACE (self));
- g_assert (GTK_IS_FLOW_BOX_CHILD (widget));
+ g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
- language = dzl_radio_box_get_active_id (self->project_language_chooser);
+ language = ide_radio_box_get_active_id (self->project_language_chooser);
- if (ide_str_empty0 (language))
- goto apply;
+ for (GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (self->project_template_chooser));
+ child != NULL;
+ child = gtk_widget_get_next_sibling (child))
+ {
+ g_auto(GStrv) template_languages = NULL;
+ GbpCreateProjectTemplateIcon *template_icon;
+ IdeProjectTemplate *template;
+ gboolean sensitive = FALSE;
- template_icon = GBP_CREATE_PROJECT_TEMPLATE_ICON (gtk_bin_get_child (GTK_BIN (widget)));
- g_object_get (template_icon,
- "template", &template,
- NULL);
- template_languages = ide_project_template_get_languages (template);
+ g_assert (GTK_IS_FLOW_BOX_CHILD (child));
- for (i = 0; template_languages [i]; i++)
- {
- if (g_str_equal (language, template_languages [i]))
- {
- sensitive = TRUE;
- goto apply;
- }
- }
+ if (ide_str_empty0 (language))
+ goto apply;
-apply:
- gtk_widget_set_sensitive (widget, sensitive);
-}
+ template_icon = GBP_CREATE_PROJECT_TEMPLATE_ICON (gtk_flow_box_child_get_child (GTK_FLOW_BOX_CHILD
(child)));
+ template = gbp_create_project_template_icon_get_template (template_icon);
+ template_languages = ide_project_template_get_languages (template);
-static void
-gbp_create_project_surface_refilter (GbpCreateProjectSurface *self)
-{
- gtk_container_foreach (GTK_CONTAINER (self->project_template_chooser),
- update_language_sensitivity,
- self);
+ sensitive = g_strv_contains ((const char * const *)template_languages, language);
+
+ apply:
+ gtk_widget_set_sensitive (child, sensitive);
+ }
}
static void
-gbp_create_project_surface_language_changed (GbpCreateProjectSurface *self,
- DzlRadioBox *language_chooser)
+gbp_create_project_widget_language_changed (GbpCreateProjectWidget *self,
+ IdeRadioBox *language_chooser)
{
- g_assert (GBP_IS_CREATE_PROJECT_SURFACE (self));
- g_assert (DZL_IS_RADIO_BOX (language_chooser));
+ g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
+ g_assert (IDE_IS_RADIO_BOX (language_chooser));
- gbp_create_project_surface_refilter (self);
+ gbp_create_project_widget_refilter (self);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_IS_READY]);
}
static void
-gbp_create_project_surface_template_selected (GbpCreateProjectSurface *self,
+gbp_create_project_widget_template_selected (GbpCreateProjectWidget *self,
GtkFlowBox *box,
GtkFlowBoxChild *child)
{
- g_assert (GBP_IS_CREATE_PROJECT_SURFACE (self));
+ g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_IS_READY]);
}
@@ -400,8 +395,8 @@ project_template_sort_func (GtkFlowBoxChild *child1,
IdeProjectTemplate *tmpl1;
IdeProjectTemplate *tmpl2;
- icon1 = GBP_CREATE_PROJECT_TEMPLATE_ICON (gtk_bin_get_child (GTK_BIN (child1)));
- icon2 = GBP_CREATE_PROJECT_TEMPLATE_ICON (gtk_bin_get_child (GTK_BIN (child2)));
+ icon1 = GBP_CREATE_PROJECT_TEMPLATE_ICON (gtk_flow_box_child_get_child (GTK_FLOW_BOX_CHILD (child1)));
+ icon2 = GBP_CREATE_PROJECT_TEMPLATE_ICON (gtk_flow_box_child_get_child (GTK_FLOW_BOX_CHILD (child2)));
tmpl1 = gbp_create_project_template_icon_get_template (icon1);
tmpl2 = gbp_create_project_template_icon_get_template (icon2);
@@ -410,10 +405,10 @@ project_template_sort_func (GtkFlowBoxChild *child1,
}
static void
-gbp_create_project_surface_add_template_buttons (GbpCreateProjectSurface *self,
+gbp_create_project_widget_add_template_buttons (GbpCreateProjectWidget *self,
GList *templates)
{
- g_assert (GBP_IS_CREATE_PROJECT_SURFACE (self));
+ g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
for (const GList *iter = templates; iter; iter = iter->next)
{
@@ -431,34 +426,34 @@ gbp_create_project_surface_add_template_buttons (GbpCreateProjectSurface *self,
template_container = g_object_new (GTK_TYPE_FLOW_BOX_CHILD,
"visible", TRUE,
NULL);
- gtk_container_add (GTK_CONTAINER (template_container), GTK_WIDGET (template_icon));
+ gtk_flow_box_child_set_child (template_container, GTK_WIDGET (template_icon));
gtk_flow_box_insert (self->project_template_chooser, GTK_WIDGET (template_container), -1);
}
}
static void
-gbp_create_project_surface_provider_added_cb (PeasExtensionSet *set,
- PeasPluginInfo *plugin_info,
- PeasExtension *exten,
- gpointer user_data)
+gbp_create_project_widget_provider_added_cb (PeasExtensionSet *set,
+ PeasPluginInfo *plugin_info,
+ PeasExtension *exten,
+ gpointer user_data)
{
- GbpCreateProjectSurface *self = user_data;
+ GbpCreateProjectWidget *self = user_data;
IdeTemplateProvider *provider = (IdeTemplateProvider *)exten;
g_autolist(IdeProjectTemplate) templates = NULL;
GtkFlowBoxChild *child;
g_assert (IDE_IS_MAIN_THREAD ());
g_assert (PEAS_IS_EXTENSION_SET (set));
- g_assert (GBP_IS_CREATE_PROJECT_SURFACE (self));
+ g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
g_assert (IDE_IS_TEMPLATE_PROVIDER (provider));
templates = ide_template_provider_get_project_templates (provider);
- gbp_create_project_surface_add_template_buttons (self, templates);
- gbp_create_project_surface_add_languages (self, templates);
+ gbp_create_project_widget_add_template_buttons (self, templates);
+ gbp_create_project_widget_add_languages (self, templates);
gtk_flow_box_invalidate_sort (self->project_template_chooser);
- gbp_create_project_surface_refilter (self);
+ gbp_create_project_widget_refilter (self);
/*
* We do the following after every add, because we might get some delayed
@@ -468,7 +463,7 @@ gbp_create_project_surface_provider_added_cb (PeasExtensionSet *set,
/* Default to C, always. We might investigate setting this to the
* previously selected item in the future.
*/
- dzl_radio_box_set_active_id (self->project_language_chooser, "C");
+ ide_radio_box_set_active_id (self->project_language_chooser, "C");
/* Select the first template that is visible so we have a selection
* initially without the user having to select. We might also try to
@@ -479,31 +474,31 @@ gbp_create_project_surface_provider_added_cb (PeasExtensionSet *set,
}
static GFile *
-gbp_create_project_surface_get_directory (GbpCreateProjectSurface *self)
+gbp_create_project_widget_get_directory (GbpCreateProjectWidget *self)
{
- g_assert (GBP_IS_CREATE_PROJECT_SURFACE (self));
+ g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
- return dzl_file_chooser_entry_get_file (self->project_location_entry);
+ return ide_file_chooser_entry_get_file (self->project_location_entry);
}
static void
-gbp_create_project_surface_set_directory (GbpCreateProjectSurface *self,
+gbp_create_project_widget_set_directory (GbpCreateProjectWidget *self,
GFile *directory)
{
- g_assert (GBP_IS_CREATE_PROJECT_SURFACE (self));
+ g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
g_assert (G_IS_FILE (directory));
- dzl_file_chooser_entry_set_file (self->project_location_entry, directory);
+ ide_file_chooser_entry_set_file (self->project_location_entry, directory);
}
static void
-gbp_create_project_surface_constructed (GObject *object)
+gbp_create_project_widget_constructed (GObject *object)
{
- GbpCreateProjectSurface *self = GBP_CREATE_PROJECT_SURFACE (object);
+ GbpCreateProjectWidget *self = GBP_CREATE_PROJECT_WIDGET (object);
- g_assert (GBP_IS_CREATE_PROJECT_SURFACE (self));
+ g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
- G_OBJECT_CLASS (gbp_create_project_surface_parent_class)->constructed (object);
+ G_OBJECT_CLASS (gbp_create_project_widget_parent_class)->constructed (object);
self->providers = peas_extension_set_new (peas_engine_get_default (),
IDE_TYPE_TEMPLATE_PROVIDER,
@@ -511,26 +506,26 @@ gbp_create_project_surface_constructed (GObject *object)
g_signal_connect (self->providers,
"extension-added",
- G_CALLBACK (gbp_create_project_surface_provider_added_cb),
+ G_CALLBACK (gbp_create_project_widget_provider_added_cb),
self);
peas_extension_set_foreach (self->providers,
- gbp_create_project_surface_provider_added_cb,
+ gbp_create_project_widget_provider_added_cb,
self);
}
static void
-gbp_create_project_surface_destroy (GtkWidget *widget)
+gbp_create_project_widget_dispose (GObject *object)
{
- GbpCreateProjectSurface *self = (GbpCreateProjectSurface *)widget;
+ GbpCreateProjectWidget *self = (GbpCreateProjectWidget *)object;
g_clear_object (&self->providers);
- GTK_WIDGET_CLASS (gbp_create_project_surface_parent_class)->destroy (widget);
+ G_OBJECT_CLASS (gbp_create_project_widget_parent_class)->dispose (object);
}
static gboolean
-gbp_create_project_surface_is_ready (GbpCreateProjectSurface *self)
+gbp_create_project_widget_is_ready (GbpCreateProjectWidget *self)
{
const gchar *text;
g_autofree gchar *project_name = NULL;
@@ -539,22 +534,22 @@ gbp_create_project_surface_is_ready (GbpCreateProjectSurface *self)
GList *selected_template = NULL;
gboolean ret = FALSE;
- g_assert (GBP_IS_CREATE_PROJECT_SURFACE (self));
+ g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
if (self->invalid_directory)
return FALSE;
- text = gtk_entry_get_text (self->project_name_entry);
+ text = gtk_editable_get_text (GTK_EDITABLE (self->project_name_entry));
project_name = g_strstrip (g_strdup (text));
if (ide_str_empty0 (project_name) || !validate_name (project_name))
return FALSE;
- app_id = gtk_entry_get_text (self->app_id_entry);
+ app_id = gtk_editable_get_text (GTK_EDITABLE (self->app_id_entry));
if (app_id[0] && !application_id_is_valid (app_id))
return FALSE;
- language = dzl_radio_box_get_active_id (self->project_language_chooser);
+ language = ide_radio_box_get_active_id (self->project_language_chooser);
if (ide_str_empty0 (language))
return FALSE;
@@ -571,24 +566,28 @@ gbp_create_project_surface_is_ready (GbpCreateProjectSurface *self)
return ret;
}
-static void
-gbp_create_project_surface_grab_focus (GtkWidget *widget)
+static gboolean
+gbp_create_project_widget_grab_focus (GtkWidget *widget)
{
- gtk_widget_grab_focus (GTK_WIDGET (GBP_CREATE_PROJECT_SURFACE (widget)->project_name_entry));
+ GbpCreateProjectWidget *self = (GbpCreateProjectWidget *)widget;
+
+ g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
+
+ return gtk_widget_grab_focus (GTK_WIDGET (self->project_name_entry));
}
static void
-gbp_create_project_surface_get_property (GObject *object,
+gbp_create_project_widget_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
- GbpCreateProjectSurface *self = GBP_CREATE_PROJECT_SURFACE(object);
+ GbpCreateProjectWidget *self = GBP_CREATE_PROJECT_WIDGET(object);
switch (prop_id)
{
case PROP_IS_READY:
- g_value_set_boolean (value, gbp_create_project_surface_is_ready (self));
+ g_value_set_boolean (value, gbp_create_project_widget_is_ready (self));
break;
default:
@@ -597,16 +596,16 @@ gbp_create_project_surface_get_property (GObject *object,
}
static void
-gbp_create_project_surface_class_init (GbpCreateProjectSurfaceClass *klass)
+gbp_create_project_widget_class_init (GbpCreateProjectWidgetClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->constructed = gbp_create_project_surface_constructed;
- object_class->get_property = gbp_create_project_surface_get_property;
+ object_class->constructed = gbp_create_project_widget_constructed;
+ object_class->dispose = gbp_create_project_widget_dispose;
+ object_class->get_property = gbp_create_project_widget_get_property;
- widget_class->destroy = gbp_create_project_surface_destroy;
- widget_class->grab_focus = gbp_create_project_surface_grab_focus;
+ widget_class->grab_focus = gbp_create_project_widget_grab_focus;
properties [PROP_IS_READY] =
g_param_spec_boolean ("is-ready",
@@ -617,65 +616,72 @@ gbp_create_project_surface_class_init (GbpCreateProjectSurfaceClass *klass)
g_object_class_install_properties (object_class, N_PROPS, properties);
- gtk_widget_class_set_css_name (widget_class, "createprojectsurface");
- gtk_widget_class_set_template_from_resource (widget_class,
"/plugins/create-project/gbp-create-project-surface.ui");
- gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectSurface, app_id_entry);
- gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectSurface, create_button);
- gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectSurface, destination_label);
- gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectSurface, license_chooser);
- gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectSurface, project_language_chooser);
- gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectSurface, project_location_entry);
- gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectSurface, project_name_entry);
- gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectSurface, project_template_chooser);
- gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectSurface, versioning_switch);
+ gtk_widget_class_set_css_name (widget_class, "createprojectwidget");
+ gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
+ gtk_widget_class_set_template_from_resource (widget_class,
"/plugins/create-project/gbp-create-project-widget.ui");
+ gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, app_id_entry);
+ gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, create_button);
+ gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, destination_label);
+ gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, license_chooser);
+ gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, project_language_chooser);
+ gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, project_location_entry);
+ gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, project_name_entry);
+ gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, project_template_chooser);
+ gtk_widget_class_bind_template_child (widget_class, GbpCreateProjectWidget, versioning_switch);
}
static void
-gbp_create_project_surface_init (GbpCreateProjectSurface *self)
+gbp_create_project_widget_init (GbpCreateProjectWidget *self)
{
g_autoptr(GFile) projects_dir = NULL;
gtk_widget_init_template (GTK_WIDGET (self));
- gtk_widget_set_name (GTK_WIDGET (self), "create-project");
- ide_surface_set_title (IDE_SURFACE (self), C_("title", "Start New Project"));
+ ide_radio_box_add_item (self->license_chooser, "gpl_3", _("GPLv3+"));
+ ide_radio_box_add_item (self->license_chooser, "lgpl_3", _("LGPLv3+"));
+ ide_radio_box_add_item (self->license_chooser, "agpl_3", _("AGPLv3+"));
+ ide_radio_box_add_item (self->license_chooser, "mit_x11", _("MIT/X11"));
+ ide_radio_box_add_item (self->license_chooser, "apache_2", _("Apache 2.0"));
+ ide_radio_box_add_item (self->license_chooser, "gpl_2", _("GPLv2+"));
+ ide_radio_box_add_item (self->license_chooser, "lgpl_2_1", _("LGPLv2.1+"));
+ ide_radio_box_add_item (self->license_chooser, "none", _("No license"));
projects_dir = g_file_new_for_path (ide_get_projects_dir ());
- gbp_create_project_surface_set_directory (self, projects_dir);
+ gbp_create_project_widget_set_directory (self, projects_dir);
g_signal_connect_object (self->project_name_entry,
"changed",
- G_CALLBACK (gbp_create_project_surface_name_changed),
+ G_CALLBACK (gbp_create_project_widget_name_changed),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (self->app_id_entry,
"changed",
- G_CALLBACK (gbp_create_project_surface_app_id_changed),
+ G_CALLBACK (gbp_create_project_widget_app_id_changed),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (self->project_location_entry,
"notify::file",
- G_CALLBACK (gbp_create_project_surface_location_changed),
+ G_CALLBACK (gbp_create_project_widget_location_changed),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (self->project_language_chooser,
"changed",
- G_CALLBACK (gbp_create_project_surface_language_changed),
+ G_CALLBACK (gbp_create_project_widget_language_changed),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (self->project_template_chooser,
"child-activated",
- G_CALLBACK (gbp_create_project_surface_template_selected),
+ G_CALLBACK (gbp_create_project_widget_template_selected),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (self->create_button,
"clicked",
- G_CALLBACK (gbp_create_project_surface_create_clicked),
+ G_CALLBACK (gbp_create_project_widget_create_clicked),
self,
G_CONNECT_SWAPPED);
@@ -696,7 +702,7 @@ init_vcs_cb (GObject *object,
g_autoptr(IdeTask) task = user_data;
g_autoptr(IdeProjectInfo) project_info = NULL;
g_autoptr(GError) error = NULL;
- GbpCreateProjectSurface *self;
+ GbpCreateProjectWidget *self;
GtkWidget *workspace;
GFile *project_file;
@@ -710,7 +716,7 @@ init_vcs_cb (GObject *object,
}
self = ide_task_get_source_object (task);
- g_assert (GBP_IS_CREATE_PROJECT_SURFACE (self));
+ g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
project_file = ide_task_get_task_data (task);
@@ -736,7 +742,7 @@ extract_cb (GObject *object,
g_autoptr(IdeTask) task = user_data;
g_autoptr(IdeVcsInitializer) vcs = NULL;
g_autoptr(GError) error = NULL;
- GbpCreateProjectSurface *self;
+ GbpCreateProjectWidget *self;
PeasPluginInfo *plugin_info;
PeasEngine *engine;
IdeContext *context;
@@ -761,7 +767,7 @@ extract_cb (GObject *object,
}
self = ide_task_get_source_object (task);
- g_assert (GBP_IS_CREATE_PROJECT_SURFACE (self));
+ g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
project_file = ide_task_get_task_data (task);
g_assert (G_IS_FILE (project_file));
@@ -811,7 +817,7 @@ failure:
}
void
-gbp_create_project_surface_create_async (GbpCreateProjectSurface *self,
+gbp_create_project_widget_create_async (GbpCreateProjectWidget *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -837,7 +843,7 @@ gbp_create_project_surface_create_async (GbpCreateProjectSurface *self,
const gchar *author_name;
GList *selected_box_child;
- g_return_if_fail (GBP_CREATE_PROJECT_SURFACE (self));
+ g_return_if_fail (GBP_CREATE_PROJECT_WIDGET (self));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
gtk_widget_set_sensitive (GTK_WIDGET (self->create_button), FALSE);
@@ -850,7 +856,7 @@ gbp_create_project_surface_create_async (GbpCreateProjectSurface *self,
selected_box_child = gtk_flow_box_get_selected_children (self->project_template_chooser);
template_container = selected_box_child->data;
- template_icon = GBP_CREATE_PROJECT_TEMPLATE_ICON (gtk_bin_get_child (GTK_BIN (template_container)));
+ template_icon = GBP_CREATE_PROJECT_TEMPLATE_ICON (gtk_flow_box_child_get_child (GTK_FLOW_BOX_CHILD
(template_container)));
g_object_get (template_icon,
"template", &template,
NULL);
@@ -861,13 +867,13 @@ gbp_create_project_surface_create_async (GbpCreateProjectSurface *self,
g_free,
(GDestroyNotify)g_variant_unref);
- text = gtk_entry_get_text (self->project_name_entry);
+ text = gtk_editable_get_text (GTK_EDITABLE (self->project_name_entry));
name = g_strstrip (g_strdup (text));
g_hash_table_insert (params,
g_strdup ("name"),
g_variant_ref_sink (g_variant_new_string (g_strdelimit (name, " ", '-'))));
- location = gbp_create_project_surface_get_directory (self);
+ location = gbp_create_project_widget_get_directory (self);
child = g_file_get_child (location, name);
path = g_file_get_path (child);
@@ -875,12 +881,12 @@ gbp_create_project_surface_create_async (GbpCreateProjectSurface *self,
g_strdup ("path"),
g_variant_ref_sink (g_variant_new_string (path)));
- language = dzl_radio_box_get_active_id (self->project_language_chooser);
+ language = ide_radio_box_get_active_id (self->project_language_chooser);
g_hash_table_insert (params,
g_strdup ("language"),
g_variant_ref_sink (g_variant_new_string (language)));
- license_id = dzl_radio_box_get_active_id (DZL_RADIO_BOX (self->license_chooser));
+ license_id = ide_radio_box_get_active_id (IDE_RADIO_BOX (self->license_chooser));
if (!g_str_equal (license_id, "none"))
{
@@ -931,7 +937,7 @@ gbp_create_project_surface_create_async (GbpCreateProjectSurface *self,
else
author_name = g_get_real_name ();
- app_id = gtk_entry_get_text (self->app_id_entry);
+ app_id = gtk_editable_get_text (GTK_EDITABLE (self->app_id_entry));
if (ide_str_empty0 (app_id))
app_id = "org.example.App";
@@ -957,11 +963,11 @@ gbp_create_project_surface_create_async (GbpCreateProjectSurface *self,
}
gboolean
-gbp_create_project_surface_create_finish (GbpCreateProjectSurface *self,
+gbp_create_project_widget_create_finish (GbpCreateProjectWidget *self,
GAsyncResult *result,
GError **error)
{
- g_return_val_if_fail (GBP_IS_CREATE_PROJECT_SURFACE (self), FALSE);
+ g_return_val_if_fail (GBP_IS_CREATE_PROJECT_WIDGET (self), FALSE);
g_return_val_if_fail (IDE_IS_TASK (result), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (self->create_button), TRUE);
diff --git a/src/plugins/create-project/gbp-create-project-widget.h
b/src/plugins/create-project/gbp-create-project-widget.h
new file mode 100644
index 000000000..36ca939f0
--- /dev/null
+++ b/src/plugins/create-project/gbp-create-project-widget.h
@@ -0,0 +1,39 @@
+/* gbp-create-project-widget.h
+ *
+ * Copyright 2016-2022 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_CREATE_PROJECT_WIDGET (gbp_create_project_widget_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpCreateProjectWidget, gbp_create_project_widget, GBP, CREATE_PROJECT_WIDGET,
GtkWidget)
+
+void gbp_create_project_widget_create_async (GbpCreateProjectWidget *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean gbp_create_project_widget_create_finish (GbpCreateProjectWidget *self,
+ GAsyncResult *result,
+ GError **error);
+
+G_END_DECLS
diff --git a/src/plugins/create-project/gbp-create-project-surface.ui
b/src/plugins/create-project/gbp-create-project-widget.ui
similarity index 66%
rename from src/plugins/create-project/gbp-create-project-surface.ui
rename to src/plugins/create-project/gbp-create-project-widget.ui
index ff5db5951..a2a925794 100644
--- a/src/plugins/create-project/gbp-create-project-surface.ui
+++ b/src/plugins/create-project/gbp-create-project-widget.ui
@@ -1,56 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <template class="GbpCreateProjectSurface" parent="IdeSurface">
+ <template class="GbpCreateProjectWidget" parent="GtkWidget">
<child>
- <object class="GtkScrolledWindow">
- <property name="visible">true</property>
+ <object class="GtkScrolledWindow" id="scroller">
<property name="propagate-natural-height">true</property>
<property name="propagate-natural-width">true</property>
<property name="hscrollbar-policy">never</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
- <property name="expand">true</property>
+ <property name="hexpand">true</property>
+ <property name="vexpand">true</property>
<property name="margin-top">72</property>
<property name="margin-start">64</property>
<property name="margin-end">64</property>
<property name="margin-bottom">64</property>
<property name="valign">start</property>
- <property name="visible">true</property>
<child>
- <object class="DzlThreeGrid" id="three_grid">
+ <object class="IdeThreeGrid" id="three_grid">
<property name="column-spacing">12</property>
<property name="row-spacing">24</property>
- <property name="visible">true</property>
<child>
<object class="GtkLabel" id="project_name_label">
<property name="halign">end</property>
<property name="label" translatable="yes">Project Name</property>
<property name="valign">start</property>
- <property name="visible">true</property>
+ <layout>
+ <property name="column">left</property>
+ <property name="row">0</property>
+ </layout>
</object>
- <packing>
- <property name="column">left</property>
- <property name="row">0</property>
- </packing>
</child>
<child>
<object class="GtkBox">
<property name="spacing">6</property>
<property name="orientation">vertical</property>
- <property name="visible">true</property>
<child>
<object class="GtkEntry" id="project_name_entry">
<property name="width-chars">50</property>
- <property name="expand">true</property>
- <property name="visible">true</property>
+ <property name="hexpand">true</property>
+ <property name="vexpand">true</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="xalign">0.0</property>
<property name="wrap">true</property>
- <property name="visible">true</property>
<property name="max-width-chars">60</property>
<property name="label" translatable="yes">Unique name that is used for your
project’s folder and other technical resources. Should be in lower case without spaces and may not start with
a number.</property>
<style>
@@ -61,41 +56,38 @@
</attributes>
</object>
</child>
+ <layout>
+ <property name="column">center</property>
+ <property name="row">0</property>
+ </layout>
</object>
- <packing>
- <property name="column">center</property>
- <property name="row">0</property>
- </packing>
</child>
<child>
<object class="GtkLabel" id="app_id_label">
<property name="halign">end</property>
<property name="label" translatable="yes">Application ID</property>
<property name="valign">start</property>
- <property name="visible">true</property>
+ <layout>
+ <property name="column">left</property>
+ <property name="row">1</property>
+ </layout>
</object>
- <packing>
- <property name="column">left</property>
- <property name="row">1</property>
- </packing>
</child>
<child>
<object class="GtkBox">
<property name="spacing">6</property>
<property name="orientation">vertical</property>
- <property name="visible">true</property>
<child>
<object class="GtkEntry" id="app_id_entry">
<property name="width-chars">50</property>
- <property name="expand">true</property>
- <property name="visible">true</property>
+ <property name="hexpand">true</property>
+ <property name="vexpand">true</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="xalign">0.0</property>
<property name="wrap">true</property>
- <property name="visible">true</property>
<property name="max-width-chars">60</property>
<property name="label" translatable="yes">The Application ID is a reverse
domain-name identifier used to uniquely identify your application such as “org.gnome.Builder” and may not
contain dashes.</property>
<style>
@@ -106,42 +98,38 @@
</attributes>
</object>
</child>
+ <layout>
+ <property name="column">center</property>
+ <property name="row">1</property>
+ </layout>
</object>
- <packing>
- <property name="column">center</property>
- <property name="row">1</property>
- </packing>
</child>
<child>
<object class="GtkLabel" id="project_location_label">
<property name="halign">end</property>
<property name="label" translatable="yes">Project Location</property>
<property name="valign">start</property>
- <property name="visible">true</property>
+ <layout>
+ <property name="column">left</property>
+ <property name="row">2</property>
+ </layout>
</object>
- <packing>
- <property name="column">left</property>
- <property name="row">2</property>
- </packing>
</child>
<child>
<object class="GtkBox">
<property name="spacing">6</property>
<property name="orientation">vertical</property>
- <property name="visible">true</property>
<child>
- <object class="DzlFileChooserEntry" id="project_location_entry">
+ <object class="IdeFileChooserEntry" id="project_location_entry">
<property name="action">select-folder</property>
<property name="title" translatable="yes">Select Project Directory</property>
<property name="hexpand">true</property>
- <property name="visible">true</property>
</object>
</child>
<child>
<object class="GtkLabel" id="destination_label">
<property name="xalign">0.0</property>
<property name="wrap">true</property>
- <property name="visible">true</property>
<property name="max-width-chars">60</property>
<property name="label" translatable="yes">Your project will be created within a new
child directory.</property>
<style>
@@ -152,11 +140,11 @@
</attributes>
</object>
</child>
+ <layout>
+ <property name="column">center</property>
+ <property name="row">2</property>
+ </layout>
</object>
- <packing>
- <property name="column">center</property>
- <property name="row">2</property>
- </packing>
</child>
<child>
@@ -164,22 +152,20 @@
<property name="halign">end</property>
<property name="label" translatable="yes">Language</property>
<property name="valign">start</property>
- <property name="visible">true</property>
+ <layout>
+ <property name="column">left</property>
+ <property name="row">3</property>
+ </layout>
</object>
- <packing>
- <property name="column">left</property>
- <property name="row">3</property>
- </packing>
</child>
<child>
- <object class="DzlRadioBox" id="project_language_chooser">
- <property name="expand">true</property>
- <property name="visible">true</property>
+ <object class="IdeRadioBox" id="project_language_chooser">
+ <property name="hexpand">true</property>
+ <layout>
+ <property name="column">center</property>
+ <property name="row">3</property>
+ </layout>
</object>
- <packing>
- <property name="column">center</property>
- <property name="row">3</property>
- </packing>
</child>
<child>
@@ -187,61 +173,47 @@
<property name="halign">end</property>
<property name="label" translatable="yes">License</property>
<property name="valign">start</property>
- <property name="visible">true</property>
+ <layout>
+ <property name="column">left</property>
+ <property name="row">4</property>
+ </layout>
</object>
- <packing>
- <property name="column">left</property>
- <property name="row">4</property>
- </packing>
</child>
<child>
- <object class="DzlRadioBox" id="license_chooser">
+ <object class="IdeRadioBox" id="license_chooser">
<property name="active-id">gpl_3</property>
- <property name="expand">true</property>
- <property name="visible">true</property>
- <items>
- <item id="gpl_3" translatable="yes">GPLv3+</item>
- <item id="lgpl_3" translatable="yes">LGPLv3+</item>
- <item id="agpl_3" translatable="yes">AGPLv3+</item>
- <item id="mit_x11" translatable="yes">MIT/X11</item>
- <item id="apache_2" translatable="yes">Apache 2.0</item>
- <item id="gpl_2" translatable="yes">GPLv2+</item>
- <item id="lgpl_2_1" translatable="yes">LGPLv2.1+</item>
- <item id="none" translatable="yes">No license</item>
- </items>
+ <property name="hexpand">true</property>
+ <layout>
+ <property name="column">center</property>
+ <property name="row">4</property>
+ </layout>
</object>
- <packing>
- <property name="column">center</property>
- <property name="row">4</property>
- </packing>
</child>
<child>
<object class="GtkLabel">
<property name="halign">end</property>
<property name="label" translatable="yes">Version Control</property>
- <property name="visible">true</property>
+ <layout>
+ <property name="column">left</property>
+ <property name="row">5</property>
+ </layout>
</object>
- <packing>
- <property name="column">left</property>
- <property name="row">5</property>
- </packing>
</child>
<child>
<object class="GtkBox" id="versioning_box">
<property name="orientation">horizontal</property>
- <property name="visible">true</property>
<child>
<object class="GtkSwitch" id="versioning_switch">
<property name="active">true</property>
<property name="halign">start</property>
- <property name="visible">true</property>
</object>
</child>
- <child>
+ <child type="end">
<object class="GtkLabel">
<property name="label" translatable="yes">Uses the Git version control
system</property>
- <property name="visible">true</property>
+ <property name="margin-start">12</property>
+ <property name="halign">center</property>
<style>
<class name="dim-label"/>
</style>
@@ -249,26 +221,21 @@
<attribute name="scale" value="0.833333"/>
</attributes>
</object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
</child>
+ <layout>
+ <property name="column">center</property>
+ <property name="row">5</property>
+ </layout>
</object>
- <packing>
- <property name="column">center</property>
- <property name="row">5</property>
- </packing>
</child>
<child>
<object class="GtkBox">
- <property name="visible">true</property>
<child>
<object class="GtkToggleButton" id="license_more">
<property name="active" bind-source="license_chooser" bind-property="show-more"
bind-flags="bidirectional"/>
<property name="sensitive" bind-source="license_chooser" bind-property="has-more"/>
<property name="valign">start</property>
<property name="vexpand">false</property>
- <property name="visible">true</property>
<property name="focus-on-click">false</property>
<style>
<class name="flat"/>
@@ -277,27 +244,24 @@
<child>
<object class="GtkImage">
<property name="icon-name">view-more-symbolic</property>
- <property name="visible">true</property>
</object>
</child>
</object>
</child>
+ <layout>
+ <property name="column">right</property>
+ <property name="row">4</property>
+ </layout>
</object>
- <packing>
- <property name="column">right</property>
- <property name="row">4</property>
- </packing>
</child>
<child>
<object class="GtkBox">
- <property name="visible">true</property>
<child>
<object class="GtkToggleButton" id="language_more">
<property name="active" bind-source="project_language_chooser"
bind-property="show-more" bind-flags="bidirectional"/>
<property name="sensitive" bind-source="project_language_chooser"
bind-property="has-more"/>
<property name="valign">start</property>
<property name="vexpand">false</property>
- <property name="visible">true</property>
<property name="focus-on-click">false</property>
<style>
<class name="flat"/>
@@ -306,57 +270,50 @@
<child>
<object class="GtkImage">
<property name="icon-name">view-more-symbolic</property>
- <property name="visible">true</property>
</object>
</child>
</object>
</child>
+ <layout>
+ <property name="column">right</property>
+ <property name="row">3</property>
+ </layout>
</object>
- <packing>
- <property name="column">right</property>
- <property name="row">3</property>
- </packing>
</child>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="margin-top">12</property>
<property name="hexpand">true</property>
- <property name="visible">true</property>
- <child>
+ <child type="end">
<object class="GtkButton" id="create_button">
<property name="label" translatable="yes">_Create Project</property>
<property name="use-underline">True</property>
<property name="halign">end</property>
- <property name="visible">true</property>
<style>
<class name="suggested-action"/>
</style>
</object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
</child>
+ <layout>
+ <property name="column">1</property>
+ <property name="row">6</property>
+ </layout>
</object>
- <packing>
- <property name="column">1</property>
- <property name="row">6</property>
- </packing>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
- <property name="expand">true</property>
+ <property name="hexpand">true</property>
+ <property name="vexpand">true</property>
<property name="valign">start</property>
<property name="spacing">12</property>
<property name="margin-top">24</property>
- <property name="visible">true</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Select a Template</property>
- <property name="visible">true</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
@@ -373,7 +330,6 @@
<property name="min-children-per-line">4</property>
<property name="halign">center</property>
<property name="valign">start</property>
- <property name="visible">true</property>
</object>
</child>
</object>
diff --git a/src/plugins/create-project/gbp-create-project-workspace-addin.c
b/src/plugins/create-project/gbp-create-project-workspace-addin.c
index b8000ed6a..45725df15 100644
--- a/src/plugins/create-project/gbp-create-project-workspace-addin.c
+++ b/src/plugins/create-project/gbp-create-project-workspace-addin.c
@@ -23,15 +23,16 @@
#include "config.h"
#include <glib/gi18n.h>
+
#include <libide-greeter.h>
-#include "gbp-create-project-surface.h"
+#include "gbp-create-project-widget.h"
#include "gbp-create-project-workspace-addin.h"
struct _GbpCreateProjectWorkspaceAddin
{
- GObject parent_instance;
- IdeSurface *surface;
+ GObject parent_instance;
+ GbpCreateProjectWidget *widget;
};
static void
@@ -40,12 +41,14 @@ gbp_create_project_workspace_addin_load (IdeWorkspaceAddin *addin,
{
GbpCreateProjectWorkspaceAddin *self = (GbpCreateProjectWorkspaceAddin *)addin;
+ IDE_ENTRY;
+
g_assert (GBP_IS_CREATE_PROJECT_WORKSPACE_ADDIN (self));
g_assert (IDE_IS_GREETER_WORKSPACE (workspace));
ide_greeter_workspace_add_button (IDE_GREETER_WORKSPACE (workspace),
g_object_new (GTK_TYPE_BUTTON,
- "action-name", "win.surface",
+ "action-name", "greeter.page",
"action-target", g_variant_new_string ("create-project"),
"label", _("Start _New Project…"),
"use-underline", TRUE,
@@ -53,10 +56,12 @@ gbp_create_project_workspace_addin_load (IdeWorkspaceAddin *addin,
NULL),
-10);
- self->surface = g_object_new (GBP_TYPE_CREATE_PROJECT_SURFACE,
- "visible", TRUE,
- NULL);
- ide_workspace_add_surface (workspace, self->surface);
+ self->widget = g_object_new (GBP_TYPE_CREATE_PROJECT_WIDGET, NULL);
+ ide_greeter_workspace_add_page (IDE_GREETER_WORKSPACE (workspace),
+ GTK_WIDGET (self->widget),
+ "create-project");
+
+ IDE_EXIT;
}
static void
@@ -65,10 +70,16 @@ gbp_create_project_workspace_addin_unload (IdeWorkspaceAddin *addin,
{
GbpCreateProjectWorkspaceAddin *self = (GbpCreateProjectWorkspaceAddin *)addin;
+ IDE_ENTRY;
+
g_assert (GBP_IS_CREATE_PROJECT_WORKSPACE_ADDIN (self));
g_assert (IDE_IS_GREETER_WORKSPACE (workspace));
- gtk_widget_destroy (GTK_WIDGET (self->surface));
+ ide_greeter_workspace_remove_page (IDE_GREETER_WORKSPACE (workspace),
+ GTK_WIDGET (self->widget));
+ self->widget = NULL;
+
+ IDE_EXIT;
}
static void
@@ -79,7 +90,7 @@ workspace_addin_iface_init (IdeWorkspaceAddinInterface *iface)
}
G_DEFINE_FINAL_TYPE_WITH_CODE (GbpCreateProjectWorkspaceAddin, gbp_create_project_workspace_addin,
G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (IDE_TYPE_WORKSPACE_ADDIN, workspace_addin_iface_init))
+ G_IMPLEMENT_INTERFACE (IDE_TYPE_WORKSPACE_ADDIN, workspace_addin_iface_init))
static void
gbp_create_project_workspace_addin_class_init (GbpCreateProjectWorkspaceAddinClass *klass)
diff --git a/src/plugins/create-project/meson.build b/src/plugins/create-project/meson.build
index 94f1f09b4..1292db5ca 100644
--- a/src/plugins/create-project/meson.build
+++ b/src/plugins/create-project/meson.build
@@ -2,7 +2,7 @@ plugins_sources += files([
'create-project-plugin.c',
'gbp-create-project-application-addin.c',
'gbp-create-project-template-icon.c',
- 'gbp-create-project-surface.c',
+ 'gbp-create-project-widget.c',
'gbp-create-project-workspace-addin.c',
])
diff --git a/src/plugins/meson.build b/src/plugins/meson.build
index 6136cbdc2..8b9f89bcb 100644
--- a/src/plugins/meson.build
+++ b/src/plugins/meson.build
@@ -56,7 +56,7 @@ subdir('codeui')
subdir('comment-code')
subdir('copyright')
subdir('c-pack')
-#subdir('create-project')
+subdir('create-project')
subdir('ctags')
subdir('debuggerui')
#subdir('devhelp')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]