Fix message dialog width and height on recent Gtk
The fix for Zenity bug 670496 "Zenity info/error windows grow in height with message length" (https://bugzilla.gnome.org/show_bug.cgi?id=670496) stopped working on recent Gtk, which doesn't seem to honor gtk_widget_set_size_request. This commit workarounds Gtk bug 657621 "Calculate the wrong height of labels wrapping on words" (https://bugzilla.gnome.org/show_bug.cgi?id=657621) by setting label's width-chars and max-width-chars to 60. This magic number was picked from GtkMessageDialog source (https://git.gnome.org/browse/gtk+/tree/gtk/ui/gtkmessagedialog.ui#n48).
This commit is contained in:
parent
ef14066564
commit
3b64d05e8a
17
src/msg.c
17
src/msg.c
@ -27,7 +27,6 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data);
|
static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data);
|
||||||
static void zenity_text_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data);
|
|
||||||
static void
|
static void
|
||||||
zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data, ZenityData *data)
|
zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data, ZenityData *data)
|
||||||
{
|
{
|
||||||
@ -188,9 +187,13 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
|
|||||||
if (data->width > -1)
|
if (data->width > -1)
|
||||||
gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1);
|
gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1);
|
||||||
else
|
else
|
||||||
if (!msg_data->ellipsize)
|
if (!msg_data->ellipsize && !msg_data->no_wrap) {
|
||||||
g_signal_connect_after (G_OBJECT (text), "size-allocate",
|
// the magic number 60 is picked from gtk+/gtk/ui/gtkmessagedialog.ui
|
||||||
G_CALLBACK (zenity_text_size_allocate), data);
|
// however, 60 would increase the distance between the icon and the text,
|
||||||
|
// decreasing to 10 fix it.
|
||||||
|
gtk_label_set_width_chars (text, 10);
|
||||||
|
gtk_label_set_max_width_chars (text, 10);
|
||||||
|
}
|
||||||
|
|
||||||
if (data->modal)
|
if (data->modal)
|
||||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||||
@ -223,12 +226,6 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
|
|||||||
gtk_main ();
|
gtk_main ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
zenity_text_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data)
|
|
||||||
{
|
|
||||||
gtk_widget_set_size_request (widget, allocation->width/2, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data)
|
zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data)
|
||||||
{
|
{
|
||||||
|
@ -518,8 +518,8 @@
|
|||||||
<property name="icon_size">6</property>
|
<property name="icon_size">6</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">True</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">False</property>
|
||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
@ -729,8 +729,8 @@
|
|||||||
<property name="icon_size">6</property>
|
<property name="icon_size">6</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">True</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">False</property>
|
||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
Reference in New Issue
Block a user