summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2015-04-11 00:28:32 +0100
committerVincent Sanders <vince@kyllikki.org>2015-04-11 00:28:32 +0100
commite193566de41d65e055db306b9ca28b35daa8bc43 (patch)
tree2264dd4e70e2479ae376bd199be881dd704370f2 /gtk
parent4f13cbd31c984957d17081ac6d59a62b04d57765 (diff)
downloadnetsurf-e193566de41d65e055db306b9ca28b35daa8bc43.tar.gz
netsurf-e193566de41d65e055db306b9ca28b35daa8bc43.tar.bz2
Improve the stock icon/icon name compatability logic to be explicit
Diffstat (limited to 'gtk')
-rw-r--r--gtk/compat.c49
-rw-r--r--gtk/compat.h13
-rw-r--r--gtk/scaffolding.c24
3 files changed, 51 insertions, 35 deletions
diff --git a/gtk/compat.c b/gtk/compat.c
index 7f6d061d8..14284fc57 100644
--- a/gtk/compat.c
+++ b/gtk/compat.c
@@ -168,11 +168,13 @@ void nsgtk_entry_set_icon_from_pixbuf(GtkWidget *entry,
#endif
}
+
+/* exported interface documented in gtk/compat.h */
void nsgtk_entry_set_icon_from_stock(GtkWidget *entry,
GtkEntryIconPosition icon_pos,
const gchar *id)
{
-#if GTK_CHECK_VERSION(3,10,0)
+#ifdef NSGTK_USE_ICON_NAME
gtk_entry_set_icon_from_icon_name(GTK_ENTRY(entry), icon_pos, id);
#else
#if GTK_CHECK_VERSION(2,16,0)
@@ -191,15 +193,39 @@ void nsgtk_entry_set_icon_from_stock(GtkWidget *entry,
#endif
}
+
+/* exported interface documented in gtk/compat.h */
GtkWidget *nsgtk_image_new_from_stock(const gchar *id, GtkIconSize size)
{
-#if GTK_CHECK_VERSION(3,10,0)
+#ifdef NSGTK_USE_ICON_NAME
return gtk_image_new_from_icon_name(id, size);
#else
return gtk_image_new_from_stock(id, size);
#endif
}
+
+/* exported interface documented in gtk/compat.h */
+GtkWidget *nsgtk_button_new_from_stock(const gchar *stock_id)
+{
+#ifdef NSGTK_USE_ICON_NAME
+ return gtk_button_new_with_label(stock_id);
+#else
+ return gtk_button_new_from_stock(stock_id);
+#endif
+}
+
+/* exported interface documented in gtk/compat.h */
+gboolean nsgtk_stock_lookup(const gchar *stock_id, GtkStockItem *item)
+{
+#ifdef NSGTK_USE_ICON_NAME
+ return FALSE;
+#else
+ return gtk_stock_lookup(stock_id, item);
+#endif
+}
+
+
void nsgtk_widget_override_background_color(GtkWidget *widget,
GtkStateFlags state,
uint16_t a,
@@ -465,25 +491,6 @@ GtkWidget *nsgtk_image_new_from_pixbuf_icon(GdkPixbuf *pixbuf, GtkIconSize size)
#endif
}
-/* exported interface documented in gtk/compat.h */
-GtkWidget *nsgtk_button_new_from_stock(const gchar *stock_id)
-{
-#if GTK_CHECK_VERSION(3,10,0)
- return gtk_button_new_with_label(stock_id);
-#else
- return gtk_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
-}
/* exported interface documented in gtk/compat.h */
void nsgtk_window_set_opacity(GtkWindow *window, gdouble opacity)
diff --git a/gtk/compat.h b/gtk/compat.h
index 15c30ab05..52d10f35e 100644
--- a/gtk/compat.h
+++ b/gtk/compat.h
@@ -29,8 +29,15 @@
/* gtk 3.10 depricated the use of stock names */
#if GTK_CHECK_VERSION(3,10,0)
+#define NSGTK_USE_ICON_NAME
+#else
+#undef NSGTK_USE_ICON_NAME
+#endif
+
+/* icon names instead of stock */
+#ifdef NSGTK_USE_ICON_NAME
#define NSGTK_STOCK_ADD "list-add"
-#define NSGTK_STOCK_CANCEL "gtk-cancel"
+#define NSGTK_STOCK_CANCEL "_Cancel"
#define NSGTK_STOCK_CLEAR "edit-clear"
#define NSGTK_STOCK_CLOSE "window-close"
#define NSGTK_STOCK_FIND "edit-find"
@@ -42,8 +49,8 @@
#define NSGTK_STOCK_SAVE "document-save"
#define NSGTK_STOCK_SAVE_AS "document-save-as"
#define NSGTK_STOCK_STOP "process-stop"
-#define NSGTK_STOCK_OK "gtk-ok"
-#define NSGTK_STOCK_OPEN "document-open"
+#define NSGTK_STOCK_OK "_OK"
+#define NSGTK_STOCK_OPEN "_Open"
#else
#define NSGTK_STOCK_ADD GTK_STOCK_ADD
#define NSGTK_STOCK_CANCEL GTK_STOCK_CANCEL
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index 650eee1cc..d7569f162 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -587,17 +587,23 @@ MULTIHANDLER(newtab)
MULTIHANDLER(openfile)
{
+ GtkWidget *dlgOpen;
+ gint response;
+
scaf_current = g;
- GtkWidget *dlgOpen = gtk_file_chooser_dialog_new("Open File",
- scaf_current->window, GTK_FILE_CHOOSER_ACTION_OPEN,
- NSGTK_STOCK_CANCEL, -6, NSGTK_STOCK_OPEN, -5, NULL);
+ dlgOpen = gtk_file_chooser_dialog_new("Open File",
+ scaf_current->window,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ NSGTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ NSGTK_STOCK_OPEN, GTK_RESPONSE_OK,
+ NULL, NULL);
- gint response = gtk_dialog_run(GTK_DIALOG(dlgOpen));
+ response = gtk_dialog_run(GTK_DIALOG(dlgOpen));
if (response == GTK_RESPONSE_OK) {
- gchar *filename = gtk_file_chooser_get_filename(
- GTK_FILE_CHOOSER(dlgOpen));
+ gchar *filename;
+ filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dlgOpen));
- nsgtk_openfile_open((const char *) filename);
+ nsgtk_openfile_open((const char *)filename);
g_free(filename);
}
@@ -2750,7 +2756,3 @@ void nsgtk_scaffolding_toolbar_size_allocate(GtkWidget *widget,
g->toolbarmem = alloc->x;
gtk_widget_size_allocate(widget, alloc);
}
-
-
-
-