Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f8efc6f1fa |
+1
-21
@@ -24,7 +24,7 @@ stages:
|
||||
variables:
|
||||
COMMON_MESON_FLAGS: "-Dwerror=true -Dcairo:werror=false -Dgi-docgen:werror=false -Dgraphene:werror=false -Dlibepoxy:werror=false -Dlibsass:werror=false -Dpango:werror=false -Dsassc:werror=false -Dgdk-pixbuf:werror=false -Dglib:werror=false -Dlibcloudproviders:werror=false -Dlibpng:werror=false -Dlibtiff:werror=false -Dsysprof:werror=false -Dwayland-protocols:werror=false -Dharfbuzz:werror=false -Dfreetype2:werror=false -Dfontconfig:werror=false -Dfribidi:werror=false -Dlibffi:werror=false -Dlibjpeg-turbo:werror=false -Dmutest:werror=false -Dpixman:werror=false -Dproxy-libintl:werror=false"
|
||||
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
|
||||
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled -Dbuild-testsuite=true -Dintrospection=enabled"
|
||||
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled -Dbuild-testsuite=true"
|
||||
MESON_TEST_TIMEOUT_MULTIPLIER: 3
|
||||
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v46"
|
||||
|
||||
@@ -123,26 +123,6 @@ release-build:
|
||||
- LD_LIBRARY_PATH=${CI_PROJECT_DIR}/_install/lib64 meson compile -C _build_hello
|
||||
- .gitlab-ci/run-tests.sh _build x11
|
||||
|
||||
fedora-clang:
|
||||
extends: .build-fedora-default
|
||||
stage: build
|
||||
needs: []
|
||||
variables:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=release"
|
||||
script:
|
||||
- .gitlab-ci/show-info-linux.sh
|
||||
- export PATH="$HOME/.local/bin:$PATH"
|
||||
- export CC=clang
|
||||
- meson subprojects download
|
||||
- meson subprojects update --reset
|
||||
- meson setup
|
||||
${COMMON_MESON_FLAGS}
|
||||
${EXTRA_MESON_FLAGS}
|
||||
${BACKEND_FLAGS}
|
||||
${FEATURE_FLAGS}
|
||||
_build
|
||||
- meson compile -C _build
|
||||
|
||||
fedora-mingw64:
|
||||
extends: .build-fedora-default
|
||||
stage: build
|
||||
|
||||
@@ -1,56 +1,6 @@
|
||||
Overview of Changes in 4.11.3, xx-xx-xxxx
|
||||
=========================================
|
||||
|
||||
* GtkGridView:
|
||||
- Respect css border-spacing
|
||||
- Don't leak the factories
|
||||
|
||||
* GtkListView:
|
||||
- Don't leak the factories
|
||||
|
||||
* GtkNotebook:
|
||||
- Make the pages model implement GtkSelectionModel
|
||||
|
||||
* GtkScrolledWindow:
|
||||
- Propagate child measure size whenever possible
|
||||
|
||||
* GtkPopoverMenu:
|
||||
- Avoid unnecessary left padding
|
||||
|
||||
* Css:
|
||||
- Add new binding-friendly css provider apis
|
||||
|
||||
* Theme:
|
||||
- Show focus in the shortcuts window
|
||||
|
||||
* Tests:
|
||||
- Improve test coverage
|
||||
|
||||
* Wayland:
|
||||
- Make exporting surface handles more flexible
|
||||
|
||||
* Build:
|
||||
- Some build options have been renamed:
|
||||
demos -> build-demos
|
||||
profile -> demo-profile
|
||||
The old names still work
|
||||
|
||||
* Deprecations:
|
||||
- gtk_css_provider_load_from_data
|
||||
- gdk_wayland_toplevel_unexport_handle
|
||||
- gdk_pixbuf_get_from_surface
|
||||
- gdk_pixbuf_get_from_texture
|
||||
- gtk_image_new_from_pixbuf
|
||||
- gtk_image_set_from_pixbuf
|
||||
- gtk_picture_new_for_pixbuf
|
||||
- gtk_picture_set_pixbuf
|
||||
|
||||
* Translation updates:
|
||||
Basque
|
||||
Catalan
|
||||
Russian
|
||||
|
||||
|
||||
Overview of Changes in 4.11.2, 09-05-2023
|
||||
=========================================
|
||||
|
||||
|
||||
@@ -2244,24 +2244,20 @@ microphone-sensitivity-medium-symbolic</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="spacing">6</property>
|
||||
<property name="valign">center</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="lockbox">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="spacing">6</property>
|
||||
<property name="valign">center</property>
|
||||
<child>
|
||||
<object class="GtkMenuButton" id="open_menubutton">
|
||||
<property name="halign">3</property>
|
||||
<property name="popover">open_popover</property>
|
||||
<property name="label">Open</property>
|
||||
<property name="valign">center</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="record_button">
|
||||
<property name="halign">3</property>
|
||||
<property name="valign">center</property>
|
||||
<signal name="toggled" handler="on_record_button_toggled"/>
|
||||
<style>
|
||||
<class name="text-button"/>
|
||||
@@ -2271,19 +2267,16 @@ microphone-sensitivity-medium-symbolic</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="spacing">6</property>
|
||||
<property name="valign">center</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="valign">4</property>
|
||||
<property name="icon-name">media-record-symbolic</property>
|
||||
<property name="valign">center</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="valign">4</property>
|
||||
<property name="label">Record</property>
|
||||
<property name="valign">center</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@@ -2292,7 +2285,6 @@ microphone-sensitivity-medium-symbolic</property>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="valign">center</property>
|
||||
<style>
|
||||
<class name="linked"/>
|
||||
</style>
|
||||
@@ -2300,14 +2292,12 @@ microphone-sensitivity-medium-symbolic</property>
|
||||
<object class="GtkToggleButton" id="grid_button">
|
||||
<property name="active">1</property>
|
||||
<property name="icon-name">view-grid-symbolic</property>
|
||||
<property name="valign">center</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="list_button">
|
||||
<property name="group">grid_button</property>
|
||||
<property name="icon-name">view-list-symbolic</property>
|
||||
<property name="valign">center</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@@ -2315,7 +2305,6 @@ microphone-sensitivity-medium-symbolic</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="circular_button">
|
||||
<property name="icon-name">emblem-system-symbolic</property>
|
||||
<property name="valign">center</property>
|
||||
<style>
|
||||
<class name="circular"/>
|
||||
</style>
|
||||
@@ -2324,15 +2313,12 @@ microphone-sensitivity-medium-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLockButton" id="lockbutton">
|
||||
<property name="valign">center</property>
|
||||
</object>
|
||||
<object class="GtkLockButton" id="lockbutton"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuButton">
|
||||
<property name="icon-name">view-more-symbolic</property>
|
||||
<property name="menu-model">new_style_menu_model</property>
|
||||
<property name="valign">center</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
@@ -68,7 +68,7 @@ in a selector, widget names must be prefixed with a # character.
|
||||
| E:focus-within | [CSS Selector Level 4](https://drafts.csswg.org/selectors/#focus-within-pseudo) | Set on all ancestors of the focus widget, unlike CSS |
|
||||
| E:focus-visible | [CSS Selector Level 4](https://drafts.csswg.org/selectors/#focus-within-pseudo) | Set on focus widget and all ancestors, unlike CSS |
|
||||
| E:disabled | [CSS Selector Level 3](https://www.w3.org/TR/css3-selectors/#UIstates) | Corresponds to GTK_STATE_FLAG_INSENSITIVE |
|
||||
| E:checked | [CSS Selector Level 3](https://www.w3.org/TR/css3-selectors/#UIstates) | Corresponds to GTK_STATE_FLAG_CHECKED |
|
||||
| E:disabled | [CSS Selector Level 3](https://www.w3.org/TR/css3-selectors/#UIstates) | Corresponds to GTK_STATE_FLAG_CHECKED |
|
||||
| E:indeterminate | [CSS Selector Level 3](https://www.w3.org/TR/css3-selectors/#indeterminate) | Corresponds to GTK_STATE_FLAG_INCONSISTENT |
|
||||
| E:backdrop, E:selected | | Corresponds to GTK_STATE_FLAG_BACKDROP, GTK_STATE_FLAG_SELECTED |
|
||||
| E:not(selector) | [CSS Selector Level 3](https://www.w3.org/TR/css3-selectors/#negation) | |
|
||||
|
||||
@@ -196,15 +196,6 @@ The _data table_ style of list is a high density table, similar in style to a
|
||||
traditional treeview. Individual cells can be selectable and editable. Use
|
||||
the `.data-table` style class.
|
||||
|
||||
## Sections
|
||||
|
||||
List models can optionally group their items into **_sections_**, by implementing
|
||||
the `GtkSectionModel` interface. Both `GtkListView` and `GtkGridView` can
|
||||
display headers for sections, by installing a separate **_header factory_**.
|
||||
|
||||
Many GTK list models support section inherently, or they pass through the
|
||||
section of a model they are wrapping.
|
||||
|
||||
## Comparison to GtkTreeView
|
||||
|
||||
Developers familiar with `GtkTreeView` may wonder how this way of doing lists
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
gdk_deprecated_sources = files([
|
||||
'gdkpixbuf.c',
|
||||
])
|
||||
gdk_deprecated_sources = [
|
||||
'deprecated/gdkpixbuf.c',
|
||||
]
|
||||
|
||||
gdk_deprecated_headers = files([
|
||||
'gdkpixbuf.h',
|
||||
])
|
||||
gdk_deprecated_headers = [
|
||||
'deprecated/gdkpixbuf.h',
|
||||
]
|
||||
|
||||
+23
-23
@@ -466,26 +466,29 @@ gdk_gl_context_real_get_damage (GdkGLContext *context)
|
||||
eglQuerySurface (gdk_display_get_egl_display (display), egl_surface,
|
||||
EGL_BUFFER_AGE_EXT, &buffer_age);
|
||||
|
||||
if (buffer_age > 0 && buffer_age <= GDK_GL_MAX_TRACKED_BUFFERS)
|
||||
switch (buffer_age)
|
||||
{
|
||||
cairo_region_t *damage = cairo_region_create ();
|
||||
int i;
|
||||
case 1:
|
||||
return cairo_region_create ();
|
||||
break;
|
||||
|
||||
for (i = 0; i < buffer_age - 1; i++)
|
||||
{
|
||||
if (context->old_updated_area[i] == NULL)
|
||||
{
|
||||
cairo_region_create_rectangle (&(GdkRectangle) {
|
||||
0, 0,
|
||||
gdk_surface_get_width (surface),
|
||||
gdk_surface_get_height (surface)
|
||||
});
|
||||
break;
|
||||
}
|
||||
cairo_region_union (damage, context->old_updated_area[i]);
|
||||
}
|
||||
case 2:
|
||||
if (context->old_updated_area[0])
|
||||
return cairo_region_copy (context->old_updated_area[0]);
|
||||
break;
|
||||
|
||||
return damage;
|
||||
case 3:
|
||||
if (context->old_updated_area[0] &&
|
||||
context->old_updated_area[1])
|
||||
{
|
||||
cairo_region_t *damage = cairo_region_copy (context->old_updated_area[0]);
|
||||
cairo_region_union (damage, context->old_updated_area[1]);
|
||||
return damage;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -594,7 +597,6 @@ gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context,
|
||||
cairo_region_t *damage;
|
||||
double scale;
|
||||
int ww, wh;
|
||||
int i;
|
||||
|
||||
surface = gdk_draw_context_get_surface (draw_context);
|
||||
scale = gdk_gl_context_get_scale (context);
|
||||
@@ -606,11 +608,9 @@ gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context,
|
||||
|
||||
damage = GDK_GL_CONTEXT_GET_CLASS (context)->get_damage (context);
|
||||
|
||||
g_clear_pointer (&context->old_updated_area[GDK_GL_MAX_TRACKED_BUFFERS - 1], cairo_region_destroy);
|
||||
for (i = GDK_GL_MAX_TRACKED_BUFFERS - 1; i > 0; i--)
|
||||
{
|
||||
context->old_updated_area[i] = context->old_updated_area[i - 1];
|
||||
}
|
||||
if (context->old_updated_area[1])
|
||||
cairo_region_destroy (context->old_updated_area[1]);
|
||||
context->old_updated_area[1] = context->old_updated_area[0];
|
||||
context->old_updated_area[0] = cairo_region_copy (region);
|
||||
|
||||
cairo_region_union (region, damage);
|
||||
|
||||
@@ -34,11 +34,6 @@ typedef enum {
|
||||
GDK_GL_CGL
|
||||
} GdkGLBackend;
|
||||
|
||||
/* The maximum amount of buffers we track update regions for.
|
||||
* Note that this is equal to the max buffer age value we
|
||||
* can provide a damage region for */
|
||||
#define GDK_GL_MAX_TRACKED_BUFFERS 4
|
||||
|
||||
#define GDK_GL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GL_CONTEXT, GdkGLContextClass))
|
||||
#define GDK_IS_GL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GL_CONTEXT))
|
||||
#define GDK_GL_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GL_CONTEXT, GdkGLContextClass))
|
||||
@@ -50,7 +45,7 @@ struct _GdkGLContext
|
||||
GdkDrawContext parent_instance;
|
||||
|
||||
/* We store the old drawn areas to support buffer-age optimizations */
|
||||
cairo_region_t *old_updated_area[GDK_GL_MAX_TRACKED_BUFFERS];
|
||||
cairo_region_t *old_updated_area[2];
|
||||
};
|
||||
|
||||
struct _GdkGLContextClass
|
||||
|
||||
+1
-3
@@ -170,7 +170,7 @@ parse_rgb_value (const char *str,
|
||||
*
|
||||
* The string can be either one of:
|
||||
*
|
||||
* - A standard name (Taken from the CSS specification).
|
||||
* - A standard name (Taken from the Css specification).
|
||||
* - A hexadecimal value in the form “\#rgb”, “\#rrggbb”,
|
||||
* “\#rrrgggbbb” or ”\#rrrrggggbbbb”
|
||||
* - A hexadecimal value in the form “\#rgba”, “\#rrggbbaa”,
|
||||
@@ -178,8 +178,6 @@ parse_rgb_value (const char *str,
|
||||
* - A RGB color in the form “rgb(r,g,b)” (In this case the color
|
||||
* will have full opacity)
|
||||
* - A RGBA color in the form “rgba(r,g,b,a)”
|
||||
* - A HSL color in the form "hsl(hue, saturation, lightness)"
|
||||
* - A HSLA color in the form "hsla(hue, saturation, lightness, alpha)"
|
||||
*
|
||||
* Where “r”, “g”, “b” and “a” are respectively the red, green,
|
||||
* blue and alpha color values. In the last two cases, “r”, “g”,
|
||||
|
||||
@@ -144,8 +144,7 @@ struct _GdkX11Display
|
||||
guint server_time_is_monotonic_time : 1;
|
||||
|
||||
/* GLX extensions we check */
|
||||
guint has_glx_sgi_swap_control : 1;
|
||||
guint has_glx_swap_control : 1;
|
||||
guint has_glx_swap_interval : 1;
|
||||
guint has_glx_create_context : 1;
|
||||
guint has_glx_texture_from_pixmap : 1;
|
||||
guint has_glx_video_sync : 1;
|
||||
|
||||
+29
-45
@@ -162,7 +162,7 @@ gdk_x11_gl_context_glx_end_frame (GdkDrawContext *draw_context,
|
||||
if (display_x11->has_glx_video_sync)
|
||||
glXGetVideoSyncSGI (&end_frame_counter);
|
||||
|
||||
if (self->do_frame_sync && !display_x11->has_glx_sgi_swap_control && !display_x11->has_glx_swap_control)
|
||||
if (self->do_frame_sync && !display_x11->has_glx_swap_interval)
|
||||
{
|
||||
glFinish ();
|
||||
|
||||
@@ -249,7 +249,7 @@ gdk_x11_gl_context_glx_make_current (GdkGLContext *context,
|
||||
if (!glXMakeContextCurrent (dpy, drawable, drawable, self->glx_context))
|
||||
return FALSE;
|
||||
|
||||
if (!surfaceless)
|
||||
if (!surfaceless && GDK_X11_DISPLAY (display)->has_glx_swap_interval)
|
||||
{
|
||||
/* If the WM is compositing there is no particular need to delay
|
||||
* the swap when drawing on the offscreen, rendering to the screen
|
||||
@@ -257,35 +257,14 @@ gdk_x11_gl_context_glx_make_current (GdkGLContext *context,
|
||||
* to the vblank. */
|
||||
do_frame_sync = ! gdk_display_is_composited (display);
|
||||
|
||||
if (GDK_X11_DISPLAY (display)->has_glx_swap_control)
|
||||
if (do_frame_sync != self->do_frame_sync)
|
||||
{
|
||||
if (do_frame_sync != self->do_frame_sync)
|
||||
{
|
||||
self->do_frame_sync = do_frame_sync;
|
||||
self->do_frame_sync = do_frame_sync;
|
||||
|
||||
if (do_frame_sync)
|
||||
glXSwapIntervalEXT (dpy, drawable, 1);
|
||||
else
|
||||
glXSwapIntervalEXT (dpy, drawable, 0);
|
||||
}
|
||||
}
|
||||
else if (GDK_X11_DISPLAY (display)->has_glx_sgi_swap_control)
|
||||
{
|
||||
/* If the WM is compositing there is no particular need to delay
|
||||
* the swap when drawing on the offscreen, rendering to the screen
|
||||
* happens later anyway, and its up to the compositor to sync that
|
||||
* to the vblank. */
|
||||
do_frame_sync = ! gdk_display_is_composited (display);
|
||||
|
||||
if (do_frame_sync != self->do_frame_sync)
|
||||
{
|
||||
self->do_frame_sync = do_frame_sync;
|
||||
|
||||
if (do_frame_sync)
|
||||
glXSwapIntervalSGI (1);
|
||||
else
|
||||
glXSwapIntervalSGI (0);
|
||||
}
|
||||
if (do_frame_sync)
|
||||
glXSwapIntervalSGI (1);
|
||||
else
|
||||
glXSwapIntervalSGI (0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,20 +287,29 @@ gdk_x11_gl_context_glx_get_damage (GdkGLContext *context)
|
||||
glXQueryDrawable (dpy, gdk_x11_gl_context_glx_get_drawable (self),
|
||||
GLX_BACK_BUFFER_AGE_EXT, &buffer_age);
|
||||
|
||||
if (buffer_age > 0 && buffer_age <= GDK_GL_MAX_TRACKED_BUFFERS)
|
||||
switch (buffer_age)
|
||||
{
|
||||
cairo_region_t *damage = cairo_region_create ();
|
||||
int i;
|
||||
case 1:
|
||||
return cairo_region_create ();
|
||||
break;
|
||||
|
||||
for (i = 0; i < buffer_age - 1; i++)
|
||||
{
|
||||
if (context->old_updated_area[i] == NULL)
|
||||
return GDK_GL_CONTEXT_CLASS (gdk_x11_gl_context_glx_parent_class)->get_damage (context);
|
||||
case 2:
|
||||
if (context->old_updated_area[0])
|
||||
return cairo_region_copy (context->old_updated_area[0]);
|
||||
break;
|
||||
|
||||
cairo_region_union (damage, context->old_updated_area[i]);
|
||||
}
|
||||
case 3:
|
||||
if (context->old_updated_area[0] &&
|
||||
context->old_updated_area[1])
|
||||
{
|
||||
cairo_region_t *damage = cairo_region_copy (context->old_updated_area[0]);
|
||||
cairo_region_union (damage, context->old_updated_area[1]);
|
||||
return damage;
|
||||
}
|
||||
break;
|
||||
|
||||
return damage;
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -957,10 +945,8 @@ gdk_x11_display_init_glx (GdkX11Display *display_x11,
|
||||
epoxy_has_glx_extension (dpy, screen_num, "GLX_ARB_create_context_profile");
|
||||
display_x11->has_glx_create_es2_context =
|
||||
epoxy_has_glx_extension (dpy, screen_num, "GLX_EXT_create_context_es2_profile");
|
||||
display_x11->has_glx_sgi_swap_control =
|
||||
display_x11->has_glx_swap_interval =
|
||||
epoxy_has_glx_extension (dpy, screen_num, "GLX_SGI_swap_control");
|
||||
display_x11->has_glx_swap_control =
|
||||
epoxy_has_glx_extension (dpy, screen_num, "GLX_EXT_swap_control");
|
||||
display_x11->has_glx_texture_from_pixmap =
|
||||
epoxy_has_glx_extension (dpy, screen_num, "GLX_EXT_texture_from_pixmap");
|
||||
display_x11->has_glx_video_sync =
|
||||
@@ -1021,7 +1007,6 @@ gdk_x11_display_init_glx (GdkX11Display *display_x11,
|
||||
"\t* GLX_ARB_create_context_profile: %s\n"
|
||||
"\t* GLX_EXT_create_context_es2_profile: %s\n"
|
||||
"\t* GLX_SGI_swap_control: %s\n"
|
||||
"\t* GLX_EXT_swap_control: %s\n"
|
||||
"\t* GLX_EXT_texture_from_pixmap: %s\n"
|
||||
"\t* GLX_SGI_video_sync: %s\n"
|
||||
"\t* GLX_EXT_buffer_age: %s\n"
|
||||
@@ -1033,8 +1018,7 @@ gdk_x11_display_init_glx (GdkX11Display *display_x11,
|
||||
glXGetClientString (dpy, GLX_VENDOR),
|
||||
display_x11->has_glx_create_context ? "yes" : "no",
|
||||
display_x11->has_glx_create_es2_context ? "yes" : "no",
|
||||
display_x11->has_glx_sgi_swap_control ? "yes" : "no",
|
||||
display_x11->has_glx_swap_control ? "yes" : "no",
|
||||
display_x11->has_glx_swap_interval ? "yes" : "no",
|
||||
display_x11->has_glx_texture_from_pixmap ? "yes" : "no",
|
||||
display_x11->has_glx_video_sync ? "yes" : "no",
|
||||
display_x11->has_glx_buffer_age ? "yes" : "no",
|
||||
|
||||
@@ -88,7 +88,7 @@ gsk_gl_texture_library_real_compact (GskGLTextureLibrary *self,
|
||||
GskGLTextureAtlasEntry *entry;
|
||||
GHashTableIter iter;
|
||||
guint dropped = 0;
|
||||
G_GNUC_UNUSED guint atlased = 0;
|
||||
guint atlased = 0;
|
||||
|
||||
g_hash_table_iter_init (&iter, self->hash_table);
|
||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&entry))
|
||||
|
||||
@@ -450,7 +450,7 @@ gsk_vulkan_glyph_cache_begin_frame (GskVulkanGlyphCache *cache)
|
||||
GHashTableIter iter;
|
||||
GlyphCacheKey *key;
|
||||
GskVulkanCachedGlyph *value;
|
||||
G_GNUC_UNUSED guint dropped = 0;
|
||||
guint dropped = 0;
|
||||
|
||||
cache->timestamp++;
|
||||
|
||||
|
||||
@@ -220,7 +220,6 @@ enum
|
||||
PROP_COLUMNS,
|
||||
PROP_ENABLE_RUBBERBAND,
|
||||
PROP_HADJUSTMENT,
|
||||
PROP_HEADER_FACTORY,
|
||||
PROP_HSCROLL_POLICY,
|
||||
PROP_MODEL,
|
||||
PROP_REORDERABLE,
|
||||
@@ -630,10 +629,6 @@ gtk_column_view_get_property (GObject *object,
|
||||
g_value_set_object (value, self->hadjustment);
|
||||
break;
|
||||
|
||||
case PROP_HEADER_FACTORY:
|
||||
g_value_set_object (value, gtk_column_view_get_header_factory (self));
|
||||
break;
|
||||
|
||||
case PROP_HSCROLL_POLICY:
|
||||
g_value_set_enum (value, gtk_scrollable_get_hscroll_policy (GTK_SCROLLABLE (self->listview)));
|
||||
break;
|
||||
@@ -717,10 +712,6 @@ gtk_column_view_set_property (GObject *object,
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_HEADER_FACTORY:
|
||||
gtk_column_view_set_header_factory (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_HSCROLL_POLICY:
|
||||
if (gtk_scrollable_get_hscroll_policy (GTK_SCROLLABLE (self->listview)) != g_value_get_enum (value))
|
||||
{
|
||||
@@ -920,18 +911,6 @@ gtk_column_view_class_init (GtkColumnViewClass *klass)
|
||||
GTK_LIST_TAB_ALL,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkColumnView:header-factory: (attributes org.gtk.Property.get=gtk_column_view_get_header_factory org.gtk.Property.set=gtk_column_view_set_header_factory)
|
||||
*
|
||||
* Factory for creating header widgets.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
properties[PROP_HEADER_FACTORY] =
|
||||
g_param_spec_object ("header-factory", NULL, NULL,
|
||||
GTK_TYPE_LIST_ITEM_FACTORY,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
||||
|
||||
/**
|
||||
@@ -2128,49 +2107,3 @@ gtk_column_view_get_tab_behavior (GtkColumnView *self)
|
||||
return gtk_list_view_get_tab_behavior (self->listview);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_column_view_get_header_factory: (attributes org.gtk.Method.get_property=header-factory)
|
||||
* @self: a `GtkColumnView`
|
||||
*
|
||||
* Gets the factory that's currently used to populate section headers.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): The factory in use
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
GtkListItemFactory *
|
||||
gtk_column_view_get_header_factory (GtkColumnView *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_COLUMN_VIEW (self), NULL);
|
||||
|
||||
return gtk_list_view_get_header_factory (self->listview);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_column_view_set_header_factory: (attributes org.gtk.Method.set_property=header-factory)
|
||||
* @self: a `GtkColumnView`
|
||||
* @factory: (nullable) (transfer none): the factory to use
|
||||
*
|
||||
* Sets the `GtkListItemFactory` to use for populating the
|
||||
* [class@Gtk.ListHeader] objects used in section headers.
|
||||
*
|
||||
* If this factory is set to %NULL, the list will not show
|
||||
* section headers.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
void
|
||||
gtk_column_view_set_header_factory (GtkColumnView *self,
|
||||
GtkListItemFactory *factory)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_COLUMN_VIEW (self));
|
||||
g_return_if_fail (factory == NULL || GTK_IS_LIST_ITEM_FACTORY (factory));
|
||||
|
||||
if (factory == gtk_list_view_get_header_factory (self->listview))
|
||||
return;
|
||||
|
||||
gtk_list_view_set_header_factory (self->listview, factory);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_HEADER_FACTORY]);
|
||||
}
|
||||
|
||||
|
||||
@@ -122,13 +122,5 @@ GDK_AVAILABLE_IN_4_12
|
||||
GtkListItemFactory *
|
||||
gtk_column_view_get_row_factory (GtkColumnView *self);
|
||||
|
||||
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
void gtk_column_view_set_header_factory (GtkColumnView *self,
|
||||
GtkListItemFactory *factory);
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
GtkListItemFactory *
|
||||
gtk_column_view_get_header_factory (GtkColumnView *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+4
-4
@@ -19,7 +19,7 @@
|
||||
* Modified by the GTK+ Team and others 1997-2000. 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/.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@@ -207,7 +207,7 @@ gtk_drag_source_set_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkDragSource *source = GTK_DRAG_SOURCE (object);
|
||||
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CONTENT:
|
||||
@@ -424,13 +424,13 @@ gtk_drag_source_class_init (GtkDragSourceClass *class)
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
NULL, NULL,
|
||||
_gtk_marshal_VOID__OBJECT_BOOLEAN,
|
||||
_gtk_marshal_OBJECT__BOOLEAN,
|
||||
G_TYPE_NONE, 2,
|
||||
GDK_TYPE_DRAG,
|
||||
G_TYPE_BOOLEAN);
|
||||
g_signal_set_va_marshaller (signals[DRAG_END],
|
||||
GTK_TYPE_DRAG_SOURCE,
|
||||
_gtk_marshal_VOID__OBJECT_BOOLEANv);
|
||||
_gtk_marshal_OBJECT__BOOLEANv);
|
||||
|
||||
/**
|
||||
* GtkDragSource::drag-cancel:
|
||||
|
||||
@@ -150,13 +150,13 @@ make_action_unique (GdkDragAction actions)
|
||||
|
||||
if (actions & GDK_ACTION_MOVE)
|
||||
return GDK_ACTION_MOVE;
|
||||
|
||||
|
||||
if (actions & GDK_ACTION_LINK)
|
||||
return GDK_ACTION_LINK;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static GdkDragAction
|
||||
gtk_drop_target_async_drag_enter (GtkDropTargetAsync *self,
|
||||
GdkDrop *drop,
|
||||
@@ -166,7 +166,7 @@ gtk_drop_target_async_drag_enter (GtkDropTargetAsync *self,
|
||||
return make_action_unique (self->actions & gdk_drop_get_actions (drop));
|
||||
}
|
||||
|
||||
static GdkDragAction
|
||||
static GdkDragAction
|
||||
gtk_drop_target_async_drag_motion (GtkDropTargetAsync *self,
|
||||
GdkDrop *drop,
|
||||
double x,
|
||||
@@ -457,12 +457,12 @@ gtk_drop_target_async_class_init (GtkDropTargetAsyncClass *class)
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkDropTargetAsyncClass, drag_enter),
|
||||
g_signal_accumulator_first_wins, NULL,
|
||||
_gtk_marshal_FLAGS__OBJECT_DOUBLE_DOUBLE,
|
||||
_gtk_marshal_ENUM__OBJECT_DOUBLE_DOUBLE,
|
||||
GDK_TYPE_DRAG_ACTION, 3,
|
||||
GDK_TYPE_DROP, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
|
||||
g_signal_set_va_marshaller (signals[DRAG_ENTER],
|
||||
GTK_TYPE_DROP_TARGET_ASYNC,
|
||||
_gtk_marshal_FLAGS__OBJECT_DOUBLE_DOUBLEv);
|
||||
_gtk_marshal_ENUM__OBJECT_DOUBLE_DOUBLEv);
|
||||
|
||||
/**
|
||||
* GtkDropTargetAsync::drag-motion:
|
||||
@@ -481,12 +481,12 @@ gtk_drop_target_async_class_init (GtkDropTargetAsyncClass *class)
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkDropTargetAsyncClass, drag_motion),
|
||||
g_signal_accumulator_first_wins, NULL,
|
||||
_gtk_marshal_FLAGS__OBJECT_DOUBLE_DOUBLE,
|
||||
_gtk_marshal_ENUM__OBJECT_DOUBLE_DOUBLE,
|
||||
GDK_TYPE_DRAG_ACTION, 3,
|
||||
GDK_TYPE_DROP, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
|
||||
g_signal_set_va_marshaller (signals[DRAG_MOTION],
|
||||
GTK_TYPE_DROP_TARGET_ASYNC,
|
||||
_gtk_marshal_FLAGS__OBJECT_DOUBLE_DOUBLEv);
|
||||
_gtk_marshal_ENUM__OBJECT_DOUBLE_DOUBLEv);
|
||||
|
||||
/**
|
||||
* GtkDropTargetAsync::drag-leave:
|
||||
@@ -617,7 +617,7 @@ GdkContentFormats *
|
||||
gtk_drop_target_async_get_formats (GtkDropTargetAsync *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_DROP_TARGET_ASYNC (self), NULL);
|
||||
|
||||
|
||||
return self->formats;
|
||||
}
|
||||
|
||||
@@ -633,7 +633,7 @@ gtk_drop_target_async_set_actions (GtkDropTargetAsync *self,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_DROP_TARGET_ASYNC (self));
|
||||
|
||||
|
||||
if (self->actions == actions)
|
||||
return;
|
||||
|
||||
|
||||
+2
-2
@@ -69,9 +69,9 @@ typedef enum
|
||||
GTK_ALIGN_START,
|
||||
GTK_ALIGN_END,
|
||||
GTK_ALIGN_CENTER,
|
||||
GTK_ALIGN_BASELINE_FILL GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||
GTK_ALIGN_BASELINE_FILL,
|
||||
GTK_ALIGN_BASELINE GDK_DEPRECATED_ENUMERATOR_IN_4_12_FOR(GTK_ALIGN_BASELINE_FILL) = GTK_ALIGN_BASELINE_FILL,
|
||||
GTK_ALIGN_BASELINE_CENTER GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||
GTK_ALIGN_BASELINE_CENTER,
|
||||
} GtkAlign;
|
||||
|
||||
/**
|
||||
|
||||
@@ -410,22 +410,16 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ABS (scroll->cur_dx) >= 0.5)
|
||||
if (ABS (scroll->cur_dx) >= 1)
|
||||
{
|
||||
steps = trunc (scroll->cur_dx);
|
||||
if (steps == 0)
|
||||
steps = (scroll->cur_dx > 0) ? 1 : -1;
|
||||
|
||||
scroll->cur_dx -= steps;
|
||||
dx = steps;
|
||||
}
|
||||
|
||||
if (ABS (scroll->cur_dy) >= 0.5)
|
||||
if (ABS (scroll->cur_dy) >= 1)
|
||||
{
|
||||
steps = trunc (scroll->cur_dy);
|
||||
if (steps == 0)
|
||||
steps = (scroll->cur_dy > 0) ? 1 : -1;
|
||||
|
||||
scroll->cur_dy -= steps;
|
||||
dy = steps;
|
||||
}
|
||||
@@ -465,22 +459,16 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
|
||||
scroll->cur_dy += dy;
|
||||
dx = dy = 0;
|
||||
|
||||
if (ABS (scroll->cur_dx) >= 0.5)
|
||||
if (ABS (scroll->cur_dx) >= 1)
|
||||
{
|
||||
steps = trunc (scroll->cur_dx);
|
||||
if (steps == 0)
|
||||
steps = (scroll->cur_dx > 0) ? 1 : -1;
|
||||
|
||||
scroll->cur_dx -= steps;
|
||||
dx = steps;
|
||||
}
|
||||
|
||||
if (ABS (scroll->cur_dy) >= 0.5)
|
||||
if (ABS (scroll->cur_dy) >= 1)
|
||||
{
|
||||
steps = trunc (scroll->cur_dy);
|
||||
if (steps == 0)
|
||||
steps = (scroll->cur_dy > 0) ? 1 : -1;
|
||||
|
||||
scroll->cur_dy -= steps;
|
||||
dy = steps;
|
||||
}
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@
|
||||
* expanded widget yourself, such as when you want to actually create
|
||||
* the widget at expansion time. In this case, create a `GtkExpander`
|
||||
* but do not add a child to it. The expander widget has an
|
||||
* [property@Gtk.Expander:expanded] property which can be used to
|
||||
* [property@Gtk.Expander:expanded[ property which can be used to
|
||||
* monitor its expansion state. You should watch this property with
|
||||
* a signal connection as follows:
|
||||
*
|
||||
|
||||
+14
-13
@@ -229,9 +229,9 @@ open_done (GObject *source,
|
||||
#endif
|
||||
|
||||
static void
|
||||
show_item_done (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
show_folder_done (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
GDBusConnection *bus = G_DBUS_CONNECTION (source);
|
||||
GTask *task = G_TASK (data);
|
||||
@@ -261,10 +261,11 @@ show_item_done (GObject *source,
|
||||
#define FILE_MANAGER_DBUS_PATH "/org/freedesktop/FileManager1"
|
||||
|
||||
static void
|
||||
show_item (GtkWindow *parent,
|
||||
const char *uri,
|
||||
GCancellable *cancellable,
|
||||
GTask *task)
|
||||
show_folder (GtkWindow *parent,
|
||||
const char *uri,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GDBusConnection *bus;
|
||||
GVariantBuilder uris_builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_STRING_ARRAY);
|
||||
@@ -273,10 +274,10 @@ show_item (GtkWindow *parent,
|
||||
|
||||
if (!bus)
|
||||
{
|
||||
g_task_return_new_error (task,
|
||||
g_task_return_new_error (G_TASK (user_data),
|
||||
GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_FAILED,
|
||||
"Session bus not available");
|
||||
g_object_unref (task);
|
||||
g_object_unref (G_TASK (user_data));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -286,14 +287,14 @@ show_item (GtkWindow *parent,
|
||||
FILE_MANAGER_DBUS_NAME,
|
||||
FILE_MANAGER_DBUS_PATH,
|
||||
FILE_MANAGER_DBUS_IFACE,
|
||||
"ShowItems",
|
||||
"ShowFolders",
|
||||
g_variant_new ("(ass)", &uris_builder, ""),
|
||||
NULL, /* ignore returned type */
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
cancellable,
|
||||
show_item_done,
|
||||
task);
|
||||
show_folder_done,
|
||||
user_data);
|
||||
}
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
@@ -469,7 +470,7 @@ gtk_file_launcher_open_containing_folder (GtkFileLauncher *self,
|
||||
{
|
||||
char *uri = g_file_get_uri (self->file);
|
||||
|
||||
show_item (parent, uri, cancellable, task);
|
||||
show_folder (parent, uri, cancellable, show_folder_done, task);
|
||||
|
||||
g_free (uri);
|
||||
}
|
||||
|
||||
@@ -34,11 +34,9 @@
|
||||
* It hides some elements from the other model according to
|
||||
* criteria given by a `GtkFilter`.
|
||||
*
|
||||
* The model can be set up to do incremental filtering, so that
|
||||
* The model can be set up to do incremental searching, so that
|
||||
* filtering long lists doesn't block the UI. See
|
||||
* [method@Gtk.FilterListModel.set_incremental] for details.
|
||||
*
|
||||
* `GtkFilterListModel` passes through sections from the underlying model.
|
||||
*/
|
||||
|
||||
enum {
|
||||
@@ -190,39 +188,6 @@ gtk_filter_list_model_get_section (GtkSectionModel *model,
|
||||
*out_end = *out_start + gtk_bitset_get_size_in_range (self->matches, start, end - 1);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_filter_list_model_sections_changed_cb (GtkSectionModel *model,
|
||||
unsigned int position,
|
||||
unsigned int n_items,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkFilterListModel *self = GTK_FILTER_LIST_MODEL (user_data);
|
||||
unsigned int start, end;
|
||||
|
||||
switch (self->strictness)
|
||||
{
|
||||
case GTK_FILTER_MATCH_NONE:
|
||||
return;
|
||||
|
||||
case GTK_FILTER_MATCH_ALL:
|
||||
gtk_section_model_sections_changed (GTK_SECTION_MODEL (self), position, n_items);
|
||||
break;
|
||||
|
||||
case GTK_FILTER_MATCH_SOME:
|
||||
if (position > 0)
|
||||
start = gtk_bitset_get_size_in_range (self->matches, 0, position - 1);
|
||||
else
|
||||
start = 0;
|
||||
end = gtk_bitset_get_size_in_range (self->matches, 0, position + n_items - 1);
|
||||
if (end - start > 0)
|
||||
gtk_section_model_sections_changed (GTK_SECTION_MODEL (self), start, end - start);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_filter_list_model_section_model_init (GtkSectionModelInterface *iface)
|
||||
{
|
||||
@@ -498,7 +463,6 @@ gtk_filter_list_model_clear_model (GtkFilterListModel *self)
|
||||
|
||||
gtk_filter_list_model_stop_filtering (self);
|
||||
g_signal_handlers_disconnect_by_func (self->model, gtk_filter_list_model_items_changed_cb, self);
|
||||
g_signal_handlers_disconnect_by_func (self->model, gtk_filter_list_model_sections_changed_cb, self);
|
||||
g_clear_object (&self->model);
|
||||
if (self->matches)
|
||||
gtk_bitset_remove_all (self->matches);
|
||||
@@ -863,8 +827,6 @@ gtk_filter_list_model_set_model (GtkFilterListModel *self,
|
||||
{
|
||||
self->model = g_object_ref (model);
|
||||
g_signal_connect (model, "items-changed", G_CALLBACK (gtk_filter_list_model_items_changed_cb), self);
|
||||
if (GTK_IS_SECTION_MODEL (model))
|
||||
g_signal_connect (model, "sections-changed", G_CALLBACK (gtk_filter_list_model_sections_changed_cb), self);
|
||||
if (removed == 0)
|
||||
{
|
||||
self->strictness = GTK_FILTER_MATCH_NONE;
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
*
|
||||
* `GtkFlattenListModel` is a list model that concatenates other list models.
|
||||
*
|
||||
* `GtkFlattenListModel` takes a list model containing list models, and flattens
|
||||
* it into a single model. Each list model becomes a section in the single model.
|
||||
* `GtkFlattenListModel` takes a list model containing list models,
|
||||
* and flattens it into a single model.
|
||||
*/
|
||||
|
||||
enum {
|
||||
|
||||
+68
-145
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkgridviewprivate.h"
|
||||
#include "gtkgridview.h"
|
||||
|
||||
#include "gtkbitset.h"
|
||||
#include "gtklistbaseprivate.h"
|
||||
@@ -384,37 +384,6 @@ gtk_grid_view_get_allocation (GtkListBase *base,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Returns the column that the given item will fall in.
|
||||
*/
|
||||
unsigned int
|
||||
gtk_grid_view_get_column_for_position (GtkListItemManager *items,
|
||||
unsigned int n_columns,
|
||||
unsigned int position)
|
||||
{
|
||||
return position % n_columns;
|
||||
}
|
||||
|
||||
/* Determine whether a tile is contained in a single row,
|
||||
* or spans multiple rows.
|
||||
*/
|
||||
gboolean
|
||||
gtk_grid_view_is_multirow_tile (GtkListItemManager *items,
|
||||
unsigned int n_columns,
|
||||
GtkListTile *tile)
|
||||
{
|
||||
unsigned int position;
|
||||
unsigned int col;
|
||||
|
||||
if (tile->n_items <= 1)
|
||||
return FALSE;
|
||||
|
||||
position = gtk_list_tile_get_position (items, tile);
|
||||
|
||||
col = position % n_columns;
|
||||
|
||||
return col + tile->n_items > n_columns;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_grid_view_get_position_from_allocation (GtkListBase *base,
|
||||
int x,
|
||||
@@ -425,7 +394,6 @@ gtk_grid_view_get_position_from_allocation (GtkListBase *base,
|
||||
GtkGridView *self = GTK_GRID_VIEW (base);
|
||||
GtkListTile *tile;
|
||||
guint pos;
|
||||
guint col;
|
||||
|
||||
tile = gtk_list_item_manager_get_nearest_tile (self->item_manager, x, y);
|
||||
if (tile == NULL)
|
||||
@@ -443,43 +411,44 @@ gtk_grid_view_get_position_from_allocation (GtkListBase *base,
|
||||
}
|
||||
|
||||
pos = gtk_list_tile_get_position (self->item_manager, tile);
|
||||
col = gtk_grid_view_get_column_for_position (self->item_manager, self->n_columns, pos);
|
||||
|
||||
if (tile->n_items > 1)
|
||||
{
|
||||
int xspacing, yspacing;
|
||||
unsigned int row_height;
|
||||
unsigned int row_index;
|
||||
|
||||
gtk_list_base_get_border_spacing (base, &xspacing, &yspacing);
|
||||
|
||||
/* offset in x direction */
|
||||
pos += column_index (self, xspacing, MAX (tile->area.width - 1, x - tile->area.x));
|
||||
if (area)
|
||||
{
|
||||
guint col = MIN (column_index (self, xspacing, x), self->n_columns - 1);
|
||||
area->x = column_start (self, xspacing, col);
|
||||
area->width = column_end (self, xspacing, col) - area->x;
|
||||
}
|
||||
|
||||
/* offset in y direction */
|
||||
if (tile->n_items > self->n_columns)
|
||||
{
|
||||
guint rows_in_tile = tile->n_items / self->n_columns;
|
||||
|
||||
row_height = (tile->area.height + yspacing) / rows_in_tile - yspacing;
|
||||
row_index = MIN (tile->area.height - 1, y - tile->area.y) / (row_height + yspacing);
|
||||
guint row_height = (tile->area.height + yspacing) / rows_in_tile - yspacing;
|
||||
guint row_index = MIN (tile->area.height - 1, y - tile->area.y) / (row_height + yspacing);
|
||||
pos += self->n_columns * row_index;
|
||||
|
||||
if (area)
|
||||
{
|
||||
area->y = tile->area.y + row_index * (row_height + yspacing);
|
||||
area->height = row_height;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
row_height = tile->area.height;
|
||||
row_index = 0;
|
||||
if (area)
|
||||
{
|
||||
area->y = tile->area.y;
|
||||
area->height = tile->area.height;
|
||||
}
|
||||
}
|
||||
|
||||
col = gtk_grid_view_get_column_for_position (self->item_manager, self->n_columns, pos);
|
||||
|
||||
if (area)
|
||||
{
|
||||
area->x = column_start (self, xspacing, col);
|
||||
area->y = tile->area.y + row_index * (row_height + yspacing);
|
||||
area->width = column_end (self, xspacing, col) - area->x;
|
||||
area->height = row_height;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -584,7 +553,8 @@ static int
|
||||
gtk_grid_view_get_unknown_row_size (GtkGridView *self,
|
||||
GArray *heights)
|
||||
{
|
||||
g_return_val_if_fail (heights->len > 0, 0);
|
||||
if (heights->len == 0)
|
||||
return 0;
|
||||
|
||||
/* return the median and hope rows are generally uniform with few outliers */
|
||||
g_array_sort (heights, compare_ints);
|
||||
@@ -767,48 +737,6 @@ gtk_grid_view_measure (GtkWidget *widget,
|
||||
gtk_grid_view_measure_across (widget, for_size, minimum, natural);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_grid_view_split_tiles_by_columns (GtkListItemManager *items,
|
||||
guint n_columns)
|
||||
{
|
||||
GtkListTile *tile;
|
||||
|
||||
for (tile = gtk_list_item_manager_get_first (items);
|
||||
tile != NULL;
|
||||
tile = gtk_rb_tree_node_get_next (tile))
|
||||
{
|
||||
if (tile->n_items > 1)
|
||||
{
|
||||
guint pos, col;
|
||||
guint remaining;
|
||||
|
||||
pos = gtk_list_tile_get_position (items, tile);
|
||||
col = gtk_grid_view_get_column_for_position (items, n_columns, pos);
|
||||
|
||||
if (col > 0)
|
||||
{
|
||||
/* Determine if the first row needs to be split off */
|
||||
remaining = n_columns - col;
|
||||
if (remaining > 0 && tile->n_items > remaining)
|
||||
gtk_list_tile_split (items, tile, remaining);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
pos += tile->n_items - 1;
|
||||
col = gtk_grid_view_get_column_for_position (items, n_columns, pos);
|
||||
|
||||
if (col < n_columns - 1)
|
||||
{
|
||||
/* Determine if the last row needs to be split off */
|
||||
remaining = n_columns - (col - 1);
|
||||
if (remaining > 0 && col + 1 < tile->n_items)
|
||||
tile = gtk_list_tile_split (items, tile, tile->n_items - (col + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_grid_view_size_allocate (GtkWidget *widget,
|
||||
int width,
|
||||
@@ -829,10 +757,8 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
|
||||
min_row_height = ceil ((double) height / GTK_GRID_VIEW_MAX_VISIBLE_ROWS);
|
||||
gtk_list_base_get_border_spacing (GTK_LIST_BASE (self), &xspacing, &yspacing);
|
||||
|
||||
gtk_list_item_manager_gc_tiles (self->item_manager);
|
||||
|
||||
/* step 0: exit early if list is empty */
|
||||
tile = gtk_list_item_manager_get_first (self->item_manager);
|
||||
tile = gtk_list_tile_gc (self->item_manager, gtk_list_item_manager_get_first (self->item_manager));
|
||||
if (tile == NULL)
|
||||
{
|
||||
gtk_list_base_allocate (GTK_LIST_BASE (self));
|
||||
@@ -848,26 +774,29 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
|
||||
self->column_width = ((orientation == GTK_ORIENTATION_VERTICAL ? width : height) + xspacing) / self->n_columns - xspacing;
|
||||
self->column_width = MAX (self->column_width, col_min);
|
||||
|
||||
/* step 2: split tiles as required */
|
||||
gtk_grid_view_split_tiles_by_columns (self->item_manager, self->n_columns);
|
||||
|
||||
/* step 3: determine height of known rows */
|
||||
/* step 2: determine height of known rows */
|
||||
heights = g_array_new (FALSE, FALSE, sizeof (int));
|
||||
|
||||
tile = gtk_list_item_manager_get_first (self->item_manager);
|
||||
while (tile != NULL)
|
||||
for (;
|
||||
tile != NULL;
|
||||
tile = gtk_list_tile_gc (self->item_manager, tile))
|
||||
{
|
||||
if (gtk_grid_view_is_multirow_tile (self->item_manager, self->n_columns, tile))
|
||||
/* if it's a multirow tile, handle it here */
|
||||
if (tile->n_items > 1 && tile->n_items >= self->n_columns)
|
||||
{
|
||||
if (tile->n_items % self->n_columns)
|
||||
gtk_list_tile_split (self->item_manager, tile, tile->n_items / self->n_columns * self->n_columns);
|
||||
tile = gtk_rb_tree_node_get_next (tile);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Not a multirow tile */
|
||||
i = 0;
|
||||
row_height = 0;
|
||||
|
||||
for (i = 0, start = tile;
|
||||
i < self->n_columns && tile != NULL;
|
||||
tile = gtk_rb_tree_node_get_next (tile))
|
||||
tile = gtk_list_tile_gc (self->item_manager, gtk_rb_tree_node_get_next (tile)))
|
||||
{
|
||||
if (tile->widget)
|
||||
{
|
||||
@@ -884,53 +813,32 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
|
||||
g_array_append_val (heights, size);
|
||||
row_height = MAX (row_height, size);
|
||||
}
|
||||
if (tile->n_items > self->n_columns - i)
|
||||
gtk_list_tile_split (self->item_manager, tile, self->n_columns - i);
|
||||
i += tile->n_items;
|
||||
}
|
||||
|
||||
if (row_height > 0)
|
||||
{
|
||||
for (i = 0;
|
||||
start != tile;
|
||||
start = gtk_rb_tree_node_get_next (start))
|
||||
{
|
||||
unsigned int n_columns;
|
||||
unsigned int tile_height;
|
||||
|
||||
if (gtk_list_tile_is_footer (start))
|
||||
{
|
||||
n_columns = self->n_columns - i;
|
||||
if (n_columns != 0 && n_columns != self->n_columns)
|
||||
tile_height = row_height;
|
||||
else
|
||||
tile_height = 0;
|
||||
}
|
||||
else if (gtk_list_tile_is_header (start))
|
||||
{
|
||||
n_columns = self->n_columns;
|
||||
tile_height = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
n_columns = start->n_items;
|
||||
tile_height = row_height;
|
||||
}
|
||||
|
||||
gtk_list_tile_set_area_size (self->item_manager,
|
||||
start,
|
||||
column_end (self, xspacing, i + n_columns - 1)
|
||||
column_end (self, xspacing, i + start->n_items - 1)
|
||||
- column_start (self, xspacing, i),
|
||||
tile_height);
|
||||
|
||||
i = (i + start->n_items) % self->n_columns;
|
||||
row_height);
|
||||
i += start->n_items;
|
||||
}
|
||||
g_assert (i <= self->n_columns);
|
||||
}
|
||||
}
|
||||
|
||||
/* step 4: determine height of rows with only unknown items */
|
||||
/* step 3: determine height of rows with only unknown items */
|
||||
unknown_row_height = gtk_grid_view_get_unknown_row_size (self, heights);
|
||||
g_array_free (heights, TRUE);
|
||||
|
||||
/* step 5: determine height for remaining rows and set each row's position */
|
||||
/* step 4: determine height for remaining rows and set each row's position */
|
||||
y = 0;
|
||||
i = 0;
|
||||
for (tile = gtk_list_item_manager_get_first (self->item_manager);
|
||||
@@ -941,8 +849,7 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
|
||||
tile,
|
||||
column_start (self, xspacing, i),
|
||||
y);
|
||||
|
||||
if (gtk_grid_view_is_multirow_tile (self->item_manager, self->n_columns, tile))
|
||||
if (tile->n_items >= self->n_columns && tile->widget == NULL)
|
||||
{
|
||||
g_assert (i == 0);
|
||||
g_assert (tile->n_items % self->n_columns == 0);
|
||||
@@ -955,10 +862,15 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_list_tile_set_area_size (self->item_manager,
|
||||
tile,
|
||||
column_end (self, xspacing, i + tile->n_items - 1) - tile->area.x,
|
||||
unknown_row_height);
|
||||
if (tile->area.height == 0)
|
||||
{
|
||||
/* this case is for the last row - it may not be a full row so it won't
|
||||
* be a multirow tile but it may have no widgets either */
|
||||
gtk_list_tile_set_area_size (self->item_manager,
|
||||
tile,
|
||||
column_end (self, xspacing, i + tile->n_items - 1) - tile->area.x,
|
||||
unknown_row_height);
|
||||
}
|
||||
i += tile->n_items;
|
||||
}
|
||||
|
||||
@@ -969,8 +881,23 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
/* Add a filler tile for empty space in the bottom right */
|
||||
if (i > 0)
|
||||
{
|
||||
GtkListTile *filler;
|
||||
tile = gtk_list_item_manager_get_last (self->item_manager);
|
||||
filler = gtk_list_tile_append_filler (self->item_manager, tile);
|
||||
gtk_list_tile_set_area_position (self->item_manager,
|
||||
filler,
|
||||
column_start (self, xspacing, i),
|
||||
y);
|
||||
gtk_list_tile_set_area_size (self->item_manager,
|
||||
filler,
|
||||
column_end (self, xspacing, self->n_columns - 1) - filler->area.x,
|
||||
tile->area.height);
|
||||
}
|
||||
|
||||
/* step 6: allocate the rest */
|
||||
/* step 4: allocate the rest */
|
||||
gtk_list_base_allocate (GTK_LIST_BASE (self));
|
||||
}
|
||||
|
||||
@@ -1025,8 +952,6 @@ gtk_grid_view_dispose (GObject *object)
|
||||
|
||||
self->item_manager = NULL;
|
||||
|
||||
g_clear_object (&self->factory);
|
||||
|
||||
G_OBJECT_CLASS (gtk_grid_view_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
@@ -1411,8 +1336,6 @@ gtk_grid_view_set_factory (GtkGridView *self,
|
||||
if (!g_set_object (&self->factory, factory))
|
||||
return;
|
||||
|
||||
gtk_grid_view_update_factories (self);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FACTORY]);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2023 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gtk/gtktypes.h"
|
||||
#include "gtk/gtkenums.h"
|
||||
#include "gtk/gtkgridview.h"
|
||||
#include "gtk/gtklistitemmanagerprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
unsigned int gtk_grid_view_get_column_for_position (GtkListItemManager *items,
|
||||
unsigned int n_columns,
|
||||
unsigned int position);
|
||||
|
||||
gboolean gtk_grid_view_is_multirow_tile (GtkListItemManager *items,
|
||||
unsigned int n_columns,
|
||||
GtkListTile *tile);
|
||||
|
||||
void gtk_grid_view_split_tiles_by_columns (GtkListItemManager *items,
|
||||
guint n_columns);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
+56
-89
@@ -198,6 +198,7 @@ gtk_list_item_manager_augment_node (GtkRbTree *tree,
|
||||
aug->has_footer = TRUE;
|
||||
break;
|
||||
case GTK_LIST_TILE_ITEM:
|
||||
case GTK_LIST_TILE_FILLER:
|
||||
case GTK_LIST_TILE_REMOVED:
|
||||
aug->has_header = FALSE;
|
||||
aug->has_footer = FALSE;
|
||||
@@ -568,7 +569,8 @@ gtk_list_tile_get_tile_at (GtkListItemManager *self,
|
||||
* 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 tiles
|
||||
* 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,
|
||||
@@ -631,7 +633,7 @@ static GtkListTile *
|
||||
gtk_list_tile_get_next_skip (GtkListTile *tile)
|
||||
{
|
||||
for (tile = gtk_rb_tree_node_get_next (tile);
|
||||
tile && tile->type == GTK_LIST_TILE_REMOVED;
|
||||
tile && (tile->type == GTK_LIST_TILE_FILLER || tile->type == GTK_LIST_TILE_REMOVED);
|
||||
tile = gtk_rb_tree_node_get_next (tile))
|
||||
{ }
|
||||
|
||||
@@ -642,7 +644,7 @@ static GtkListTile *
|
||||
gtk_list_tile_get_previous_skip (GtkListTile *tile)
|
||||
{
|
||||
for (tile = gtk_rb_tree_node_get_previous (tile);
|
||||
tile && tile->type == GTK_LIST_TILE_REMOVED;
|
||||
tile && (tile->type == GTK_LIST_TILE_FILLER || tile->type == GTK_LIST_TILE_REMOVED);
|
||||
tile = gtk_rb_tree_node_get_previous (tile))
|
||||
{ }
|
||||
|
||||
@@ -883,6 +885,7 @@ gtk_list_item_manager_remove_items (GtkListItemManager *self,
|
||||
gtk_list_tile_set_type (tile, GTK_LIST_TILE_REMOVED);
|
||||
break;
|
||||
|
||||
case GTK_LIST_TILE_FILLER:
|
||||
case GTK_LIST_TILE_REMOVED:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
@@ -925,7 +928,7 @@ gtk_list_item_manager_add_items (GtkListItemManager *self,
|
||||
{
|
||||
/* at end of list, pick the footer */
|
||||
for (tile = gtk_rb_tree_get_last (self->items);
|
||||
tile && tile->type == GTK_LIST_TILE_REMOVED;
|
||||
tile && (tile->type == GTK_LIST_TILE_REMOVED || tile->type == GTK_LIST_TILE_FILLER);
|
||||
tile = gtk_rb_tree_node_get_previous (tile))
|
||||
{ }
|
||||
|
||||
@@ -999,7 +1002,7 @@ gtk_list_item_manager_merge_list_items (GtkListItemManager *self,
|
||||
* 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
|
||||
* inserted after the tile.
|
||||
* nserted after the tile.
|
||||
*
|
||||
* It is not valid for either tile to have 0 items after
|
||||
* the split.
|
||||
@@ -1026,6 +1029,34 @@ gtk_list_tile_split (GtkListItemManager *self,
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* gtk_list_tile_append_filler:
|
||||
* @self: the listitemmanager
|
||||
* @previous: tile to append to
|
||||
*
|
||||
* Appends a filler tile.
|
||||
*
|
||||
* Filler tiles don't refer to any items or header and exist
|
||||
* just to take up space, so that finding items by position gets
|
||||
* easier.
|
||||
*
|
||||
* They ave a special garbage-collection behavior, see
|
||||
* gtk_list_tile_gc().
|
||||
*
|
||||
* Returns: The new filler tile
|
||||
**/
|
||||
GtkListTile *
|
||||
gtk_list_tile_append_filler (GtkListItemManager *self,
|
||||
GtkListTile *previous)
|
||||
{
|
||||
GtkListTile *result;
|
||||
|
||||
result = gtk_rb_tree_insert_after (self->items, previous);
|
||||
result->type = GTK_LIST_TILE_FILLER;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* gtk_list_tile_gc:
|
||||
* @self: the listitemmanager
|
||||
@@ -1043,7 +1074,7 @@ gtk_list_tile_split (GtkListItemManager *self,
|
||||
*
|
||||
* Returns: The next tile or NULL if everything was gc'ed
|
||||
**/
|
||||
static GtkListTile *
|
||||
GtkListTile *
|
||||
gtk_list_tile_gc (GtkListItemManager *self,
|
||||
GtkListTile *tile)
|
||||
{
|
||||
@@ -1052,6 +1083,13 @@ gtk_list_tile_gc (GtkListItemManager *self,
|
||||
if (tile == NULL)
|
||||
return NULL;
|
||||
|
||||
if (tile->type == GTK_LIST_TILE_FILLER)
|
||||
{
|
||||
next = gtk_rb_tree_node_get_next (tile);
|
||||
gtk_rb_tree_remove (self->items, tile);
|
||||
tile = next;
|
||||
}
|
||||
|
||||
while (tile)
|
||||
{
|
||||
next = gtk_rb_tree_node_get_next (tile);
|
||||
@@ -1075,6 +1113,7 @@ gtk_list_tile_gc (GtkListItemManager *self,
|
||||
case GTK_LIST_TILE_FOOTER:
|
||||
case GTK_LIST_TILE_UNMATCHED_HEADER:
|
||||
case GTK_LIST_TILE_UNMATCHED_FOOTER:
|
||||
case GTK_LIST_TILE_FILLER:
|
||||
break;
|
||||
|
||||
case GTK_LIST_TILE_REMOVED:
|
||||
@@ -1093,18 +1132,6 @@ gtk_list_tile_gc (GtkListItemManager *self,
|
||||
return tile;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_list_item_manager_gc_tiles (GtkListItemManager *self)
|
||||
{
|
||||
GtkListTile *tile;
|
||||
|
||||
for (tile = gtk_list_tile_gc (self, gtk_list_item_manager_get_first (self));
|
||||
tile != NULL;
|
||||
tile = gtk_list_tile_gc (self, gtk_rb_tree_node_get_next (tile)))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_list_item_manager_release_items (GtkListItemManager *self,
|
||||
GtkListItemChange *change)
|
||||
@@ -1153,6 +1180,7 @@ gtk_list_item_manager_release_items (GtkListItemManager *self,
|
||||
deleted_section = TRUE;
|
||||
break;
|
||||
|
||||
case GTK_LIST_TILE_FILLER:
|
||||
case GTK_LIST_TILE_REMOVED:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
@@ -1386,6 +1414,7 @@ gtk_list_item_manager_ensure_items (GtkListItemManager *self,
|
||||
break;
|
||||
|
||||
case GTK_LIST_TILE_UNMATCHED_FOOTER:
|
||||
case GTK_LIST_TILE_FILLER:
|
||||
case GTK_LIST_TILE_REMOVED:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
@@ -1565,67 +1594,6 @@ gtk_list_item_manager_model_items_changed_cb (GListModel *model,
|
||||
gtk_widget_queue_resize (self->widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_list_item_manager_model_sections_changed_cb (GListModel *model,
|
||||
guint position,
|
||||
guint n_items,
|
||||
GtkListItemManager *self)
|
||||
{
|
||||
GtkListItemChange change;
|
||||
GtkListTile *tile, *header;
|
||||
guint offset;
|
||||
|
||||
if (!gtk_list_item_manager_has_sections (self))
|
||||
return;
|
||||
|
||||
gtk_list_item_change_init (&change);
|
||||
|
||||
tile = gtk_list_item_manager_get_nth (self, position, &offset);
|
||||
header = gtk_list_tile_get_header (self, tile);
|
||||
gtk_list_item_change_clear_header (&change, &header->widget);
|
||||
gtk_list_tile_set_type (header, GTK_LIST_TILE_UNMATCHED_HEADER);
|
||||
|
||||
n_items -= MIN (n_items, position - offset);
|
||||
while (n_items > 0)
|
||||
{
|
||||
switch (tile->type)
|
||||
{
|
||||
case GTK_LIST_TILE_HEADER:
|
||||
case GTK_LIST_TILE_UNMATCHED_HEADER:
|
||||
gtk_list_item_change_clear_header (&change, &tile->widget);
|
||||
gtk_list_tile_set_type (tile, GTK_LIST_TILE_REMOVED);
|
||||
break;
|
||||
|
||||
case GTK_LIST_TILE_FOOTER:
|
||||
case GTK_LIST_TILE_UNMATCHED_FOOTER:
|
||||
gtk_list_tile_set_type (tile, GTK_LIST_TILE_REMOVED);
|
||||
break;
|
||||
|
||||
case GTK_LIST_TILE_ITEM:
|
||||
n_items -= MIN (n_items, tile->n_items);
|
||||
break;
|
||||
|
||||
case GTK_LIST_TILE_REMOVED:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
tile = gtk_list_tile_get_next_skip (tile);
|
||||
}
|
||||
|
||||
if (!gtk_list_tile_is_footer (tile))
|
||||
tile = gtk_list_tile_get_footer (self, tile);
|
||||
|
||||
gtk_list_tile_set_type (tile, GTK_LIST_TILE_UNMATCHED_FOOTER);
|
||||
|
||||
gtk_list_item_manager_ensure_items (self, &change, G_MAXUINT, 0);
|
||||
|
||||
gtk_list_item_change_finish (&change);
|
||||
|
||||
gtk_widget_queue_resize (GTK_WIDGET (self->widget));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_list_item_manager_model_selection_changed_cb (GListModel *model,
|
||||
guint position,
|
||||
@@ -1666,6 +1634,7 @@ static void
|
||||
gtk_list_item_manager_clear_model (GtkListItemManager *self)
|
||||
{
|
||||
GtkListItemChange change;
|
||||
GtkListTile *tile;
|
||||
GSList *l;
|
||||
|
||||
if (self->model == NULL)
|
||||
@@ -1685,13 +1654,15 @@ gtk_list_item_manager_clear_model (GtkListItemManager *self)
|
||||
g_signal_handlers_disconnect_by_func (self->model,
|
||||
gtk_list_item_manager_model_items_changed_cb,
|
||||
self);
|
||||
g_signal_handlers_disconnect_by_func (self->model,
|
||||
gtk_list_item_manager_model_sections_changed_cb,
|
||||
self);
|
||||
g_clear_object (&self->model);
|
||||
|
||||
gtk_list_item_manager_gc_tiles (self);
|
||||
|
||||
/* really empty the tiles */
|
||||
for (tile = gtk_list_tile_gc (self, gtk_list_item_manager_get_first (self));
|
||||
tile;
|
||||
tile = gtk_list_tile_gc (self, tile))
|
||||
{
|
||||
g_assert (tile->type == GTK_LIST_TILE_FILLER);
|
||||
}
|
||||
g_assert (gtk_rb_tree_get_root (self->items) == NULL);
|
||||
}
|
||||
|
||||
@@ -1746,11 +1717,6 @@ gtk_list_item_manager_set_model (GtkListItemManager *self,
|
||||
"selection-changed",
|
||||
G_CALLBACK (gtk_list_item_manager_model_selection_changed_cb),
|
||||
self);
|
||||
if (GTK_IS_SECTION_MODEL (model))
|
||||
g_signal_connect (model,
|
||||
"sections-changed",
|
||||
G_CALLBACK (gtk_list_item_manager_model_sections_changed_cb),
|
||||
self);
|
||||
|
||||
gtk_list_item_change_init (&change);
|
||||
gtk_list_item_manager_add_items (self, &change, 0, g_list_model_get_n_items (G_LIST_MODEL (model)));
|
||||
@@ -1809,6 +1775,7 @@ gtk_list_item_manager_set_has_sections (GtkListItemManager *self,
|
||||
footer = tile;
|
||||
break;
|
||||
case GTK_LIST_TILE_ITEM:
|
||||
case GTK_LIST_TILE_FILLER:
|
||||
case GTK_LIST_TILE_REMOVED:
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -51,6 +51,7 @@ typedef enum
|
||||
GTK_LIST_TILE_FOOTER,
|
||||
GTK_LIST_TILE_UNMATCHED_HEADER,
|
||||
GTK_LIST_TILE_UNMATCHED_FOOTER,
|
||||
GTK_LIST_TILE_FILLER,
|
||||
GTK_LIST_TILE_REMOVED,
|
||||
} GtkListTileType;
|
||||
|
||||
@@ -59,7 +60,7 @@ struct _GtkListTile
|
||||
GtkListTileType type;
|
||||
GtkWidget *widget;
|
||||
guint n_items;
|
||||
/* area occupied by tile. May be empty if tile has no allocation */
|
||||
/* area occupied by tile. May be empty if tile has no allcoation */
|
||||
cairo_rectangle_int_t area;
|
||||
};
|
||||
|
||||
@@ -94,19 +95,7 @@ gpointer gtk_list_item_manager_get_nth (GtkListItemMana
|
||||
GtkListTile * gtk_list_item_manager_get_nearest_tile (GtkListItemManager *self,
|
||||
int x,
|
||||
int y);
|
||||
void gtk_list_item_manager_gc_tiles (GtkListItemManager *self);
|
||||
|
||||
static inline gboolean
|
||||
gtk_list_tile_is_header (GtkListTile *tile)
|
||||
{
|
||||
return tile->type == GTK_LIST_TILE_HEADER || tile->type == GTK_LIST_TILE_UNMATCHED_HEADER;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
gtk_list_tile_is_footer (GtkListTile *tile)
|
||||
{
|
||||
return tile->type == GTK_LIST_TILE_FOOTER || tile->type == GTK_LIST_TILE_UNMATCHED_FOOTER;
|
||||
}
|
||||
|
||||
guint gtk_list_tile_get_position (GtkListItemManager *self,
|
||||
GtkListTile *tile);
|
||||
@@ -127,6 +116,10 @@ void gtk_list_tile_set_area_size (GtkListItemMana
|
||||
GtkListTile * gtk_list_tile_split (GtkListItemManager *self,
|
||||
GtkListTile *tile,
|
||||
guint n_items);
|
||||
GtkListTile * gtk_list_tile_append_filler (GtkListItemManager *self,
|
||||
GtkListTile *previous);
|
||||
GtkListTile * gtk_list_tile_gc (GtkListItemManager *self,
|
||||
GtkListTile *tile);
|
||||
|
||||
void gtk_list_item_manager_set_model (GtkListItemManager *self,
|
||||
GtkSelectionModel *model);
|
||||
|
||||
+3
-7
@@ -235,6 +235,7 @@ gtk_list_view_update_factories_with (GtkListView *self,
|
||||
case GTK_LIST_TILE_UNMATCHED_HEADER:
|
||||
case GTK_LIST_TILE_FOOTER:
|
||||
case GTK_LIST_TILE_UNMATCHED_FOOTER:
|
||||
case GTK_LIST_TILE_FILLER:
|
||||
case GTK_LIST_TILE_REMOVED:
|
||||
g_assert (tile->widget == NULL);
|
||||
break;
|
||||
@@ -608,10 +609,8 @@ gtk_list_view_size_allocate (GtkWidget *widget,
|
||||
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);
|
||||
|
||||
gtk_list_item_manager_gc_tiles (self->item_manager);
|
||||
|
||||
/* step 0: exit early if list is empty */
|
||||
tile = gtk_list_item_manager_get_first (self->item_manager);
|
||||
tile = gtk_list_tile_gc (self->item_manager, gtk_list_item_manager_get_first (self->item_manager));
|
||||
if (tile == NULL)
|
||||
{
|
||||
gtk_list_base_allocate (GTK_LIST_BASE (self));
|
||||
@@ -633,7 +632,7 @@ gtk_list_view_size_allocate (GtkWidget *widget,
|
||||
|
||||
for (;
|
||||
tile != NULL;
|
||||
tile = gtk_rb_tree_node_get_next (tile))
|
||||
tile = gtk_list_tile_gc (self->item_manager, gtk_rb_tree_node_get_next (tile)))
|
||||
{
|
||||
if (tile->widget == NULL)
|
||||
continue;
|
||||
@@ -727,9 +726,6 @@ gtk_list_view_dispose (GObject *object)
|
||||
|
||||
self->item_manager = NULL;
|
||||
|
||||
g_clear_object (&self->factory);
|
||||
g_clear_object (&self->header_factory);
|
||||
|
||||
G_OBJECT_CLASS (gtk_list_view_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,11 +42,12 @@ BOOLEAN:OBJECT,OBJECT,OBJECT
|
||||
BOOLEAN:STRING
|
||||
BOOLEAN:UINT,UINT,FLAGS
|
||||
BOOLEAN:VOID
|
||||
FLAGS:OBJECT,DOUBLE,DOUBLE
|
||||
ENUM:OBJECT,DOUBLE,DOUBLE
|
||||
FLAGS:DOUBLE,DOUBLE
|
||||
INT:INT
|
||||
INT:OBJECT,OBJECT,POINTER
|
||||
INT:POINTER
|
||||
OBJECT:BOOLEAN
|
||||
OBJECT:DOUBLE,DOUBLE
|
||||
OBJECT:OBJECT
|
||||
OBJECT:VOID
|
||||
|
||||
+1
-1
@@ -1554,7 +1554,7 @@ gtk_menu_button_get_child (GtkMenuButton *menu_button)
|
||||
* @menu_button: a `GtkMenuButton`
|
||||
* @active: whether the menu button is active
|
||||
*
|
||||
* Sets whether the menu button is active.
|
||||
* Sets whether menu button acts is active.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
|
||||
@@ -664,7 +664,7 @@ gtk_menu_section_box_new_section (GtkMenuTrackerItem *item,
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (box->item_box), GTK_ORIENTATION_HORIZONTAL);
|
||||
gtk_widget_add_css_class (GTK_WIDGET (box->item_box), "inline-buttons");
|
||||
|
||||
spacer = gtk_gizmo_new ("none", NULL, NULL, NULL,NULL, NULL, NULL);
|
||||
spacer = gtk_builtin_icon_new ("none");
|
||||
gtk_box_append (GTK_BOX (box->item_box), spacer);
|
||||
gtk_size_group_add_widget (box->indicators, spacer);
|
||||
|
||||
|
||||
@@ -291,17 +291,6 @@ gtk_multi_selection_items_changed_cb (GListModel *model,
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_N_ITEMS]);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_multi_selection_sections_changed_cb (GtkSectionModel *model,
|
||||
unsigned int position,
|
||||
unsigned int n_items,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkMultiSelection *self = GTK_MULTI_SELECTION (user_data);
|
||||
|
||||
gtk_section_model_sections_changed (GTK_SECTION_MODEL (self), position, n_items);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_multi_selection_clear_model (GtkMultiSelection *self)
|
||||
{
|
||||
@@ -311,9 +300,6 @@ gtk_multi_selection_clear_model (GtkMultiSelection *self)
|
||||
g_signal_handlers_disconnect_by_func (self->model,
|
||||
gtk_multi_selection_items_changed_cb,
|
||||
self);
|
||||
g_signal_handlers_disconnect_by_func (self->model,
|
||||
gtk_multi_selection_sections_changed_cb,
|
||||
self);
|
||||
g_clear_object (&self->model);
|
||||
}
|
||||
|
||||
@@ -504,9 +490,6 @@ gtk_multi_selection_set_model (GtkMultiSelection *self,
|
||||
"items-changed",
|
||||
G_CALLBACK (gtk_multi_selection_items_changed_cb),
|
||||
self);
|
||||
if (GTK_IS_SECTION_MODEL (self->model))
|
||||
g_signal_connect (self->model, "sections-changed",
|
||||
G_CALLBACK (gtk_multi_selection_sections_changed_cb), self);
|
||||
gtk_multi_selection_items_changed_cb (self->model,
|
||||
0,
|
||||
n_items_before,
|
||||
|
||||
+1
-20
@@ -33,8 +33,6 @@
|
||||
*
|
||||
* This model is meant to be used as a simple wrapper around a `GListModel`
|
||||
* when a `GtkSelectionModel` is required.
|
||||
*
|
||||
* `GtkNoSelection` passes through sections from the underlying model.
|
||||
*/
|
||||
struct _GtkNoSelection
|
||||
{
|
||||
@@ -154,29 +152,15 @@ gtk_no_selection_items_changed_cb (GListModel *model,
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_N_ITEMS]);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_no_selection_sections_changed_cb (GtkSectionModel *model,
|
||||
unsigned int position,
|
||||
unsigned int n_items,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkNoSelection *self = GTK_NO_SELECTION (user_data);
|
||||
|
||||
gtk_section_model_sections_changed (GTK_SECTION_MODEL (self), position, n_items);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_no_selection_clear_model (GtkNoSelection *self)
|
||||
{
|
||||
if (self->model == NULL)
|
||||
return;
|
||||
|
||||
g_signal_handlers_disconnect_by_func (self->model,
|
||||
g_signal_handlers_disconnect_by_func (self->model,
|
||||
gtk_no_selection_items_changed_cb,
|
||||
self);
|
||||
g_signal_handlers_disconnect_by_func (self->model,
|
||||
gtk_no_selection_sections_changed_cb,
|
||||
self);
|
||||
g_clear_object (&self->model);
|
||||
}
|
||||
|
||||
@@ -361,9 +345,6 @@ gtk_no_selection_set_model (GtkNoSelection *self,
|
||||
self->model = g_object_ref (model);
|
||||
g_signal_connect (self->model, "items-changed",
|
||||
G_CALLBACK (gtk_no_selection_items_changed_cb), self);
|
||||
if (GTK_IS_SECTION_MODEL (self->model))
|
||||
g_signal_connect (self->model, "sections-changed",
|
||||
G_CALLBACK (gtk_no_selection_sections_changed_cb), self);
|
||||
n_items_after = g_list_model_get_n_items (self->model);
|
||||
}
|
||||
else
|
||||
|
||||
+8
-9
@@ -483,7 +483,6 @@ create_popup_layout (GtkPopover *popover)
|
||||
GdkPopupLayout *layout;
|
||||
GtkCssStyle *style;
|
||||
GtkBorder shadow_width;
|
||||
gboolean ltr = gtk_widget_get_direction (GTK_WIDGET (popover)) != GTK_TEXT_DIR_RTL;
|
||||
|
||||
compute_surface_pointing_to (popover, &rect);
|
||||
|
||||
@@ -546,13 +545,13 @@ create_popup_layout (GtkPopover *popover)
|
||||
switch (gtk_widget_get_halign (GTK_WIDGET (popover)))
|
||||
{
|
||||
case GTK_ALIGN_START:
|
||||
parent_anchor = ltr ? GDK_GRAVITY_NORTH_WEST : GDK_GRAVITY_NORTH_EAST;
|
||||
surface_anchor = ltr ? GDK_GRAVITY_SOUTH_WEST : GDK_GRAVITY_SOUTH_EAST;
|
||||
parent_anchor = GDK_GRAVITY_NORTH_WEST;
|
||||
surface_anchor = GDK_GRAVITY_SOUTH_WEST;
|
||||
break;
|
||||
|
||||
case GTK_ALIGN_END:
|
||||
parent_anchor = ltr ? GDK_GRAVITY_NORTH_EAST : GDK_GRAVITY_NORTH_WEST;
|
||||
surface_anchor = ltr ? GDK_GRAVITY_SOUTH_EAST : GDK_GRAVITY_SOUTH_WEST;
|
||||
parent_anchor = GDK_GRAVITY_NORTH_EAST;
|
||||
surface_anchor = GDK_GRAVITY_SOUTH_EAST;
|
||||
break;
|
||||
|
||||
case GTK_ALIGN_FILL:
|
||||
@@ -571,13 +570,13 @@ create_popup_layout (GtkPopover *popover)
|
||||
switch (gtk_widget_get_halign (GTK_WIDGET (popover)))
|
||||
{
|
||||
case GTK_ALIGN_START:
|
||||
parent_anchor = ltr ? GDK_GRAVITY_SOUTH_WEST : GDK_GRAVITY_SOUTH_EAST;
|
||||
surface_anchor = ltr ? GDK_GRAVITY_NORTH_WEST : GDK_GRAVITY_NORTH_EAST;
|
||||
parent_anchor = GDK_GRAVITY_SOUTH_WEST;
|
||||
surface_anchor = GDK_GRAVITY_NORTH_WEST;
|
||||
break;
|
||||
|
||||
case GTK_ALIGN_END:
|
||||
parent_anchor = ltr ? GDK_GRAVITY_SOUTH_EAST : GDK_GRAVITY_SOUTH_WEST;
|
||||
surface_anchor = ltr ? GDK_GRAVITY_NORTH_EAST : GDK_GRAVITY_NORTH_WEST;
|
||||
parent_anchor = GDK_GRAVITY_SOUTH_EAST;
|
||||
surface_anchor = GDK_GRAVITY_NORTH_EAST;
|
||||
break;
|
||||
|
||||
case GTK_ALIGN_FILL:
|
||||
|
||||
@@ -1431,7 +1431,6 @@ gtk_recent_manager_clamp_to_age (GtkRecentManager *manager,
|
||||
}
|
||||
|
||||
g_strfreev (uris);
|
||||
g_date_time_unref (now);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2181,16 +2180,13 @@ gtk_recent_info_get_uri_display (GtkRecentInfo *info)
|
||||
int
|
||||
gtk_recent_info_get_age (GtkRecentInfo *info)
|
||||
{
|
||||
int diff;
|
||||
GDateTime *now;
|
||||
|
||||
g_return_val_if_fail (info != NULL, -1);
|
||||
|
||||
now = g_date_time_new_now_utc ();
|
||||
diff = (int) (g_date_time_difference (now, info->modified) / (double)G_TIME_SPAN_DAY);
|
||||
|
||||
g_date_time_unref (now);
|
||||
return diff;
|
||||
return (int) (g_date_time_difference (now, info->modified) / (double)G_TIME_SPAN_DAY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-31
@@ -1750,38 +1750,8 @@ gtk_scrolled_window_measure (GtkWidget *widget,
|
||||
if (priv->child && gtk_widget_get_visible (priv->child))
|
||||
{
|
||||
int min_child_size, nat_child_size;
|
||||
int child_for_size = -1;
|
||||
|
||||
/* We can pass on the requested size if we have a scrollbar policy that prevents scrolling in that direction */
|
||||
if ((orientation == GTK_ORIENTATION_VERTICAL && priv->hscrollbar_policy == GTK_POLICY_NEVER)
|
||||
|| (orientation == GTK_ORIENTATION_HORIZONTAL && priv->vscrollbar_policy == GTK_POLICY_NEVER))
|
||||
{
|
||||
child_for_size = for_size;
|
||||
|
||||
/* If the other scrollbar is always visible and not an overlay scrollbar we must subtract it from the measure */
|
||||
if (orientation == GTK_ORIENTATION_VERTICAL && !priv->use_indicators && priv->vscrollbar_policy == GTK_POLICY_ALWAYS)
|
||||
{
|
||||
int min_scrollbar_width;
|
||||
|
||||
gtk_widget_measure (priv->vscrollbar, GTK_ORIENTATION_HORIZONTAL, -1,
|
||||
&min_scrollbar_width, NULL,
|
||||
NULL, NULL);
|
||||
|
||||
child_for_size = MAX (0, child_for_size - min_scrollbar_width);
|
||||
}
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL && !priv->use_indicators && priv->hscrollbar_policy == GTK_POLICY_ALWAYS)
|
||||
{
|
||||
int min_scrollbar_height;
|
||||
|
||||
gtk_widget_measure (priv->hscrollbar, GTK_ORIENTATION_VERTICAL, -1,
|
||||
&min_scrollbar_height, NULL,
|
||||
NULL, NULL);
|
||||
|
||||
child_for_size = MAX (0, child_for_size - min_scrollbar_height);
|
||||
}
|
||||
}
|
||||
|
||||
gtk_widget_measure (priv->child, orientation, child_for_size,
|
||||
gtk_widget_measure (priv->child, orientation, -1,
|
||||
&min_child_size, &nat_child_size,
|
||||
NULL, NULL);
|
||||
|
||||
|
||||
+12
-11
@@ -26,19 +26,21 @@
|
||||
/**
|
||||
* GtkSectionModel:
|
||||
*
|
||||
* `GtkSectionModel` is an interface that adds support for sections to list models.
|
||||
* `GtkSectionModel` is an interface that adds support for section to list models.
|
||||
*
|
||||
* A `GtkSectionModel` groups successive items into so-called sections. List widgets
|
||||
* like `GtkListView` and `GtkGridView` then allow displaying section headers for
|
||||
* these sections by installing a header factory.
|
||||
* This support is then used by widgets using list models to be able to group their
|
||||
* items into sections.
|
||||
*
|
||||
* Many GTK list models support sections inherently, or they pass through the sections
|
||||
* of a model they are wrapping.
|
||||
*
|
||||
* When the section groupings of a model change, the model will emit the
|
||||
* A `GtkSectionModel` groups successive items into so-called sections. List widgets
|
||||
* like `GtkListView` then allow displaying section headers for these sections.
|
||||
*
|
||||
* When the section groupings of a model changes, the model will emit the
|
||||
* [signal@Gtk.SectionModel::sections-changed] signal by calling the
|
||||
* [method@Gtk.SectionModel.sections_changed] function. All sections in the given range
|
||||
* then need to be queried again.
|
||||
* now need to be queried again.
|
||||
* The [signal@Gio.ListModel::items-changed] signal has the same effect, all sections in
|
||||
* that range are invalidated, too.
|
||||
*
|
||||
@@ -194,11 +196,10 @@ gtk_list_model_get_section (GListModel *self,
|
||||
* @n_items: the number of changed items
|
||||
*
|
||||
* This function emits the [signal@Gtk.SectionModel::section-changed]
|
||||
* signal to notify about changes to sections.
|
||||
*
|
||||
* It must cover all positions that used to be a section start or that
|
||||
* are now a section start. It does not have to cover all positions for
|
||||
* which the section has changed.
|
||||
* signal to notify about changes to sections. It must cover all
|
||||
* positions that used to be a section start or that are now a section
|
||||
* start. It does not have to cover all positions for which the section
|
||||
* has changed.
|
||||
*
|
||||
* The [signal@Gio.ListModel::items-changed] implies the effect of the
|
||||
* [signal@Gtk.SectionModel::section-changed] signal for all the items
|
||||
|
||||
@@ -300,29 +300,15 @@ gtk_single_selection_items_changed_cb (GListModel *model,
|
||||
g_object_thaw_notify (G_OBJECT (self));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_single_selection_sections_changed_cb (GtkSectionModel *model,
|
||||
unsigned int position,
|
||||
unsigned int n_items,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkSingleSelection *self = GTK_SINGLE_SELECTION (user_data);
|
||||
|
||||
gtk_section_model_sections_changed (GTK_SECTION_MODEL (self), position, n_items);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_single_selection_clear_model (GtkSingleSelection *self)
|
||||
{
|
||||
if (self->model == NULL)
|
||||
return;
|
||||
|
||||
g_signal_handlers_disconnect_by_func (self->model,
|
||||
g_signal_handlers_disconnect_by_func (self->model,
|
||||
gtk_single_selection_items_changed_cb,
|
||||
self);
|
||||
g_signal_handlers_disconnect_by_func (self->model,
|
||||
gtk_single_selection_sections_changed_cb,
|
||||
self);
|
||||
g_clear_object (&self->model);
|
||||
}
|
||||
|
||||
@@ -572,7 +558,7 @@ gtk_single_selection_set_model (GtkSingleSelection *self,
|
||||
return;
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (self));
|
||||
|
||||
|
||||
n_items_before = self->model ? g_list_model_get_n_items (self->model) : 0;
|
||||
gtk_single_selection_clear_model (self);
|
||||
|
||||
@@ -581,9 +567,6 @@ gtk_single_selection_set_model (GtkSingleSelection *self,
|
||||
self->model = g_object_ref (model);
|
||||
g_signal_connect (self->model, "items-changed",
|
||||
G_CALLBACK (gtk_single_selection_items_changed_cb), self);
|
||||
if (GTK_IS_SECTION_MODEL (self->model))
|
||||
g_signal_connect (self->model, "sections-changed",
|
||||
G_CALLBACK (gtk_single_selection_sections_changed_cb), self);
|
||||
gtk_single_selection_items_changed_cb (self->model,
|
||||
0,
|
||||
n_items_before,
|
||||
|
||||
+3
-69
@@ -20,7 +20,6 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkslicelistmodel.h"
|
||||
#include "gtksectionmodelprivate.h"
|
||||
|
||||
#include "gtkprivate.h"
|
||||
|
||||
@@ -32,8 +31,6 @@
|
||||
* This is useful when implementing paging by setting the size to the number
|
||||
* of elements per page and updating the offset whenever a different page is
|
||||
* opened.
|
||||
*
|
||||
* `GtkSliceListModel` passes through sections from the underlying model.
|
||||
*/
|
||||
|
||||
#define DEFAULT_SIZE 10
|
||||
@@ -55,6 +52,8 @@ struct _GtkSliceListModel
|
||||
GListModel *model;
|
||||
guint offset;
|
||||
guint size;
|
||||
|
||||
guint n_items;
|
||||
};
|
||||
|
||||
struct _GtkSliceListModelClass
|
||||
@@ -112,69 +111,8 @@ gtk_slice_list_model_model_init (GListModelInterface *iface)
|
||||
iface->get_item = gtk_slice_list_model_get_item;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_slice_list_model_get_section (GtkSectionModel *model,
|
||||
guint position,
|
||||
guint *start,
|
||||
guint *end)
|
||||
{
|
||||
GtkSliceListModel *self = GTK_SLICE_LIST_MODEL (model);
|
||||
unsigned int n_items;
|
||||
|
||||
n_items = g_list_model_get_n_items (G_LIST_MODEL (self));
|
||||
if (position >= n_items)
|
||||
{
|
||||
*start = n_items;
|
||||
*end = G_MAXUINT;
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_list_model_get_section (self->model, position + self->offset, start, end);
|
||||
|
||||
*start = MAX (*start, self->offset) - self->offset;
|
||||
*end = MIN (*end - self->offset, n_items);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_slice_list_model_sections_changed_cb (GtkSectionModel *model,
|
||||
unsigned int position,
|
||||
unsigned int n_items,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkSliceListModel *self = GTK_SLICE_LIST_MODEL (user_data);
|
||||
unsigned int start = position;
|
||||
unsigned int end = position + n_items;
|
||||
unsigned int size;
|
||||
|
||||
if (end <= self->offset)
|
||||
return;
|
||||
|
||||
size = g_list_model_get_n_items (G_LIST_MODEL (self));
|
||||
|
||||
end = MIN (end - self->offset, size);
|
||||
|
||||
if (start <= self->offset)
|
||||
start = 0;
|
||||
else
|
||||
start = start - self->offset;
|
||||
|
||||
if (start >= size)
|
||||
return;
|
||||
|
||||
gtk_section_model_sections_changed (GTK_SECTION_MODEL (self), start, end - start);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_slice_list_model_section_model_init (GtkSectionModelInterface *iface)
|
||||
{
|
||||
iface->get_section = gtk_slice_list_model_get_section;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkSliceListModel, gtk_slice_list_model, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, gtk_slice_list_model_model_init)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_SECTION_MODEL, gtk_slice_list_model_section_model_init))
|
||||
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, gtk_slice_list_model_model_init))
|
||||
|
||||
static void
|
||||
gtk_slice_list_model_items_changed_cb (GListModel *model,
|
||||
@@ -300,7 +238,6 @@ gtk_slice_list_model_clear_model (GtkSliceListModel *self)
|
||||
if (self->model == NULL)
|
||||
return;
|
||||
|
||||
g_signal_handlers_disconnect_by_func (self->model, gtk_slice_list_model_sections_changed_cb, self);
|
||||
g_signal_handlers_disconnect_by_func (self->model, gtk_slice_list_model_items_changed_cb, self);
|
||||
g_clear_object (&self->model);
|
||||
}
|
||||
@@ -450,9 +387,6 @@ gtk_slice_list_model_set_model (GtkSliceListModel *self,
|
||||
self->model = g_object_ref (model);
|
||||
g_signal_connect (model, "items-changed", G_CALLBACK (gtk_slice_list_model_items_changed_cb), self);
|
||||
added = g_list_model_get_n_items (G_LIST_MODEL (self));
|
||||
|
||||
if (GTK_IS_SECTION_MODEL (model))
|
||||
g_signal_connect (model, "sections-changed", G_CALLBACK (gtk_slice_list_model_sections_changed_cb), self);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+19
-36
@@ -873,10 +873,9 @@ gtk_sort_list_model_get_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_sort_list_model_sorter_changed (GtkSorter *sorter,
|
||||
int change,
|
||||
GtkSortListModel *self,
|
||||
gboolean sections_changed)
|
||||
gtk_sort_list_model_sorter_changed_cb (GtkSorter *sorter,
|
||||
int change,
|
||||
GtkSortListModel *self)
|
||||
{
|
||||
guint pos, n_items;
|
||||
|
||||
@@ -913,12 +912,6 @@ gtk_sort_list_model_sorter_changed (GtkSorter *sorter,
|
||||
}
|
||||
}
|
||||
|
||||
if (self->section_sorter)
|
||||
{
|
||||
gtk_sort_keys_unref (self->section_sort_keys);
|
||||
self->section_sort_keys = gtk_sorter_get_keys (self->section_sorter);
|
||||
}
|
||||
|
||||
if (gtk_sort_list_model_start_sorting (self, NULL))
|
||||
pos = n_items = 0;
|
||||
else
|
||||
@@ -929,25 +922,8 @@ gtk_sort_list_model_sorter_changed (GtkSorter *sorter,
|
||||
gtk_sort_list_model_clear_items (self, &pos, &n_items);
|
||||
}
|
||||
|
||||
if (sections_changed && self->n_items > 0)
|
||||
{
|
||||
if (n_items > 0)
|
||||
g_list_model_items_changed (G_LIST_MODEL (self), 0, self->n_items, self->n_items);
|
||||
else
|
||||
gtk_section_model_sections_changed (GTK_SECTION_MODEL (self), 0, self->n_items);
|
||||
}
|
||||
else if (n_items > 0)
|
||||
{
|
||||
g_list_model_items_changed (G_LIST_MODEL (self), pos, n_items, n_items);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_sort_list_model_sorter_changed_cb (GtkSorter *sorter,
|
||||
int change,
|
||||
GtkSortListModel *self)
|
||||
{
|
||||
gtk_sort_list_model_sorter_changed (sorter, change, self, FALSE);
|
||||
if (n_items > 0)
|
||||
g_list_model_items_changed (G_LIST_MODEL (self), pos, n_items, n_items);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -973,8 +949,7 @@ gtk_sort_list_model_clear_real_sorter (GtkSortListModel *self)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_sort_list_model_ensure_real_sorter (GtkSortListModel *self,
|
||||
gboolean sections_changed)
|
||||
gtk_sort_list_model_ensure_real_sorter (GtkSortListModel *self)
|
||||
{
|
||||
if (self->sorter)
|
||||
{
|
||||
@@ -999,7 +974,7 @@ gtk_sort_list_model_ensure_real_sorter (GtkSortListModel *self,
|
||||
if (self->real_sorter)
|
||||
g_signal_connect (self->real_sorter, "changed", G_CALLBACK (gtk_sort_list_model_sorter_changed_cb), self);
|
||||
|
||||
gtk_sort_list_model_sorter_changed (self->real_sorter, GTK_SORTER_CHANGE_DIFFERENT, self, sections_changed);
|
||||
gtk_sort_list_model_sorter_changed_cb (self->real_sorter, GTK_SORTER_CHANGE_DIFFERENT, self);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1220,8 +1195,12 @@ gtk_sort_list_model_set_sorter (GtkSortListModel *self,
|
||||
return;
|
||||
|
||||
gtk_sort_list_model_clear_real_sorter (self);
|
||||
g_set_object (&self->sorter, sorter);
|
||||
gtk_sort_list_model_ensure_real_sorter (self, FALSE);
|
||||
g_clear_object (&self->sorter);
|
||||
|
||||
if (sorter)
|
||||
self->sorter = g_object_ref (sorter);
|
||||
|
||||
gtk_sort_list_model_ensure_real_sorter (self);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SORTER]);
|
||||
}
|
||||
@@ -1262,8 +1241,12 @@ gtk_sort_list_model_set_section_sorter (GtkSortListModel *self,
|
||||
return;
|
||||
|
||||
gtk_sort_list_model_clear_real_sorter (self);
|
||||
g_set_object (&self->section_sorter, sorter);
|
||||
gtk_sort_list_model_ensure_real_sorter (self, TRUE);
|
||||
g_clear_object (&self->section_sorter);
|
||||
|
||||
if (sorter)
|
||||
self->section_sorter = g_object_ref (sorter);
|
||||
|
||||
gtk_sort_list_model_ensure_real_sorter (self);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SECTION_SORTER]);
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "gtkmain.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtknative.h"
|
||||
#include "gtkpopover.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkrenderbackgroundprivate.h"
|
||||
#include "gtkrenderborderprivate.h"
|
||||
|
||||
+1
-1
@@ -1195,7 +1195,7 @@ if build_gir
|
||||
gdk_gir_inc = [ 'cairo-1.0', 'Gio-2.0', 'GdkPixbuf-2.0', 'Pango-1.0', 'PangoCairo-1.0' ]
|
||||
|
||||
gdk_gir = gnome.generate_gir(libgtk,
|
||||
sources: gdk_public_headers + gdk_deprecated_headers + gdk_public_sources + gdk_deprecated_sources + [ gdkenum_h ],
|
||||
sources: gdk_public_headers + gdk_public_sources + [ gdkenum_h ],
|
||||
namespace: 'Gdk',
|
||||
nsversion: gtk_api_version,
|
||||
identifier_prefix: 'Gdk',
|
||||
|
||||
@@ -4543,7 +4543,7 @@ void *convert_run_optimize(void *c, uint8_t typecode_original,
|
||||
|
||||
int long_ctr = 0;
|
||||
uint64_t cur_word = c_qua_bitset->array[0];
|
||||
G_GNUC_UNUSED int run_count = 0;
|
||||
int run_count = 0;
|
||||
while (true) {
|
||||
while (cur_word == UINT64_C(0) &&
|
||||
long_ctr < BITSET_CONTAINER_SIZE_IN_WORDS - 1)
|
||||
|
||||
@@ -96,9 +96,9 @@ struct _GtkCupsRequest
|
||||
char *password;
|
||||
char *username;
|
||||
|
||||
unsigned int own_http : 1;
|
||||
unsigned int need_password : 1;
|
||||
unsigned int need_auth_info : 1;
|
||||
int own_http : 1;
|
||||
int need_password : 1;
|
||||
int need_auth_info : 1;
|
||||
char **auth_info_required;
|
||||
char **auth_info;
|
||||
GtkCupsPasswordState password_state;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
gtk_tests = [
|
||||
# testname, optional extra sources
|
||||
['testsections'],
|
||||
['testfilelauncher'],
|
||||
['input'],
|
||||
['testpopup'],
|
||||
|
||||
@@ -1,389 +0,0 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void
|
||||
setup_item (GtkSignalListItemFactory *self,
|
||||
GObject *object)
|
||||
{
|
||||
GtkListItem *list_item = GTK_LIST_ITEM (object);
|
||||
GtkWidget *child = gtk_label_new ("");
|
||||
|
||||
gtk_label_set_xalign (GTK_LABEL (child), 0);
|
||||
gtk_list_item_set_child (list_item, child);
|
||||
}
|
||||
|
||||
static void
|
||||
bind_item (GtkSignalListItemFactory *self,
|
||||
GObject *object)
|
||||
{
|
||||
GtkListItem *list_item = GTK_LIST_ITEM (object);
|
||||
GObject *item = gtk_list_item_get_item (list_item);
|
||||
GtkWidget *child = gtk_list_item_get_child (list_item);
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (child),
|
||||
gtk_string_object_get_string (GTK_STRING_OBJECT (item)));
|
||||
}
|
||||
|
||||
static char *
|
||||
reverse_word (const char *word)
|
||||
{
|
||||
GString *s = g_string_new ("");
|
||||
const char *p;
|
||||
gunichar c;
|
||||
gboolean capitalize;
|
||||
|
||||
capitalize = g_unichar_isupper (g_utf8_get_char (word));
|
||||
|
||||
p = word + strlen (word);
|
||||
while ((p = g_utf8_find_prev_char (word, p)) != NULL)
|
||||
{
|
||||
c = g_utf8_get_char (p);
|
||||
|
||||
if (s->len == 0 && capitalize)
|
||||
c = g_unichar_toupper (c);
|
||||
else
|
||||
c = g_unichar_tolower (c);
|
||||
|
||||
g_string_append_unichar (s, c);
|
||||
}
|
||||
|
||||
return g_string_free (s, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
bind_item_reverse (GtkSignalListItemFactory *self,
|
||||
GObject *object)
|
||||
{
|
||||
GtkListItem *list_item = GTK_LIST_ITEM (object);
|
||||
GObject *item = gtk_list_item_get_item (list_item);
|
||||
GtkWidget *child = gtk_list_item_get_child (list_item);
|
||||
char *word;
|
||||
|
||||
word = reverse_word (gtk_string_object_get_string (GTK_STRING_OBJECT (item)));
|
||||
gtk_label_set_label (GTK_LABEL (child), word);
|
||||
g_free (word);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_header (GtkSignalListItemFactory *self,
|
||||
GObject *object)
|
||||
{
|
||||
GtkListHeader *header = GTK_LIST_HEADER (object);
|
||||
GtkWidget *child = gtk_label_new ("");
|
||||
|
||||
gtk_label_set_xalign (GTK_LABEL (child), 0);
|
||||
gtk_list_header_set_child (header, child);
|
||||
}
|
||||
|
||||
static char *
|
||||
get_first (GObject *this)
|
||||
{
|
||||
const char *s = gtk_string_object_get_string (GTK_STRING_OBJECT (this));
|
||||
char buffer[6] = { 0, };
|
||||
|
||||
g_unichar_to_utf8 (g_unichar_toupper (g_utf8_get_char (s)), buffer);
|
||||
|
||||
return g_strdup (buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
bind_header (GtkSignalListItemFactory *self,
|
||||
GObject *object)
|
||||
{
|
||||
GtkListHeader *header = GTK_LIST_HEADER (object);
|
||||
GObject *item = gtk_list_header_get_item (header);
|
||||
GtkWidget *child = gtk_list_header_get_child (header);
|
||||
PangoAttrList *attrs;
|
||||
char *string;
|
||||
|
||||
string = get_first (item);
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (child), string);
|
||||
attrs = pango_attr_list_new ();
|
||||
pango_attr_list_insert (attrs, pango_attr_scale_new (PANGO_SCALE_X_LARGE));
|
||||
pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
|
||||
gtk_label_set_attributes (GTK_LABEL (child), attrs);
|
||||
pango_attr_list_unref (attrs);
|
||||
g_free (string);
|
||||
}
|
||||
|
||||
static const char *strings[] = {
|
||||
"Alpha", "Andromeda", "Anaphylaxis", "Anaheim", "Beer", "Branch", "Botulism", "Banana",
|
||||
"Bee", "Crane", "Caldera", "Copper", "Crowd", "Dora", "Dolphin", "Dam", "Ding",
|
||||
NULL,
|
||||
};
|
||||
|
||||
gboolean done_reading = FALSE;
|
||||
|
||||
static gboolean
|
||||
dump_sections (gpointer data)
|
||||
{
|
||||
GtkSectionModel *model = data;
|
||||
|
||||
if (!done_reading)
|
||||
return G_SOURCE_CONTINUE;
|
||||
|
||||
for (unsigned int i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (model)); i++)
|
||||
{
|
||||
unsigned int s, e;
|
||||
gtk_section_model_get_section (model, i, &s, &e);
|
||||
g_print ("(%u %u)\n", s, e - 1);
|
||||
i = e;
|
||||
}
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
read_lines_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
GBufferedInputStream *stream = G_BUFFERED_INPUT_STREAM (object);
|
||||
GtkStringList *stringlist = data;
|
||||
GError *error = NULL;
|
||||
gsize size;
|
||||
GPtrArray *lines;
|
||||
gssize n_filled;
|
||||
const char *buffer, *newline;
|
||||
|
||||
n_filled = g_buffered_input_stream_fill_finish (stream, result, &error);
|
||||
if (n_filled < 0)
|
||||
{
|
||||
g_print ("Could not read data: %s\n", error->message);
|
||||
g_clear_error (&error);
|
||||
g_object_unref (stringlist);
|
||||
return;
|
||||
}
|
||||
|
||||
buffer = g_buffered_input_stream_peek_buffer (stream, &size);
|
||||
|
||||
if (n_filled == 0)
|
||||
{
|
||||
if (size)
|
||||
gtk_string_list_take (stringlist, g_utf8_make_valid (buffer, size));
|
||||
g_object_unref (stringlist);
|
||||
done_reading = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
lines = NULL;
|
||||
while ((newline = memchr (buffer, '\n', size)))
|
||||
{
|
||||
if (newline > buffer)
|
||||
{
|
||||
if (lines == NULL)
|
||||
lines = g_ptr_array_new_with_free_func (g_free);
|
||||
g_ptr_array_add (lines, g_utf8_make_valid (buffer, newline - buffer));
|
||||
}
|
||||
if (g_input_stream_skip (G_INPUT_STREAM (stream), newline - buffer + 1, NULL, &error) < 0)
|
||||
{
|
||||
g_clear_error (&error);
|
||||
break;
|
||||
}
|
||||
buffer = g_buffered_input_stream_peek_buffer (stream, &size);
|
||||
}
|
||||
if (lines == NULL)
|
||||
{
|
||||
g_buffered_input_stream_set_buffer_size (stream, g_buffered_input_stream_get_buffer_size (stream) + 4096);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_ptr_array_add (lines, NULL);
|
||||
gtk_string_list_splice (stringlist, g_list_model_get_n_items (G_LIST_MODEL (stringlist)), 0, (const char **) lines->pdata);
|
||||
g_ptr_array_free (lines, TRUE);
|
||||
}
|
||||
|
||||
g_buffered_input_stream_fill_async (stream, -1, G_PRIORITY_HIGH_IDLE, NULL, read_lines_cb, data);
|
||||
}
|
||||
|
||||
static void
|
||||
file_is_open_cb (GObject *file,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GFileInputStream *file_stream;
|
||||
GBufferedInputStream *stream;
|
||||
|
||||
file_stream = g_file_read_finish (G_FILE (file), result, &error);
|
||||
if (file_stream == NULL)
|
||||
{
|
||||
g_print ("Could not open file: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
g_object_unref (data);
|
||||
return;
|
||||
}
|
||||
|
||||
stream = G_BUFFERED_INPUT_STREAM (g_buffered_input_stream_new (G_INPUT_STREAM (file_stream)));
|
||||
g_buffered_input_stream_fill_async (stream, -1, G_PRIORITY_HIGH_IDLE, NULL, read_lines_cb, data);
|
||||
g_object_unref (stream);
|
||||
}
|
||||
|
||||
static void
|
||||
load_file (GtkStringList *list,
|
||||
GFile *file)
|
||||
{
|
||||
gtk_string_list_splice (list, 0, g_list_model_get_n_items (G_LIST_MODEL (list)), NULL);
|
||||
g_file_read_async (file, G_PRIORITY_HIGH_IDLE, NULL, file_is_open_cb, g_object_ref (list));
|
||||
}
|
||||
|
||||
static void
|
||||
toggle_cb (GtkCheckButton *check, GtkWidget *list)
|
||||
{
|
||||
GtkListItemFactory *header_factory = NULL;
|
||||
|
||||
if (gtk_check_button_get_active (check))
|
||||
{
|
||||
header_factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (header_factory, "setup", G_CALLBACK (setup_header), NULL);
|
||||
g_signal_connect (header_factory, "bind", G_CALLBACK (bind_header), NULL);
|
||||
}
|
||||
|
||||
g_object_set (list, "header-factory", header_factory, NULL);
|
||||
|
||||
g_clear_object (&header_factory);
|
||||
}
|
||||
|
||||
static void
|
||||
value_changed_cb (GtkAdjustment *adj, gpointer data)
|
||||
{
|
||||
g_print ("horizontal adjustment changed to %f\n", gtk_adjustment_get_value (adj));
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *sw;
|
||||
GtkWidget *lv;
|
||||
GtkWidget *gv;
|
||||
GtkWidget *cv;
|
||||
GtkWidget *header;
|
||||
GtkWidget *toggle;
|
||||
GtkWidget *switcher;
|
||||
GtkWidget *stack;
|
||||
GtkListItemFactory *factory;
|
||||
GtkExpression *expression;
|
||||
GtkSortListModel *sortmodel;
|
||||
GtkSelectionModel *selection;
|
||||
GtkStringList *stringlist;
|
||||
GtkAdjustment *adj;
|
||||
GtkColumnViewColumn *column;
|
||||
|
||||
stringlist = gtk_string_list_new (NULL);
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
GFile *file = g_file_new_for_commandline_arg (argv[1]);
|
||||
load_file (stringlist, file);
|
||||
g_object_unref (file);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; strings[i]; i++)
|
||||
gtk_string_list_append (stringlist, strings[i]);
|
||||
done_reading = TRUE;
|
||||
}
|
||||
|
||||
gtk_init ();
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
|
||||
toggle = gtk_check_button_new ();
|
||||
gtk_widget_set_valign (toggle, GTK_ALIGN_CENTER);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), toggle);
|
||||
|
||||
stack = gtk_stack_new ();
|
||||
gtk_window_set_child (GTK_WINDOW (window), stack);
|
||||
|
||||
switcher = gtk_stack_switcher_new ();
|
||||
gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header), switcher);
|
||||
|
||||
gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (stack));
|
||||
|
||||
expression = gtk_property_expression_new (GTK_TYPE_STRING_OBJECT, NULL, "string");
|
||||
sortmodel = gtk_sort_list_model_new (G_LIST_MODEL (stringlist),
|
||||
GTK_SORTER (gtk_string_sorter_new (expression)));
|
||||
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 0, NULL, (GCallback) get_first, NULL, NULL);
|
||||
gtk_sort_list_model_set_section_sorter (sortmodel, GTK_SORTER (gtk_string_sorter_new (expression)));
|
||||
selection = GTK_SELECTION_MODEL (gtk_no_selection_new (G_LIST_MODEL (sortmodel)));
|
||||
|
||||
/* list */
|
||||
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_stack_add_titled (GTK_STACK (stack), sw, "list", "List");
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_item), NULL);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (bind_item), NULL);
|
||||
|
||||
lv = gtk_list_view_new (g_object_ref (selection), factory);
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), lv);
|
||||
|
||||
g_signal_connect (toggle, "toggled", G_CALLBACK (toggle_cb), lv);
|
||||
|
||||
/* grid */
|
||||
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_stack_add_titled (GTK_STACK (stack), sw, "grid", "Grid");
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_item), NULL);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (bind_item), NULL);
|
||||
|
||||
gv = gtk_grid_view_new (g_object_ref (selection), factory);
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), gv);
|
||||
|
||||
g_signal_connect (toggle, "toggled", G_CALLBACK (toggle_cb), gv);
|
||||
|
||||
gtk_grid_view_set_min_columns (GTK_GRID_VIEW (gv), 5);
|
||||
|
||||
adj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (sw));
|
||||
g_signal_connect (adj, "value-changed", G_CALLBACK (value_changed_cb), NULL);
|
||||
|
||||
/* columns */
|
||||
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_stack_add_titled (GTK_STACK (stack), sw, "columns", "Columns");
|
||||
|
||||
cv = gtk_column_view_new (g_object_ref (selection));
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), cv);
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_item), NULL);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (bind_item), NULL);
|
||||
|
||||
column = gtk_column_view_column_new ("Word", factory);
|
||||
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
|
||||
gtk_column_view_column_set_expand (column, TRUE);
|
||||
gtk_column_view_column_set_resizable (column, TRUE);
|
||||
g_object_unref (column);
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_item), NULL);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (bind_item_reverse), NULL);
|
||||
|
||||
column = gtk_column_view_column_new ("Reverse", factory);
|
||||
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
|
||||
gtk_column_view_column_set_expand (column, TRUE);
|
||||
gtk_column_view_column_set_resizable (column, TRUE);
|
||||
g_object_unref (column);
|
||||
|
||||
g_signal_connect (toggle, "toggled", G_CALLBACK (toggle_cb), cv);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
|
||||
g_timeout_add (500, dump_sections, selection);
|
||||
|
||||
while (g_list_model_get_n_items (gtk_window_get_toplevels ()) > 0)
|
||||
g_main_context_iteration (NULL, FALSE);
|
||||
|
||||
g_object_unref (selection);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Bitmask tests.
|
||||
/* GtkRBTree tests.
|
||||
*
|
||||
* Copyright (C) 2011, Red Hat, Inc.
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Bitset tests.
|
||||
/* GtkRBTree tests.
|
||||
*
|
||||
* Copyright (C) 2011, Red Hat, Inc.
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Filter tests.
|
||||
/* GtkRBTree tests.
|
||||
*
|
||||
* Copyright (C) 2011, Red Hat, Inc.
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Filterlistmodel tests.
|
||||
/* GtkRBTree tests.
|
||||
*
|
||||
* Copyright (C) 2011, Red Hat, Inc.
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
@@ -478,17 +478,6 @@ filter_func (gpointer item,
|
||||
return s[0] == s[1];
|
||||
}
|
||||
|
||||
static void
|
||||
sections_changed (GtkSectionModel *model,
|
||||
unsigned int start,
|
||||
unsigned int end,
|
||||
gpointer user_data)
|
||||
{
|
||||
gboolean *got_it = user_data;
|
||||
|
||||
*got_it = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
test_sections (void)
|
||||
{
|
||||
@@ -510,7 +499,6 @@ test_sections (void)
|
||||
guint s, e;
|
||||
GtkFilterListModel *filtered;
|
||||
GtkFilter *filter;
|
||||
gboolean got_it = FALSE;
|
||||
|
||||
list = gtk_string_list_new (strings);
|
||||
sorter = GTK_SORTER (gtk_string_sorter_new (gtk_property_expression_new (GTK_TYPE_STRING_OBJECT, NULL, "string")));
|
||||
@@ -553,10 +541,6 @@ test_sections (void)
|
||||
g_assert_cmpint (s, ==, 3);
|
||||
g_assert_cmpint (e, ==, 4);
|
||||
|
||||
g_signal_connect (filtered, "sections-changed", G_CALLBACK (sections_changed), &got_it);
|
||||
gtk_sort_list_model_set_section_sorter (GTK_SORT_LIST_MODEL (sorted), NULL);
|
||||
g_assert_true (got_it);
|
||||
|
||||
g_object_unref (filtered);
|
||||
g_object_unref (sorted);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Flattenlistmodel tests.
|
||||
/* GtkRBTree tests.
|
||||
*
|
||||
* Copyright (C) 2011, Red Hat, Inc.
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
|
||||
+23
-123
@@ -20,7 +20,6 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include "gtk/gtklistitemmanagerprivate.h"
|
||||
#include "gtk/gtklistbaseprivate.h"
|
||||
#include "gtk/gtkgridviewprivate.h"
|
||||
|
||||
static GListModel *
|
||||
create_source_model (guint min_size, guint max_size)
|
||||
@@ -72,6 +71,9 @@ print_list_item_manager_tiles (GtkListItemManager *items)
|
||||
g_string_append_c (string, ')');
|
||||
break;
|
||||
|
||||
case GTK_LIST_TILE_FILLER:
|
||||
g_string_append_c (string, '_');
|
||||
break;
|
||||
case GTK_LIST_TILE_REMOVED:
|
||||
g_string_append_c (string, '.');
|
||||
break;
|
||||
@@ -101,7 +103,6 @@ check_list_item_manager (GtkListItemManager *items,
|
||||
MATCHED_SECTION,
|
||||
UNMATCHED_SECTION
|
||||
} section_state = NO_SECTION;
|
||||
gboolean after_items = FALSE;
|
||||
|
||||
has_sections = gtk_list_item_manager_get_has_sections (items);
|
||||
|
||||
@@ -117,32 +118,28 @@ check_list_item_manager (GtkListItemManager *items,
|
||||
g_assert_true (has_sections);
|
||||
g_assert_true (tile->widget);
|
||||
section_state = MATCHED_SECTION;
|
||||
after_items = FALSE;
|
||||
break;
|
||||
|
||||
case GTK_LIST_TILE_UNMATCHED_HEADER:
|
||||
g_assert_cmpint (section_state, ==, NO_SECTION);
|
||||
g_assert_cmpint (tile->n_items, ==, 0);
|
||||
g_assert_null (tile->widget);
|
||||
g_assert_false (tile->widget);
|
||||
section_state = UNMATCHED_SECTION;
|
||||
after_items = FALSE;
|
||||
break;
|
||||
|
||||
case GTK_LIST_TILE_FOOTER:
|
||||
g_assert_cmpint (section_state, ==, MATCHED_SECTION);
|
||||
g_assert_cmpint (tile->n_items, ==, 0);
|
||||
g_assert_true (has_sections);
|
||||
g_assert_null (tile->widget);
|
||||
g_assert_false (tile->widget);
|
||||
section_state = NO_SECTION;
|
||||
after_items = FALSE;
|
||||
break;
|
||||
|
||||
case GTK_LIST_TILE_UNMATCHED_FOOTER:
|
||||
g_assert_cmpint (section_state, ==, UNMATCHED_SECTION);
|
||||
g_assert_cmpint (tile->n_items, ==, 0);
|
||||
g_assert_null (tile->widget);
|
||||
g_assert_false (tile->widget);
|
||||
section_state = NO_SECTION;
|
||||
after_items = FALSE;
|
||||
break;
|
||||
|
||||
case GTK_LIST_TILE_ITEM:
|
||||
@@ -158,19 +155,19 @@ check_list_item_manager (GtkListItemManager *items,
|
||||
g_object_unref (item);
|
||||
g_assert_cmpint (n_items, ==, gtk_list_item_base_get_position (GTK_LIST_ITEM_BASE (tile->widget)));
|
||||
g_assert_cmpint (tile->n_items, ==, 1);
|
||||
after_items = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
after_items = TRUE;
|
||||
}
|
||||
if (tile->n_items)
|
||||
n_items += tile->n_items;
|
||||
break;
|
||||
|
||||
case GTK_LIST_TILE_FILLER:
|
||||
/* We don't add fillers */
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
|
||||
case GTK_LIST_TILE_REMOVED:
|
||||
g_assert_cmpint (tile->n_items, ==, 0);
|
||||
g_assert_null (tile->widget);
|
||||
g_assert_false (tile->widget);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -195,7 +192,10 @@ check_list_item_manager (GtkListItemManager *items,
|
||||
g_assert_true (tile->widget);
|
||||
}
|
||||
|
||||
gtk_list_item_manager_gc_tiles (items);
|
||||
for (tile = gtk_list_tile_gc (items, gtk_list_item_manager_get_first (items));
|
||||
tile != NULL;
|
||||
tile = gtk_list_tile_gc (items, gtk_rb_tree_node_get_next (tile)))
|
||||
;
|
||||
|
||||
n_items = 0;
|
||||
|
||||
@@ -211,7 +211,6 @@ check_list_item_manager (GtkListItemManager *items,
|
||||
g_assert_true (has_sections);
|
||||
g_assert_true (tile->widget);
|
||||
section_state = MATCHED_SECTION;
|
||||
after_items = FALSE;
|
||||
break;
|
||||
|
||||
case GTK_LIST_TILE_UNMATCHED_HEADER:
|
||||
@@ -219,7 +218,6 @@ check_list_item_manager (GtkListItemManager *items,
|
||||
g_assert_cmpint (tile->n_items, ==, 0);
|
||||
g_assert_false (tile->widget);
|
||||
section_state = UNMATCHED_SECTION;
|
||||
after_items = FALSE;
|
||||
break;
|
||||
|
||||
case GTK_LIST_TILE_FOOTER:
|
||||
@@ -228,7 +226,6 @@ check_list_item_manager (GtkListItemManager *items,
|
||||
g_assert_true (has_sections);
|
||||
g_assert_false (tile->widget);
|
||||
section_state = NO_SECTION;
|
||||
after_items = FALSE;
|
||||
break;
|
||||
|
||||
case GTK_LIST_TILE_UNMATCHED_FOOTER:
|
||||
@@ -236,7 +233,6 @@ check_list_item_manager (GtkListItemManager *items,
|
||||
g_assert_cmpint (tile->n_items, ==, 0);
|
||||
g_assert_false (tile->widget);
|
||||
section_state = NO_SECTION;
|
||||
after_items = FALSE;
|
||||
break;
|
||||
|
||||
case GTK_LIST_TILE_ITEM:
|
||||
@@ -244,17 +240,12 @@ check_list_item_manager (GtkListItemManager *items,
|
||||
if (tile->widget)
|
||||
{
|
||||
g_assert_cmpint (tile->n_items, ==, 1);
|
||||
after_items = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_assert_false (after_items);
|
||||
after_items = TRUE;
|
||||
}
|
||||
if (tile->n_items)
|
||||
n_items += tile->n_items;
|
||||
break;
|
||||
|
||||
case GTK_LIST_TILE_FILLER:
|
||||
case GTK_LIST_TILE_REMOVED:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
@@ -374,78 +365,8 @@ print_changes_cb (GListModel *model,
|
||||
g_test_message ("%u/%u: removing %u and adding %u items", position, g_list_model_get_n_items (model), removed, added);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_footer (GtkListTile *tile)
|
||||
{
|
||||
if (tile == NULL)
|
||||
return FALSE;
|
||||
|
||||
return tile->type == GTK_LIST_TILE_FOOTER ||
|
||||
tile->type == GTK_LIST_TILE_UNMATCHED_FOOTER;
|
||||
}
|
||||
|
||||
static void
|
||||
check_tile_invariants_for_columns (GtkListItemManager *items,
|
||||
unsigned int n_columns)
|
||||
{
|
||||
GtkListTile *tile;
|
||||
|
||||
for (tile = gtk_list_item_manager_get_first (items);
|
||||
tile != NULL;
|
||||
tile = gtk_rb_tree_node_get_next (tile))
|
||||
{
|
||||
g_assert (tile->type != GTK_LIST_TILE_REMOVED);
|
||||
if (tile->n_items > 1)
|
||||
{
|
||||
unsigned int pos, col, col2;
|
||||
gboolean before_footer;
|
||||
|
||||
pos = gtk_list_tile_get_position (items, tile);
|
||||
col = gtk_grid_view_get_column_for_position (items, n_columns, pos);
|
||||
col2 = gtk_grid_view_get_column_for_position (items, n_columns, pos + tile->n_items - 1);
|
||||
before_footer = is_footer (gtk_rb_tree_node_get_next (tile));
|
||||
|
||||
if (gtk_grid_view_is_multirow_tile (items, n_columns, tile))
|
||||
{
|
||||
g_assert_true (col == 0);
|
||||
g_assert_true (col2 == n_columns - 1 || before_footer);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_assert_true (col2 == col + tile->n_items - 1);
|
||||
g_assert_true (col2 <= n_columns);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
check_grid_view (GtkListItemManager *items)
|
||||
{
|
||||
for (unsigned int n_columns = 1; n_columns < 10; n_columns++)
|
||||
{
|
||||
if (g_test_verbose ())
|
||||
g_test_message ("GC");
|
||||
|
||||
gtk_list_item_manager_gc_tiles (items);
|
||||
|
||||
if (g_test_verbose ())
|
||||
print_list_item_manager_tiles (items);
|
||||
|
||||
if (g_test_verbose ())
|
||||
g_test_message ("grid split %u columns", n_columns);
|
||||
|
||||
gtk_grid_view_split_tiles_by_columns (items, n_columns);
|
||||
|
||||
if (g_test_verbose ())
|
||||
print_list_item_manager_tiles (items);
|
||||
|
||||
check_tile_invariants_for_columns (items, n_columns);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_exhaustive (gboolean grid)
|
||||
test_exhaustive (void)
|
||||
{
|
||||
GtkListItemTracker *trackers[N_TRACKERS];
|
||||
GListStore *store;
|
||||
@@ -483,14 +404,9 @@ test_exhaustive (gboolean grid)
|
||||
switch (g_test_rand_int_range (0, 6))
|
||||
{
|
||||
case 0:
|
||||
if (grid)
|
||||
check_grid_view (items);
|
||||
else
|
||||
{
|
||||
if (g_test_verbose ())
|
||||
g_test_message ("GC and checking");
|
||||
check_list_item_manager (items, trackers, N_TRACKERS);
|
||||
}
|
||||
if (g_test_verbose ())
|
||||
g_test_message ("GC and checking");
|
||||
check_list_item_manager (items, trackers, N_TRACKERS);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
@@ -560,10 +476,7 @@ test_exhaustive (gboolean grid)
|
||||
}
|
||||
}
|
||||
|
||||
if (grid)
|
||||
check_grid_view (items);
|
||||
else
|
||||
check_list_item_manager (items, trackers, N_TRACKERS);
|
||||
check_list_item_manager (items, trackers, N_TRACKERS);
|
||||
|
||||
for (i = 0; i < N_TRACKERS; i++)
|
||||
gtk_list_item_tracker_free (items, trackers[i]);
|
||||
@@ -571,18 +484,6 @@ test_exhaustive (gboolean grid)
|
||||
gtk_window_destroy (GTK_WINDOW (widget));
|
||||
}
|
||||
|
||||
static void
|
||||
test_exhaustive_list (void)
|
||||
{
|
||||
test_exhaustive (FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
test_exhaustive_grid (void)
|
||||
{
|
||||
test_exhaustive (TRUE);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@@ -590,8 +491,7 @@ main (int argc, char *argv[])
|
||||
|
||||
g_test_add_func ("/listitemmanager/create", test_create);
|
||||
g_test_add_func ("/listitemmanager/create_with_items", test_create_with_items);
|
||||
g_test_add_func ("/listitemmanager/exhaustive", test_exhaustive_list);
|
||||
g_test_add_func ("/gridview/split", test_exhaustive_grid);
|
||||
g_test_add_func ("/listitemmanager/exhaustive", test_exhaustive);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Maplistmodel tests.
|
||||
/* GtkRBTree tests.
|
||||
*
|
||||
* Copyright (C) 2011, Red Hat, Inc.
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
|
||||
+12
-133
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (C) 2019, Red Hat, Inc.
|
||||
* Authors: Matthias Clasen <mclasen@redhat.com>
|
||||
*
|
||||
@@ -52,42 +52,6 @@ model_to_string (GListModel *model)
|
||||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
static char *
|
||||
section_model_to_string (GListModel *model)
|
||||
{
|
||||
GString *string = g_string_new (NULL);
|
||||
guint i, s, e, n;
|
||||
|
||||
if (!GTK_IS_SECTION_MODEL (model))
|
||||
return model_to_string (model);
|
||||
|
||||
n = g_list_model_get_n_items (model);
|
||||
|
||||
i = 0;
|
||||
while (i < n)
|
||||
{
|
||||
gtk_section_model_get_section (GTK_SECTION_MODEL (model), i, &s, &e);
|
||||
|
||||
if (i > 0)
|
||||
g_string_append (string, " ");
|
||||
|
||||
g_string_append (string, "[");
|
||||
|
||||
for (; i < e; i++)
|
||||
{
|
||||
if (i > s)
|
||||
g_string_append (string, " ");
|
||||
|
||||
g_string_append_printf (string, "%u", get (model, i));
|
||||
}
|
||||
|
||||
g_string_append (string, "]");
|
||||
i = e;
|
||||
}
|
||||
|
||||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
static char *
|
||||
selection_to_string (GListModel *model)
|
||||
{
|
||||
@@ -176,14 +140,6 @@ insert (GListStore *store,
|
||||
g_free (s); \
|
||||
}G_STMT_END
|
||||
|
||||
#define assert_section_model(model, expected) G_STMT_START{ \
|
||||
char *s = section_model_to_string (G_LIST_MODEL (model)); \
|
||||
if (!g_str_equal (s, expected)) \
|
||||
g_assertion_message_cmpstr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||
#model " == " #expected, s, "==", expected); \
|
||||
g_free (s); \
|
||||
}G_STMT_END
|
||||
|
||||
#define ignore_changes(model) G_STMT_START{ \
|
||||
GString *changes = g_object_get_qdata (G_OBJECT (model), changes_quark); \
|
||||
g_string_set_size (changes, 0); \
|
||||
@@ -268,20 +224,6 @@ items_changed (GListModel *model,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sections_changed (GListModel *model,
|
||||
guint position,
|
||||
guint n_items,
|
||||
GString *changes)
|
||||
{
|
||||
g_assert_true (n_items != 0);
|
||||
|
||||
if (changes->len)
|
||||
g_string_append (changes, ", ");
|
||||
|
||||
g_string_append_printf (changes, "s%u:%u", position, n_items);
|
||||
}
|
||||
|
||||
static void
|
||||
notify_n_items (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
@@ -314,17 +256,16 @@ free_changes (gpointer data)
|
||||
}
|
||||
|
||||
static GtkSelectionModel *
|
||||
new_model (GListModel *store)
|
||||
new_model (GListStore *store)
|
||||
{
|
||||
GtkSelectionModel *result;
|
||||
GString *changes;
|
||||
|
||||
result = GTK_SELECTION_MODEL (gtk_multi_selection_new (g_object_ref (store)));
|
||||
result = GTK_SELECTION_MODEL (gtk_multi_selection_new (g_object_ref (G_LIST_MODEL (store))));
|
||||
|
||||
changes = g_string_new ("");
|
||||
g_object_set_qdata_full (G_OBJECT (result), changes_quark, changes, free_changes);
|
||||
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
|
||||
g_signal_connect (result, "items-changed", G_CALLBACK (items_changed), changes);
|
||||
g_signal_connect (result, "sections-changed", G_CALLBACK (sections_changed), changes);
|
||||
g_signal_connect (result, "notify::n-items", G_CALLBACK (notify_n_items), changes);
|
||||
|
||||
changes = g_string_new ("");
|
||||
@@ -358,7 +299,7 @@ test_create (void)
|
||||
guint start, end;
|
||||
|
||||
store = new_store (1, 5, 2);
|
||||
selection = new_model (G_LIST_MODEL (store));
|
||||
selection = new_model (store);
|
||||
|
||||
assert_model (selection, "1 3 5");
|
||||
assert_changes (selection, "");
|
||||
@@ -399,7 +340,7 @@ test_changes (void)
|
||||
gboolean ret;
|
||||
|
||||
store = new_store (1, 5, 1);
|
||||
selection = new_model (G_LIST_MODEL (store));
|
||||
selection = new_model (store);
|
||||
assert_model (selection, "1 2 3 4 5");
|
||||
assert_changes (selection, "");
|
||||
assert_selection (selection, "");
|
||||
@@ -446,7 +387,7 @@ test_selection (void)
|
||||
gboolean ret;
|
||||
|
||||
store = new_store (1, 5, 1);
|
||||
selection = new_model (G_LIST_MODEL (store));
|
||||
selection = new_model (store);
|
||||
assert_selection (selection, "");
|
||||
assert_selection_changes (selection, "");
|
||||
|
||||
@@ -501,7 +442,7 @@ test_select_range (void)
|
||||
gboolean ret;
|
||||
|
||||
store = new_store (1, 5, 1);
|
||||
selection = new_model (G_LIST_MODEL (store));
|
||||
selection = new_model (store);
|
||||
assert_selection (selection, "");
|
||||
assert_selection_changes (selection, "");
|
||||
|
||||
@@ -536,7 +477,7 @@ test_readd (void)
|
||||
|
||||
store = new_store (1, 5, 1);
|
||||
|
||||
selection = new_model (G_LIST_MODEL (store));
|
||||
selection = new_model (store);
|
||||
assert_model (selection, "1 2 3 4 5");
|
||||
assert_selection (selection, "");
|
||||
assert_selection_changes (selection, "");
|
||||
@@ -565,7 +506,7 @@ test_set_selection (void)
|
||||
|
||||
store = new_store (1, 10, 1);
|
||||
|
||||
selection = new_model (G_LIST_MODEL (store));
|
||||
selection = new_model (store);
|
||||
assert_model (selection, "1 2 3 4 5 6 7 8 9 10");
|
||||
assert_selection (selection, "");
|
||||
assert_selection_changes (selection, "");
|
||||
@@ -606,7 +547,7 @@ test_selection_filter (void)
|
||||
gboolean ret;
|
||||
|
||||
store = new_store (1, 5, 1);
|
||||
selection = new_model (G_LIST_MODEL (store));
|
||||
selection = new_model (store);
|
||||
assert_selection (selection, "");
|
||||
assert_selection_changes (selection, "");
|
||||
|
||||
@@ -719,7 +660,7 @@ test_set_model (void)
|
||||
store = new_store (1, 5, 1);
|
||||
m1 = G_LIST_MODEL (store);
|
||||
m2 = G_LIST_MODEL (gtk_slice_list_model_new (g_object_ref (m1), 0, 3));
|
||||
selection = new_model (G_LIST_MODEL (store));
|
||||
selection = new_model (store);
|
||||
assert_selection (selection, "");
|
||||
assert_selection_changes (selection, "");
|
||||
|
||||
@@ -801,67 +742,6 @@ test_empty_filter (void)
|
||||
g_object_unref (selection);
|
||||
}
|
||||
|
||||
static int
|
||||
by_n (gconstpointer p1,
|
||||
gconstpointer p2,
|
||||
gpointer data)
|
||||
{
|
||||
guint n1 = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (p1), number_quark));
|
||||
guint n2 = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (p2), number_quark));
|
||||
unsigned int n = GPOINTER_TO_UINT (data);
|
||||
|
||||
n1 = n1 / n;
|
||||
n2 = n2 / n;
|
||||
|
||||
if (n1 < n2)
|
||||
return -1;
|
||||
else if (n1 > n2)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
compare (gconstpointer first,
|
||||
gconstpointer second,
|
||||
gpointer unused)
|
||||
{
|
||||
return GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (first), number_quark))
|
||||
- GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (second), number_quark));
|
||||
}
|
||||
|
||||
static void
|
||||
test_sections (void)
|
||||
{
|
||||
GListStore *store;
|
||||
GtkSortListModel *sorted;
|
||||
GtkSelectionModel *selection;
|
||||
GtkSorter *sorter;
|
||||
|
||||
store = new_store (1, 10, 1);
|
||||
sorted = gtk_sort_list_model_new (G_LIST_MODEL (store),
|
||||
GTK_SORTER (gtk_custom_sorter_new (compare, NULL, NULL)));
|
||||
selection = new_model (G_LIST_MODEL (sorted));
|
||||
assert_model (selection, "1 2 3 4 5 6 7 8 9 10");
|
||||
assert_section_model (selection, "[1 2 3 4 5 6 7 8 9 10]");
|
||||
assert_changes (selection, "");
|
||||
|
||||
sorter = GTK_SORTER (gtk_custom_sorter_new (by_n, GUINT_TO_POINTER (3), NULL));
|
||||
gtk_sort_list_model_set_section_sorter (sorted, sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
assert_section_model (selection, "[1 2] [3 4 5] [6 7 8] [9 10]");
|
||||
assert_changes (selection, "s0:10");
|
||||
|
||||
gtk_section_model_sections_changed (GTK_SECTION_MODEL (sorted), 0, 3);
|
||||
assert_changes (selection, "s0:3");
|
||||
|
||||
gtk_section_model_sections_changed (GTK_SECTION_MODEL (sorted), 5, 3);
|
||||
assert_changes (selection, "s5:3");
|
||||
|
||||
g_object_unref (selection);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@@ -884,7 +764,6 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/multiselection/set-model", test_set_model);
|
||||
g_test_add_func ("/multiselection/empty", test_empty);
|
||||
g_test_add_func ("/multiselection/selection-filter/empty", test_empty_filter);
|
||||
g_test_add_func ("/multiselection/sections", test_sections);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
+8
-129
@@ -52,42 +52,6 @@ model_to_string (GListModel *model)
|
||||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
static char *
|
||||
section_model_to_string (GListModel *model)
|
||||
{
|
||||
GString *string = g_string_new (NULL);
|
||||
guint i, s, e, n;
|
||||
|
||||
if (!GTK_IS_SECTION_MODEL (model))
|
||||
return model_to_string (model);
|
||||
|
||||
n = g_list_model_get_n_items (model);
|
||||
|
||||
i = 0;
|
||||
while (i < n)
|
||||
{
|
||||
gtk_section_model_get_section (GTK_SECTION_MODEL (model), i, &s, &e);
|
||||
|
||||
if (i > 0)
|
||||
g_string_append (string, " ");
|
||||
|
||||
g_string_append (string, "[");
|
||||
|
||||
for (; i < e; i++)
|
||||
{
|
||||
if (i > s)
|
||||
g_string_append (string, " ");
|
||||
|
||||
g_string_append_printf (string, "%u", get (model, i));
|
||||
}
|
||||
|
||||
g_string_append (string, "]");
|
||||
i = e;
|
||||
}
|
||||
|
||||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
static char *
|
||||
selection_to_string (GListModel *model)
|
||||
{
|
||||
@@ -172,14 +136,6 @@ insert (GListStore *store,
|
||||
g_free (s); \
|
||||
}G_STMT_END
|
||||
|
||||
#define assert_section_model(model, expected) G_STMT_START{ \
|
||||
char *s = section_model_to_string (G_LIST_MODEL (model)); \
|
||||
if (!g_str_equal (s, expected)) \
|
||||
g_assertion_message_cmpstr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||
#model " == " #expected, s, "==", expected); \
|
||||
g_free (s); \
|
||||
}G_STMT_END
|
||||
|
||||
#define ignore_changes(model) G_STMT_START{ \
|
||||
GString *changes = g_object_get_qdata (G_OBJECT (model), changes_quark); \
|
||||
g_string_set_size (changes, 0); \
|
||||
@@ -264,20 +220,6 @@ items_changed (GListModel *model,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sections_changed (GListModel *model,
|
||||
guint position,
|
||||
guint n_items,
|
||||
GString *changes)
|
||||
{
|
||||
g_assert_true (n_items != 0);
|
||||
|
||||
if (changes->len)
|
||||
g_string_append (changes, ", ");
|
||||
|
||||
g_string_append_printf (changes, "s%u:%u", position, n_items);
|
||||
}
|
||||
|
||||
static void
|
||||
notify_n_items (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
@@ -310,17 +252,16 @@ free_changes (gpointer data)
|
||||
}
|
||||
|
||||
static GtkSelectionModel *
|
||||
new_model (GListModel *store, gboolean autoselect, gboolean can_unselect)
|
||||
new_model (GListStore *store, gboolean autoselect, gboolean can_unselect)
|
||||
{
|
||||
GtkSelectionModel *result;
|
||||
GString *changes;
|
||||
|
||||
result = GTK_SELECTION_MODEL (gtk_no_selection_new (g_object_ref (store)));
|
||||
result = GTK_SELECTION_MODEL (gtk_no_selection_new (g_object_ref (G_LIST_MODEL (store))));
|
||||
|
||||
changes = g_string_new ("");
|
||||
g_object_set_qdata_full (G_OBJECT (result), changes_quark, changes, free_changes);
|
||||
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
|
||||
g_signal_connect (result, "items-changed", G_CALLBACK (items_changed), changes);
|
||||
g_signal_connect (result, "sections-changed", G_CALLBACK (sections_changed), changes);
|
||||
g_signal_connect (result, "notify::n-items", G_CALLBACK (notify_n_items), changes);
|
||||
|
||||
changes = g_string_new ("");
|
||||
@@ -343,7 +284,7 @@ test_create (void)
|
||||
}
|
||||
|
||||
store = new_store (1, 5, 2);
|
||||
selection = new_model (G_LIST_MODEL (store), FALSE, FALSE);
|
||||
selection = new_model (store, FALSE, FALSE);
|
||||
|
||||
assert_model (selection, "1 3 5");
|
||||
assert_changes (selection, "");
|
||||
@@ -384,7 +325,7 @@ test_changes (void)
|
||||
}
|
||||
|
||||
store = new_store (1, 5, 1);
|
||||
selection = new_model (G_LIST_MODEL (store), FALSE, FALSE);
|
||||
selection = new_model (store, FALSE, FALSE);
|
||||
assert_model (selection, "1 2 3 4 5");
|
||||
assert_changes (selection, "");
|
||||
assert_selection (selection, "");
|
||||
@@ -426,7 +367,7 @@ test_selection (void)
|
||||
}
|
||||
|
||||
store = new_store (1, 5, 1);
|
||||
selection = new_model (G_LIST_MODEL (store), TRUE, FALSE);
|
||||
selection = new_model (store, TRUE, FALSE);
|
||||
assert_selection (selection, "");
|
||||
assert_selection_changes (selection, "");
|
||||
|
||||
@@ -503,7 +444,7 @@ test_query_range (void)
|
||||
GListStore *store;
|
||||
|
||||
store = new_store (1, 5, 1);
|
||||
selection = new_model (G_LIST_MODEL (store), TRUE, TRUE);
|
||||
selection = new_model (store, TRUE, TRUE);
|
||||
check_get_selection (selection);
|
||||
|
||||
gtk_selection_model_unselect_item (selection, 0);
|
||||
@@ -531,7 +472,7 @@ test_set_model (void)
|
||||
store = new_store (1, 5, 1);
|
||||
m1 = G_LIST_MODEL (store);
|
||||
m2 = G_LIST_MODEL (gtk_slice_list_model_new (g_object_ref (m1), 0, 3));
|
||||
selection = new_model (G_LIST_MODEL (store), TRUE, TRUE);
|
||||
selection = new_model (store, TRUE, TRUE);
|
||||
assert_selection (selection, "");
|
||||
assert_selection_changes (selection, "");
|
||||
|
||||
@@ -590,67 +531,6 @@ test_empty (void)
|
||||
g_object_unref (selection);
|
||||
}
|
||||
|
||||
static int
|
||||
by_n (gconstpointer p1,
|
||||
gconstpointer p2,
|
||||
gpointer data)
|
||||
{
|
||||
guint n1 = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (p1), number_quark));
|
||||
guint n2 = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (p2), number_quark));
|
||||
unsigned int n = GPOINTER_TO_UINT (data);
|
||||
|
||||
n1 = n1 / n;
|
||||
n2 = n2 / n;
|
||||
|
||||
if (n1 < n2)
|
||||
return -1;
|
||||
else if (n1 > n2)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
compare (gconstpointer first,
|
||||
gconstpointer second,
|
||||
gpointer unused)
|
||||
{
|
||||
return GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (first), number_quark))
|
||||
- GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (second), number_quark));
|
||||
}
|
||||
|
||||
static void
|
||||
test_sections (void)
|
||||
{
|
||||
GListStore *store;
|
||||
GtkSortListModel *sorted;
|
||||
GtkSelectionModel *selection;
|
||||
GtkSorter *sorter;
|
||||
|
||||
store = new_store (1, 10, 1);
|
||||
sorted = gtk_sort_list_model_new (G_LIST_MODEL (store),
|
||||
GTK_SORTER (gtk_custom_sorter_new (compare, NULL, NULL)));
|
||||
selection = new_model (G_LIST_MODEL (sorted), TRUE, TRUE);
|
||||
assert_model (selection, "1 2 3 4 5 6 7 8 9 10");
|
||||
assert_section_model (selection, "[1 2 3 4 5 6 7 8 9 10]");
|
||||
assert_changes (selection, "");
|
||||
|
||||
sorter = GTK_SORTER (gtk_custom_sorter_new (by_n, GUINT_TO_POINTER (3), NULL));
|
||||
gtk_sort_list_model_set_section_sorter (sorted, sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
assert_section_model (selection, "[1 2] [3 4 5] [6 7 8] [9 10]");
|
||||
assert_changes (selection, "s0:10");
|
||||
|
||||
gtk_section_model_sections_changed (GTK_SECTION_MODEL (sorted), 0, 3);
|
||||
assert_changes (selection, "s0:3");
|
||||
|
||||
gtk_section_model_sections_changed (GTK_SECTION_MODEL (sorted), 5, 3);
|
||||
assert_changes (selection, "s5:3");
|
||||
|
||||
g_object_unref (selection);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@@ -668,7 +548,6 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/noselection/changes", test_changes);
|
||||
g_test_add_func ("/noselection/set-model", test_set_model);
|
||||
g_test_add_func ("/noselection/empty", test_empty);
|
||||
g_test_add_func ("/noselection/sections", test_sections);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Propertylookupmodel tests.
|
||||
/* GtkRBTree tests.
|
||||
*
|
||||
* Copyright (C) 2011, Red Hat, Inc.
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
|
||||
+12
-133
@@ -52,42 +52,6 @@ model_to_string (GListModel *model)
|
||||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
static char *
|
||||
section_model_to_string (GListModel *model)
|
||||
{
|
||||
GString *string = g_string_new (NULL);
|
||||
guint i, s, e, n;
|
||||
|
||||
if (!GTK_IS_SECTION_MODEL (model))
|
||||
return model_to_string (model);
|
||||
|
||||
n = g_list_model_get_n_items (model);
|
||||
|
||||
i = 0;
|
||||
while (i < n)
|
||||
{
|
||||
gtk_section_model_get_section (GTK_SECTION_MODEL (model), i, &s, &e);
|
||||
|
||||
if (i > 0)
|
||||
g_string_append (string, " ");
|
||||
|
||||
g_string_append (string, "[");
|
||||
|
||||
for (; i < e; i++)
|
||||
{
|
||||
if (i > s)
|
||||
g_string_append (string, " ");
|
||||
|
||||
g_string_append_printf (string, "%u", get (model, i));
|
||||
}
|
||||
|
||||
g_string_append (string, "]");
|
||||
i = e;
|
||||
}
|
||||
|
||||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
static char *
|
||||
selection_to_string (GListModel *model)
|
||||
{
|
||||
@@ -172,14 +136,6 @@ insert (GListStore *store,
|
||||
g_free (s); \
|
||||
}G_STMT_END
|
||||
|
||||
#define assert_section_model(model, expected) G_STMT_START{ \
|
||||
char *s = section_model_to_string (G_LIST_MODEL (model)); \
|
||||
if (!g_str_equal (s, expected)) \
|
||||
g_assertion_message_cmpstr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||
#model " == " #expected, s, "==", expected); \
|
||||
g_free (s); \
|
||||
}G_STMT_END
|
||||
|
||||
#define ignore_changes(model) G_STMT_START{ \
|
||||
GString *changes = g_object_get_qdata (G_OBJECT (model), changes_quark); \
|
||||
g_string_set_size (changes, 0); \
|
||||
@@ -264,20 +220,6 @@ items_changed (GListModel *model,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sections_changed (GListModel *model,
|
||||
guint position,
|
||||
guint n_items,
|
||||
GString *changes)
|
||||
{
|
||||
g_assert_true (n_items != 0);
|
||||
|
||||
if (changes->len)
|
||||
g_string_append (changes, ", ");
|
||||
|
||||
g_string_append_printf (changes, "s%u:%u", position, n_items);
|
||||
}
|
||||
|
||||
static void
|
||||
notify_n_items (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
@@ -310,12 +252,12 @@ free_changes (gpointer data)
|
||||
}
|
||||
|
||||
static GtkSelectionModel *
|
||||
new_model (GListModel *store, gboolean autoselect, gboolean can_unselect)
|
||||
new_model (GListStore *store, gboolean autoselect, gboolean can_unselect)
|
||||
{
|
||||
GtkSelectionModel *result;
|
||||
GString *changes;
|
||||
|
||||
result = GTK_SELECTION_MODEL (gtk_single_selection_new (g_object_ref (store)));
|
||||
result = GTK_SELECTION_MODEL (gtk_single_selection_new (g_object_ref (G_LIST_MODEL (store))));
|
||||
|
||||
/* We want to return an empty selection unless autoselect is true,
|
||||
* so undo the initial selection due to autoselect defaulting to TRUE.
|
||||
@@ -329,9 +271,8 @@ new_model (GListModel *store, gboolean autoselect, gboolean can_unselect)
|
||||
gtk_single_selection_set_can_unselect (GTK_SINGLE_SELECTION (result), can_unselect);
|
||||
|
||||
changes = g_string_new ("");
|
||||
g_object_set_qdata_full (G_OBJECT (result), changes_quark, changes, free_changes);
|
||||
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
|
||||
g_signal_connect (result, "items-changed", G_CALLBACK (items_changed), changes);
|
||||
g_signal_connect (result, "sections-changed", G_CALLBACK (sections_changed), changes);
|
||||
g_signal_connect (result, "notify::n-items", G_CALLBACK (notify_n_items), changes);
|
||||
|
||||
changes = g_string_new ("");
|
||||
@@ -355,7 +296,7 @@ test_create (void)
|
||||
}
|
||||
|
||||
store = new_store (1, 5, 2);
|
||||
selection = new_model (G_LIST_MODEL (store), FALSE, FALSE);
|
||||
selection = new_model (store, FALSE, FALSE);
|
||||
g_assert_false (gtk_single_selection_get_autoselect (GTK_SINGLE_SELECTION (selection)));
|
||||
|
||||
assert_model (selection, "1 3 5");
|
||||
@@ -403,7 +344,7 @@ test_changes (void)
|
||||
}
|
||||
|
||||
store = new_store (1, 5, 1);
|
||||
selection = new_model (G_LIST_MODEL (store), FALSE, FALSE);
|
||||
selection = new_model (store, FALSE, FALSE);
|
||||
assert_model (selection, "1 2 3 4 5");
|
||||
assert_changes (selection, "");
|
||||
assert_selection (selection, "");
|
||||
@@ -445,7 +386,7 @@ test_selection (void)
|
||||
}
|
||||
|
||||
store = new_store (1, 5, 1);
|
||||
selection = new_model (G_LIST_MODEL (store), TRUE, FALSE);
|
||||
selection = new_model (store, TRUE, FALSE);
|
||||
assert_selection (selection, "1");
|
||||
assert_selection_changes (selection, "");
|
||||
|
||||
@@ -501,7 +442,7 @@ test_autoselect (void)
|
||||
}
|
||||
|
||||
store = new_empty_store ();
|
||||
selection = new_model (G_LIST_MODEL (store), TRUE, FALSE);
|
||||
selection = new_model (store, TRUE, FALSE);
|
||||
assert_model (selection, "");
|
||||
assert_changes (selection, "");
|
||||
assert_selection (selection, "");
|
||||
@@ -572,7 +513,7 @@ test_autoselect_toggle (void)
|
||||
}
|
||||
|
||||
store = new_store (1, 1, 1);
|
||||
selection = new_model (G_LIST_MODEL (store), TRUE, TRUE);
|
||||
selection = new_model (store, TRUE, TRUE);
|
||||
assert_model (selection, "1");
|
||||
assert_changes (selection, "");
|
||||
assert_selection (selection, "1");
|
||||
@@ -614,7 +555,7 @@ test_can_unselect (void)
|
||||
}
|
||||
|
||||
store = new_store (1, 5, 1);
|
||||
selection = new_model (G_LIST_MODEL (store), TRUE, FALSE);
|
||||
selection = new_model (store, TRUE, FALSE);
|
||||
assert_selection (selection, "1");
|
||||
assert_selection_changes (selection, "");
|
||||
|
||||
@@ -659,7 +600,7 @@ test_persistence (void)
|
||||
}
|
||||
|
||||
store = new_store (1, 5, 1);
|
||||
selection = new_model (G_LIST_MODEL (store), TRUE, FALSE);
|
||||
selection = new_model (store, TRUE, FALSE);
|
||||
assert_selection (selection, "1");
|
||||
assert_selection_changes (selection, "");
|
||||
g_assert_true (gtk_selection_model_is_selected (selection, 0));
|
||||
@@ -712,7 +653,7 @@ test_query_range (void)
|
||||
GListStore *store;
|
||||
|
||||
store = new_store (1, 5, 1);
|
||||
selection = new_model (G_LIST_MODEL (store), TRUE, TRUE);
|
||||
selection = new_model (store, TRUE, TRUE);
|
||||
check_get_selection (selection);
|
||||
|
||||
gtk_selection_model_unselect_item (selection, 0);
|
||||
@@ -740,7 +681,7 @@ test_set_model (void)
|
||||
store = new_store (1, 5, 1);
|
||||
m1 = G_LIST_MODEL (store);
|
||||
m2 = G_LIST_MODEL (gtk_slice_list_model_new (g_object_ref (m1), 0, 3));
|
||||
selection = new_model (G_LIST_MODEL (store), TRUE, TRUE);
|
||||
selection = new_model (store, TRUE, TRUE);
|
||||
assert_selection (selection, "1");
|
||||
assert_selection_changes (selection, "");
|
||||
|
||||
@@ -802,67 +743,6 @@ test_empty (void)
|
||||
g_object_unref (selection);
|
||||
}
|
||||
|
||||
static int
|
||||
by_n (gconstpointer p1,
|
||||
gconstpointer p2,
|
||||
gpointer data)
|
||||
{
|
||||
guint n1 = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (p1), number_quark));
|
||||
guint n2 = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (p2), number_quark));
|
||||
unsigned int n = GPOINTER_TO_UINT (data);
|
||||
|
||||
n1 = n1 / n;
|
||||
n2 = n2 / n;
|
||||
|
||||
if (n1 < n2)
|
||||
return -1;
|
||||
else if (n1 > n2)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
compare (gconstpointer first,
|
||||
gconstpointer second,
|
||||
gpointer unused)
|
||||
{
|
||||
return GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (first), number_quark))
|
||||
- GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (second), number_quark));
|
||||
}
|
||||
|
||||
static void
|
||||
test_sections (void)
|
||||
{
|
||||
GListStore *store;
|
||||
GtkSortListModel *sorted;
|
||||
GtkSelectionModel *selection;
|
||||
GtkSorter *sorter;
|
||||
|
||||
store = new_store (1, 10, 1);
|
||||
sorted = gtk_sort_list_model_new (G_LIST_MODEL (store),
|
||||
GTK_SORTER (gtk_custom_sorter_new (compare, NULL, NULL)));
|
||||
selection = new_model (G_LIST_MODEL (sorted), TRUE, TRUE);
|
||||
assert_model (selection, "1 2 3 4 5 6 7 8 9 10");
|
||||
assert_section_model (selection, "[1 2 3 4 5 6 7 8 9 10]");
|
||||
assert_changes (selection, "");
|
||||
|
||||
sorter = GTK_SORTER (gtk_custom_sorter_new (by_n, GUINT_TO_POINTER (3), NULL));
|
||||
gtk_sort_list_model_set_section_sorter (sorted, sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
assert_section_model (selection, "[1 2] [3 4 5] [6 7 8] [9 10]");
|
||||
assert_changes (selection, "s0:10");
|
||||
|
||||
gtk_section_model_sections_changed (GTK_SECTION_MODEL (sorted), 0, 3);
|
||||
assert_changes (selection, "s0:3");
|
||||
|
||||
gtk_section_model_sections_changed (GTK_SECTION_MODEL (sorted), 5, 3);
|
||||
assert_changes (selection, "s5:3");
|
||||
|
||||
g_object_unref (selection);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@@ -884,7 +764,6 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/singleselection/changes", test_changes);
|
||||
g_test_add_func ("/singleselection/set-model", test_set_model);
|
||||
g_test_add_func ("/singleselection/empty", test_empty);
|
||||
g_test_add_func ("/singleselection/sections", test_sections);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
@@ -51,41 +51,6 @@ model_to_string (GListModel *model)
|
||||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
static char *
|
||||
section_model_to_string (GListModel *model)
|
||||
{
|
||||
GString *string = g_string_new (NULL);
|
||||
guint i, s, e;
|
||||
|
||||
if (!GTK_IS_SECTION_MODEL (model))
|
||||
return model_to_string (model);
|
||||
|
||||
i = 0;
|
||||
while (i < g_list_model_get_n_items (model))
|
||||
{
|
||||
gtk_section_model_get_section (GTK_SECTION_MODEL (model), i, &s, &e);
|
||||
g_assert (s == i);
|
||||
|
||||
if (i > 0)
|
||||
g_string_append (string, " ");
|
||||
|
||||
g_string_append (string, "[");
|
||||
|
||||
for (; i < e; i++)
|
||||
{
|
||||
if (i > s)
|
||||
g_string_append (string, " ");
|
||||
|
||||
g_string_append_printf (string, "%u", get (model, i));
|
||||
}
|
||||
|
||||
g_string_append (string, "]");
|
||||
i = e;
|
||||
}
|
||||
|
||||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
static GListStore *
|
||||
new_store (guint start,
|
||||
guint end,
|
||||
@@ -151,14 +116,6 @@ insert (GListStore *store,
|
||||
g_free (s); \
|
||||
}G_STMT_END
|
||||
|
||||
#define assert_section_model(model, expected) G_STMT_START{ \
|
||||
char *s = section_model_to_string (G_LIST_MODEL (model)); \
|
||||
if (!g_str_equal (s, expected)) \
|
||||
g_assertion_message_cmpstr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||
#model " == " #expected, s, "==", expected); \
|
||||
g_free (s); \
|
||||
}G_STMT_END
|
||||
|
||||
#define assert_changes(model, expected) G_STMT_START{ \
|
||||
GString *changes = g_object_get_qdata (G_OBJECT (model), changes_quark); \
|
||||
if (!g_str_equal (changes->str, expected)) \
|
||||
@@ -217,20 +174,6 @@ items_changed (GListModel *model,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sections_changed (GListModel *model,
|
||||
guint position,
|
||||
guint n_items,
|
||||
GString *changes)
|
||||
{
|
||||
g_assert_true (n_items != 0);
|
||||
|
||||
if (changes->len)
|
||||
g_string_append (changes, ", ");
|
||||
|
||||
g_string_append_printf (changes, "s%u:%u", position, n_items);
|
||||
}
|
||||
|
||||
static void
|
||||
notify_n_items (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
@@ -251,19 +194,18 @@ free_changes (gpointer data)
|
||||
}
|
||||
|
||||
static GtkSliceListModel *
|
||||
new_model (GListModel *store, guint offset, guint size)
|
||||
new_model (GListStore *store, guint offset, guint size)
|
||||
{
|
||||
GtkSliceListModel *result;
|
||||
GString *changes;
|
||||
|
||||
if (store)
|
||||
g_object_ref (store);
|
||||
result = gtk_slice_list_model_new (store, offset, size);
|
||||
result = gtk_slice_list_model_new (G_LIST_MODEL (store), offset, size);
|
||||
|
||||
changes = g_string_new ("");
|
||||
g_object_set_qdata_full (G_OBJECT (result), changes_quark, changes, free_changes);
|
||||
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
|
||||
g_signal_connect (result, "items-changed", G_CALLBACK (items_changed), changes);
|
||||
g_signal_connect (result, "sections-changed", G_CALLBACK (sections_changed), changes);
|
||||
g_signal_connect (result, "notify::n-items", G_CALLBACK (notify_n_items), changes);
|
||||
|
||||
return result;
|
||||
@@ -288,7 +230,7 @@ test_create (void)
|
||||
GListStore *store;
|
||||
|
||||
store = new_store (1, 5, 2);
|
||||
slice = new_model (G_LIST_MODEL (store), 0, 10);
|
||||
slice = new_model (store, 0, 10);
|
||||
assert_model (slice, "1 3 5");
|
||||
assert_changes (slice, "");
|
||||
|
||||
@@ -331,7 +273,7 @@ test_set_slice (void)
|
||||
GListStore *store;
|
||||
|
||||
store = new_store (1, 7, 2);
|
||||
slice = new_model (G_LIST_MODEL (store), 0, 3);
|
||||
slice = new_model (store, 0, 3);
|
||||
assert_model (slice, "1 3 5");
|
||||
assert_changes (slice, "");
|
||||
|
||||
@@ -360,7 +302,7 @@ test_changes (void)
|
||||
GListStore *store;
|
||||
|
||||
store = new_store (1, 20, 1);
|
||||
slice = new_model (G_LIST_MODEL (store), 10, 5);
|
||||
slice = new_model (store, 10, 5);
|
||||
assert_model (slice, "11 12 13 14 15");
|
||||
assert_changes (slice, "");
|
||||
|
||||
@@ -407,7 +349,7 @@ test_bug_added_equals_removed (void)
|
||||
GListStore *store;
|
||||
|
||||
store = new_store (1, 10, 1);
|
||||
slice = new_model (G_LIST_MODEL (store), 0, 10);
|
||||
slice = new_model (store, 0, 10);
|
||||
assert_model (slice, "1 2 3 4 5 6 7 8 9 10");
|
||||
assert_changes (slice, "");
|
||||
|
||||
@@ -426,7 +368,7 @@ test_bug_skip_amount (void)
|
||||
GListStore *store;
|
||||
|
||||
store = new_store (1, 5, 1);
|
||||
slice = new_model (G_LIST_MODEL (store), 2, 2);
|
||||
slice = new_model (store, 2, 2);
|
||||
assert_model (slice, "3 4");
|
||||
assert_changes (slice, "");
|
||||
|
||||
@@ -438,76 +380,6 @@ test_bug_skip_amount (void)
|
||||
g_object_unref (slice);
|
||||
}
|
||||
|
||||
static int
|
||||
by_n (gconstpointer p1,
|
||||
gconstpointer p2,
|
||||
gpointer data)
|
||||
{
|
||||
guint n1 = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (p1), number_quark));
|
||||
guint n2 = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (p2), number_quark));
|
||||
unsigned int n = GPOINTER_TO_UINT (data);
|
||||
|
||||
n1 = n1 / n;
|
||||
n2 = n2 / n;
|
||||
|
||||
if (n1 < n2)
|
||||
return -1;
|
||||
else if (n1 > n2)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
compare (gconstpointer first,
|
||||
gconstpointer second,
|
||||
gpointer unused)
|
||||
{
|
||||
return GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (first), number_quark))
|
||||
- GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (second), number_quark));
|
||||
}
|
||||
|
||||
static void
|
||||
test_sections (void)
|
||||
{
|
||||
GListStore *store;
|
||||
GtkSortListModel *sorted;
|
||||
GtkSliceListModel *slice;
|
||||
GtkSorter *sorter;
|
||||
|
||||
store = new_store (1, 10, 1);
|
||||
sorted = gtk_sort_list_model_new (G_LIST_MODEL (store),
|
||||
GTK_SORTER (gtk_custom_sorter_new (compare, NULL, NULL)));
|
||||
slice = new_model (G_LIST_MODEL (sorted), 0, 10);
|
||||
assert_model (slice, "1 2 3 4 5 6 7 8 9 10");
|
||||
assert_section_model (slice, "[1 2 3 4 5 6 7 8 9 10]");
|
||||
assert_changes (slice, "");
|
||||
|
||||
sorter = GTK_SORTER (gtk_custom_sorter_new (by_n, GUINT_TO_POINTER (3), NULL));
|
||||
gtk_sort_list_model_set_section_sorter (sorted, sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
assert_section_model (slice, "[1 2] [3 4 5] [6 7 8] [9 10]");
|
||||
assert_changes (slice, "s0:10");
|
||||
|
||||
gtk_slice_list_model_set_size (slice, 5);
|
||||
|
||||
assert_section_model (slice, "[1 2] [3 4 5]");
|
||||
assert_changes (slice, "5-5*");
|
||||
|
||||
gtk_slice_list_model_set_offset (slice, 1);
|
||||
assert_section_model (slice, "[2] [3 4 5] [6]");
|
||||
assert_changes (slice, "0-5+5");
|
||||
|
||||
gtk_section_model_sections_changed (GTK_SECTION_MODEL (sorted), 0, 3);
|
||||
assert_changes (slice, "s0:2");
|
||||
|
||||
gtk_section_model_sections_changed (GTK_SECTION_MODEL (sorted), 5, 3);
|
||||
assert_changes (slice, "s4:1");
|
||||
|
||||
g_object_unref (slice);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@@ -524,7 +396,6 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/slicelistmodel/changes", test_changes);
|
||||
g_test_add_func ("/slicelistmodel/bug/added_equals_removed", test_bug_added_equals_removed);
|
||||
g_test_add_func ("/slicelistmodel/bug/skip_amount", test_bug_skip_amount);
|
||||
g_test_add_func ("/slicelistmodel/sections", test_sections);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
+39
-124
@@ -1,4 +1,4 @@
|
||||
/* sortlistmodel tests
|
||||
/* GtkRBTree tests.
|
||||
*
|
||||
* Copyright (C) 2011, Red Hat, Inc.
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
@@ -52,41 +52,6 @@ model_to_string (GListModel *model)
|
||||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
static char *
|
||||
section_model_to_string (GListModel *model)
|
||||
{
|
||||
GString *string = g_string_new (NULL);
|
||||
guint i, s, e;
|
||||
|
||||
if (!GTK_IS_SECTION_MODEL (model))
|
||||
return model_to_string (model);
|
||||
|
||||
i = 0;
|
||||
while (i < g_list_model_get_n_items (model))
|
||||
{
|
||||
gtk_section_model_get_section (GTK_SECTION_MODEL (model), i, &s, &e);
|
||||
g_assert (s == i);
|
||||
|
||||
if (i > 0)
|
||||
g_string_append (string, " ");
|
||||
|
||||
g_string_append (string, "[");
|
||||
|
||||
for (; i < e; i++)
|
||||
{
|
||||
if (i > s)
|
||||
g_string_append (string, " ");
|
||||
|
||||
g_string_append_printf (string, "%u", get (model, i));
|
||||
}
|
||||
|
||||
g_string_append (string, "]");
|
||||
i = e;
|
||||
}
|
||||
|
||||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
splice (GListStore *store,
|
||||
guint pos,
|
||||
@@ -150,14 +115,6 @@ insert (GListStore *store,
|
||||
g_free (s); \
|
||||
}G_STMT_END
|
||||
|
||||
#define assert_section_model(model, expected) G_STMT_START{ \
|
||||
char *s = section_model_to_string (G_LIST_MODEL (model)); \
|
||||
if (!g_str_equal (s, expected)) \
|
||||
g_assertion_message_cmpstr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||
#model " == " #expected, s, "==", expected); \
|
||||
g_free (s); \
|
||||
}G_STMT_END
|
||||
|
||||
#define assert_changes(model, expected) G_STMT_START{ \
|
||||
GString *changes = g_object_get_qdata (G_OBJECT (model), changes_quark); \
|
||||
if (!g_str_equal (changes->str, expected)) \
|
||||
@@ -219,20 +176,6 @@ items_changed (GListModel *model,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sections_changed (GListModel *model,
|
||||
guint position,
|
||||
guint n_items,
|
||||
GString *changes)
|
||||
{
|
||||
g_assert_true (n_items != 0);
|
||||
|
||||
if (changes->len)
|
||||
g_string_append (changes, ", ");
|
||||
|
||||
g_string_append_printf (changes, "s%u:%u", position, n_items);
|
||||
}
|
||||
|
||||
static void
|
||||
notify_n_items (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
@@ -293,7 +236,6 @@ new_model (gpointer model)
|
||||
changes = g_string_new ("");
|
||||
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
|
||||
g_signal_connect (result, "items-changed", G_CALLBACK (items_changed), changes);
|
||||
g_signal_connect (result, "sections-changed", G_CALLBACK (sections_changed), changes);
|
||||
g_signal_connect (result, "notify::n-items", G_CALLBACK (notify_n_items), changes);
|
||||
|
||||
return result;
|
||||
@@ -629,82 +571,55 @@ test_add_remove_item (void)
|
||||
}
|
||||
|
||||
static int
|
||||
by_n (gconstpointer p1,
|
||||
gconstpointer p2,
|
||||
gpointer data)
|
||||
sort_func (gconstpointer p1,
|
||||
gconstpointer p2,
|
||||
gpointer data)
|
||||
{
|
||||
guint n1 = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (p1), number_quark));
|
||||
guint n2 = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (p2), number_quark));
|
||||
unsigned int n = GPOINTER_TO_UINT (data);
|
||||
const char *s1 = gtk_string_object_get_string ((GtkStringObject *)p1);
|
||||
const char *s2 = gtk_string_object_get_string ((GtkStringObject *)p2);
|
||||
|
||||
n1 = n1 / n;
|
||||
n2 = n2 / n;
|
||||
|
||||
if (n1 < n2)
|
||||
return -1;
|
||||
else if (n1 > n2)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
weird (gconstpointer p1,
|
||||
gconstpointer p2,
|
||||
gpointer data)
|
||||
{
|
||||
guint n1 = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (p1), number_quark));
|
||||
guint n2 = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (p2), number_quark));
|
||||
|
||||
if (n1 == 5 && n2 != 5)
|
||||
return -1;
|
||||
else if (n1 != 5 && n2 == 5)
|
||||
return 1;
|
||||
|
||||
return by_n (p1, p2, data);
|
||||
/* compare just the first byte */
|
||||
return (int)(s1[0]) - (int)(s2[0]);
|
||||
}
|
||||
|
||||
static void
|
||||
test_sections (void)
|
||||
{
|
||||
GListStore *store;
|
||||
GtkSortListModel *model;
|
||||
GtkStringList *list;
|
||||
const char *strings[] = {
|
||||
"aaa",
|
||||
"aab",
|
||||
"abc",
|
||||
"bbb",
|
||||
"bq1",
|
||||
"bq2",
|
||||
"cc",
|
||||
"cx",
|
||||
NULL
|
||||
};
|
||||
GtkSorter *sorter;
|
||||
GtkSortListModel *sorted;
|
||||
GtkSorter *section_sorter;
|
||||
guint s, e;
|
||||
|
||||
store = new_store ((guint[]) { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 });
|
||||
model = new_model (store);
|
||||
assert_model (model, "1 2 3 4 5 6 7 8 9 10");
|
||||
assert_section_model (model, "[1 2 3 4 5 6 7 8 9 10]");
|
||||
assert_changes (model, "");
|
||||
list = gtk_string_list_new (strings);
|
||||
sorter = GTK_SORTER (gtk_string_sorter_new (gtk_property_expression_new (GTK_TYPE_STRING_OBJECT, NULL, "string")));
|
||||
sorted = gtk_sort_list_model_new (G_LIST_MODEL (list), sorter);
|
||||
section_sorter = GTK_SORTER (gtk_custom_sorter_new (sort_func, NULL, NULL));
|
||||
gtk_sort_list_model_set_section_sorter (GTK_SORT_LIST_MODEL (sorted), section_sorter);
|
||||
g_object_unref (section_sorter);
|
||||
|
||||
g_assert_true (gtk_sort_list_model_get_section_sorter (model) == NULL);
|
||||
gtk_section_model_get_section (GTK_SECTION_MODEL (sorted), 0, &s, &e);
|
||||
g_assert_cmpint (s, ==, 0);
|
||||
g_assert_cmpint (e, ==, 3);
|
||||
gtk_section_model_get_section (GTK_SECTION_MODEL (sorted), 3, &s, &e);
|
||||
g_assert_cmpint (s, ==, 3);
|
||||
g_assert_cmpint (e, ==, 6);
|
||||
gtk_section_model_get_section (GTK_SECTION_MODEL (sorted), 6, &s, &e);
|
||||
g_assert_cmpint (s, ==, 6);
|
||||
g_assert_cmpint (e, ==, 8);
|
||||
|
||||
sorter = GTK_SORTER (gtk_custom_sorter_new (by_n, GUINT_TO_POINTER (3), NULL));
|
||||
gtk_sort_list_model_set_section_sorter (model, sorter);
|
||||
g_assert_true (gtk_sort_list_model_get_section_sorter (model) == sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
assert_changes (model, "s0:10");
|
||||
assert_section_model (model, "[1 2] [3 4 5] [6 7 8] [9 10]");
|
||||
|
||||
sorter = GTK_SORTER (gtk_custom_sorter_new (by_n, GUINT_TO_POINTER (5), NULL));
|
||||
g_assert_false (gtk_sort_list_model_get_section_sorter (model) == sorter);
|
||||
gtk_sort_list_model_set_section_sorter (model, sorter);
|
||||
g_assert_true (gtk_sort_list_model_get_section_sorter (model) == sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
assert_changes (model, "s0:10");
|
||||
assert_section_model (model, "[1 2 3 4] [5 6 7 8 9] [10]");
|
||||
|
||||
sorter = GTK_SORTER (gtk_custom_sorter_new (weird, GUINT_TO_POINTER (5), NULL));
|
||||
gtk_sort_list_model_set_section_sorter (model, sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
assert_changes (model, "0-10+10");
|
||||
assert_section_model (model, "[5] [1 2 3 4] [6 7 8 9] [10]");
|
||||
|
||||
g_object_unref (store);
|
||||
g_object_unref (model);
|
||||
g_object_unref (sorted);
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Treelistmodel tests.
|
||||
/* GtkRBTree tests.
|
||||
*
|
||||
* Copyright (C) 2011, Red Hat, Inc.
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
@@ -550,7 +550,6 @@ test_same_child_model (void)
|
||||
GtkTreeListModel *treelist;
|
||||
DemoNode *d;
|
||||
guint i, j;
|
||||
char str[2] = { 0, };
|
||||
|
||||
i = N_MODELS;
|
||||
while (i --> 0)
|
||||
@@ -558,8 +557,7 @@ test_same_child_model (void)
|
||||
models[i] = g_list_store_new (demo_node_get_type ());
|
||||
for (j = 0; j < N_ITEMS_PER_MODEL; j++)
|
||||
{
|
||||
str[0] = 'A' + j;
|
||||
d = demo_node_new (str, i + 1 < N_MODELS ? models[i + 1] : NULL);
|
||||
d = demo_node_new ("A" + j, i + 1 < N_MODELS ? models[i + 1] : NULL);
|
||||
g_list_store_append (models[i], d);
|
||||
}
|
||||
}
|
||||
@@ -581,8 +579,7 @@ test_same_child_model (void)
|
||||
case 0:
|
||||
if (n_items < 10)
|
||||
{
|
||||
str[0] = 'A' + (i % 26);
|
||||
d = demo_node_new (str, model_id + 1 < N_MODELS ? models[model_id + 1] : NULL);
|
||||
d = demo_node_new ("A" + (i % 26), model_id + 1 < N_MODELS ? models[model_id + 1] : NULL);
|
||||
g_list_store_insert (model,
|
||||
g_test_rand_int_range (0, n_items + 1),
|
||||
d);
|
||||
@@ -594,8 +591,7 @@ test_same_child_model (void)
|
||||
g_list_store_remove (model, g_test_rand_int_range (0, n_items));
|
||||
break;
|
||||
case 2:
|
||||
str[0] = 'A' + (i % 26);
|
||||
d = demo_node_new (str, model_id + 1 < N_MODELS ? models[model_id + 1] : NULL);
|
||||
d = demo_node_new ("A" + (i % 26), model_id + 1 < N_MODELS ? models[model_id + 1] : NULL);
|
||||
g_list_store_splice (model,
|
||||
n_items ? g_test_rand_int_range (0, n_items) : 0,
|
||||
n_items ? 1 : 0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* GtkTreePath tests.
|
||||
/* GtkTrePath tests.
|
||||
*
|
||||
* Copyright (C) 2011, Red Hat, Inc.
|
||||
* Authors: Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
Reference in New Issue
Block a user