diff options
Diffstat (limited to 'frontends/gtk/compat.c')
-rw-r--r-- | frontends/gtk/compat.c | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/frontends/gtk/compat.c b/frontends/gtk/compat.c index 4c5524b0e..bd3f46ee5 100644 --- a/frontends/gtk/compat.c +++ b/frontends/gtk/compat.c @@ -170,18 +170,18 @@ void nsgtk_entry_set_icon_from_pixbuf(GtkWidget *entry, /* exported interface documented in gtk/compat.h */ -void nsgtk_entry_set_icon_from_stock(GtkWidget *entry, - GtkEntryIconPosition icon_pos, - const gchar *id) +void nsgtk_entry_set_icon_from_icon_name(GtkWidget *entry, + GtkEntryIconPosition icon_pos, + const gchar *id) { #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) - gtk_entry_set_icon_from_stock(GTK_ENTRY(entry), icon_pos, id); + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(entry), icon_pos, id); #else - GtkImage *image = GTK_IMAGE(gtk_image_new_from_stock(id, - GTK_ICON_SIZE_LARGE_TOOLBAR)); + GtkImage *image; + image = GTK_IMAGE(gtk_image_new_from_stock(id, GTK_ICON_SIZE_LARGE_TOOLBAR)); if (image != NULL) { sexy_icon_entry_set_icon(SEXY_ICON_ENTRY(entry), @@ -216,6 +216,17 @@ GtkWidget *nsgtk_button_new_from_stock(const gchar *stock_id) } /* exported interface documented in gtk/compat.h */ +void nsgtk_button_set_focus_on_click(GtkButton *button, gboolean focus_on_click) +{ +#if GTK_CHECK_VERSION(3,20,0) + gtk_widget_set_focus_on_click(GTK_WIDGET(button), focus_on_click); +#else + gtk_button_set_focus_on_click(button, focus_on_click); +#endif +} + + +/* exported interface documented in gtk/compat.h */ gboolean nsgtk_stock_lookup(const gchar *stock_id, GtkStockItem *item) { #ifdef NSGTK_USE_ICON_NAME @@ -234,12 +245,17 @@ void nsgtk_widget_override_background_color(GtkWidget *widget, uint16_t b) { #if GTK_CHECK_VERSION(3,0,0) +#if GTK_CHECK_VERSION(3,16,0) + /* do nothing - deprecated - must use css styling */ + return; +#else GdkRGBA colour; colour.alpha = (double)a / 0xffff; colour.red = (double)r / 0xffff; colour.green = (double)g / 0xffff; colour.blue = (double)b / 0xffff; gtk_widget_override_background_color(widget, state, &colour); +#endif #else GdkColor colour; colour.pixel = a; @@ -403,15 +419,25 @@ GtkWidget *nsgtk_dialog_get_content_area(GtkDialog *dialog) #endif } +#if GTK_CHECK_VERSION(3,22,0) +#include "gtk/scaffolding.h" +#endif + gboolean nsgtk_show_uri(GdkScreen *screen, const gchar *uri, guint32 timestamp, GError **error) { #if GTK_CHECK_VERSION(2,14,0) +#if GTK_CHECK_VERSION(3,22,0) + GtkWindow *parent; + parent = nsgtk_scaffolding_window(nsgtk_current_scaffolding()); + return gtk_show_uri_on_window(parent, uri, timestamp,error); +#else return gtk_show_uri(screen, uri, timestamp, error); +#endif #else - return FALSE; /* FIXME */ + return FALSE; /** \todo add uri opening for before gtk 2.14 */ #endif } @@ -532,6 +558,17 @@ void nsgtk_image_menu_item_set_image(GtkWidget *image_menu_item, GtkWidget *imag } /* exported interface documented in gtk/compat.h */ +void nsgtk_menu_popup_at_pointer(GtkMenu *menu, const GdkEvent *trigger_event) +{ +#if GTK_CHECK_VERSION(3,22,0) + gtk_menu_popup_at_pointer(menu, trigger_event); +#else + gtk_menu_popup(menu, NULL, NULL, NULL, NULL, 0, + gtk_get_current_event_time()); +#endif +} + +/* exported interface documented in gtk/compat.h */ gboolean nsgtk_icon_size_lookup_for_settings(GtkSettings *settings, GtkIconSize size, gint *width, @@ -598,7 +635,9 @@ void nsgtk_widget_set_margins(GtkWidget *widget, gint hmargin, gint vmargin) gtk_widget_set_margin_top(widget, vmargin); gtk_widget_set_margin_bottom(widget, vmargin); #else - gtk_misc_set_padding(GTK_MISC(widget), hmargin, vmargin); + if (GTK_IS_MISC(widget)) { + gtk_misc_set_padding(GTK_MISC(widget), hmargin, vmargin); + } #endif } |