Maemo GTK+ 2.10 Overview

Although the delta between Maemo GTK+ 2.10 and upstream has been greatly reduced, there's still some important functionality implemented as patches on top of modified GTK+. This document will serve as an overview of that functionality and as a little primer about the correct way of using it for Hildon application development.

Tap and Hold

Used to present the user a menu when she taps and holds (hence the name) the stylus or her finger long enough on a UI element. The function used to setup this is:

void gtk_tap_and_hold_setup (GtkWidget *widget, GtkWidget *menu, GtkCallback func, GtkWidgetTapAndHoldFlags flags);

GtkWidget *widget: the widget being setup.
GtkWidget *menu: menu to show when the functionality is activated (optional).
GtkCallback *func: if you want to position the menu in a different way than the GTK+ default you can pass this function to do so (optional).
GtkWidgetTapAndHoldFlags flags: deprecated, don't use.

Let's say we want to present the user a simple menu in a GtkButton:

(...)

static void
item_cb (GtkWidget *item, GtkWidget *menu)
{
/* Do your stuff here */
}

(...)

GtkWidget *button, *menu, *item;

/* Button */
button = gtk_button_new_with_label ("Tap and hold me");

/* Menu */
menu = gtk_menu_new ();
item = gtk_menu_item_new_with_label ("Item");
g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (item_cb), menu);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show_all (menu);

/* Connect */
gtk_tap_and_hold_setup (button, menu, NULL, 0);

(...)

It is possible to pass NULL as the menu parameter. No menu will be shown by default this way, but you'll still be able to connect to the "tap-and-hold" signal and execute arbitrary code there:

(...)

static void
tap_and_hold_cb (GtkWidget *widget, gpointer user_data)
{
/* Do your stuff here */
}

(...)

GtkWidget *button = gtk_button_new_with_label ("Tap and hold me");

g_signal_connect (G_OBJECT (button), "tap-and-hold", G_CALLBACK (tap_and_hold_cb), NULL);
gtk_tap_and_hold_setup (button, NULL, NULL, 0);

(...)

Finally, you can connect to the "tap-and-hold-query" signal to manually control this functionality. Return "TRUE" from the callback to stop the functionality from happening, "FALSE" otherwise. For example:

(...)

static gboolean
tap_and_hold_query_cb (GtkWidget *widget, GdkEvent *event)
{
gint moon_phase = get_moon_phase ();

if (moon_phase_is_propicious (moon_phase)) {
  return FALSE;
} else {
  return TRUE;
}
}

(...)

GtkWidget *button = gtk_button_new_with_label ("Tap and hold me");
g_signal_connect (G_OBJECT (button), "tap-and-hold-query", G_CALLBACK (tap_and_hold_query_cb), NULL);

/* Finish setup here... */

(...)

You can see the patch with the Tap and Hold functionality here: tap_and_hold.diff

Hildon Input Method

Insensitive Press

The original intention of the insensitive press signal was to let application developers show an informative banner when the user clicks on an insensitive widget. The usual idiom goes like this:

(...)

static void
insensitive_press_cb (GtkWidget *button, gpointer user_data)
{
hildon_banner_show_information (button, NULL, "Can't do anything now");
}

(...)

g_signal_connect (G_OBJECT (button), "insensitive-press", G_CALLBACK (insensitive_press), NULL);

(...)

This behaviour can be now implemented using the following API from the hildon library:

hildon_helper_set_insensitive_message (button, "Can't do anything now");

Other uses of the insensitive-press signal are *strongly* discouraged. The signal can be considered as deprecated and it's scheduled for removal in a future version of Maemo GTK+.

GtkMenu changes

GtkTreeView changes

GtkEntry changes

Attic/Maemo/Gtk210Overview (last edited 2013-11-23 01:26:52 by WilliamJonMcCann)