summaryrefslogtreecommitdiff
path: root/src/gui/panels
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2024-07-22 23:38:20 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2024-07-22 23:38:20 (GMT)
commit1596de25f349ca065422074327e208cfca7d8d3f (patch)
tree481f73f6af8388bad797525b2925ec373e642670 /src/gui/panels
parent6523d49b446139a1ec1e2134a2ea980765b7c66a (diff)
Simplify the constraint-based layout for the Welcome panel.
Diffstat (limited to 'src/gui/panels')
-rw-r--r--src/gui/panels/welcome.c31
-rw-r--r--src/gui/panels/welcome.ui149
2 files changed, 78 insertions, 102 deletions
diff --git a/src/gui/panels/welcome.c b/src/gui/panels/welcome.c
index d10b16a..3cd349f 100644
--- a/src/gui/panels/welcome.c
+++ b/src/gui/panels/welcome.c
@@ -280,6 +280,8 @@ bool gtk_welcome_panel_create(GtkWelcomePanel *panel)
{
bool result; /* Bilan à retourner */
int min; /* Taille à gauche minimale */
+ GtkConstraintLayout *layout; /* Disposition fixant la taille*/
+ GtkConstraint *constraint; /* Contrainte à considérer */
/* Constitution de la liste des démarreurs */
@@ -289,8 +291,6 @@ bool gtk_welcome_panel_create(GtkWelcomePanel *panel)
(GtkListBoxCreateWidgetFunc)gtk_welcome_panel_create_launcher_widget,
NULL, NULL);
-
-
/* Dimensionnement de la zone d'astuces */
gtk_widget_measure(GTK_WIDGET(panel->list), GTK_ORIENTATION_HORIZONTAL, -1, &min, NULL, NULL, NULL);
@@ -298,7 +298,32 @@ bool gtk_welcome_panel_create(GtkWelcomePanel *panel)
if (min > 150)
min -= 150;
- g_object_set(G_OBJECT(panel->hints), "width-request", min, NULL);
+ layout = GTK_CONSTRAINT_LAYOUT(gtk_widget_get_layout_manager(GTK_WIDGET(panel->hints)));
+
+ gtk_constraint_layout_remove_all_constraints(layout);
+
+ constraint = gtk_constraint_new_constant(NULL,
+ GTK_CONSTRAINT_ATTRIBUTE_LEFT,
+ GTK_CONSTRAINT_RELATION_EQ,
+ 0,
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
+ gtk_constraint_layout_add_constraint(layout, constraint);
+
+ constraint = gtk_constraint_new_constant(NULL,
+ GTK_CONSTRAINT_ATTRIBUTE_TOP,
+ GTK_CONSTRAINT_RELATION_EQ,
+ 0,
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
+ gtk_constraint_layout_add_constraint(layout, constraint);
+
+ constraint = gtk_constraint_new_constant(NULL,
+ GTK_CONSTRAINT_ATTRIBUTE_RIGHT,
+ GTK_CONSTRAINT_RELATION_EQ,
+ min,
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
+ gtk_constraint_layout_add_constraint(layout, constraint);
+
+ /* Premier affichage */
gtk_label_set_markup(panel->hints, panel->raw_hints[panel->cur_hint]);
diff --git a/src/gui/panels/welcome.ui b/src/gui/panels/welcome.ui
index 422e2ad..c545b1d 100644
--- a/src/gui/panels/welcome.ui
+++ b/src/gui/panels/welcome.ui
@@ -10,112 +10,16 @@
<property name="vexpand">TRUE</property>
<property name="has-frame">0</property>
<child>
- <object class="GtkGizmo">
+ <object class="GtkGrid">
<property name="halign">center</property>
<property name="valign">center</property>
+ <property name="column-spacing">64</property>
+ <property name="column-homogeneous">TRUE</property>
<property name="margin-bottom">32</property>
<property name="margin-end">32</property>
<property name="margin-start">32</property>
<property name="margin-top">32</property>
- <!-- Layout -->
- <property name="layout-manager">
- <object class="GtkConstraintLayout">
- <constraints>
-
- <!-- Central point -->
-
- <guide name="guide-center"
- min-width="1" nat-width="1" max-width="1"
- min-height="1" nat-height="1" max-height="1"/>
-
- <constraint target="guide-center" target-attribute="left"
- source="super" source-attribute="width"
- relation="eq"
- multiplier="0.5"
- strength="required"/>
-
- <constraint target="guide-center" target-attribute="top"
- source="super" source-attribute="height"
- relation="eq"
- multiplier="0.5"
- strength="required"/>
-
- <!-- Widgets -->
-
- <constraint target="list" target-attribute="right"
- source="guide-center" source-attribute="left"
- relation="eq"
- constant="-32"
- strength="required"/>
-
- <constraint target="list" target-attribute="center-y"
- source="guide-center" source-attribute="top"
- relation="eq"
- strength="required"/>
-
- <constraint target="properties" target-attribute="left"
- source="guide-center" source-attribute="left"
- relation="eq"
- constant="32"
- strength="required"/>
-
- <constraint target="properties" target-attribute="width"
- source="list" source-attribute="width"
- relation="eq"
- strength="required"/>
-
- <constraint target="properties" target-attribute="center-y"
- source="guide-center" source-attribute="top"
- relation="eq"
- strength="required"/>
-
- <!-- Surface for viewport -->
-
- <constraint target="super" target-attribute="left"
- source="list" source-attribute="left"
- relation="le"
- strength="required"/>
-
- <constraint target="super" target-attribute="left"
- source="properties" source-attribute="left"
- relation="le"
- strength="required"/>
-
- <constraint target="super" target-attribute="right"
- source="list" source-attribute="right"
- relation="ge"
- strength="required"/>
-
- <constraint target="super" target-attribute="right"
- source="properties" source-attribute="right"
- relation="ge"
- strength="required"/>
-
- <constraint target="super" target-attribute="top"
- source="list" source-attribute="top"
- relation="le"
- strength="required"/>
-
- <constraint target="super" target-attribute="top"
- source="properties" source-attribute="top"
- relation="le"
- strength="required"/>
-
- <constraint target="super" target-attribute="bottom"
- source="list" source-attribute="bottom"
- relation="ge"
- strength="required"/>
-
- <constraint target="super" target-attribute="bottom"
- source="properties" source-attribute="bottom"
- relation="ge"
- strength="required"/>
-
- </constraints>
- </object>
- </property>
-
<!-- Launcher list -->
<child>
<object class="GtkListBox" id="list">
@@ -123,11 +27,19 @@
<property name="valign">center</property>
<property name="selection-mode">GTK_SELECTION_SINGLE</property>
<property name="activate-on-single-click">0</property>
+
+ <layout>
+ <property name="column">0</property>
+ <property name="row">0</property>
+ </layout>
+
<style>
<class name="boxed-list"/>
<class name="frame"/>
</style>
+
<signal name="selected-rows-changed" handler="gtk_welcome_panel_on_selected_rows_changed"/>
+
</object>
</child>
@@ -136,11 +48,18 @@
<object class="GtkStack" id="properties">
<property name="halign">start</property>
<property name="valign">fill</property>
+
+ <layout>
+ <property name="column">1</property>
+ <property name="row">0</property>
+ </layout>
+
<child>
<object class="GtkStackPage">
<property name="name">default</property>
<property name="title">Welcome</property>
+
<property name="child">
<object class="GtkGrid" id="def_child">
<property name="halign">start</property>
@@ -149,6 +68,7 @@
<property name="column-homogeneous">FALSE</property>
<!-- Text -->
+
<child>
<object class="GtkLabel" id="hints">
<property name="halign">start</property>
@@ -158,10 +78,37 @@
<property name="vexpand">1</property>
<property name="width-request">50</property>
<property name="wrap">TRUE</property>
+
+ <property name="layout-manager">
+ <object class="GtkConstraintLayout">
+ <!--
+ <constraints>
+
+ <constraint target="super" target-attribute="left"
+ relation="eq"
+ constant="0"
+ strength="required"/>
+
+ <constraint target="super" target-attribute="top"
+ relation="eq"
+ constant="0"
+ strength="required"/>
+
+ <constraint target="super" target-attribute="right"
+ relation="eq"
+ constant="340"
+ strength="required"/>
+
+ </constraints>
+ -->
+ </object>
+ </property>
+
<layout>
<property name="column">0</property>
<property name="row">0</property>
</layout>
+
</object>
</child>
@@ -176,6 +123,7 @@
<property name="column">1</property>
<property name="row">1</property>
</layout>
+
<child>
<object class="GtkButton">
<property name="icon-name">go-previous-symbolic</property>
@@ -183,6 +131,7 @@
<signal name="clicked" handler="gtk_welcome_panel_on_prev_hint_clicked"/>
</object>
</child>
+
<child>
<object class="GtkButton">
<property name="icon-name">go-next-symbolic</property>
@@ -190,9 +139,11 @@
<signal name="clicked" handler="gtk_welcome_panel_on_next_hint_clicked"/>
</object>
</child>
+
<style>
<class name="linked"/>
</style>
+
</object>
</child>