[file-roller/wip/gtk4: 30/54] Use a CSS class to define the dialog content padding




commit 98481af65bca463c0810b8566150bc45b3520f06
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Oct 1 17:57:17 2022 +0200

    Use a CSS class to define the dialog content padding

 src/dlg-password.c           | 5 +----
 src/dlg-prop.c               | 8 ++------
 src/fr-window.c              | 2 +-
 src/ui/app.css               | 4 ++++
 src/ui/new-archive-dialog.ui | 4 +++-
 src/ui/password.ui           | 3 +++
 src/ui/properties.ui         | 3 +++
 7 files changed, 17 insertions(+), 12 deletions(-)
---
diff --git a/src/dlg-password.c b/src/dlg-password.c
index a9d18332..4c508aa2 100644
--- a/src/dlg-password.c
+++ b/src/dlg-password.c
@@ -75,7 +75,6 @@ dlg_password (GtkWidget *widget,
 {
        FrWindow   *window = callback_data;
        DialogData *data;
-       GtkWidget  *content_area;
        char       *basename;
        char       *title;
 
@@ -91,9 +90,7 @@ dlg_password (GtkWidget *widget,
                                     "use-header-bar", _gtk_settings_get_dialogs_use_header (),
                                     "title", _("Password"),
                                     NULL);
-       content_area = gtk_dialog_get_content_area (GTK_DIALOG (data->dialog));
-       _gtk_widget_set_margin (content_area, 20);
-       gtk_box_append (GTK_BOX (content_area), GET_WIDGET ("password_vbox"));
+       gtk_box_append (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (data->dialog))), GET_WIDGET 
("password_vbox"));
        gtk_dialog_add_buttons (GTK_DIALOG (data->dialog),
                                _GTK_LABEL_CANCEL, GTK_RESPONSE_CANCEL,
                                _GTK_LABEL_SAVE, GTK_RESPONSE_OK,
diff --git a/src/dlg-prop.c b/src/dlg-prop.c
index 7391027c..25623caa 100644
--- a/src/dlg-prop.c
+++ b/src/dlg-prop.c
@@ -50,7 +50,6 @@ dlg_prop (FrWindow *window)
 {
        DialogData *data;
        GtkWidget  *label;
-       GtkWidget  *table;
        GFile      *parent;
        char       *uri;
        char       *markup;
@@ -64,10 +63,6 @@ dlg_prop (FrWindow *window)
 
        data->builder = gtk_builder_new_from_resource (FILE_ROLLER_RESOURCE_UI_PATH "properties.ui");
 
-       /* Get the widgets. */
-       table = _gtk_builder_get_widget (data->builder, "content");
-       _gtk_widget_set_margin (table, 20);
-
        /* Make the dialog */
 
        data->dialog = g_object_new (GTK_TYPE_DIALOG,
@@ -76,7 +71,8 @@ dlg_prop (FrWindow *window)
                                     "use-header-bar", _gtk_settings_get_dialogs_use_header (),
                                     NULL);
 
-       gtk_box_append (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (data->dialog))), table);
+       gtk_box_append (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (data->dialog))),
+                       _gtk_builder_get_widget (data->builder, "content"));
 
        /* Set widgets data. */
 
diff --git a/src/fr-window.c b/src/fr-window.c
index 7961299a..8831334f 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -7426,7 +7426,7 @@ fr_window_view_last_output (FrWindow   *window,
        /**/
 
        vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-       _gtk_widget_set_margin (GTK_WIDGET (vbox), 10);
+       gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (vbox)), "dialog-content");
        gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolled), text_view);
        _gtk_box_pack_start (GTK_BOX (vbox), scrolled, TRUE, TRUE);
        _gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), vbox, TRUE, TRUE);
diff --git a/src/ui/app.css b/src/ui/app.css
index 4f0049af..dfbc8d67 100644
--- a/src/ui/app.css
+++ b/src/ui/app.css
@@ -7,3 +7,7 @@
        padding: 15px;
        border-top: 1px solid @borders;
 }
+
+.dialog-content {
+       padding: 20px;
+}
diff --git a/src/ui/new-archive-dialog.ui b/src/ui/new-archive-dialog.ui
index 078f729b..41256042 100644
--- a/src/ui/new-archive-dialog.ui
+++ b/src/ui/new-archive-dialog.ui
@@ -2,9 +2,11 @@
 <interface>
   <requires lib="gtk" version="4.0"/>
   <object class="GtkBox" id="content">
-    <property name="border_width">15</property>
     <property name="orientation">vertical</property>
     <property name="spacing">24</property>
+    <style>
+      <class name="dialog-content"/>
+    </style>
     <child>
       <object class="GtkBox" id="box1">
         <property name="orientation">vertical</property>
diff --git a/src/ui/password.ui b/src/ui/password.ui
index 20842102..a6253f5b 100644
--- a/src/ui/password.ui
+++ b/src/ui/password.ui
@@ -4,6 +4,9 @@
   <object class="GtkBox" id="password_vbox">
     <property name="orientation">vertical</property>
     <property name="spacing">15</property>
+    <style>
+      <class name="dialog-content"/>
+    </style>
     <child>
       <object class="GtkLabel" id="title_label">
         <property name="label">Enter a password for &quot;archive.tar.xz&quot;</property>
diff --git a/src/ui/properties.ui b/src/ui/properties.ui
index 1b14c55d..8e4c98ee 100644
--- a/src/ui/properties.ui
+++ b/src/ui/properties.ui
@@ -4,6 +4,9 @@
   <object class="GtkGrid" id="content">
     <property name="row_spacing">10</property>
     <property name="column_spacing">10</property>
+    <style>
+      <class name="dialog-content"/>
+    </style>
     <child>
       <object class="GtkLabel" id="p_name_label_label">
         <property name="label" translatable="1" context="File">Name:</property>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]