summaryrefslogtreecommitdiff
path: root/src/gtk-utils.c
diff options
context:
space:
mode:
authorrbuj <[email protected]>2019-09-12 13:19:22 +0200
committerZenWalker <[email protected]>2019-09-15 12:16:55 +0200
commit3f4c82587df3c7fde79ebb7e546d73321479760a (patch)
tree043676f1336ee64ed3a18bb606680058953154b2 /src/gtk-utils.c
parent6e2ab64994fd6ca44305b0eb37f7cf444abcab6d (diff)
downloadengrampa-3f4c82587df3c7fde79ebb7e546d73321479760a.tar.bz2
engrampa-3f4c82587df3c7fde79ebb7e546d73321479760a.tar.xz
remove warnings: ‘gtk_image_new_from_stock’ is deprecated
gtk-utils.c:171:3: warning: ‘gtk_image_new_from_stock’ is deprecated: Use 'gtk_image_new_from_icon_name' instead [-Wdeprecated-declarations] 171 | image = gtk_image_new_from_stock (text, GTK_ICON_SIZE_BUTTON); | ^~~~~ gtk-utils.c:173:3: warning: ‘gtk_image_new_from_stock’ is deprecated: Use 'gtk_image_new_from_icon_name' instead [-Wdeprecated-declarations] 173 | image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON); | ^~~~~
Diffstat (limited to 'src/gtk-utils.c')
-rw-r--r--src/gtk-utils.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/src/gtk-utils.c b/src/gtk-utils.c
index 890cbc7..7a6ce1d 100644
--- a/src/gtk-utils.c
+++ b/src/gtk-utils.c
@@ -150,30 +150,19 @@ _gtk_message_dialog_new (GtkWindow *parent,
static GtkWidget *
-create_button (const char *stock_id,
+create_button (const char *icon_name,
const char *text)
{
+ GtkIconTheme *icon_theme;
GtkWidget *button;
- GtkWidget *image;
- const char *label_text;
- gboolean text_is_stock;
- GtkStockItem stock_item;
-
- if (gtk_stock_lookup (text, &stock_item)) {
- label_text = stock_item.label;
- text_is_stock = TRUE;
- } else {
- label_text = text;
- text_is_stock = FALSE;
- }
-
- if (text_is_stock)
- image = gtk_image_new_from_stock (text, GTK_ICON_SIZE_BUTTON);
- else
- image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
- button = gtk_button_new_with_mnemonic (label_text);
- gtk_button_set_image (GTK_BUTTON (button), image);
+ button = gtk_button_new_with_mnemonic (text);
+ icon_theme = gtk_icon_theme_get_default ();
+ if (gtk_icon_theme_has_icon (icon_theme, icon_name)) {
+ GtkWidget *image;
+ image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON);
+ gtk_button_set_image (GTK_BUTTON (button), image);
+ }
gtk_widget_set_can_default (button, TRUE);
gtk_widget_show (button);
@@ -244,7 +233,7 @@ _gtk_request_dialog_run (GtkWindow *parent,
/* Add buttons */
- button = create_button ("gtk-cancel", no_button_text);
+ button = create_button ("process-stop", no_button_text);
gtk_dialog_add_action_widget (GTK_DIALOG (dialog),
button,
GTK_RESPONSE_CANCEL);