[nautilus] compress-dialog: fix dialog width changes
- From: Răzvan-Mihai Chițu <razvanchitu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] compress-dialog: fix dialog width changes
- Date: Tue, 4 Oct 2016 20:23:22 +0000 (UTC)
commit 36e506a73c9648973b0b25222145b8ec2c89ef06
Author: Razvan Chitu <razvan ch95 gmail com>
Date: Fri Sep 30 16:54:35 2016 +0300
compress-dialog: fix dialog width changes
The compress dialog has a width allocation request that can be smaller than the
width of description labels in various languages other than english. In order to
fix this, use a label widget for each description and group them in a
homogeneous GtkStack.
https://bugzilla.gnome.org/show_bug.cgi?id=771435
src/nautilus-compress-dialog-controller.c | 24 +++++-------
src/resources/ui/nautilus-compress-dialog.ui | 48 ++++++++++++++++++++++---
2 files changed, 52 insertions(+), 20 deletions(-)
---
diff --git a/src/nautilus-compress-dialog-controller.c b/src/nautilus-compress-dialog-controller.c
index db4662d..3937181 100644
--- a/src/nautilus-compress-dialog-controller.c
+++ b/src/nautilus-compress-dialog-controller.c
@@ -26,16 +26,12 @@
#include "nautilus-global-preferences.h"
-#define ZIP_DESCRIPTION _("Compatible with all operating systems.")
-#define TAR_XZ_DESCRIPTION _("Smaller archives but Linux and Mac only.")
-#define SEVEN_ZIP_DESCRIPTION _("Smaller archives but must be installed on Windows and Mac.")
-
struct _NautilusCompressDialogController
{
NautilusFileNameWidgetController parent_instance;
GtkWidget *compress_dialog;
- GtkWidget *description_label;
+ GtkWidget *description_stack;
GtkWidget *name_entry;
GtkWidget *zip_radio_button;
GtkWidget *tar_xz_radio_button;
@@ -123,7 +119,7 @@ update_selected_format (NautilusCompressDialogController *self,
NautilusCompressionFormat format)
{
const char *extension;
- const char *description;
+ const char *description_label_name;
GtkWidget *active_button;
switch (format)
@@ -131,7 +127,7 @@ update_selected_format (NautilusCompressDialogController *self,
case NAUTILUS_COMPRESSION_ZIP:
{
extension = ".zip";
- description = ZIP_DESCRIPTION;
+ description_label_name = "zip-description-label";
active_button = self->zip_radio_button;
}
break;
@@ -139,7 +135,7 @@ update_selected_format (NautilusCompressDialogController *self,
case NAUTILUS_COMPRESSION_TAR_XZ:
{
extension = ".tar.xz";
- description = TAR_XZ_DESCRIPTION;
+ description_label_name = "tar-xz-description-label";
active_button = self->tar_xz_radio_button;
}
break;
@@ -147,7 +143,7 @@ update_selected_format (NautilusCompressDialogController *self,
case NAUTILUS_COMPRESSION_7ZIP:
{
extension = ".7z";
- description = SEVEN_ZIP_DESCRIPTION;
+ description_label_name = "seven-zip-description-label";
active_button = self->seven_zip_radio_button;
}
break;
@@ -161,8 +157,8 @@ update_selected_format (NautilusCompressDialogController *self,
self->extension = extension;
- gtk_label_set_text (GTK_LABEL (self->description_label),
- description);
+ gtk_stack_set_visible_child_name (GTK_STACK (self->description_stack),
+ description_label_name);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (active_button),
TRUE);
@@ -239,7 +235,7 @@ nautilus_compress_dialog_controller_new (GtkWindow *parent_window,
GtkWidget *error_label;
GtkWidget *name_entry;
GtkWidget *activate_button;
- GtkWidget *description_label;
+ GtkWidget *description_stack;
GtkWidget *zip_radio_button;
GtkWidget *tar_xz_radio_button;
GtkWidget *seven_zip_radio_button;
@@ -254,7 +250,7 @@ nautilus_compress_dialog_controller_new (GtkWindow *parent_window,
zip_radio_button = GTK_WIDGET (gtk_builder_get_object (builder, "zip_radio_button"));
tar_xz_radio_button = GTK_WIDGET (gtk_builder_get_object (builder, "tar_xz_radio_button"));
seven_zip_radio_button = GTK_WIDGET (gtk_builder_get_object (builder, "seven_zip_radio_button"));
- description_label = GTK_WIDGET (gtk_builder_get_object (builder, "description_label"));
+ description_stack = GTK_WIDGET (gtk_builder_get_object (builder, "description_stack"));
gtk_window_set_transient_for (GTK_WINDOW (compress_dialog),
parent_window);
@@ -270,7 +266,7 @@ nautilus_compress_dialog_controller_new (GtkWindow *parent_window,
self->zip_radio_button = zip_radio_button;
self->tar_xz_radio_button = tar_xz_radio_button;
self->seven_zip_radio_button = seven_zip_radio_button;
- self->description_label = description_label;
+ self->description_stack = description_stack;
self->name_entry = name_entry;
self->response_handler_id = g_signal_connect (compress_dialog,
diff --git a/src/resources/ui/nautilus-compress-dialog.ui b/src/resources/ui/nautilus-compress-dialog.ui
index 507f0ba..526e9ee 100644
--- a/src/resources/ui/nautilus-compress-dialog.ui
+++ b/src/resources/ui/nautilus-compress-dialog.ui
@@ -9,7 +9,6 @@
<property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
<property name="use-header-bar">1</property>
- <property name="width_request">490</property>
<child internal-child="vbox">
<object class="GtkBox" id="vbox">
<property name="orientation">vertical</property>
@@ -109,12 +108,49 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="description_label">
+ <object class="GtkStack" id="description_stack">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <style>
- <class name="dim-label"/>
- </style>
+ <property name="can_focus">False</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkLabel" id="zip_description_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Compatible with all operating systems.</property>
+ <property name="xalign">0</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="name">zip-description-label</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="tar_xz_description_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Smaller archives but Linux and Mac only.</property>
+ <property name="xalign">0</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="name">tar-xz-description-label</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="seven_zip_description_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Smaller archives but must be installed on Windows
and Mac.</property>
+ <property name="xalign">0</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="name">seven-zip-description-label</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]