+2008-12-30 Matthias Clasen <mclasen@redhat.com>
+
+ * gtk/gtkentry.c: Rename the icon signals to ::icon-press and
+ ::icon-release to avoid clashes with the existing SexyIconEntry
+ signals. Also annotate the GdkEvent parameters as static-scope.
+
+ * tests/testentryicons.c: Adapt
+ * demos/gtk-demo/search-entry.c: Adapt
+
2008-12-30 Matthias Clasen <mclasen@redhat.com>
Bug 565846 – "va_end(args);" should be added into gtk_tree_store_new
}
static void
-icon_pressed_cb (GtkEntry *entry,
- gint position,
- GdkEventButton *event,
- gpointer data)
+icon_press_cb (GtkEntry *entry,
+ gint position,
+ GdkEventButton *event,
+ gpointer data)
{
if (position == GTK_ENTRY_ICON_PRIMARY)
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
GTK_STOCK_CLEAR);
text_changed_cb (GTK_ENTRY (entry), NULL, find_button);
- g_signal_connect (entry, "icon-pressed",
- G_CALLBACK (icon_pressed_cb), NULL);
+ g_signal_connect (entry, "icon-press",
+ G_CALLBACK (icon_press_cb), NULL);
g_signal_connect (entry, "notify::text",
G_CALLBACK (text_changed_cb), find_button);
g_signal_connect (entry, "activate",
+2008-12-31 Matthias Clasen <mclasen@redhat.com>
+
+ * gtk/migrating-GtkEntry-icons.sgml: Add a section about
+ signals.
+
+ * gtk/tmpl/gtkentry.sgml: Update to new signal names
+
2008-12-30 Matthias Clasen <mclasen@redhat.com>
* gtk/tmpl/gtkorientable.sgml:
</programlisting></informalexample>
</para>
+ <para>
+ The signals SexyIconEntry::icon-pressed and SexyIconEntry::icon-released
+ have been renamed to #GtkEntry::icon-press and #GtkEntry::icon-release
+ to avoid problems due to signal name clashes. Also, the signature of the
+ signals has changed from
+<informalexample><programlisting>
+void (*icon_pressed) (SexyIconEntry *entry,
+ SexyIconEntryPosition icon_pos,
+ int button)
+</programlisting></informalexample>
+to
+<informalexample><programlisting>
+void (*icon_press) (GtkEntry *entry,
+ GtkEntryIconPosition icon_pos,
+ GdkEventButton *event)
+</programlisting></informalexample>
+ The new signature has the advantage that the signal handler can use
+ the timestamp of the event, e.g. for passing it to gtk_menu_popup().
+ When adapting an existing signal handler to the new signature, you
+ should note that the button number is easily available as @event->button,
+ as shown in the following example:
+<informalexample><programlisting>
+static void
+icon_pressed_cb (SexyIconEntry *entry,
+ SexyIconEntryPosition position,
+ int button,
+ gpointer data)
+{
+ GtkMenu *menu = data;
+
+ if (position == SEXY_ICON_ENTRY_PRIMARY)
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
+ button, GDK_CURRENT_TIME);
+}
+</programlisting></informalexample>
+ can be ported as:
+<informalexample><programlisting>
+static void
+icon_press_cb (GtkEntry *entry,
+ GtkEntryIconPosition position,
+ GdkEventButton *event,
+ gpointer data)
+{
+ GtkMenu *menu = data;
+
+ if (position == GTK_ENTRY_ICON_PRIMARY)
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
+ event->button, event->time);
+}
+</programlisting></informalexample>
+ </para>
+
<para>
Another difference is that SexyIconEntry offers manual control of
the icon prelighting, via sexy_icon_entry_set_icon_highlight().
can have tooltips. To add an icon, use gtk_entry_set_icon_from_gicon() or
one of the various other functions that set an icon from a stock id, an
icon name or a pixbuf. To trigger an action when the user clicks an icon,
-connect to the #GtkEntry::icon-pressed signal. To allow DND operations
+connect to the #GtkEntry::icon-press signal. To allow DND operations
from an icon, use gtk_entry_set_icon_drag_source(). To set a tooltip on
an icon, use gtk_entry_set_icon_tooltip_text() or the corresponding function
for markup.
<!-- ##### ENUM GtkEntryIconPosition ##### -->
<para>
-
+Specifies the side of the entry at which an icon is placed.
</para>
-@GTK_ENTRY_ICON_PRIMARY:
-@GTK_ENTRY_ICON_SECONDARY:
+@GTK_ENTRY_ICON_PRIMARY: At the beginning of the entry (depending on the text direction).
+@GTK_ENTRY_ICON_SECONDARY: At the end of the entry (depending on the text direction).
<!-- ##### FUNCTION gtk_entry_set_icon_from_pixbuf ##### -->
<para>
COPY_CLIPBOARD,
PASTE_CLIPBOARD,
TOGGLE_OVERWRITE,
- ICON_PRESSED,
- ICON_RELEASED,
+ ICON_PRESS,
+ ICON_RELEASE,
LAST_SIGNAL
};
*
* Whether the primary icon is activatable.
*
- * GTK+ emits the #GtkEntry::icon-pressed and #GtkEntry::icon-released
+ * GTK+ emits the #GtkEntry::icon-press and #GtkEntry::icon-release
* signals only on sensitive, activatable icons.
*
* Sensitive, but non-activatable icons can be used for purely
*
* Whether the secondary icon is activatable.
*
- * GTK+ emits the #GtkEntry::icon-pressed and #GtkEntry::icon-released
+ * GTK+ emits the #GtkEntry::icon-press and #GtkEntry::icon-release
* signals only on sensitive, activatable icons.
*
* Sensitive, but non-activatable icons can be used for purely
* Whether the primary icon is sensitive.
*
* An insensitive icon appears grayed out. GTK+ does not emit the
- * #GtkEntry::icon-pressed and #GtkEntry::icon-released signals and
+ * #GtkEntry::icon-press and #GtkEntry::icon-release signals and
* does not allow DND from insensitive icons.
*
* An icon should be set insensitive if the action that would trigger
* Whether the secondary icon is sensitive.
*
* An insensitive icon appears grayed out. GTK+ does not emit the
- * #GtkEntry::icon-pressed and #GtkEntry::icon-released signals and
+ * #GtkEntry::icon-press and #GtkEntry::icon-release signals and
* does not allow DND from insensitive icons.
*
* An icon should be set insensitive if the action that would trigger
G_TYPE_NONE, 0);
/**
- * GtkEntry::icon-pressed:
+ * GtkEntry::icon-press:
* @entry: The entry on which the signal is emitted
* @icon_pos: The position of the clicked icon
* @event: the button press event
*
- * The ::icon-pressed signal is emitted when an activatable icon
+ * The ::icon-press signal is emitted when an activatable icon
* is clicked.
*
* Since: 2.16
*/
- signals[ICON_PRESSED] =
- g_signal_new (I_("icon-pressed"),
+ signals[ICON_PRESS] =
+ g_signal_new (I_("icon-press"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
0,
_gtk_marshal_VOID__ENUM_BOXED,
G_TYPE_NONE, 2,
GTK_TYPE_ENTRY_ICON_POSITION,
- GDK_TYPE_EVENT);
+ GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
/**
- * GtkEntry::icon-released:
+ * GtkEntry::icon-release:
* @entry: The entry on which the signal is emitted
* @icon_pos: The position of the clicked icon
* @event: the button release event
*
- * The ::icon-released signal is emitted on the button release from a
+ * The ::icon-release signal is emitted on the button release from a
* mouse click over an activatable icon.
*
* Since: 2.16
*/
- signals[ICON_RELEASED] =
- g_signal_new (I_("icon-released"),
+ signals[ICON_RELEASE] =
+ g_signal_new (I_("icon-release"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
0,
_gtk_marshal_VOID__ENUM_BOXED,
G_TYPE_NONE, 2,
GTK_TYPE_ENTRY_ICON_POSITION,
- GDK_TYPE_EVENT);
+ GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
/*
icon_info->pressed = TRUE;
if (!icon_info->nonactivatable)
- g_signal_emit (entry, signals[ICON_PRESSED], 0, i, event);
+ g_signal_emit (entry, signals[ICON_PRESS], 0, i, event);
return TRUE;
}
}
if (!icon_info->nonactivatable)
- g_signal_emit (entry, signals[ICON_RELEASED], 0, i, event);
+ g_signal_emit (entry, signals[ICON_RELEASE], 0, i, event);
return TRUE;
}
gtk_entry_set_text (entry, "");
}
+static void
+drag_begin_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ gpointer user_data)
+{
+ gint pos;
+
+ pos = gtk_entry_get_current_icon_drag_source (GTK_ENTRY (widget));
+ if (pos != -1)
+ gtk_drag_set_icon_stock (context, GTK_STOCK_INFO, 2, 2);
+
+ g_print ("drag begin %d\n", pos);
+}
+
static void
drag_data_get_cb (GtkWidget *widget,
GdkDragContext *context,
gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
GTK_ENTRY_ICON_PRIMARY,
tlist, GDK_ACTION_COPY);
+ g_signal_connect_after (entry, "drag-begin",
+ G_CALLBACK (drag_begin_cb), NULL);
g_signal_connect (entry, "drag-data-get",
G_CALLBACK (drag_data_get_cb), NULL);
gtk_target_list_unref (tlist);
GTK_ENTRY_ICON_SECONDARY,
GTK_STOCK_CLEAR);
- g_signal_connect (entry, "icon-pressed", G_CALLBACK (clear_pressed), NULL);
+ g_signal_connect (entry, "icon-press", G_CALLBACK (clear_pressed), NULL);
button = gtk_button_new_with_label ("Properties");
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 2, 3,