Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master Closes #2897 and #2898 See merge request GNOME/gtk!2158
This commit is contained in:
@@ -9,9 +9,9 @@
|
||||
* The dataset used here has up to 16 777 216 items.
|
||||
*
|
||||
* Note that this demo also functions as a performance
|
||||
* test for some of the list model machinery, and biggest
|
||||
* sizes here can lock up the application for extended
|
||||
* times when used with sorting.
|
||||
* test for some of the list model machinery, and the
|
||||
* biggest sizes here can lock up the application for
|
||||
* extended times when used with sorting.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
@@ -715,16 +715,17 @@ limit_changed_cb2 (GtkDropDown *dropdown,
|
||||
GParamSpec *pspec,
|
||||
GtkLabel *label)
|
||||
{
|
||||
gpointer item;
|
||||
char *string;
|
||||
int len;
|
||||
guint limit;
|
||||
|
||||
item = gtk_drop_down_get_selected_item (dropdown);
|
||||
g_object_get (item, "string", &string, NULL);
|
||||
limit = 1 << (3 * (gtk_drop_down_get_selected (dropdown) + 1));
|
||||
|
||||
string = g_strdup_printf ("%'u", limit);
|
||||
len = g_utf8_strlen (string, -1);
|
||||
g_free (string);
|
||||
|
||||
gtk_label_set_max_width_chars (label, len + 2); /* for " /" */
|
||||
gtk_label_set_width_chars (label, len + 2); /* for " /" */
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -737,11 +738,44 @@ items_changed_cb (GListModel *model,
|
||||
guint n = g_list_model_get_n_items (model);
|
||||
char *text;
|
||||
|
||||
text = g_strdup_printf ("%u /", n);
|
||||
text = g_strdup_printf ("%'u /", n);
|
||||
gtk_label_set_label (GTK_LABEL (label), text);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_number_item (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item)
|
||||
{
|
||||
GtkWidget *label;
|
||||
PangoAttrList *attrs;
|
||||
|
||||
label = gtk_label_new ("");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 1);
|
||||
|
||||
attrs = pango_attr_list_new ();
|
||||
pango_attr_list_insert (attrs, pango_attr_font_features_new ("tnum"));
|
||||
gtk_label_set_attributes (GTK_LABEL (label), attrs);
|
||||
pango_attr_list_unref (attrs);
|
||||
|
||||
gtk_list_item_set_child (item, label);
|
||||
}
|
||||
|
||||
static void
|
||||
bind_number_item (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item)
|
||||
{
|
||||
GtkWidget *label;
|
||||
guint limit;
|
||||
char *string;
|
||||
|
||||
label = gtk_list_item_get_child (item);
|
||||
|
||||
limit = 1 << (3 * (gtk_list_item_get_position (item) + 1));
|
||||
string = g_strdup_printf ("%'u", limit);
|
||||
gtk_label_set_label (GTK_LABEL (label), string);
|
||||
g_free (string);
|
||||
}
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
@@ -761,6 +795,8 @@ do_listview_colors (GtkWidget *do_widget)
|
||||
GtkWidget *button;
|
||||
GtkWidget *label;
|
||||
PangoAttrList *attrs;
|
||||
char *string;
|
||||
guint len;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Colors");
|
||||
@@ -793,8 +829,12 @@ do_listview_colors (GtkWidget *do_widget)
|
||||
pango_attr_list_insert (attrs, pango_attr_font_features_new ("tnum"));
|
||||
gtk_label_set_attributes (GTK_LABEL (label), attrs);
|
||||
pango_attr_list_unref (attrs);
|
||||
gtk_label_set_width_chars (GTK_LABEL (label), 6);
|
||||
string = g_strdup_printf ("%'u", 4096);
|
||||
len = g_utf8_strlen (string, -1);
|
||||
g_free (string);
|
||||
gtk_label_set_width_chars (GTK_LABEL (label), len + 2);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 1);
|
||||
|
||||
g_signal_connect (gtk_grid_view_get_model (GTK_GRID_VIEW (gridview)),
|
||||
"items-changed", G_CALLBACK (items_changed_cb), label);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), label);
|
||||
@@ -807,6 +847,11 @@ do_listview_colors (GtkWidget *do_widget)
|
||||
g_signal_connect (dropdown, "notify::selected",
|
||||
G_CALLBACK (limit_changed_cb2),
|
||||
label);
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_number_item), NULL);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (bind_number_item), NULL);
|
||||
gtk_drop_down_set_factory (GTK_DROP_DOWN (dropdown), factory);
|
||||
g_object_unref (factory);
|
||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (dropdown), 3); /* 4096 */
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), dropdown);
|
||||
|
||||
|
||||
@@ -332,7 +332,7 @@ gtk_list_item_set_child (GtkListItem *self,
|
||||
* @self: a #GtkListItem
|
||||
*
|
||||
* Gets the position in the model that @self currently displays.
|
||||
* If @self is unbound, 0 is returned.
|
||||
* If @self is unbound, %GTK_INVALID_LIST_POSITION is returned.
|
||||
*
|
||||
* Returns: The position of this item
|
||||
**/
|
||||
@@ -443,10 +443,10 @@ gtk_list_item_get_activatable (GtkListItem *self)
|
||||
* Sets @self to be activatable.
|
||||
*
|
||||
* If an item is activatable, double-clicking on the item, using
|
||||
* the <Return> key or calling gtk_widget_activate() will activate
|
||||
* the Return key or calling gtk_widget_activate() will activate
|
||||
* the item. Activating instructs the containing view to handle
|
||||
* activation. #GtkListView for example will be emitting the
|
||||
* GtkListView::activate signal.
|
||||
* #GtkListView::activate signal.
|
||||
*
|
||||
* By default, list items are activatable
|
||||
**/
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtknative.h"
|
||||
#include "gtkdebug.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
@@ -370,6 +371,18 @@ gtk_shortcut_controller_run_controllers (GtkEventController *controller,
|
||||
data->widget = widget;
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GTK_DEBUG_CHECK (KEYBINDINGS))
|
||||
{
|
||||
g_message ("Found %u shortcuts triggered %s by %s %u %u",
|
||||
shortcuts ? shortcuts->len : 0,
|
||||
has_exact ? "exactly" : "approximately",
|
||||
gdk_event_get_event_type (event) == GDK_KEY_PRESS ? "key press" : "key release",
|
||||
gdk_key_event_get_keyval (event),
|
||||
gdk_event_get_modifier_state (event));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!shortcuts)
|
||||
return retval;
|
||||
|
||||
|
||||
@@ -2627,6 +2627,7 @@ gtk_text_do_popup (GtkText *self,
|
||||
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
||||
|
||||
gtk_text_update_clipboard_actions (self);
|
||||
gtk_text_update_emoji_action (self);
|
||||
|
||||
if (!priv->popup_menu)
|
||||
{
|
||||
@@ -4024,7 +4025,11 @@ gtk_text_copy_clipboard (GtkText *self)
|
||||
return;
|
||||
}
|
||||
|
||||
str = gtk_text_get_display_text (self, priv->selection_bound, priv->current_pos);
|
||||
if (priv->selection_bound < priv->current_pos)
|
||||
str = gtk_text_get_display_text (self, priv->selection_bound, priv->current_pos);
|
||||
else
|
||||
str = gtk_text_get_display_text (self, priv->current_pos, priv->selection_bound);
|
||||
|
||||
gdk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (self)), str);
|
||||
g_free (str);
|
||||
}
|
||||
@@ -5397,6 +5402,9 @@ gtk_text_set_editable (GtkText *self,
|
||||
gtk_event_controller_key_set_im_context (GTK_EVENT_CONTROLLER_KEY (priv->key_controller),
|
||||
is_editable ? priv->im_context : NULL);
|
||||
|
||||
gtk_text_update_clipboard_actions (self);
|
||||
gtk_text_update_emoji_action (self);
|
||||
|
||||
g_object_notify (G_OBJECT (self), "editable");
|
||||
}
|
||||
}
|
||||
@@ -5909,7 +5917,10 @@ gtk_text_update_clipboard_actions (GtkText *self)
|
||||
static void
|
||||
gtk_text_update_emoji_action (GtkText *self)
|
||||
{
|
||||
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
||||
|
||||
gtk_widget_action_set_enabled (GTK_WIDGET (self), "misc.insert-emoji",
|
||||
priv->editable &&
|
||||
(gtk_text_get_input_hints (self) & GTK_INPUT_HINT_NO_EMOJI) == 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -4378,7 +4378,7 @@ gtk_widget_run_controllers (GtkWidget *widget,
|
||||
if (this_handled &&
|
||||
(type == GDK_KEY_PRESS || type == GDK_KEY_RELEASE))
|
||||
{
|
||||
g_message ("key %s (keyval %d) handled at widget %s by controller %s\n",
|
||||
g_message ("key %s (keyval %d) handled at widget %s by controller %s",
|
||||
type == GDK_KEY_PRESS ? "press" : "release",
|
||||
gdk_key_event_get_keyval (event),
|
||||
G_OBJECT_TYPE_NAME (widget),
|
||||
|
||||
Reference in New Issue
Block a user