Mercurial > hg > forks > geeqie
changeset 1959:058331ac7c2d
Add compat functions to handle deprecated gtk stuff.
void setWidgetHasFocus(GtkWidget *widget, gboolean hasFocus);
void setWidgetCanFocus(GtkWidget *widget, gboolean canFocus);
void setWidgetCanDefault(GtkWidget *widget, gboolean canDefault);
author | Laurent Monin <zas@norz.org> |
---|---|
date | Sat, 22 Jan 2011 11:19:45 +0100 |
parents | f91e7788a94c |
children | 4845663f466e |
files | src/compat.c src/compat.h |
diffstat | 2 files changed, 41 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/compat.c Sun Jan 16 18:21:54 2011 +0100 +++ b/src/compat.c Sat Jan 22 11:19:45 2011 +0100 @@ -55,4 +55,41 @@ #endif } + +void setWidgetHasFocus(GtkWidget *widget, gboolean hasFocus) +{ + g_object_set(widget, "has-focus", hasFocus, NULL); + + // These functions are deprecated in GTK+ 2.22, yet theme engines still look + // at these flags when determining if a widget has focus, so we must use them. + if (hasFocus) + (GTK_OBJECT (widget)->flags) |= GTK_HAS_FOCUS; + else + (GTK_OBJECT (widget)->flags) &= ~(GTK_HAS_FOCUS); +} + +void setWidgetCanFocus(GtkWidget *widget, gboolean canFocus) +{ +#if GTK_CHECK_VERSION(2,18,0) + gtk_widget_set_can_focus(widget, canFocus); +#else + if (canFocus) + GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_FOCUS); + else + GTK_WIDGET_UNSET_FLAGS(widget, GTK_CAN_FOCUS); +#endif +} + +void setWidgetCanDefault(GtkWidget *widget, gboolean canDefault) +{ +#if GTK_CHECK_VERSION(2,18,0) + gtk_widget_set_can_default(widget, canDefault); +#else + if (canDefault) + GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_DEFAULT); + else + GTK_WIDGET_UNSET_FLAGS(widget, GTK_CAN_DEFAULT); +#endif +} + /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
--- a/src/compat.h Sun Jan 16 18:21:54 2011 +0100 +++ b/src/compat.h Sat Jan 22 11:19:45 2011 +0100 @@ -15,6 +15,10 @@ void radio_action_set_current_value(GtkRadioAction *action, gint current_value); GList* hash_table_get_keys(GHashTable *hash_table); +void setWidgetHasFocus(GtkWidget *widget, gboolean hasFocus); +void setWidgetCanFocus(GtkWidget *widget, gboolean canFocus); +void setWidgetCanDefault(GtkWidget *widget, gboolean canDefault); + #if !GTK_CHECK_VERSION(2,12,0) #define gtk_widget_set_tooltip_text(widget, text) /* ignored */