Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 49e93f6ee4 | |||
| 4ec2234537 | |||
| 5a3755b233 |
@@ -20,7 +20,6 @@ flatpak build ${builddir} meson \
|
||||
-Dx11-backend=true \
|
||||
-Dwayland-backend=true \
|
||||
-Dbuild-tests=false \
|
||||
-Dbuild-testsuite=false \
|
||||
-Dbuild-examples=false \
|
||||
-Dintrospection=disabled \
|
||||
-Ddemos=true \
|
||||
|
||||
@@ -1,150 +1,5 @@
|
||||
Overview of Changes in 4.10.2, 21-04-2023
|
||||
=========================================
|
||||
|
||||
* Fixed issues:
|
||||
- Holding control to select multiple files broken in filechooser (#5669)
|
||||
- Inspector crash (#5681)
|
||||
- Listbase doesn't account for bottom padding in size_allocate_child (#5380)
|
||||
- Leaking AT contexts (#5690)
|
||||
- OpenGL / Windows: Crash when closing gtk4-widget-factory (#5685)
|
||||
- GTK apps crash on startup when setting cursor-size to 0 on Wayland (#5700)
|
||||
- Segmentation fault: gdk_wayland_toplevel_set_startup_id() needs to null-check
|
||||
display->xdg_activation before using it (#5701)
|
||||
- Possible use-after-free under gtk_scrolled_window_update_use_indicators() (#5684)
|
||||
- Wrong error message in `gtk_init` (#5704)
|
||||
- Segfault when scrolling after changing ListView model (#5763)
|
||||
- Bluetooth panel from the Settings app: clicking in the "Downloads" link
|
||||
no longer opens Nautilus (#5671)
|
||||
- Broadway docs or code is broken (#5662)
|
||||
- Disabled GtkPicture's are not properly themed (#5683)
|
||||
- Setting CSS padding to a GtkTextView gives the context menu an offset (#5695)
|
||||
- A11y: the Showing state is used only for windows (#5194)
|
||||
- Gtk4 expander: CSS nodes mismatch code vs. documentation (#5723)
|
||||
- Invoking gtk inspector on a folder results in a crash (#5729)
|
||||
- Double tap requires very precise touch input (#5580)
|
||||
- Name autocompletion dropdown in the GTK4 FileChooser's Save dialog gets
|
||||
stuck, creates artifacts, jumps around (#5743)
|
||||
- Links are not opened when xdg-desktop-portal OpenURI is not available (#5733)
|
||||
- GtkSnapshot generates no nodes appending whitespace-only layouts (#5747)
|
||||
|
||||
* Translation updates
|
||||
British English
|
||||
Bulgarian
|
||||
Chinese (China)
|
||||
French
|
||||
Indonesian
|
||||
Korean
|
||||
Russian
|
||||
Serbian
|
||||
Slovenian
|
||||
Turkish
|
||||
|
||||
|
||||
Overview of Changes in 4.10.1, 14-03-2023
|
||||
=========================================
|
||||
|
||||
* GtkFileChooser
|
||||
- Improve search performance
|
||||
- Be safe against pathless files
|
||||
- Fix memory leaks
|
||||
- Only show local files in recent files
|
||||
- Show most recent files first
|
||||
- Make files non-selectable in selet_folder mode
|
||||
|
||||
* GtkListView / GtkColumnView / GtkGridView
|
||||
- Fix scrolling problems
|
||||
- Support CSS border-spacing
|
||||
|
||||
* GtkComboBox
|
||||
- Fix a size allocation problem
|
||||
|
||||
* gtk
|
||||
- Size allocation fixes
|
||||
|
||||
* Accessibility
|
||||
- Miscellaneous property fixes and improvements
|
||||
|
||||
* Wayland
|
||||
- Fix an ordering problem in surface disposal
|
||||
|
||||
* Windows
|
||||
- Fix Visual Studio build with older GLib
|
||||
|
||||
* Translation updates
|
||||
Basque
|
||||
Bulgarian
|
||||
Catalan
|
||||
Czech
|
||||
Danish
|
||||
Finnish
|
||||
Friulian
|
||||
Galician
|
||||
Georgian
|
||||
Hungarian
|
||||
Lithuanian
|
||||
Polish
|
||||
Portuguese
|
||||
Swedish
|
||||
Turkish
|
||||
Ukrainian
|
||||
|
||||
|
||||
Overview of Changes in 4.10.0, 04-03-2023
|
||||
=========================================
|
||||
|
||||
* GtkTextView
|
||||
- Document hanging indentation
|
||||
|
||||
* GtkListView
|
||||
- Fix a size allocation problem
|
||||
|
||||
* GtkFileChooser
|
||||
- Fix paned behavior
|
||||
- Fix a crash
|
||||
|
||||
* GtkText
|
||||
- Fix various problems with undo
|
||||
|
||||
* Accessibility
|
||||
- Make some getters transfer-full
|
||||
- Allow setting accessible parents and siblings
|
||||
- Add a role for toggle buttons
|
||||
- Miscellaneous property fixes and improvements
|
||||
|
||||
* gtk
|
||||
- Improve the handling resize-during-size-allocate
|
||||
|
||||
* gdk
|
||||
- Introduce GdkTextureDownloader and use it
|
||||
- Make gdk_texture_get_format public
|
||||
|
||||
* gsk
|
||||
- Make mask nodes more versatile
|
||||
- Improve the GL implementation for texture scale nodes
|
||||
|
||||
* X11
|
||||
- Fix key handling during DND
|
||||
|
||||
* Tools
|
||||
- gtk-builder-tool: Try harder to handle templates
|
||||
- gtk-builder-tool: Prefer properties over <child>
|
||||
|
||||
* Translation updates
|
||||
Basque
|
||||
Belarusian
|
||||
Bulgarian
|
||||
Indonesian
|
||||
Galician
|
||||
Georgian
|
||||
German
|
||||
Hebrew
|
||||
Lithuanian
|
||||
Portuguese
|
||||
Spanish
|
||||
Swedish
|
||||
Turkish
|
||||
Ukrainian
|
||||
|
||||
Overview of Changes in 4.9.5, xx-xx-xxxx
|
||||
========================================
|
||||
|
||||
Overview of Changes in 4.9.4, 12-02-2023
|
||||
========================================
|
||||
|
||||
@@ -9,7 +9,7 @@ constraint_editor_sources = [
|
||||
|
||||
constraint_editor_resources = gnome.compile_resources('constraint_editor_resources',
|
||||
'constraint-editor.gresource.xml',
|
||||
source_dir: meson.current_source_dir(),
|
||||
source_dir: '.',
|
||||
)
|
||||
|
||||
executable('gtk4-constraint-editor',
|
||||
|
||||
+24
-164
@@ -5,8 +5,7 @@ enum
|
||||
{
|
||||
PROP_TEXTURE = 1,
|
||||
PROP_FILTER,
|
||||
PROP_SCALE,
|
||||
PROP_ANGLE,
|
||||
PROP_SCALE
|
||||
};
|
||||
|
||||
struct _Demo3Widget
|
||||
@@ -15,7 +14,6 @@ struct _Demo3Widget
|
||||
|
||||
GdkTexture *texture;
|
||||
float scale;
|
||||
float angle;
|
||||
GskScalingFilter filter;
|
||||
|
||||
GtkWidget *menu;
|
||||
@@ -28,85 +26,10 @@ struct _Demo3WidgetClass
|
||||
|
||||
G_DEFINE_TYPE (Demo3Widget, demo3_widget, GTK_TYPE_WIDGET)
|
||||
|
||||
static gboolean
|
||||
query_tooltip (GtkWidget *widget,
|
||||
int x,
|
||||
int y,
|
||||
gboolean keyboard_mode,
|
||||
GtkTooltip *tooltip,
|
||||
gpointer data)
|
||||
{
|
||||
Demo3Widget *self = DEMO3_WIDGET (widget);
|
||||
GtkWidget *grid;
|
||||
GtkWidget *label;
|
||||
char *s, *s2;
|
||||
const char *filter[] = { "Linear", "Nearest", "Trilinear" };
|
||||
int precision, l;
|
||||
|
||||
grid = gtk_grid_new ();
|
||||
gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
|
||||
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
|
||||
label = gtk_label_new ("Texture");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
|
||||
s = g_strdup_printf ("%d\342\200\206\303\227\342\200\206%d",
|
||||
gdk_texture_get_width (self->texture),
|
||||
gdk_texture_get_height (self->texture));
|
||||
label = gtk_label_new (s);
|
||||
g_free (s);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 1);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 1, 0, 1, 1);
|
||||
|
||||
label = gtk_label_new ("Rotation");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);
|
||||
s = g_strdup_printf ("%.1f", self->angle);
|
||||
if (g_str_has_suffix (s, ".0"))
|
||||
s[strlen (s) - 2] = '\0';
|
||||
s2 = g_strconcat (s, "\302\260", NULL);
|
||||
label = gtk_label_new (s2);
|
||||
g_free (s2);
|
||||
g_free (s);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 1);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 1, 1, 1, 1);
|
||||
|
||||
label = gtk_label_new ("Scale");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1);
|
||||
|
||||
precision = 1;
|
||||
do {
|
||||
s = g_strdup_printf ("%.*f", precision, self->scale);
|
||||
l = strlen (s) - 1;
|
||||
while (s[l] == '0')
|
||||
l--;
|
||||
if (s[l] == '.')
|
||||
s[l] = '\0';
|
||||
precision++;
|
||||
} while (strcmp (s, "0") == 0);
|
||||
|
||||
label = gtk_label_new (s);
|
||||
g_free (s);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 1);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 1, 2, 1, 1);
|
||||
|
||||
label = gtk_label_new ("Filter");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 1, 1);
|
||||
label = gtk_label_new (filter[self->filter]);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 1);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 1, 3, 1, 1);
|
||||
|
||||
gtk_tooltip_set_custom (tooltip, grid);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
demo3_widget_init (Demo3Widget *self)
|
||||
{
|
||||
self->scale = 1.f;
|
||||
self->angle = 0.f;
|
||||
self->filter = GSK_SCALING_FILTER_LINEAR;
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
}
|
||||
@@ -129,35 +52,26 @@ demo3_widget_snapshot (GtkWidget *widget,
|
||||
{
|
||||
Demo3Widget *self = DEMO3_WIDGET (widget);
|
||||
int x, y, width, height;
|
||||
double w, h, w2, h2;
|
||||
double w, h;
|
||||
GskRenderNode *node;
|
||||
|
||||
width = gtk_widget_get_width (widget);
|
||||
height = gtk_widget_get_height (widget);
|
||||
|
||||
w2 = w = self->scale * gdk_texture_get_width (self->texture);
|
||||
h2 = h = self->scale * gdk_texture_get_height (self->texture);
|
||||
w = self->scale * gdk_texture_get_width (self->texture);
|
||||
h = self->scale * gdk_texture_get_height (self->texture);
|
||||
|
||||
if (G_APPROX_VALUE (self->angle, 90.f, FLT_EPSILON) ||
|
||||
G_APPROX_VALUE (self->angle, 270.f, FLT_EPSILON))
|
||||
{
|
||||
double s = w2;
|
||||
w2 = h2;
|
||||
h2 = s;
|
||||
}
|
||||
|
||||
x = (width - ceil (w2)) / 2;
|
||||
y = (height - ceil (h2)) / 2;
|
||||
x = MAX (0, (width - ceil (w)) / 2);
|
||||
y = MAX (0, (height - ceil (h)) / 2);
|
||||
|
||||
gtk_snapshot_push_clip (snapshot, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
gtk_snapshot_save (snapshot);
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (w2 / 2, h2 / 2));
|
||||
gtk_snapshot_rotate (snapshot, self->angle);
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (- w / 2, - h / 2));
|
||||
gtk_snapshot_append_scaled_texture (snapshot,
|
||||
self->texture,
|
||||
self->filter,
|
||||
&GRAPHENE_RECT_INIT (0, 0, w, h));
|
||||
node = gsk_texture_scale_node_new (self->texture,
|
||||
&GRAPHENE_RECT_INIT (0, 0, w, h),
|
||||
self->filter);
|
||||
gtk_snapshot_append_node (snapshot, node);
|
||||
gsk_render_node_unref (node);
|
||||
gtk_snapshot_restore (snapshot);
|
||||
gtk_snapshot_pop (snapshot);
|
||||
}
|
||||
@@ -172,26 +86,14 @@ demo3_widget_measure (GtkWidget *widget,
|
||||
int *natural_baseline)
|
||||
{
|
||||
Demo3Widget *self = DEMO3_WIDGET (widget);
|
||||
int width, height;
|
||||
int size;
|
||||
|
||||
width = gdk_texture_get_width (self->texture);
|
||||
height = gdk_texture_get_height (self->texture);
|
||||
|
||||
if (G_APPROX_VALUE (self->angle, 90.f, FLT_EPSILON) ||
|
||||
G_APPROX_VALUE (self->angle, 270.f, FLT_EPSILON))
|
||||
{
|
||||
int s = width;
|
||||
width = height;
|
||||
height = s;
|
||||
}
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
size = width;
|
||||
size = gdk_texture_get_width (self->texture);
|
||||
else
|
||||
size = height;
|
||||
size = gdk_texture_get_height (self->texture);
|
||||
|
||||
*minimum = *natural = (int) ceil (self->scale * size);
|
||||
*minimum = *natural = self->scale * size;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -209,8 +111,6 @@ demo3_widget_size_allocate (GtkWidget *widget,
|
||||
gtk_popover_present (GTK_POPOVER (self->menu));
|
||||
}
|
||||
|
||||
static void update_actions (Demo3Widget *self);
|
||||
|
||||
static void
|
||||
demo3_widget_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
@@ -229,12 +129,6 @@ demo3_widget_set_property (GObject *object,
|
||||
|
||||
case PROP_SCALE:
|
||||
self->scale = g_value_get_float (value);
|
||||
update_actions (self);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (object));
|
||||
break;
|
||||
|
||||
case PROP_ANGLE:
|
||||
self->angle = fmodf (g_value_get_float (value), 360.f);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (object));
|
||||
break;
|
||||
|
||||
@@ -267,10 +161,6 @@ demo3_widget_get_property (GObject *object,
|
||||
g_value_set_float (value, self->scale);
|
||||
break;
|
||||
|
||||
case PROP_ANGLE:
|
||||
g_value_set_float (value, self->angle);
|
||||
break;
|
||||
|
||||
case PROP_FILTER:
|
||||
g_value_set_enum (value, self->filter);
|
||||
break;
|
||||
@@ -296,14 +186,6 @@ pressed_cb (GtkGestureClick *gesture,
|
||||
gtk_popover_popup (GTK_POPOVER (self->menu));
|
||||
}
|
||||
|
||||
static void
|
||||
update_actions (Demo3Widget *self)
|
||||
{
|
||||
gtk_widget_action_set_enabled (GTK_WIDGET (self), "zoom.in", self->scale < 1024.);
|
||||
gtk_widget_action_set_enabled (GTK_WIDGET (self), "zoom.out", self->scale > 1./1024.);
|
||||
gtk_widget_action_set_enabled (GTK_WIDGET (self), "zoom.reset", self->scale != 1.);
|
||||
}
|
||||
|
||||
static void
|
||||
zoom_cb (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
@@ -313,30 +195,19 @@ zoom_cb (GtkWidget *widget,
|
||||
float scale;
|
||||
|
||||
if (g_str_equal (action_name, "zoom.in"))
|
||||
scale = MIN (1024., self->scale * M_SQRT2);
|
||||
scale = MIN (10, self->scale * M_SQRT2);
|
||||
else if (g_str_equal (action_name, "zoom.out"))
|
||||
scale = MAX (1./1024., self->scale / M_SQRT2);
|
||||
else if (g_str_equal (action_name, "zoom.reset"))
|
||||
scale = 1.0;
|
||||
scale = MAX (0.01, self->scale / M_SQRT2);
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
scale = 1.0;
|
||||
|
||||
gtk_widget_action_set_enabled (widget, "zoom.in", scale < 10);
|
||||
gtk_widget_action_set_enabled (widget, "zoom.out", scale > 0.01);
|
||||
gtk_widget_action_set_enabled (widget, "zoom.reset", scale != 1);
|
||||
|
||||
g_object_set (widget, "scale", scale, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
rotate_cb (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *parameter)
|
||||
{
|
||||
Demo3Widget *self = DEMO3_WIDGET (widget);
|
||||
int angle;
|
||||
|
||||
g_variant_get (parameter, "i", &angle);
|
||||
|
||||
g_object_set (widget, "angle", fmodf (self->angle + angle, 360.f), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
demo3_widget_class_init (Demo3WidgetClass *class)
|
||||
{
|
||||
@@ -358,12 +229,7 @@ demo3_widget_class_init (Demo3WidgetClass *class)
|
||||
|
||||
g_object_class_install_property (object_class, PROP_SCALE,
|
||||
g_param_spec_float ("scale", NULL, NULL,
|
||||
1./1024., 1024., 1.0,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_ANGLE,
|
||||
g_param_spec_float ("angle", NULL, NULL,
|
||||
0.0, 360.0, 0.0,
|
||||
0.0, 10.0, 1.0,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_FILTER,
|
||||
@@ -375,7 +241,6 @@ demo3_widget_class_init (Demo3WidgetClass *class)
|
||||
gtk_widget_class_install_action (widget_class, "zoom.in", NULL, zoom_cb);
|
||||
gtk_widget_class_install_action (widget_class, "zoom.out", NULL, zoom_cb);
|
||||
gtk_widget_class_install_action (widget_class, "zoom.reset", NULL, zoom_cb);
|
||||
gtk_widget_class_install_action (widget_class, "rotate", "i", rotate_cb);
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/menu/demo3widget.ui");
|
||||
gtk_widget_class_bind_template_child (widget_class, Demo3Widget, menu);
|
||||
@@ -390,12 +255,7 @@ demo3_widget_new (const char *resource)
|
||||
|
||||
texture = gdk_texture_new_from_resource (resource);
|
||||
|
||||
self = g_object_new (DEMO3_TYPE_WIDGET,
|
||||
"texture", texture,
|
||||
"has-tooltip", TRUE,
|
||||
NULL);
|
||||
|
||||
g_signal_connect (self, "query-tooltip", G_CALLBACK (query_tooltip), NULL);
|
||||
self = g_object_new (DEMO3_TYPE_WIDGET, "texture", texture, NULL);
|
||||
|
||||
g_object_unref (texture);
|
||||
|
||||
|
||||
@@ -12,11 +12,6 @@
|
||||
<attribute name="label">1∶1</attribute>
|
||||
<attribute name="action">zoom.reset</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label">Rotate</attribute>
|
||||
<attribute name="action">rotate</attribute>
|
||||
<attribute name="target" type="i">90</attribute>
|
||||
</item>
|
||||
</menu>
|
||||
<template class="Demo3Widget">
|
||||
<child>
|
||||
|
||||
+14
-133
@@ -1,120 +1,18 @@
|
||||
/* Image Scaling
|
||||
* #Keywords: zoom, scale, filter, action, menu
|
||||
/* Menu
|
||||
* #Keywords: action, zoom
|
||||
*
|
||||
* Demonstrates how to add a context menu to a custom widget
|
||||
* and connect it with widget actions.
|
||||
*
|
||||
* The custom widget we create here is similar to a GtkPicture,
|
||||
* but allows setting a zoom level and filtering mode for the
|
||||
* displayed paintable.
|
||||
* but allows setting a zoom level for the displayed paintable.
|
||||
*
|
||||
* It also demonstrates how to add a context menu to a custom
|
||||
* widget and connect it with widget actions.
|
||||
*
|
||||
* The context menu has items to change the zoom level.
|
||||
* Our context menu has items to change the zoom level.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "demo3widget.h"
|
||||
|
||||
static void
|
||||
file_opened (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *data)
|
||||
{
|
||||
GFile *file;
|
||||
GError *error = NULL;
|
||||
GdkTexture *texture;
|
||||
|
||||
file = gtk_file_dialog_open_finish (GTK_FILE_DIALOG (source), result, &error);
|
||||
|
||||
if (!file)
|
||||
{
|
||||
g_print ("%s\n", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
texture = gdk_texture_new_from_file (file, &error);
|
||||
g_object_unref (file);
|
||||
if (!texture)
|
||||
{
|
||||
g_print ("%s\n", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
g_object_set (G_OBJECT (data), "texture", texture, NULL);
|
||||
g_object_unref (texture);
|
||||
}
|
||||
|
||||
static void
|
||||
open_file (GtkWidget *picker,
|
||||
GtkWidget *demo)
|
||||
{
|
||||
GtkWindow *parent = GTK_WINDOW (gtk_widget_get_root (picker));
|
||||
GtkFileDialog *dialog;
|
||||
GtkFileFilter *filter;
|
||||
GListStore *filters;
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
|
||||
filter = gtk_file_filter_new ();
|
||||
gtk_file_filter_set_name (filter, "Images");
|
||||
gtk_file_filter_add_pixbuf_formats (filter);
|
||||
filters = g_list_store_new (GTK_TYPE_FILE_FILTER);
|
||||
g_list_store_append (filters, filter);
|
||||
g_object_unref (filter);
|
||||
|
||||
gtk_file_dialog_set_filters (dialog, G_LIST_MODEL (filters));
|
||||
g_object_unref (filters);
|
||||
|
||||
gtk_file_dialog_open (dialog, parent, NULL, file_opened, demo);
|
||||
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
rotate (GtkWidget *button,
|
||||
GtkWidget *demo)
|
||||
{
|
||||
float angle;
|
||||
|
||||
g_object_get (demo, "angle", &angle, NULL);
|
||||
|
||||
angle = fmodf (angle + 90.f, 360.f);
|
||||
|
||||
g_object_set (demo, "angle", angle, NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
transform_to (GBinding *binding,
|
||||
const GValue *src,
|
||||
GValue *dest,
|
||||
gpointer user_data)
|
||||
{
|
||||
double from;
|
||||
float to;
|
||||
|
||||
from = g_value_get_double (src);
|
||||
to = (float) pow (2., from);
|
||||
g_value_set_float (dest, to);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
transform_from (GBinding *binding,
|
||||
const GValue *src,
|
||||
GValue *dest,
|
||||
gpointer user_data)
|
||||
{
|
||||
float to;
|
||||
double from;
|
||||
|
||||
to = g_value_get_float (src);
|
||||
from = log2 (to);
|
||||
g_value_set_double (dest, from);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_menu (GtkWidget *do_widget)
|
||||
@@ -129,10 +27,9 @@ do_menu (GtkWidget *do_widget)
|
||||
GtkWidget *widget;
|
||||
GtkWidget *scale;
|
||||
GtkWidget *dropdown;
|
||||
GtkWidget *button;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Image Scaling");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Menu");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
@@ -151,35 +48,19 @@ do_menu (GtkWidget *do_widget)
|
||||
box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_box_append (GTK_BOX (box), box2);
|
||||
|
||||
button = gtk_button_new_from_icon_name ("document-open-symbolic");
|
||||
gtk_widget_set_tooltip_text (button, "Open File");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (open_file), widget);
|
||||
gtk_box_append (GTK_BOX (box2), button);
|
||||
|
||||
button = gtk_button_new_from_icon_name ("object-rotate-right-symbolic");
|
||||
gtk_widget_set_tooltip_text (button, "Rotate");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (rotate), widget);
|
||||
gtk_box_append (GTK_BOX (box2), button);
|
||||
|
||||
scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, -10., 10., 0.1);
|
||||
gtk_scale_add_mark (GTK_SCALE (scale), 0., GTK_POS_TOP, NULL);
|
||||
gtk_widget_set_tooltip_text (scale, "Zoom");
|
||||
gtk_range_set_value (GTK_RANGE (scale), 0.);
|
||||
scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0.01, 10.0, 0.1);
|
||||
gtk_range_set_value (GTK_RANGE (scale), 1.0);
|
||||
gtk_widget_set_hexpand (scale, TRUE);
|
||||
gtk_box_append (GTK_BOX (box2), scale);
|
||||
|
||||
dropdown = gtk_drop_down_new (G_LIST_MODEL (gtk_string_list_new ((const char *[]){ "Linear", "Nearest", "Trilinear", NULL })), NULL);
|
||||
gtk_widget_set_tooltip_text (dropdown, "Filter");
|
||||
gtk_box_append (GTK_BOX (box2), dropdown);
|
||||
|
||||
g_object_bind_property (dropdown, "selected", widget, "filter", G_BINDING_DEFAULT);
|
||||
|
||||
g_object_bind_property_full (gtk_range_get_adjustment (GTK_RANGE (scale)), "value",
|
||||
widget, "scale",
|
||||
G_BINDING_BIDIRECTIONAL,
|
||||
transform_to,
|
||||
transform_from,
|
||||
NULL, NULL);
|
||||
|
||||
g_object_bind_property (gtk_range_get_adjustment (GTK_RANGE (scale)), "value",
|
||||
widget, "scale",
|
||||
G_BINDING_BIDIRECTIONAL);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
||||
@@ -225,7 +225,7 @@ if not meson.is_cross_build() and build_machine.cpu_family() != 'arm' and build_
|
||||
else
|
||||
gtkdemo_resources = gnome.compile_resources('gtkdemo_resources',
|
||||
'demo.gresource.xml',
|
||||
source_dir: meson.current_source_dir()
|
||||
source_dir: '.',
|
||||
)
|
||||
endif
|
||||
|
||||
|
||||
@@ -13,13 +13,20 @@
|
||||
static GtkWidget *app_picker;
|
||||
|
||||
static void
|
||||
set_file (GFile *file,
|
||||
gpointer data)
|
||||
file_opened (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *data)
|
||||
{
|
||||
GFile *file;
|
||||
GError *error = NULL;
|
||||
char *name;
|
||||
|
||||
file = gtk_file_dialog_open_finish (GTK_FILE_DIALOG (source), result, &error);
|
||||
|
||||
if (!file)
|
||||
{
|
||||
g_print ("%s\n", error->message);
|
||||
g_error_free (error);
|
||||
gtk_widget_set_sensitive (app_picker, FALSE);
|
||||
g_object_set_data (G_OBJECT (app_picker), "file", NULL);
|
||||
return;
|
||||
@@ -33,25 +40,6 @@ set_file (GFile *file,
|
||||
g_object_set_data_full (G_OBJECT (app_picker), "file", g_object_ref (file), g_object_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
file_opened (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *data)
|
||||
{
|
||||
GFile *file;
|
||||
GError *error = NULL;
|
||||
|
||||
file = gtk_file_dialog_open_finish (GTK_FILE_DIALOG (source), result, &error);
|
||||
|
||||
if (!file)
|
||||
{
|
||||
g_print ("%s\n", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
set_file (file, data);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
abort_mission (gpointer data)
|
||||
{
|
||||
@@ -142,28 +130,11 @@ launch_uri (GtkButton *picker)
|
||||
g_object_unref (launcher);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
on_drop (GtkDropTarget *target,
|
||||
const GValue *value,
|
||||
double x,
|
||||
double y,
|
||||
gpointer data)
|
||||
{
|
||||
if (G_VALUE_HOLDS (value, G_TYPE_FILE))
|
||||
{
|
||||
set_file (g_value_get_object (value), data);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_pickers (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *table, *label, *picker, *button;
|
||||
GtkDropTarget *drop_target;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
@@ -208,13 +179,7 @@ do_pickers (GtkWidget *do_widget)
|
||||
|
||||
picker = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
button = gtk_button_new_from_icon_name ("document-open-symbolic");
|
||||
|
||||
label = gtk_label_new ("None");
|
||||
|
||||
drop_target = gtk_drop_target_new (G_TYPE_FILE, GDK_ACTION_COPY);
|
||||
g_signal_connect (drop_target, "drop", G_CALLBACK (on_drop), label);
|
||||
gtk_widget_add_controller (button, GTK_EVENT_CONTROLLER (drop_target));
|
||||
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.);
|
||||
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_MIDDLE);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
|
||||
@@ -22,7 +22,6 @@ show_shortcuts (GtkWidget *window,
|
||||
gtk_window_set_transient_for (GTK_WINDOW (overlay), GTK_WINDOW (window));
|
||||
g_object_set (overlay, "view-name", view, NULL);
|
||||
g_object_unref (builder);
|
||||
gtk_window_present (GTK_WINDOW (overlay));
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void
|
||||
|
||||
@@ -8,7 +8,7 @@ iconbrowser_sources = [
|
||||
|
||||
iconbrowser_resources = gnome.compile_resources('iconbrowser_resources',
|
||||
'iconbrowser.gresource.xml',
|
||||
source_dir: meson.current_source_dir(),
|
||||
source_dir: '.',
|
||||
)
|
||||
|
||||
executable('gtk4-icon-browser',
|
||||
|
||||
@@ -7,7 +7,7 @@ node_editor_sources = [
|
||||
|
||||
node_editor_resources = gnome.compile_resources('node_editor_resources',
|
||||
'node-editor.gresource.xml',
|
||||
source_dir: meson.current_source_dir(),
|
||||
source_dir: '.',
|
||||
)
|
||||
|
||||
executable('gtk4-node-editor',
|
||||
|
||||
@@ -32,11 +32,6 @@
|
||||
#include "gsk/vulkan/gskvulkanrenderer.h"
|
||||
#endif
|
||||
|
||||
#include <cairo.h>
|
||||
#ifdef CAIRO_HAS_SVG_SURFACE
|
||||
#include <cairo-svg.h>
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gsize start_chars;
|
||||
@@ -648,34 +643,23 @@ save_cb (GtkWidget *button,
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
static GskRenderNode *
|
||||
create_node (NodeEditorWindow *self)
|
||||
static GdkTexture *
|
||||
create_texture (NodeEditorWindow *self)
|
||||
{
|
||||
GdkPaintable *paintable;
|
||||
GtkSnapshot *snapshot;
|
||||
GskRenderer *renderer;
|
||||
GskRenderNode *node;
|
||||
GdkTexture *texture;
|
||||
|
||||
paintable = gtk_picture_get_paintable (GTK_PICTURE (self->picture));
|
||||
if (paintable == NULL ||
|
||||
gdk_paintable_get_intrinsic_width (paintable) <= 0 ||
|
||||
gdk_paintable_get_intrinsic_height (paintable) <= 0)
|
||||
return NULL;
|
||||
|
||||
snapshot = gtk_snapshot_new ();
|
||||
gdk_paintable_snapshot (paintable, snapshot, gdk_paintable_get_intrinsic_width (paintable), gdk_paintable_get_intrinsic_height (paintable));
|
||||
node = gtk_snapshot_free_to_node (snapshot);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
static GdkTexture *
|
||||
create_texture (NodeEditorWindow *self)
|
||||
{
|
||||
GskRenderer *renderer;
|
||||
GskRenderNode *node;
|
||||
GdkTexture *texture;
|
||||
|
||||
node = create_node (self);
|
||||
if (node == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -686,58 +670,6 @@ create_texture (NodeEditorWindow *self)
|
||||
return texture;
|
||||
}
|
||||
|
||||
#ifdef CAIRO_HAS_SVG_SURFACE
|
||||
static cairo_status_t
|
||||
cairo_serializer_write (gpointer user_data,
|
||||
const unsigned char *data,
|
||||
unsigned int length)
|
||||
{
|
||||
g_byte_array_append (user_data, data, length);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static GBytes *
|
||||
create_svg (GskRenderNode *node,
|
||||
GError **error)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
graphene_rect_t bounds;
|
||||
GByteArray *array;
|
||||
|
||||
gsk_render_node_get_bounds (node, &bounds);
|
||||
array = g_byte_array_new ();
|
||||
|
||||
surface = cairo_svg_surface_create_for_stream (cairo_serializer_write,
|
||||
array,
|
||||
bounds.size.width,
|
||||
bounds.size.height);
|
||||
cairo_svg_surface_set_document_unit (surface, CAIRO_SVG_UNIT_PX);
|
||||
cairo_surface_set_device_offset (surface, -bounds.origin.x, -bounds.origin.y);
|
||||
|
||||
cr = cairo_create (surface);
|
||||
gsk_render_node_draw (node, cr);
|
||||
cairo_destroy (cr);
|
||||
|
||||
cairo_surface_finish (surface);
|
||||
if (cairo_surface_status (surface) == CAIRO_STATUS_SUCCESS)
|
||||
{
|
||||
cairo_surface_destroy (surface);
|
||||
return g_byte_array_free_to_bytes (array);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_set_error (error,
|
||||
G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"%s", cairo_status_to_string (cairo_surface_status (surface)));
|
||||
cairo_surface_destroy (surface);
|
||||
g_byte_array_unref (array);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static GdkTexture *
|
||||
create_cairo_texture (NodeEditorWindow *self)
|
||||
{
|
||||
@@ -770,140 +702,50 @@ create_cairo_texture (NodeEditorWindow *self)
|
||||
}
|
||||
|
||||
static void
|
||||
export_image_saved_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!g_file_replace_contents_finish (G_FILE (source), result, NULL, &error))
|
||||
{
|
||||
GtkAlertDialog *alert;
|
||||
|
||||
alert = gtk_alert_dialog_new ("Exporting to image failed");
|
||||
gtk_alert_dialog_set_detail (alert, error->message);
|
||||
gtk_alert_dialog_show (alert, NULL);
|
||||
g_object_unref (alert);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
export_image_response_cb (GObject *source,
|
||||
export_image_response_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
void *user_data)
|
||||
{
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
GskRenderNode *node = user_data;
|
||||
GdkTexture *texture = user_data;
|
||||
GFile *file;
|
||||
char *uri;
|
||||
GBytes *bytes;
|
||||
|
||||
file = gtk_file_dialog_save_finish (dialog, result, NULL);
|
||||
if (file == NULL)
|
||||
if (file)
|
||||
{
|
||||
gsk_render_node_unref (node);
|
||||
return;
|
||||
}
|
||||
|
||||
uri = g_file_get_uri (file);
|
||||
#ifdef CAIRO_HAS_SVG_SURFACE
|
||||
if (g_str_has_suffix (uri, "svg"))
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
bytes = create_svg (node, &error);
|
||||
if (bytes == NULL)
|
||||
if (!gdk_texture_save_to_png (texture, g_file_peek_path (file)))
|
||||
{
|
||||
GtkAlertDialog *alert;
|
||||
|
||||
alert = gtk_alert_dialog_new ("Exporting to image failed");
|
||||
gtk_alert_dialog_set_detail (alert, error->message);
|
||||
gtk_alert_dialog_show (alert, NULL);
|
||||
gtk_alert_dialog_show (alert, GTK_WINDOW (gtk_window_get_transient_for (GTK_WINDOW (dialog))));
|
||||
g_object_unref (alert);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
GdkTexture *texture;
|
||||
GskRenderer *renderer;
|
||||
|
||||
renderer = gsk_gl_renderer_new ();
|
||||
if (!gsk_renderer_realize (renderer, NULL, NULL))
|
||||
{
|
||||
g_object_unref (renderer);
|
||||
renderer = gsk_cairo_renderer_new ();
|
||||
if (!gsk_renderer_realize (renderer, NULL, NULL))
|
||||
{
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
texture = gsk_renderer_render_texture (renderer, node, NULL);
|
||||
gsk_renderer_unrealize (renderer);
|
||||
g_object_unref (renderer);
|
||||
|
||||
if (g_str_has_suffix (uri, "tiff"))
|
||||
bytes = gdk_texture_save_to_tiff_bytes (texture);
|
||||
else
|
||||
bytes = gdk_texture_save_to_png_bytes (texture);
|
||||
g_object_unref (texture);
|
||||
g_object_unref (file);
|
||||
}
|
||||
g_free (uri);
|
||||
|
||||
if (bytes)
|
||||
{
|
||||
g_file_replace_contents_bytes_async (file,
|
||||
bytes,
|
||||
NULL,
|
||||
FALSE,
|
||||
0,
|
||||
NULL,
|
||||
export_image_saved_cb,
|
||||
NULL);
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
gsk_render_node_unref (node);
|
||||
g_object_unref (file);
|
||||
g_object_unref (texture);
|
||||
}
|
||||
|
||||
static void
|
||||
export_image_cb (GtkWidget *button,
|
||||
NodeEditorWindow *self)
|
||||
{
|
||||
GskRenderNode *node;
|
||||
GdkTexture *texture;
|
||||
GtkFileDialog *dialog;
|
||||
GtkFileFilter *filter;
|
||||
GListStore *filters;
|
||||
|
||||
node = create_node (self);
|
||||
if (node == NULL)
|
||||
texture = create_texture (self);
|
||||
if (texture == NULL)
|
||||
return;
|
||||
|
||||
filters = g_list_store_new (GTK_TYPE_FILE_FILTER);
|
||||
filter = gtk_file_filter_new ();
|
||||
gtk_file_filter_add_mime_type (filter, "image/png");
|
||||
g_list_store_append (filters, filter);
|
||||
g_object_unref (filter);
|
||||
filter = gtk_file_filter_new ();
|
||||
gtk_file_filter_add_mime_type (filter, "image/svg+xml");
|
||||
g_list_store_append (filters, filter);
|
||||
g_object_unref (filter);
|
||||
filter = gtk_file_filter_new ();
|
||||
gtk_file_filter_add_mime_type (filter, "image/tiff");
|
||||
g_list_store_append (filters, filter);
|
||||
g_object_unref (filter);
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, "");
|
||||
gtk_file_dialog_set_initial_name (dialog, "example.png");
|
||||
gtk_file_dialog_set_filters (dialog, G_LIST_MODEL (filters));
|
||||
gtk_file_dialog_save (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (button))),
|
||||
NULL,
|
||||
export_image_response_cb, node);
|
||||
g_object_unref (filters);
|
||||
export_image_response_cb, texture);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ if not meson.is_cross_build() and build_machine.cpu_family() != 'arm' and build_
|
||||
else
|
||||
widgetfactory_resources = gnome.compile_resources('widgetfactory_resources',
|
||||
'widget-factory.gresource.xml',
|
||||
source_dir: meson.current_source_dir(),
|
||||
source_dir: '.',
|
||||
)
|
||||
endif
|
||||
|
||||
|
||||
@@ -66,10 +66,6 @@ You can compile the program above with GCC using:
|
||||
gcc $( pkg-config --cflags gtk4 ) -o example-0 example-0.c $( pkg-config --libs gtk4 )
|
||||
```
|
||||
|
||||
**Note**: If the above compilation does not work due to an error regarding `G_APPLICATION_DEFAULT_FLAGS`
|
||||
this could be due to your OS providing an older version of GLib. For GLib versions older than 2.74 you
|
||||
will need to replace `G_APPLICATION_DEFAULT_FLAGS` with `G_APPLICATION_FLAGS_NONE` in this example, and
|
||||
others in this documentation.
|
||||
For more information on how to compile a GTK application, please
|
||||
refer to the [Compiling GTK Applications](compiling.html)
|
||||
section in this reference.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
app2_resources = gnome.compile_resources('exampleapp2_resources',
|
||||
'exampleapp.gresource.xml',
|
||||
source_dir: meson.current_source_dir())
|
||||
source_dir: '.')
|
||||
|
||||
executable('exampleapp2',
|
||||
'exampleapp.c', 'exampleappwin.c', 'main.c', app2_resources,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
app3_resources = gnome.compile_resources('exampleapp3_resources',
|
||||
'exampleapp.gresource.xml',
|
||||
source_dir: meson.current_source_dir())
|
||||
source_dir: '.')
|
||||
|
||||
executable('exampleapp3',
|
||||
'exampleapp.c', 'exampleappwin.c', 'main.c', app3_resources,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
app4_resources = gnome.compile_resources('exampleapp4_resources',
|
||||
'exampleapp.gresource.xml',
|
||||
source_dir: meson.current_source_dir())
|
||||
source_dir: '.')
|
||||
|
||||
executable('exampleapp4',
|
||||
'exampleapp.c', 'exampleappwin.c', 'main.c', app4_resources,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
app5_resources = gnome.compile_resources('exampleapp5_resources',
|
||||
'exampleapp.gresource.xml',
|
||||
source_dir: meson.current_source_dir())
|
||||
source_dir: '.')
|
||||
|
||||
app5_schemas = gnome.compile_schemas()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
app6_resources = gnome.compile_resources('exampleapp6_resources',
|
||||
'exampleapp.gresource.xml',
|
||||
source_dir: meson.current_source_dir())
|
||||
source_dir: '.')
|
||||
|
||||
app6_schemas = gnome.compile_schemas()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
app7_resources = gnome.compile_resources('exampleapp7_resources',
|
||||
'exampleapp.gresource.xml',
|
||||
source_dir: meson.current_source_dir())
|
||||
source_dir: '.')
|
||||
|
||||
app7_schemas = gnome.compile_schemas()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
app8_resources = gnome.compile_resources('exampleapp8 resources',
|
||||
'exampleapp.gresource.xml',
|
||||
source_dir: meson.current_source_dir())
|
||||
source_dir: '.')
|
||||
|
||||
app8_schemas = gnome.compile_schemas()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
app9_resources = gnome.compile_resources('exampleapp9_resources',
|
||||
'exampleapp.gresource.xml',
|
||||
source_dir: meson.current_source_dir())
|
||||
source_dir: '.')
|
||||
|
||||
app9_schemas = gnome.compile_schemas()
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
bp_resources = gnome.compile_resources('bloatpad_resources',
|
||||
'bloatpad.gresources.xml',
|
||||
source_dir: meson.current_source_dir())
|
||||
source_dir: '.')
|
||||
|
||||
executable('bloatpad', 'bloatpad.c', bp_resources, dependencies: libgtk_dep, c_args: common_cflags)
|
||||
|
||||
@@ -60,11 +60,7 @@ GdkDebugFlags gdk_display_get_debug_flags (GdkDisplay *display);
|
||||
void gdk_display_set_debug_flags (GdkDisplay *display,
|
||||
GdkDebugFlags flags);
|
||||
|
||||
#ifdef GLIB_USING_SYSTEM_PRINTF
|
||||
#define gdk_debug_message(format, ...) fprintf (stderr, format "\n", ##__VA_ARGS__)
|
||||
#else
|
||||
#define gdk_debug_message(format, ...) g_fprintf (stderr, format "\n", ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
|
||||
|
||||
+2
-15
@@ -410,19 +410,12 @@ gdk_display_manager_open_display (GdkDisplayManager *manager,
|
||||
{
|
||||
const char *backend = backends[i];
|
||||
gboolean any = g_str_equal (backend, "*");
|
||||
gboolean found = FALSE;
|
||||
|
||||
if (!allow_any && !any && !strstr (allowed_backends, backend))
|
||||
{
|
||||
GDK_DEBUG (MISC, "Skipping %s backend", backend);
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
|
||||
for (j = 0; gdk_backends[j].name != NULL; j++)
|
||||
{
|
||||
if (g_str_equal (backend, gdk_backends[j].name))
|
||||
found = TRUE;
|
||||
|
||||
if ((any && allow_any) ||
|
||||
(any && strstr (allowed_backends, gdk_backends[j].name)) ||
|
||||
g_str_equal (backend, gdk_backends[j].name))
|
||||
@@ -430,15 +423,9 @@ gdk_display_manager_open_display (GdkDisplayManager *manager,
|
||||
GDK_DEBUG (MISC, "Trying %s backend", gdk_backends[j].name);
|
||||
display = gdk_backends[j].open_display (name);
|
||||
if (display)
|
||||
{
|
||||
GDK_DEBUG (MISC, "Using %s display %s", gdk_backends[j].name, gdk_display_get_name (display));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found && !display)
|
||||
g_warning ("No such backend: %s", backend);
|
||||
}
|
||||
|
||||
g_strfreev (backends);
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@
|
||||
* for the synchronization being implemented, the clock will process a frame and
|
||||
* emit signals for each phase that has been requested. (See the signals of the
|
||||
* `GdkFrameClock` class for documentation of the phases.
|
||||
* %GDK_FRAME_CLOCK_PHASE_UPDATE and the [signal@Gdk.FrameClock::update] signal
|
||||
* %GDK_FRAME_CLOCK_PHASE_UPDATE and the [signal@GdkFrameClock::update] signal
|
||||
* are most interesting for application writers, and are used to update the
|
||||
* animations, using the frame time given by [method@Gdk.FrameClock.get_frame_time].
|
||||
*
|
||||
@@ -60,7 +60,7 @@
|
||||
* are called at a “similar” time get the same value. This means that
|
||||
* if different animations are timed by looking at the difference in
|
||||
* time between an initial value from [method@Gdk.FrameClock.get_frame_time]
|
||||
* and the value inside the [signal@Gdk.FrameClock::update] signal of the clock,
|
||||
* and the value inside the [signal@GdkFrameClock::update] signal of the clock,
|
||||
* they will stay exactly synchronized.
|
||||
*/
|
||||
|
||||
|
||||
@@ -584,6 +584,8 @@ gdk_frame_clock_paint_idle (void *data)
|
||||
{
|
||||
priv->requested &= ~GDK_FRAME_CLOCK_PHASE_LAYOUT;
|
||||
_gdk_frame_clock_emit_layout (clock);
|
||||
if (priv->requested & GDK_FRAME_CLOCK_PHASE_LAYOUT)
|
||||
g_print ("looping in layout %d\n", iter);
|
||||
}
|
||||
if (iter == 5)
|
||||
g_warning ("gdk-frame-clock: layout continuously requested, giving up after 4 tries");
|
||||
@@ -809,3 +811,12 @@ _gdk_frame_clock_idle_new (void)
|
||||
|
||||
return GDK_FRAME_CLOCK (clock);
|
||||
}
|
||||
|
||||
GdkFrameClockPhase
|
||||
gdk_frame_clock_get_current_phase (GdkFrameClock *clock)
|
||||
{
|
||||
GdkFrameClockIdle *clock_idle = GDK_FRAME_CLOCK_IDLE (clock);
|
||||
GdkFrameClockIdlePrivate *priv = clock_idle->priv;
|
||||
|
||||
return priv->phase;
|
||||
}
|
||||
|
||||
@@ -127,6 +127,8 @@ void _gdk_frame_clock_emit_paint (GdkFrameClock *frame_clock);
|
||||
void _gdk_frame_clock_emit_after_paint (GdkFrameClock *frame_clock);
|
||||
void _gdk_frame_clock_emit_resume_events (GdkFrameClock *frame_clock);
|
||||
|
||||
GdkFrameClockPhase gdk_frame_clock_get_current_phase (GdkFrameClock *frame_clock);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_FRAME_CLOCK_PRIVATE_H__ */
|
||||
|
||||
@@ -335,7 +335,6 @@ gdk_gl_texture_determine_format (GdkGLTexture *self)
|
||||
switch (internal_format)
|
||||
{
|
||||
case GL_RGB8:
|
||||
case GL_RGB:
|
||||
texture->format = GDK_MEMORY_R8G8B8;
|
||||
break;
|
||||
|
||||
|
||||
@@ -178,10 +178,10 @@ gdk_memory_texture_new_subtexture (GdkMemoryTexture *source,
|
||||
GBytes *bytes;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_MEMORY_TEXTURE (source), NULL);
|
||||
g_return_val_if_fail (x >= 0 && x < GDK_TEXTURE (source)->width, NULL);
|
||||
g_return_val_if_fail (y >= 0 && y < GDK_TEXTURE (source)->height, NULL);
|
||||
g_return_val_if_fail (width > 0 && x + width <= GDK_TEXTURE (source)->width, NULL);
|
||||
g_return_val_if_fail (height > 0 && y + height <= GDK_TEXTURE (source)->height, NULL);
|
||||
g_return_val_if_fail (x >= 0 || x < GDK_TEXTURE (source)->width, NULL);
|
||||
g_return_val_if_fail (y >= 0 || y < GDK_TEXTURE (source)->height, NULL);
|
||||
g_return_val_if_fail (width > 0 || x + width <= GDK_TEXTURE (source)->width, NULL);
|
||||
g_return_val_if_fail (height > 0 || y + height <= GDK_TEXTURE (source)->height, NULL);
|
||||
|
||||
texture = GDK_TEXTURE (source);
|
||||
bpp = gdk_memory_format_bytes_per_pixel (texture->format);
|
||||
|
||||
+5
-5
@@ -50,7 +50,7 @@ void gtk_snapshot_pop (GdkSnapshot
|
||||
* to do, it is suggested that you scale your paintable ignoring any potential
|
||||
* aspect ratio.
|
||||
*
|
||||
* The contents that a `GdkPaintable` produces may depend on the [class@Gdk.Snapshot]
|
||||
* The contents that a `GdkPaintable` produces may depend on the [class@GdkSnapshot]
|
||||
* passed to it. For example, paintables may decide to use more detailed images
|
||||
* on higher resolution screens or when OpenGL is available. A `GdkPaintable`
|
||||
* will however always produce the same output for the same snapshot.
|
||||
@@ -58,7 +58,7 @@ void gtk_snapshot_pop (GdkSnapshot
|
||||
* A `GdkPaintable` may change its contents, meaning that it will now produce
|
||||
* a different output with the same snapshot. Once that happens, it will call
|
||||
* [method@Gdk.Paintable.invalidate_contents] which will emit the
|
||||
* [signal@Gdk.Paintable::invalidate-contents] signal. If a paintable is known
|
||||
* [signal@GdkPaintable::invalidate-contents] signal. If a paintable is known
|
||||
* to never change its contents, it will set the %GDK_PAINTABLE_STATIC_CONTENTS
|
||||
* flag. If a consumer cannot deal with changing contents, it may call
|
||||
* [method@Gdk.Paintable.get_current_image] which will return a static
|
||||
@@ -69,7 +69,7 @@ void gtk_snapshot_pop (GdkSnapshot
|
||||
* can use this information to layout thepaintable appropriately. Just like the
|
||||
* contents, the size of a paintable can change. A paintable will indicate this
|
||||
* by calling [method@Gdk.Paintable.invalidate_size] which will emit the
|
||||
* [signal@Gdk.Paintable::invalidate-size] signal. And just like for contents,
|
||||
* [signal@GdkPaintable::invalidate-size] signal. And just like for contents,
|
||||
* if a paintable is known to never change its size, it will set the
|
||||
* %GDK_PAINTABLE_STATIC_SIZE flag.
|
||||
*
|
||||
@@ -529,7 +529,7 @@ gdk_paintable_compute_concrete_size (GdkPaintable *paintable,
|
||||
* the missing dimension is calculated from the present
|
||||
* dimension and the intrinsic aspect ratio.
|
||||
* Otherwise, the missing dimension is taken from the default
|
||||
* object size.
|
||||
* object size.
|
||||
*/
|
||||
if (image_width)
|
||||
*concrete_width = image_width;
|
||||
@@ -559,7 +559,7 @@ gdk_paintable_compute_concrete_size (GdkPaintable *paintable,
|
||||
* dimensions, the missing dimension is taken from the object's intrinsic
|
||||
* dimensions.
|
||||
* Otherwise, the missing dimension of the concrete object size is taken
|
||||
* from the default object size.
|
||||
* from the default object size.
|
||||
*/
|
||||
if (specified_width)
|
||||
{
|
||||
|
||||
+3
-3
@@ -37,10 +37,10 @@ G_DECLARE_INTERFACE (GdkPaintable, gdk_paintable, GDK, PAINTABLE, GObject)
|
||||
/**
|
||||
* GdkPaintableFlags:
|
||||
* @GDK_PAINTABLE_STATIC_SIZE: The size is immutable.
|
||||
* The [signal@Gdk.Paintable::invalidate-size] signal will never be
|
||||
* The [signal@GdkPaintable::invalidate-size] signal will never be
|
||||
* emitted.
|
||||
* @GDK_PAINTABLE_STATIC_CONTENTS: The content is immutable.
|
||||
* The [signal@Gdk.Paintable::invalidate-contents] signal will never be
|
||||
* The [signal@GdkPaintable::invalidate-contents] signal will never be
|
||||
* emitted.
|
||||
*
|
||||
* Flags about a paintable object.
|
||||
@@ -97,7 +97,7 @@ struct _GdkPaintableInterface
|
||||
double height);
|
||||
/* get the current contents in an immutable form (optional) */
|
||||
GdkPaintable * (* get_current_image) (GdkPaintable *paintable);
|
||||
|
||||
|
||||
/* get flags for potential optimizations (optional) */
|
||||
GdkPaintableFlags (* get_flags) (GdkPaintable *paintable);
|
||||
/* preferred width of paintable or 0 if it has no width (optional) */
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@
|
||||
* The `GdkPopup` is positioned relative to its parent surface.
|
||||
*
|
||||
* `GdkPopup`s are typically used to implement menus and similar popups.
|
||||
* They can be modal, which is indicated by the [property@Gdk.Popup:autohide]
|
||||
* They can be modal, which is indicated by the [property@GdkPopup:autohide]
|
||||
* property.
|
||||
*/
|
||||
|
||||
@@ -113,7 +113,7 @@ gdk_popup_default_init (GdkPopupInterface *iface)
|
||||
* otherwise it will change position according to @layout.
|
||||
*
|
||||
* After calling this function, the result should be handled in response
|
||||
* to the [signal@Gdk.Surface::layout] signal being emitted. The resulting
|
||||
* to the [signal@GdkSurface::layout] signal being emitted. The resulting
|
||||
* popup position can be queried using [method@Gdk.Popup.get_position_x],
|
||||
* [method@Gdk.Popup.get_position_y], and the resulting size will be sent as
|
||||
* parameters in the layout signal. Use [method@Gdk.Popup.get_rect_anchor]
|
||||
|
||||
+1
-1
@@ -395,7 +395,7 @@ gdk_texture_new_for_pixbuf (GdkPixbuf *pixbuf)
|
||||
|
||||
bytes = g_bytes_new_with_free_func (gdk_pixbuf_get_pixels (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf)
|
||||
* (gsize) gdk_pixbuf_get_rowstride (pixbuf),
|
||||
* gdk_pixbuf_get_rowstride (pixbuf),
|
||||
g_object_unref,
|
||||
g_object_ref (pixbuf));
|
||||
texture = gdk_memory_texture_new (gdk_pixbuf_get_width (pixbuf),
|
||||
|
||||
+1
-1
@@ -131,7 +131,7 @@ gdk_gresource_xml = configure_file(output: 'gdk.gresource.xml',
|
||||
|
||||
gdkresources = gnome.compile_resources('gdkresources',
|
||||
gdk_gresource_xml,
|
||||
source_dir: meson.current_source_dir(),
|
||||
source_dir: '.',
|
||||
c_name: '_gdk',
|
||||
extra_args: '--manual-register',
|
||||
)
|
||||
|
||||
@@ -586,6 +586,13 @@ _gdk_wayland_display_open (const char *display_name)
|
||||
|
||||
GDK_DEBUG (MISC, "opening display %s", display_name ? display_name : "");
|
||||
|
||||
/* If this variable is unset then wayland initialisation will surely
|
||||
* fail, logging a fatal error in the process. Save ourselves from
|
||||
* that.
|
||||
*/
|
||||
if (g_getenv ("XDG_RUNTIME_DIR") == NULL)
|
||||
return NULL;
|
||||
|
||||
wl_log_set_handler_client (log_handler);
|
||||
|
||||
wl_display = wl_display_connect (display_name);
|
||||
@@ -1075,9 +1082,6 @@ gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
|
||||
g_assert (display_wayland);
|
||||
g_assert (display_wayland->shm);
|
||||
|
||||
if (size == 0)
|
||||
size = 24;
|
||||
|
||||
if (g_strcmp0 (name, display_wayland->cursor_theme_name) == 0 &&
|
||||
display_wayland->cursor_theme_size == size)
|
||||
return;
|
||||
|
||||
@@ -65,9 +65,6 @@ gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
|
||||
int dx = impl->pending_buffer_offset_x;
|
||||
int dy = impl->pending_buffer_offset_y;
|
||||
|
||||
impl->pending_buffer_offset_x = 0;
|
||||
impl->pending_buffer_offset_y = 0;
|
||||
|
||||
gdk_wayland_surface_sync (surface);
|
||||
gdk_wayland_surface_request_frame (surface);
|
||||
|
||||
@@ -121,7 +118,7 @@ gdk_wayland_display_init_gl (GdkDisplay *display,
|
||||
{
|
||||
GdkWaylandDisplay *self = GDK_WAYLAND_DISPLAY (display);
|
||||
|
||||
if (!gdk_display_init_egl (display,
|
||||
if (!gdk_display_init_egl (display,
|
||||
EGL_PLATFORM_WAYLAND_EXT,
|
||||
self->wl_display,
|
||||
TRUE,
|
||||
|
||||
@@ -398,11 +398,7 @@ gdk_wayland_popup_handle_configure (GdkWaylandSurface *wayland_surface)
|
||||
g_warn_if_reached ();
|
||||
|
||||
if (wayland_popup->pending.has_repositioned_token)
|
||||
{
|
||||
wayland_popup->received_reposition_token =
|
||||
wayland_popup->pending.repositioned_token;
|
||||
wayland_popup->pending.has_repositioned_token = FALSE;
|
||||
}
|
||||
wayland_popup->received_reposition_token = wayland_popup->pending.repositioned_token;
|
||||
|
||||
switch (wayland_popup->state)
|
||||
{
|
||||
@@ -747,7 +743,9 @@ create_dynamic_positioner (GdkWaylandPopup *wayland_popup,
|
||||
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
||||
GdkRectangle geometry;
|
||||
uint32_t constraint_adjustment = ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_NONE;
|
||||
GdkRectangle anchor_rect;
|
||||
const GdkRectangle *anchor_rect;
|
||||
int real_anchor_rect_x, real_anchor_rect_y;
|
||||
int anchor_rect_width, anchor_rect_height;
|
||||
int rect_anchor_dx;
|
||||
int rect_anchor_dy;
|
||||
GdkGravity rect_anchor;
|
||||
@@ -773,24 +771,12 @@ create_dynamic_positioner (GdkWaylandPopup *wayland_popup,
|
||||
|
||||
gdk_wayland_surface_get_window_geometry (surface->parent, &parent_geometry);
|
||||
|
||||
anchor_rect = *gdk_popup_layout_get_anchor_rect (layout);
|
||||
anchor_rect = gdk_popup_layout_get_anchor_rect (layout);
|
||||
real_anchor_rect_x = anchor_rect->x - parent_geometry.x;
|
||||
real_anchor_rect_y = anchor_rect->y - parent_geometry.y;
|
||||
|
||||
/* Wayland protocol requires that the anchor rect is specified
|
||||
* wrt. to the parent geometry, and that it is non-empty and
|
||||
* contained in the parent geometry.
|
||||
*/
|
||||
if (!gdk_rectangle_intersect (&parent_geometry, &anchor_rect, &anchor_rect))
|
||||
{
|
||||
anchor_rect.x = 0;
|
||||
anchor_rect.y = 0;
|
||||
anchor_rect.width = 1;
|
||||
anchor_rect.height = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
anchor_rect.x -= parent_geometry.x;
|
||||
anchor_rect.y -= parent_geometry.y;
|
||||
}
|
||||
anchor_rect_width = MAX (anchor_rect->width, 1);
|
||||
anchor_rect_height = MAX (anchor_rect->height, 1);
|
||||
|
||||
gdk_popup_layout_get_offset (layout, &rect_anchor_dx, &rect_anchor_dy);
|
||||
|
||||
@@ -811,10 +797,10 @@ create_dynamic_positioner (GdkWaylandPopup *wayland_popup,
|
||||
|
||||
xdg_positioner_set_size (positioner, geometry.width, geometry.height);
|
||||
xdg_positioner_set_anchor_rect (positioner,
|
||||
anchor_rect.x,
|
||||
anchor_rect.y,
|
||||
anchor_rect.width,
|
||||
anchor_rect.height);
|
||||
real_anchor_rect_x,
|
||||
real_anchor_rect_y,
|
||||
anchor_rect_width,
|
||||
anchor_rect_height);
|
||||
xdg_positioner_set_offset (positioner, rect_anchor_dx, rect_anchor_dy);
|
||||
|
||||
anchor = rect_anchor_to_anchor (rect_anchor);
|
||||
@@ -865,10 +851,10 @@ create_dynamic_positioner (GdkWaylandPopup *wayland_popup,
|
||||
|
||||
zxdg_positioner_v6_set_size (positioner, geometry.width, geometry.height);
|
||||
zxdg_positioner_v6_set_anchor_rect (positioner,
|
||||
anchor_rect.x,
|
||||
anchor_rect.y,
|
||||
anchor_rect.width,
|
||||
anchor_rect.height);
|
||||
real_anchor_rect_x,
|
||||
real_anchor_rect_y,
|
||||
anchor_rect_width,
|
||||
anchor_rect_height);
|
||||
zxdg_positioner_v6_set_offset (positioner,
|
||||
rect_anchor_dx,
|
||||
rect_anchor_dy);
|
||||
@@ -982,9 +968,6 @@ gdk_wayland_surface_create_xdg_popup (GdkWaylandPopup *wayland_popup,
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
wayland_popup->received_reposition_token = 0;
|
||||
wayland_popup->reposition_token = 0;
|
||||
|
||||
gdk_popup_layout_get_shadow_width (layout,
|
||||
&impl->shadow_left,
|
||||
&impl->shadow_right,
|
||||
|
||||
@@ -561,14 +561,8 @@ gdk_wayland_surface_attach_image (GdkSurface *surface,
|
||||
/* Attach this new buffer to the surface */
|
||||
wl_surface_attach (impl->display_server.wl_surface,
|
||||
_gdk_wayland_shm_surface_get_wl_buffer (cairo_surface),
|
||||
0, 0);
|
||||
|
||||
if ((impl->pending_buffer_offset_x || impl->pending_buffer_offset_y) &&
|
||||
wl_surface_get_version (impl->display_server.wl_surface) >=
|
||||
WL_SURFACE_OFFSET_SINCE_VERSION)
|
||||
wl_surface_offset (impl->display_server.wl_surface,
|
||||
impl->pending_buffer_offset_x,
|
||||
impl->pending_buffer_offset_y);
|
||||
impl->pending_buffer_offset_x,
|
||||
impl->pending_buffer_offset_y);
|
||||
impl->pending_buffer_offset_x = 0;
|
||||
impl->pending_buffer_offset_y = 0;
|
||||
|
||||
@@ -977,15 +971,6 @@ gdk_wayland_surface_hide_surface (GdkSurface *surface)
|
||||
impl->display_server.egl_window = NULL;
|
||||
}
|
||||
|
||||
impl->awaiting_frame = FALSE;
|
||||
if (impl->awaiting_frame_frozen)
|
||||
{
|
||||
impl->awaiting_frame_frozen = FALSE;
|
||||
gdk_surface_thaw_updates (surface);
|
||||
}
|
||||
|
||||
GDK_WAYLAND_SURFACE_GET_CLASS (impl)->hide_surface (impl);
|
||||
|
||||
if (impl->display_server.xdg_surface)
|
||||
{
|
||||
xdg_surface_destroy (impl->display_server.xdg_surface);
|
||||
@@ -1004,6 +989,15 @@ gdk_wayland_surface_hide_surface (GdkSurface *surface)
|
||||
impl->initial_configure_received = FALSE;
|
||||
}
|
||||
|
||||
impl->awaiting_frame = FALSE;
|
||||
if (impl->awaiting_frame_frozen)
|
||||
{
|
||||
impl->awaiting_frame_frozen = FALSE;
|
||||
gdk_surface_thaw_updates (surface);
|
||||
}
|
||||
|
||||
GDK_WAYLAND_SURFACE_GET_CLASS (impl)->hide_surface (impl);
|
||||
|
||||
g_clear_pointer (&impl->display_server.wl_surface, wl_surface_destroy);
|
||||
|
||||
g_slist_free (impl->display_server.outputs);
|
||||
|
||||
@@ -991,7 +991,7 @@ gdk_wayland_toplevel_set_startup_id (GdkWaylandToplevel *toplevel,
|
||||
startup_id = free_me;
|
||||
}
|
||||
|
||||
if (display->xdg_activation && startup_id)
|
||||
if (startup_id)
|
||||
xdg_activation_v1_activate (display->xdg_activation,
|
||||
startup_id,
|
||||
surface->display_server.wl_surface);
|
||||
|
||||
@@ -1005,8 +1005,7 @@ gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon,
|
||||
} bmi;
|
||||
HDC hdc;
|
||||
uint8_t *pixels, *bits;
|
||||
int x, y, w, h;
|
||||
gsize rowstride;
|
||||
int rowstride, x, y, w, h;
|
||||
|
||||
if (!GDI_CALL (GetIconInfo, (hicon, &ii)))
|
||||
return NULL;
|
||||
@@ -1058,7 +1057,7 @@ gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon,
|
||||
no_alpha = FALSE;
|
||||
pixels += 4;
|
||||
}
|
||||
pixels += rowstride - w * 4;
|
||||
pixels += (w * 4 - rowstride);
|
||||
}
|
||||
|
||||
/* mask */
|
||||
@@ -1073,7 +1072,7 @@ gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon,
|
||||
pixels[3] = 255 - bits[(x + y * w) * 4];
|
||||
pixels += 4;
|
||||
}
|
||||
pixels += rowstride - w * 4;
|
||||
pixels += (w * 4 - rowstride);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1147,7 +1146,7 @@ gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon,
|
||||
xorp++;
|
||||
}
|
||||
}
|
||||
pixels += rowstride - w * 4;
|
||||
pixels += (w * 4 - rowstride);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
*
|
||||
* gdkglcontext-win32-wgl-private.c: Win32 specific OpenGL wrappers
|
||||
*
|
||||
* Copyright © 2023 Chun-wei Fan
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These wrapper functions are used when we don't want to use the wgl*() core functions
|
||||
* that we acquire via libepoxy (such as when we are disposing the Gdk(W)GLContext from,
|
||||
* different threads, so for these calls, we are actually linking to the system's/ICD
|
||||
* opengl32.dll directly, so that we are guaranteed that the "right" versions of these
|
||||
* WGL calls are carried out. This must be a separate source file because we can't include
|
||||
* the system's GL/gl.h with epoxy/(w)gl.h together in a single source file. We should not
|
||||
* need to use these when we are creating/initializing a WGL context in GDK, since we should
|
||||
* be in the same thread at this point.
|
||||
*/
|
||||
|
||||
#define DONT_INCLUDE_LIBEPOXY
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
|
||||
#include "gdkglcontext-win32.h"
|
||||
|
||||
void
|
||||
gdk_win32_private_wglDeleteContext (HGLRC hglrc)
|
||||
{
|
||||
wglDeleteContext (hglrc);
|
||||
}
|
||||
|
||||
HGLRC
|
||||
gdk_win32_private_wglGetCurrentContext (void)
|
||||
{
|
||||
return wglGetCurrentContext ();
|
||||
}
|
||||
|
||||
BOOL
|
||||
gdk_win32_private_wglMakeCurrent (HDC hdc,
|
||||
HGLRC hglrc)
|
||||
{
|
||||
return wglMakeCurrent (hdc, hglrc);
|
||||
}
|
||||
@@ -60,12 +60,12 @@ gdk_win32_gl_context_wgl_dispose (GObject *gobject)
|
||||
|
||||
if (context_wgl->wgl_context != NULL)
|
||||
{
|
||||
if (gdk_win32_private_wglGetCurrentContext () == context_wgl->wgl_context)
|
||||
gdk_win32_private_wglMakeCurrent (NULL, NULL);
|
||||
if (wglGetCurrentContext () == context_wgl->wgl_context)
|
||||
wglMakeCurrent (NULL, NULL);
|
||||
|
||||
GDK_NOTE (OPENGL, g_print ("Destroying WGL context\n"));
|
||||
|
||||
gdk_win32_private_wglDeleteContext (context_wgl->wgl_context);
|
||||
wglDeleteContext (context_wgl->wgl_context);
|
||||
context_wgl->wgl_context = NULL;
|
||||
}
|
||||
|
||||
@@ -628,7 +628,7 @@ gdk_win32_gl_context_wgl_realize (GdkGLContext *context,
|
||||
static gboolean
|
||||
gdk_win32_gl_context_wgl_clear_current (GdkGLContext *context)
|
||||
{
|
||||
return gdk_win32_private_wglMakeCurrent (NULL, NULL);
|
||||
return wglMakeCurrent (NULL, NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -636,7 +636,7 @@ gdk_win32_gl_context_wgl_is_current (GdkGLContext *context)
|
||||
{
|
||||
GdkWin32GLContextWGL *self = GDK_WIN32_GL_CONTEXT_WGL (context);
|
||||
|
||||
return self->wgl_context == gdk_win32_private_wglGetCurrentContext ();
|
||||
return self->wgl_context == wglGetCurrentContext ();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -654,7 +654,7 @@ gdk_win32_gl_context_wgl_make_current (GdkGLContext *context,
|
||||
else
|
||||
hdc = GDK_WIN32_SURFACE (surface)->hdc;
|
||||
|
||||
if (!gdk_win32_private_wglMakeCurrent (hdc, context_wgl->wgl_context))
|
||||
if (!wglMakeCurrent (hdc, context_wgl->wgl_context))
|
||||
return FALSE;
|
||||
|
||||
if (!surfaceless && display_win32->hasWglEXTSwapControl)
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#ifndef __GDK_WIN32_GL_CONTEXT__
|
||||
#define __GDK_WIN32_GL_CONTEXT__
|
||||
|
||||
#ifndef DONT_INCLUDE_LIBEPOXY
|
||||
#include <epoxy/gl.h>
|
||||
#include <epoxy/wgl.h>
|
||||
|
||||
@@ -32,18 +31,9 @@
|
||||
#include "gdkglcontextprivate.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdksurface.h"
|
||||
#else
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
# include <GL/gl.h>
|
||||
|
||||
# include <glib.h>
|
||||
#endif
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#ifndef DONT_INCLUDE_LIBEPOXY
|
||||
|
||||
#define GDK_WIN32_GL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WIN32_GL_CONTEXT, GdkWin32GLContextClass))
|
||||
#define GDK_WIN32_GL_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WIN32_GL_CONTEXT, GdkWin32GLContextClass))
|
||||
#define GDK_WIN32_IS_GL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WIN32_GL_CONTEXT))
|
||||
@@ -88,13 +78,6 @@ GType gdk_win32_gl_context_egl_get_type (void) G_GNUC_CONST;
|
||||
void
|
||||
_gdk_win32_surface_invalidate_egl_framebuffer (GdkSurface *surface);
|
||||
|
||||
#endif /* !DONT_INCLUDE_LIBEPOXY */
|
||||
|
||||
HGLRC gdk_win32_private_wglGetCurrentContext (void);
|
||||
BOOL gdk_win32_private_wglMakeCurrent (HDC hdc,
|
||||
HGLRC hglrc);
|
||||
void gdk_win32_private_wglDeleteContext (HGLRC hglrc);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_WIN32_GL_CONTEXT__ */
|
||||
|
||||
@@ -23,7 +23,6 @@ gdk_win32_sources = gdk_win32_public_sources + files([
|
||||
'gdkdevice-wintab.c',
|
||||
'gdkdrop-win32.c',
|
||||
'gdkglobals-win32.c',
|
||||
'gdkglcontext-win32-wgl-private.c',
|
||||
'gdkhdataoutputstream-win32.c',
|
||||
'gdkinput-dmanipulation.c',
|
||||
'gdkinput-winpointer.c',
|
||||
@@ -60,7 +59,6 @@ endif
|
||||
gdk_win32_deps = [
|
||||
pangowin32_dep, # FIXME
|
||||
cc.find_library('hid'),
|
||||
cc.find_library('opengl32'),
|
||||
]
|
||||
|
||||
libgdk_win32 = static_library('gdk-win32',
|
||||
|
||||
@@ -1358,7 +1358,6 @@ gdk_x11_surface_destroy (GdkSurface *surface,
|
||||
|
||||
unhook_surface_changed (surface);
|
||||
disconnect_frame_clock (surface);
|
||||
g_clear_handle_id (&impl->compute_size_source_id, g_source_remove);
|
||||
|
||||
if (impl->cairo_surface)
|
||||
{
|
||||
|
||||
+105
-109
@@ -260,7 +260,6 @@ node_supports_2d_transform (const GskRenderNode *node)
|
||||
case GSK_OPACITY_NODE:
|
||||
case GSK_COLOR_MATRIX_NODE:
|
||||
case GSK_TEXTURE_NODE:
|
||||
case GSK_TEXTURE_SCALE_NODE:
|
||||
case GSK_CROSS_FADE_NODE:
|
||||
case GSK_LINEAR_GRADIENT_NODE:
|
||||
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
|
||||
@@ -315,7 +314,6 @@ node_supports_transform (const GskRenderNode *node)
|
||||
case GSK_CAIRO_NODE:
|
||||
case GSK_BLEND_NODE:
|
||||
case GSK_BLUR_NODE:
|
||||
case GSK_MASK_NODE:
|
||||
return TRUE;
|
||||
|
||||
case GSK_SHADOW_NODE:
|
||||
@@ -874,21 +872,6 @@ gsk_gl_render_job_transform_bounds (GskGLRenderJob *job,
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_gl_render_job_untransform_bounds (GskGLRenderJob *job,
|
||||
const graphene_rect_t *rect,
|
||||
graphene_rect_t *out_rect)
|
||||
{
|
||||
GskTransform *transform;
|
||||
|
||||
transform = gsk_transform_invert (gsk_transform_ref (job->current_modelview->transform));
|
||||
|
||||
gsk_transform_transform_bounds (transform, rect, out_rect);
|
||||
|
||||
out_rect->origin.x -= job->offset_x;
|
||||
out_rect->origin.y -= job->offset_y;
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_gl_render_job_transform_rounded_rect (GskGLRenderJob *job,
|
||||
const GskRoundedRect *rect,
|
||||
@@ -3632,114 +3615,127 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
|
||||
int min_filter = min_filters[scaling_filter];
|
||||
int mag_filter = mag_filters[scaling_filter];
|
||||
int max_texture_size = job->command_queue->max_texture_size;
|
||||
graphene_rect_t clip_rect;
|
||||
GskGLRenderTarget *render_target;
|
||||
GskGLRenderOffscreen offscreen = {0};
|
||||
graphene_rect_t viewport;
|
||||
graphene_rect_t prev_viewport;
|
||||
graphene_matrix_t prev_projection;
|
||||
float prev_alpha;
|
||||
guint prev_fbo;
|
||||
guint texture_id;
|
||||
float u0, u1, v0, v1;
|
||||
GskTextureKey key;
|
||||
|
||||
gsk_gl_render_job_untransform_bounds (job, &job->current_clip->rect.bounds, &clip_rect);
|
||||
|
||||
if (!graphene_rect_intersection (bounds, &clip_rect, &clip_rect))
|
||||
return;
|
||||
|
||||
if G_UNLIKELY (clip_rect.size.width > max_texture_size ||
|
||||
clip_rect.size.height > max_texture_size)
|
||||
if (scaling_filter == GSK_SCALING_FILTER_LINEAR)
|
||||
{
|
||||
gsk_gl_render_job_visit_texture (job, texture, bounds);
|
||||
return;
|
||||
}
|
||||
|
||||
key.pointer = node;
|
||||
key.pointer_is_child = TRUE;
|
||||
key.parent_rect = clip_rect;
|
||||
key.scale_x = 1.;
|
||||
key.scale_y = 1.;
|
||||
key.filter = min_filter;
|
||||
|
||||
texture_id = gsk_gl_driver_lookup_texture (job->driver, &key);
|
||||
if (texture_id != 0)
|
||||
goto render_texture;
|
||||
|
||||
viewport = GRAPHENE_RECT_INIT (0, 0,
|
||||
clip_rect.size.width,
|
||||
clip_rect.size.height);
|
||||
|
||||
if (!gsk_gl_driver_create_render_target (job->driver,
|
||||
(int) ceilf (clip_rect.size.width),
|
||||
(int) ceilf (clip_rect.size.height),
|
||||
get_target_format (job, node),
|
||||
GL_LINEAR, GL_LINEAR,
|
||||
&render_target))
|
||||
if G_LIKELY (texture->width <= max_texture_size &&
|
||||
texture->height <= max_texture_size)
|
||||
{
|
||||
gsk_gl_render_job_visit_texture (job, texture, bounds);
|
||||
return;
|
||||
GskGLRenderTarget *render_target;
|
||||
GskGLRenderOffscreen offscreen = {0};
|
||||
graphene_rect_t viewport;
|
||||
graphene_rect_t prev_viewport;
|
||||
graphene_matrix_t prev_projection;
|
||||
float prev_alpha;
|
||||
guint prev_fbo;
|
||||
guint texture_id;
|
||||
|
||||
viewport = GRAPHENE_RECT_INIT (0, 0,
|
||||
bounds->size.width,
|
||||
bounds->size.height);
|
||||
|
||||
if (!gsk_gl_driver_create_render_target (job->driver,
|
||||
(int) ceilf (viewport.size.width),
|
||||
(int) ceilf (viewport.size.height),
|
||||
get_target_format (job, node),
|
||||
GL_LINEAR, GL_LINEAR,
|
||||
&render_target))
|
||||
{
|
||||
/* viewport is too big, slice the texture and try again */
|
||||
goto slice;
|
||||
}
|
||||
|
||||
gsk_gl_render_job_upload_texture (job, texture, min_filter, mag_filter, &offscreen);
|
||||
|
||||
g_assert (offscreen.texture_id);
|
||||
g_assert (offscreen.was_offscreen == FALSE);
|
||||
|
||||
gsk_gl_render_job_set_viewport (job, &viewport, &prev_viewport);
|
||||
gsk_gl_render_job_set_projection_from_rect (job, &viewport, &prev_projection);
|
||||
gsk_gl_render_job_set_modelview (job, NULL);
|
||||
prev_alpha = gsk_gl_render_job_set_alpha (job, 1.0f);
|
||||
gsk_gl_render_job_push_clip (job, &GSK_ROUNDED_RECT_INIT_FROM_RECT (viewport));
|
||||
|
||||
prev_fbo = gsk_gl_command_queue_bind_framebuffer (job->command_queue, render_target->framebuffer_id);
|
||||
gsk_gl_command_queue_clear (job->command_queue, 0, &viewport);
|
||||
|
||||
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
|
||||
gsk_gl_program_set_uniform_texture (job->current_program,
|
||||
UNIFORM_SHARED_SOURCE, 0,
|
||||
GL_TEXTURE_2D,
|
||||
GL_TEXTURE0,
|
||||
offscreen.texture_id);
|
||||
gsk_gl_render_job_draw_offscreen (job, &viewport, &offscreen);
|
||||
gsk_gl_render_job_end_draw (job);
|
||||
|
||||
gsk_gl_render_job_pop_clip (job);
|
||||
gsk_gl_render_job_pop_modelview (job);
|
||||
gsk_gl_render_job_set_viewport (job, &prev_viewport, NULL);
|
||||
gsk_gl_render_job_set_projection (job, &prev_projection);
|
||||
gsk_gl_render_job_set_alpha (job, prev_alpha);
|
||||
gsk_gl_command_queue_bind_framebuffer (job->command_queue, prev_fbo);
|
||||
|
||||
texture_id = gsk_gl_driver_release_render_target (job->driver, render_target, FALSE);
|
||||
|
||||
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
|
||||
gsk_gl_program_set_uniform_texture (job->current_program,
|
||||
UNIFORM_SHARED_SOURCE, 0,
|
||||
GL_TEXTURE_2D,
|
||||
GL_TEXTURE0,
|
||||
texture_id);
|
||||
gsk_gl_render_job_draw_offscreen_rect (job, bounds);
|
||||
gsk_gl_render_job_end_draw (job);
|
||||
}
|
||||
else
|
||||
slice:
|
||||
{
|
||||
float min_x = bounds->origin.x;
|
||||
float min_y = bounds->origin.y;
|
||||
float max_x = min_x + bounds->size.width;
|
||||
float max_y = min_y + bounds->size.height;
|
||||
float scale_x = (max_x - min_x) / texture->width;
|
||||
float scale_y = (max_y - min_y) / texture->height;
|
||||
GskGLTextureSlice *slices = NULL;
|
||||
guint n_slices = 0;
|
||||
GdkGLContext *context = gsk_gl_driver_get_context (job->driver);
|
||||
guint rows, cols;
|
||||
|
||||
gsk_gl_render_job_upload_texture (job, texture, min_filter, mag_filter, &offscreen);
|
||||
/* Slice enough that neither the original texture nor the scaled texture
|
||||
* exceed the texture size limit
|
||||
*/
|
||||
cols = (int)(MAX (bounds->size.width, texture->width) / (max_texture_size / 4)) + 1;
|
||||
rows = (int)(MAX (bounds->size.height, texture->height) / (max_texture_size / 4)) + 1;
|
||||
|
||||
g_assert (offscreen.texture_id);
|
||||
g_assert (offscreen.was_offscreen == FALSE);
|
||||
gsk_gl_driver_slice_texture (job->driver, texture, GL_NEAREST, GL_NEAREST, cols, rows, &slices, &n_slices);
|
||||
|
||||
u0 = (clip_rect.origin.x - bounds->origin.x) / bounds->size.width;
|
||||
v0 = (clip_rect.origin.y - bounds->origin.y) / bounds->size.height;
|
||||
u1 = (clip_rect.origin.x + clip_rect.size.width - bounds->origin.x) / bounds->size.width;
|
||||
v1 = (clip_rect.origin.y + clip_rect.size.height - bounds->origin.y) / bounds->size.height;
|
||||
g_assert (slices != NULL);
|
||||
g_assert (n_slices > 0);
|
||||
|
||||
gsk_gl_render_job_set_viewport (job, &viewport, &prev_viewport);
|
||||
gsk_gl_render_job_set_projection_from_rect (job, &viewport, &prev_projection);
|
||||
gsk_gl_render_job_set_modelview (job, NULL);
|
||||
prev_alpha = gsk_gl_render_job_set_alpha (job, 1.0f);
|
||||
gsk_gl_render_job_push_clip (job, &GSK_ROUNDED_RECT_INIT_FROM_RECT (viewport));
|
||||
for (guint i = 0; i < n_slices; i ++)
|
||||
{
|
||||
const GskGLTextureSlice *slice = &slices[i];
|
||||
float x1, x2, y1, y2;
|
||||
GdkTexture *sub_texture;
|
||||
GskRenderNode *sub_node;
|
||||
|
||||
prev_fbo = gsk_gl_command_queue_bind_framebuffer (job->command_queue, render_target->framebuffer_id);
|
||||
gsk_gl_command_queue_clear (job->command_queue, 0, &viewport);
|
||||
x1 = min_x + (scale_x * slice->rect.x);
|
||||
x2 = x1 + (slice->rect.width * scale_x);
|
||||
y1 = min_y + (scale_y * slice->rect.y);
|
||||
y2 = y1 + (slice->rect.height * scale_y);
|
||||
|
||||
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
|
||||
gsk_gl_program_set_uniform_texture (job->current_program,
|
||||
UNIFORM_SHARED_SOURCE, 0,
|
||||
GL_TEXTURE_2D,
|
||||
GL_TEXTURE0,
|
||||
offscreen.texture_id);
|
||||
gsk_gl_render_job_draw_coords (job,
|
||||
0, 0, clip_rect.size.width, clip_rect.size.height,
|
||||
u0, v0, u1, v1,
|
||||
(guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO });
|
||||
gsk_gl_render_job_end_draw (job);
|
||||
sub_texture = gdk_gl_texture_new (context, slice->texture_id, slice->rect.width, slice->rect.height, NULL, NULL);
|
||||
|
||||
gsk_gl_render_job_pop_clip (job);
|
||||
gsk_gl_render_job_pop_modelview (job);
|
||||
gsk_gl_render_job_set_viewport (job, &prev_viewport, NULL);
|
||||
gsk_gl_render_job_set_projection (job, &prev_projection);
|
||||
gsk_gl_render_job_set_alpha (job, prev_alpha);
|
||||
gsk_gl_command_queue_bind_framebuffer (job->command_queue, prev_fbo);
|
||||
sub_node = gsk_texture_scale_node_new (sub_texture, &GRAPHENE_RECT_INIT (x1, y1, x2 - x1, y2 - y1), scaling_filter);
|
||||
|
||||
texture_id = gsk_gl_driver_release_render_target (job->driver, render_target, FALSE);
|
||||
|
||||
gsk_gl_driver_cache_texture (job->driver, &key, texture_id);
|
||||
|
||||
render_texture:
|
||||
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
|
||||
gsk_gl_program_set_uniform_texture (job->current_program,
|
||||
UNIFORM_SHARED_SOURCE, 0,
|
||||
GL_TEXTURE_2D,
|
||||
GL_TEXTURE0,
|
||||
texture_id);
|
||||
gsk_gl_render_job_draw_coords (job,
|
||||
job->offset_x + clip_rect.origin.x,
|
||||
job->offset_y + clip_rect.origin.y,
|
||||
job->offset_x + clip_rect.origin.x + clip_rect.size.width,
|
||||
job->offset_y + clip_rect.origin.y + clip_rect.size.height,
|
||||
0, clip_rect.size.width / ceilf (clip_rect.size.width),
|
||||
clip_rect.size.height / ceilf (clip_rect.size.height), 0,
|
||||
(guint16[]){ FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO } );
|
||||
gsk_gl_render_job_end_draw (job);
|
||||
gsk_gl_render_job_visit_node (job, sub_node);
|
||||
gsk_render_node_unref (sub_node);
|
||||
g_object_unref (sub_texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
||||
+28
-160
@@ -21,10 +21,8 @@
|
||||
#include "gskrendernodeprivate.h"
|
||||
|
||||
#include "gskcairoblurprivate.h"
|
||||
#include "gskcairorenderer.h"
|
||||
#include "gskdebugprivate.h"
|
||||
#include "gskdiffprivate.h"
|
||||
#include "gl/gskglrenderer.h"
|
||||
#include "gskrendererprivate.h"
|
||||
#include "gskroundedrectprivate.h"
|
||||
#include "gsktransformprivate.h"
|
||||
@@ -33,10 +31,6 @@
|
||||
#include "gdk/gdkmemoryformatprivate.h"
|
||||
#include "gdk/gdkprivate.h"
|
||||
|
||||
#include <cairo.h>
|
||||
#ifdef CAIRO_HAS_SVG_SURFACE
|
||||
#include <cairo-svg.h>
|
||||
#endif
|
||||
#include <hb-ot.h>
|
||||
|
||||
/* maximal number of rectangles we keep in a diff region before we throw
|
||||
@@ -64,16 +58,6 @@ rectangle_init_from_graphene (cairo_rectangle_int_t *cairo,
|
||||
cairo->height = ceilf (graphene->origin.y + graphene->size.height) - cairo->y;
|
||||
}
|
||||
|
||||
static void
|
||||
_graphene_rect_init_from_clip_extents (graphene_rect_t *rect,
|
||||
cairo_t *cr)
|
||||
{
|
||||
double x1c, y1c, x2c, y2c;
|
||||
|
||||
cairo_clip_extents (cr, &x1c, &y1c, &x2c, &y2c);
|
||||
graphene_rect_init (rect, x1c, y1c, x2c - x1c, y2c - y1c);
|
||||
}
|
||||
|
||||
/* {{{ GSK_COLOR_NODE */
|
||||
|
||||
/**
|
||||
@@ -1573,10 +1557,6 @@ gsk_texture_node_get_texture (const GskRenderNode *node)
|
||||
* Creates a `GskRenderNode` that will render the given
|
||||
* @texture into the area given by @bounds.
|
||||
*
|
||||
* Note that GSK applies linear filtering when textures are
|
||||
* scaled and transformed. See [class@Gsk.TextureScaleNode]
|
||||
* for a way to influence filtering.
|
||||
*
|
||||
* Returns: (transfer full) (type GskTextureNode): A new `GskRenderNode`
|
||||
*/
|
||||
GskRenderNode *
|
||||
@@ -1645,21 +1625,15 @@ gsk_texture_scale_node_draw (GskRenderNode *node,
|
||||
};
|
||||
cairo_t *cr2;
|
||||
cairo_surface_t *surface2;
|
||||
graphene_rect_t clip_rect;
|
||||
|
||||
/* Make sure we draw the minimum region by using the clip */
|
||||
gsk_cairo_rectangle (cr, &node->bounds);
|
||||
cairo_clip (cr);
|
||||
_graphene_rect_init_from_clip_extents (&clip_rect, cr);
|
||||
if (clip_rect.size.width <= 0 || clip_rect.size.height <= 0)
|
||||
return;
|
||||
|
||||
surface2 = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
||||
(int) ceilf (clip_rect.size.width),
|
||||
(int) ceilf (clip_rect.size.height));
|
||||
cairo_surface_set_device_offset (surface2, -clip_rect.origin.x, -clip_rect.origin.y);
|
||||
(int) ceilf (node->bounds.size.width),
|
||||
(int) ceilf (node->bounds.size.height));
|
||||
cr2 = cairo_create (surface2);
|
||||
|
||||
cairo_set_source_rgba (cr2, 0, 0, 0, 0);
|
||||
cairo_paint (cr2);
|
||||
|
||||
surface = gdk_texture_download_surface (self->texture);
|
||||
pattern = cairo_pattern_create_for_surface (surface);
|
||||
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
|
||||
@@ -1758,11 +1732,7 @@ gsk_texture_scale_node_get_filter (const GskRenderNode *node)
|
||||
* @filter: how to scale the texture
|
||||
*
|
||||
* Creates a node that scales the texture to the size given by the
|
||||
* bounds using the filter and then places it at the bounds' position.
|
||||
*
|
||||
* Note that further scaling and other transformations which are
|
||||
* applied to the node will apply linear filtering to the resulting
|
||||
* texture, as usual.
|
||||
* bounds and the filter and then places it at the bounds' position.
|
||||
*
|
||||
* This node is intended for tight control over scaling applied
|
||||
* to a texture, such as in image editors and requires the
|
||||
@@ -2102,15 +2072,15 @@ gsk_inset_shadow_node_draw (GskRenderNode *node,
|
||||
GskInsetShadowNode *self = (GskInsetShadowNode *) node;
|
||||
GskRoundedRect box, clip_box;
|
||||
int clip_radius;
|
||||
graphene_rect_t clip_rect;
|
||||
double x1c, y1c, x2c, y2c;
|
||||
double blur_radius;
|
||||
|
||||
/* We don't need to draw invisible shadows */
|
||||
if (gdk_rgba_is_clear (&self->color))
|
||||
return;
|
||||
|
||||
_graphene_rect_init_from_clip_extents (&clip_rect, cr);
|
||||
if (!gsk_rounded_rect_intersects_rect (&self->outline, &clip_rect))
|
||||
cairo_clip_extents (cr, &x1c, &y1c, &x2c, &y2c);
|
||||
if (!gsk_rounded_rect_intersects_rect (&self->outline, &GRAPHENE_RECT_INIT (x1c, y1c, x2c - x1c, y2c - y1c)))
|
||||
return;
|
||||
|
||||
blur_radius = self->blur_radius / 2;
|
||||
@@ -2398,7 +2368,7 @@ gsk_outset_shadow_node_draw (GskRenderNode *node,
|
||||
GskOutsetShadowNode *self = (GskOutsetShadowNode *) node;
|
||||
GskRoundedRect box, clip_box;
|
||||
int clip_radius;
|
||||
graphene_rect_t clip_rect;
|
||||
double x1c, y1c, x2c, y2c;
|
||||
float top, right, bottom, left;
|
||||
double blur_radius;
|
||||
|
||||
@@ -2406,8 +2376,8 @@ gsk_outset_shadow_node_draw (GskRenderNode *node,
|
||||
if (gdk_rgba_is_clear (&self->color))
|
||||
return;
|
||||
|
||||
_graphene_rect_init_from_clip_extents (&clip_rect, cr);
|
||||
if (!gsk_rounded_rect_intersects_rect (&self->outline, &clip_rect))
|
||||
cairo_clip_extents (cr, &x1c, &y1c, &x2c, &y2c);
|
||||
if (gsk_rounded_rect_contains_rect (&self->outline, &GRAPHENE_RECT_INIT (x1c, y1c, x2c - x1c, y2c - y1c)))
|
||||
return;
|
||||
|
||||
blur_radius = self->blur_radius / 2;
|
||||
@@ -6241,9 +6211,9 @@ gsk_render_node_init_types_once (void)
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_render_node_serialize_bytes_finish (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer serializer)
|
||||
gsk_render_node_content_serializer_finish (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer serializer)
|
||||
{
|
||||
GOutputStream *stream = G_OUTPUT_STREAM (source);
|
||||
GError *error = NULL;
|
||||
@@ -6254,109 +6224,10 @@ gsk_render_node_serialize_bytes_finish (GObject *source,
|
||||
gdk_content_serializer_return_success (serializer);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_render_node_serialize_bytes (GdkContentSerializer *serializer,
|
||||
GBytes *bytes)
|
||||
{
|
||||
GInputStream *input;
|
||||
|
||||
input = g_memory_input_stream_new_from_bytes (bytes);
|
||||
|
||||
g_output_stream_splice_async (gdk_content_serializer_get_output_stream (serializer),
|
||||
input,
|
||||
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE,
|
||||
gdk_content_serializer_get_priority (serializer),
|
||||
gdk_content_serializer_get_cancellable (serializer),
|
||||
gsk_render_node_serialize_bytes_finish,
|
||||
serializer);
|
||||
g_object_unref (input);
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
|
||||
#ifdef CAIRO_HAS_SVG_SURFACE
|
||||
static cairo_status_t
|
||||
gsk_render_node_cairo_serializer_write (gpointer user_data,
|
||||
const unsigned char *data,
|
||||
unsigned int length)
|
||||
{
|
||||
g_byte_array_append (user_data, data, length);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_render_node_svg_serializer (GdkContentSerializer *serializer)
|
||||
{
|
||||
GskRenderNode *node;
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
graphene_rect_t bounds;
|
||||
GByteArray *array;
|
||||
|
||||
node = gsk_value_get_render_node (gdk_content_serializer_get_value (serializer));
|
||||
gsk_render_node_get_bounds (node, &bounds);
|
||||
array = g_byte_array_new ();
|
||||
|
||||
surface = cairo_svg_surface_create_for_stream (gsk_render_node_cairo_serializer_write,
|
||||
array,
|
||||
bounds.size.width,
|
||||
bounds.size.height);
|
||||
cairo_svg_surface_set_document_unit (surface, CAIRO_SVG_UNIT_PX);
|
||||
cairo_surface_set_device_offset (surface, -bounds.origin.x, -bounds.origin.y);
|
||||
|
||||
cr = cairo_create (surface);
|
||||
gsk_render_node_draw (node, cr);
|
||||
cairo_destroy (cr);
|
||||
|
||||
cairo_surface_finish (surface);
|
||||
if (cairo_surface_status (surface) == CAIRO_STATUS_SUCCESS)
|
||||
{
|
||||
gsk_render_node_serialize_bytes (serializer, g_byte_array_free_to_bytes (array));
|
||||
}
|
||||
else
|
||||
{
|
||||
GError *error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
cairo_status_to_string (cairo_surface_status (surface)));
|
||||
gdk_content_serializer_return_error (serializer, error);
|
||||
g_byte_array_unref (array);
|
||||
}
|
||||
cairo_surface_destroy (surface);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gsk_render_node_png_serializer (GdkContentSerializer *serializer)
|
||||
{
|
||||
GskRenderNode *node;
|
||||
GdkTexture *texture;
|
||||
GskRenderer *renderer;
|
||||
GBytes *bytes;
|
||||
|
||||
node = gsk_value_get_render_node (gdk_content_serializer_get_value (serializer));
|
||||
|
||||
renderer = gsk_gl_renderer_new ();
|
||||
if (!gsk_renderer_realize (renderer, NULL, NULL))
|
||||
{
|
||||
g_object_unref (renderer);
|
||||
renderer = gsk_cairo_renderer_new ();
|
||||
if (!gsk_renderer_realize (renderer, NULL, NULL))
|
||||
{
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
texture = gsk_renderer_render_texture (renderer, node, NULL);
|
||||
gsk_renderer_unrealize (renderer);
|
||||
g_object_unref (renderer);
|
||||
|
||||
bytes = gdk_texture_save_to_png_bytes (texture);
|
||||
g_object_unref (texture);
|
||||
|
||||
gsk_render_node_serialize_bytes (serializer, bytes);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_render_node_content_serializer (GdkContentSerializer *serializer)
|
||||
{
|
||||
GInputStream *input;
|
||||
const GValue *value;
|
||||
GskRenderNode *node;
|
||||
GBytes *bytes;
|
||||
@@ -6364,14 +6235,23 @@ gsk_render_node_content_serializer (GdkContentSerializer *serializer)
|
||||
value = gdk_content_serializer_get_value (serializer);
|
||||
node = gsk_value_get_render_node (value);
|
||||
bytes = gsk_render_node_serialize (node);
|
||||
input = g_memory_input_stream_new_from_bytes (bytes);
|
||||
|
||||
gsk_render_node_serialize_bytes (serializer, bytes);
|
||||
g_output_stream_splice_async (gdk_content_serializer_get_output_stream (serializer),
|
||||
input,
|
||||
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE,
|
||||
gdk_content_serializer_get_priority (serializer),
|
||||
gdk_content_serializer_get_cancellable (serializer),
|
||||
gsk_render_node_content_serializer_finish,
|
||||
serializer);
|
||||
g_object_unref (input);
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_render_node_content_deserializer_finish (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer deserializer)
|
||||
GAsyncResult *result,
|
||||
gpointer deserializer)
|
||||
{
|
||||
GOutputStream *stream = G_OUTPUT_STREAM (source);
|
||||
GError *error = NULL;
|
||||
@@ -6435,18 +6315,6 @@ gsk_render_node_init_content_serializers (void)
|
||||
gsk_render_node_content_serializer,
|
||||
NULL,
|
||||
NULL);
|
||||
#ifdef CAIRO_HAS_SVG_SURFACE
|
||||
gdk_content_register_serializer (GSK_TYPE_RENDER_NODE,
|
||||
"image/svg+xml",
|
||||
gsk_render_node_svg_serializer,
|
||||
NULL,
|
||||
NULL);
|
||||
#endif
|
||||
gdk_content_register_serializer (GSK_TYPE_RENDER_NODE,
|
||||
"image/png",
|
||||
gsk_render_node_png_serializer,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
gdk_content_register_deserializer ("application/x-gtk-render-node",
|
||||
GSK_TYPE_RENDER_NODE,
|
||||
|
||||
@@ -128,10 +128,6 @@ parse_texture (GtkCssParser *parser,
|
||||
}
|
||||
else
|
||||
{
|
||||
g_set_error (&error,
|
||||
GTK_CSS_PARSER_ERROR,
|
||||
GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE,
|
||||
"Failed to resolve URL");
|
||||
texture = NULL;
|
||||
}
|
||||
}
|
||||
@@ -233,19 +229,8 @@ parse_script (GtkCssParser *parser,
|
||||
GFile *file;
|
||||
|
||||
file = gtk_css_parser_resolve_url (parser, url);
|
||||
if (file)
|
||||
{
|
||||
bytes = g_file_load_bytes (file, NULL, NULL, &error);
|
||||
g_object_unref (file);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_set_error (&error,
|
||||
GTK_CSS_PARSER_ERROR,
|
||||
GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE,
|
||||
"Failed to resolve URL");
|
||||
bytes = NULL;
|
||||
}
|
||||
bytes = g_file_load_bytes (file, NULL, NULL, &error);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
g_free (scheme);
|
||||
@@ -431,10 +416,7 @@ parse_string (GtkCssParser *parser,
|
||||
|
||||
token = gtk_css_parser_get_token (parser);
|
||||
if (!gtk_css_token_is (token, GTK_CSS_TOKEN_STRING))
|
||||
{
|
||||
gtk_css_parser_error_syntax (parser, "Expected a string");
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
s = g_strdup (gtk_css_token_get_string (token));
|
||||
gtk_css_parser_consume_token (parser);
|
||||
|
||||
+1
-1
@@ -164,7 +164,7 @@ gskenum_h = gsk_enums[1]
|
||||
gskresources = gnome.compile_resources('gskresources',
|
||||
gsk_resources_xml,
|
||||
dependencies: gsk_private_vulkan_compiled_shaders_deps,
|
||||
source_dir: meson.current_source_dir(),
|
||||
source_dir: '.',
|
||||
c_name: '_gsk',
|
||||
extra_args: [ '--manual-register', ],
|
||||
)
|
||||
|
||||
@@ -158,12 +158,9 @@ component_handle_method (GDBusConnection *connection,
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkATContext *context = gtk_accessible_get_at_context (GTK_ACCESSIBLE (child));
|
||||
GtkAtSpiContext *ctx = GTK_AT_SPI_CONTEXT (context);
|
||||
GtkAtSpiContext *ctx = GTK_AT_SPI_CONTEXT (gtk_accessible_get_at_context (GTK_ACCESSIBLE (child)));
|
||||
|
||||
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(@(so))", gtk_at_spi_context_to_ref (ctx)));
|
||||
|
||||
g_object_unref (context);
|
||||
}
|
||||
}
|
||||
else if (g_strcmp0 (method_name, "GetExtents") == 0)
|
||||
|
||||
+33
-112
@@ -203,7 +203,6 @@ collect_states (GtkAtSpiContext *self,
|
||||
|
||||
if (gtk_at_context_has_accessible_state (ctx, GTK_ACCESSIBLE_STATE_CHECKED))
|
||||
{
|
||||
set_atspi_state (&states, ATSPI_STATE_CHECKABLE);
|
||||
value = gtk_at_context_get_accessible_state (ctx, GTK_ACCESSIBLE_STATE_CHECKED);
|
||||
switch (gtk_tristate_accessible_value_get (value))
|
||||
{
|
||||
@@ -247,7 +246,7 @@ collect_states (GtkAtSpiContext *self,
|
||||
case GTK_ACCESSIBLE_INVALID_TRUE:
|
||||
case GTK_ACCESSIBLE_INVALID_GRAMMAR:
|
||||
case GTK_ACCESSIBLE_INVALID_SPELLING:
|
||||
set_atspi_state (&states, ATSPI_STATE_INVALID_ENTRY);
|
||||
set_atspi_state (&states, ATSPI_STATE_INVALID);
|
||||
break;
|
||||
case GTK_ACCESSIBLE_INVALID_FALSE:
|
||||
default:
|
||||
@@ -283,34 +282,6 @@ collect_states (GtkAtSpiContext *self,
|
||||
}
|
||||
}
|
||||
|
||||
if (gtk_at_context_has_accessible_property (ctx, GTK_ACCESSIBLE_PROPERTY_REQUIRED))
|
||||
{
|
||||
value = gtk_at_context_get_accessible_property (ctx, GTK_ACCESSIBLE_PROPERTY_REQUIRED);
|
||||
if (gtk_boolean_accessible_value_get (value))
|
||||
set_atspi_state (&states, ATSPI_STATE_REQUIRED);
|
||||
}
|
||||
|
||||
if (gtk_at_context_has_accessible_property (ctx, GTK_ACCESSIBLE_PROPERTY_MULTI_SELECTABLE))
|
||||
{
|
||||
value = gtk_at_context_get_accessible_property (ctx, GTK_ACCESSIBLE_PROPERTY_MULTI_SELECTABLE);
|
||||
if (gtk_boolean_accessible_value_get (value))
|
||||
set_atspi_state (&states, ATSPI_STATE_MULTISELECTABLE);
|
||||
}
|
||||
|
||||
if (gtk_at_context_has_accessible_property (ctx, GTK_ACCESSIBLE_PROPERTY_HAS_POPUP))
|
||||
{
|
||||
value = gtk_at_context_get_accessible_property (ctx, GTK_ACCESSIBLE_PROPERTY_HAS_POPUP);
|
||||
if (gtk_boolean_accessible_value_get (value))
|
||||
set_atspi_state (&states, ATSPI_STATE_HAS_POPUP);
|
||||
}
|
||||
|
||||
if (gtk_at_context_has_accessible_property (ctx, GTK_ACCESSIBLE_PROPERTY_AUTOCOMPLETE))
|
||||
{
|
||||
value = gtk_at_context_get_accessible_property (ctx, GTK_ACCESSIBLE_PROPERTY_AUTOCOMPLETE);
|
||||
if (gtk_autocomplete_accessible_value_get (value) != GTK_ACCESSIBLE_AUTOCOMPLETE_NONE)
|
||||
set_atspi_state (&states, ATSPI_STATE_SUPPORTS_AUTOCOMPLETION);
|
||||
}
|
||||
|
||||
g_variant_builder_add (builder, "u", (guint32) (states & 0xffffffff));
|
||||
g_variant_builder_add (builder, "u", (guint32) (states >> 32));
|
||||
}
|
||||
@@ -328,12 +299,11 @@ collect_relations (GtkAtSpiContext *self,
|
||||
{ GTK_ACCESSIBLE_RELATION_LABELLED_BY, ATSPI_RELATION_LABELLED_BY },
|
||||
{ GTK_ACCESSIBLE_RELATION_CONTROLS, ATSPI_RELATION_CONTROLLER_FOR },
|
||||
{ GTK_ACCESSIBLE_RELATION_DESCRIBED_BY, ATSPI_RELATION_DESCRIBED_BY },
|
||||
{ GTK_ACCESSIBLE_RELATION_DETAILS, ATSPI_RELATION_DETAILS },
|
||||
{ GTK_ACCESSIBLE_RELATION_ERROR_MESSAGE, ATSPI_RELATION_ERROR_MESSAGE},
|
||||
{ GTK_ACCESSIBLE_RELATION_FLOW_TO, ATSPI_RELATION_FLOWS_TO},
|
||||
};
|
||||
GtkAccessibleValue *value;
|
||||
GList *list, *l;
|
||||
GtkATContext *target_ctx;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (map); i++)
|
||||
@@ -348,16 +318,13 @@ collect_relations (GtkAtSpiContext *self,
|
||||
|
||||
for (l = list; l; l = l->next)
|
||||
{
|
||||
GtkATContext *target_ctx =
|
||||
gtk_accessible_get_at_context (GTK_ACCESSIBLE (l->data));
|
||||
target_ctx = gtk_accessible_get_at_context (GTK_ACCESSIBLE (l->data));
|
||||
|
||||
/* Realize the ATContext of the target, so we can ask for its ref */
|
||||
gtk_at_context_realize (target_ctx);
|
||||
|
||||
g_variant_builder_add (&b, "@(so)",
|
||||
gtk_at_spi_context_to_ref (GTK_AT_SPI_CONTEXT (target_ctx)));
|
||||
|
||||
g_object_unref (target_ctx);
|
||||
}
|
||||
|
||||
g_variant_builder_add (builder, "(ua(so))", map[i].s, &b);
|
||||
@@ -369,17 +336,17 @@ static int
|
||||
get_index_in (GtkAccessible *parent,
|
||||
GtkAccessible *child)
|
||||
{
|
||||
GtkAccessible *candidate;
|
||||
guint res;
|
||||
|
||||
if (parent == NULL)
|
||||
return -1;
|
||||
|
||||
guint res = 0;
|
||||
GtkAccessible *candidate;
|
||||
res = 0;
|
||||
for (candidate = gtk_accessible_get_first_accessible_child (parent);
|
||||
candidate != NULL;
|
||||
candidate = gtk_accessible_get_next_accessible_sibling (candidate))
|
||||
{
|
||||
g_object_unref (candidate);
|
||||
|
||||
if (candidate == child)
|
||||
return res;
|
||||
|
||||
@@ -398,13 +365,7 @@ get_index_in_parent (GtkAccessible *accessible)
|
||||
GtkAccessible *parent = gtk_accessible_get_accessible_parent (accessible);
|
||||
|
||||
if (parent != NULL)
|
||||
{
|
||||
int res = get_index_in (parent, accessible);
|
||||
|
||||
g_object_unref (parent);
|
||||
|
||||
return res;
|
||||
}
|
||||
return get_index_in (parent, accessible);
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -440,6 +401,7 @@ static GVariant *
|
||||
get_parent_context_ref (GtkAccessible *accessible)
|
||||
{
|
||||
GVariant *res = NULL;
|
||||
|
||||
GtkAccessible *parent = gtk_accessible_get_accessible_parent (accessible);
|
||||
|
||||
if (parent == NULL)
|
||||
@@ -448,19 +410,13 @@ get_parent_context_ref (GtkAccessible *accessible)
|
||||
GtkAtSpiContext *self = GTK_AT_SPI_CONTEXT (context);
|
||||
|
||||
res = gtk_at_spi_root_to_ref (self->root);
|
||||
|
||||
g_object_unref (context);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkATContext *parent_context = gtk_accessible_get_at_context (parent);
|
||||
|
||||
gtk_at_context_realize (parent_context);
|
||||
|
||||
res = gtk_at_spi_context_to_ref (GTK_AT_SPI_CONTEXT (parent_context));
|
||||
|
||||
g_object_unref (parent_context);
|
||||
g_object_unref (parent);
|
||||
}
|
||||
|
||||
if (res == NULL)
|
||||
@@ -541,32 +497,31 @@ handle_accessible_method (GDBusConnection *connection,
|
||||
{
|
||||
GtkATContext *context = NULL;
|
||||
GtkAccessible *accessible;
|
||||
GtkAccessible *child = NULL;
|
||||
int idx, presentable_idx;
|
||||
|
||||
g_variant_get (parameters, "(i)", &idx);
|
||||
|
||||
accessible = gtk_at_context_get_accessible (GTK_AT_CONTEXT (self));
|
||||
|
||||
presentable_idx = 0;
|
||||
GtkAccessible *child;
|
||||
|
||||
presentable_idx = 0;
|
||||
for (child = gtk_accessible_get_first_accessible_child (accessible);
|
||||
child != NULL;
|
||||
child = gtk_accessible_get_next_accessible_sibling (child))
|
||||
{
|
||||
g_object_unref (child);
|
||||
|
||||
if (!gtk_accessible_should_present (child))
|
||||
continue;
|
||||
continue;
|
||||
|
||||
if (presentable_idx == idx)
|
||||
break;
|
||||
presentable_idx++;
|
||||
|
||||
presentable_idx += 1;
|
||||
}
|
||||
|
||||
if (child != NULL)
|
||||
context = gtk_accessible_get_at_context (child);
|
||||
if (child)
|
||||
{
|
||||
context = gtk_accessible_get_at_context (child);
|
||||
}
|
||||
|
||||
if (context == NULL)
|
||||
{
|
||||
@@ -581,23 +536,20 @@ handle_accessible_method (GDBusConnection *connection,
|
||||
gtk_at_context_realize (context);
|
||||
|
||||
GVariant *ref = gtk_at_spi_context_to_ref (GTK_AT_SPI_CONTEXT (context));
|
||||
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(@(so))", ref));
|
||||
|
||||
g_object_unref (context);
|
||||
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(@(so))", ref));
|
||||
}
|
||||
else if (g_strcmp0 (method_name, "GetChildren") == 0)
|
||||
{
|
||||
GVariantBuilder builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE ("a(so)"));
|
||||
|
||||
GtkAccessible *accessible = gtk_at_context_get_accessible (GTK_AT_CONTEXT (self));
|
||||
GtkAccessible *child = NULL;
|
||||
|
||||
GtkAccessible *child;
|
||||
for (child = gtk_accessible_get_first_accessible_child (accessible);
|
||||
child != NULL;
|
||||
child = gtk_accessible_get_next_accessible_sibling (child))
|
||||
{
|
||||
g_object_unref (child);
|
||||
|
||||
{
|
||||
if (!gtk_accessible_should_present (child))
|
||||
continue;
|
||||
|
||||
@@ -610,8 +562,6 @@ handle_accessible_method (GDBusConnection *connection,
|
||||
|
||||
if (ref != NULL)
|
||||
g_variant_builder_add (&builder, "@(so)", ref);
|
||||
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(a(so))", &builder));
|
||||
@@ -791,13 +741,8 @@ emit_property_changed (GtkAtSpiContext *self,
|
||||
const char *name,
|
||||
GVariant *value)
|
||||
{
|
||||
GVariant *value_owned = g_variant_ref_sink (value);
|
||||
|
||||
if (self->connection == NULL)
|
||||
{
|
||||
g_variant_unref (value_owned);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
|
||||
g_dbus_connection_emit_signal (self->connection,
|
||||
NULL,
|
||||
@@ -805,9 +750,8 @@ emit_property_changed (GtkAtSpiContext *self,
|
||||
"org.a11y.atspi.Event.Object",
|
||||
"PropertyChange",
|
||||
g_variant_new ("(siiva{sv})",
|
||||
name, 0, 0, value_owned, NULL),
|
||||
name, 0, 0, value, NULL),
|
||||
NULL);
|
||||
g_variant_unref (value_owned);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -906,6 +850,8 @@ gtk_at_spi_context_state_change (GtkATContext *ctx,
|
||||
|
||||
if (changed_states & GTK_ACCESSIBLE_STATE_CHANGE_HIDDEN)
|
||||
{
|
||||
GtkAccessible *parent;
|
||||
GtkATContext *context;
|
||||
GtkAccessibleChildChange change;
|
||||
|
||||
value = gtk_accessible_attribute_set_get_value (states, GTK_ACCESSIBLE_STATE_HIDDEN);
|
||||
@@ -921,15 +867,10 @@ gtk_at_spi_context_state_change (GtkATContext *ctx,
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkAccessible *parent =
|
||||
gtk_accessible_get_accessible_parent (accessible);
|
||||
GtkATContext *context =
|
||||
gtk_accessible_get_at_context (parent);
|
||||
parent = gtk_accessible_get_accessible_parent (accessible);
|
||||
|
||||
context = gtk_accessible_get_at_context (parent);
|
||||
gtk_at_context_child_changed (context, change, accessible);
|
||||
|
||||
g_object_unref (context);
|
||||
g_object_unref (parent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1096,18 +1037,10 @@ gtk_at_spi_context_state_change (GtkATContext *ctx,
|
||||
}
|
||||
|
||||
if (changed_properties & GTK_ACCESSIBLE_PROPERTY_CHANGE_DESCRIPTION)
|
||||
{
|
||||
char *label = gtk_at_context_get_description (GTK_AT_CONTEXT (self));
|
||||
GVariant *v = g_variant_new_take_string (label);
|
||||
emit_property_changed (self, "accessible-description", v);
|
||||
}
|
||||
|
||||
if (changed_properties & GTK_ACCESSIBLE_PROPERTY_CHANGE_VALUE_NOW)
|
||||
{
|
||||
value = gtk_accessible_attribute_set_get_value (properties, GTK_ACCESSIBLE_PROPERTY_VALUE_NOW);
|
||||
emit_property_changed (self,
|
||||
"accessible-value",
|
||||
g_variant_new_double (gtk_number_accessible_value_get (value)));
|
||||
char *label = gtk_at_context_get_description (GTK_AT_CONTEXT (self));
|
||||
GVariant *v = g_variant_new_take_string (label);
|
||||
emit_property_changed (self, "accessible-description", v);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1186,18 +1119,9 @@ gtk_at_spi_context_child_change (GtkATContext *ctx,
|
||||
int idx = 0;
|
||||
|
||||
if (parent == NULL)
|
||||
{
|
||||
idx = -1;
|
||||
}
|
||||
idx = -1;
|
||||
else if (parent == accessible)
|
||||
{
|
||||
idx = get_index_in (accessible, child);
|
||||
g_object_unref (parent);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_object_unref (parent);
|
||||
}
|
||||
idx = get_index_in (accessible, child);
|
||||
|
||||
if (change & GTK_ACCESSIBLE_CHILD_CHANGE_ADDED)
|
||||
emit_children_changed (self,
|
||||
@@ -1209,8 +1133,6 @@ gtk_at_spi_context_child_change (GtkATContext *ctx,
|
||||
GTK_AT_SPI_CONTEXT (child_context),
|
||||
idx,
|
||||
GTK_ACCESSIBLE_CHILD_STATE_REMOVED);
|
||||
|
||||
g_object_unref (child_context);
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ D-Bus Registration */
|
||||
@@ -1779,16 +1701,15 @@ gtk_at_spi_context_get_child_count (GtkAtSpiContext *self)
|
||||
int n_children = 0;
|
||||
|
||||
GtkAccessible *child = NULL;
|
||||
|
||||
for (child = gtk_accessible_get_first_accessible_child (accessible);
|
||||
child != NULL;
|
||||
child = gtk_accessible_get_next_accessible_sibling (child))
|
||||
{
|
||||
g_object_unref (child);
|
||||
|
||||
if (!gtk_accessible_should_present (child))
|
||||
continue;
|
||||
|
||||
n_children += 1;
|
||||
n_children++;
|
||||
}
|
||||
|
||||
return n_children;
|
||||
|
||||
@@ -225,10 +225,6 @@ typedef enum {
|
||||
ATSPI_RELATION_PARENT_WINDOW_OF,
|
||||
ATSPI_RELATION_DESCRIPTION_FOR,
|
||||
ATSPI_RELATION_DESCRIBED_BY,
|
||||
ATSPI_RELATION_DETAILS,
|
||||
ATSPI_RELATION_DETAILS_FOR,
|
||||
ATSPI_RELATION_ERROR_MESSAGE,
|
||||
ATSPI_RELATION_ERROR_FOR,
|
||||
ATSPI_RELATION_LAST_DEFINED,
|
||||
} AtspiRelationType;
|
||||
|
||||
|
||||
@@ -314,8 +314,6 @@ handle_accessible_method (GDBusConnection *connection,
|
||||
const char *path = gtk_at_spi_context_get_context_path (GTK_AT_SPI_CONTEXT (context));
|
||||
|
||||
g_dbus_method_invocation_return_value (invocation, g_variant_new ("((so))", name, path));
|
||||
|
||||
g_object_unref (context);
|
||||
}
|
||||
else if (g_strcmp0 (method_name, "GetChildren") == 0)
|
||||
{
|
||||
@@ -336,8 +334,6 @@ handle_accessible_method (GDBusConnection *connection,
|
||||
const char *path = gtk_at_spi_context_get_context_path (GTK_AT_SPI_CONTEXT (context));
|
||||
|
||||
g_variant_builder_add (&builder, "(so)", name, path);
|
||||
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(a(so))", &builder));
|
||||
@@ -457,8 +453,6 @@ gtk_at_spi_root_child_changed (GtkAtSpiRoot *self,
|
||||
GtkATContext *context = gtk_accessible_get_at_context (child);
|
||||
|
||||
window_ref = gtk_at_spi_context_to_ref (GTK_AT_SPI_CONTEXT (context));
|
||||
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
switch (change)
|
||||
|
||||
@@ -94,9 +94,7 @@ listbox_handle_method (GDBusConnection *connection,
|
||||
else
|
||||
{
|
||||
GtkATContext *ctx = gtk_accessible_get_at_context (GTK_ACCESSIBLE (counter.child));
|
||||
g_dbus_method_invocation_return_value (invocation,
|
||||
g_variant_new ("(@(so))", gtk_at_spi_context_to_ref (GTK_AT_SPI_CONTEXT (ctx))));
|
||||
g_object_unref (ctx);
|
||||
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(@(so))", gtk_at_spi_context_to_ref (GTK_AT_SPI_CONTEXT (ctx))));
|
||||
}
|
||||
}
|
||||
else if (g_strcmp0 (method_name, "SelectChild") == 0)
|
||||
@@ -273,8 +271,7 @@ listview_handle_method (GDBusConnection *connection,
|
||||
{
|
||||
GtkATContext *ctx = gtk_accessible_get_at_context (GTK_ACCESSIBLE (child));
|
||||
g_dbus_method_invocation_return_value (invocation,
|
||||
g_variant_new ("(@(so))", gtk_at_spi_context_to_ref (GTK_AT_SPI_CONTEXT (ctx))));
|
||||
g_object_unref (ctx);
|
||||
g_variant_new ("(@(so))", gtk_at_spi_context_to_ref (GTK_AT_SPI_CONTEXT (ctx))));
|
||||
}
|
||||
}
|
||||
else if (g_strcmp0 (method_name, "SelectChild") == 0)
|
||||
@@ -498,9 +495,7 @@ flowbox_handle_method (GDBusConnection *connection,
|
||||
else
|
||||
{
|
||||
GtkATContext *ctx = gtk_accessible_get_at_context (GTK_ACCESSIBLE (counter.child));
|
||||
g_dbus_method_invocation_return_value (invocation,
|
||||
g_variant_new ("(@(so))", gtk_at_spi_context_to_ref (GTK_AT_SPI_CONTEXT (ctx))));
|
||||
g_object_unref (ctx);
|
||||
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(@(so))", gtk_at_spi_context_to_ref (GTK_AT_SPI_CONTEXT (ctx))));
|
||||
}
|
||||
}
|
||||
else if (g_strcmp0 (method_name, "SelectChild") == 0)
|
||||
@@ -766,8 +761,7 @@ stackswitcher_handle_method (GDBusConnection *connection,
|
||||
{
|
||||
GtkATContext *ctx = gtk_accessible_get_at_context (GTK_ACCESSIBLE (child));
|
||||
g_dbus_method_invocation_return_value (invocation,
|
||||
g_variant_new ("(@(so))", gtk_at_spi_context_to_ref (GTK_AT_SPI_CONTEXT (ctx))));
|
||||
g_object_unref (ctx);
|
||||
g_variant_new ("(@(so))", gtk_at_spi_context_to_ref (GTK_AT_SPI_CONTEXT (ctx))));
|
||||
}
|
||||
}
|
||||
else if (g_strcmp0 (method_name, "SelectChild") == 0)
|
||||
@@ -897,8 +891,7 @@ notebook_handle_method (GDBusConnection *connection,
|
||||
{
|
||||
GtkATContext *ctx = gtk_accessible_get_at_context (GTK_ACCESSIBLE (child));
|
||||
g_dbus_method_invocation_return_value (invocation,
|
||||
g_variant_new ("(@(so))", gtk_at_spi_context_to_ref (GTK_AT_SPI_CONTEXT (ctx))));
|
||||
g_object_unref (ctx);
|
||||
g_variant_new ("(@(so))", gtk_at_spi_context_to_ref (GTK_AT_SPI_CONTEXT (ctx))));
|
||||
}
|
||||
}
|
||||
else if (g_strcmp0 (method_name, "SelectChild") == 0)
|
||||
|
||||
@@ -109,7 +109,7 @@ gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
|
||||
return ATSPI_ROLE_LABEL;
|
||||
|
||||
case GTK_ACCESSIBLE_ROLE_LANDMARK:
|
||||
return ATSPI_ROLE_LANDMARK;
|
||||
break;
|
||||
|
||||
case GTK_ACCESSIBLE_ROLE_LEGEND:
|
||||
return ATSPI_ROLE_LABEL;
|
||||
@@ -169,7 +169,7 @@ gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
|
||||
return ATSPI_ROLE_OPTION_PANE;
|
||||
|
||||
case GTK_ACCESSIBLE_ROLE_PRESENTATION:
|
||||
return ATSPI_ROLE_FILLER;
|
||||
return ATSPI_ROLE_SECTION;
|
||||
|
||||
case GTK_ACCESSIBLE_ROLE_PROGRESS_BAR:
|
||||
return ATSPI_ROLE_PROGRESS_BAR;
|
||||
@@ -205,7 +205,7 @@ gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
|
||||
return ATSPI_ROLE_ENTRY;
|
||||
|
||||
case GTK_ACCESSIBLE_ROLE_SECTION:
|
||||
return ATSPI_ROLE_SECTION;
|
||||
return ATSPI_ROLE_FILLER;
|
||||
|
||||
case GTK_ACCESSIBLE_ROLE_SECTION_HEAD:
|
||||
return ATSPI_ROLE_FILLER;
|
||||
@@ -273,8 +273,6 @@ gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
|
||||
case GTK_ACCESSIBLE_ROLE_WINDOW:
|
||||
return ATSPI_ROLE_FRAME;
|
||||
|
||||
case GTK_ACCESSIBLE_ROLE_TOGGLE_BUTTON:
|
||||
return ATSPI_ROLE_TOGGLE_BUTTON;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@
|
||||
* button events, however some customized derived areas can be implemented
|
||||
* who are interested in handling other events. Handling an event can
|
||||
* trigger the [`signal@Gtk.CellArea::focus-changed`] signal to fire; as well
|
||||
* as [`signal@Gtk.CellArea::add-editable`] in the case that an editable cell
|
||||
* as [`signal@GtkCellArea::add-editable`] in the case that an editable cell
|
||||
* was clicked and needs to start editing. You can call
|
||||
* [method@Gtk.CellArea.stop_editing] at any time to cancel any cell editing
|
||||
* that is currently in progress.
|
||||
|
||||
@@ -995,11 +995,10 @@ gtk_cell_area_box_focus_changed (GtkCellArea *area,
|
||||
GParamSpec *pspec,
|
||||
GtkCellAreaBox *box)
|
||||
{
|
||||
GtkCellAreaBoxPrivate *priv = gtk_cell_area_box_get_instance_private (box);
|
||||
GtkCellRenderer *focus_cell = gtk_cell_area_get_focus_cell (area);
|
||||
GtkCellAreaBoxPrivate *priv = gtk_cell_area_box_get_instance_private (box);
|
||||
|
||||
if (focus_cell)
|
||||
priv->last_focus_cell = focus_cell;
|
||||
if (gtk_cell_area_get_focus_cell (area))
|
||||
priv->last_focus_cell = gtk_cell_area_get_focus_cell (area);
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
|
||||
@@ -366,6 +366,7 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
|
||||
{
|
||||
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
||||
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
||||
int menu_width;
|
||||
|
||||
gtk_widget_size_allocate (priv->box,
|
||||
&(GtkAllocation) {
|
||||
@@ -373,8 +374,17 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
|
||||
width, height
|
||||
}, baseline);
|
||||
|
||||
gtk_widget_set_size_request (priv->popup_widget, width, -1);
|
||||
gtk_widget_queue_resize (priv->popup_widget);
|
||||
gtk_widget_set_size_request (priv->popup_widget, -1, -1);
|
||||
|
||||
if (priv->popup_fixed_width)
|
||||
gtk_widget_measure (priv->popup_widget, GTK_ORIENTATION_HORIZONTAL, -1,
|
||||
&menu_width, NULL, NULL, NULL);
|
||||
else
|
||||
gtk_widget_measure (priv->popup_widget, GTK_ORIENTATION_HORIZONTAL, -1,
|
||||
NULL, &menu_width, NULL, NULL);
|
||||
|
||||
gtk_widget_set_size_request (priv->popup_widget,
|
||||
MAX (width, menu_width), -1);
|
||||
|
||||
gtk_popover_present (GTK_POPOVER (priv->popup_widget));
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
* [class@Gtk.FontChooserWidget], [class@Gtk.FontChooserDialog] and
|
||||
* [class@Gtk.FontButton].
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
|
||||
@@ -60,7 +60,7 @@ gtk_font_chooser_default_init (GtkFontChooserInterface *iface)
|
||||
*
|
||||
* The font description as a string, e.g. "Sans Italic 12".
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton] instead
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton] instead
|
||||
*/
|
||||
g_object_interface_install_property
|
||||
(iface,
|
||||
@@ -73,7 +73,7 @@ gtk_font_chooser_default_init (GtkFontChooserInterface *iface)
|
||||
*
|
||||
* The font description as a `PangoFontDescription`.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton] instead
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton] instead
|
||||
*/
|
||||
g_object_interface_install_property
|
||||
(iface,
|
||||
@@ -86,7 +86,7 @@ gtk_font_chooser_default_init (GtkFontChooserInterface *iface)
|
||||
*
|
||||
* The string with which to preview the font.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton] instead
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton] instead
|
||||
*/
|
||||
g_object_interface_install_property
|
||||
(iface,
|
||||
@@ -99,7 +99,7 @@ gtk_font_chooser_default_init (GtkFontChooserInterface *iface)
|
||||
*
|
||||
* Whether to show an entry to change the preview text.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton] instead
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton] instead
|
||||
*/
|
||||
g_object_interface_install_property
|
||||
(iface,
|
||||
@@ -112,7 +112,7 @@ gtk_font_chooser_default_init (GtkFontChooserInterface *iface)
|
||||
*
|
||||
* The level of granularity to offer for selecting fonts.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton] instead
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton] instead
|
||||
*/
|
||||
g_object_interface_install_property
|
||||
(iface,
|
||||
@@ -131,7 +131,7 @@ gtk_font_chooser_default_init (GtkFontChooserInterface *iface)
|
||||
* The format of the string is compatible with
|
||||
* CSS and with Pango attributes.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton] instead
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton] instead
|
||||
*/
|
||||
g_object_interface_install_property
|
||||
(iface,
|
||||
@@ -144,7 +144,7 @@ gtk_font_chooser_default_init (GtkFontChooserInterface *iface)
|
||||
*
|
||||
* The language for which the font features were selected.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton] instead
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton] instead
|
||||
*/
|
||||
g_object_interface_install_property
|
||||
(iface,
|
||||
@@ -163,7 +163,7 @@ gtk_font_chooser_default_init (GtkFontChooserInterface *iface)
|
||||
* or an item is selected and the user presses one of the keys
|
||||
* Space, Shift+Space, Return or Enter.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton] instead
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton] instead
|
||||
*/
|
||||
chooser_signals[SIGNAL_FONT_ACTIVATED] =
|
||||
g_signal_new (I_("font-activated"),
|
||||
@@ -189,7 +189,7 @@ gtk_font_chooser_default_init (GtkFontChooserInterface *iface)
|
||||
* Returns: (nullable) (transfer none): A `PangoFontFamily` representing the
|
||||
* selected font family
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
PangoFontFamily *
|
||||
@@ -212,7 +212,7 @@ gtk_font_chooser_get_font_family (GtkFontChooser *fontchooser)
|
||||
* Returns: (nullable) (transfer none): A `PangoFontFace` representing the
|
||||
* selected font group details
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
PangoFontFace *
|
||||
@@ -232,7 +232,7 @@ gtk_font_chooser_get_font_face (GtkFontChooser *fontchooser)
|
||||
* Returns: A n integer representing the selected font size,
|
||||
* or -1 if no font size is selected.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
int
|
||||
@@ -261,7 +261,7 @@ gtk_font_chooser_get_font_size (GtkFontChooser *fontchooser)
|
||||
* Returns: (nullable) (transfer full): A string with the name
|
||||
* of the current font
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
char *
|
||||
@@ -284,7 +284,7 @@ gtk_font_chooser_get_font (GtkFontChooser *fontchooser)
|
||||
*
|
||||
* Sets the currently-selected font.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
void
|
||||
@@ -315,7 +315,7 @@ gtk_font_chooser_set_font (GtkFontChooser *fontchooser,
|
||||
* Returns: (nullable) (transfer full): A `PangoFontDescription` for the
|
||||
* current font
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
PangoFontDescription *
|
||||
@@ -337,7 +337,7 @@ gtk_font_chooser_get_font_desc (GtkFontChooser *fontchooser)
|
||||
*
|
||||
* Sets the currently-selected font from @font_desc.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
void
|
||||
@@ -358,7 +358,7 @@ gtk_font_chooser_set_font_desc (GtkFontChooser *fontchooser,
|
||||
*
|
||||
* Returns: (transfer full): the text displayed in the preview area
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
char *
|
||||
@@ -382,7 +382,7 @@ gtk_font_chooser_get_preview_text (GtkFontChooser *fontchooser)
|
||||
*
|
||||
* The @text is used to show how the selected font looks.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
void
|
||||
@@ -403,7 +403,7 @@ gtk_font_chooser_set_preview_text (GtkFontChooser *fontchooser,
|
||||
*
|
||||
* Returns: %TRUE if the preview entry is shown or %FALSE if it is hidden.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
gboolean
|
||||
@@ -425,7 +425,7 @@ gtk_font_chooser_get_show_preview_entry (GtkFontChooser *fontchooser)
|
||||
*
|
||||
* Shows or hides the editable preview entry.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
void
|
||||
@@ -448,7 +448,7 @@ gtk_font_chooser_set_show_preview_entry (GtkFontChooser *fontchooser,
|
||||
* Adds a filter function that decides which fonts to display
|
||||
* in the font chooser.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
void
|
||||
@@ -505,7 +505,7 @@ _gtk_font_chooser_font_activated (GtkFontChooser *chooser,
|
||||
* pango_context_set_font_map (context, fontmap);
|
||||
* ```
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
void
|
||||
@@ -528,7 +528,7 @@ gtk_font_chooser_set_font_map (GtkFontChooser *fontchooser,
|
||||
*
|
||||
* Returns: (nullable) (transfer full): a `PangoFontMap`
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
PangoFontMap *
|
||||
@@ -551,7 +551,7 @@ gtk_font_chooser_get_font_map (GtkFontChooser *fontchooser)
|
||||
*
|
||||
* Sets the desired level of granularity for selecting fonts.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
void
|
||||
@@ -571,7 +571,7 @@ gtk_font_chooser_set_level (GtkFontChooser *fontchooser,
|
||||
*
|
||||
* Returns: the current granularity level
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
GtkFontChooserLevel
|
||||
@@ -598,7 +598,7 @@ gtk_font_chooser_get_level (GtkFontChooser *fontchooser)
|
||||
*
|
||||
* Returns: the currently selected font features
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
char *
|
||||
@@ -621,7 +621,7 @@ gtk_font_chooser_get_font_features (GtkFontChooser *fontchooser)
|
||||
*
|
||||
* Returns: the currently selected language
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
char *
|
||||
@@ -643,7 +643,7 @@ gtk_font_chooser_get_language (GtkFontChooser *fontchooser)
|
||||
*
|
||||
* Sets the language to use for font features.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@Gtk.FontDialogButton]
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
void
|
||||
|
||||
@@ -126,7 +126,7 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
* style class applied.
|
||||
*
|
||||
* Deprecated: 4.10: There is no replacement in GTK for an "info bar" widget;
|
||||
* you can use [class@Gtk.Revealer] with a [class@Gtk.Box] containing a
|
||||
* you can use [class@Gtk.Revealer] with a [class@GtkBox] containing a
|
||||
* [class@Gtk.Label] and an optional [class@Gtk.Button], according to
|
||||
* your application's design.
|
||||
*/
|
||||
|
||||
@@ -284,8 +284,7 @@ extract_plane (GdkPixbuf *src,
|
||||
int to_plane)
|
||||
{
|
||||
guchar *src_data, *dst_data;
|
||||
int width, height;
|
||||
gsize src_stride, dst_stride;
|
||||
int width, height, src_stride, dst_stride;
|
||||
guchar *src_row, *dst_row;
|
||||
int x, y;
|
||||
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ for f in funcs:
|
||||
file_output += ['#ifdef GDK_WINDOWING_WIN32']
|
||||
file_output += ['*tp++ = {0}();'.format(f)]
|
||||
file_output += ['#endif']
|
||||
elif f.startswith('gdk_macos'):
|
||||
elif f.startswith('gdk_quartz'):
|
||||
file_output += ['#ifdef GDK_WINDOWING_MACOS']
|
||||
file_output += ['*tp++ = {0}();'.format(f)]
|
||||
file_output += ['#endif']
|
||||
|
||||
+32
-95
@@ -91,9 +91,9 @@ gtk_accessible_default_init (GtkAccessibleInterface *iface)
|
||||
* gtk_accessible_get_at_context:
|
||||
* @self: a `GtkAccessible`
|
||||
*
|
||||
* Retrieves the accessible implementation for the given `GtkAccessible`.
|
||||
* Retrieves the `GtkATContext` for the given `GtkAccessible`.
|
||||
*
|
||||
* Returns: (transfer full): the accessible implementation object
|
||||
* Returns: (transfer none): the `GtkATContext`
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
@@ -109,11 +109,11 @@ gtk_accessible_get_at_context (GtkAccessible *self)
|
||||
* gtk_accessible_get_accessible_parent:
|
||||
* @self: a `GtkAccessible`
|
||||
*
|
||||
* Retrieves the accessible parent for an accessible object.
|
||||
* Retrieves the accessible accessible for an accessible object
|
||||
*
|
||||
* This function returns `NULL` for top level widgets.
|
||||
* This function returns `NULL` for top level widgets
|
||||
*
|
||||
* Returns: (transfer full) (nullable): the accessible parent
|
||||
* Returns: (transfer none) (nullable): the accessible parent
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
@@ -127,13 +127,10 @@ gtk_accessible_get_accessible_parent (GtkAccessible *self)
|
||||
|
||||
context = gtk_accessible_get_at_context (self);
|
||||
if (context != NULL)
|
||||
{
|
||||
parent = gtk_at_context_get_accessible_parent (context);
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
parent = gtk_at_context_get_accessible_parent (context);
|
||||
|
||||
if (parent != NULL)
|
||||
return g_object_ref (parent);
|
||||
return parent;
|
||||
else
|
||||
return GTK_ACCESSIBLE_GET_IFACE (self)->get_accessible_parent (self);
|
||||
}
|
||||
@@ -164,7 +161,6 @@ gtk_accessible_set_accessible_parent (GtkAccessible *self,
|
||||
g_return_if_fail (GTK_IS_ACCESSIBLE (self));
|
||||
g_return_if_fail (parent == NULL || GTK_IS_ACCESSIBLE (parent));
|
||||
g_return_if_fail (next_sibling == NULL || GTK_IS_ACCESSIBLE (parent));
|
||||
|
||||
GtkATContext *context;
|
||||
|
||||
context = gtk_accessible_get_at_context (self);
|
||||
@@ -172,7 +168,6 @@ gtk_accessible_set_accessible_parent (GtkAccessible *self,
|
||||
{
|
||||
gtk_at_context_set_accessible_parent (context, parent);
|
||||
gtk_at_context_set_next_accessible_sibling (context, next_sibling);
|
||||
g_object_unref (context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +177,6 @@ gtk_accessible_set_accessible_parent (GtkAccessible *self,
|
||||
* @new_sibling: (nullable): the new next accessible sibling to set
|
||||
*
|
||||
* Updates the next accessible sibling of @self.
|
||||
*
|
||||
* That might be useful when a new child of a custom `GtkAccessible`
|
||||
* is created, and it needs to be linked to a previous child.
|
||||
*
|
||||
@@ -193,26 +187,20 @@ gtk_accessible_update_next_accessible_sibling (GtkAccessible *self,
|
||||
GtkAccessible *new_sibling)
|
||||
{
|
||||
GtkATContext *context;
|
||||
GtkAccessible *parent;
|
||||
|
||||
g_return_if_fail (GTK_IS_ACCESSIBLE (self));
|
||||
|
||||
context = gtk_accessible_get_at_context (self);
|
||||
if (context == NULL)
|
||||
if (!context)
|
||||
return;
|
||||
|
||||
parent = gtk_at_context_get_accessible_parent (context);
|
||||
if (parent == NULL)
|
||||
{
|
||||
g_object_unref (context);
|
||||
g_critical ("Failed to update next accessible sibling: no parent accessible set for this accessible");
|
||||
return;
|
||||
}
|
||||
|
||||
if (gtk_at_context_get_accessible_parent (context) == NULL)
|
||||
{
|
||||
g_critical ("Failed to update next accessible sibling: no parent accessible set for this accessible");
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_at_context_set_next_accessible_sibling (context, new_sibling);
|
||||
|
||||
g_object_unref (parent);
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,7 +209,7 @@ gtk_accessible_update_next_accessible_sibling (GtkAccessible *self,
|
||||
*
|
||||
* Retrieves the first accessible child of an accessible object.
|
||||
*
|
||||
* Returns: (transfer full) (nullable): the first accessible child
|
||||
* Returns: (transfer none) (nullable): the first accessible child
|
||||
*
|
||||
* since: 4.10
|
||||
*/
|
||||
@@ -239,7 +227,7 @@ gtk_accessible_get_first_accessible_child (GtkAccessible *self)
|
||||
*
|
||||
* Retrieves the next accessible sibling of an accessible object
|
||||
*
|
||||
* Returns: (transfer full) (nullable): the next accessible sibling
|
||||
* Returns: (transfer none) (nullable): the next accessible sibling
|
||||
*
|
||||
* since: 4.10
|
||||
*/
|
||||
@@ -249,21 +237,12 @@ gtk_accessible_get_next_accessible_sibling (GtkAccessible *self)
|
||||
g_return_val_if_fail (GTK_IS_ACCESSIBLE (self), NULL);
|
||||
|
||||
GtkATContext *context;
|
||||
GtkAccessible *sibling = NULL;
|
||||
|
||||
context = gtk_accessible_get_at_context (self);
|
||||
if (context != NULL && gtk_at_context_get_accessible_parent (context) != NULL)
|
||||
{
|
||||
sibling = gtk_at_context_get_next_accessible_sibling (context);
|
||||
if (sibling != NULL)
|
||||
sibling = g_object_ref (sibling);
|
||||
}
|
||||
return gtk_at_context_get_next_accessible_sibling (context);
|
||||
else
|
||||
sibling = GTK_ACCESSIBLE_GET_IFACE (self)->get_next_accessible_sibling (self);
|
||||
|
||||
g_clear_object (&context);
|
||||
|
||||
return sibling;
|
||||
return GTK_ACCESSIBLE_GET_IFACE (self)->get_next_accessible_sibling (self);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,21 +256,13 @@ gtk_accessible_get_next_accessible_sibling (GtkAccessible *self)
|
||||
GtkAccessibleRole
|
||||
gtk_accessible_get_accessible_role (GtkAccessible *self)
|
||||
{
|
||||
GtkAccessibleRole role = GTK_ACCESSIBLE_ROLE_NONE;
|
||||
GtkAccessibleRole role;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_ACCESSIBLE (self), GTK_ACCESSIBLE_ROLE_NONE);
|
||||
|
||||
GtkATContext *context = gtk_accessible_get_at_context (self);
|
||||
if (context != NULL)
|
||||
{
|
||||
if (gtk_at_context_is_realized (context))
|
||||
role = gtk_at_context_get_accessible_role (context);
|
||||
|
||||
g_object_unref (context);
|
||||
|
||||
if (role != GTK_ACCESSIBLE_ROLE_NONE)
|
||||
return role;
|
||||
}
|
||||
if (context != NULL && gtk_at_context_is_realized (context))
|
||||
return gtk_at_context_get_accessible_role (context);
|
||||
|
||||
g_object_get (G_OBJECT (self), "accessible-role", &role, NULL);
|
||||
|
||||
@@ -365,8 +336,6 @@ gtk_accessible_update_state (GtkAccessible *self,
|
||||
|
||||
out:
|
||||
va_end (args);
|
||||
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -420,7 +389,6 @@ gtk_accessible_update_state_value (GtkAccessible *self,
|
||||
}
|
||||
|
||||
gtk_at_context_update (context);
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -444,7 +412,6 @@ gtk_accessible_reset_state (GtkAccessible *self,
|
||||
|
||||
gtk_at_context_set_accessible_state (context, state, NULL);
|
||||
gtk_at_context_update (context);
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -516,8 +483,6 @@ gtk_accessible_update_property (GtkAccessible *self,
|
||||
|
||||
out:
|
||||
va_end (args);
|
||||
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -571,7 +536,6 @@ gtk_accessible_update_property_value (GtkAccessible *self,
|
||||
}
|
||||
|
||||
gtk_at_context_update (context);
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -595,7 +559,6 @@ gtk_accessible_reset_property (GtkAccessible *self,
|
||||
|
||||
gtk_at_context_set_accessible_property (context, property, NULL);
|
||||
gtk_at_context_update (context);
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -667,8 +630,6 @@ gtk_accessible_update_relation (GtkAccessible *self,
|
||||
|
||||
out:
|
||||
va_end (args);
|
||||
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -697,8 +658,6 @@ gtk_accessible_update_relation_value (GtkAccessible *self,
|
||||
g_return_if_fail (n_relations > 0);
|
||||
|
||||
context = gtk_accessible_get_at_context (self);
|
||||
if (context == NULL)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < n_relations; i++)
|
||||
{
|
||||
@@ -717,14 +676,15 @@ gtk_accessible_update_relation_value (GtkAccessible *self,
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_at_context_set_accessible_relation (context, relation, real_value);
|
||||
if (context)
|
||||
gtk_at_context_set_accessible_relation (context, relation, real_value);
|
||||
|
||||
if (real_value != NULL)
|
||||
gtk_accessible_value_unref (real_value);
|
||||
}
|
||||
|
||||
gtk_at_context_update (context);
|
||||
g_object_unref (context);
|
||||
if (context)
|
||||
gtk_at_context_update (context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -748,7 +708,6 @@ gtk_accessible_reset_relation (GtkAccessible *self,
|
||||
|
||||
gtk_at_context_set_accessible_relation (context, relation, NULL);
|
||||
gtk_at_context_update (context);
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
static const char *role_names[] = {
|
||||
@@ -909,22 +868,13 @@ gtk_accessible_platform_changed (GtkAccessible *self,
|
||||
|
||||
/* propagate changes up from ignored widgets */
|
||||
if (gtk_accessible_get_accessible_role (self) == GTK_ACCESSIBLE_ROLE_NONE)
|
||||
{
|
||||
GtkAccessible *parent = gtk_accessible_get_accessible_parent (self);
|
||||
|
||||
if (parent != NULL)
|
||||
{
|
||||
context = gtk_accessible_get_at_context (parent);
|
||||
g_object_unref (parent);
|
||||
}
|
||||
}
|
||||
context = gtk_accessible_get_at_context (gtk_accessible_get_accessible_parent (self));
|
||||
|
||||
if (context == NULL)
|
||||
return;
|
||||
|
||||
gtk_at_context_platform_changed (context, change);
|
||||
gtk_at_context_update (context);
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -978,7 +928,6 @@ gtk_accessible_bounds_changed (GtkAccessible *self)
|
||||
return;
|
||||
|
||||
gtk_at_context_bounds_changed (context);
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1031,7 +980,6 @@ gtk_accessible_should_present (GtkAccessible *self)
|
||||
{
|
||||
GtkAccessibleRole role;
|
||||
GtkATContext *context;
|
||||
gboolean res = TRUE;
|
||||
|
||||
if (GTK_IS_WIDGET (self) &&
|
||||
!gtk_widget_get_visible (GTK_WIDGET (self)))
|
||||
@@ -1052,12 +1000,10 @@ gtk_accessible_should_present (GtkAccessible *self)
|
||||
|
||||
value = gtk_at_context_get_accessible_state (context, GTK_ACCESSIBLE_STATE_HIDDEN);
|
||||
if (gtk_boolean_accessible_value_get (value))
|
||||
res = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_object_unref (context);
|
||||
|
||||
return res;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1071,24 +1017,15 @@ gtk_accessible_update_children (GtkAccessible *self,
|
||||
gtk_widget_get_root (GTK_WIDGET (self)) == NULL)
|
||||
return;
|
||||
|
||||
context = gtk_accessible_get_at_context (self);
|
||||
|
||||
/* propagate changes up from ignored widgets */
|
||||
if (gtk_accessible_get_accessible_role (self) == GTK_ACCESSIBLE_ROLE_NONE)
|
||||
{
|
||||
GtkAccessible *parent = gtk_accessible_get_accessible_parent (self);
|
||||
|
||||
context = gtk_accessible_get_at_context (parent);
|
||||
|
||||
g_object_unref (parent);
|
||||
}
|
||||
else
|
||||
{
|
||||
context = gtk_accessible_get_at_context (self);
|
||||
}
|
||||
context = gtk_accessible_get_at_context (gtk_accessible_get_accessible_parent (self));
|
||||
|
||||
if (context == NULL)
|
||||
return;
|
||||
|
||||
gtk_at_context_child_changed (context, 1 << state, child);
|
||||
gtk_at_context_update (context);
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
+4
-4
@@ -73,7 +73,7 @@ struct _GtkAccessibleInterface
|
||||
* Retrieves the platform-specific accessibility context for the
|
||||
* accessible implementation.
|
||||
*
|
||||
* Returns: (transfer full) (nullable): the accessibility context
|
||||
* Returns: (transfer none) (nullable): the accessibility context
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
@@ -101,7 +101,7 @@ struct _GtkAccessibleInterface
|
||||
*
|
||||
* This virtual function should return `NULL` for top level objects.
|
||||
*
|
||||
* Returns: (nullable) (transfer full): the accessible parent
|
||||
* Returns: (nullable) (transfer none): the accessible parent
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
@@ -113,7 +113,7 @@ struct _GtkAccessibleInterface
|
||||
*
|
||||
* Retrieves the first accessible child of an accessible object.
|
||||
*
|
||||
* Returns: (transfer full) (nullable): an accessible object
|
||||
* Returns: (transfer none) (nullable): an accessible object
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
@@ -125,7 +125,7 @@ struct _GtkAccessibleInterface
|
||||
*
|
||||
* Retrieves the next accessible sibling of an accessible object.
|
||||
*
|
||||
* Returns: (transfer full) (nullable): an accessible object
|
||||
* Returns: (transfer none) (nullable): an accessible object
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
|
||||
+10
-19
@@ -352,21 +352,6 @@ gtk_adjustment_dispatch_properties_changed (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
static double
|
||||
gtk_adjustment_sanitize_value (GtkAdjustment *self,
|
||||
double value)
|
||||
{
|
||||
GtkAdjustmentPrivate *priv = gtk_adjustment_get_instance_private (self);
|
||||
|
||||
/* don't use CLAMP() so we don't end up below lower if upper - page_size
|
||||
* is smaller than lower
|
||||
*/
|
||||
value = MIN (value, priv->upper - priv->page_size);
|
||||
value = MAX (value, priv->lower);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_adjustment_new:
|
||||
* @value: the initial value
|
||||
@@ -434,8 +419,6 @@ adjustment_set_value (GtkAdjustment *adjustment,
|
||||
{
|
||||
GtkAdjustmentPrivate *priv = gtk_adjustment_get_instance_private (adjustment);
|
||||
|
||||
value = gtk_adjustment_sanitize_value (adjustment, value);
|
||||
|
||||
if (priv->value != value)
|
||||
{
|
||||
priv->value = value;
|
||||
@@ -514,7 +497,11 @@ gtk_adjustment_set_value_internal (GtkAdjustment *adjustment,
|
||||
{
|
||||
GtkAdjustmentPrivate *priv = gtk_adjustment_get_instance_private (adjustment);
|
||||
|
||||
value = gtk_adjustment_sanitize_value (adjustment, value);
|
||||
/* don't use CLAMP() so we don't end up below lower if upper - page_size
|
||||
* is smaller than lower
|
||||
*/
|
||||
value = MIN (value, priv->upper - priv->page_size);
|
||||
value = MAX (value, priv->lower);
|
||||
|
||||
if (animate && priv->duration != 0 && priv->clock != NULL)
|
||||
{
|
||||
@@ -838,7 +825,11 @@ gtk_adjustment_configure (GtkAdjustment *adjustment,
|
||||
gtk_adjustment_set_page_increment (adjustment, page_increment);
|
||||
gtk_adjustment_set_page_size (adjustment, page_size);
|
||||
|
||||
value = gtk_adjustment_sanitize_value (adjustment, value);
|
||||
/* don't use CLAMP() so we don't end up below lower if upper - page_size
|
||||
* is smaller than lower
|
||||
*/
|
||||
value = MIN (value, upper - page_size);
|
||||
value = MAX (value, lower);
|
||||
|
||||
if (value != priv->value)
|
||||
{
|
||||
|
||||
+7
-46
@@ -85,20 +85,6 @@ gtk_at_context_dispose (GObject *gobject)
|
||||
|
||||
gtk_at_context_unrealize (self);
|
||||
|
||||
if (self->accessible_parent != NULL)
|
||||
{
|
||||
g_object_remove_weak_pointer (G_OBJECT (self->accessible_parent),
|
||||
(gpointer *) &self->accessible_parent);
|
||||
self->accessible_parent = NULL;
|
||||
}
|
||||
|
||||
if (self->next_accessible_sibling != NULL)
|
||||
{
|
||||
g_object_remove_weak_pointer (G_OBJECT (self->next_accessible_sibling),
|
||||
(gpointer *) &self->next_accessible_sibling);
|
||||
self->next_accessible_sibling = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (gtk_at_context_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
@@ -473,14 +459,14 @@ GtkAccessible *
|
||||
gtk_at_context_get_accessible_parent (GtkATContext *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_AT_CONTEXT (self), NULL);
|
||||
|
||||
|
||||
return self->accessible_parent;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gtk_at_context_set_accessible_parent:
|
||||
* @self: a `GtkAtContext`
|
||||
* @parent: (nullable): the parent `GtkAccessible` to set
|
||||
* @parent: the parent `GtkAccessible` to set
|
||||
*
|
||||
* Sets the parent accessible object of the given `GtkAtContext`.
|
||||
*/
|
||||
@@ -489,18 +475,8 @@ gtk_at_context_set_accessible_parent (GtkATContext *self,
|
||||
GtkAccessible *parent)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_AT_CONTEXT (self));
|
||||
|
||||
if (self->accessible_parent != parent)
|
||||
{
|
||||
if (self->accessible_parent != NULL)
|
||||
g_object_remove_weak_pointer (G_OBJECT (self->accessible_parent),
|
||||
(gpointer *) &self->accessible_parent);
|
||||
|
||||
self->accessible_parent = parent;
|
||||
if (self->accessible_parent != NULL)
|
||||
g_object_add_weak_pointer (G_OBJECT (self->accessible_parent),
|
||||
(gpointer *) &self->accessible_parent);
|
||||
}
|
||||
|
||||
g_set_object (&self->accessible_parent, parent);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
@@ -515,7 +491,7 @@ GtkAccessible *
|
||||
gtk_at_context_get_next_accessible_sibling (GtkATContext *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_AT_CONTEXT (self), NULL);
|
||||
|
||||
|
||||
return self->next_accessible_sibling;
|
||||
}
|
||||
|
||||
@@ -531,19 +507,8 @@ gtk_at_context_set_next_accessible_sibling (GtkATContext *self,
|
||||
GtkAccessible *sibling)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_AT_CONTEXT (self));
|
||||
|
||||
if (self->next_accessible_sibling != sibling)
|
||||
{
|
||||
if (self->next_accessible_sibling != NULL)
|
||||
g_object_remove_weak_pointer (G_OBJECT (self->next_accessible_sibling),
|
||||
(gpointer *) &self->next_accessible_sibling);
|
||||
|
||||
self->next_accessible_sibling = sibling;
|
||||
|
||||
if (self->next_accessible_sibling != NULL)
|
||||
g_object_add_weak_pointer (G_OBJECT (self->next_accessible_sibling),
|
||||
(gpointer *) &self->next_accessible_sibling);
|
||||
}
|
||||
|
||||
g_set_object (&self->next_accessible_sibling, sibling);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
@@ -1028,8 +993,6 @@ gtk_at_context_get_name_accumulate (GtkATContext *self,
|
||||
GtkATContext *rel_context = gtk_accessible_get_at_context (rel);
|
||||
|
||||
gtk_at_context_get_name_accumulate (rel_context, names, FALSE);
|
||||
|
||||
g_object_unref (rel_context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1102,8 +1065,6 @@ gtk_at_context_get_description_accumulate (GtkATContext *self,
|
||||
GtkATContext *rel_context = gtk_accessible_get_at_context (rel);
|
||||
|
||||
gtk_at_context_get_description_accumulate (rel_context, labels, FALSE);
|
||||
|
||||
g_object_unref (rel_context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ struct _GtkBuildableParser
|
||||
* @set_buildable_property: Sets a property of a buildable object.
|
||||
* It is normally not necessary to implement this, g_object_set_property()
|
||||
* is used by default. `GtkWindow` implements this to delay showing itself
|
||||
* (i.e. setting the [property@Gtk.Widget:visible] property) until the whole
|
||||
* (i.e. setting the [property@GtkWidget:visible] property) until the whole
|
||||
* interface is created.
|
||||
* @construct_child: Constructs a child of a buildable that has been
|
||||
* specified as “constructor” in the UI definition. This can be used to
|
||||
|
||||
@@ -1608,7 +1608,6 @@ create_subparser (GObject *object,
|
||||
subparser->object = object;
|
||||
subparser->child = child;
|
||||
subparser->tagname = g_strdup (element_name);
|
||||
subparser->level = 1;
|
||||
subparser->start = element_name;
|
||||
subparser->parser = g_memdup2 (parser, sizeof (GtkBuildableParser));
|
||||
subparser->data = user_data;
|
||||
@@ -1639,8 +1638,6 @@ subparser_start (GtkBuildableParseContext *context,
|
||||
|
||||
if (subparser->start)
|
||||
{
|
||||
subparser->level++;
|
||||
|
||||
if (subparser->parser->start_element)
|
||||
subparser->parser->start_element (context,
|
||||
element_name, names, values,
|
||||
@@ -1656,8 +1653,6 @@ subparser_end (GtkBuildableParseContext *context,
|
||||
ParserData *data,
|
||||
GError **error)
|
||||
{
|
||||
data->subparser->level--;
|
||||
|
||||
if (data->subparser->parser->end_element)
|
||||
data->subparser->parser->end_element (context, element_name,
|
||||
data->subparser->data, error);
|
||||
@@ -1665,11 +1660,9 @@ subparser_end (GtkBuildableParseContext *context,
|
||||
if (*error)
|
||||
return;
|
||||
|
||||
if (data->subparser->level > 0)
|
||||
if (strcmp (data->subparser->start, element_name) != 0)
|
||||
return;
|
||||
|
||||
g_assert (strcmp (data->subparser->start, element_name) == 0);
|
||||
|
||||
gtk_buildable_custom_tag_end (GTK_BUILDABLE (data->subparser->object),
|
||||
data->builder,
|
||||
data->subparser->child,
|
||||
|
||||
@@ -165,7 +165,6 @@ struct _GtkBuildableParseContext {
|
||||
typedef struct {
|
||||
GtkBuildableParser *parser;
|
||||
char *tagname;
|
||||
int level;
|
||||
const char *start;
|
||||
gpointer data;
|
||||
GObject *object;
|
||||
|
||||
+4
-1
@@ -19,7 +19,7 @@
|
||||
* Modified by the GTK+ Team and others 1997-2001. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -63,6 +63,7 @@
|
||||
|
||||
#include "gtkactionhelperprivate.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkcheckbutton.h"
|
||||
#include "gtkgestureclick.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
#include "gtkbinlayout.h"
|
||||
@@ -828,6 +829,8 @@ gtk_button_set_label (GtkButton *button,
|
||||
gtk_label_set_use_underline (GTK_LABEL (child), priv->use_underline);
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (child), GTK_WIDGET (button));
|
||||
}
|
||||
if (GTK_IS_CHECK_BUTTON (button))
|
||||
gtk_label_set_xalign (GTK_LABEL (child), 0.0);
|
||||
|
||||
gtk_button_set_child (button, child);
|
||||
}
|
||||
|
||||
@@ -103,8 +103,6 @@ gtk_column_list_item_factory_update (GtkListItemFactory *factory,
|
||||
{
|
||||
GtkListItem *list_item = GTK_LIST_ITEM (item);
|
||||
GtkWidget *child;
|
||||
gboolean selectable = TRUE;
|
||||
gboolean activatable = TRUE;
|
||||
|
||||
GTK_LIST_ITEM_FACTORY_CLASS (gtk_column_list_item_factory_parent_class)->update (factory, item, unbind, bind, func, data);
|
||||
|
||||
@@ -112,28 +110,11 @@ gtk_column_list_item_factory_update (GtkListItemFactory *factory,
|
||||
child;
|
||||
child = gtk_widget_get_next_sibling (child))
|
||||
{
|
||||
GtkListItem *cell_item;
|
||||
|
||||
gtk_list_item_widget_update (GTK_LIST_ITEM_WIDGET (child),
|
||||
gtk_list_item_get_position (list_item),
|
||||
gtk_list_item_get_item (list_item),
|
||||
gtk_list_item_get_selected (list_item));
|
||||
|
||||
cell_item = gtk_list_item_widget_get_list_item (GTK_LIST_ITEM_WIDGET (child));
|
||||
if (cell_item)
|
||||
{
|
||||
selectable &= gtk_list_item_get_selectable (cell_item);
|
||||
activatable &= gtk_list_item_get_activatable (cell_item);
|
||||
}
|
||||
}
|
||||
|
||||
/* This really does not belong here, but doing better
|
||||
* requires considerable plumbing that we don't have now,
|
||||
* and something like this is needed to fix the filechooser
|
||||
* in select_folder mode.
|
||||
*/
|
||||
gtk_list_item_set_selectable (list_item, selectable);
|
||||
gtk_list_item_set_activatable (list_item, activatable);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -477,8 +477,6 @@ gtk_column_view_dispose (GObject *object)
|
||||
{
|
||||
GtkColumnView *self = GTK_COLUMN_VIEW (object);
|
||||
|
||||
gtk_column_view_sorter_clear (GTK_COLUMN_VIEW_SORTER (self->sorter));
|
||||
|
||||
while (g_list_model_get_n_items (G_LIST_MODEL (self->columns)) > 0)
|
||||
{
|
||||
GtkColumnViewColumn *column = g_list_model_get_item (G_LIST_MODEL (self->columns), 0);
|
||||
|
||||
+4
-3
@@ -507,6 +507,9 @@ gtk_css_node_real_node_removed (GtkCssNode *parent,
|
||||
node->previous_sibling = NULL;
|
||||
node->next_sibling = NULL;
|
||||
node->parent = NULL;
|
||||
|
||||
if (parent->children_observer)
|
||||
gtk_list_list_model_item_removed (parent->children_observer, previous);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -712,8 +715,6 @@ gtk_css_node_reposition (GtkCssNode *node,
|
||||
if (old_parent != NULL)
|
||||
{
|
||||
GTK_CSS_NODE_GET_CLASS (old_parent)->node_removed (old_parent, node, node->previous_sibling);
|
||||
if (old_parent->children_observer && old_parent != new_parent)
|
||||
gtk_list_list_model_item_removed (old_parent->children_observer, old_previous);
|
||||
if (old_parent->first_child && node->visible)
|
||||
gtk_css_node_invalidate (old_parent->first_child, GTK_CSS_CHANGE_NTH_LAST_CHILD);
|
||||
}
|
||||
@@ -783,7 +784,7 @@ gtk_css_node_reposition (GtkCssNode *node,
|
||||
|
||||
if (new_parent && new_parent->children_observer)
|
||||
{
|
||||
if (old_previous && old_parent == new_parent)
|
||||
if (old_previous)
|
||||
gtk_list_list_model_item_moved (new_parent->children_observer, node, old_previous);
|
||||
else
|
||||
gtk_list_list_model_item_added (new_parent->children_observer, node);
|
||||
|
||||
@@ -758,8 +758,11 @@ _gtk_css_number_value_get (const GtkCssValue *value,
|
||||
gboolean
|
||||
gtk_css_dimension_value_is_zero (const GtkCssValue *value)
|
||||
{
|
||||
g_assert (value != 0);
|
||||
g_assert (value->class == >K_CSS_VALUE_NUMBER);
|
||||
if (!value)
|
||||
return TRUE;
|
||||
|
||||
if (value->class != >K_CSS_VALUE_NUMBER)
|
||||
return FALSE;
|
||||
|
||||
if (value->type != TYPE_DIMENSION)
|
||||
return FALSE;
|
||||
|
||||
+3
-7
@@ -852,6 +852,8 @@ typedef enum {
|
||||
GTK_LEVEL_BAR_MODE_DISCRETE
|
||||
} GtkLevelBarMode;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
/**
|
||||
* GtkInputPurpose:
|
||||
* @GTK_INPUT_PURPOSE_FREE_FORM: Allow any character
|
||||
@@ -1304,9 +1306,6 @@ typedef enum {
|
||||
* @GTK_ACCESSIBLE_ROLE_WIDGET: An interactive component of a graphical user
|
||||
* interface. This is the role that GTK uses by default for widgets.
|
||||
* @GTK_ACCESSIBLE_ROLE_WINDOW: An application window.
|
||||
* @GTK_ACCESSIBLE_ROLE_TOGGLE_BUTTON: A type of push button
|
||||
* which stays pressed until depressed by a second activation.
|
||||
* Since: 4.10
|
||||
*
|
||||
* The accessible role for a [iface@Accessible] implementation.
|
||||
*
|
||||
@@ -1391,8 +1390,7 @@ typedef enum {
|
||||
GTK_ACCESSIBLE_ROLE_TREE_GRID,
|
||||
GTK_ACCESSIBLE_ROLE_TREE_ITEM,
|
||||
GTK_ACCESSIBLE_ROLE_WIDGET,
|
||||
GTK_ACCESSIBLE_ROLE_WINDOW,
|
||||
GTK_ACCESSIBLE_ROLE_TOGGLE_BUTTON
|
||||
GTK_ACCESSIBLE_ROLE_WINDOW
|
||||
} GtkAccessibleRole;
|
||||
|
||||
/**
|
||||
@@ -1668,6 +1666,4 @@ typedef enum { /*< prefix=GTK_ACCESSIBLE_SORT >*/
|
||||
GTK_ACCESSIBLE_SORT_OTHER
|
||||
} GtkAccessibleSort;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_ENUMS_H__ */
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "gtkselectionmodel.h"
|
||||
#include "gtkfilechooserutils.h"
|
||||
#include "gtkfilechooserwidgetprivate.h"
|
||||
#include "gtklistitem.h"
|
||||
|
||||
struct _GtkFileChooserCell
|
||||
{
|
||||
@@ -40,7 +39,6 @@ struct _GtkFileChooserCell
|
||||
GFileInfo *item;
|
||||
gboolean selected;
|
||||
guint position;
|
||||
GtkListItem *list_item;
|
||||
|
||||
gboolean show_time;
|
||||
};
|
||||
@@ -58,7 +56,6 @@ enum
|
||||
PROP_SELECTED,
|
||||
PROP_ITEM,
|
||||
PROP_SHOW_TIME,
|
||||
PROP_LIST_ITEM,
|
||||
};
|
||||
|
||||
#define ICON_SIZE 16
|
||||
@@ -200,22 +197,6 @@ gtk_file_chooser_cell_dispose (GObject *object)
|
||||
G_OBJECT_CLASS (gtk_file_chooser_cell_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
get_selectable (GtkFileChooserCell *self)
|
||||
{
|
||||
if (self->item)
|
||||
return g_file_info_get_attribute_boolean (self->item, "filechooser::selectable");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
update_list_item (GtkFileChooserCell *self)
|
||||
{
|
||||
if (self->list_item)
|
||||
gtk_list_item_set_selectable (self->list_item, get_selectable (self));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_chooser_cell_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
@@ -236,25 +217,12 @@ gtk_file_chooser_cell_set_property (GObject *object,
|
||||
|
||||
case PROP_ITEM:
|
||||
self->item = g_value_get_object (value);
|
||||
|
||||
if (get_selectable (self))
|
||||
gtk_widget_remove_css_class (GTK_WIDGET (self), "dim-label");
|
||||
else
|
||||
gtk_widget_add_css_class (GTK_WIDGET (self), "dim-label");
|
||||
|
||||
update_list_item (self);
|
||||
break;
|
||||
|
||||
case PROP_SHOW_TIME:
|
||||
self->show_time = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_LIST_ITEM:
|
||||
self->list_item = g_value_get_object (value);
|
||||
|
||||
update_list_item (self);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@@ -324,11 +292,6 @@ gtk_file_chooser_cell_class_init (GtkFileChooserCellClass *klass)
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_LIST_ITEM,
|
||||
g_param_spec_object ("list-item", NULL, NULL,
|
||||
GTK_TYPE_LIST_ITEM,
|
||||
GTK_PARAM_WRITABLE));
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, I_("filelistcell"));
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||
}
|
||||
|
||||
+23
-74
@@ -34,7 +34,6 @@
|
||||
#include "gtkfilechooserprivate.h"
|
||||
#include "deprecated/gtkfilechooserdialog.h"
|
||||
#include "deprecated/gtkfilechooser.h"
|
||||
#include "gtkfilechoosercellprivate.h"
|
||||
#include "gtkfilechooserentry.h"
|
||||
#include "gtkfilechooserutils.h"
|
||||
#include "gtkfilesystemmodelprivate.h"
|
||||
@@ -329,6 +328,7 @@ struct _GtkFileChooserWidget
|
||||
guint show_type_column : 1;
|
||||
guint create_folders : 1;
|
||||
guint auto_selecting_first_row : 1;
|
||||
guint starting_search : 1;
|
||||
guint browse_files_interaction_frozen : 1;
|
||||
};
|
||||
|
||||
@@ -638,36 +638,25 @@ _gtk_file_chooser_extract_recent_folders (GList *infos)
|
||||
for (l = infos; l; l = l->next)
|
||||
{
|
||||
GtkRecentInfo *info = l->data;
|
||||
const char *uri, *mime_type;
|
||||
GFile *dir;
|
||||
const char *uri;
|
||||
GFile *parent;
|
||||
GFile *file;
|
||||
|
||||
if (!gtk_recent_info_is_local (info))
|
||||
continue;
|
||||
|
||||
uri = gtk_recent_info_get_uri (info);
|
||||
|
||||
file = g_file_new_for_uri (uri);
|
||||
parent = g_file_get_parent (file);
|
||||
g_object_unref (file);
|
||||
|
||||
mime_type = gtk_recent_info_get_mime_type (info);
|
||||
if (strcmp (mime_type, "inode/directory") != 0)
|
||||
if (parent)
|
||||
{
|
||||
dir = g_file_get_parent (file);
|
||||
g_object_unref (file);
|
||||
}
|
||||
else
|
||||
{
|
||||
dir = file;
|
||||
}
|
||||
|
||||
if (dir)
|
||||
{
|
||||
if (!g_hash_table_lookup (folders, dir))
|
||||
if (!g_hash_table_lookup (folders, parent))
|
||||
{
|
||||
g_hash_table_insert (folders, dir, (gpointer) 1);
|
||||
result = g_list_prepend (result, g_object_ref (dir));
|
||||
g_hash_table_insert (folders, parent, (gpointer) 1);
|
||||
result = g_list_prepend (result, g_object_ref (parent));
|
||||
}
|
||||
|
||||
g_object_unref (dir);
|
||||
g_object_unref (parent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2072,9 +2061,6 @@ file_chooser_get_location (GtkFileChooserWidget *impl,
|
||||
else
|
||||
location = g_file_get_path (dir_location);
|
||||
|
||||
if (!location)
|
||||
location = g_strdup ("");
|
||||
|
||||
g_clear_object (&dir_location);
|
||||
g_clear_object (&home_location);
|
||||
|
||||
@@ -2585,11 +2571,7 @@ set_select_multiple (GtkFileChooserWidget *impl,
|
||||
if (select_multiple)
|
||||
impl->selection_model = GTK_SELECTION_MODEL (gtk_multi_selection_new (model));
|
||||
else
|
||||
{
|
||||
impl->selection_model = GTK_SELECTION_MODEL (gtk_single_selection_new (model));
|
||||
gtk_single_selection_set_can_unselect (GTK_SINGLE_SELECTION (impl->selection_model), TRUE);
|
||||
gtk_single_selection_set_autoselect (GTK_SINGLE_SELECTION (impl->selection_model), FALSE);
|
||||
}
|
||||
impl->selection_model = GTK_SELECTION_MODEL (gtk_single_selection_new (model));
|
||||
|
||||
g_signal_connect (impl->selection_model, "selection-changed",
|
||||
G_CALLBACK (list_selection_changed), impl);
|
||||
@@ -2678,16 +2660,6 @@ location_bar_update (GtkFileChooserWidget *impl)
|
||||
gtk_widget_set_visible (impl->browse_new_folder_button, create_folder_visible);
|
||||
}
|
||||
|
||||
static void
|
||||
search_clear_engine (GtkFileChooserWidget *impl)
|
||||
{
|
||||
if (impl->search_engine)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_data (impl->search_engine, impl);
|
||||
g_clear_object (&impl->search_engine);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
operation_mode_stop (GtkFileChooserWidget *impl,
|
||||
OperationMode mode)
|
||||
@@ -2698,7 +2670,6 @@ operation_mode_stop (GtkFileChooserWidget *impl,
|
||||
search_stop_searching (impl, TRUE);
|
||||
search_clear_model (impl, TRUE);
|
||||
gtk_widget_set_visible (impl->remote_warning_bar, FALSE);
|
||||
search_clear_engine (impl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3102,7 +3073,6 @@ cancel_all_operations (GtkFileChooserWidget *impl)
|
||||
g_clear_object (&impl->file_exists_get_info_cancellable);
|
||||
|
||||
search_stop_searching (impl, TRUE);
|
||||
search_clear_engine (impl);
|
||||
}
|
||||
|
||||
static void sorter_changed (GtkSorter *main_sorter,
|
||||
@@ -3579,12 +3549,9 @@ show_and_select_files (GtkFileChooserWidget *impl,
|
||||
|
||||
if (!g_file_info_get_attribute_boolean (info, "filechooser::visible"))
|
||||
{
|
||||
gboolean has_is_hidden = g_file_info_has_attribute (info, "standard::is-hidden");
|
||||
gboolean has_is_backup = g_file_info_has_attribute (info, "standard::is-backup");
|
||||
|
||||
if (!enabled_hidden &&
|
||||
((has_is_hidden && g_file_info_get_is_hidden (info)) ||
|
||||
(has_is_backup && g_file_info_get_is_backup (info))))
|
||||
(g_file_info_get_is_hidden (info) ||
|
||||
g_file_info_get_is_backup (info)))
|
||||
{
|
||||
set_show_hidden (impl, TRUE);
|
||||
enabled_hidden = TRUE;
|
||||
@@ -3982,10 +3949,10 @@ set_list_model (GtkFileChooserWidget *impl,
|
||||
set_busy_cursor (impl, TRUE);
|
||||
|
||||
impl->browse_files_model =
|
||||
_gtk_file_system_model_new_for_directory (impl->current_folder, MODEL_ATTRIBUTES);
|
||||
_gtk_file_system_model_new_for_directory (impl->current_folder,
|
||||
MODEL_ATTRIBUTES);
|
||||
|
||||
_gtk_file_system_model_set_show_hidden (impl->browse_files_model, impl->show_hidden);
|
||||
_gtk_file_system_model_set_can_select_files (impl->browse_files_model, impl->action != GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
|
||||
|
||||
load_setup_timer (impl); /* This changes the state to LOAD_PRELOAD */
|
||||
|
||||
@@ -5801,6 +5768,8 @@ search_stop_searching (GtkFileChooserWidget *impl,
|
||||
if (impl->search_engine)
|
||||
{
|
||||
_gtk_search_engine_stop (impl->search_engine);
|
||||
g_signal_handlers_disconnect_by_data (impl->search_engine, impl);
|
||||
g_clear_object (&impl->search_engine);
|
||||
|
||||
set_busy_cursor (impl, FALSE);
|
||||
gtk_widget_set_visible (impl->search_spinner, FALSE);
|
||||
@@ -5821,8 +5790,6 @@ search_setup_model (GtkFileChooserWidget *impl)
|
||||
|
||||
impl->search_model = _gtk_file_system_model_new ();
|
||||
|
||||
_gtk_file_system_model_set_can_select_files (impl->search_model, impl->action != GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
|
||||
|
||||
set_current_model (impl, G_LIST_MODEL (impl->search_model));
|
||||
update_columns (impl, TRUE, _("Modified"));
|
||||
}
|
||||
@@ -5927,12 +5894,11 @@ static void
|
||||
search_entry_stop_cb (GtkFileChooserWidget *impl)
|
||||
{
|
||||
if (impl->search_engine)
|
||||
{
|
||||
search_stop_searching (impl, FALSE);
|
||||
search_clear_engine (impl);
|
||||
}
|
||||
search_stop_searching (impl, FALSE);
|
||||
else
|
||||
g_object_set (impl, "search-mode", FALSE, NULL);
|
||||
|
||||
impl->starting_search = FALSE;
|
||||
}
|
||||
|
||||
/* Hides the path bar and creates the search entry */
|
||||
@@ -5989,7 +5955,6 @@ recent_start_loading (GtkFileChooserWidget *impl)
|
||||
impl->recent_model = _gtk_file_system_model_new ();
|
||||
|
||||
_gtk_file_system_model_set_filter (impl->recent_model, impl->current_filter);
|
||||
_gtk_file_system_model_set_can_select_files (impl->recent_model, impl->action != GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
|
||||
|
||||
if (!impl->recent_manager)
|
||||
return;
|
||||
@@ -6012,9 +5977,6 @@ recent_start_loading (GtkFileChooserWidget *impl)
|
||||
GtkRecentInfo *info = l->data;
|
||||
GFile *file;
|
||||
|
||||
if (!gtk_recent_info_is_local (info))
|
||||
continue;
|
||||
|
||||
if (gtk_recent_info_get_private_hint (info) &&
|
||||
!gtk_recent_info_has_application (info, app_name))
|
||||
continue;
|
||||
@@ -7021,20 +6983,15 @@ location_sort_func (gconstpointer a,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkFileChooserWidget *impl = user_data;
|
||||
char *location_a, *location_b;
|
||||
char *key_a, *key_b;
|
||||
GtkOrdering result;
|
||||
|
||||
/* FIXME: use sortkeys for these */
|
||||
location_a = file_chooser_get_location (impl, (GFileInfo *)a);
|
||||
location_b = file_chooser_get_location (impl, (GFileInfo *)b);
|
||||
key_a = g_utf8_collate_key_for_filename (location_a, -1);
|
||||
key_b = g_utf8_collate_key_for_filename (location_b, -1);
|
||||
key_a = g_utf8_collate_key_for_filename (file_chooser_get_location (impl, (GFileInfo *)a), -1);
|
||||
key_b = g_utf8_collate_key_for_filename (file_chooser_get_location (impl, (GFileInfo *)b), -1);
|
||||
|
||||
result = g_strcmp0 (key_a, key_b);
|
||||
|
||||
g_free (location_a);
|
||||
g_free (location_b);
|
||||
g_free (key_a);
|
||||
g_free (key_b);
|
||||
|
||||
@@ -7118,10 +7075,6 @@ recent_sort_func (gconstpointer a,
|
||||
|
||||
result = time_sort_func (a, b, user_data);
|
||||
|
||||
/* Recent files should show most recently changed items first
|
||||
*/
|
||||
result = -result;
|
||||
|
||||
if (result == GTK_ORDERING_EQUAL)
|
||||
result = name_sort_func (a, b, user_data);
|
||||
|
||||
@@ -7305,7 +7258,6 @@ gtk_file_chooser_widget_init (GtkFileChooserWidget *impl)
|
||||
g_type_ensure (GTK_TYPE_PATH_BAR);
|
||||
g_type_ensure (GTK_TYPE_PLACES_VIEW);
|
||||
g_type_ensure (GTK_TYPE_PLACES_SIDEBAR);
|
||||
g_type_ensure (GTK_TYPE_FILE_CHOOSER_CELL);
|
||||
g_type_ensure (GTK_TYPE_FILE_CHOOSER_ERROR_STACK);
|
||||
|
||||
impl->select_multiple = FALSE;
|
||||
@@ -7337,9 +7289,6 @@ gtk_file_chooser_widget_init (GtkFileChooserWidget *impl)
|
||||
G_CALLBACK (list_items_changed), impl);
|
||||
|
||||
gtk_single_selection_set_model (GTK_SINGLE_SELECTION (impl->selection_model), G_LIST_MODEL (impl->sort_model));
|
||||
gtk_single_selection_set_can_unselect (GTK_SINGLE_SELECTION (impl->selection_model), TRUE);
|
||||
gtk_single_selection_set_autoselect (GTK_SINGLE_SELECTION (impl->selection_model), FALSE);
|
||||
|
||||
gtk_sort_list_model_set_model (impl->sort_model, G_LIST_MODEL (impl->filter_model));
|
||||
|
||||
gtk_column_view_set_model (GTK_COLUMN_VIEW (impl->browse_files_column_view), impl->selection_model);
|
||||
|
||||
+6
-35
@@ -68,17 +68,15 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <string.h>
|
||||
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
#include "gtkfilefilterprivate.h"
|
||||
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkbuilderprivate.h"
|
||||
#include "gtkfilter.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <string.h>
|
||||
#include "gtkfilter.h"
|
||||
|
||||
typedef struct _GtkFileFilterClass GtkFileFilterClass;
|
||||
typedef struct _FilterRule FilterRule;
|
||||
@@ -989,13 +987,6 @@ gtk_file_filter_to_gvariant (GtkFileFilter *filter)
|
||||
{
|
||||
GVariantBuilder builder;
|
||||
GSList *l;
|
||||
GVariant *result;
|
||||
char *name;
|
||||
|
||||
if (filter->name)
|
||||
name = g_strdup (filter->name);
|
||||
else
|
||||
name = NULL;
|
||||
|
||||
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(us)"));
|
||||
for (l = filter->rules; l; l = l->next)
|
||||
@@ -1007,8 +998,6 @@ gtk_file_filter_to_gvariant (GtkFileFilter *filter)
|
||||
{
|
||||
case FILTER_RULE_PATTERN:
|
||||
g_variant_builder_add (&builder, "(us)", 0, rule->u.pattern);
|
||||
if (name == NULL)
|
||||
name = g_strdup (rule->u.pattern);
|
||||
break;
|
||||
|
||||
case FILTER_RULE_SUFFIX:
|
||||
@@ -1019,24 +1008,13 @@ gtk_file_filter_to_gvariant (GtkFileFilter *filter)
|
||||
char *pattern = _gtk_make_ci_glob_pattern (rule->u.pattern);
|
||||
g_variant_builder_add (&builder, "(us)", 0, pattern);
|
||||
g_free (pattern);
|
||||
if (name == NULL)
|
||||
name = g_strdup (rule->u.pattern);
|
||||
}
|
||||
break;
|
||||
|
||||
case FILTER_RULE_MIME_TYPE:
|
||||
case FILTER_RULE_PIXBUF_FORMATS:
|
||||
for (i = 0; rule->u.content_types[i]; i++)
|
||||
{
|
||||
g_variant_builder_add (&builder, "(us)", 1, rule->u.content_types[i]);
|
||||
if (name == NULL)
|
||||
{
|
||||
if (rule->type == FILTER_RULE_PIXBUF_FORMATS)
|
||||
name = g_strdup (_("Image"));
|
||||
else
|
||||
name = g_content_type_get_description (rule->u.content_types[i]);
|
||||
}
|
||||
}
|
||||
g_variant_builder_add (&builder, "(us)", 1, rule->u.content_types[i]);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1044,14 +1022,7 @@ gtk_file_filter_to_gvariant (GtkFileFilter *filter)
|
||||
}
|
||||
}
|
||||
|
||||
if (name == NULL)
|
||||
name = g_strdup (_("Unspecified"));
|
||||
|
||||
result = g_variant_new ("(s@a(us))", name, g_variant_builder_end (&builder));
|
||||
|
||||
g_free (name);
|
||||
|
||||
return result;
|
||||
return g_variant_new ("(s@a(us))", filter->name, g_variant_builder_end (&builder));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+10
-45
@@ -81,7 +81,6 @@ struct _GtkFileSystemModel
|
||||
guint show_folders :1;/* whether to show folders */
|
||||
guint show_files :1; /* whether to show files */
|
||||
guint filter_folders :1;/* whether filter applies to folders */
|
||||
guint can_select_files : 1;
|
||||
};
|
||||
|
||||
static void freeze_updates (GtkFileSystemModel *model);
|
||||
@@ -152,8 +151,7 @@ static void
|
||||
node_set_visible_and_filtered_out (GtkFileSystemModel *model,
|
||||
guint id,
|
||||
gboolean visible,
|
||||
gboolean filtered_out,
|
||||
gboolean selectable)
|
||||
gboolean filtered_out)
|
||||
{
|
||||
FileModelNode *node = get_node (model, id);
|
||||
|
||||
@@ -166,10 +164,6 @@ node_set_visible_and_filtered_out (GtkFileSystemModel *model,
|
||||
node->filtered_out = filtered_out;
|
||||
}
|
||||
|
||||
/* Selectability */
|
||||
|
||||
g_file_info_set_attribute_boolean (node->info, "filechooser::selectable", selectable);
|
||||
|
||||
/* Visibility */
|
||||
|
||||
g_file_info_set_attribute_boolean (node->info, "filechooser::visible", visible);
|
||||
@@ -215,18 +209,13 @@ node_should_be_visible (GtkFileSystemModel *model,
|
||||
gboolean filtered_out)
|
||||
{
|
||||
FileModelNode *node = get_node (model, id);
|
||||
gboolean has_is_hidden;
|
||||
gboolean has_is_backup;
|
||||
gboolean result;
|
||||
|
||||
if (node->info == NULL)
|
||||
return FALSE;
|
||||
|
||||
has_is_hidden = g_file_info_has_attribute (node->info, "standard::is-hidden");
|
||||
has_is_backup = g_file_info_has_attribute (node->info, "standard::is-backup");
|
||||
if (!model->show_hidden &&
|
||||
((has_is_hidden && g_file_info_get_is_hidden (node->info)) ||
|
||||
(has_is_backup && g_file_info_get_is_backup (node->info))))
|
||||
(g_file_info_get_is_hidden (node->info) || g_file_info_get_is_backup (node->info)))
|
||||
return FALSE;
|
||||
|
||||
if (_gtk_file_info_consider_as_directory (node->info))
|
||||
@@ -248,34 +237,17 @@ node_should_be_visible (GtkFileSystemModel *model,
|
||||
return result;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
node_should_be_selectable (GtkFileSystemModel *model,
|
||||
guint id)
|
||||
{
|
||||
FileModelNode *node = get_node (model, id);
|
||||
|
||||
if (node->info == NULL)
|
||||
return TRUE;
|
||||
|
||||
if (_gtk_file_info_consider_as_directory (node->info))
|
||||
return TRUE;
|
||||
else
|
||||
return model->can_select_files;
|
||||
}
|
||||
|
||||
static void
|
||||
node_compute_visibility_and_filters (GtkFileSystemModel *model,
|
||||
guint id)
|
||||
{
|
||||
gboolean filtered_out;
|
||||
gboolean visible;
|
||||
gboolean selectable;
|
||||
|
||||
filtered_out = node_should_be_filtered_out (model, id);
|
||||
visible = node_should_be_visible (model, id, filtered_out);
|
||||
selectable = node_should_be_selectable (model, id);
|
||||
|
||||
node_set_visible_and_filtered_out (model, id, visible, filtered_out, selectable);
|
||||
node_set_visible_and_filtered_out (model, id, visible, filtered_out);
|
||||
}
|
||||
|
||||
static guint
|
||||
@@ -331,6 +303,8 @@ list_model_get_item (GListModel *list_model,
|
||||
GtkFileSystemModel *model = GTK_FILE_SYSTEM_MODEL (list_model);
|
||||
FileModelNode *node;
|
||||
|
||||
/* The first items of GtkFileSystemModel is not really a file,
|
||||
* so ignore it. */
|
||||
if (position >= model->files->len)
|
||||
return NULL;
|
||||
|
||||
@@ -485,7 +459,7 @@ remove_file (GtkFileSystemModel *model,
|
||||
g_return_if_fail (G_IS_FILE (file));
|
||||
|
||||
id = node_get_for_file (model, file);
|
||||
if (id == GTK_INVALID_LIST_POSITION)
|
||||
if (id == 0)
|
||||
return;
|
||||
|
||||
node = get_node (model, id);
|
||||
@@ -500,7 +474,7 @@ remove_file (GtkFileSystemModel *model,
|
||||
|
||||
g_array_remove_index (model->files, id);
|
||||
|
||||
g_list_model_items_changed (G_LIST_MODEL (model), id, 1, 0);
|
||||
g_list_model_items_changed (G_LIST_MODEL (model), id - 1, 1, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -566,7 +540,6 @@ gtk_file_system_model_init (GtkFileSystemModel *model)
|
||||
model->show_folders = TRUE;
|
||||
model->show_hidden = FALSE;
|
||||
model->filter_folders = FALSE;
|
||||
model->can_select_files = TRUE;
|
||||
|
||||
model->file_lookup = g_hash_table_new (g_file_hash, (GEqualFunc) g_file_equal);
|
||||
model->cancellable = g_cancellable_new ();
|
||||
@@ -968,7 +941,7 @@ _gtk_file_system_model_set_filter_folders (GtkFileSystemModel *model,
|
||||
* @model: the model
|
||||
*
|
||||
* Gets the cancellable used by the @model. This is the cancellable used
|
||||
* internally by the @model that will be cancelled when @model is
|
||||
* internally by the @model that will be cancelled when @model is
|
||||
* disposed. So you can use it for operations that should be cancelled
|
||||
* when the model goes away.
|
||||
*
|
||||
@@ -1032,7 +1005,7 @@ _gtk_file_system_model_update_files (GtkFileSystemModel *model,
|
||||
* _gtk_file_system_model_set_filter:
|
||||
* @mode: a `GtkFileSystemModel`
|
||||
* @filter: (nullable): %NULL or filter to use
|
||||
*
|
||||
*
|
||||
* Sets a filter to be used for deciding if a row should be visible or not.
|
||||
* Whether this filter applies to directories can be toggled with
|
||||
* _gtk_file_system_model_set_filter_folders().
|
||||
@@ -1055,7 +1028,7 @@ _gtk_file_system_model_set_filter (GtkFileSystemModel *model,
|
||||
* @file: the file to add
|
||||
* @attributes: attributes to query before adding the file
|
||||
*
|
||||
* This is a convenience function that calls g_file_query_info_async() on
|
||||
* This is a convenience function that calls g_file_query_info_async() on
|
||||
* the given file, and when successful, adds it to the model.
|
||||
* Upon failure, the @file is discarded.
|
||||
**/
|
||||
@@ -1118,11 +1091,3 @@ _gtk_file_system_model_get_directory (GtkFileSystemModel *model)
|
||||
return model->dir;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_file_system_model_set_can_select_files (GtkFileSystemModel *model,
|
||||
gboolean can_select)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_FILE_SYSTEM_MODEL (model));
|
||||
|
||||
model->can_select_files = can_select;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <gtk/gtkfilefilter.h>
|
||||
#include <gtk/deprecated/gtkfilechooser.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -58,9 +57,6 @@ void _gtk_file_system_model_set_filter_folders (GtkFileSystemMode
|
||||
void _gtk_file_system_model_set_filter (GtkFileSystemModel *model,
|
||||
GtkFileFilter *filter);
|
||||
|
||||
void _gtk_file_system_model_set_can_select_files (GtkFileSystemModel *model,
|
||||
gboolean can_select);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_FILE_SYSTEM_MODEL_PRIVATE_H__ */
|
||||
|
||||
+7
-20
@@ -78,10 +78,7 @@ update_image (GtkFileThumbnail *self)
|
||||
int scale;
|
||||
|
||||
if (!g_file_info_has_attribute (self->info, G_FILE_ATTRIBUTE_STANDARD_ICON))
|
||||
{
|
||||
gtk_image_clear (GTK_IMAGE (self->image));
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
scale = gtk_widget_get_scale_factor (GTK_WIDGET (self));
|
||||
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (self)));
|
||||
@@ -94,6 +91,7 @@ update_image (GtkFileThumbnail *self)
|
||||
g_object_unref (icon);
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -104,19 +102,10 @@ thumbnail_queried_cb (GObject *object,
|
||||
GtkFileThumbnail *self = user_data; /* might be unreffed if operation was cancelled */
|
||||
GFile *file = G_FILE (object);
|
||||
GFileInfo *queried;
|
||||
GError *error = NULL;
|
||||
|
||||
queried = g_file_query_info_finish (file, result, &error);
|
||||
|
||||
if (error)
|
||||
{
|
||||
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
g_file_info_set_attribute_boolean (self->info, "filechooser::queried", TRUE);
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
|
||||
g_file_info_set_attribute_boolean (self->info, "filechooser::queried", TRUE);
|
||||
queried = g_file_query_info_finish (file, result, NULL);
|
||||
if (queried == NULL)
|
||||
return;
|
||||
|
||||
copy_attribute (self->info, queried, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
|
||||
copy_attribute (self->info, queried, G_FILE_ATTRIBUTE_THUMBNAILING_FAILED);
|
||||
@@ -140,10 +129,7 @@ static void
|
||||
get_thumbnail (GtkFileThumbnail *self)
|
||||
{
|
||||
if (!self->info)
|
||||
{
|
||||
gtk_image_clear (GTK_IMAGE (self->image));
|
||||
return;
|
||||
}
|
||||
return;
|
||||
|
||||
if (!update_image (self))
|
||||
{
|
||||
@@ -156,6 +142,7 @@ get_thumbnail (GtkFileThumbnail *self)
|
||||
self->cancellable = g_cancellable_new ();
|
||||
|
||||
file = _gtk_file_info_get_file (self->info);
|
||||
g_file_info_set_attribute_boolean (self->info, "filechooser::queried", TRUE);
|
||||
g_file_query_info_async (file,
|
||||
G_FILE_ATTRIBUTE_THUMBNAIL_PATH ","
|
||||
G_FILE_ATTRIBUTE_THUMBNAILING_FAILED ","
|
||||
|
||||
+477
-387
File diff suppressed because it is too large
Load Diff
@@ -3051,7 +3051,6 @@ theme_lookup_icon (IconTheme *theme,
|
||||
|
||||
min_difference = G_MAXINT;
|
||||
min_dir_size = NULL;
|
||||
min_file = NULL;
|
||||
|
||||
for (i = 0; i < theme->dir_sizes->len; i++)
|
||||
{
|
||||
|
||||
@@ -351,8 +351,6 @@ init_compose_table_thread_cb (GTask *task,
|
||||
|
||||
gtk_im_context_simple_init_compose_table ();
|
||||
|
||||
g_task_return_boolean (task, TRUE);
|
||||
|
||||
gdk_profiler_end_mark (before, "im compose table load (thread)", NULL);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -2950,7 +2950,7 @@ label_mnemonic_widget_weak_notify (gpointer data,
|
||||
* the label) you need to set it explicitly using this function.
|
||||
*
|
||||
* The target widget will be accelerated by emitting the
|
||||
* [signal@Gtk.Widget::mnemonic-activate] signal on it. The default handler for
|
||||
* [signal@GtkWidget::mnemonic-activate] signal on it. The default handler for
|
||||
* this signal will activate the widget if there are no mnemonic collisions
|
||||
* and toggle focus between the colliding widgets otherwise.
|
||||
*/
|
||||
|
||||
+136
-192
@@ -23,9 +23,6 @@
|
||||
|
||||
#include "gtkadjustment.h"
|
||||
#include "gtkbitset.h"
|
||||
#include "gtkcssboxesprivate.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
#include "gtkcsspositionvalueprivate.h"
|
||||
#include "gtkdragsourceprivate.h"
|
||||
#include "gtkdropcontrollermotion.h"
|
||||
#include "gtkgesturedrag.h"
|
||||
@@ -213,11 +210,6 @@ gtk_list_base_adjustment_value_changed_cb (GtkAdjustment *adjustment,
|
||||
&pos,
|
||||
&cell_area))
|
||||
{
|
||||
/* If we get here with n-items == 0, then somebody cleared the list but
|
||||
* GC hasn't run. So no item to be found. */
|
||||
if (gtk_list_base_get_n_items (self) == 0)
|
||||
return;
|
||||
|
||||
g_warning ("%s failed to scroll to given position. Ignoring...", G_OBJECT_TYPE_NAME (self));
|
||||
return;
|
||||
}
|
||||
@@ -335,22 +327,49 @@ gtk_list_base_move_focus (GtkListBase *self,
|
||||
}
|
||||
|
||||
/*
|
||||
* gtk_list_base_get_allocation:
|
||||
* gtk_list_base_get_allocation_along:
|
||||
* @self: a `GtkListBase`
|
||||
* @pos: item to get the area of
|
||||
* @area: (out caller-allocates): set to the area
|
||||
* occupied by the item
|
||||
* @pos: item to get the size of
|
||||
* @offset: (out caller-allocates) (optional): set to the offset
|
||||
* of the top/left of the item
|
||||
* @size: (out caller-allocates) (optional): set to the size of
|
||||
* the item in the direction
|
||||
*
|
||||
* Computes the allocation of the item in the given position
|
||||
* Computes the allocation of the item in the direction along the sizing
|
||||
* axis.
|
||||
*
|
||||
* Returns: %TRUE if the item exists and has an allocation, %FALSE otherwise
|
||||
**/
|
||||
static gboolean
|
||||
gtk_list_base_get_allocation (GtkListBase *self,
|
||||
guint pos,
|
||||
GdkRectangle *area)
|
||||
gtk_list_base_get_allocation_along (GtkListBase *self,
|
||||
guint pos,
|
||||
int *offset,
|
||||
int *size)
|
||||
{
|
||||
return GTK_LIST_BASE_GET_CLASS (self)->get_allocation (self, pos, area);
|
||||
return GTK_LIST_BASE_GET_CLASS (self)->get_allocation_along (self, pos, offset, size);
|
||||
}
|
||||
|
||||
/*
|
||||
* gtk_list_base_get_allocation_across:
|
||||
* @self: a `GtkListBase`
|
||||
* @pos: item to get the size of
|
||||
* @offset: (out caller-allocates) (optional): set to the offset
|
||||
* of the top/left of the item
|
||||
* @size: (out caller-allocates) (optional): set to the size of
|
||||
* the item in the direction
|
||||
*
|
||||
* Computes the allocation of the item in the direction across to the sizing
|
||||
* axis.
|
||||
*
|
||||
* Returns: %TRUE if the item exists and has an allocation, %FALSE otherwise
|
||||
**/
|
||||
static gboolean
|
||||
gtk_list_base_get_allocation_across (GtkListBase *self,
|
||||
guint pos,
|
||||
int *offset,
|
||||
int *size)
|
||||
{
|
||||
return GTK_LIST_BASE_GET_CLASS (self)->get_allocation_across (self, pos, offset, size);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -473,7 +492,7 @@ gtk_list_base_focus (GtkWidget *widget,
|
||||
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
||||
guint old, pos, n_items;
|
||||
GtkWidget *focus_child;
|
||||
GtkListTile *tile;
|
||||
GtkListItemManagerItem *item;
|
||||
|
||||
focus_child = gtk_widget_get_focus_child (widget);
|
||||
/* focus is moving around fine inside the focus child, don't disturb it */
|
||||
@@ -539,15 +558,15 @@ gtk_list_base_focus (GtkWidget *widget,
|
||||
if (old == pos)
|
||||
return TRUE;
|
||||
|
||||
tile = gtk_list_item_manager_get_nth (priv->item_manager, pos, NULL);
|
||||
if (tile == NULL)
|
||||
item = gtk_list_item_manager_get_nth (priv->item_manager, pos, NULL);
|
||||
if (item == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* This shouldn't really happen, but if it does, oh well */
|
||||
if (tile->widget == NULL)
|
||||
if (item->widget == NULL)
|
||||
return gtk_list_base_grab_focus_on_item (GTK_LIST_BASE (self), pos, TRUE, FALSE, FALSE);
|
||||
|
||||
return gtk_widget_child_focus (tile->widget, direction);
|
||||
return gtk_widget_child_focus (item->widget, direction);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -644,8 +663,6 @@ gtk_list_base_set_adjustment (GtkListBase *self,
|
||||
|
||||
if (adjustment == NULL)
|
||||
adjustment = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
||||
else
|
||||
gtk_adjustment_configure (adjustment, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
||||
g_object_ref_sink (adjustment);
|
||||
|
||||
gtk_list_base_clear_adjustment (self, orientation);
|
||||
@@ -790,22 +807,29 @@ gtk_list_base_scroll_to_item (GtkListBase *self,
|
||||
guint pos)
|
||||
{
|
||||
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
||||
int start, end;
|
||||
double align_along, align_across;
|
||||
GtkPackType side_along, side_across;
|
||||
GdkRectangle area;
|
||||
|
||||
if (!gtk_list_base_get_allocation (GTK_LIST_BASE (self), pos, &area))
|
||||
/* figure out primary orientation and if position is valid */
|
||||
if (!gtk_list_base_get_allocation_along (GTK_LIST_BASE (self), pos, &start, &end))
|
||||
return;
|
||||
|
||||
end += start;
|
||||
gtk_list_base_compute_scroll_align (self,
|
||||
gtk_list_base_get_orientation (GTK_LIST_BASE (self)),
|
||||
area.y, area.y + area.height,
|
||||
start, end,
|
||||
priv->anchor_align_along, priv->anchor_side_along,
|
||||
&align_along, &side_along);
|
||||
|
||||
/* now do the same thing with the other orientation */
|
||||
if (!gtk_list_base_get_allocation_across (GTK_LIST_BASE (self), pos, &start, &end))
|
||||
return;
|
||||
|
||||
end += start;
|
||||
gtk_list_base_compute_scroll_align (self,
|
||||
gtk_list_base_get_opposite_orientation (GTK_LIST_BASE (self)),
|
||||
area.x, area.x + area.width,
|
||||
start, end,
|
||||
priv->anchor_align_across, priv->anchor_side_across,
|
||||
&align_across, &side_across);
|
||||
|
||||
@@ -935,7 +959,8 @@ gtk_list_base_move_cursor_page_up (GtkWidget *widget,
|
||||
|
||||
pos = gtk_list_base_get_focus_position (self);
|
||||
page_size = gtk_adjustment_get_page_size (priv->adjustment[priv->orientation]);
|
||||
if (!gtk_list_base_get_allocation (self, pos, &area))
|
||||
if (!gtk_list_base_get_allocation_along (self, pos, &area.y, &area.height) ||
|
||||
!gtk_list_base_get_allocation_across (self, pos, &area.x, &area.width))
|
||||
return TRUE;
|
||||
if (!gtk_list_base_get_position_from_allocation (self,
|
||||
area.x + area.width / 2,
|
||||
@@ -980,7 +1005,8 @@ gtk_list_base_move_cursor_page_down (GtkWidget *widget,
|
||||
if (end == 0)
|
||||
return TRUE;
|
||||
|
||||
if (!gtk_list_base_get_allocation (self, pos, &area))
|
||||
if (!gtk_list_base_get_allocation_along (self, pos, &area.y, &area.height) ||
|
||||
!gtk_list_base_get_allocation_across (self, pos, &area.x, &area.width))
|
||||
return TRUE;
|
||||
|
||||
if (!gtk_list_base_get_position_from_allocation (self,
|
||||
@@ -1329,11 +1355,9 @@ update_autoscroll (GtkListBase *self,
|
||||
remove_autoscroll (self);
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* gtk_list_base_size_allocate_child:
|
||||
* @self: The listbase
|
||||
* @boxes: The CSS boxes of @self to allow for proper
|
||||
* clipping
|
||||
* @child: The child
|
||||
* @x: top left coordinate in the across direction
|
||||
* @y: top right coordinate in the along direction
|
||||
@@ -1344,9 +1368,8 @@ update_autoscroll (GtkListBase *self,
|
||||
* but with the coordinates already offset by the scroll
|
||||
* offset.
|
||||
**/
|
||||
static void
|
||||
void
|
||||
gtk_list_base_size_allocate_child (GtkListBase *self,
|
||||
GtkCssBoxes *boxes,
|
||||
GtkWidget *child,
|
||||
int x,
|
||||
int y,
|
||||
@@ -1354,9 +1377,10 @@ gtk_list_base_size_allocate_child (GtkListBase *self,
|
||||
int height)
|
||||
{
|
||||
GtkAllocation child_allocation;
|
||||
int self_width;
|
||||
int self_width, self_height;
|
||||
|
||||
self_width = gtk_widget_get_width (GTK_WIDGET (self));
|
||||
self_height = gtk_widget_get_height (GTK_WIDGET (self));
|
||||
|
||||
if (gtk_list_base_get_orientation (GTK_LIST_BASE (self)) == GTK_ORIENTATION_VERTICAL)
|
||||
{
|
||||
@@ -1389,14 +1413,14 @@ gtk_list_base_size_allocate_child (GtkListBase *self,
|
||||
child_allocation.height = width;
|
||||
}
|
||||
|
||||
if (!graphene_rect_intersection (gtk_css_boxes_get_padding_rect (boxes),
|
||||
&GRAPHENE_RECT_INIT(
|
||||
child_allocation.x + GTK_LIST_BASE_CHILD_MAX_OVERDRAW,
|
||||
child_allocation.y + GTK_LIST_BASE_CHILD_MAX_OVERDRAW,
|
||||
child_allocation.width + 2 * GTK_LIST_BASE_CHILD_MAX_OVERDRAW,
|
||||
child_allocation.height + 2 * GTK_LIST_BASE_CHILD_MAX_OVERDRAW
|
||||
),
|
||||
NULL))
|
||||
if (!gdk_rectangle_intersect (&child_allocation,
|
||||
&(GdkRectangle) {
|
||||
- GTK_LIST_BASE_CHILD_MAX_OVERDRAW,
|
||||
- GTK_LIST_BASE_CHILD_MAX_OVERDRAW,
|
||||
self_width + GTK_LIST_BASE_CHILD_MAX_OVERDRAW,
|
||||
self_height + GTK_LIST_BASE_CHILD_MAX_OVERDRAW
|
||||
},
|
||||
NULL))
|
||||
{
|
||||
/* child is fully outside the viewport, hide it and don't allocate it */
|
||||
gtk_widget_set_child_visible (child, FALSE);
|
||||
@@ -1408,34 +1432,6 @@ gtk_list_base_size_allocate_child (GtkListBase *self,
|
||||
gtk_widget_size_allocate (child, &child_allocation, -1);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_list_base_allocate_children (GtkListBase *self,
|
||||
GtkCssBoxes *boxes)
|
||||
{
|
||||
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
||||
GtkListTile *tile;
|
||||
int dx, dy;
|
||||
|
||||
gtk_list_base_get_adjustment_values (self, OPPOSITE_ORIENTATION (priv->orientation), &dx, NULL, NULL);
|
||||
gtk_list_base_get_adjustment_values (self, priv->orientation, &dy, NULL, NULL);
|
||||
|
||||
for (tile = gtk_list_item_manager_get_first (priv->item_manager);
|
||||
tile != NULL;
|
||||
tile = gtk_rb_tree_node_get_next (tile))
|
||||
{
|
||||
if (tile->widget)
|
||||
{
|
||||
gtk_list_base_size_allocate_child (GTK_LIST_BASE (self),
|
||||
boxes,
|
||||
tile->widget,
|
||||
tile->area.x - dx,
|
||||
tile->area.y - dy,
|
||||
tile->area.width,
|
||||
tile->area.height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_list_base_widget_to_list (GtkListBase *self,
|
||||
double x_widget,
|
||||
@@ -1468,14 +1464,7 @@ static GtkBitset *
|
||||
gtk_list_base_get_items_in_rect (GtkListBase *self,
|
||||
const GdkRectangle *rect)
|
||||
{
|
||||
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
||||
GdkRectangle bounds;
|
||||
|
||||
gtk_list_item_manager_get_tile_bounds (priv->item_manager, &bounds);
|
||||
if (!gdk_rectangle_intersect (&bounds, rect, &bounds))
|
||||
return gtk_bitset_new_empty ();
|
||||
|
||||
return GTK_LIST_BASE_GET_CLASS (self)->get_items_in_rect (self, &bounds);
|
||||
return GTK_LIST_BASE_GET_CLASS (self)->get_items_in_rect (self, rect);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -1495,13 +1484,13 @@ gtk_list_base_get_rubberband_coords (GtkListBase *self,
|
||||
}
|
||||
else
|
||||
{
|
||||
GdkRectangle area;
|
||||
guint pos = gtk_list_item_tracker_get_position (priv->item_manager, priv->rubberband->start_tracker);
|
||||
|
||||
if (gtk_list_base_get_allocation (self, pos, &area))
|
||||
if (gtk_list_base_get_allocation_along (self, pos, &y1, &y2) &&
|
||||
gtk_list_base_get_allocation_across (self, pos, &x1, &x2))
|
||||
{
|
||||
x1 = area.x + area.width * priv->rubberband->start_align_across;
|
||||
y1 = area.y + area.height * priv->rubberband->start_align_along;
|
||||
x1 += x2 * priv->rubberband->start_align_across;
|
||||
y1 += y2 * priv->rubberband->start_align_along;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1522,9 +1511,8 @@ gtk_list_base_get_rubberband_coords (GtkListBase *self,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_list_base_allocate_rubberband (GtkListBase *self,
|
||||
GtkCssBoxes *boxes)
|
||||
void
|
||||
gtk_list_base_allocate_rubberband (GtkListBase *self)
|
||||
{
|
||||
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
||||
GtkRequisition min_size;
|
||||
@@ -1544,7 +1532,6 @@ gtk_list_base_allocate_rubberband (GtkListBase *self,
|
||||
rect.y -= offset_y;
|
||||
|
||||
gtk_list_base_size_allocate_child (self,
|
||||
boxes,
|
||||
priv->rubberband->widget,
|
||||
rect.x, rect.y, rect.width, rect.height);
|
||||
}
|
||||
@@ -1661,17 +1648,17 @@ static void
|
||||
gtk_list_base_stop_rubberband (GtkListBase *self)
|
||||
{
|
||||
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
||||
GtkListTile *tile;
|
||||
GtkListItemManagerItem *item;
|
||||
|
||||
if (!priv->rubberband)
|
||||
return;
|
||||
|
||||
for (tile = gtk_list_item_manager_get_first (priv->item_manager);
|
||||
tile != NULL;
|
||||
tile = gtk_rb_tree_node_get_next (tile))
|
||||
for (item = gtk_list_item_manager_get_first (priv->item_manager);
|
||||
item != NULL;
|
||||
item = gtk_rb_tree_node_get_next (item))
|
||||
{
|
||||
if (tile->widget)
|
||||
gtk_widget_unset_state_flags (tile->widget, GTK_STATE_FLAG_ACTIVE);
|
||||
if (item->widget)
|
||||
gtk_widget_unset_state_flags (item->widget, GTK_STATE_FLAG_ACTIVE);
|
||||
}
|
||||
|
||||
gtk_list_item_tracker_free (priv->item_manager, priv->rubberband->start_tracker);
|
||||
@@ -1686,7 +1673,7 @@ static void
|
||||
gtk_list_base_update_rubberband_selection (GtkListBase *self)
|
||||
{
|
||||
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
||||
GtkListTile *tile;
|
||||
GtkListItemManagerItem *item;
|
||||
GdkRectangle rect;
|
||||
guint pos;
|
||||
GtkBitset *rubberband_selection;
|
||||
@@ -1697,19 +1684,19 @@ gtk_list_base_update_rubberband_selection (GtkListBase *self)
|
||||
rubberband_selection = gtk_list_base_get_items_in_rect (self, &rect);
|
||||
|
||||
pos = 0;
|
||||
for (tile = gtk_list_item_manager_get_first (priv->item_manager);
|
||||
tile != NULL;
|
||||
tile = gtk_rb_tree_node_get_next (tile))
|
||||
for (item = gtk_list_item_manager_get_first (priv->item_manager);
|
||||
item != NULL;
|
||||
item = gtk_rb_tree_node_get_next (item))
|
||||
{
|
||||
if (tile->widget)
|
||||
if (item->widget)
|
||||
{
|
||||
if (gtk_bitset_contains (rubberband_selection, pos))
|
||||
gtk_widget_set_state_flags (tile->widget, GTK_STATE_FLAG_ACTIVE, FALSE);
|
||||
gtk_widget_set_state_flags (item->widget, GTK_STATE_FLAG_ACTIVE, FALSE);
|
||||
else
|
||||
gtk_widget_unset_state_flags (tile->widget, GTK_STATE_FLAG_ACTIVE);
|
||||
gtk_widget_unset_state_flags (item->widget, GTK_STATE_FLAG_ACTIVE);
|
||||
}
|
||||
|
||||
pos += tile->n_items;
|
||||
pos += item->n_items;
|
||||
}
|
||||
|
||||
gtk_bitset_unref (rubberband_selection);
|
||||
@@ -1857,14 +1844,6 @@ gtk_list_base_drag_leave (GtkDropControllerMotion *motion,
|
||||
remove_autoscroll (GTK_LIST_BASE (widget));
|
||||
}
|
||||
|
||||
static GtkListTile *
|
||||
gtk_list_base_split_func (gpointer data,
|
||||
GtkListTile *tile,
|
||||
guint n_items)
|
||||
{
|
||||
return GTK_LIST_BASE_GET_CLASS (data)->split (data, tile, n_items);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_list_base_init_real (GtkListBase *self,
|
||||
GtkListBaseClass *g_class)
|
||||
@@ -1872,11 +1851,12 @@ gtk_list_base_init_real (GtkListBase *self,
|
||||
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
||||
GtkEventController *controller;
|
||||
|
||||
priv->item_manager = gtk_list_item_manager_new (GTK_WIDGET (self),
|
||||
g_class->list_item_name,
|
||||
g_class->list_item_role,
|
||||
gtk_list_base_split_func,
|
||||
self);
|
||||
priv->item_manager = gtk_list_item_manager_new_for_size (GTK_WIDGET (self),
|
||||
g_class->list_item_name,
|
||||
g_class->list_item_role,
|
||||
g_class->list_item_size,
|
||||
g_class->list_item_augment_size,
|
||||
g_class->list_item_augment_func);
|
||||
priv->anchor = gtk_list_item_tracker_new (priv->item_manager);
|
||||
priv->anchor_side_along = GTK_PACK_START;
|
||||
priv->anchor_side_across = GTK_PACK_START;
|
||||
@@ -1899,7 +1879,7 @@ gtk_list_base_init_real (GtkListBase *self,
|
||||
gtk_widget_add_controller (GTK_WIDGET (self), controller);
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
gtk_list_base_set_adjustment_values (GtkListBase *self,
|
||||
GtkOrientation orientation,
|
||||
int value,
|
||||
@@ -1927,24 +1907,23 @@ gtk_list_base_set_adjustment_values (GtkListBase *self,
|
||||
g_signal_handlers_unblock_by_func (priv->adjustment[orientation],
|
||||
gtk_list_base_adjustment_value_changed_cb,
|
||||
self);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_list_base_update_adjustments (GtkListBase *self)
|
||||
void
|
||||
gtk_list_base_update_adjustments (GtkListBase *self,
|
||||
int total_across,
|
||||
int total_along,
|
||||
int page_across,
|
||||
int page_along,
|
||||
int *across,
|
||||
int *along)
|
||||
{
|
||||
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
||||
GdkRectangle bounds;
|
||||
int value_along, value_across;
|
||||
int page_along, page_across;
|
||||
int value_along, value_across, size;
|
||||
guint pos;
|
||||
|
||||
gtk_list_item_manager_get_tile_bounds (priv->item_manager, &bounds);
|
||||
g_assert (bounds.x == 0);
|
||||
g_assert (bounds.y == 0);
|
||||
|
||||
page_across = gtk_widget_get_size (GTK_WIDGET (self), OPPOSITE_ORIENTATION (priv->orientation));
|
||||
page_along = gtk_widget_get_size (GTK_WIDGET (self), priv->orientation);
|
||||
|
||||
pos = gtk_list_item_tracker_get_position (priv->item_manager, priv->anchor);
|
||||
if (pos == GTK_INVALID_LIST_POSITION)
|
||||
{
|
||||
@@ -1953,49 +1932,38 @@ gtk_list_base_update_adjustments (GtkListBase *self)
|
||||
}
|
||||
else
|
||||
{
|
||||
GdkRectangle area;
|
||||
|
||||
if (gtk_list_base_get_allocation (self, pos, &area))
|
||||
if (gtk_list_base_get_allocation_across (self, pos, &value_across, &size))
|
||||
{
|
||||
value_across = area.x;
|
||||
value_along = area.y;
|
||||
if (priv->anchor_side_across == GTK_PACK_END)
|
||||
value_across += area.width;
|
||||
if (priv->anchor_side_along == GTK_PACK_END)
|
||||
value_along += area.height;
|
||||
value_across += size;
|
||||
value_across -= priv->anchor_align_across * page_across;
|
||||
}
|
||||
else
|
||||
{
|
||||
value_along = 0;
|
||||
}
|
||||
if (gtk_list_base_get_allocation_along (self, pos, &value_along, &size))
|
||||
{
|
||||
if (priv->anchor_side_along == GTK_PACK_END)
|
||||
value_along += size;
|
||||
value_along -= priv->anchor_align_along * page_along;
|
||||
}
|
||||
else
|
||||
{
|
||||
value_across = 0;
|
||||
value_along = 0;
|
||||
}
|
||||
}
|
||||
|
||||
gtk_list_base_set_adjustment_values (self,
|
||||
OPPOSITE_ORIENTATION (priv->orientation),
|
||||
value_across,
|
||||
bounds.width,
|
||||
page_across);
|
||||
gtk_list_base_set_adjustment_values (self,
|
||||
priv->orientation,
|
||||
value_along,
|
||||
bounds.height,
|
||||
page_along);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_list_base_allocate (GtkListBase *self)
|
||||
{
|
||||
GtkCssBoxes boxes;
|
||||
|
||||
gtk_css_boxes_init (&boxes, GTK_WIDGET (self));
|
||||
|
||||
gtk_list_base_update_adjustments (self);
|
||||
|
||||
gtk_list_base_allocate_children (self, &boxes);
|
||||
gtk_list_base_allocate_rubberband (self, &boxes);
|
||||
*across = gtk_list_base_set_adjustment_values (self,
|
||||
OPPOSITE_ORIENTATION (priv->orientation),
|
||||
value_across,
|
||||
total_across,
|
||||
page_across);
|
||||
*along = gtk_list_base_set_adjustment_values (self,
|
||||
priv->orientation,
|
||||
value_along,
|
||||
total_along,
|
||||
page_along);
|
||||
}
|
||||
|
||||
GtkScrollablePolicy
|
||||
@@ -2015,30 +1983,6 @@ gtk_list_base_get_orientation (GtkListBase *self)
|
||||
return priv->orientation;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_list_base_get_border_spacing (GtkListBase *self,
|
||||
int *xspacing,
|
||||
int *yspacing)
|
||||
{
|
||||
GtkCssStyle *style = gtk_css_node_get_style (gtk_widget_get_css_node (GTK_WIDGET (self)));
|
||||
GtkCssValue *border_spacing = style->size->border_spacing;
|
||||
|
||||
if (gtk_list_base_get_orientation (self) == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
if (xspacing)
|
||||
*xspacing = _gtk_css_position_value_get_y (border_spacing, 0);
|
||||
if (yspacing)
|
||||
*yspacing = _gtk_css_position_value_get_x (border_spacing, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (xspacing)
|
||||
*xspacing = _gtk_css_position_value_get_x (border_spacing, 0);
|
||||
if (yspacing)
|
||||
*yspacing = _gtk_css_position_value_get_y (border_spacing, 0);
|
||||
}
|
||||
}
|
||||
|
||||
GtkListItemManager *
|
||||
gtk_list_base_get_manager (GtkListBase *self)
|
||||
{
|
||||
@@ -2180,14 +2124,14 @@ gtk_list_base_grab_focus_on_item (GtkListBase *self,
|
||||
gboolean extend)
|
||||
{
|
||||
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
||||
GtkListTile *tile;
|
||||
GtkListItemManagerItem *item;
|
||||
gboolean success;
|
||||
|
||||
tile = gtk_list_item_manager_get_nth (priv->item_manager, pos, NULL);
|
||||
if (tile == NULL)
|
||||
item = gtk_list_item_manager_get_nth (priv->item_manager, pos, NULL);
|
||||
if (item == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!tile->widget)
|
||||
if (!item->widget)
|
||||
{
|
||||
GtkListItemTracker *tracker = gtk_list_item_tracker_new (priv->item_manager);
|
||||
|
||||
@@ -2197,16 +2141,16 @@ gtk_list_base_grab_focus_on_item (GtkListBase *self,
|
||||
* so we create a temporary one. */
|
||||
gtk_list_item_tracker_set_position (priv->item_manager, tracker, pos, 0, 0);
|
||||
|
||||
tile = gtk_list_item_manager_get_nth (priv->item_manager, pos, NULL);
|
||||
g_assert (tile->widget);
|
||||
item = gtk_list_item_manager_get_nth (priv->item_manager, pos, NULL);
|
||||
g_assert (item->widget);
|
||||
|
||||
success = gtk_widget_grab_focus (tile->widget);
|
||||
success = gtk_widget_grab_focus (item->widget);
|
||||
|
||||
gtk_list_item_tracker_free (priv->item_manager, tracker);
|
||||
}
|
||||
else
|
||||
{
|
||||
success = gtk_widget_grab_focus (tile->widget);
|
||||
success = gtk_widget_grab_focus (item->widget);
|
||||
}
|
||||
|
||||
if (!success)
|
||||
|
||||
+26
-10
@@ -36,14 +36,20 @@ struct _GtkListBaseClass
|
||||
|
||||
const char * list_item_name;
|
||||
GtkAccessibleRole list_item_role;
|
||||
gsize list_item_size;
|
||||
gsize list_item_augment_size;
|
||||
GtkRbTreeAugmentFunc list_item_augment_func;
|
||||
|
||||
GtkListTile * (* split) (GtkListBase *self,
|
||||
GtkListTile *tile,
|
||||
guint n_items);
|
||||
|
||||
gboolean (* get_allocation) (GtkListBase *self,
|
||||
void (* adjustment_value_changed) (GtkListBase *self,
|
||||
GtkOrientation orientation);
|
||||
gboolean (* get_allocation_along) (GtkListBase *self,
|
||||
guint pos,
|
||||
GdkRectangle *area);
|
||||
int *offset,
|
||||
int *size);
|
||||
gboolean (* get_allocation_across) (GtkListBase *self,
|
||||
guint pos,
|
||||
int *offset,
|
||||
int *size);
|
||||
gboolean (* get_position_from_allocation) (GtkListBase *self,
|
||||
int across,
|
||||
int along,
|
||||
@@ -62,9 +68,6 @@ struct _GtkListBaseClass
|
||||
GtkOrientation gtk_list_base_get_orientation (GtkListBase *self);
|
||||
#define gtk_list_base_get_opposite_orientation(self) OPPOSITE_ORIENTATION(gtk_list_base_get_orientation(self))
|
||||
guint gtk_list_base_get_focus_position (GtkListBase *self);
|
||||
void gtk_list_base_get_border_spacing (GtkListBase *self,
|
||||
int *xspacing,
|
||||
int *yspacing);
|
||||
GtkListItemManager * gtk_list_base_get_manager (GtkListBase *self);
|
||||
GtkScrollablePolicy gtk_list_base_get_scroll_policy (GtkListBase *self,
|
||||
GtkOrientation orientation);
|
||||
@@ -72,6 +75,13 @@ guint gtk_list_base_get_n_items (GtkListBase
|
||||
GtkSelectionModel * gtk_list_base_get_model (GtkListBase *self);
|
||||
gboolean gtk_list_base_set_model (GtkListBase *self,
|
||||
GtkSelectionModel *model);
|
||||
void gtk_list_base_update_adjustments (GtkListBase *self,
|
||||
int total_across,
|
||||
int total_along,
|
||||
int page_across,
|
||||
int page_along,
|
||||
int *across,
|
||||
int *along);
|
||||
|
||||
guint gtk_list_base_get_anchor (GtkListBase *self);
|
||||
void gtk_list_base_set_anchor (GtkListBase *self,
|
||||
@@ -96,7 +106,13 @@ gboolean gtk_list_base_grab_focus_on_item (GtkListBase
|
||||
void gtk_list_base_set_enable_rubberband (GtkListBase *self,
|
||||
gboolean enable);
|
||||
gboolean gtk_list_base_get_enable_rubberband (GtkListBase *self);
|
||||
void gtk_list_base_allocate_rubberband (GtkListBase *self);
|
||||
|
||||
void gtk_list_base_allocate (GtkListBase *self);
|
||||
void gtk_list_base_size_allocate_child (GtkListBase *self,
|
||||
GtkWidget *child,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
#endif /* __GTK_LIST_BASE_PRIVATE_H__ */
|
||||
|
||||
+194
-490
@@ -39,9 +39,6 @@ struct _GtkListItemManager
|
||||
|
||||
GtkRbTree *items;
|
||||
GSList *trackers;
|
||||
|
||||
GtkListTile * (* split_func) (gpointer, GtkListTile *, guint);
|
||||
gpointer user_data;
|
||||
};
|
||||
|
||||
struct _GtkListItemManagerClass
|
||||
@@ -77,70 +74,54 @@ static void gtk_list_item_manager_release_list_item (GtkListItemMana
|
||||
GtkWidget *widget);
|
||||
G_DEFINE_TYPE (GtkListItemManager, gtk_list_item_manager, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
potentially_empty_rectangle_union (cairo_rectangle_int_t *self,
|
||||
const cairo_rectangle_int_t *area)
|
||||
{
|
||||
if (area->width <= 0 || area->height <= 0)
|
||||
return;
|
||||
|
||||
if (self->width <= 0 || self->height <= 0)
|
||||
{
|
||||
*self = *area;
|
||||
return;
|
||||
}
|
||||
|
||||
gdk_rectangle_union (self, area, self);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
gtk_list_item_manager_augment_node (GtkRbTree *tree,
|
||||
gpointer node_augment,
|
||||
gpointer node,
|
||||
gpointer left,
|
||||
gpointer right)
|
||||
{
|
||||
GtkListTile *tile = node;
|
||||
GtkListTileAugment *aug = node_augment;
|
||||
GtkListItemManagerItem *item = node;
|
||||
GtkListItemManagerItemAugment *aug = node_augment;
|
||||
|
||||
aug->n_items = tile->n_items;
|
||||
aug->area = tile->area;
|
||||
aug->n_items = item->n_items;
|
||||
|
||||
if (left)
|
||||
{
|
||||
GtkListTileAugment *left_aug = gtk_rb_tree_get_augment (tree, left);
|
||||
GtkListItemManagerItemAugment *left_aug = gtk_rb_tree_get_augment (tree, left);
|
||||
|
||||
aug->n_items += left_aug->n_items;
|
||||
potentially_empty_rectangle_union (&aug->area, &left_aug->area);
|
||||
}
|
||||
|
||||
if (right)
|
||||
{
|
||||
GtkListTileAugment *right_aug = gtk_rb_tree_get_augment (tree, right);
|
||||
GtkListItemManagerItemAugment *right_aug = gtk_rb_tree_get_augment (tree, right);
|
||||
|
||||
aug->n_items += right_aug->n_items;
|
||||
potentially_empty_rectangle_union (&aug->area, &right_aug->area);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_list_item_manager_clear_node (gpointer _tile)
|
||||
gtk_list_item_manager_clear_node (gpointer _item)
|
||||
{
|
||||
GtkListTile *tile G_GNUC_UNUSED = _tile;
|
||||
GtkListItemManagerItem *item G_GNUC_UNUSED = _item;
|
||||
|
||||
g_assert (tile->widget == NULL);
|
||||
g_assert (item->widget == NULL);
|
||||
}
|
||||
|
||||
GtkListItemManager *
|
||||
gtk_list_item_manager_new (GtkWidget *widget,
|
||||
const char *item_css_name,
|
||||
GtkAccessibleRole item_role,
|
||||
GtkListTile * (* split_func) (gpointer, GtkListTile *, guint),
|
||||
gpointer user_data)
|
||||
gtk_list_item_manager_new_for_size (GtkWidget *widget,
|
||||
const char *item_css_name,
|
||||
GtkAccessibleRole item_role,
|
||||
gsize element_size,
|
||||
gsize augment_size,
|
||||
GtkRbTreeAugmentFunc augment_func)
|
||||
{
|
||||
GtkListItemManager *self;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
g_return_val_if_fail (element_size >= sizeof (GtkListItemManagerItem), NULL);
|
||||
g_return_val_if_fail (augment_size >= sizeof (GtkListItemManagerItemAugment), NULL);
|
||||
|
||||
self = g_object_new (GTK_TYPE_LIST_ITEM_MANAGER, NULL);
|
||||
|
||||
@@ -148,48 +129,22 @@ gtk_list_item_manager_new (GtkWidget *widget,
|
||||
self->widget = widget;
|
||||
self->item_css_name = g_intern_string (item_css_name);
|
||||
self->item_role = item_role;
|
||||
self->split_func = split_func;
|
||||
self->user_data = user_data;
|
||||
|
||||
self->items = gtk_rb_tree_new_for_size (sizeof (GtkListTile),
|
||||
sizeof (GtkListTileAugment),
|
||||
gtk_list_item_manager_augment_node,
|
||||
self->items = gtk_rb_tree_new_for_size (element_size,
|
||||
augment_size,
|
||||
augment_func,
|
||||
gtk_list_item_manager_clear_node,
|
||||
NULL);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_list_item_manager_get_tile_bounds (GtkListItemManager *self,
|
||||
GdkRectangle *out_bounds)
|
||||
{
|
||||
GtkListTile *tile;
|
||||
GtkListTileAugment *aug;
|
||||
|
||||
tile = gtk_rb_tree_get_root (self->items);
|
||||
if (tile == NULL)
|
||||
{
|
||||
*out_bounds = (GdkRectangle) { 0, 0, 0, 0 };
|
||||
return;
|
||||
}
|
||||
|
||||
aug = gtk_rb_tree_get_augment (self->items, tile);
|
||||
*out_bounds = aug->area;
|
||||
}
|
||||
|
||||
gpointer
|
||||
gtk_list_item_manager_get_first (GtkListItemManager *self)
|
||||
{
|
||||
return gtk_rb_tree_get_first (self->items);
|
||||
}
|
||||
|
||||
gpointer
|
||||
gtk_list_item_manager_get_last (GtkListItemManager *self)
|
||||
{
|
||||
return gtk_rb_tree_get_last (self->items);
|
||||
}
|
||||
|
||||
gpointer
|
||||
gtk_list_item_manager_get_root (GtkListItemManager *self)
|
||||
{
|
||||
@@ -200,15 +155,15 @@ gtk_list_item_manager_get_root (GtkListItemManager *self)
|
||||
* gtk_list_item_manager_get_nth:
|
||||
* @self: a `GtkListItemManager`
|
||||
* @position: position of the item
|
||||
* @offset: (out): offset into the returned tile
|
||||
* @offset: (out): offset into the returned item
|
||||
*
|
||||
* Looks up the GtkListTile that represents @position.
|
||||
* Looks up the GtkListItemManagerItem that represents @position.
|
||||
*
|
||||
* If a the returned tile represents multiple rows, the @offset into
|
||||
* the returned tile for @position will be set. If the returned tile
|
||||
* If a the returned item represents multiple rows, the @offset into
|
||||
* the returned item for @position will be set. If the returned item
|
||||
* represents a row with an existing widget, @offset will always be 0.
|
||||
*
|
||||
* Returns: (type GtkListTile): the tile for @position or
|
||||
* Returns: (type GtkListItemManagerItem): the item for @position or
|
||||
* %NULL if position is out of range
|
||||
**/
|
||||
gpointer
|
||||
@@ -216,186 +171,48 @@ gtk_list_item_manager_get_nth (GtkListItemManager *self,
|
||||
guint position,
|
||||
guint *offset)
|
||||
{
|
||||
GtkListTile *tile, *tmp;
|
||||
GtkListItemManagerItem *item, *tmp;
|
||||
|
||||
tile = gtk_rb_tree_get_root (self->items);
|
||||
item = gtk_rb_tree_get_root (self->items);
|
||||
|
||||
while (tile)
|
||||
while (item)
|
||||
{
|
||||
tmp = gtk_rb_tree_node_get_left (tile);
|
||||
tmp = gtk_rb_tree_node_get_left (item);
|
||||
if (tmp)
|
||||
{
|
||||
GtkListTileAugment *aug = gtk_rb_tree_get_augment (self->items, tmp);
|
||||
GtkListItemManagerItemAugment *aug = gtk_rb_tree_get_augment (self->items, tmp);
|
||||
if (position < aug->n_items)
|
||||
{
|
||||
tile = tmp;
|
||||
item = tmp;
|
||||
continue;
|
||||
}
|
||||
position -= aug->n_items;
|
||||
}
|
||||
|
||||
if (position < tile->n_items)
|
||||
if (position < item->n_items)
|
||||
break;
|
||||
position -= tile->n_items;
|
||||
position -= item->n_items;
|
||||
|
||||
tile = gtk_rb_tree_node_get_right (tile);
|
||||
item = gtk_rb_tree_node_get_right (item);
|
||||
}
|
||||
|
||||
if (offset)
|
||||
*offset = tile ? position : 0;
|
||||
*offset = item ? position : 0;
|
||||
|
||||
return tile;
|
||||
}
|
||||
|
||||
/* This computes Manhattan distance */
|
||||
static int
|
||||
rectangle_distance (const cairo_rectangle_int_t *rect,
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
int x_dist, y_dist;
|
||||
|
||||
if (rect->x > x)
|
||||
x_dist = rect->x - x;
|
||||
else if (rect->x + rect->width < x)
|
||||
x_dist = x - (rect->x + rect->width);
|
||||
else
|
||||
x_dist = 0;
|
||||
|
||||
if (rect->y > y)
|
||||
y_dist = rect->y - y;
|
||||
else if (rect->y + rect->height < y)
|
||||
y_dist = y - (rect->y + rect->height);
|
||||
else
|
||||
y_dist = 0;
|
||||
|
||||
return x_dist + y_dist;
|
||||
}
|
||||
|
||||
static GtkListTile *
|
||||
gtk_list_tile_get_tile_at (GtkListItemManager *self,
|
||||
GtkListTile *tile,
|
||||
int x,
|
||||
int y,
|
||||
int *distance)
|
||||
{
|
||||
GtkListTileAugment *aug;
|
||||
GtkListTile *left, *right, *result;
|
||||
int dist, left_dist, right_dist;
|
||||
|
||||
left = gtk_rb_tree_node_get_left (tile);
|
||||
if (left)
|
||||
{
|
||||
aug = gtk_list_tile_get_augment (self, left);
|
||||
left_dist = rectangle_distance (&aug->area, x, y);
|
||||
}
|
||||
else
|
||||
left_dist = *distance;
|
||||
right = gtk_rb_tree_node_get_right (tile);
|
||||
if (right)
|
||||
{
|
||||
aug = gtk_list_tile_get_augment (self, right);
|
||||
right_dist = rectangle_distance (&aug->area, x, y);
|
||||
}
|
||||
else
|
||||
right_dist = *distance;
|
||||
|
||||
dist = rectangle_distance (&tile->area, x, y);
|
||||
result = NULL;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
if (dist < left_dist && dist < right_dist)
|
||||
{
|
||||
if (dist >= *distance)
|
||||
return result;
|
||||
|
||||
*distance = dist;
|
||||
return tile;
|
||||
}
|
||||
|
||||
if (left_dist < right_dist)
|
||||
{
|
||||
if (left_dist >= *distance)
|
||||
return result;
|
||||
|
||||
left = gtk_list_tile_get_tile_at (self, left, x, y, distance);
|
||||
if (left)
|
||||
result = left;
|
||||
left_dist = G_MAXINT;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (right_dist >= *distance)
|
||||
return result;
|
||||
|
||||
right = gtk_list_tile_get_tile_at (self, right, x, y, distance);
|
||||
if (right)
|
||||
result = right;
|
||||
right_dist = G_MAXINT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gtk_list_item_manager_get_tile_at:
|
||||
* @self: a GtkListItemManager
|
||||
* @x: x coordinate of tile
|
||||
* @y: y coordinate of tile
|
||||
*
|
||||
* Finds the tile occupying the coordinates at (x, y). If no
|
||||
* tile occupies the coordinates (for example, if the tile is out of bounds),
|
||||
* NULL is returned.
|
||||
*
|
||||
* Returns: (nullable): The tile at (x, y) or NULL
|
||||
**/
|
||||
GtkListTile *
|
||||
gtk_list_item_manager_get_tile_at (GtkListItemManager *self,
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
int distance = 1;
|
||||
|
||||
return gtk_list_tile_get_tile_at (self, gtk_list_item_manager_get_root (self), x, y, &distance);
|
||||
}
|
||||
|
||||
/*
|
||||
* gtk_list_item_manager_get_nearest_tile:
|
||||
* @self: a GtkListItemManager
|
||||
* @x: x coordinate of tile
|
||||
* @y: y coordinate of tile
|
||||
*
|
||||
* Finds the tile closest to the coordinates at (x, y). If no
|
||||
* tile occupies the coordinates (for example, if the tile is out of bounds),
|
||||
* Manhattan distance is used to find the nearest tile.
|
||||
*
|
||||
* If multiple tiles have the same distance, the one closest to the start
|
||||
* will be returned.
|
||||
*
|
||||
* Returns: (nullable): The tile nearest to (x, y) or NULL if there are no
|
||||
* tile
|
||||
**/
|
||||
GtkListTile *
|
||||
gtk_list_item_manager_get_nearest_tile (GtkListItemManager *self,
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
int distance = G_MAXINT;
|
||||
|
||||
return gtk_list_tile_get_tile_at (self, gtk_list_item_manager_get_root (self), x, y, &distance);
|
||||
return item;
|
||||
}
|
||||
|
||||
guint
|
||||
gtk_list_tile_get_position (GtkListItemManager *self,
|
||||
GtkListTile *tile)
|
||||
gtk_list_item_manager_get_item_position (GtkListItemManager *self,
|
||||
gpointer item)
|
||||
{
|
||||
GtkListTile *parent, *left;
|
||||
GtkListItemManagerItem *parent, *left;
|
||||
int pos;
|
||||
|
||||
left = gtk_rb_tree_node_get_left (tile);
|
||||
left = gtk_rb_tree_node_get_left (item);
|
||||
if (left)
|
||||
{
|
||||
GtkListTileAugment *aug = gtk_rb_tree_get_augment (self->items, left);
|
||||
GtkListItemManagerItemAugment *aug = gtk_rb_tree_get_augment (self->items, left);
|
||||
pos = aug->n_items;
|
||||
}
|
||||
else
|
||||
@@ -403,93 +220,33 @@ gtk_list_tile_get_position (GtkListItemManager *self,
|
||||
pos = 0;
|
||||
}
|
||||
|
||||
for (parent = gtk_rb_tree_node_get_parent (tile);
|
||||
for (parent = gtk_rb_tree_node_get_parent (item);
|
||||
parent != NULL;
|
||||
parent = gtk_rb_tree_node_get_parent (tile))
|
||||
parent = gtk_rb_tree_node_get_parent (item))
|
||||
{
|
||||
left = gtk_rb_tree_node_get_left (parent);
|
||||
|
||||
if (left != tile)
|
||||
if (left != item)
|
||||
{
|
||||
if (left)
|
||||
{
|
||||
GtkListTileAugment *aug = gtk_rb_tree_get_augment (self->items, left);
|
||||
GtkListItemManagerItemAugment *aug = gtk_rb_tree_get_augment (self->items, left);
|
||||
pos += aug->n_items;
|
||||
}
|
||||
pos += parent->n_items;
|
||||
}
|
||||
|
||||
tile = parent;
|
||||
item = parent;
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
gpointer
|
||||
gtk_list_tile_get_augment (GtkListItemManager *self,
|
||||
GtkListTile *tile)
|
||||
gtk_list_item_manager_get_item_augment (GtkListItemManager *self,
|
||||
gpointer item)
|
||||
{
|
||||
return gtk_rb_tree_get_augment (self->items, tile);
|
||||
}
|
||||
|
||||
/*
|
||||
* gtk_list_tile_set_area:
|
||||
* @self: the list item manager
|
||||
* @tile: tile to set area for
|
||||
* @area: (nullable): area to set or NULL to clear
|
||||
* the area
|
||||
*
|
||||
* Updates the area of the tile.
|
||||
*
|
||||
* The area is given in the internal coordinate system,
|
||||
* so the x/y flip due to orientation and the left/right
|
||||
* flip for RTL languages will happen later.
|
||||
*
|
||||
* This function should only be called from inside size_allocate().
|
||||
**/
|
||||
void
|
||||
gtk_list_tile_set_area (GtkListItemManager *self,
|
||||
GtkListTile *tile,
|
||||
const cairo_rectangle_int_t *area)
|
||||
{
|
||||
cairo_rectangle_int_t empty_area = { 0, 0, 0, 0 };
|
||||
|
||||
if (!area)
|
||||
area = &empty_area;
|
||||
|
||||
if (gdk_rectangle_equal (&tile->area, area))
|
||||
return;
|
||||
|
||||
tile->area = *area;
|
||||
gtk_rb_tree_node_mark_dirty (tile);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_list_tile_set_area_position (GtkListItemManager *self,
|
||||
GtkListTile *tile,
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
if (tile->area.x == x && tile->area.y == y)
|
||||
return;
|
||||
|
||||
tile->area.x = x;
|
||||
tile->area.y = y;
|
||||
gtk_rb_tree_node_mark_dirty (tile);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_list_tile_set_area_size (GtkListItemManager *self,
|
||||
GtkListTile *tile,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
if (tile->area.width == width && tile->area.height == height)
|
||||
return;
|
||||
|
||||
tile->area.width = width;
|
||||
tile->area.height = height;
|
||||
gtk_rb_tree_node_mark_dirty (tile);
|
||||
return gtk_rb_tree_get_augment (self->items, item);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -590,47 +347,37 @@ restart:
|
||||
}
|
||||
}
|
||||
|
||||
static GtkListTile *
|
||||
gtk_list_item_manager_ensure_split (GtkListItemManager *self,
|
||||
GtkListTile *tile,
|
||||
guint n_items)
|
||||
{
|
||||
return self->split_func (self->user_data, tile, n_items);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_list_item_manager_remove_items (GtkListItemManager *self,
|
||||
GHashTable *change,
|
||||
guint position,
|
||||
guint n_items)
|
||||
{
|
||||
GtkListTile *tile, *next;
|
||||
guint offset;
|
||||
GtkListItemManagerItem *item;
|
||||
|
||||
if (n_items == 0)
|
||||
return;
|
||||
|
||||
tile = gtk_list_item_manager_get_nth (self, position, &offset);
|
||||
if (offset)
|
||||
tile = gtk_list_item_manager_ensure_split (self, tile, offset);
|
||||
item = gtk_list_item_manager_get_nth (self, position, NULL);
|
||||
|
||||
while (n_items > 0)
|
||||
{
|
||||
if (tile->n_items > n_items)
|
||||
if (item->n_items > n_items)
|
||||
{
|
||||
gtk_list_item_manager_ensure_split (self, tile, n_items);
|
||||
g_assert (tile->n_items <= n_items);
|
||||
item->n_items -= n_items;
|
||||
gtk_rb_tree_node_mark_dirty (item);
|
||||
n_items = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkListItemManagerItem *next = gtk_rb_tree_node_get_next (item);
|
||||
if (item->widget)
|
||||
gtk_list_item_manager_release_list_item (self, change, item->widget);
|
||||
item->widget = NULL;
|
||||
n_items -= item->n_items;
|
||||
gtk_rb_tree_remove (self->items, item);
|
||||
item = next;
|
||||
}
|
||||
|
||||
next = gtk_rb_tree_node_get_next (tile);
|
||||
if (tile->widget)
|
||||
gtk_list_item_manager_release_list_item (self, change, tile->widget);
|
||||
tile->widget = NULL;
|
||||
n_items -= tile->n_items;
|
||||
tile->n_items = 0;
|
||||
gtk_rb_tree_node_mark_dirty (tile);
|
||||
|
||||
tile = next;
|
||||
}
|
||||
|
||||
gtk_widget_queue_resize (GTK_WIDGET (self->widget));
|
||||
@@ -641,27 +388,26 @@ gtk_list_item_manager_add_items (GtkListItemManager *self,
|
||||
guint position,
|
||||
guint n_items)
|
||||
{
|
||||
GtkListTile *tile;
|
||||
GtkListItemManagerItem *item;
|
||||
guint offset;
|
||||
|
||||
if (n_items == 0)
|
||||
return;
|
||||
|
||||
tile = gtk_list_item_manager_get_nth (self, position, &offset);
|
||||
if (offset)
|
||||
tile = gtk_list_item_manager_ensure_split (self, tile, offset);
|
||||
item = gtk_list_item_manager_get_nth (self, position, &offset);
|
||||
|
||||
tile = gtk_rb_tree_insert_before (self->items, tile);
|
||||
tile->n_items = n_items;
|
||||
gtk_rb_tree_node_mark_dirty (tile);
|
||||
if (item == NULL || item->widget)
|
||||
item = gtk_rb_tree_insert_before (self->items, item);
|
||||
item->n_items += n_items;
|
||||
gtk_rb_tree_node_mark_dirty (item);
|
||||
|
||||
gtk_widget_queue_resize (GTK_WIDGET (self->widget));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_list_item_manager_merge_list_items (GtkListItemManager *self,
|
||||
GtkListTile *first,
|
||||
GtkListTile *second)
|
||||
gtk_list_item_manager_merge_list_items (GtkListItemManager *self,
|
||||
GtkListItemManagerItem *first,
|
||||
GtkListItemManagerItem *second)
|
||||
{
|
||||
if (first->widget || second->widget)
|
||||
return FALSE;
|
||||
@@ -673,86 +419,11 @@ gtk_list_item_manager_merge_list_items (GtkListItemManager *self,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* gtk_list_tile_split:
|
||||
* @self: the listitemmanager
|
||||
* @tile: a tile to split into two
|
||||
* @n_items: nuber of items to keep in tile
|
||||
*
|
||||
* Splits the given tile into two tiles. The original
|
||||
* tile will remain with @n_items items, the remaining
|
||||
* items will be given to the new tile, which will be
|
||||
* nserted after the tile.
|
||||
*
|
||||
* It is valid for either tile to have 0 items after
|
||||
* the split.
|
||||
*
|
||||
* Returns: The new tile
|
||||
**/
|
||||
GtkListTile *
|
||||
gtk_list_tile_split (GtkListItemManager *self,
|
||||
GtkListTile *tile,
|
||||
guint n_items)
|
||||
{
|
||||
GtkListTile *result;
|
||||
|
||||
g_assert (n_items <= tile->n_items);
|
||||
|
||||
result = gtk_rb_tree_insert_after (self->items, tile);
|
||||
result->n_items = tile->n_items - n_items;
|
||||
tile->n_items = n_items;
|
||||
gtk_rb_tree_node_mark_dirty (tile);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* gtk_list_tile_gc:
|
||||
* @self: the listitemmanager
|
||||
* @tile: a tile
|
||||
*
|
||||
* Tries to get rid of tiles when they aren't needed anymore,
|
||||
* either because their referenced listitems were deleted or
|
||||
* because they can be merged with the next item(s).
|
||||
*
|
||||
* Note that this only looks forward, but never backward.
|
||||
*
|
||||
* Returns: The next tile
|
||||
**/
|
||||
GtkListTile *
|
||||
gtk_list_tile_gc (GtkListItemManager *self,
|
||||
GtkListTile *tile)
|
||||
{
|
||||
GtkListTile *next;
|
||||
|
||||
while (tile)
|
||||
{
|
||||
next = gtk_rb_tree_node_get_next (tile);
|
||||
|
||||
if (tile->n_items == 0)
|
||||
{
|
||||
gtk_rb_tree_remove (self->items, tile);
|
||||
tile = next;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (next == NULL)
|
||||
break;
|
||||
|
||||
if (gtk_list_item_manager_merge_list_items (self, tile, next))
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return tile;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_list_item_manager_release_items (GtkListItemManager *self,
|
||||
GQueue *released)
|
||||
{
|
||||
GtkListTile *tile;
|
||||
GtkListItemManagerItem *item, *prev, *next;
|
||||
guint position, i, n_items, query_n_items;
|
||||
gboolean tracked;
|
||||
|
||||
@@ -768,18 +439,37 @@ gtk_list_item_manager_release_items (GtkListItemManager *self,
|
||||
continue;
|
||||
}
|
||||
|
||||
tile = gtk_list_item_manager_get_nth (self, position, &i);
|
||||
item = gtk_list_item_manager_get_nth (self, position, &i);
|
||||
i = position - i;
|
||||
while (i < position + query_n_items)
|
||||
{
|
||||
g_assert (tile != NULL);
|
||||
if (tile->widget)
|
||||
g_assert (item != NULL);
|
||||
if (item->widget)
|
||||
{
|
||||
g_queue_push_tail (released, tile->widget);
|
||||
tile->widget = NULL;
|
||||
g_queue_push_tail (released, item->widget);
|
||||
item->widget = NULL;
|
||||
i++;
|
||||
prev = gtk_rb_tree_node_get_previous (item);
|
||||
if (prev && gtk_list_item_manager_merge_list_items (self, prev, item))
|
||||
item = prev;
|
||||
next = gtk_rb_tree_node_get_next (item);
|
||||
if (next && next->widget == NULL)
|
||||
{
|
||||
i += next->n_items;
|
||||
if (!gtk_list_item_manager_merge_list_items (self, next, item))
|
||||
g_assert_not_reached ();
|
||||
item = gtk_rb_tree_node_get_next (next);
|
||||
}
|
||||
else
|
||||
{
|
||||
item = next;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
i += item->n_items;
|
||||
item = gtk_rb_tree_node_get_next (item);
|
||||
}
|
||||
i += tile->n_items;
|
||||
tile = gtk_rb_tree_node_get_next (tile);
|
||||
}
|
||||
position += query_n_items;
|
||||
}
|
||||
@@ -790,7 +480,7 @@ gtk_list_item_manager_ensure_items (GtkListItemManager *self,
|
||||
GHashTable *change,
|
||||
guint update_start)
|
||||
{
|
||||
GtkListTile *tile, *other_tile;
|
||||
GtkListItemManagerItem *item, *new_item;
|
||||
GtkWidget *widget, *insert_after;
|
||||
guint position, i, n_items, query_n_items, offset;
|
||||
GQueue released = G_QUEUE_INIT;
|
||||
@@ -813,61 +503,70 @@ gtk_list_item_manager_ensure_items (GtkListItemManager *self,
|
||||
continue;
|
||||
}
|
||||
|
||||
tile = gtk_list_item_manager_get_nth (self, position, &offset);
|
||||
for (other_tile = tile;
|
||||
other_tile && other_tile->widget == NULL;
|
||||
other_tile = gtk_rb_tree_node_get_previous (other_tile))
|
||||
item = gtk_list_item_manager_get_nth (self, position, &offset);
|
||||
for (new_item = item;
|
||||
new_item && new_item->widget == NULL;
|
||||
new_item = gtk_rb_tree_node_get_previous (new_item))
|
||||
{ /* do nothing */ }
|
||||
insert_after = other_tile ? other_tile->widget : NULL;
|
||||
insert_after = new_item ? new_item->widget : NULL;
|
||||
|
||||
if (offset > 0)
|
||||
tile = gtk_list_item_manager_ensure_split (self, tile, offset);
|
||||
{
|
||||
g_assert (item != NULL);
|
||||
new_item = gtk_rb_tree_insert_before (self->items, item);
|
||||
new_item->n_items = offset;
|
||||
item->n_items -= offset;
|
||||
gtk_rb_tree_node_mark_dirty (item);
|
||||
}
|
||||
|
||||
for (i = 0; i < query_n_items; i++)
|
||||
{
|
||||
g_assert (tile != NULL);
|
||||
|
||||
while (tile->n_items == 0)
|
||||
tile = gtk_rb_tree_node_get_next (tile);
|
||||
|
||||
if (tile->n_items > 1)
|
||||
gtk_list_item_manager_ensure_split (self, tile, 1);
|
||||
|
||||
if (tile->widget == NULL)
|
||||
g_assert (item != NULL);
|
||||
if (item->n_items > 1)
|
||||
{
|
||||
new_item = gtk_rb_tree_insert_before (self->items, item);
|
||||
new_item->n_items = 1;
|
||||
item->n_items--;
|
||||
gtk_rb_tree_node_mark_dirty (item);
|
||||
}
|
||||
else
|
||||
{
|
||||
new_item = item;
|
||||
item = gtk_rb_tree_node_get_next (item);
|
||||
}
|
||||
if (new_item->widget == NULL)
|
||||
{
|
||||
if (change)
|
||||
{
|
||||
tile->widget = gtk_list_item_manager_try_reacquire_list_item (self,
|
||||
change,
|
||||
position + i,
|
||||
insert_after);
|
||||
new_item->widget = gtk_list_item_manager_try_reacquire_list_item (self,
|
||||
change,
|
||||
position + i,
|
||||
insert_after);
|
||||
}
|
||||
if (tile->widget == NULL)
|
||||
if (new_item->widget == NULL)
|
||||
{
|
||||
tile->widget = g_queue_pop_head (&released);
|
||||
if (tile->widget)
|
||||
new_item->widget = g_queue_pop_head (&released);
|
||||
if (new_item->widget)
|
||||
{
|
||||
gtk_list_item_manager_move_list_item (self,
|
||||
tile->widget,
|
||||
new_item->widget,
|
||||
position + i,
|
||||
insert_after);
|
||||
}
|
||||
else
|
||||
{
|
||||
tile->widget = gtk_list_item_manager_acquire_list_item (self,
|
||||
position + i,
|
||||
insert_after);
|
||||
new_item->widget = gtk_list_item_manager_acquire_list_item (self,
|
||||
position + i,
|
||||
insert_after);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (update_start <= position + i)
|
||||
gtk_list_item_manager_update_list_item (self, tile->widget, position + i);
|
||||
gtk_list_item_manager_update_list_item (self, new_item->widget, position + i);
|
||||
}
|
||||
insert_after = tile->widget;
|
||||
|
||||
tile = gtk_rb_tree_node_get_next (tile);
|
||||
insert_after = new_item->widget;
|
||||
}
|
||||
position += query_n_items;
|
||||
}
|
||||
@@ -909,17 +608,17 @@ gtk_list_item_manager_model_items_changed_cb (GListModel *model,
|
||||
* trying to find where it moved */
|
||||
if (l)
|
||||
{
|
||||
GtkListTile *tile, *new_tile;
|
||||
GtkListItemManagerItem *item, *new_item;
|
||||
GtkWidget *insert_after;
|
||||
guint i, offset;
|
||||
|
||||
tile = gtk_list_item_manager_get_nth (self, position, &offset);
|
||||
for (new_tile = tile ? gtk_rb_tree_node_get_previous (tile) : gtk_rb_tree_get_last (self->items);
|
||||
new_tile && new_tile->widget == NULL;
|
||||
new_tile = gtk_rb_tree_node_get_previous (new_tile))
|
||||
item = gtk_list_item_manager_get_nth (self, position, &offset);
|
||||
for (new_item = item ? gtk_rb_tree_node_get_previous (item) : gtk_rb_tree_get_last (self->items);
|
||||
new_item && new_item->widget == NULL;
|
||||
new_item = gtk_rb_tree_node_get_previous (new_item))
|
||||
{ }
|
||||
if (new_tile)
|
||||
insert_after = new_tile->widget;
|
||||
if (new_item)
|
||||
insert_after = new_item->widget;
|
||||
else
|
||||
insert_after = NULL; /* we're at the start */
|
||||
|
||||
@@ -937,24 +636,29 @@ gtk_list_item_manager_model_items_changed_cb (GListModel *model,
|
||||
continue;
|
||||
}
|
||||
|
||||
while (offset >= tile->n_items)
|
||||
{
|
||||
offset -= tile->n_items;
|
||||
tile = gtk_rb_tree_node_get_next (tile);
|
||||
}
|
||||
if (offset > 0)
|
||||
{
|
||||
tile = gtk_list_item_manager_ensure_split (self, tile, offset);
|
||||
new_item = gtk_rb_tree_insert_before (self->items, item);
|
||||
new_item->n_items = offset;
|
||||
item->n_items -= offset;
|
||||
offset = 0;
|
||||
gtk_rb_tree_node_mark_dirty (item);
|
||||
}
|
||||
|
||||
new_tile = tile;
|
||||
if (tile->n_items == 1)
|
||||
tile = gtk_rb_tree_node_get_next (tile);
|
||||
if (item->n_items == 1)
|
||||
{
|
||||
new_item = item;
|
||||
item = gtk_rb_tree_node_get_next (item);
|
||||
}
|
||||
else
|
||||
tile = gtk_list_item_manager_ensure_split (self, tile, 1);
|
||||
{
|
||||
new_item = gtk_rb_tree_insert_before (self->items, item);
|
||||
new_item->n_items = 1;
|
||||
item->n_items--;
|
||||
gtk_rb_tree_node_mark_dirty (item);
|
||||
}
|
||||
|
||||
new_tile->widget = widget;
|
||||
new_item->widget = widget;
|
||||
insert_after = widget;
|
||||
}
|
||||
}
|
||||
@@ -1015,16 +719,16 @@ gtk_list_item_manager_model_items_changed_cb (GListModel *model,
|
||||
for (l = self->trackers; l; l = l->next)
|
||||
{
|
||||
GtkListItemTracker *tracker = l->data;
|
||||
GtkListTile *tile;
|
||||
GtkListItemManagerItem *item;
|
||||
|
||||
if (tracker->widget != NULL ||
|
||||
tracker->position == GTK_INVALID_LIST_POSITION)
|
||||
continue;
|
||||
|
||||
tile = gtk_list_item_manager_get_nth (self, tracker->position, NULL);
|
||||
g_assert (tile != NULL);
|
||||
g_assert (tile->widget);
|
||||
tracker->widget = GTK_LIST_ITEM_WIDGET (tile->widget);
|
||||
item = gtk_list_item_manager_get_nth (self, tracker->position, NULL);
|
||||
g_assert (item != NULL);
|
||||
g_assert (item->widget);
|
||||
tracker->widget = GTK_LIST_ITEM_WIDGET (item->widget);
|
||||
}
|
||||
|
||||
g_hash_table_unref (change);
|
||||
@@ -1038,28 +742,28 @@ gtk_list_item_manager_model_selection_changed_cb (GListModel *model,
|
||||
guint n_items,
|
||||
GtkListItemManager *self)
|
||||
{
|
||||
GtkListTile *tile;
|
||||
GtkListItemManagerItem *item;
|
||||
guint offset;
|
||||
|
||||
tile = gtk_list_item_manager_get_nth (self, position, &offset);
|
||||
item = gtk_list_item_manager_get_nth (self, position, &offset);
|
||||
|
||||
if (offset)
|
||||
{
|
||||
position += tile->n_items - offset;
|
||||
if (tile->n_items - offset > n_items)
|
||||
position += item->n_items - offset;
|
||||
if (item->n_items - offset > n_items)
|
||||
n_items = 0;
|
||||
else
|
||||
n_items -= tile->n_items - offset;
|
||||
tile = gtk_rb_tree_node_get_next (tile);
|
||||
n_items -= item->n_items - offset;
|
||||
item = gtk_rb_tree_node_get_next (item);
|
||||
}
|
||||
|
||||
while (n_items > 0)
|
||||
{
|
||||
if (tile->widget)
|
||||
gtk_list_item_manager_update_list_item (self, tile->widget, position);
|
||||
position += tile->n_items;
|
||||
n_items -= MIN (n_items, tile->n_items);
|
||||
tile = gtk_rb_tree_node_get_next (tile);
|
||||
if (item->widget)
|
||||
gtk_list_item_manager_update_list_item (self, item->widget, position);
|
||||
position += item->n_items;
|
||||
n_items -= MIN (n_items, item->n_items);
|
||||
item = gtk_rb_tree_node_get_next (item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1138,14 +842,14 @@ gtk_list_item_manager_set_factory (GtkListItemManager *self,
|
||||
for (l = self->trackers; l; l = l->next)
|
||||
{
|
||||
GtkListItemTracker *tracker = l->data;
|
||||
GtkListTile *tile;
|
||||
GtkListItemManagerItem *item;
|
||||
|
||||
if (tracker->widget == NULL)
|
||||
continue;
|
||||
|
||||
tile = gtk_list_item_manager_get_nth (self, tracker->position, NULL);
|
||||
g_assert (tile);
|
||||
tracker->widget = GTK_LIST_ITEM_WIDGET (tile->widget);
|
||||
item = gtk_list_item_manager_get_nth (self, tracker->position, NULL);
|
||||
g_assert (item);
|
||||
tracker->widget = GTK_LIST_ITEM_WIDGET (item->widget);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1383,18 +1087,18 @@ void
|
||||
gtk_list_item_manager_set_single_click_activate (GtkListItemManager *self,
|
||||
gboolean single_click_activate)
|
||||
{
|
||||
GtkListTile *tile;
|
||||
GtkListItemManagerItem *item;
|
||||
|
||||
g_return_if_fail (GTK_IS_LIST_ITEM_MANAGER (self));
|
||||
|
||||
self->single_click_activate = single_click_activate;
|
||||
|
||||
for (tile = gtk_rb_tree_get_first (self->items);
|
||||
tile != NULL;
|
||||
tile = gtk_rb_tree_node_get_next (tile))
|
||||
for (item = gtk_rb_tree_get_first (self->items);
|
||||
item != NULL;
|
||||
item = gtk_rb_tree_node_get_next (item))
|
||||
{
|
||||
if (tile->widget)
|
||||
gtk_list_item_widget_set_single_click_activate (GTK_LIST_ITEM_WIDGET (tile->widget), single_click_activate);
|
||||
if (item->widget)
|
||||
gtk_list_item_widget_set_single_click_activate (GTK_LIST_ITEM_WIDGET (item->widget), single_click_activate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1444,7 +1148,7 @@ gtk_list_item_tracker_set_position (GtkListItemManager *self,
|
||||
guint n_before,
|
||||
guint n_after)
|
||||
{
|
||||
GtkListTile *tile;
|
||||
GtkListItemManagerItem *item;
|
||||
guint n_items;
|
||||
|
||||
gtk_list_item_tracker_unset_position (self, tracker);
|
||||
@@ -1462,9 +1166,9 @@ gtk_list_item_tracker_set_position (GtkListItemManager *self,
|
||||
|
||||
gtk_list_item_manager_ensure_items (self, NULL, G_MAXUINT);
|
||||
|
||||
tile = gtk_list_item_manager_get_nth (self, position, NULL);
|
||||
if (tile)
|
||||
tracker->widget = GTK_LIST_ITEM_WIDGET (tile->widget);
|
||||
item = gtk_list_item_manager_get_nth (self, position, NULL);
|
||||
if (item)
|
||||
tracker->widget = GTK_LIST_ITEM_WIDGET (item->widget);
|
||||
|
||||
gtk_widget_queue_resize (self->widget);
|
||||
}
|
||||
|
||||
@@ -39,71 +39,47 @@ G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkListItemManager GtkListItemManager;
|
||||
typedef struct _GtkListItemManagerClass GtkListItemManagerClass;
|
||||
typedef struct _GtkListTile GtkListTile;
|
||||
typedef struct _GtkListTileAugment GtkListTileAugment;
|
||||
typedef struct _GtkListItemManagerItem GtkListItemManagerItem; /* sorry */
|
||||
typedef struct _GtkListItemManagerItemAugment GtkListItemManagerItemAugment;
|
||||
typedef struct _GtkListItemTracker GtkListItemTracker;
|
||||
|
||||
struct _GtkListTile
|
||||
struct _GtkListItemManagerItem
|
||||
{
|
||||
GtkWidget *widget;
|
||||
guint n_items;
|
||||
/* area occupied by tile. May be empty if tile has no allcoation */
|
||||
cairo_rectangle_int_t area;
|
||||
};
|
||||
|
||||
struct _GtkListTileAugment
|
||||
struct _GtkListItemManagerItemAugment
|
||||
{
|
||||
guint n_items;
|
||||
/* union of all areas of tile and children */
|
||||
cairo_rectangle_int_t area;
|
||||
};
|
||||
|
||||
|
||||
GType gtk_list_item_manager_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkListItemManager * gtk_list_item_manager_new (GtkWidget *widget,
|
||||
GtkListItemManager * gtk_list_item_manager_new_for_size (GtkWidget *widget,
|
||||
const char *item_css_name,
|
||||
GtkAccessibleRole item_role,
|
||||
GtkListTile * (* split_func) (gpointer, GtkListTile *, guint),
|
||||
gpointer user_data);
|
||||
gsize element_size,
|
||||
gsize augment_size,
|
||||
GtkRbTreeAugmentFunc augment_func);
|
||||
#define gtk_list_item_manager_new(widget, item_css_name, type, augment_type, augment_func) \
|
||||
gtk_list_item_manager_new_for_size (widget, item_css_name, sizeof (type), sizeof (augment_type), (augment_func))
|
||||
|
||||
void gtk_list_item_manager_get_tile_bounds (GtkListItemManager *self,
|
||||
GdkRectangle *out_bounds);
|
||||
void gtk_list_item_manager_augment_node (GtkRbTree *tree,
|
||||
gpointer node_augment,
|
||||
gpointer node,
|
||||
gpointer left,
|
||||
gpointer right);
|
||||
gpointer gtk_list_item_manager_get_root (GtkListItemManager *self);
|
||||
gpointer gtk_list_item_manager_get_first (GtkListItemManager *self);
|
||||
gpointer gtk_list_item_manager_get_last (GtkListItemManager *self);
|
||||
gpointer gtk_list_item_manager_get_nth (GtkListItemManager *self,
|
||||
guint position,
|
||||
guint *offset);
|
||||
GtkListTile * gtk_list_item_manager_get_tile_at (GtkListItemManager *self,
|
||||
int x,
|
||||
int y);
|
||||
GtkListTile * gtk_list_item_manager_get_nearest_tile (GtkListItemManager *self,
|
||||
int x,
|
||||
int y);
|
||||
|
||||
|
||||
guint gtk_list_tile_get_position (GtkListItemManager *self,
|
||||
GtkListTile *tile);
|
||||
gpointer gtk_list_tile_get_augment (GtkListItemManager *self,
|
||||
GtkListTile *tile);
|
||||
void gtk_list_tile_set_area (GtkListItemManager *self,
|
||||
GtkListTile *tile,
|
||||
const cairo_rectangle_int_t *area);
|
||||
void gtk_list_tile_set_area_position (GtkListItemManager *self,
|
||||
GtkListTile *tile,
|
||||
int x,
|
||||
int y);
|
||||
void gtk_list_tile_set_area_size (GtkListItemManager *self,
|
||||
GtkListTile *tile,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
GtkListTile * gtk_list_tile_split (GtkListItemManager *self,
|
||||
GtkListTile *tile,
|
||||
guint n_items);
|
||||
GtkListTile * gtk_list_tile_gc (GtkListItemManager *self,
|
||||
GtkListTile *tile);
|
||||
guint gtk_list_item_manager_get_item_position (GtkListItemManager *self,
|
||||
gpointer item);
|
||||
gpointer gtk_list_item_manager_get_item_augment (GtkListItemManager *self,
|
||||
gpointer item);
|
||||
|
||||
void gtk_list_item_manager_set_factory (GtkListItemManager *self,
|
||||
GtkListItemFactory *factory);
|
||||
|
||||
@@ -480,7 +480,6 @@ gtk_list_item_widget_click_gesture_released (GtkGestureClick *gesture,
|
||||
extend = (state & GDK_SHIFT_MASK) != 0;
|
||||
modify = (state & GDK_CONTROL_MASK) != 0;
|
||||
|
||||
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
||||
gtk_widget_activate_action (GTK_WIDGET (self),
|
||||
"list.select-item",
|
||||
"(ubb)",
|
||||
|
||||
+301
-199
@@ -141,6 +141,21 @@
|
||||
* items use the %GTK_ACCESSIBLE_ROLE_LIST_ITEM role.
|
||||
*/
|
||||
|
||||
typedef struct _ListRow ListRow;
|
||||
typedef struct _ListRowAugment ListRowAugment;
|
||||
|
||||
struct _ListRow
|
||||
{
|
||||
GtkListItemManagerItem parent;
|
||||
guint height; /* per row */
|
||||
};
|
||||
|
||||
struct _ListRowAugment
|
||||
{
|
||||
GtkListItemManagerItemAugment parent;
|
||||
guint height; /* total */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
@@ -166,116 +181,223 @@ static guint signals[LAST_SIGNAL] = { 0 };
|
||||
static void G_GNUC_UNUSED
|
||||
dump (GtkListView *self)
|
||||
{
|
||||
GtkListTile *tile;
|
||||
ListRow *row;
|
||||
guint n_widgets, n_list_rows;
|
||||
|
||||
n_widgets = 0;
|
||||
n_list_rows = 0;
|
||||
//g_print ("ANCHOR: %u - %u\n", self->anchor_start, self->anchor_end);
|
||||
for (tile = gtk_list_item_manager_get_first (self->item_manager);
|
||||
tile;
|
||||
tile = gtk_rb_tree_node_get_next (tile))
|
||||
for (row = gtk_list_item_manager_get_first (self->item_manager);
|
||||
row;
|
||||
row = gtk_rb_tree_node_get_next (row))
|
||||
{
|
||||
if (tile->widget)
|
||||
if (row->parent.widget)
|
||||
n_widgets++;
|
||||
n_list_rows++;
|
||||
g_print (" %4u%s %d,%d,%d,%d\n", tile->n_items, tile->widget ? " (widget)" : "",
|
||||
tile->area.x, tile->area.y, tile->area.width, tile->area.height);
|
||||
g_print (" %4u%s (%upx)\n", row->parent.n_items, row->parent.widget ? " (widget)" : "", row->height);
|
||||
}
|
||||
|
||||
g_print (" => %u widgets in %u list rows\n", n_widgets, n_list_rows);
|
||||
}
|
||||
|
||||
static GtkListTile *
|
||||
gtk_list_view_split (GtkListBase *base,
|
||||
GtkListTile *tile,
|
||||
guint n_items)
|
||||
static void
|
||||
list_row_augment (GtkRbTree *tree,
|
||||
gpointer node_augment,
|
||||
gpointer node,
|
||||
gpointer left,
|
||||
gpointer right)
|
||||
{
|
||||
GtkListView *self = GTK_LIST_VIEW (base);
|
||||
GtkListTile *new_tile;
|
||||
int spacing, row_height;
|
||||
ListRow *row = node;
|
||||
ListRowAugment *aug = node_augment;
|
||||
|
||||
gtk_list_base_get_border_spacing (GTK_LIST_BASE (self), NULL, &spacing);
|
||||
row_height = (tile->area.height - (tile->n_items - 1) * spacing) / tile->n_items;
|
||||
gtk_list_item_manager_augment_node (tree, node_augment, node, left, right);
|
||||
|
||||
new_tile = gtk_list_tile_split (self->item_manager, tile, n_items);
|
||||
gtk_list_tile_set_area_size (self->item_manager,
|
||||
tile,
|
||||
tile->area.width,
|
||||
row_height * tile->n_items + spacing * (tile->n_items - 1));
|
||||
gtk_list_tile_set_area (self->item_manager,
|
||||
new_tile,
|
||||
&(GdkRectangle) {
|
||||
tile->area.x,
|
||||
tile->area.y + tile->area.height + spacing,
|
||||
tile->area.width,
|
||||
row_height * new_tile->n_items + spacing * (new_tile->n_items - 1)
|
||||
});
|
||||
aug->height = row->height * row->parent.n_items;
|
||||
|
||||
return new_tile;
|
||||
if (left)
|
||||
{
|
||||
ListRowAugment *left_aug = gtk_rb_tree_get_augment (tree, left);
|
||||
|
||||
aug->height += left_aug->height;
|
||||
}
|
||||
|
||||
if (right)
|
||||
{
|
||||
ListRowAugment *right_aug = gtk_rb_tree_get_augment (tree, right);
|
||||
|
||||
aug->height += right_aug->height;
|
||||
}
|
||||
}
|
||||
|
||||
static ListRow *
|
||||
gtk_list_view_get_row_at_y (GtkListView *self,
|
||||
int y,
|
||||
int *offset)
|
||||
{
|
||||
ListRow *row, *tmp;
|
||||
|
||||
row = gtk_list_item_manager_get_root (self->item_manager);
|
||||
|
||||
while (row)
|
||||
{
|
||||
tmp = gtk_rb_tree_node_get_left (row);
|
||||
if (tmp)
|
||||
{
|
||||
ListRowAugment *aug = gtk_list_item_manager_get_item_augment (self->item_manager, tmp);
|
||||
if (y < aug->height)
|
||||
{
|
||||
row = tmp;
|
||||
continue;
|
||||
}
|
||||
y -= aug->height;
|
||||
}
|
||||
|
||||
if (y < row->height * row->parent.n_items)
|
||||
break;
|
||||
y -= row->height * row->parent.n_items;
|
||||
|
||||
row = gtk_rb_tree_node_get_right (row);
|
||||
}
|
||||
|
||||
if (offset)
|
||||
*offset = row ? y : 0;
|
||||
|
||||
return row;
|
||||
}
|
||||
|
||||
static int
|
||||
list_row_get_y (GtkListView *self,
|
||||
ListRow *row)
|
||||
{
|
||||
ListRow *parent, *left;
|
||||
int y;
|
||||
|
||||
left = gtk_rb_tree_node_get_left (row);
|
||||
if (left)
|
||||
{
|
||||
ListRowAugment *aug = gtk_list_item_manager_get_item_augment (self->item_manager, left);
|
||||
y = aug->height;
|
||||
}
|
||||
else
|
||||
y = 0;
|
||||
|
||||
for (parent = gtk_rb_tree_node_get_parent (row);
|
||||
parent != NULL;
|
||||
parent = gtk_rb_tree_node_get_parent (row))
|
||||
{
|
||||
left = gtk_rb_tree_node_get_left (parent);
|
||||
|
||||
if (left != row)
|
||||
{
|
||||
if (left)
|
||||
{
|
||||
ListRowAugment *aug = gtk_list_item_manager_get_item_augment (self->item_manager, left);
|
||||
y += aug->height;
|
||||
}
|
||||
y += parent->height * parent->parent.n_items;
|
||||
}
|
||||
|
||||
row = parent;
|
||||
}
|
||||
|
||||
return y ;
|
||||
}
|
||||
|
||||
static int
|
||||
gtk_list_view_get_list_height (GtkListView *self)
|
||||
{
|
||||
ListRow *row;
|
||||
ListRowAugment *aug;
|
||||
|
||||
row = gtk_list_item_manager_get_root (self->item_manager);
|
||||
if (row == NULL)
|
||||
return 0;
|
||||
|
||||
aug = gtk_list_item_manager_get_item_augment (self->item_manager, row);
|
||||
return aug->height;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_list_view_get_allocation (GtkListBase *base,
|
||||
guint pos,
|
||||
GdkRectangle *area)
|
||||
gtk_list_view_get_allocation_along (GtkListBase *base,
|
||||
guint pos,
|
||||
int *offset,
|
||||
int *size)
|
||||
{
|
||||
GtkListView *self = GTK_LIST_VIEW (base);
|
||||
GtkListTile *tile;
|
||||
guint offset;
|
||||
ListRow *row;
|
||||
guint skip;
|
||||
int y;
|
||||
|
||||
tile = gtk_list_item_manager_get_nth (self->item_manager, pos, &offset);
|
||||
if (tile == NULL)
|
||||
return FALSE;
|
||||
|
||||
*area = tile->area;
|
||||
if (area->width || area->height)
|
||||
row = gtk_list_item_manager_get_nth (self->item_manager, pos, &skip);
|
||||
if (row == NULL)
|
||||
{
|
||||
if (tile->n_items)
|
||||
area->height /= tile->n_items;
|
||||
if (offset)
|
||||
area->y += offset * area->height;
|
||||
*offset = 0;
|
||||
if (size)
|
||||
*size = 0;
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* item is not allocated yet */
|
||||
GtkListTile *other;
|
||||
int spacing;
|
||||
|
||||
gtk_list_base_get_border_spacing (GTK_LIST_BASE (self), NULL, &spacing);
|
||||
y = list_row_get_y (self, row);
|
||||
y += skip * row->height;
|
||||
|
||||
for (other = gtk_rb_tree_node_get_previous (tile);
|
||||
other;
|
||||
other = gtk_rb_tree_node_get_previous (other))
|
||||
{
|
||||
if (other->area.width || other->area.height)
|
||||
{
|
||||
area->x = other->area.x;
|
||||
area->width = other->area.width;
|
||||
area->y = other->area.y + other->area.height + spacing;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (other == NULL)
|
||||
{
|
||||
for (other = gtk_rb_tree_node_get_next (tile);
|
||||
other;
|
||||
other = gtk_rb_tree_node_get_next (other))
|
||||
{
|
||||
if (other->area.width || other->area.height)
|
||||
{
|
||||
area->x = other->area.x;
|
||||
area->width = other->area.width;
|
||||
area->y = MAX (0, other->area.y - spacing);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (offset)
|
||||
*offset = y;
|
||||
if (size)
|
||||
*size = row->height;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_list_view_get_allocation_across (GtkListBase *base,
|
||||
guint pos,
|
||||
int *offset,
|
||||
int *size)
|
||||
{
|
||||
GtkListView *self = GTK_LIST_VIEW (base);
|
||||
|
||||
if (offset)
|
||||
*offset = 0;
|
||||
if (size)
|
||||
*size = self->list_width;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GtkBitset *
|
||||
gtk_list_view_get_items_in_rect (GtkListBase *base,
|
||||
const cairo_rectangle_int_t *rect)
|
||||
{
|
||||
GtkListView *self = GTK_LIST_VIEW (base);
|
||||
guint first, last, n_items;
|
||||
GtkBitset *result;
|
||||
ListRow *row;
|
||||
|
||||
result = gtk_bitset_new_empty ();
|
||||
|
||||
if (rect->y >= gtk_list_view_get_list_height (self))
|
||||
return result;
|
||||
|
||||
n_items = gtk_list_base_get_n_items (base);
|
||||
if (n_items == 0)
|
||||
return result;
|
||||
|
||||
row = gtk_list_view_get_row_at_y (self, rect->y, NULL);
|
||||
if (row)
|
||||
first = gtk_list_item_manager_get_item_position (self->item_manager, row);
|
||||
else
|
||||
first = rect->y < 0 ? 0 : n_items - 1;
|
||||
row = gtk_list_view_get_row_at_y (self, rect->y + rect->height, NULL);
|
||||
if (row)
|
||||
last = gtk_list_item_manager_get_item_position (self->item_manager, row);
|
||||
else
|
||||
last = rect->y + rect->height < 0 ? 0 : n_items - 1;
|
||||
|
||||
gtk_bitset_add_range_closed (result, first, last);
|
||||
return result;
|
||||
}
|
||||
|
||||
static guint
|
||||
gtk_list_view_move_focus_along (GtkListBase *base,
|
||||
guint pos,
|
||||
@@ -293,84 +415,39 @@ gtk_list_view_move_focus_along (GtkListBase *base,
|
||||
|
||||
static gboolean
|
||||
gtk_list_view_get_position_from_allocation (GtkListBase *base,
|
||||
int x,
|
||||
int y,
|
||||
int across,
|
||||
int along,
|
||||
guint *pos,
|
||||
cairo_rectangle_int_t *area)
|
||||
{
|
||||
GtkListView *self = GTK_LIST_VIEW (base);
|
||||
GtkListTile *tile;
|
||||
ListRow *row;
|
||||
int remaining;
|
||||
|
||||
tile = gtk_list_item_manager_get_nearest_tile (self->item_manager, x, y);
|
||||
if (tile == NULL)
|
||||
if (across >= self->list_width)
|
||||
return FALSE;
|
||||
|
||||
while (tile && tile->n_items == 0)
|
||||
tile = gtk_rb_tree_node_get_previous (tile);
|
||||
if (tile == NULL)
|
||||
{
|
||||
tile = gtk_list_item_manager_get_first (self->item_manager);
|
||||
while (tile && tile->n_items == 0)
|
||||
tile = gtk_rb_tree_node_get_next (tile);
|
||||
if (tile == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
along = CLAMP (along, 0, gtk_list_view_get_list_height (self) - 1);
|
||||
|
||||
row = gtk_list_view_get_row_at_y (self, along, &remaining);
|
||||
if (row == NULL)
|
||||
return FALSE;
|
||||
|
||||
*pos = gtk_list_item_manager_get_item_position (self->item_manager, row);
|
||||
g_assert (remaining < row->height * row->parent.n_items);
|
||||
*pos += remaining / row->height;
|
||||
|
||||
*pos = gtk_list_tile_get_position (self->item_manager, tile);
|
||||
if (area)
|
||||
*area = tile->area;
|
||||
|
||||
if (tile->n_items > 1)
|
||||
{
|
||||
int row_height, tile_pos, spacing;
|
||||
|
||||
gtk_list_base_get_border_spacing (GTK_LIST_BASE (self), NULL, &spacing);
|
||||
row_height = (tile->area.height - (tile->n_items - 1) * spacing) / tile->n_items;
|
||||
if (y >= tile->area.y + tile->area.height)
|
||||
tile_pos = tile->n_items - 1;
|
||||
else
|
||||
tile_pos = (y - tile->area.y) / (row_height + spacing);
|
||||
|
||||
*pos += tile_pos;
|
||||
if (area)
|
||||
{
|
||||
area->y = tile->area.y + tile_pos * (row_height + spacing);
|
||||
area->height = row_height;
|
||||
}
|
||||
area->x = 0;
|
||||
area->width = self->list_width;
|
||||
area->y = along - remaining % row->height;
|
||||
area->height = row->height;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GtkBitset *
|
||||
gtk_list_view_get_items_in_rect (GtkListBase *base,
|
||||
const cairo_rectangle_int_t *rect)
|
||||
{
|
||||
guint first, last;
|
||||
cairo_rectangle_int_t area;
|
||||
GtkBitset *result;
|
||||
|
||||
result = gtk_bitset_new_empty ();
|
||||
|
||||
if (!gtk_list_view_get_position_from_allocation (base, rect->x, rect->y, &first, &area))
|
||||
return result;
|
||||
if (area.y + area.height < rect->y)
|
||||
first++;
|
||||
|
||||
if (!gtk_list_view_get_position_from_allocation (base,
|
||||
rect->x + rect->width - 1,
|
||||
rect->y + rect->height - 1,
|
||||
&last, &area))
|
||||
return result;
|
||||
if (area.y >= rect->y + rect->height)
|
||||
last--;
|
||||
|
||||
if (last >= first)
|
||||
gtk_bitset_add_range_closed (result, first, last);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static guint
|
||||
gtk_list_view_move_focus_across (GtkListBase *base,
|
||||
guint pos,
|
||||
@@ -406,7 +483,7 @@ gtk_list_view_measure_across (GtkWidget *widget,
|
||||
int *natural)
|
||||
{
|
||||
GtkListView *self = GTK_LIST_VIEW (widget);
|
||||
GtkListTile *tile;
|
||||
ListRow *row;
|
||||
int min, nat, child_min, child_nat;
|
||||
/* XXX: Figure out how to split a given height into per-row heights.
|
||||
* Good luck! */
|
||||
@@ -415,15 +492,15 @@ gtk_list_view_measure_across (GtkWidget *widget,
|
||||
min = 0;
|
||||
nat = 0;
|
||||
|
||||
for (tile = gtk_list_item_manager_get_first (self->item_manager);
|
||||
tile != NULL;
|
||||
tile = gtk_rb_tree_node_get_next (tile))
|
||||
for (row = gtk_list_item_manager_get_first (self->item_manager);
|
||||
row != NULL;
|
||||
row = gtk_rb_tree_node_get_next (row))
|
||||
{
|
||||
/* ignore unavailable rows */
|
||||
if (tile->widget == NULL)
|
||||
if (row->parent.widget == NULL)
|
||||
continue;
|
||||
|
||||
gtk_widget_measure (tile->widget,
|
||||
gtk_widget_measure (row->parent.widget,
|
||||
orientation, for_size,
|
||||
&child_min, &child_nat, NULL, NULL);
|
||||
min = MAX (min, child_min);
|
||||
@@ -442,15 +519,10 @@ gtk_list_view_measure_list (GtkWidget *widget,
|
||||
int *natural)
|
||||
{
|
||||
GtkListView *self = GTK_LIST_VIEW (widget);
|
||||
GtkListTile *tile;
|
||||
int min, nat, child_min, child_nat, spacing;
|
||||
ListRow *row;
|
||||
int min, nat, child_min, child_nat;
|
||||
GArray *min_heights, *nat_heights;
|
||||
guint n_unknown, n_items;
|
||||
|
||||
n_items = gtk_list_base_get_n_items (GTK_LIST_BASE (self));
|
||||
if (n_items == 0)
|
||||
return;
|
||||
gtk_list_base_get_border_spacing (GTK_LIST_BASE (self), NULL, &spacing);
|
||||
guint n_unknown;
|
||||
|
||||
min_heights = g_array_new (FALSE, FALSE, sizeof (int));
|
||||
nat_heights = g_array_new (FALSE, FALSE, sizeof (int));
|
||||
@@ -458,13 +530,13 @@ gtk_list_view_measure_list (GtkWidget *widget,
|
||||
min = 0;
|
||||
nat = 0;
|
||||
|
||||
for (tile = gtk_list_item_manager_get_first (self->item_manager);
|
||||
tile != NULL;
|
||||
tile = gtk_rb_tree_node_get_next (tile))
|
||||
for (row = gtk_list_item_manager_get_first (self->item_manager);
|
||||
row != NULL;
|
||||
row = gtk_rb_tree_node_get_next (row))
|
||||
{
|
||||
if (tile->widget)
|
||||
if (row->parent.widget)
|
||||
{
|
||||
gtk_widget_measure (tile->widget,
|
||||
gtk_widget_measure (row->parent.widget,
|
||||
orientation, for_size,
|
||||
&child_min, &child_nat, NULL, NULL);
|
||||
g_array_append_val (min_heights, child_min);
|
||||
@@ -474,7 +546,7 @@ gtk_list_view_measure_list (GtkWidget *widget,
|
||||
}
|
||||
else
|
||||
{
|
||||
n_unknown += tile->n_items;
|
||||
n_unknown += row->parent.n_items;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -486,8 +558,8 @@ gtk_list_view_measure_list (GtkWidget *widget,
|
||||
g_array_free (min_heights, TRUE);
|
||||
g_array_free (nat_heights, TRUE);
|
||||
|
||||
*minimum = min + spacing * (n_items - 1);
|
||||
*natural = nat + spacing * (n_items - 1);
|
||||
*minimum = min;
|
||||
*natural = nat;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -514,9 +586,10 @@ gtk_list_view_size_allocate (GtkWidget *widget,
|
||||
int baseline)
|
||||
{
|
||||
GtkListView *self = GTK_LIST_VIEW (widget);
|
||||
GtkListTile *tile;
|
||||
ListRow *row;
|
||||
GArray *heights;
|
||||
int min, nat, row_height, y, list_width, spacing;
|
||||
int min, nat, row_height;
|
||||
int x, y;
|
||||
GtkOrientation orientation, opposite_orientation;
|
||||
GtkScrollablePolicy scroll_policy, opposite_scroll_policy;
|
||||
|
||||
@@ -524,13 +597,11 @@ gtk_list_view_size_allocate (GtkWidget *widget,
|
||||
opposite_orientation = OPPOSITE_ORIENTATION (orientation);
|
||||
scroll_policy = gtk_list_base_get_scroll_policy (GTK_LIST_BASE (self), orientation);
|
||||
opposite_scroll_policy = gtk_list_base_get_scroll_policy (GTK_LIST_BASE (self), opposite_orientation);
|
||||
gtk_list_base_get_border_spacing (GTK_LIST_BASE (self), NULL, &spacing);
|
||||
|
||||
/* step 0: exit early if list is empty */
|
||||
tile = gtk_list_tile_gc (self->item_manager, gtk_list_item_manager_get_first (self->item_manager));
|
||||
if (tile == NULL)
|
||||
if (gtk_list_item_manager_get_root (self->item_manager) == NULL)
|
||||
{
|
||||
gtk_list_base_allocate (GTK_LIST_BASE (self));
|
||||
gtk_list_base_update_adjustments (GTK_LIST_BASE (self), 0, 0, 0, 0, &x, &y);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -538,57 +609,85 @@ gtk_list_view_size_allocate (GtkWidget *widget,
|
||||
gtk_list_view_measure_across (widget, opposite_orientation,
|
||||
-1,
|
||||
&min, &nat);
|
||||
list_width = orientation == GTK_ORIENTATION_VERTICAL ? width : height;
|
||||
self->list_width = orientation == GTK_ORIENTATION_VERTICAL ? width : height;
|
||||
if (opposite_scroll_policy == GTK_SCROLL_MINIMUM)
|
||||
list_width = MAX (min, list_width);
|
||||
self->list_width = MAX (min, self->list_width);
|
||||
else
|
||||
list_width = MAX (nat, list_width);
|
||||
self->list_width = MAX (nat, self->list_width);
|
||||
|
||||
/* step 2: determine height of known list items and gc the list */
|
||||
/* step 2: determine height of known list items */
|
||||
heights = g_array_new (FALSE, FALSE, sizeof (int));
|
||||
|
||||
for (;
|
||||
tile != NULL;
|
||||
tile = gtk_list_tile_gc (self->item_manager, gtk_rb_tree_node_get_next (tile)))
|
||||
for (row = gtk_list_item_manager_get_first (self->item_manager);
|
||||
row != NULL;
|
||||
row = gtk_rb_tree_node_get_next (row))
|
||||
{
|
||||
if (tile->widget == NULL)
|
||||
if (row->parent.widget == NULL)
|
||||
continue;
|
||||
|
||||
gtk_widget_measure (tile->widget, orientation,
|
||||
list_width,
|
||||
gtk_widget_measure (row->parent.widget, orientation,
|
||||
self->list_width,
|
||||
&min, &nat, NULL, NULL);
|
||||
if (scroll_policy == GTK_SCROLL_MINIMUM)
|
||||
row_height = min;
|
||||
else
|
||||
row_height = nat;
|
||||
gtk_list_tile_set_area_size (self->item_manager, tile, list_width, row_height);
|
||||
if (row->height != row_height)
|
||||
{
|
||||
row->height = row_height;
|
||||
gtk_rb_tree_node_mark_dirty (row);
|
||||
}
|
||||
g_array_append_val (heights, row_height);
|
||||
}
|
||||
|
||||
/* step 3: determine height of unknown items and set the positions */
|
||||
/* step 3: determine height of unknown items */
|
||||
row_height = gtk_list_view_get_unknown_row_height (self, heights);
|
||||
g_array_free (heights, TRUE);
|
||||
|
||||
y = 0;
|
||||
for (tile = gtk_list_item_manager_get_first (self->item_manager);
|
||||
tile != NULL;
|
||||
tile = gtk_rb_tree_node_get_next (tile))
|
||||
for (row = gtk_list_item_manager_get_first (self->item_manager);
|
||||
row != NULL;
|
||||
row = gtk_rb_tree_node_get_next (row))
|
||||
{
|
||||
gtk_list_tile_set_area_position (self->item_manager, tile, 0, y);
|
||||
if (tile->widget == NULL)
|
||||
{
|
||||
gtk_list_tile_set_area_size (self->item_manager,
|
||||
tile,
|
||||
list_width,
|
||||
row_height * tile->n_items
|
||||
+ spacing * (tile->n_items - 1));
|
||||
}
|
||||
if (row->parent.widget)
|
||||
continue;
|
||||
|
||||
y += tile->area.height + spacing;
|
||||
if (row->height != row_height)
|
||||
{
|
||||
row->height = row_height;
|
||||
gtk_rb_tree_node_mark_dirty (row);
|
||||
}
|
||||
}
|
||||
|
||||
/* step 4: allocate the rest */
|
||||
gtk_list_base_allocate (GTK_LIST_BASE (self));
|
||||
/* step 3: update the adjustments */
|
||||
gtk_list_base_update_adjustments (GTK_LIST_BASE (self),
|
||||
self->list_width,
|
||||
gtk_list_view_get_list_height (self),
|
||||
gtk_widget_get_size (widget, opposite_orientation),
|
||||
gtk_widget_get_size (widget, orientation),
|
||||
&x, &y);
|
||||
x = -x;
|
||||
y = -y;
|
||||
|
||||
/* step 4: actually allocate the widgets */
|
||||
|
||||
for (row = gtk_list_item_manager_get_first (self->item_manager);
|
||||
row != NULL;
|
||||
row = gtk_rb_tree_node_get_next (row))
|
||||
{
|
||||
if (row->parent.widget)
|
||||
{
|
||||
gtk_list_base_size_allocate_child (GTK_LIST_BASE (self),
|
||||
row->parent.widget,
|
||||
x,
|
||||
y,
|
||||
self->list_width,
|
||||
row->height);
|
||||
}
|
||||
|
||||
y += row->height * row->parent.n_items;
|
||||
}
|
||||
|
||||
gtk_list_base_allocate_rubberband (GTK_LIST_BASE (self));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -700,8 +799,11 @@ gtk_list_view_class_init (GtkListViewClass *klass)
|
||||
|
||||
list_base_class->list_item_name = "row";
|
||||
list_base_class->list_item_role = GTK_ACCESSIBLE_ROLE_LIST_ITEM;
|
||||
list_base_class->split = gtk_list_view_split;
|
||||
list_base_class->get_allocation = gtk_list_view_get_allocation;
|
||||
list_base_class->list_item_size = sizeof (ListRow);
|
||||
list_base_class->list_item_augment_size = sizeof (ListRowAugment);
|
||||
list_base_class->list_item_augment_func = list_row_augment;
|
||||
list_base_class->get_allocation_along = gtk_list_view_get_allocation_along;
|
||||
list_base_class->get_allocation_across = gtk_list_view_get_allocation_across;
|
||||
list_base_class->get_items_in_rect = gtk_list_view_get_items_in_rect;
|
||||
list_base_class->get_position_from_allocation = gtk_list_view_get_position_from_allocation;
|
||||
list_base_class->move_focus_along = gtk_list_view_move_focus_along;
|
||||
|
||||
@@ -31,6 +31,8 @@ struct _GtkListView
|
||||
|
||||
GtkListItemManager *item_manager;
|
||||
gboolean show_separators;
|
||||
|
||||
int list_width;
|
||||
};
|
||||
|
||||
struct _GtkListViewClass
|
||||
|
||||
+4
-2
@@ -256,7 +256,8 @@ _gtk_magnifier_set_coords (GtkMagnifier *magnifier,
|
||||
magnifier->x = x;
|
||||
magnifier->y = y;
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (magnifier));
|
||||
if (gtk_widget_is_visible (GTK_WIDGET (magnifier)))
|
||||
gtk_widget_queue_draw (GTK_WIDGET (magnifier));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -288,7 +289,8 @@ _gtk_magnifier_set_magnification (GtkMagnifier *magnifier,
|
||||
if (magnifier->resize)
|
||||
gtk_widget_queue_resize (GTK_WIDGET (magnifier));
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (magnifier));
|
||||
if (gtk_widget_is_visible (GTK_WIDGET (magnifier)))
|
||||
gtk_widget_queue_draw (GTK_WIDGET (magnifier));
|
||||
}
|
||||
|
||||
double
|
||||
|
||||
+4
-1
@@ -660,7 +660,10 @@ gtk_init (void)
|
||||
{
|
||||
if (!gtk_init_check ())
|
||||
{
|
||||
g_warning ("Failed to open display");
|
||||
const char *display_name_arg;
|
||||
|
||||
display_name_arg = getenv ("DISPLAY");
|
||||
g_warning ("cannot open display: %s", display_name_arg ? display_name_arg : "");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,8 +329,6 @@ update_at_context (GtkModelButton *button)
|
||||
|
||||
if (was_realized)
|
||||
gtk_at_context_realize (context);
|
||||
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1201,7 +1199,7 @@ gtk_model_button_class_init (GtkModelButtonClass *class)
|
||||
* A GIcon that will be used if iconic appearance for the button is
|
||||
* desired.
|
||||
*/
|
||||
properties[PROP_ICON] =
|
||||
properties[PROP_ICON] =
|
||||
g_param_spec_object ("icon", NULL, NULL,
|
||||
G_TYPE_ICON,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
+3
-5
@@ -4033,6 +4033,9 @@ gtk_notebook_insert_notebook_page (GtkNotebook *notebook,
|
||||
g_signal_connect (controller, "enter", G_CALLBACK (gtk_notebook_tab_drop_enter), page);
|
||||
g_signal_connect (controller, "leave", G_CALLBACK (gtk_notebook_tab_drop_leave), page);
|
||||
gtk_widget_add_controller (page->tab_widget, controller);
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (page->tab_widget),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, _("Tab"),
|
||||
-1);
|
||||
|
||||
page->expand = FALSE;
|
||||
page->fill = TRUE;
|
||||
@@ -4332,11 +4335,6 @@ gtk_notebook_update_labels (GtkNotebook *notebook)
|
||||
text = page->tab_text;
|
||||
else
|
||||
text = string;
|
||||
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (page->tab_widget),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, text,
|
||||
-1);
|
||||
|
||||
if (notebook->show_tabs)
|
||||
{
|
||||
if (page->default_tab)
|
||||
|
||||
+5
-9
@@ -218,7 +218,7 @@ gtk_path_bar_init (GtkPathBar *path_bar)
|
||||
desktop = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
|
||||
if (desktop != NULL)
|
||||
path_bar->desktop_file = g_file_new_for_path (desktop);
|
||||
else
|
||||
else
|
||||
path_bar->desktop_file = NULL;
|
||||
}
|
||||
else
|
||||
@@ -306,7 +306,7 @@ update_visibility_up_to_next_root (GtkPathBar *path_bar,
|
||||
{
|
||||
gboolean fake_root_found = FALSE;
|
||||
GList *l;
|
||||
|
||||
|
||||
for (l = start_from_button; l; l = l->next)
|
||||
{
|
||||
GtkWidget *button = BUTTON_DATA (l->data)->button;
|
||||
@@ -776,7 +776,6 @@ gtk_path_bar_get_info_callback (GObject *source,
|
||||
GFileInfo *info;
|
||||
ButtonData *button_data;
|
||||
const char *display_name;
|
||||
gboolean has_is_hidden, has_is_backup;
|
||||
gboolean is_hidden;
|
||||
|
||||
info = g_file_query_info_finish (file, result, NULL);
|
||||
@@ -795,10 +794,7 @@ gtk_path_bar_get_info_callback (GObject *source,
|
||||
file_info->cancellable = NULL;
|
||||
|
||||
display_name = g_file_info_get_display_name (info);
|
||||
has_is_hidden = g_file_info_has_attribute (info, "standard::is-hidden");
|
||||
has_is_backup = g_file_info_has_attribute (info, "standard::is-backup");
|
||||
is_hidden = (has_is_hidden && g_file_info_get_is_hidden (info)) ||
|
||||
(has_is_backup && g_file_info_get_is_backup (info));
|
||||
is_hidden = g_file_info_get_is_hidden (info) || g_file_info_get_is_backup (info);
|
||||
|
||||
button_data = make_directory_button (file_info->path_bar, display_name,
|
||||
file_info->file,
|
||||
@@ -883,7 +879,7 @@ _gtk_path_bar_set_file (GtkPathBar *path_bar,
|
||||
/**
|
||||
* _gtk_path_bar_up:
|
||||
* @path_bar: a `GtkPathBar`
|
||||
*
|
||||
*
|
||||
* If the selected button in the pathbar is not the furthest button “up” (in the
|
||||
* root direction), act as if the user clicked on the next button up.
|
||||
**/
|
||||
@@ -910,7 +906,7 @@ _gtk_path_bar_up (GtkPathBar *path_bar)
|
||||
/**
|
||||
* _gtk_path_bar_down:
|
||||
* @path_bar: a `GtkPathBar`
|
||||
*
|
||||
*
|
||||
* If the selected button in the pathbar is not the furthest button “down” (in the
|
||||
* leaf direction), act as if the user clicked on the next button down.
|
||||
**/
|
||||
|
||||
+2
-2
@@ -68,8 +68,8 @@
|
||||
* that paintables are never made smaller than their ideal size - but
|
||||
* be careful if you do not know the size of the paintable in use (like
|
||||
* when displaying user-loaded images). This can easily cause the picture to
|
||||
* grow larger than the screen. And [property@Gtk.Widget:halign] and
|
||||
* [property@Gtk.Widget:valign] can be used to make sure the paintable doesn't
|
||||
* grow larger than the screen. And [property@GtkWidget:halign] and
|
||||
* [property@GtkWidget:valign] can be used to make sure the paintable doesn't
|
||||
* fill all available space but is instead displayed at its original size.
|
||||
*
|
||||
* ## CSS nodes
|
||||
|
||||
@@ -45,8 +45,7 @@ gtk_render_node_paintable_paintable_snapshot (GdkPaintable *paintable,
|
||||
GtkRenderNodePaintable *self = GTK_RENDER_NODE_PAINTABLE (paintable);
|
||||
|
||||
if (self->bounds.size.width <= 0 ||
|
||||
self->bounds.size.height <= 0 ||
|
||||
self->node == NULL)
|
||||
self->bounds.size.height <= 0)
|
||||
return;
|
||||
|
||||
gtk_snapshot_save (snapshot);
|
||||
@@ -142,12 +141,12 @@ gtk_render_node_paintable_new (GskRenderNode *node,
|
||||
{
|
||||
GtkRenderNodePaintable *self;
|
||||
|
||||
g_return_val_if_fail (node == NULL || GSK_IS_RENDER_NODE (node), NULL);
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE (node), NULL);
|
||||
g_return_val_if_fail (bounds != NULL, NULL);
|
||||
|
||||
self = g_object_new (GTK_TYPE_RENDER_NODE_PAINTABLE, NULL);
|
||||
|
||||
self->node = node ? gsk_render_node_ref (node) : NULL;
|
||||
self->node = gsk_render_node_ref (node);
|
||||
self->bounds = *bounds;
|
||||
|
||||
return GDK_PAINTABLE (self);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user