summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2015-04-10 00:06:48 +0100
committerVincent Sanders <vince@kyllikki.org>2015-04-10 00:06:48 +0100
commit50f68b11a4983341bd94f0946e2f05f1d89ca1c8 (patch)
treec11c14450f4c0160ee9d3c4e0599894318495134 /gtk
parent23ae8ccf110f94019c745ebc4959c06b842a626d (diff)
downloadnetsurf-50f68b11a4983341bd94f0946e2f05f1d89ca1c8.tar.gz
netsurf-50f68b11a4983341bd94f0946e2f05f1d89ca1c8.tar.bz2
fixup default toolbar button creation for depricated GTK 3 operations
Diffstat (limited to 'gtk')
-rw-r--r--gtk/compat.c10
-rw-r--r--gtk/compat.h11
-rw-r--r--gtk/toolbar.c30
3 files changed, 38 insertions, 13 deletions
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)