diff --git a/gtk/compat.c b/gtk/compat.c index 3248254fd..f403e367f 100644 --- a/gtk/compat.c +++ b/gtk/compat.c @@ -483,3 +483,13 @@ GtkWidget *nsgtk_button_new_from_stock(const gchar *stock_id) return nsgtk_button_new_from_stock(stock_id); #endif } + +/* exported interface documented in gtk/compat.h */ +gboolean nsgtk_stock_lookup(const gchar *stock_id, GtkStockItem *item) +{ +#if GTK_CHECK_VERSION(3,10,0) + return false; +#else + return gtk_stock_lookup(stock_id, item); +#endif +} diff --git a/gtk/compat.h b/gtk/compat.h index 42deab2ac..0b5e02e66 100644 --- a/gtk/compat.h +++ b/gtk/compat.h @@ -148,6 +148,17 @@ GtkWidget *nsgtk_image_new_from_stock(const gchar *stock_id, GtkIconSize size); */ GtkWidget *nsgtk_button_new_from_stock(const gchar *stock_id); +/** + + * Fills item with the registered values for stock_id. + * + * Compatability interface for original deprecated in GTK 3.10 + * + * \param stock_id the name of the stock item + * \return TRUE if stock_id was known. + */ +gboolean nsgtk_stock_lookup(const gchar *stock_id, GtkStockItem *item); + GtkWidget *nsgtk_entry_new(void); void nsgtk_entry_set_icon_from_pixbuf(GtkWidget *entry, GtkEntryIconPosition icon_pos, GdkPixbuf *pixbuf); diff --git a/gtk/toolbar.c b/gtk/toolbar.c index 132ab2d7d..dd542d7fa 100644 --- a/gtk/toolbar.c +++ b/gtk/toolbar.c @@ -684,19 +684,23 @@ GtkWidget *nsgtk_toolbar_make_widget(struct nsgtk_scaffolding *g, switch(i) { /* gtk_tool_button_new() accepts NULL args */ -#define MAKE_STOCKBUTTON(p, q) case p##_BUTTON: {\ - GtkStockItem item;\ - char *label = NULL;\ - gtk_stock_lookup(q, &item);\ - if (item.label != NULL)\ - label = remove_underscores(item.label, false);\ - GtkWidget *w = GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(\ - theme->image[p##_BUTTON]), label));\ - if (label != NULL) {\ - free(label);\ - label = NULL;\ - }\ - return w;\ +#define MAKE_STOCKBUTTON(p, q) \ + case p##_BUTTON: { \ + GtkStockItem item; \ + GtkWidget *w; \ + if (nsgtk_stock_lookup(q, &item) && \ + (item.label != NULL)) { \ + char *label = NULL; \ + w = GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET( \ + theme->image[p##_BUTTON]), label)); \ + label = remove_underscores(item.label, false); \ + free(label); \ + label = NULL; \ + } else { \ + w = GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET( \ + theme->image[p##_BUTTON]), q)); \ + } \ + return w; \ } MAKE_STOCKBUTTON(HOME, NSGTK_STOCK_HOME)