forked from AuroraMiddleware/gtk
Rename GtkEntry icon-related signals
svn path=/trunk/; revision=22023
This commit is contained in:
parent
b7ef9c53f7
commit
e31eb99c9d
@ -1,3 +1,12 @@
|
||||
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
|
||||
|
@ -77,10 +77,10 @@ stop_search (GtkButton *button,
|
||||
}
|
||||
|
||||
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,
|
||||
@ -223,8 +223,8 @@ do_search_entry (GtkWidget *do_widget)
|
||||
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",
|
||||
|
@ -1,3 +1,10 @@
|
||||
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:
|
||||
|
@ -24,6 +24,58 @@ gtk_entry_set_icon_from_stock (entry, GTK_ICON_ENTRY_PRIMARY, GTK_STOCK_NEW);
|
||||
</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().
|
||||
|
@ -34,7 +34,7 @@ icons can be activatable by clicking, can be set up as drag source and
|
||||
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.
|
||||
@ -737,11 +737,11 @@ The #GtkEntry-struct struct contains only private data.
|
||||
|
||||
<!-- ##### 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>
|
||||
|
@ -172,8 +172,8 @@ enum {
|
||||
COPY_CLIPBOARD,
|
||||
PASTE_CLIPBOARD,
|
||||
TOGGLE_OVERWRITE,
|
||||
ICON_PRESSED,
|
||||
ICON_RELEASED,
|
||||
ICON_PRESS,
|
||||
ICON_RELEASE,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
@ -1001,7 +1001,7 @@ gtk_entry_class_init (GtkEntryClass *class)
|
||||
*
|
||||
* 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
|
||||
@ -1022,7 +1022,7 @@ gtk_entry_class_init (GtkEntryClass *class)
|
||||
*
|
||||
* 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
|
||||
@ -1045,7 +1045,7 @@ gtk_entry_class_init (GtkEntryClass *class)
|
||||
* 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
|
||||
@ -1067,7 +1067,7 @@ gtk_entry_class_init (GtkEntryClass *class)
|
||||
* 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
|
||||
@ -1335,18 +1335,18 @@ gtk_entry_class_init (GtkEntryClass *class)
|
||||
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,
|
||||
@ -1354,21 +1354,21 @@ gtk_entry_class_init (GtkEntryClass *class)
|
||||
_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,
|
||||
@ -1376,7 +1376,7 @@ gtk_entry_class_init (GtkEntryClass *class)
|
||||
_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);
|
||||
|
||||
|
||||
/*
|
||||
@ -3239,7 +3239,7 @@ gtk_entry_button_press (GtkWidget *widget,
|
||||
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;
|
||||
}
|
||||
@ -3427,7 +3427,7 @@ gtk_entry_button_release (GtkWidget *widget,
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -40,6 +40,20 @@ clear_pressed (GtkEntry *entry, gint icon, GdkEvent *event, gpointer data)
|
||||
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,
|
||||
@ -154,6 +168,8 @@ main (int argc, char **argv)
|
||||
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);
|
||||
@ -184,7 +200,7 @@ main (int argc, char **argv)
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user