Skip to content
Permalink
Browse files

avoid 'gtk_dialog_add_button' with stock ids

  • Loading branch information...
sc0w committed Dec 11, 2018
1 parent 717a8f9 commit 7cd2ccc48b5a90cd54ba24f6bcdfe36dd8b495f6
Showing with 42 additions and 12 deletions.
  1. +9 −6 capplet/gsm-app-dialog.c
  2. +7 −6 mate-session/gsm-logout-dialog.c
  3. +20 −0 mate-session/gsm-util.c
  4. +6 −0 mate-session/gsm-util.h
@@ -186,19 +186,22 @@ setup_dialog (GsmAppDialog *dialog)
"resizable", FALSE,
NULL);

gtk_dialog_add_button (GTK_DIALOG (dialog),
"gtk-cancel", GTK_RESPONSE_CANCEL);
gsm_util_dialog_add_button (GTK_DIALOG (dialog),
_("_Cancel"), "process-stop",
GTK_RESPONSE_CANCEL);

if (dialog->name == NULL
&& dialog->command == NULL
&& dialog->comment == NULL) {
gtk_window_set_title (GTK_WINDOW (dialog), _("Add Startup Program"));
gtk_dialog_add_button (GTK_DIALOG (dialog),
"gtk-add", GTK_RESPONSE_OK);
gsm_util_dialog_add_button (GTK_DIALOG (dialog),
_("_Add"), "list-add",
GTK_RESPONSE_OK);
} else {
gtk_window_set_title (GTK_WINDOW (dialog), _("Edit Startup Program"));
gtk_dialog_add_button (GTK_DIALOG (dialog),
"gtk-save", GTK_RESPONSE_OK);
gsm_util_dialog_add_button (GTK_DIALOG (dialog),
_("_Save"), "document-save",
GTK_RESPONSE_OK);
}

dialog->name_entry = GTK_WIDGET (gtk_builder_get_object (xml, CAPPLET_NAME_ENTRY_WIDGET_NAME));
@@ -33,6 +33,7 @@
#endif
#include "gsm-consolekit.h"
#include "mdm.h"
#include "gsm-util.h"

#define GSM_ICON_LOGOUT "system-log-out"
#define GSM_ICON_SHUTDOWN "system-shutdown"
@@ -447,9 +448,9 @@ gsm_get_dialog (GsmDialogLogoutType type,
GSM_LOGOUT_RESPONSE_SWITCH_USER);
}

gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
"gtk-cancel",
GTK_RESPONSE_CANCEL);
gsm_util_dialog_add_button (GTK_DIALOG (logout_dialog),
_("_Cancel"), "process-stop",
GTK_RESPONSE_CANCEL);

gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
_("_Log Out"),
@@ -480,9 +481,9 @@ gsm_get_dialog (GsmDialogLogoutType type,
GSM_LOGOUT_RESPONSE_REBOOT);
}

gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
"gtk-cancel",
GTK_RESPONSE_CANCEL);
gsm_util_dialog_add_button (GTK_DIALOG (logout_dialog),
_("_Cancel"), "process-stop",
GTK_RESPONSE_CANCEL);

if (gsm_logout_supports_shutdown (logout_dialog)) {
gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
@@ -688,3 +688,23 @@ gsm_util_setenv (const char *variable,
}
#endif
}

GtkWidget*
gsm_util_dialog_add_button (GtkDialog *dialog,
const gchar *button_text,
const gchar *icon_name,
gint response_id)
{
GtkWidget *button;

button = gtk_button_new_with_mnemonic (button_text);
gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON));

gtk_button_set_use_underline (GTK_BUTTON (button), TRUE);
gtk_style_context_add_class (gtk_widget_get_style_context (button), "text-button");
gtk_widget_set_can_default (button, TRUE);
gtk_widget_show (button);
gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, response_id);

return button;
}
@@ -21,6 +21,7 @@
#define __GSM_UTIL_H__

#include <glib.h>
#include <gtk/gtk.h>

#ifdef __cplusplus
extern "C" {
@@ -57,6 +58,11 @@ gboolean gsm_util_export_user_environment (GError **error);
void gsm_util_setenv (const char *variable,
const char *value);

GtkWidget* gsm_util_dialog_add_button (GtkDialog *dialog,
const gchar *button_text,
const gchar *icon_name,
gint response_id);

#ifdef __cplusplus
}
#endif

0 comments on commit 7cd2ccc

Please sign in to comment.
You can’t perform that action at this time.