mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-02 08:50:28 +00:00
Merge branch 'otte/for-master' into 'master'
Otte/for master See merge request GNOME/gtk!1136
This commit is contained in:
commit
342d88a1dc
@ -5249,6 +5249,7 @@ gtk_bindings_activate_event
|
||||
gtk_binding_set_activate
|
||||
gtk_binding_entry_add_action
|
||||
gtk_binding_entry_add_action_variant
|
||||
GtkBindingCallback
|
||||
gtk_binding_entry_add_callback
|
||||
gtk_binding_entry_add_signal
|
||||
gtk_binding_entry_add_signal_from_string
|
||||
|
@ -67,6 +67,9 @@ typedef enum {
|
||||
typedef struct _GtkBindingEntry GtkBindingEntry;
|
||||
typedef struct _GtkBindingSignal GtkBindingSignal;
|
||||
typedef struct _GtkBindingArg GtkBindingArg;
|
||||
typedef struct _GtkBindingSignalSignal GtkBindingSignalSignal;
|
||||
typedef struct _GtkBindingSignalAction GtkBindingSignalAction;
|
||||
typedef struct _GtkBindingSignalCallback GtkBindingSignalCallback;
|
||||
|
||||
/**
|
||||
* GtkBindingSet:
|
||||
@ -148,9 +151,7 @@ typedef enum
|
||||
/**
|
||||
* GtkBindingSignal:
|
||||
* @next: implementation detail
|
||||
* @signal_name: the action signal to be emitted
|
||||
* @n_args: number of arguments specified for the signal
|
||||
* @args: (array length=n_args): the arguments specified for the signal
|
||||
* @action_type: Actual type of the action
|
||||
*
|
||||
* A GtkBindingSignal stores the necessary information to
|
||||
* activate a widget in response to a key press via a signal
|
||||
@ -159,20 +160,31 @@ typedef enum
|
||||
struct _GtkBindingSignal
|
||||
{
|
||||
GtkBindingSignal *next;
|
||||
gchar *signal_name;
|
||||
GtkBindingActionType action_type;
|
||||
union {
|
||||
struct {
|
||||
guint n_args;
|
||||
GtkBindingArg *args;
|
||||
};
|
||||
GVariant *variant;
|
||||
struct {
|
||||
GtkCallback callback;
|
||||
gpointer user_data;
|
||||
GDestroyNotify user_destroy;
|
||||
} callback;
|
||||
};
|
||||
};
|
||||
|
||||
struct _GtkBindingSignalSignal
|
||||
{
|
||||
GtkBindingSignal parent;
|
||||
const gchar *signal_name;
|
||||
guint n_args;
|
||||
GtkBindingArg *args;
|
||||
};
|
||||
|
||||
struct _GtkBindingSignalAction
|
||||
{
|
||||
GtkBindingSignal parent;
|
||||
const gchar *action_name;
|
||||
GVariant *variant;
|
||||
};
|
||||
|
||||
struct _GtkBindingSignalCallback
|
||||
{
|
||||
GtkBindingSignal parent;
|
||||
GtkBindingCallback callback;
|
||||
GVariant *args;
|
||||
gpointer user_data;
|
||||
GDestroyNotify user_destroy;
|
||||
};
|
||||
|
||||
/* --- variables --- */
|
||||
@ -189,77 +201,90 @@ static GtkBindingSignal*
|
||||
binding_signal_new_signal (const gchar *signal_name,
|
||||
guint n_args)
|
||||
{
|
||||
GtkBindingSignal *signal;
|
||||
GtkBindingSignalSignal *signal;
|
||||
|
||||
signal = (GtkBindingSignal *) g_slice_alloc0 (sizeof (GtkBindingSignal) + n_args * sizeof (GtkBindingArg));
|
||||
signal->next = NULL;
|
||||
signal->action_type = GTK_BINDING_SIGNAL;
|
||||
signal->signal_name = (gchar *)g_intern_string (signal_name);
|
||||
signal = (GtkBindingSignalSignal *) g_slice_alloc0 (sizeof (GtkBindingSignalSignal) + n_args * sizeof (GtkBindingArg));
|
||||
signal->parent.next = NULL;
|
||||
signal->parent.action_type = GTK_BINDING_SIGNAL;
|
||||
signal->signal_name = g_intern_string (signal_name);
|
||||
signal->n_args = n_args;
|
||||
signal->args = (GtkBindingArg *)(signal + 1);
|
||||
|
||||
return signal;
|
||||
return &signal->parent;
|
||||
}
|
||||
|
||||
static GtkBindingSignal*
|
||||
binding_signal_new_action (const gchar *signal_name,
|
||||
binding_signal_new_action (const gchar *action_name,
|
||||
GVariant *variant)
|
||||
{
|
||||
GtkBindingSignal *signal;
|
||||
GtkBindingSignalAction *signal;
|
||||
|
||||
signal = g_slice_new0 (GtkBindingSignal);
|
||||
signal->next = NULL;
|
||||
signal->action_type = GTK_BINDING_ACTION;
|
||||
signal->signal_name = (gchar *)g_intern_string (signal_name);
|
||||
signal = g_slice_new0 (GtkBindingSignalAction);
|
||||
signal->parent.next = NULL;
|
||||
signal->parent.action_type = GTK_BINDING_ACTION;
|
||||
signal->action_name = g_intern_string (action_name);
|
||||
signal->variant = variant;
|
||||
if (variant)
|
||||
g_variant_ref_sink (variant);
|
||||
|
||||
return signal;
|
||||
return &signal->parent;
|
||||
}
|
||||
|
||||
static GtkBindingSignal *
|
||||
binding_signal_new_callback (GtkCallback callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy)
|
||||
binding_signal_new_callback (GtkBindingCallback callback,
|
||||
GVariant *args,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy)
|
||||
{
|
||||
GtkBindingSignal *signal;
|
||||
GtkBindingSignalCallback *signal;
|
||||
|
||||
signal = g_slice_new0 (GtkBindingSignal);
|
||||
signal->next = NULL;
|
||||
signal->action_type = GTK_BINDING_CALLBACK;
|
||||
signal->callback.callback = callback;
|
||||
signal->callback.user_data = user_data;
|
||||
signal->callback.user_destroy = user_destroy;
|
||||
signal = g_slice_new0 (GtkBindingSignalCallback);
|
||||
signal->parent.next = NULL;
|
||||
signal->parent.action_type = GTK_BINDING_CALLBACK;
|
||||
signal->callback = callback;
|
||||
signal->args = args;
|
||||
if (args)
|
||||
g_variant_ref_sink (args);
|
||||
signal->user_data = user_data;
|
||||
signal->user_destroy = user_destroy;
|
||||
|
||||
return signal;
|
||||
return &signal->parent;
|
||||
}
|
||||
|
||||
static void
|
||||
binding_signal_free (GtkBindingSignal *sig)
|
||||
binding_signal_free (GtkBindingSignal *signal)
|
||||
{
|
||||
guint i;
|
||||
|
||||
switch (sig->action_type)
|
||||
switch (signal->action_type)
|
||||
{
|
||||
case GTK_BINDING_SIGNAL:
|
||||
for (i = 0; i < sig->n_args; i++)
|
||||
{
|
||||
if (G_TYPE_FUNDAMENTAL (sig->args[i].arg_type) == G_TYPE_STRING)
|
||||
g_free (sig->args[i].d.string_data);
|
||||
}
|
||||
g_slice_free1 (sizeof (GtkBindingSignal) + sig->n_args * sizeof (GtkBindingArg), sig);
|
||||
{
|
||||
GtkBindingSignalSignal *sig = (GtkBindingSignalSignal *) signal;
|
||||
for (i = 0; i < sig->n_args; i++)
|
||||
{
|
||||
if (G_TYPE_FUNDAMENTAL (sig->args[i].arg_type) == G_TYPE_STRING)
|
||||
g_free (sig->args[i].d.string_data);
|
||||
}
|
||||
g_slice_free1 (sizeof (GtkBindingSignalSignal) + sig->n_args * sizeof (GtkBindingArg), sig);
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_BINDING_ACTION:
|
||||
g_clear_pointer (&sig->variant, g_variant_unref);
|
||||
g_slice_free (GtkBindingSignal, sig);
|
||||
{
|
||||
GtkBindingSignalAction *sig = (GtkBindingSignalAction *) signal;
|
||||
g_clear_pointer (&sig->variant, g_variant_unref);
|
||||
g_slice_free (GtkBindingSignalAction, sig);
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_BINDING_CALLBACK:
|
||||
if (sig->callback.user_destroy)
|
||||
sig->callback.user_destroy (sig->callback.user_data);
|
||||
g_slice_free (GtkBindingSignal, sig);
|
||||
{
|
||||
GtkBindingSignalCallback *sig = (GtkBindingSignalCallback *) signal;
|
||||
if (sig->user_destroy)
|
||||
sig->user_destroy (sig->user_data);
|
||||
g_slice_free (GtkBindingSignalCallback, sig);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -633,8 +658,8 @@ binding_compose_params (GObject *object,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
binding_signal_activate_signal (GtkBindingSignal *sig,
|
||||
GObject *object)
|
||||
binding_signal_activate_signal (GtkBindingSignalSignal *sig,
|
||||
GObject *object)
|
||||
{
|
||||
GSignalQuery query;
|
||||
guint signal_id;
|
||||
@ -700,8 +725,8 @@ binding_signal_activate_signal (GtkBindingSignal *sig,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
binding_signal_activate_action (GtkBindingSignal *sig,
|
||||
GObject *object)
|
||||
binding_signal_activate_action (GtkBindingSignalAction *sig,
|
||||
GObject *object)
|
||||
{
|
||||
if (!GTK_IS_WIDGET (object))
|
||||
{
|
||||
@ -711,11 +736,11 @@ binding_signal_activate_action (GtkBindingSignal *sig,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!gtk_widget_activate_action_variant (GTK_WIDGET (object), sig->signal_name, sig->variant))
|
||||
if (!gtk_widget_activate_action_variant (GTK_WIDGET (object), sig->action_name, sig->variant))
|
||||
{
|
||||
g_warning ("gtk_binding_entry_activate(): "
|
||||
"action \"%s\" does not exist on class \"%s\"",
|
||||
sig->signal_name,
|
||||
sig->action_name,
|
||||
G_OBJECT_TYPE_NAME (object));
|
||||
return FALSE;
|
||||
}
|
||||
@ -724,8 +749,8 @@ binding_signal_activate_action (GtkBindingSignal *sig,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
binding_signal_activate_callback (GtkBindingSignal *sig,
|
||||
GObject *object)
|
||||
binding_signal_activate_callback (GtkBindingSignalCallback *sig,
|
||||
GObject *object)
|
||||
{
|
||||
if (!GTK_IS_WIDGET (object))
|
||||
{
|
||||
@ -735,7 +760,7 @@ binding_signal_activate_callback (GtkBindingSignal *sig,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
sig->callback.callback (GTK_WIDGET (object), sig->callback.user_data);
|
||||
sig->callback (GTK_WIDGET (object), sig->args, sig->user_data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -758,15 +783,15 @@ gtk_binding_entry_activate (GtkBindingEntry *entry,
|
||||
switch (sig->action_type)
|
||||
{
|
||||
case GTK_BINDING_SIGNAL:
|
||||
handled = binding_signal_activate_signal (sig, object);
|
||||
handled = binding_signal_activate_signal ((GtkBindingSignalSignal *) sig, object);
|
||||
break;
|
||||
|
||||
case GTK_BINDING_ACTION:
|
||||
handled = binding_signal_activate_action (sig, object);
|
||||
handled = binding_signal_activate_action ((GtkBindingSignalAction *) sig, object);
|
||||
break;
|
||||
|
||||
case GTK_BINDING_CALLBACK:
|
||||
handled = binding_signal_activate_callback (sig, object);
|
||||
handled = binding_signal_activate_callback ((GtkBindingSignalCallback *) sig, object);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1041,7 +1066,7 @@ gtk_binding_entry_add_signall (GtkBindingSet *binding_set,
|
||||
|
||||
signal = binding_signal_new_signal (signal_name, g_slist_length (binding_args));
|
||||
|
||||
arg = signal->args;
|
||||
arg = ((GtkBindingSignalSignal *) signal)->args;
|
||||
for (slist = binding_args; slist; slist = slist->next)
|
||||
{
|
||||
GtkBindingArg *tmp_arg;
|
||||
@ -1274,12 +1299,13 @@ gtk_binding_entry_add_action (GtkBindingSet *binding_set,
|
||||
}
|
||||
|
||||
void
|
||||
gtk_binding_entry_add_callback (GtkBindingSet *binding_set,
|
||||
guint keyval,
|
||||
GdkModifierType modifiers,
|
||||
GtkCallback callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy)
|
||||
gtk_binding_entry_add_callback (GtkBindingSet *binding_set,
|
||||
guint keyval,
|
||||
GdkModifierType modifiers,
|
||||
GtkBindingCallback callback,
|
||||
GVariant *args,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy)
|
||||
{
|
||||
g_return_if_fail (binding_set != NULL);
|
||||
g_return_if_fail (callback != NULL);
|
||||
@ -1287,7 +1313,7 @@ gtk_binding_entry_add_callback (GtkBindingSet *binding_set,
|
||||
gtk_binding_entry_add_binding_signal (binding_set,
|
||||
keyval,
|
||||
modifiers,
|
||||
binding_signal_new_callback (callback, user_data, user_destroy));
|
||||
binding_signal_new_callback (callback, args, user_data, user_destroy));
|
||||
|
||||
}
|
||||
|
||||
|
@ -35,12 +35,25 @@
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtkenums.h>
|
||||
#include <gtk/gtkwidget.h>
|
||||
#include <gtk/gtktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkBindingSet GtkBindingSet;
|
||||
|
||||
/**
|
||||
* GtkBindingCallback:
|
||||
* @widget: The object to invoke the callback on
|
||||
* @args: (allow-none): The arguments or %NULL if none
|
||||
* @user_data: The user data passed when registering the callback
|
||||
*
|
||||
* Prototype of the callback function registered with
|
||||
* gtk_binding_entry_add_callback.
|
||||
*/
|
||||
typedef void (* GtkBindingCallback) (GtkWidget *widget,
|
||||
GVariant *args,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkBindingSet *gtk_binding_set_new (const gchar *set_name);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
@ -96,7 +109,8 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gtk_binding_entry_add_callback(GtkBindingSet *binding_set,
|
||||
guint keyval,
|
||||
GdkModifierType modifiers,
|
||||
GtkCallback callback,
|
||||
GtkBindingCallback callback,
|
||||
GVariant *args,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy);
|
||||
|
||||
|
@ -1695,14 +1695,17 @@ gtk_entry_snapshot (GtkWidget *widget,
|
||||
* You only want to call this on some special entries
|
||||
* which the user usually doesn't want to replace all text in,
|
||||
* such as search-as-you-type entries.
|
||||
*
|
||||
* Returns: %TRUE if focus is now inside @self
|
||||
*/
|
||||
void
|
||||
gboolean
|
||||
gtk_entry_grab_focus_without_selecting (GtkEntry *entry)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_ENTRY (entry));
|
||||
GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
|
||||
|
||||
gtk_text_grab_focus_without_selecting (GTK_TEXT (priv->text));
|
||||
g_return_val_if_fail (GTK_IS_ENTRY (entry), FALSE);
|
||||
|
||||
return gtk_text_grab_focus_without_selecting (GTK_TEXT (priv->text));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -304,7 +304,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
PangoTabArray *gtk_entry_get_tabs (GtkEntry *entry);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_entry_grab_focus_without_selecting (GtkEntry *entry);
|
||||
gboolean gtk_entry_grab_focus_without_selecting (GtkEntry *entry);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_entry_set_extra_menu (GtkEntry *entry,
|
||||
|
@ -166,10 +166,10 @@ gtk_css_style_snapshot_icon_paintable (GtkCssStyle *style,
|
||||
if (recolor)
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
transparent:
|
||||
if (has_shadow)
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
transparent:
|
||||
gtk_css_filter_value_pop_snapshot (filter_value, snapshot);
|
||||
|
||||
gsk_transform_unref (transform);
|
||||
|
@ -1681,6 +1681,7 @@ gtk_text_init (GtkText *self)
|
||||
priv->truncate_multiline = FALSE;
|
||||
priv->xalign = 0.0;
|
||||
priv->insert_pos = -1;
|
||||
priv->cursor_alpha = 1.0;
|
||||
|
||||
priv->selection_content = g_object_new (GTK_TYPE_TEXT_CONTENT, NULL);
|
||||
GTK_TEXT_CONTENT (priv->selection_content)->self = self;
|
||||
|
Loading…
Reference in New Issue
Block a user