Do not use an icon for Cancel/OK buttons

GTK+ documentation recommends to not use an icons, but use
"_OK"/"_Cancel" labels instead
This commit is contained in:
Javier Jardón 2015-03-22 04:57:05 +00:00
parent d26aa23e1d
commit 6fcbb80fd1
11 changed files with 4 additions and 42 deletions

View File

@ -95,15 +95,11 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
if (data->ok_label) { if (data->ok_label) {
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_ok_button")); button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_ok_button"));
gtk_button_set_label (GTK_BUTTON (button), data->ok_label); gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
} }
if (data->cancel_label) { if (data->cancel_label) {
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_cancel_button")); button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_cancel_button"));
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
} }
g_object_unref (builder); g_object_unref (builder);

View File

@ -60,16 +60,12 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data)
if (data->ok_label) { if (data->ok_label) {
g_object_get (G_OBJECT (dialog), "ok-button", &button, NULL); g_object_get (G_OBJECT (dialog), "ok-button", &button, NULL);
gtk_button_set_label (GTK_BUTTON (button), data->ok_label); gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
g_object_unref (G_OBJECT (button)); g_object_unref (G_OBJECT (button));
} }
if (data->cancel_label) { if (data->cancel_label) {
g_object_get (G_OBJECT (dialog), "cancel-button", &button, NULL); g_object_get (G_OBJECT (dialog), "cancel-button", &button, NULL);
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
g_object_unref (G_OBJECT (button)); g_object_unref (G_OBJECT (button));
} }

View File

@ -87,15 +87,11 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data)
if (data->ok_label) { if (data->ok_label) {
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_ok_button")); button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_ok_button"));
gtk_button_set_label (GTK_BUTTON (button), data->ok_label); gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
} }
if (data->cancel_label) { if (data->cancel_label) {
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_cancel_button")); button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_cancel_button"));
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
} }
text = gtk_builder_get_object (builder, "zenity_entry_text"); text = gtk_builder_get_object (builder, "zenity_entry_text");

View File

@ -52,8 +52,8 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data)
dialog = gtk_file_chooser_dialog_new (NULL, NULL, dialog = gtk_file_chooser_dialog_new (NULL, NULL,
action, action,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, _("_Cancel"), GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK, _("_OK"), GTK_RESPONSE_OK,
NULL); NULL);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog),

View File

@ -209,15 +209,11 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data)
if (data->ok_label) { if (data->ok_label) {
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_ok_button")); button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_ok_button"));
gtk_button_set_label (GTK_BUTTON (button), data->ok_label); gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
} }
if (data->cancel_label) { if (data->cancel_label) {
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_cancel_button")); button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_cancel_button"));
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
} }
text = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_text")); text = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_text"));

View File

@ -40,14 +40,10 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data
if (data->cancel_label) { if (data->cancel_label) {
gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label); gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label);
gtk_button_set_image (GTK_BUTTON (cancel_button),
gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
} }
if (data->ok_label) { if (data->ok_label) {
gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label);
gtk_button_set_image (GTK_BUTTON (ok_button),
gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
} }
} }
@ -119,8 +115,6 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
if (ok_button) { if (ok_button) {
if (data->ok_label) { if (data->ok_label) {
gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label);
gtk_button_set_image (GTK_BUTTON (ok_button),
gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
} }
} }

View File

@ -45,10 +45,10 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data
dialog = gtk_dialog_new (); dialog = gtk_dialog_new ();
gtk_dialog_add_button(GTK_DIALOG(dialog), gtk_dialog_add_button(GTK_DIALOG(dialog),
data->cancel_label != NULL ? data->cancel_label : GTK_STOCK_CANCEL, data->cancel_label != NULL ? data->cancel_label : _("_Cancel"),
GTK_RESPONSE_CANCEL); GTK_RESPONSE_CANCEL);
gtk_dialog_add_button(GTK_DIALOG(dialog), gtk_dialog_add_button(GTK_DIALOG(dialog),
data->ok_label != NULL ? data->ok_label : GTK_STOCK_OK, data->ok_label != NULL ? data->ok_label : _("_OK"),
GTK_RESPONSE_OK); GTK_RESPONSE_OK);
image = gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION, image = gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION,

View File

@ -319,15 +319,11 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
if (data->ok_label) { if (data->ok_label) {
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_ok_button")); button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_ok_button"));
gtk_button_set_label (GTK_BUTTON (button), data->ok_label); gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
} }
if (data->cancel_label) { if (data->cancel_label) {
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_cancel_button")); button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_cancel_button"));
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
} }
if (progress_data->dialog_text) if (progress_data->dialog_text)

View File

@ -82,15 +82,11 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data)
if (data->ok_label) { if (data->ok_label) {
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_ok_button")); button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_ok_button"));
gtk_button_set_label (GTK_BUTTON (button), data->ok_label); gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
} }
if (data->cancel_label) { if (data->cancel_label) {
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_cancel_button")); button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_cancel_button"));
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
} }
if (scale_data->dialog_text) if (scale_data->dialog_text)

View File

@ -278,14 +278,10 @@ zenity_text (ZenityData *data, ZenityTextData *text_data)
if (data->ok_label) { if (data->ok_label) {
gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label);
gtk_button_set_image (GTK_BUTTON (ok_button),
gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
} }
if (data->cancel_label) { if (data->cancel_label) {
gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label); gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label);
gtk_button_set_image (GTK_BUTTON (cancel_button),
gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
} }
if (text_data->checkbox) { if (text_data->checkbox) {

View File

@ -399,15 +399,11 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
if (data->ok_label) { if (data->ok_label) {
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_ok_button")); button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_ok_button"));
gtk_button_set_label (GTK_BUTTON (button), data->ok_label); gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
} }
if (data->cancel_label) { if (data->cancel_label) {
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_cancel_button")); button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_cancel_button"));
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
} }
text = gtk_builder_get_object (builder, "zenity_tree_text"); text = gtk_builder_get_object (builder, "zenity_tree_text");