diff --git a/INSTALL b/INSTALL index 9eb4519c..14d2129a 100644 --- a/INSTALL +++ b/INSTALL @@ -51,6 +51,12 @@ If you are interested in HTTP communication, try this: Where '2' can be a level between 0 and 3. +If you are interested in (non-) touchscreen behaviour, try this: + +'MIDORI_TOUCHSCREEN=1 _build_/default/midori/midori', or + +'MIDORI_TOUCHSCREEN=0 _build_/default/midori/midori' + For further information a tutorial for gdb and reading up on how you can install debugging symbols for libraries used by Midori are recommended. diff --git a/katze/katze-scrolled.c b/katze/katze-scrolled.c index 49239250..e059551e 100644 --- a/katze/katze-scrolled.c +++ b/katze/katze-scrolled.c @@ -16,6 +16,7 @@ #endif #include "katze-scrolled.h" +#include "katze-utils.h" #define DEFAULT_INTERVAL 50 #define DEFAULT_DECELERATION 0.7 @@ -819,14 +820,13 @@ katze_scrolled_realize (GtkWidget* widget) KatzeScrolled* scrolled = KATZE_SCROLLED (widget); KatzeScrolledPrivate* priv = scrolled->priv; gboolean drag_scrolling; - GtkSettings* settings = gtk_widget_get_settings (widget); GtkPolicyType policy; GdkWindowAttr attr; GdkColor color; (*GTK_WIDGET_CLASS (katze_scrolled_parent_class)->realize) (widget); - g_object_get (settings, "gtk-touchscreen-mode", &drag_scrolling, NULL); + drag_scrolling = katze_widget_has_touchscreen_mode (widget); policy = drag_scrolling ? GTK_POLICY_NEVER : GTK_POLICY_AUTOMATIC; g_object_set (scrolled, "drag-scrolling", drag_scrolling, "hscrollbar-policy", policy, "vscrollbar-policy", policy, NULL); @@ -888,7 +888,6 @@ katze_scrolled_class_init (KatzeScrolledClass* class) GtkWidgetClass* widget_class; GtkContainerClass* container_class; GParamFlags flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT; - GtkSettings* gtk_settings; gobject_class = G_OBJECT_CLASS (class); widget_class = GTK_WIDGET_CLASS (class); @@ -944,13 +943,8 @@ katze_scrolled_class_init (KatzeScrolledClass* class) /* Usually touchscreen mode is either always set or it isn't, so it should be a safe optimization to not setup events if not needed. */ - if ((gtk_settings = gtk_settings_get_default ())) - { - gboolean touchscreen; - g_object_get (gtk_settings, "gtk-touchscreen-mode", &touchscreen, NULL); - if (touchscreen) - katze_scrolled_event_handler_append (katze_scrolled_event_handler, NULL); - } + if (katze_widget_has_touchscreen_mode (NULL)) + katze_scrolled_event_handler_append (katze_scrolled_event_handler, NULL); g_type_class_add_private (class, sizeof (KatzeScrolledPrivate)); } diff --git a/katze/katze-utils.c b/katze/katze-utils.c index 76199595..0a88dfdf 100644 --- a/katze/katze-utils.c +++ b/katze/katze-utils.c @@ -1110,3 +1110,36 @@ katze_mkdir_with_parents (const gchar* pathname, return 0; } + +/** + * katze_widget_has_touchscreen_mode: + * @widget: a #GtkWidget, or %NULL + * + * Determines whether @widget should operate in touchscreen + * mode, as determined by GtkSettings or the environment + * variable MIDORI_TOUCHSCREEN. + * + * If @widget is %NULL, the default screen will be used. + * + * Returns: %TRUE if touchscreen mode should be used + * + * Since: 0.2.1 + */ +gboolean +katze_widget_has_touchscreen_mode (GtkWidget* widget) +{ + const gchar* touchscreen = g_getenv ("MIDORI_TOUCHSCREEN"); + if (touchscreen && touchscreen[0] == '1') + return TRUE; + else if (touchscreen && touchscreen[0] == '0') + return FALSE; + else + { + GdkScreen* screen = widget && gtk_widget_has_screen (widget) + ? gtk_widget_get_screen (widget) : gdk_screen_get_default (); + GtkSettings* gtk_settings = gtk_settings_get_for_screen (screen); + gboolean enabled; + g_object_get (gtk_settings, "gtk-touchscreen-mode", &enabled, NULL); + return enabled; + } +} diff --git a/katze/katze-utils.h b/katze/katze-utils.h index 8e675207..3b226ee8 100644 --- a/katze/katze-utils.h +++ b/katze/katze-utils.h @@ -144,6 +144,9 @@ int katze_mkdir_with_parents (const gchar* pathname, int mode); +gboolean +katze_widget_has_touchscreen_mode (GtkWidget* widget); + G_END_DECLS #endif /* __KATZE_UTILS_H__ */ diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c index bbeed4c9..0970a82e 100644 --- a/midori/midori-preferences.c +++ b/midori/midori-preferences.c @@ -257,9 +257,6 @@ midori_preferences_set_settings (MidoriPreferences* preferences, GtkWidget* header; GtkWindow* parent; const gchar* icon_name; - #if WEBKIT_CHECK_VERSION (1, 1, 15) || HAVE_HILDON - GtkSettings* gtk_settings; - #endif KatzePreferences* _preferences; GtkWidget* label; GtkWidget* button; @@ -281,10 +278,6 @@ midori_preferences_set_settings (MidoriPreferences* preferences, header, FALSE, FALSE, 0); gtk_widget_show_all (header); } - #if WEBKIT_CHECK_VERSION (1, 1, 15) || HAVE_HILDON - gtk_settings = parent ? - gtk_widget_get_settings (GTK_WIDGET (parent)) : gtk_settings_get_default (); - #endif _preferences = KATZE_PREFERENCES (preferences); #define PAGE_NEW(__icon, __label) \ @@ -383,7 +376,8 @@ midori_preferences_set_settings (MidoriPreferences* preferences, INDENTED_ADD (button); #endif #if WEBKIT_CHECK_VERSION (1, 1, 15) || HAVE_HILDON - if (katze_object_get_boolean (gtk_settings, "gtk-touchscreen-mode")) + if (katze_widget_has_touchscreen_mode (parent ? + GTK_WIDGET (parent) : GTK_WIDGET (preferences))) button = katze_property_proxy (settings, "kinetic-scrolling", NULL); else {