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.
#endif
#include "katze-scrolled.h"
+#include "katze-utils.h"
#define DEFAULT_INTERVAL 50
#define DEFAULT_DECELERATION 0.7
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);
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);
/* 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));
}
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;
+ }
+}
katze_mkdir_with_parents (const gchar* pathname,
int mode);
+gboolean
+katze_widget_has_touchscreen_mode (GtkWidget* widget);
+
G_END_DECLS
#endif /* __KATZE_UTILS_H__ */
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;
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) \
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
{