diff options
Diffstat (limited to 'src/msg.c')
-rw-r--r-- | src/msg.c | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -31,6 +31,8 @@ static void zenity_text_size_allocate (GtkWidget *widget, GtkAllocation *allocat static void zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data, ZenityData *data) { + + GtkWidget *cancel_button, *ok_button; cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("_No"), GTK_RESPONSE_CANCEL); @@ -45,6 +47,33 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data if (data->ok_label) { gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); } + + +} + +static void +zenity_label_widget_clipboard_selection(GtkWidget *widget) +{ + /* Workaround hotfix for suspected toolkit issue: + since focus change of the dialog's focussed widget (text) + somehow currently chooses to destroy + a pre-existing (read: foreign, user-initiated) X11 primary selection + (via gtk_label_select_region() -> ... + -> gtk_clipboard_set_contents()/gtk_clipboard_clear()), + we need to ensure + that the widget does have its gtk-label-select-on-focus property off, + in order to avoid having the label become selected automatically + and thereby having pre-existing clipboard content nullified. + Side note: this selection issue only applies to widgets + which have both + <property name="can_focus">True</property> + <property name="selectable">True</property> + . + */ + g_object_set(gtk_widget_get_settings (widget), + "gtk-label-select-on-focus", + FALSE, + NULL); } void @@ -66,6 +95,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) break; case ZENITY_MSG_QUESTION: + case ZENITY_MSG_SWITCH: builder = zenity_util_load_ui_file ("zenity_question_dialog", NULL); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_question_dialog")); text = gtk_builder_get_object (builder, "zenity_question_text"); @@ -99,6 +129,14 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) break; } + if (data->extra_label) { + gint i=0; + while(data->extra_label[i]!=NULL){ + gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; @@ -128,6 +166,10 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) zenity_msg_construct_question_dialog (dialog, msg_data, data); break; + case ZENITY_MSG_SWITCH: + zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-question"); + break; + case ZENITY_MSG_ERROR: zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-error"); break; @@ -158,6 +200,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); else gtk_label_set_markup (GTK_LABEL (text), g_strcompress (msg_data->dialog_text)); + zenity_label_widget_clipboard_selection(GTK_WIDGET (text)); } if (msg_data->ellipsize) @@ -201,6 +244,8 @@ zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: + if (response < g_strv_length(zen_data->extra_label)) + printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } |