Compare commits

...

113 Commits

Author SHA1 Message Date
Matt Watson c9f4c86b1f animatedstyle: don't share styleanimations
Because of our port of css animation and css transition to
progress tracker, we should not think of animated styles as
immutable objects that can map any timestamp to css values.
Rather, timestamps can correspond to different values depending
on the value of GTK_SLOWDOWN over the course of the animation.

To keep animated styles and style animations totally immutable,
we will not share styleanimations between animatedstyles, and
make a new copy of a styleanimation for each timestamp.
2016-04-06 15:40:53 -07:00
Matt Watson 945f4a45d5 animatedstyle: just ref current style if timestamp the same 2016-04-06 15:40:53 -07:00
Matt Watson e56a1ddce3 animatedstyle: fail to create new style if timestamp goes backwards
With slowdown factor, we will only we be able to handle timestamps
that monotonically increase.
2016-04-06 15:40:53 -07:00
Matt Watson b1c94375e8 cssanimation: port to progress tracker 2016-04-06 15:40:53 -07:00
Matt Watson 865201f11f csstransition: port to progress tracker 2016-04-06 15:40:53 -07:00
Matt Watson f5a8201b0f entry: port to progress tracker 2016-04-06 15:40:52 -07:00
Matt Watson 4bf81e6ab5 progressbar: port to progress tracker 2016-04-06 15:40:52 -07:00
Matt Watson a09586175e scrolledwindow: port indicator fade to progress tracker 2016-04-06 15:40:52 -07:00
Matt Watson 3fed034b0c popover: port to progress tracker 2016-04-06 15:40:52 -07:00
Matt Watson c2b97c1b22 switch: port to progress tracker 2016-04-06 15:40:52 -07:00
Matt Watson 5d5ee76a8b revealer: port to progress tracker 2016-04-06 15:40:52 -07:00
Matt Watson abc8b34683 stack: skip first frame for animations
Not the ideal solution for this problem, but in practice leads to
much better performance on lower end hardware.

Stack does a double draw on the first frame of its animation, of
both the old contents (into a cairo surface) and the new contents.
Homogeneous stacks only need to reallocate contents on the first
frame.

On lower powered hardware where our frames will be a good deal
slower than the refresh rate anyway, we can assure a smother
experience by waiting a frame to start tweening where frame duration
will be more consistent.
2016-04-06 15:40:52 -07:00
Matt Watson d3961dacad stack: port to progress tracker 2016-04-06 15:40:52 -07:00
Matt Watson e962ebab82 inspector: add slider to control slowdown factor 2016-04-06 15:40:52 -07:00
Matt Watson ed75fa655b progresstracker: add GTK_SLOWDOWN environment variable
As we consolidate widgets to use progress tracker, this will allow
us to control the speed of all animations in a centralized place
2016-04-06 15:40:52 -07:00
Matt Watson 44a9c0e36d progresstracker: simple struct to track animation progress 2016-04-06 15:40:52 -07:00
Lapo Calamandrei 85e37925f0 Adwaita: transparent textview border border
So it will play nicely with gedit color combinations.
See https://bugzilla.gnome.org/show_bug.cgi?id=764203
2016-04-04 12:03:11 +02:00
Tom Tryfonidis d5b78d474a Updated Greek translation
(cherry picked from commit 40afffb9fd)
2016-04-04 09:28:33 +00:00
Matthias Clasen 2f0354fcf9 Move GdkDeviceManager to deprecated section
It has been superseded by GdkSeat.
2016-04-03 23:41:20 -04:00
Matthias Clasen 8ef12fda83 Add an index for 3.22 api additions 2016-04-03 23:33:57 -04:00
Matthias Clasen 9bfc8371fe wayland: Remove an unused vfunc 2016-04-03 18:18:17 -04:00
Matthias Clasen 59e40f3d6f wayland: Remove unused field 2016-04-03 18:18:17 -04:00
Kristjan SCHMIDT 62a7447c5f Updated Esperanto translation 2016-04-03 02:20:00 +02:00
Kristjan SCHMIDT f052f1554b Updated Esperanto translation 2016-04-03 00:46:18 +02:00
Timm Bäder 58891c1fe5 headerbar: Don't underallocate the label box
We use a label_sizing_box to make sure the headerbar can always contain
both a title and a subtitle without resizing when showing/hiding either
of them, but we should only do that for the height; the min width of the
label_box can be larger than that of the label_sizing_box.
2016-04-02 17:03:52 +02:00
Lapo Calamandrei d23c6c6246 Adwaita: style textview border
see https://bugzilla.gnome.org/show_bug.cgi?id=764203
2016-04-02 16:24:52 +02:00
Lapo Calamandrei f2f1725b40 Adwaita: cosmetic fixes 2016-04-02 16:03:02 +02:00
Carlos Garnacho 2784eacf00 wayland: Avoid NULL slave devices in GdkSeat::get_slaves
Just because we're asked for a capability, it doesn't mean we have
it.
2016-04-01 19:10:36 +02:00
Lapo Calamandrei b1205a9c96 Adwaita: set secondary caret color to selection blue
see https://bugzilla.gnome.org/show_bug.cgi?id=764204
2016-04-01 16:48:13 +02:00
Rui Matos 4bfa6c30bf gtkwindow: Don't allow unresizable windows to be smaller than required
Commit cdc580463e made it so that
unresizable windows can't be smaller than a set default size but it
lost the logic to ensure these windows remain at least big enough to
comply with their requisition.

https://bugzilla.gnome.org/show_bug.cgi?id=764174
2016-04-01 15:30:03 +02:00
Timm Bäder 84dfda1a2b widget: Always warn when underallocating widgets 2016-04-01 10:04:25 +02:00
Matthias Clasen 4c698bc824 wayland: Print out more debug info
Print out the subpixel layout and frame rates that the compositor
sends us.
2016-03-31 20:31:00 -04:00
Alexander Larsson 4c10800bcc gdkwindow: Remove O(n-children) code in gdk_window_invalidate
When we invalidate a window we need to also invalidate all child windows
that are native (non-native are automatically invalidated as we track
invalidation once per native window only). This was done in a pretty
inefficient way, recursing over the entire tree.

This makes the invalidation much faster by only looking at the native
children of the native window we're in, filtering out those that
are not a descendant of the client side window we're interested in.
Given that there are very few native subwindows this is much faster.
2016-03-31 18:56:18 +02:00
Matthias Clasen d1acb786a7 icon theme: Make the builtin hicolor index match reality
We were missing all of the status directories, and a few sizes.
This was causing us to not find image-missing on systems without
hicolor icon theme (this basically only happens on Windows).

https://bugzilla.gnome.org/show_bug.cgi?id=764378
2016-03-31 07:12:50 -04:00
Theppitak Karoonboonyanan a93e477a4d Updated Thai translation. 2016-03-31 09:13:42 +07:00
Matthias Clasen 6faafbff6e Use AM_DISTCHECK_CONFIGURE_FLAGS
This is preferred over DISTCHECK_CONFIGURE_FLAGS in modern automake.
2016-03-30 21:54:04 -04:00
Matthias Clasen d8da5879aa Adwaita: theme acceleditor > label
We need to have an opaque background here, otherwise the underlying
cell shines through.

https://bugzilla.gnome.org/show_bug.cgi?id=764376
2016-03-30 19:50:22 -04:00
Matthias Clasen 72178fd0c9 Accel cell renderer: Set a css name
Give the event box we use here the distinctive name "acceleditor".
2016-03-30 19:50:22 -04:00
Benjamin Otte 71a5f07620 widget: queue a redraw only if resize highlighting is enabled
e8aa9b0440 introduced a new debug mode
that highlights resizes. Unfortunately it has the side effect of
always queueing redraws even when the debug mode is not enabled.
Make the redraw conditional.
2016-03-30 21:44:58 +02:00
Debarshi Ray fd143a2b38 window: Make the sample code obey the party line on geometry widgets
The geometry_widget parameter is deprecated [1]. If one is passed, we
remove GDK_HINT_BASE_SIZE and GDK_HINT_RESIZE_INC from the mask [2].

[1] commit 08974a1e9a
[2] commit f7cc4abbad

https://bugzilla.gnome.org/show_bug.cgi?id=764321
2016-03-30 13:21:50 +02:00
Руслан Ижбулатов bde5281ae8 GDK W32: Use a dumb window class for decorative windows
Currently only one kind of decorative window is in use - the shape
indicator that is shown when snapping windows to the edge of the screen.

When normal toplevel class is used, its window procedure expects certain
motions from GDK (passing user data to CreateWindowEx(), registering
handle in a hash map etc), and might crash if that is not done.

Dumb window doesn't require anything, it can just be.

https://bugzilla.gnome.org/show_bug.cgi?id=763013
2016-03-30 09:04:46 +00:00
Руслан Ижбулатов cfbb8c5252 GDK W32: Add/subtract shadow when (un)snapping
Now halfleft/halfright/fullup snaps do hug screen edges as intended.

Documents AeroSnap behaviour when snapped windows are drag-resized
(currently this implementation handles this in a very simplistic way).

Don't believe GTK when it tells us that window shadow is 0, preserve
previous values (but do remember that GTK wants no shadow, in case
we need that).

Fixes a couple of bugs in unsnapping (check offset against the half
of the window; don't put pointer in the middle of the window vertically
if it still fits in the top half).

https://bugzilla.gnome.org/show_bug.cgi?id=763013
2016-03-30 09:04:37 +00:00
Руслан Ижбулатов f853283d7b GDK W32: Add/subtract shadow when drag-resizing
Implements gdk_win32_window_set_shadow_width().
Uses shadow width/height to adjust max tracking size, allowing
windows to be drag-resized to cover the whole desktop.

Also uses SM_C*VIRTUALSCREEN instead of SM_C*MAXTRACK.

https://bugzilla.gnome.org/show_bug.cgi?id=763013
2016-03-30 09:03:56 +00:00
Руслан Ижбулатов b0131616b2 GDK W32: Draw snap indicators for AeroSnap
Indicator is a bare layered click-through native window,
painted completely by GDK, including animation.

This commit also isolates some of the more spam-ish debug logging
under ifdef.

This commit also changes the system metric used for maximal window
height for the snapping purposes. Turns out, SM_CYMAXTRACK is way
too large, use SM_CYVIRTUALSCREEN instead.

https://bugzilla.gnome.org/show_bug.cgi?id=763013
2016-03-30 09:03:41 +00:00
Руслан Ижбулатов b420c53773 GDK W32: Add drag-to-snap feature to AeroSnap
This implements the part of AeroSnap that snaps windows when you
drag them (while moving or resizing) to the edge of the screen.

It also fixes drag behaviour for snapped and maximized windows
(if such windows are dragged, first they must be unmaximized/unsnapped).

Note that this code does not take into account the shadow width, and
because of that the under-pointer-position-preserving window moves
might not look as such for maximized windows, which lack the shadow
when maximized, but do have the shadow when unmaximized.

This commit also doesn't cover some corner-cases the same way AeroSnap does.

Also, the snapping indicator (which is supposed to be a window shape that
shows where the window will be if the drag op is stopped at its current
point) is not being drawn, all routines responsible for its creation,
moving and drawing are stubs.

https://bugzilla.gnome.org/show_bug.cgi?id=763013
2016-03-30 09:00:07 +00:00
Руслан Ижбулатов 2ea96cf946 GDK W32: Improve AeroSnap - don't resize windows that fit
This is what AeroSnap does. If a window is being unsnapped on
a new monitor, check if the work area is large enough for the
window to fit in its normal size. If the window fits, just
reposition it so that the ratio of
left-window-edge-to-screen-edge / right-window-edge-to-screen-edge
remains the same, without scaling the window.

https://bugzilla.gnome.org/show_bug.cgi?id=763013
2016-03-30 09:00:02 +00:00
Руслан Ижбулатов 0ce217cf94 GDK W32: Re-implement AeroSnap for CSD windows
It works exactly like AeroSnap.
Except for shift+win+left/right, which is left for AeroSnap
to handle (AeroSnap takes action before we get the message,
so there's no way for us to override it).
The only thing that doesn't work is shift+win+left/right on
a maximized window, for reasons unknown at the moment.

This only implements winkey+stuff behaviour of AeroSnap,
not the drag-to-the-edge-and-something-funny-happens one.

https://bugzilla.gnome.org/show_bug.cgi?id=763013
2016-03-30 08:59:56 +00:00
Debarshi Ray 27a1b50bc6 window: Fix gtk_window_set_geometry_hints documentation
The geometry_widget parameter is ignored from 3.20 onwards [1], not
3.18 as mentioned in the documentation.

[1] commit 08974a1e9a

https://bugzilla.gnome.org/show_bug.cgi?id=764321
2016-03-29 19:31:59 +02:00
Emmanuele Bassi 6267b6b6eb Bump to 3.21.0
Otherwise newly added API will start warning.
2016-03-29 16:24:14 +01:00
Руслан Ижбулатов 77eebbda5c GDK W32: Erase hidden layered windows before showing them
If a layered window was hidden and is made visible, erase its
contents before showing it. GDK will schedule a redraw, but until
then we generally don't want to show old contents.

https://bugzilla.gnome.org/show_bug.cgi?id=763783
2016-03-29 14:30:19 +00:00
Руслан Ижбулатов cea8c29a26 GDK W32: Implement show_window_menu()
This is achieved by sending undocumented message WM_SYSMENU
to the window.
Before doing that, the window is given WS_SYSMENU style
(to enable window menu) and some combination of
WS_MAXIMIZEBOX (for "Mazimize" item)
WS_MINIMIZEBOX (for "Minimize" item)
WS_SIZEBOX (for "Size" item)
depending on which operations are currently permissible.

WM_SYSMENU is processed by DefWindowProc(), which results
in showing the window menu. We remove extra styles
at the first opportunity (WM_INITMENU message), as they
alter the way our window is rendered.

https://bugzilla.gnome.org/show_bug.cgi?id=763851
2016-03-29 13:47:49 +00:00
Lapo Calamandrei 38f94194a6 Adwaita: set caret-color for drop targets 2016-03-29 15:06:11 +02:00
Lapo Calamandrei e7cd3dddd8 Adwaita: cosmetic fix 2016-03-29 15:01:57 +02:00
Matthias Clasen 43a568395b Add some tests for GdkRectangle
In particular, we're testing corner cases with empty rectangles
here.
2016-03-28 19:54:55 -04:00
Matthias Clasen 669336cf95 Expand visual tests a bit 2016-03-28 19:28:57 -04:00
Matthias Clasen 785a425516 Add tests for seat apis
These are just some basic sanity tests.
2016-03-28 19:22:36 -04:00
Matthias Clasen 6f2d5a6290 Move autotestkeywords to testsuite
All the 'make check' and installed tests are now in testsuite/,
and tests/ is just a collection manual test programs.
2016-03-28 17:56:13 -04:00
Benjamin Otte a91237d65e window: Remove suspicious branch
While this commit was found to make emacs windows shrink (and it was
reverted in the gtk-3-20 branch for that reason), that was the only
observed breakage, while the reversal broke several of our unit tests.

Closer study of the emacs sources revealed that it does some really
unsupportable things like doing its own X event handling behind GTK+'s
back and freely mixing sizes of GtkWindows and GdkWindows obtained in
various ways. I've filed a bug against emacs with suggestions for how
to avoid the shrinking window, regardless of this commit.

Original commit message:

It seems this branch is not needed anymore. It was originally added in
1999 to support gtk_widget_realize(), but all those reasons seem
obsolete today.
Instead just call gtk_widget_realize().

If you end up at this commit when bisecting:
There is no bug that made me remove this code, it was purely meant to be
cleanup / dead code removal. I seem to have introduced a new bug or
bisecting wouldn't have let you here. So it seems we should just revert
this commit.
2016-03-28 17:05:09 -04:00
Timm Bäder aeed695e26 gtkapplication: _get_app_menu can return NULL 2016-03-28 18:18:20 +02:00
Aurimas Černius a9f94ba67f Updated Lithuanian translation 2016-03-28 17:48:10 +03:00
Matthias Clasen 568feffa69 Use dngettext instead of ngettext
Since we are a library, we have to pass the domain explicitly.

https://bugzilla.gnome.org/show_bug.cgi?id=764261
2016-03-27 19:00:31 -04:00
Matthias Clasen 5dabfa7b39 places sidebar: Plug a small memory leak
_gtk_trash_moniotr_get_icon is transfer full, so we have
to unref the icon.
2016-03-27 18:42:25 -04:00
Cosimo Cecchi b6b53fc19c GtkClipboard: fix a typo 2016-03-27 08:39:44 -07:00
Cosimo Cecchi efea673c31 GtkCssSection: remove duplicated documentation
Fixes a build time warning.
2016-03-27 08:35:13 -07:00
Cosimo Cecchi 26f9dc6508 scale: fix marks node position for scales with value
We should only count the value node as the first/last one if its
position matches.
2016-03-26 22:43:53 -07:00
Cosimo Cecchi 9f48b6b07a range: use gadget pointers for grab/mouse locations
Simplify code and remove the mouse location indirection.
2016-03-26 22:43:53 -07:00
Cosimo Cecchi 6efc06ef5c scale: remove impossible case
We only create the gadget when the markup is not empty, so we don't
need to check again here.
2016-03-26 22:43:53 -07:00
Cosimo Cecchi b989910293 scale: cache pango layouts for mark labels
Constantly creating pango layouts while drawing means that animations
will be slow. Instead, cache the pango layout in the mark structure.
2016-03-26 22:43:53 -07:00
Matthias Clasen 7e15ac8927 Add an index for 3.22 api additions 2016-03-26 23:32:45 -04:00
Matthias Clasen 100cf2442e Add a function to get the selection of a clipboard
This was requested in
http://bugzilla.gnome.org/show_bug.cgi?id=730821
2016-03-26 23:30:21 -04:00
Matthias Clasen cb738bc201 Remove private clipboard api from public headers 2016-03-26 23:17:53 -04:00
Matthias Clasen 0d0980f30e filter model: Mark property nicks and blurbs for translation
Better descriptions are not going to happen... might as well
admit it.
2016-03-26 18:59:02 -04:00
Matthias Clasen b1b271ab09 Drop some more code
This ifdefed out function was only used in the code I just nuked,
so it can go as well.
2016-03-26 18:53:55 -04:00
Matthias Clasen 543ad3aabb file chooser: Drop unused code
We've never restored filechooser positions, and we aren't going to.
2016-03-26 18:52:04 -04:00
Matthias Clasen 59d8cba482 wayland: Get min/max keycode from xkb keymap
Instead of hardcoding 8/255 here.
2016-03-26 18:48:27 -04:00
Matthias Clasen 7249897dc8 Drop irritating FIXMEs in docs
There is nothing to fix here, so don't make gnome-builder pick
these lines up for its todo list.
2016-03-26 18:39:39 -04:00
Matthias Clasen 8d874cf0f8 Stop using pango_split_file_list
Add a copy of this deprecated utility in gtkutils.c and use
it instead of the pango API.
2016-03-26 18:19:37 -04:00
Matthias Clasen 6994fe03ee Split off copied pango utils in their own source
This will make it easier to use them in more than one place.
2016-03-26 18:12:16 -04:00
Matthias Clasen e2d89b9931 Revert "window: Remove suspicious branch"
This reverts commit 67ab00e01e.

Bisection showed that this commit caused emacs windows to shrink
to a small size when first shown.
2016-03-26 17:38:40 -04:00
Matthias Clasen 1057f249bd wayland: Add debug output for pixel formats
Use GDK_DEBUG=misc to see information about wl_shm pixel formats
supported by the compositor.
2016-03-26 16:08:01 -04:00
Matthias Clasen f06fc8d378 Deprecate gdk_visual_get_colormap_size
Since we don't have API for colormaps anymore, this is not
a useful function.
2016-03-26 15:15:28 -04:00
Matthias Clasen ce0074b034 Deprecate gdk_visual_get_byte_order
This function is only useful when working with XImages,
and is not meaningfully implemented in other backends.
2016-03-26 15:07:09 -04:00
Matthias Clasen c6cdddd68d wayland: Fix up visual implementation
Don't return visuals that don't match the requested depth
and/or visual type.
2016-03-26 14:58:48 -04:00
Matthias Clasen 89973118f3 Add some more visual tests
These are just basic tests to ensure that the visual implementation
of a backend is sound.
2016-03-26 14:56:36 -04:00
Matthias Clasen aa4c5459b7 Deprecate gdk_visual_get_bits_per_rgb
This function is pretty useless, since the Wayland backend returns
0 for this, and the Windows backend 42 (!).
2016-03-26 14:20:23 -04:00
Matthias Clasen c448061d49 Add version macros for 3.22 2016-03-26 14:08:10 -04:00
Matthias Clasen 7fe1037e84 range: Simplify highlight allocation
Since we are really only interested in the center point of the
slider allocation, the pre-computed slider geometry is perfectly
fine, just use it always. This avoids the complication with
gadget visibility.
2016-03-26 13:50:42 -04:00
Matthias Clasen e33188ad41 range: Avoid miscalculating highlight allocation
The slider gadget may be turned invisible as side-effect of
gtk_range_calc_slider(). If that happens,
gtk_css_gadget_get_content_allocation() returns { 0, 0, 0, 0},
which leads us to calculate a negative allocation for the highlight
node. Avoid this, by just reusing our already calculated slider
allocation in this case (it is not technically the same as the
content, allocation, but the difference hardly matter here.

https://bugzilla.gnome.org/show_bug.cgi?id=764022
2016-03-26 10:50:00 -04:00
Matthias Clasen 2374e2aa3b Add a test for the system rgba visual
The main point of this test is to ensure that the pixel_details
getters work as expected.
2016-03-26 10:10:57 -04:00
Matthias Clasen e48e29db3b wayland: Fully initialize the visual
The pixel details (mask, shift and precision) are supposed to
be filled in for TrueColor visuals.
2016-03-26 10:10:57 -04:00
Matthias Clasen 8206b824fa Make gdk_visual_get_*_pixel_details work again
These functions are supposed to return the numbers of consecutive
1 bits in each components mask as precision. However, due to a
copy-paste mistake when this code was moved around in
commit 70d689cddd, the precision
was always reported as zero. This affects only a few applications
that directly set window background on X11 windows, such as emacs.

https://bugzilla.gnome.org/show_bug.cgi?id=764210
2016-03-26 09:35:53 -04:00
Jordi Mas 120c296ff6 Update Catalan translation 2016-03-26 08:10:28 +01:00
Matthias Clasen 82bde5b84d HighContrastInverse: Fix suggested-action colors
Choose a suitable foreground color instead of hardcoding white.

https://bugzilla.gnome.org/show_bug.cgi?id=764170
2016-03-25 22:45:55 -04:00
Matthias Clasen fab9c17b89 gtk3-demo: Show more button styles
Add examples for suggested-action and destructive-action
buttons in the style classes example.
2016-03-25 22:45:55 -04:00
Matthias Clasen 258ba6c8a4 gtk3-demo: Rename "CSS Theming" group
Call it just "Themeing" to avoid the repetition of CSS.
2016-03-25 22:45:55 -04:00
Balázs Úr 12bc02db94 Updated Hungarian translation 2016-03-26 00:47:32 +00:00
Руслан Ижбулатов b9b67e05e1 GDK W32: Optimize clipboard handling a bit
Delay as long as possible before calling OpenClipboard(),
call CloseClipboard() as quickly as possible after that.
Don't call OpenClipboard() when we don't need to (for example,
we don't need to open clipboard to call GetClipboardOwner()).

Also, print out actual W32 error code in some cases where it
was not printed before.

https://bugzilla.gnome.org/show_bug.cgi?id=763907
2016-03-26 00:03:50 +00:00
Руслан Ижбулатов 692c3b11ff GDK W32: Print error code along with the error message
Error codes can be easily looked up in an error code list
and/or googled up. Error messages, while descriptive, often
describe the wrong thing, and the messages themselves are not
part of the documentation of a function, unlike error codes.
It would be preferable to have the code, or both.

https://bugzilla.gnome.org/show_bug.cgi?id=763913
2016-03-25 22:04:58 +00:00
Руслан Ижбулатов c4c00299b2 GDK W32: Print more debug info about events
1) Print timestamps for events
2) Print wParam and lParam (in hex form) for messages

https://bugzilla.gnome.org/show_bug.cgi?id=763913
2016-03-25 22:04:57 +00:00
Piotr Drąg 24d2f85b23 Updated POTFILES.in 2016-03-25 21:27:21 +01:00
Christoph Reiter 72346cb209 inspector: add slider for adjusting the font scale
https://bugzilla.gnome.org/show_bug.cgi?id=761435
2016-03-25 16:10:28 -04:00
Matthias Clasen 826f729b6f stack switcher: Add a missing include 2016-03-25 15:52:33 -04:00
Matthias Clasen 6ac7b54378 dnd: Move GtkDragDest to a separate file
This follows what was done for GtkDragSource in
415030d25f and shaves another
500 lines off gtkdnd.c.
2016-03-25 15:37:20 -04:00
Wolfgang Stöggl db93386f23 Updated German translation
(cherry picked from commit 5e5372ce74)
2016-03-25 18:20:37 +00:00
Wolfgang Stöggl ea21ee3039 Updated German translation
(cherry picked from commit c08f4bd2a9)
2016-03-25 18:17:52 +00:00
Mohammed Sadik d47c7f7ba0 gtkaboutdialog: don't break ABI in GtkLicense enum
As the elements in the enum are not explicitly numbered, inserting an
element between some other elements shall change the values of elements
after the insertion. So append the new element at the end.

Anyway, no code should rely on the position of an element in an enum.

https://bugzilla.gnome.org/show_bug.cgi?id=763850
2016-03-25 18:38:46 +01:00
Matthias Clasen 4c8557fa35 Add a css node test for scales 2016-03-25 13:22:11 -04:00
Olivier Fourdan 5d34cf64a2 popover: raise when showing
Some other widget might have mapped and raised another child window of
the toplevel in the meantime, causing the popover window to be covered.

Raise the popover window to avoid the issue.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=763627
2016-03-25 17:23:34 +01:00
Jordi Mas 19034a2352 Fix Catalan translation 2016-03-25 14:27:16 +01:00
Milo Casagrande fae1effec9 Updated Italian translation
(cherry picked from commit be624e71f4)
2016-03-25 10:58:40 +00:00
Razvan Chitu 65687ba392 trashmonitor: change trash monitoring process
The trash is monitored for state changes - going from empty to non-empty and the
other way round. Monitoring is done by handling change signals from a regular
file monitor. On each signal, an enumeration of the trash contents is started in
order to see if it is empty or not. This causes issues when many files are
trashed, because the gvfs trash backend is flooded with enumeration requests,
resulting in CPU usage spikes. In order to fix this, the "item-count" attribute
of the trash should be queried instead.

Replace asynchronous enumeration with asynchronous information query and update
the trash state based on the "item-count" attribute. Emit state change signal
only when the state actually changes.

https://bugzilla.gnome.org/show_bug.cgi?id=763600
2016-03-24 23:20:14 -04:00
Mohammed Sadik 40e777ae30 gtkaboutdialog: Add support for GNU Affero GPLv3+
Add support for GNU Affero GPLv3 (or later) to GtkLicense enum

https://bugzilla.gnome.org/show_bug.cgi?id=763850
2016-03-24 23:18:40 -04:00
Matthias Clasen caa804613d add a css style test for font: smaller 2016-03-24 22:58:43 -04:00
122 changed files with 15197 additions and 7708 deletions
+1 -1
View File
@@ -95,7 +95,7 @@ ChangeLog:
uninstall-local:
rm -f $(DESTDIR)$(pkgconfigdir)/gtk+-3.0.pc
DISTCHECK_CONFIGURE_FLAGS = \
AM_DISTCHECK_CONFIGURE_FLAGS = \
--enable-gtk-doc \
--disable-doc-cross-references \
--enable-man \
+3 -3
View File
@@ -9,9 +9,9 @@
# set GTK_BINARY_AGE and GTK_INTERFACE_AGE to 0.
m4_define([gtk_major_version], [3])
m4_define([gtk_minor_version], [20])
m4_define([gtk_micro_version], [1])
m4_define([gtk_interface_age], [1])
m4_define([gtk_minor_version], [21])
m4_define([gtk_micro_version], [0])
m4_define([gtk_interface_age], [0])
m4_define([gtk_binary_age],
[m4_eval(100 * gtk_minor_version + gtk_micro_version)])
m4_define([gtk_version],
+1 -1
View File
@@ -1,4 +1,4 @@
/* CSS Theming/CSS Accordion
/* Theming/CSS Accordion
*
* A simple accordion demo written using CSS transitions and multiple backgrounds
*
+1 -1
View File
@@ -1,4 +1,4 @@
/* CSS Theming/CSS Basics
/* Theming/CSS Basics
*
* Gtk themes are written using CSS. Every widget is build of multiple items
* that you can style very similarly to a regular website.
+1 -1
View File
@@ -1,4 +1,4 @@
/* CSS Theming/Multiple Backgrounds
/* Theming/Multiple Backgrounds
*
* Gtk themes are written using CSS. Every widget is build of multiple items
* that you can style very similarly to a regular website.
+1 -1
View File
@@ -1,4 +1,4 @@
/* CSS Theming/Animated Backgrounds
/* Theming/Animated Backgrounds
*
* This demo is done in honour of the Pixbufs demo further down.
* It is done exclusively with CSS as the background of the window.
+1 -1
View File
@@ -1,4 +1,4 @@
/* CSS Theming/Shadows
/* Theming/Shadows
*
* This demo shows how to use CSS shadows.
*/
+36 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkGrid" id="grid">
<property name="row-spacing">6</property>
<property name="row-spacing">10</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkToolbar">
@@ -271,5 +271,40 @@
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="visible">1</property>
<property name="spacing">10</property>
<property name="orientation">horizontal</property>
<child>
<object class="GtkButton">
<property name="visible">1</property>
<property name="label">Plain</property>
<property name="halign">end</property>
</object>
<packing>
<property name="expand">1</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="visible">1</property>
<property name="label">Destructive</property>
<style>
<class name="destructive-action"/>
</style>
</object>
</child>
<child>
<object class="GtkButton">
<property name="visible">1</property>
<property name="label">Suggested</property>
<style>
<class name="suggested-action"/>
</style>
</object>
</child>
</object>
</child>
</object>
</interface>
+2 -1
View File
@@ -1,4 +1,4 @@
/* CSS Theming/Style Classes
/* Theming/Style Classes
*
* GTK+ uses CSS for theming. Style classes can be associated
* with widgets to inform the theme about intended rendering.
@@ -24,6 +24,7 @@ do_theming_style_classes (GtkWidget *do_widget)
gtk_window_set_screen (GTK_WINDOW (window),
gtk_widget_get_screen (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Style Classes");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_container_set_border_width (GTK_CONTAINER (window), 12);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
+5 -1
View File
@@ -23,7 +23,6 @@
<xi:include href="xml/gdkdisplay.xml" />
<xi:include href="xml/gdkscreen.xml" />
<xi:include href="xml/gdkseat.xml" />
<xi:include href="xml/gdkdevicemanager.xml" />
<xi:include href="xml/gdkdevice.xml" />
<xi:include href="xml/regions.xml" />
<xi:include href="xml/pixbufs.xml" />
@@ -52,6 +51,7 @@
<reference>
<title>Deprecated</title>
<xi:include href="xml/colors.xml" />
<xi:include href="xml/gdkdevicemanager.xml" />
</reference>
<index id="api-index-full">
@@ -106,6 +106,10 @@
<title>Index of new symbols in 3.20</title>
<xi:include href="xml/api-index-3.20.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-3-22" role="3.22">
<title>Index of new symbols in 3.22</title>
<xi:include href="xml/api-index-3.22.xml"><xi:fallback /></xi:include>
</index>
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
+21 -21
View File
@@ -44,7 +44,7 @@
<informalexample>
<para>Create a new file with the following content named <filename>example-0.c.</filename></para>
<programlisting><xi:include href="../../../../examples/window-default.c" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/window-default.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</informalexample>
<para>
@@ -154,7 +154,7 @@
<title>Hello World in GTK+</title>
<para>Create a new file with the following content named example-1.c.</para>
<programlisting><xi:include href="../../../../examples/hello-world.c" parse="text">
<xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</example>
<para>
@@ -233,7 +233,7 @@
<example id="gtk-getting-started-grid-packing">
<title>Packing buttons</title>
<para>Create a new file with the following content named example-2.c.</para>
<programlisting><xi:include href="../../../../examples/grid-packing.c" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/grid-packing.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</example>
<para>
You can compile the program above with GCC using:
@@ -257,9 +257,9 @@
<example>
<title>Packing buttons with GtkBuilder</title>
<para>Create a new file with the following content named example-4.c.</para>
<programlisting><xi:include href="../../../../examples/builder.c" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/builder.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<para>Create a new file with the following content named builder.ui.</para>
<programlisting><xi:include href="../../../../examples/builder.ui" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/builder.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</example>
<para>
You can compile the program above with GCC using:
@@ -346,7 +346,7 @@
of our application class.</para>
<informalexample>
<programlisting><xi:include href="../../../../examples/application1/main.c" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/application1/main.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</informalexample>
<para>All the application logic is in the application class, which
@@ -364,7 +364,7 @@
GIO <ulink url="https://developer.gnome.org/gio/2.36/GApplication.html#GApplication.description">documentation</ulink>.</para>
<informalexample>
<programlisting><xi:include href="../../../../examples/application1/exampleapp.c" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/application1/exampleapp.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</informalexample>
<para>Another important class that is part of the application support
@@ -373,7 +373,7 @@
window.</para>
<informalexample>
<programlisting><xi:include href="../../../../examples/application1/exampleappwin.c" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/application1/exampleappwin.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</informalexample>
<para>As part of the initial setup of our application, we also
@@ -388,7 +388,7 @@
</informalfigure>
<informalexample>
<programlisting><xi:include href="../../../../examples/application1/exampleapp.desktop" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/application1/exampleapp.desktop" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</informalexample>
<para>Note that <replaceable>@<!-- -->bindir@</replaceable> needs to be replaced
@@ -420,7 +420,7 @@
</para>
<informalexample>
<programlisting><xi:include href="../../../../examples/application2/window.ui" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/application2/window.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</informalexample>
<para>To make use of this file in our application, we revisit
@@ -460,7 +460,7 @@ example_app_window_class_init (ExampleAppWindowClass *class)
</para>
<informalexample>
<programlisting><xi:include href="../../../../examples/application2/exampleapp.gresource.xml" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/application2/exampleapp.gresource.xml" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</informalexample>
<para>This file has to be converted into a C source file that will be
@@ -598,7 +598,7 @@ example_app_window_open (ExampleAppWindow *win,
in a ui file, and add it as a resource to our binary.</para>
<informalexample>
<programlisting><xi:include href="../../../../examples/application4/app-menu.ui" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/application4/app-menu.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</informalexample>
<para>To associate the app menu with the application, we have to call
@@ -697,7 +697,7 @@ example_app_class_init (ExampleAppClass *class)
GSettings requires a schema that describes our settings:</para>
<informalexample>
<programlisting><xi:include href="../../../../examples/application5/org.gtk.exampleapp.gschema.xml" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/application5/org.gtk.exampleapp.gschema.xml" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</informalexample>
<para>Before we can make use of this schema in our application,
@@ -749,13 +749,13 @@ example_app_window_init (ExampleAppWindow *win)
<para>Lets start with the template.</para>
<informalexample>
<programlisting><xi:include href="../../../../examples/application6/prefs.ui" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/application6/prefs.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</informalexample>
<para>Next comes the dialog subclass.</para>
<informalexample>
<programlisting><xi:include href="../../../../examples/application6/exampleappprefs.c" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/application6/exampleappprefs.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</informalexample>
<para>Now we revisit the <literal>preferences_activated(<!-- -->)</literal> function in our
@@ -807,7 +807,7 @@ preferences_activated (GSimpleAction *action,
to slide out the search bar below the header bar.</para>
<informalexample>
<programlisting><xi:include href="../../../../examples/application7/window.ui" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/application7/window.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</informalexample>
<para>Implementing the search needs quite a few code changes that
@@ -887,7 +887,7 @@ example_app_window_init (ExampleAppWindow *win)
which demonstrates #GtkMenuButton, #GtkRevealer and #GtkListBox.</para>
<informalexample>
<programlisting><xi:include href="../../../../examples/application8/window.ui" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/application8/window.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</informalexample>
<para>The code to populate the sidebar with buttons for the words
@@ -898,7 +898,7 @@ example_app_window_init (ExampleAppWindow *win)
ui file.</para>
<informalexample>
<programlisting><xi:include href="../../../../examples/application8/gears-menu.ui" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/application8/gears-menu.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</informalexample>
<para>To connect the menuitem to the show-words setting, we use
@@ -957,7 +957,7 @@ example_app_window_init (ExampleAppWindow *win)
triggers the show-lines action:</para>
<informalexample>
<programlisting><xi:include href="../../../../examples/application9/gears-menu.ui" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/application9/gears-menu.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</informalexample>
<para>To make this menu item do something, we create a property
@@ -1017,7 +1017,7 @@ example_app_window_init (ExampleAppWindow *win)
be a direct child of the window, and set its type to be titlebar.</para>
<informalexample>
<programlisting><xi:include href="../../../../examples/application10/window.ui" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/application10/window.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</informalexample>
<para>A small extra bonus of using a header bar is that we get
@@ -1073,7 +1073,7 @@ example_app_window_init (ExampleAppWindow *win)
<example id="gtk-getting-started-drawing">
<title>Drawing in response to input</title>
<para>Create a new file with the following content named example-3.c.</para>
<programlisting><xi:include href="../../../../examples/drawing.c" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
<programlisting><xi:include href="../../../../examples/drawing.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</example>
<para>
You can compile the program above with GCC using:
+4
View File
@@ -488,6 +488,10 @@
<title>Index of new symbols in 3.20</title>
<xi:include href="xml/api-index-3.20.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-3-22" role="3.22">
<title>Index of new symbols in 3.22</title>
<xi:include href="xml/api-index-3.22.xml"><xi:fallback /></xi:include>
</index>
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
+1
View File
@@ -6625,6 +6625,7 @@ gtk_clipboard_wait_for_targets
gtk_clipboard_wait_is_target_available
gtk_clipboard_set_can_store
gtk_clipboard_store
gtk_clipboard_get_selection
<SUBSECTION Standard>
GTK_CLIPBOARD
GTK_TYPE_CLIPBOARD
+4
View File
@@ -138,6 +138,10 @@
* Devices may also have associated “keys” or
* macro buttons. Such keys can be globally set to map into normal X
* keyboard events. The mapping is set using gdk_device_set_key().
*
* In GTK+ 3.20, a new #GdkSeat object has been introduced that
* supersedes #GdkDeviceManager and should be preferred in newly
* written code.
*/
static void gdk_device_manager_set_property (GObject *object,
+24
View File
@@ -162,6 +162,16 @@
*/
#define GDK_VERSION_3_20 (G_ENCODE_VERSION (3, 20))
/**
* GDK_VERSION_3_22:
*
* A macro that evaluates to the 3.22 version of GDK, in a format
* that can be used by the C pre-processor.
*
* Since: 3.20
*/
#define GDK_VERSION_3_22 (G_ENCODE_VERSION (3, 22))
/* evaluates to the current stable version; for development cycles,
* this means the next stable target
*/
@@ -388,5 +398,19 @@
# define GDK_AVAILABLE_IN_3_20 _GDK_EXTERN
#endif
#if GDK_VERSION_MIN_REQUIRED >= GDK_VERSION_3_22
# define GDK_DEPRECATED_IN_3_22 GDK_DEPRECATED
# define GDK_DEPRECATED_IN_3_22_FOR(f) GDK_DEPRECATED_FOR(f)
#else
# define GDK_DEPRECATED_IN_3_22 _GDK_EXTERN
# define GDK_DEPRECATED_IN_3_22_FOR(f) _GDK_EXTERN
#endif
#if GDK_VERSION_MAX_ALLOWED < GDK_VERSION_3_22
# define GDK_AVAILABLE_IN_3_22 GDK_UNAVAILABLE(3, 22)
#else
# define GDK_AVAILABLE_IN_3_22 _GDK_EXTERN
#endif
#endif /* __GDK_VERSION_MACROS_H__ */
+16 -1
View File
@@ -303,9 +303,15 @@ gdk_visual_get_depth (GdkVisual *visual)
*
* Returns the byte order of this visual.
*
* The information returned by this function is only relevant
* when working with XImages, and not all backends return
* meaningful information for this.
*
* Returns: A #GdkByteOrder stating the byte order of @visual.
*
* Since: 2.22
*
* Deprecated: 3.22: This information is not useful
*/
GdkByteOrder
gdk_visual_get_byte_order (GdkVisual *visual)
@@ -321,9 +327,14 @@ gdk_visual_get_byte_order (GdkVisual *visual)
*
* Returns the size of a colormap for this visual.
*
* You have to use platform-specific APIs to manipulate colormaps.
*
* Returns: The size of a colormap that is suitable for @visual.
*
* Since: 2.22
*
* Deprecated: 3.22: This information is not useful, since GDK does not
* provide APIs to operate on colormaps.
*/
gint
gdk_visual_get_colormap_size (GdkVisual *visual)
@@ -339,9 +350,14 @@ gdk_visual_get_colormap_size (GdkVisual *visual)
*
* Returns the number of significant bits per red, green and blue value.
*
* Not all GDK backend provide a meaningful value for this function.
*
* Returns: The number of significant bits per color value for @visual.
*
* Since: 2.22
*
* Deprecated: 3.22. Use gdk_visual_get_red_pixel_details() and its variants to
* learn about the pixel layout of TrueColor and DirectColor visuals
*/
gint
gdk_visual_get_bits_per_rgb (GdkVisual *visual)
@@ -371,7 +387,6 @@ gdk_visual_get_pixel_details (GdkVisual *visual,
m >>= 1;
}
m = pixel_mask;
while (m & 0x1)
{
p++;
+3 -3
View File
@@ -115,11 +115,11 @@ GDK_AVAILABLE_IN_ALL
GdkVisualType gdk_visual_get_visual_type (GdkVisual *visual);
GDK_AVAILABLE_IN_ALL
gint gdk_visual_get_depth (GdkVisual *visual);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_22
GdkByteOrder gdk_visual_get_byte_order (GdkVisual *visual);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_22
gint gdk_visual_get_colormap_size (GdkVisual *visual);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_22
gint gdk_visual_get_bits_per_rgb (GdkVisual *visual);
GDK_AVAILABLE_IN_ALL
void gdk_visual_get_red_pixel_details (GdkVisual *visual,
+63 -29
View File
@@ -4078,44 +4078,77 @@ gdk_window_invalidate_maybe_recurse_full (GdkWindow *window,
GdkWindowChildFunc child_func,
gpointer user_data);
/* Returns true if window is a decendant of parent, but stops looking
* at the first native window. Also ensures that all parents match
* child_func if non-null..
*
* This is useful in combination with
* window->impl_window->native_children as it lets you find all native
* decendants in an efficient way (assuming few children are native).
*/
static gboolean
has_visible_ancestor_in_impl (GdkWindow *window,
GdkWindow *ancestor,
GdkWindowChildFunc child_func,
gpointer user_data)
{
GdkWindow *p;
GdkWindow *stop_at;
p = window->parent;
stop_at = p->impl_window;
while (p != NULL)
{
if (!p->viewable)
return FALSE;
if (child_func &&
!(*child_func) ((GdkWindow *)p, user_data))
return FALSE;
if (p == ancestor)
return TRUE;
if (p == stop_at)
return FALSE;
p = p->parent;
}
return FALSE;
}
static void
invalidate_impl_subwindows (GdkWindow *window,
const cairo_region_t *region,
GdkWindowChildFunc child_func,
gpointer user_data,
int dx, int dy)
gpointer user_data)
{
GList *tmp_list;
GList *l;
tmp_list = window->children;
while (tmp_list)
/* Iterate over all native children of the native window
that window is in. */
for (l = window->impl_window->native_children;
l != NULL;
l = l->next)
{
GdkWindow *child = tmp_list->data;
tmp_list = tmp_list->next;
GdkWindow *native_child = l->data;
cairo_region_t *tmp;
int dx, dy;
if (child->input_only ||
!window->viewable)
if (native_child->input_only)
continue;
if (child_func && (*child_func) ((GdkWindow *)child, user_data))
{
if (gdk_window_has_impl (child))
{
cairo_region_t *tmp = cairo_region_copy (region);
cairo_region_translate (tmp, -dx - child->x, -dy - child->y);
gdk_window_invalidate_maybe_recurse_full (child,
tmp, child_func, user_data);
cairo_region_destroy (tmp);
}
else
{
invalidate_impl_subwindows (child,
region,
child_func, user_data,
dx + child->x, dy + child->y);
}
}
/* Then skip any that does not have window as an ancestor,
* also checking that the ancestors are visible and pass child_func
* This is fast if we assume native children are rare */
if (!has_visible_ancestor_in_impl (native_child, window,
child_func, user_data))
continue;
dx = native_child->parent->abs_x + native_child->x - window->abs_x;
dy = native_child->parent->abs_y + native_child->y - window->abs_y;
tmp = cairo_region_copy (region);
cairo_region_translate (tmp, -dx, -dy);
gdk_window_invalidate_maybe_recurse_full (native_child,
tmp, child_func, user_data);
cairo_region_destroy (tmp);
}
}
@@ -4145,7 +4178,8 @@ gdk_window_invalidate_maybe_recurse_full (GdkWindow *window,
visible_region = cairo_region_copy (region);
invalidate_impl_subwindows (window, region, child_func, user_data, 0, 0);
if (child_func)
invalidate_impl_subwindows (window, region, child_func, user_data);
display = gdk_window_get_display (window);
if (gdk_display_get_debug_updates (display))
+3 -3
View File
@@ -2893,11 +2893,11 @@ gdk_wayland_seat_get_slaves (GdkSeat *seat,
GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat);
GList *slaves = NULL;
if (capabilities & GDK_SEAT_CAPABILITY_POINTER)
if (wayland_seat->pointer && (capabilities & GDK_SEAT_CAPABILITY_POINTER))
slaves = g_list_prepend (slaves, wayland_seat->pointer);
if (capabilities & GDK_SEAT_CAPABILITY_KEYBOARD)
if (wayland_seat->keyboard && (capabilities & GDK_SEAT_CAPABILITY_KEYBOARD))
slaves = g_list_prepend (slaves, wayland_seat->keyboard);
if (capabilities & GDK_SEAT_CAPABILITY_TOUCH)
if (wayland_seat->touch && (capabilities & GDK_SEAT_CAPABILITY_TOUCH))
slaves = g_list_prepend (slaves, wayland_seat->touch);
return slaves;
+92
View File
@@ -230,6 +230,97 @@ postpone_on_globals_closure (GdkWaylandDisplay *display_wayland,
g_list_append (display_wayland->on_has_globals_closures, closure);
}
#ifdef G_ENABLE_DEBUG
static const char *
get_format_name (enum wl_shm_format format)
{
int i;
#define FORMAT(s) { WL_SHM_FORMAT_ ## s, #s }
struct { int format; const char *name; } formats[] = {
FORMAT(ARGB8888),
FORMAT(XRGB8888),
FORMAT(C8),
FORMAT(RGB332),
FORMAT(BGR233),
FORMAT(XRGB4444),
FORMAT(XBGR4444),
FORMAT(RGBX4444),
FORMAT(BGRX4444),
FORMAT(ARGB4444),
FORMAT(ABGR4444),
FORMAT(RGBA4444),
FORMAT(BGRA4444),
FORMAT(XRGB1555),
FORMAT(XBGR1555),
FORMAT(RGBX5551),
FORMAT(BGRX5551),
FORMAT(ARGB1555),
FORMAT(ABGR1555),
FORMAT(RGBA5551),
FORMAT(BGRA5551),
FORMAT(RGB565),
FORMAT(BGR565),
FORMAT(RGB888),
FORMAT(BGR888),
FORMAT(XBGR8888),
FORMAT(RGBX8888),
FORMAT(BGRX8888),
FORMAT(ABGR8888),
FORMAT(RGBA8888),
FORMAT(BGRA8888),
FORMAT(XRGB2101010),
FORMAT(XBGR2101010),
FORMAT(RGBX1010102),
FORMAT(BGRX1010102),
FORMAT(ARGB2101010),
FORMAT(ABGR2101010),
FORMAT(RGBA1010102),
FORMAT(BGRA1010102),
FORMAT(YUYV),
FORMAT(YVYU),
FORMAT(UYVY),
FORMAT(VYUY),
FORMAT(AYUV),
FORMAT(NV12),
FORMAT(NV21),
FORMAT(NV16),
FORMAT(NV61),
FORMAT(YUV410),
FORMAT(YVU410),
FORMAT(YUV411),
FORMAT(YVU411),
FORMAT(YUV420),
FORMAT(YVU420),
FORMAT(YUV422),
FORMAT(YVU422),
FORMAT(YUV444),
FORMAT(YVU444),
{ 0xffffffff, NULL }
};
#undef FORMAT
for (i = 0; formats[i].name; i++)
{
if (formats[i].format == format)
return formats[i].name;
}
return NULL;
}
#endif
static void
wl_shm_format (void *data,
struct wl_shm *wl_shm,
uint32_t format)
{
GDK_NOTE (MISC, g_message ("supported pixel format %s", get_format_name (format)));
}
static const struct wl_shm_listener wl_shm_listener = {
wl_shm_format
};
static void
gdk_registry_handle_global (void *data,
struct wl_registry *registry,
@@ -254,6 +345,7 @@ gdk_registry_handle_global (void *data,
{
display_wayland->shm =
wl_registry_bind (display_wayland->wl_registry, id, &wl_shm_interface, 1);
wl_shm_add_listener (display_wayland->shm, &wl_shm_listener, display_wayland);
}
else if (strcmp (interface, "xdg_shell") == 0)
{
+4 -1
View File
@@ -133,10 +133,13 @@ gdk_wayland_keymap_get_entries_for_keyval (GdkKeymap *keymap,
struct xkb_keymap *xkb_keymap = GDK_WAYLAND_KEYMAP (keymap)->xkb_keymap;
GArray *retval;
guint keycode;
xkb_keycode_t min_keycode, max_keycode;
retval = g_array_new (FALSE, FALSE, sizeof (GdkKeymapKey));
for (keycode = 8; keycode < 255; keycode++) /* FIXME: min/max keycode */
min_keycode = xkb_keymap_min_keycode (xkb_keymap);
max_keycode = xkb_keymap_max_keycode (xkb_keymap);
for (keycode = min_keycode; keycode < max_keycode; keycode++)
{
gint num_layouts, layout;
num_layouts = xkb_keymap_num_layouts_for_key (xkb_keymap, keycode);
+70 -10
View File
@@ -66,7 +66,6 @@ struct _GdkWaylandScreen
/* Xinerama/RandR 1.2 */
GPtrArray *monitors;
gint primary_monitor;
GHashTable *settings;
GsdXftSettings xft_settings;
@@ -77,8 +76,6 @@ struct _GdkWaylandScreen
struct _GdkWaylandScreenClass
{
GdkScreenClass parent_class;
void (* window_manager_changed) (GdkWaylandScreen *screen_wayland);
};
#define OUTPUT_VERSION_WITH_DONE 2
@@ -133,7 +130,6 @@ init_multihead (GdkScreen *screen)
GdkWaylandScreen *screen_wayland = GDK_WAYLAND_SCREEN (screen);
screen_wayland->monitors = g_ptr_array_new_with_free_func (free_monitor);
screen_wayland->primary_monitor = 0;
}
static void
@@ -215,7 +211,7 @@ gdk_wayland_screen_get_n_monitors (GdkScreen *screen)
static gint
gdk_wayland_screen_get_primary_monitor (GdkScreen *screen)
{
return GDK_WAYLAND_SCREEN (screen)->primary_monitor;
return 0;
}
static gint
@@ -864,14 +860,20 @@ static GdkVisual*
gdk_wayland_screen_visual_get_best_with_depth (GdkScreen *screen,
gint depth)
{
return GDK_WAYLAND_SCREEN (screen)->visual;
if (depth == 32)
return GDK_WAYLAND_SCREEN (screen)->visual;
else
return NULL;
}
static GdkVisual*
gdk_wayland_screen_visual_get_best_with_type (GdkScreen *screen,
GdkVisualType visual_type)
{
return GDK_WAYLAND_SCREEN (screen)->visual;
if (visual_type == GDK_VISUAL_TRUE_COLOR)
return GDK_WAYLAND_SCREEN (screen)->visual;
else
return NULL;
}
static GdkVisual*
@@ -879,7 +881,10 @@ gdk_wayland_screen_visual_get_best_with_both (GdkScreen *screen,
gint depth,
GdkVisualType visual_type)
{
return GDK_WAYLAND_SCREEN (screen)->visual;
if (depth == 32 && visual_type == GDK_VISUAL_TRUE_COLOR)
return GDK_WAYLAND_SCREEN (screen)->visual;
else
return NULL;
}
static void
@@ -921,6 +926,8 @@ gdk_wayland_screen_list_visuals (GdkScreen *screen)
#define GDK_TYPE_WAYLAND_VISUAL (_gdk_wayland_visual_get_type ())
#define GDK_WAYLAND_VISUAL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_VISUAL, GdkWaylandVisual))
/* Currently, the Wayland backend only ever uses ARGB8888.
*/
static GdkVisual *
gdk_wayland_visual_new (GdkScreen *screen)
{
@@ -930,6 +937,9 @@ gdk_wayland_visual_new (GdkScreen *screen)
visual->screen = GDK_SCREEN (screen);
visual->type = GDK_VISUAL_TRUE_COLOR;
visual->depth = 32;
visual->red_mask = 0xff0000;
visual->green_mask = 0x00ff00;
visual->blue_mask = 0x0000ff;
visual->bits_per_rgb = 8;
return visual;
@@ -1061,6 +1071,56 @@ update_screen_size (GdkWaylandScreen *screen_wayland)
g_signal_emit_by_name (screen_wayland, "size-changed");
}
#ifdef G_ENABLE_DEBUG
static const char *
subpixel_to_string (int layout)
{
int i;
struct { int layout; const char *name; } layouts[] = {
{ WL_OUTPUT_SUBPIXEL_UNKNOWN, "unknown" },
{ WL_OUTPUT_SUBPIXEL_NONE, "none" },
{ WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB, "rgb" },
{ WL_OUTPUT_SUBPIXEL_HORIZONTAL_BGR, "bgr" },
{ WL_OUTPUT_SUBPIXEL_VERTICAL_RGB, "vrgb" },
{ WL_OUTPUT_SUBPIXEL_VERTICAL_BGR, "vbgr" },
{ 0xffffffff, NULL }
};
for (i = 0; layouts[i].name; i++)
{
if (layouts[i].layout == layout)
return layouts[i].name;
}
return NULL;
}
static const char *
transform_to_string (int transform)
{
int i;
struct { int transform; const char *name; } transforms[] = {
{ WL_OUTPUT_TRANSFORM_NORMAL, "normal" },
{ WL_OUTPUT_TRANSFORM_90, "90" },
{ WL_OUTPUT_TRANSFORM_180, "180" },
{ WL_OUTPUT_TRANSFORM_270, "270" },
{ WL_OUTPUT_TRANSFORM_FLIPPED, "flipped" },
{ WL_OUTPUT_TRANSFORM_FLIPPED_90, "flipped 90" },
{ WL_OUTPUT_TRANSFORM_FLIPPED_180, "flipped 180" },
{ WL_OUTPUT_TRANSFORM_FLIPPED_270, "flipped 270" },
{ 0xffffffff, NULL }
};
for (i = 0; transforms[i].name; i++)
{
if (transforms[i].transform == transform)
return transforms[i].name;
}
return NULL;
}
#endif
static void
output_handle_geometry (void *data,
struct wl_output *wl_output,
@@ -1076,8 +1136,8 @@ output_handle_geometry (void *data,
GdkWaylandMonitor *monitor = (GdkWaylandMonitor *)data;
GDK_NOTE (MISC,
g_message ("handle geometry output %d, position %d %d, phys. size %d %d, manufacturer %s, model %s",
monitor->id, x, y, physical_width, physical_height, make, model));
g_message ("handle geometry output %d, position %d %d, phys. size %d %d, subpixel layout %s, manufacturer %s, model %s, transform %s",
monitor->id, x, y, physical_width, physical_height, subpixel_to_string (subpixel), make, model, transform_to_string (transform)));
monitor->geometry.x = x;
monitor->geometry.y = y;
+26 -20
View File
@@ -380,38 +380,46 @@ inner_clipboard_window_procedure (HWND hwnd,
case WM_CLIPBOARDUPDATE:
case WM_DRAWCLIPBOARD:
{
int success;
HWND hwndOwner;
#ifdef G_ENABLE_DEBUG
UINT nFormat = 0;
#endif
HWND hwnd_owner;
HWND hwnd_opener;
GdkEvent *event;
GdkWindow *owner;
success = OpenClipboard (hwnd);
if (!success)
{
g_warning ("Failed to OpenClipboard on window handle %p", hwnd);
return 0;
}
hwnd_owner = GetClipboardOwner ();
hwndOwner = GetClipboardOwner ();
owner = gdk_win32_window_lookup_for_display (_gdk_display, hwndOwner);
if (owner == NULL)
owner = gdk_win32_window_foreign_new_for_display (_gdk_display, hwndOwner);
if ((hwnd_owner == NULL) &&
(GetLastError () != ERROR_SUCCESS))
WIN32_API_FAILED ("GetClipboardOwner");
GDK_NOTE (DND, g_print (" drawclipboard owner: %p", hwndOwner));
hwnd_opener = GetOpenClipboardWindow ();
GDK_NOTE (DND, g_print (" drawclipboard owner: %p; opener %p ", hwnd_owner, hwnd_opener));
#ifdef G_ENABLE_DEBUG
if (_gdk_debug_flags & GDK_DEBUG_DND)
{
while ((nFormat = EnumClipboardFormats (nFormat)) != 0)
g_print ("%s ", _gdk_win32_cf_to_string (nFormat));
if (OpenClipboard (hwnd))
{
UINT nFormat = 0;
while ((nFormat = EnumClipboardFormats (nFormat)) != 0)
g_print ("%s ", _gdk_win32_cf_to_string (nFormat));
CloseClipboard ();
}
else
{
WIN32_API_FAILED ("OpenClipboard");
}
}
#endif
GDK_NOTE (DND, g_print (" \n"));
owner = gdk_win32_window_lookup_for_display (_gdk_display, hwnd_owner);
if (owner == NULL)
owner = gdk_win32_window_foreign_new_for_display (_gdk_display, hwnd_owner);
event = gdk_event_new (GDK_OWNER_CHANGE);
event->owner_change.window = gdk_get_default_root_window ();
event->owner_change.owner = owner;
@@ -421,8 +429,6 @@ inner_clipboard_window_procedure (HWND hwnd,
event->owner_change.selection_time = GDK_CURRENT_TIME;
_gdk_win32_append_event (event);
CloseClipboard ();
if (_hwnd_next_viewer != NULL)
return SendMessage (_hwnd_next_viewer, message, wparam, lparam);
+148 -8
View File
@@ -278,10 +278,11 @@ _gdk_win32_window_procedure (HWND hwnd,
{
LRESULT retval;
GDK_NOTE (EVENTS, g_print ("%s%*s%s %p",
GDK_NOTE (EVENTS, g_print ("%s%*s%s %p %#x %#lx",
(debug_indent > 0 ? "\n" : ""),
debug_indent, "",
_gdk_win32_message_to_string (message), hwnd));
_gdk_win32_message_to_string (message), hwnd,
wparam, lparam));
debug_indent += 2;
retval = inner_window_procedure (hwnd, message, wparam, lparam);
debug_indent -= 2;
@@ -679,7 +680,9 @@ _gdk_win32_print_event (const GdkEvent *event)
default: g_assert_not_reached ();
}
g_print (" %p ", event->any.window ? GDK_WINDOW_HWND (event->any.window) : NULL);
g_print (" %p @ %ums ",
event->any.window ? GDK_WINDOW_HWND (event->any.window) : NULL,
gdk_event_get_time (event));
switch (event->any.type)
{
@@ -1053,17 +1056,17 @@ show_window_recurse (GdkWindow *window, gboolean hide_window)
{
if (gdk_window_get_state (window) & GDK_WINDOW_STATE_MAXIMIZED)
{
ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWMAXIMIZED);
GtkShowWindow (GDK_WINDOW_HWND (window), SW_SHOWMAXIMIZED);
}
else
{
ShowWindow (GDK_WINDOW_HWND (window), SW_RESTORE);
GtkShowWindow (GDK_WINDOW_HWND (window), SW_RESTORE);
}
}
}
else
{
ShowWindow (GDK_WINDOW_HWND (window), SW_MINIMIZE);
GtkShowWindow (GDK_WINDOW_HWND (window), SW_MINIMIZE);
}
}
@@ -1907,6 +1910,77 @@ ensure_stacking_on_activate_app (MSG *msg,
}
}
static gboolean
handle_wm_sysmenu (GdkWindow *window, MSG *msg, gint *ret_valp)
{
GdkWindowImplWin32 *impl;
LONG_PTR style, tmp_style;
gboolean maximized, minimized;
LONG_PTR additional_styles;
impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
style = GetWindowLongPtr (msg->hwnd, GWL_STYLE);
maximized = IsZoomed (msg->hwnd);
minimized = IsIconic (msg->hwnd);
additional_styles = 0;
if (!(style & WS_SYSMENU))
additional_styles |= WS_SYSMENU;
if (!maximized && !(style & WS_MAXIMIZEBOX))
additional_styles |= WS_MAXIMIZEBOX;
if (!minimized && !(style & WS_MINIMIZEBOX))
additional_styles |= WS_MINIMIZEBOX;
if (!minimized && !maximized && !(style & WS_SIZEBOX))
additional_styles |= WS_SIZEBOX;
if (additional_styles == 0)
/* The caller will eventually pass this to DefWindowProc (),
* only without the style dance, which isn't needed, as it turns out.
*/
return FALSE;
/* Note: This code will enable resizing, maximizing and minimizing windows
* via window menu even if these are non-CSD windows that were explicitly
* forbidden from doing this by removing the appropriate styles,
* or if these are CSD windows that were explicitly forbidden from doing
* this by removing appropriate decorations from the headerbar and/or
* changing hints or properties.
*
* If doing this for non-CSD windows is not desired,
* do a _gdk_win32_window_lacks_wm_decorations() check and return FALSE
* if it doesn't pass.
*
* If doing this for CSD windows with disabled decorations is not desired,
* tough luck - GDK can't know which CSD decorations are enabled, and which
* are not.
*
* If doing this for CSD windows with particular hints is not desired,
* check window hints here and return FALSE (DefWindowProc() will return
* FALSE later) or set *ret_valp to 0 and return TRUE.
*/
tmp_style = style | additional_styles;
GDK_NOTE (EVENTS, g_print (" Handling WM_SYSMENU: style 0x%lx -> 0x%lx\n", style, tmp_style));
impl->have_temp_styles = TRUE;
impl->temp_styles = additional_styles;
SetWindowLongPtr (msg->hwnd, GWL_STYLE, tmp_style);
*ret_valp = DefWindowProc (msg->hwnd, msg->message, msg->wParam, msg->lParam);
tmp_style = GetWindowLongPtr (msg->hwnd, GWL_STYLE);
style = tmp_style & ~additional_styles;
GDK_NOTE (EVENTS, g_print (" Handling WM_SYSMENU: style 0x%lx <- 0x%lx\n", style, tmp_style));
SetWindowLongPtr (msg->hwnd, GWL_STYLE, style);
impl->have_temp_styles = FALSE;
return TRUE;
}
gboolean
_gdk_win32_window_fill_min_max_info (GdkWindow *window,
MINMAXINFO *mmi)
@@ -1970,8 +2044,8 @@ _gdk_win32_window_fill_min_max_info (GdkWindow *window,
mmi->ptMaxSize.y = nearest_info.rcWork.bottom - nearest_info.rcWork.top;
}
mmi->ptMaxTrackSize.x = GetSystemMetrics (SM_CXMAXTRACK);
mmi->ptMaxTrackSize.y = GetSystemMetrics (SM_CYMAXTRACK);
mmi->ptMaxTrackSize.x = GetSystemMetrics (SM_CXVIRTUALSCREEN) + impl->margins_x;
mmi->ptMaxTrackSize.y = GetSystemMetrics (SM_CYVIRTUALSCREEN) + impl->margins_y;
}
return TRUE;
@@ -2214,6 +2288,48 @@ gdk_event_translate (MSG *msg,
if (GDK_WINDOW_DESTROYED (window))
break;
if (msg->message == WM_KEYUP &&
!GDK_WINDOW_DESTROYED (gdk_window_get_toplevel (window)) &&
_gdk_win32_window_lacks_wm_decorations (gdk_window_get_toplevel (window)) && /* For CSD only */
((GetKeyState (VK_LWIN) & 0x8000) ||
(GetKeyState (VK_RWIN) & 0x8000)))
{
GdkWin32AeroSnapCombo combo = GDK_WIN32_AEROSNAP_COMBO_NOTHING;
gboolean lshiftdown = GetKeyState (VK_LSHIFT) & 0x8000;
gboolean rshiftdown = GetKeyState (VK_RSHIFT) & 0x8000;
gboolean oneshiftdown = (lshiftdown || rshiftdown) && !(lshiftdown && rshiftdown);
switch (msg->wParam)
{
case VK_UP:
combo = GDK_WIN32_AEROSNAP_COMBO_UP;
break;
case VK_DOWN:
combo = GDK_WIN32_AEROSNAP_COMBO_DOWN;
break;
case VK_LEFT:
combo = GDK_WIN32_AEROSNAP_COMBO_LEFT;
break;
case VK_RIGHT:
combo = GDK_WIN32_AEROSNAP_COMBO_RIGHT;
break;
}
if (oneshiftdown && combo != GDK_WIN32_AEROSNAP_COMBO_NOTHING)
combo += 4;
/* These are the only combos that Windows WM does handle for us */
if (combo == GDK_WIN32_AEROSNAP_COMBO_SHIFTLEFT ||
combo == GDK_WIN32_AEROSNAP_COMBO_SHIFTRIGHT)
combo = GDK_WIN32_AEROSNAP_COMBO_NOTHING;
if (combo != GDK_WIN32_AEROSNAP_COMBO_NOTHING)
{
_gdk_win32_window_handle_aerosnap (gdk_window_get_toplevel (window), combo);
break;
}
}
event = gdk_event_new ((msg->message == WM_KEYDOWN ||
msg->message == WM_SYSKEYDOWN) ?
GDK_KEY_PRESS : GDK_KEY_RELEASE);
@@ -2856,6 +2972,30 @@ gdk_event_translate (MSG *msg,
}
break;
case WM_SYSMENU:
return_val = handle_wm_sysmenu (window, msg, ret_valp);
break;
case WM_INITMENU:
impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
if (impl->have_temp_styles)
{
LONG_PTR window_style;
window_style = GetWindowLongPtr (GDK_WINDOW_HWND (window),
GWL_STYLE);
/* Handling WM_SYSMENU added extra styles to this window,
* remove them now.
*/
window_style &= ~impl->temp_styles;
SetWindowLongPtr (GDK_WINDOW_HWND (window),
GWL_STYLE,
window_style);
}
break;
case WM_SYSCOMMAND:
switch (msg->wParam)
{
+4 -3
View File
@@ -134,10 +134,11 @@ _gdk_win32_windowing_init (void)
void
_gdk_win32_api_failed (const gchar *where,
const gchar *api)
const gchar *api)
{
gchar *msg = g_win32_error_message (GetLastError ());
g_warning ("%s: %s failed: %s", where, api, msg);
DWORD error_code = GetLastError ();
gchar *msg = g_win32_error_message (error_code);
g_warning ("%s: %s failed with code %lu: %s", where, api, error_code, msg);
g_free (msg);
}
+18
View File
@@ -97,6 +97,18 @@
#define WM_MOUSEHWHEEL 0x20E
#endif
/* According to
* http://blog.airesoft.co.uk/2009/11/wm_messages/
* this is the actual internal name MS uses for this undocumented message.
* According to
* https://bugs.winehq.org/show_bug.cgi?id=15055
* wParam is 0
* lParam is a pair of virtual desktop coordinates for the popup
*/
#ifndef WM_SYSMENU
#define WM_SYSMENU 0x313
#endif
#ifndef CF_DIBV5
#define CF_DIBV5 17
#endif
@@ -524,6 +536,9 @@ void _gdk_win32_emit_configure_event (GdkWindow *window);
guint32 _gdk_win32_keymap_get_decimal_mark (void);
void _gdk_win32_window_handle_aerosnap (GdkWindow *window,
GdkWin32AeroSnapCombo combo);
gboolean _gdk_win32_get_window_rect (GdkWindow *window,
RECT *rect);
void _gdk_win32_do_emit_configure_event (GdkWindow *window,
@@ -537,6 +552,9 @@ gboolean _gdk_win32_window_fill_min_max_info (GdkWindow *window,
gboolean _gdk_win32_window_lacks_wm_decorations (GdkWindow *window);
BOOL WINAPI GtkShowWindow (HWND hwnd,
int cmd_show);
/* Initialization */
void _gdk_win32_windowing_init (void);
void _gdk_dnd_init (void);
+7 -6
View File
@@ -194,12 +194,6 @@ _gdk_win32_window_change_property (GdkWindow *window,
if (type == _utf8_string)
{
if (!OpenClipboard (GDK_WINDOW_HWND (window)))
{
WIN32_API_FAILED ("OpenClipboard");
return;
}
wcptr = g_utf8_to_utf16 ((char *) data, nelements, NULL, &wclen, &err);
if (err != NULL)
{
@@ -208,6 +202,13 @@ _gdk_win32_window_change_property (GdkWindow *window,
return;
}
if (!OpenClipboard (GDK_WINDOW_HWND (window)))
{
WIN32_API_FAILED ("OpenClipboard");
g_free (wcptr);
return;
}
wclen++; /* Terminating 0 */
size = wclen * 2;
for (i = 0; i < wclen; i++)
+2 -2
View File
@@ -492,6 +492,8 @@ _gdk_win32_display_convert_selection (GdkDisplay *display,
}
}
API_CALL (CloseClipboard, ());
GDK_NOTE (DND, {
int i;
@@ -514,8 +516,6 @@ _gdk_win32_display_convert_selection (GdkDisplay *display,
ntargets * sizeof (GdkAtom));
else
property = GDK_NONE;
API_CALL (CloseClipboard, ());
}
else if (selection == GDK_SELECTION_CLIPBOARD && target == _utf8_string)
{
File diff suppressed because it is too large Load Diff
+152
View File
@@ -46,6 +46,46 @@ typedef struct _GdkWindowImplWin32Class GdkWindowImplWin32Class;
#define GDK_IS_WINDOW_IMPL_WIN32_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WINDOW_IMPL_WIN32))
#define GDK_WINDOW_IMPL_WIN32_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WINDOW_IMPL_WIN32, GdkWindowImplWin32Class))
enum _GdkWin32AeroSnapCombo
{
GDK_WIN32_AEROSNAP_COMBO_NOTHING = 0,
GDK_WIN32_AEROSNAP_COMBO_UP,
GDK_WIN32_AEROSNAP_COMBO_DOWN,
GDK_WIN32_AEROSNAP_COMBO_LEFT,
GDK_WIN32_AEROSNAP_COMBO_RIGHT,
/* Same order as non-shift variants. We use it to do things like:
* AEROSNAP_UP + 4 = AEROSNAP_SHIFTUP
*/
GDK_WIN32_AEROSNAP_COMBO_SHIFTUP,
GDK_WIN32_AEROSNAP_COMBO_SHIFTDOWN,
GDK_WIN32_AEROSNAP_COMBO_SHIFTLEFT,
GDK_WIN32_AEROSNAP_COMBO_SHIFTRIGHT
};
typedef enum _GdkWin32AeroSnapCombo GdkWin32AeroSnapCombo;
enum _GdkWin32AeroSnapState
{
GDK_WIN32_AEROSNAP_STATE_UNDETERMINED = 0,
GDK_WIN32_AEROSNAP_STATE_HALFLEFT,
GDK_WIN32_AEROSNAP_STATE_HALFRIGHT,
GDK_WIN32_AEROSNAP_STATE_FULLUP,
/* Maximize state is only used by edge-snap */
GDK_WIN32_AEROSNAP_STATE_MAXIMIZE
};
typedef enum _GdkWin32AeroSnapState GdkWin32AeroSnapState;
struct _GdkRectangleDouble
{
gdouble x;
gdouble y;
gdouble width;
gdouble height;
};
typedef struct _GdkRectangleDouble GdkRectangleDouble;
enum _GdkW32WindowDragOp
{
GDK_WIN32_DRAGOP_NONE = 0,
@@ -58,6 +98,9 @@ typedef enum _GdkW32WindowDragOp GdkW32WindowDragOp;
struct _GdkW32DragMoveResizeContext
{
/* The window that is being moved/resized */
GdkWindow *window;
/* The kind of drag-operation going on. */
GdkW32WindowDragOp op;
@@ -97,6 +140,77 @@ struct _GdkW32DragMoveResizeContext
/* The cursor we should use while the operation is running. */
GdkCursor *cursor;
/* This window looks like an outline and is drawn under the window
* that is being dragged. It indicates the shape the dragged window
* will take if released at a particular point.
* Indicator window size always matches the target indicator shape,
* the the actual indicator drawn on it might not, depending on
* how much time elapsed since the animation started.
*/
HWND shape_indicator;
/* Used to draw the indicator */
cairo_surface_t *indicator_surface;
gint indicator_surface_width;
gint indicator_surface_height;
/* Size/position of shape_indicator */
GdkRectangle indicator_window_rect;
/* Indicator will animate to occupy this rectangle */
GdkRectangle indicator_target;
/* Indicator will start animating from this rectangle */
GdkRectangle indicator_start;
/* Timestamp of the animation start */
gint64 indicator_start_time;
/* Timer that drives the animation */
guint timer;
/* A special timestamp, if we want to draw not how
* the animation should look *now*, but how it should
* look at arbitrary moment of time.
* Set to 0 to tell GDK to use current time.
*/
gint64 draw_timestamp;
/* Indicates that a transformation was revealed:
*
* For drag-resize: If it's FALSE,
* then the pointer have not yet hit a trigger that triggers fullup.
* If TRUE, then the pointer did hit a trigger that triggers fullup
* at some point during this drag op.
* This is used to prevent drag-resize from triggering
* a transformation when first approaching a trigger of the work area -
* one must drag it all the way to the very trigger to trigger; afterwards
* a transformation will start triggering at some distance from the trigger
* for as long as the op is still running. This is how AeroSnap works.
*
* For drag-move: If it's FALSE,
* then the pointer have not yet hit a trigger, even if it is
* already within a edge region.
* If it's TRUE, then the pointer did hit a trigger within an
* edge region, and have not yet left an edge region
* (passing from one edge region into another doesn't count).
*/
gboolean revealed;
/* Arrays of GdkRectangle pairs, describing the areas of the virtual
* desktop that trigger various AeroSnap window transofrmations
* Coordinates are GDK screen coordinates.
*/
GArray *halfleft_regions;
GArray *halfright_regions;
GArray *maximize_regions;
GArray *fullup_regions;
/* Current pointer position will result in this kind of snapping,
* if the drag op is finished.
*/
GdkWin32AeroSnapState current_snap;
};
typedef struct _GdkW32DragMoveResizeContext GdkW32DragMoveResizeContext;
@@ -130,6 +244,17 @@ struct _GdkWindowImplWin32
gint initial_x;
gint initial_y;
/* left/right/top/bottom width of the shadow/resize-grip around the window */
RECT margins;
/* left+right and top+bottom from @margins */
gint margins_x;
gint margins_y;
/* Set to TRUE when GTK tells us that margins are 0 everywhere.
* We don't actually set margins to 0, we just set this bit.
*/
guint zero_margins : 1;
guint no_bg : 1;
guint inhibit_configure : 1;
guint override_redirect : 1;
@@ -141,6 +266,11 @@ struct _GdkWindowImplWin32
*/
guint layered : 1;
/* If TRUE, the @temp_styles is set to the styles that were temporarily
* added to this window.
*/
guint have_temp_styles : 1;
/* GDK does not keep window contents around, it just draws new
* stuff over the window where changes occurred.
* cache_surface retains old window contents, because
@@ -168,11 +298,33 @@ struct _GdkWindowImplWin32
GdkW32DragMoveResizeContext drag_move_resize_context;
/* Remembers where the window was snapped.
* Some snap operations change their meaning if
* the window is already snapped.
*/
GdkWin32AeroSnapState snap_state;
/* Remembers window position before it was snapped.
* This is used to unsnap it.
* Position and size are percentages of the workarea
* of the monitor on which the window was before it was snapped.
*/
GdkRectangleDouble *snap_stash;
/* Also remember the same position, but in absolute form. */
GdkRectangle *snap_stash_int;
/* Decorations set by gdk_window_set_decorations() or NULL if unset */
GdkWMDecoration* decorations;
/* No. of windows to force layered windows off */
guint suppress_layered;
/* Temporary styles that this window got for the purpose of
* handling WM_SYSMENU.
* They are removed at the first opportunity (usually WM_INITMENU).
*/
LONG_PTR temp_styles;
};
struct _GdkWindowImplWin32Class
+7 -1
View File
@@ -173,6 +173,7 @@ gtk_public_h_sources = \
gtkdebug.h \
gtkdialog.h \
gtkdnd.h \
gtkdragdest.h \
gtkdragsource.h \
gtkdrawingarea.h \
gtkeditable.h \
@@ -519,6 +520,7 @@ gtk_private_h_sources = \
gtkprintutils.h \
gtkprivate.h \
gtkpixelcacheprivate.h \
gtkprogresstrackerprivate.h \
gtkquery.h \
gtkrangeprivate.h \
gtkrbtree.h \
@@ -567,6 +569,7 @@ gtk_private_h_sources = \
gtktooltipwindowprivate.h \
gtktreedatalist.h \
gtktreeprivate.h \
gtkutilsprivate.h \
gtkwidgetprivate.h \
gtkwidgetpathprivate.h \
gtkwin32drawprivate.h \
@@ -724,6 +727,7 @@ gtk_base_c_sources = \
gtkcsswidgetnode.c \
gtkcsswin32sizevalue.c \
gtkdialog.c \
gtkdragdest.c \
gtkdragsource.c \
gtkdrawingarea.c \
gtkeditable.c \
@@ -829,6 +833,7 @@ gtk_base_c_sources = \
gtkprivate.c \
gtkprivatetypebuiltins.c \
gtkprogressbar.c \
gtkprogresstracker.c \
gtkpixelcache.c \
gtkpopover.c \
gtkpopovermenu.c \
@@ -926,6 +931,7 @@ gtk_base_c_sources = \
gtktreeview.c \
gtktreeviewcolumn.c \
gtktypebuiltins.c \
gtkutils.c \
gtkvolumebutton.c \
gtkviewport.c \
gtkwidget.c \
@@ -1507,7 +1513,7 @@ bin_PROGRAMS = \
gtk-query-settings \
gtk-launch
gtk_query_immodules_3_0_SOURCES = queryimmodules.c
gtk_query_immodules_3_0_SOURCES = queryimmodules.c gtkutils.c
gtk_query_immodules_3_0_LDADD = \
libgtk-3.la \
$(top_builddir)/gdk/libgdk-3.la \
+1
View File
@@ -41,6 +41,7 @@
#include "gtkcolorutils.h"
#include "gtkdnd.h"
#include "gtkdragsource.h"
#include "gtkdragdest.h"
#include "gtkdrawingarea.h"
#include "gtkframe.h"
#include "gtkgrid.h"
+1
View File
@@ -84,6 +84,7 @@
#include <gtk/gtkdebug.h>
#include <gtk/gtkdialog.h>
#include <gtk/gtkdnd.h>
#include <gtk/gtkdragdest.h>
#include <gtk/gtkdragsource.h>
#include <gtk/gtkdrawingarea.h>
#include <gtk/gtkeditable.h>
+2 -1
View File
@@ -127,7 +127,8 @@ static const LicenseInfo gtk_license_info [] = {
{ N_("GNU General Public License, version 2 only"), "http://www.gnu.org/licenses/old-licenses/gpl-2.0.html" },
{ N_("GNU General Public License, version 3 only"), "http://www.gnu.org/licenses/gpl-3.0.html" },
{ N_("GNU Lesser General Public License, version 2.1 only"), "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html" },
{ N_("GNU Lesser General Public License, version 3 only"), "http://www.gnu.org/licenses/lgpl-3.0.html" }
{ N_("GNU Lesser General Public License, version 3 only"), "http://www.gnu.org/licenses/lgpl-3.0.html" },
{ N_("GNU Affero General Public License, version 3 or later"), "http://www.gnu.org/licenses/agpl-3.0.html" }
};
typedef struct
+4 -1
View File
@@ -58,6 +58,7 @@ typedef struct _GtkAboutDialogPrivate GtkAboutDialogPrivate;
* @GTK_LICENSE_GPL_3_0_ONLY: The GNU General Public License, version 3.0 only. Since 3.12.
* @GTK_LICENSE_LGPL_2_1_ONLY: The GNU Lesser General Public License, version 2.1 only. Since 3.12.
* @GTK_LICENSE_LGPL_3_0_ONLY: The GNU Lesser General Public License, version 3.0 only. Since 3.12.
* @GTK_LICENSE_AGPL_3_0: The GNU Affero General Public License, version 3.0 or later. Since: 3.22.
*
* The type of license for an application.
*
@@ -83,7 +84,9 @@ typedef enum {
GTK_LICENSE_GPL_2_0_ONLY,
GTK_LICENSE_GPL_3_0_ONLY,
GTK_LICENSE_LGPL_2_1_ONLY,
GTK_LICENSE_LGPL_3_0_ONLY
GTK_LICENSE_LGPL_3_0_ONLY,
GTK_LICENSE_AGPL_3_0
} GtkLicense;
/**
+3 -2
View File
@@ -31,7 +31,7 @@
#include <string.h>
#include "gtkapplicationprivate.h"
#include "gtkclipboard.h"
#include "gtkclipboardprivate.h"
#include "gtkmarshalers.h"
#include "gtkmain.h"
#include "gtkrecentmanager.h"
@@ -1402,7 +1402,8 @@ gtk_application_set_app_menu (GtkApplication *application,
* Returns the menu model that has been set with
* gtk_application_set_app_menu().
*
* Returns: (transfer none): the application menu of @application
* Returns: (transfer none) (nullable): the application menu of @application
* or %NULL if no application menu has been set.
*
* Since: 3.4
*/
+1
View File
@@ -73,6 +73,7 @@
#include "gtkcalendar.h"
#include "gtkdnd.h"
#include "gtkdragdest.h"
#include "gtkintl.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
+2
View File
@@ -739,6 +739,8 @@ gtk_cell_editable_event_box_class_init (GtkCellEditableEventBoxClass *class)
g_object_class_install_property (object_class, PROP_PATH,
g_param_spec_string ("path", NULL, NULL,
NULL, GTK_PARAM_READWRITE));
gtk_widget_class_set_css_name (widget_class, "acceleditor");
}
static void
+18
View File
@@ -2208,3 +2208,21 @@ _gtk_clipboard_store_all (void)
g_slist_free (displays);
}
/**
* gtk_clipboard_get_selection:
* @clipboard: a #GtkClipboard
*
* Gets the selection that this clipboard is for.
*
* Returns: the selection
*
* Since: 3.22
*/
GdkAtom
gtk_clipboard_get_selection (GtkClipboard *clipboard)
{
g_return_val_if_fail (GTK_IS_CLIPBOARD (clipboard), GDK_NONE);
return clipboard->selection;
}
+2 -4
View File
@@ -290,10 +290,8 @@ void gtk_clipboard_set_can_store (GtkClipboard *clipboard,
GDK_AVAILABLE_IN_ALL
void gtk_clipboard_store (GtkClipboard *clipboard);
/* private */
void _gtk_clipboard_handle_event (GdkEventOwnerChange *event);
void _gtk_clipboard_store_all (void);
GDK_AVAILABLE_IN_3_22
GdkAtom gtk_clipboard_get_selection (GtkClipboard *clipboard);
G_END_DECLS
+4
View File
@@ -83,6 +83,10 @@ struct _GtkClipboardClass
void (* owner_change) (GtkClipboard *clipboard,
GdkEventOwnerChange *event);
};
void _gtk_clipboard_handle_event (GdkEventOwnerChange *event);
void _gtk_clipboard_store_all (void);
G_END_DECLS
+1
View File
@@ -37,6 +37,7 @@
#include "gtkcolorchooserdialog.h"
#include "gtkcolorswatchprivate.h"
#include "gtkdnd.h"
#include "gtkdragdest.h"
#include "gtkdragsource.h"
#include "gtkmarshalers.h"
#include "gtkprivate.h"
+22 -17
View File
@@ -71,7 +71,7 @@ gtk_css_animated_style_is_static (GtkCssStyle *style)
for (list = animated->animations; list; list = list->next)
{
if (!_gtk_style_animation_is_static (list->data, animated->current_time))
if (!_gtk_style_animation_is_static (list->data))
return FALSE;
}
@@ -288,7 +288,10 @@ gtk_css_animated_style_create_css_transitions (GSList *animations,
{
animation = gtk_css_animated_style_find_transition (GTK_CSS_ANIMATED_STYLE (source), i);
if (animation)
animations = g_slist_prepend (animations, g_object_ref (animation));
{
animation = _gtk_style_animation_advance (animation, timestamp);
animations = g_slist_prepend (animations, animation);
}
continue;
}
@@ -301,8 +304,9 @@ gtk_css_animated_style_create_css_transitions (GSList *animations,
animation = _gtk_css_transition_new (i,
gtk_css_style_get_value (source, i),
_gtk_css_array_value_get_nth (timing_functions, i),
timestamp + delay * G_USEC_PER_SEC,
timestamp + (delay + duration) * G_USEC_PER_SEC);
timestamp,
duration * G_USEC_PER_SEC,
delay * G_USEC_PER_SEC);
animations = g_slist_prepend (animations, animation);
}
@@ -367,9 +371,9 @@ gtk_css_animated_style_create_css_animations (GSList *animation
if (animation)
{
animation = _gtk_css_animation_copy (GTK_CSS_ANIMATION (animation),
timestamp,
_gtk_css_play_state_value_get (_gtk_css_array_value_get_nth (play_states, i)));
animation = _gtk_css_animation_advance_with_play_state (GTK_CSS_ANIMATION (animation),
timestamp,
_gtk_css_play_state_value_get (_gtk_css_array_value_get_nth (play_states, i)));
}
else
{
@@ -400,8 +404,7 @@ gtk_css_animated_style_create_css_animations (GSList *animation
/* PUBLIC API */
static void
gtk_css_animated_style_apply_animations (GtkCssAnimatedStyle *style,
gint64 timestamp)
gtk_css_animated_style_apply_animations (GtkCssAnimatedStyle *style)
{
GSList *l;
@@ -409,9 +412,8 @@ gtk_css_animated_style_apply_animations (GtkCssAnimatedStyle *style,
{
GtkStyleAnimation *animation = l->data;
_gtk_style_animation_set_values (animation,
timestamp,
GTK_CSS_ANIMATED_STYLE (style));
_gtk_style_animation_apply_values (animation,
GTK_CSS_ANIMATED_STYLE (style));
}
}
@@ -448,7 +450,7 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
result->current_time = timestamp;
result->animations = animations;
gtk_css_animated_style_apply_animations (result, timestamp);
gtk_css_animated_style_apply_animations (result);
return GTK_CSS_STYLE (result);
}
@@ -464,18 +466,21 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (source), NULL);
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (base), NULL);
if (timestamp == 0)
if (timestamp == 0 || timestamp == source->current_time)
return g_object_ref (source->style);
gtk_internal_return_val_if_fail (timestamp > source->current_time, NULL);
animations = NULL;
for (l = source->animations; l; l = l->next)
{
GtkStyleAnimation *animation = l->data;
if (_gtk_style_animation_is_finished (animation, timestamp))
if (_gtk_style_animation_is_finished (animation))
continue;
animations = g_slist_prepend (animations, g_object_ref (animation));
animation = _gtk_style_animation_advance (animation, timestamp);
animations = g_slist_prepend (animations, animation);
}
animations = g_slist_reverse (animations);
@@ -488,7 +493,7 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
result->current_time = timestamp;
result->animations = animations;
gtk_css_animated_style_apply_animations (result, timestamp);
gtk_css_animated_style_apply_animations (result);
return GTK_CSS_STYLE (result);
}
+64 -80
View File
@@ -22,41 +22,25 @@
#include "gtkcssanimationprivate.h"
#include "gtkcsseasevalueprivate.h"
#include "gtkprogresstrackerprivate.h"
#include <math.h>
G_DEFINE_TYPE (GtkCssAnimation, _gtk_css_animation, GTK_TYPE_STYLE_ANIMATION)
/* NB: Return value can be negative (if animation hasn't started yet) */
static gint64
gtk_css_animation_get_elapsed (GtkCssAnimation *animation,
gint64 for_time_us)
{
if (animation->play_state == GTK_CSS_PLAY_STATE_PAUSED)
return animation->timestamp;
else
return for_time_us - animation->timestamp;
}
/* NB: Return value can be negative and +-Inf */
static double
gtk_css_animation_get_iteration (GtkCssAnimation *animation,
gint64 for_time_us)
{
return (double) gtk_css_animation_get_elapsed (animation, for_time_us) / animation->duration;
}
static gboolean
gtk_css_animation_is_executing_at_iteration (GtkCssAnimation *animation,
double iteration)
gtk_css_animation_is_executing (GtkCssAnimation *animation)
{
GtkProgressState state = gtk_progress_tracker_get_state (&animation->tracker);
switch (animation->fill_mode)
{
case GTK_CSS_FILL_NONE:
return iteration >= 0 && iteration <= animation->iteration_count;
return state == GTK_PROGRESS_STATE_DURING;
case GTK_CSS_FILL_FORWARDS:
return iteration >= 0;
return state != GTK_PROGRESS_STATE_BEFORE;
case GTK_CSS_FILL_BACKWARDS:
return iteration <= animation->iteration_count;
return state != GTK_PROGRESS_STATE_AFTER;
case GTK_CSS_FILL_BOTH:
return TRUE;
default:
@@ -65,57 +49,58 @@ gtk_css_animation_is_executing_at_iteration (GtkCssAnimation *animation,
}
static double
gtk_css_animation_get_progress_from_iteration (GtkCssAnimation *animation,
double iteration)
gtk_css_animation_get_progress (GtkCssAnimation *animation)
{
gboolean reverse;
double completed;
iteration = CLAMP (iteration, 0.0, animation->iteration_count);
completed = floor (iteration);
gboolean reverse, odd_iteration;
gint cycle = gtk_progress_tracker_get_iteration_cycle (&animation->tracker);
odd_iteration = cycle % 2 > 0;
switch (animation->direction)
{
case GTK_CSS_DIRECTION_NORMAL:
reverse = completed == iteration && iteration > 0;
reverse = FALSE;
break;
case GTK_CSS_DIRECTION_REVERSE:
reverse = !(completed == iteration && iteration > 0);
reverse = TRUE;
break;
case GTK_CSS_DIRECTION_ALTERNATE:
reverse = fmod (iteration, 2) >= 1.0;
reverse = odd_iteration;
break;
case GTK_CSS_DIRECTION_ALTERNATE_REVERSE:
reverse = !(fmod (iteration, 2) >= 1.0);
reverse = !odd_iteration;
break;
default:
g_return_val_if_reached (0.0);
}
iteration -= completed;
if (reverse)
iteration = 1.0 - iteration;
return gtk_progress_tracker_get_progress (&animation->tracker, reverse);
}
return iteration;
GtkStyleAnimation *
gtk_css_animation_advance (GtkStyleAnimation *style_animation,
gint64 timestamp)
{
GtkCssAnimation *animation = GTK_CSS_ANIMATION (style_animation);
return _gtk_css_animation_advance_with_play_state (animation,
timestamp,
animation->play_state);
}
static void
gtk_css_animation_set_values (GtkStyleAnimation *style_animation,
gint64 for_time_us,
GtkCssAnimatedStyle *style)
gtk_css_animation_apply_values (GtkStyleAnimation *style_animation,
GtkCssAnimatedStyle *style)
{
GtkCssAnimation *animation = GTK_CSS_ANIMATION (style_animation);
double iteration, progress;
double progress;
guint i;
iteration = gtk_css_animation_get_iteration (animation, for_time_us);
if (!gtk_css_animation_is_executing_at_iteration (animation, iteration))
if (!gtk_css_animation_is_executing (animation))
return;
progress = gtk_css_animation_get_progress_from_iteration (animation, iteration);
progress = gtk_css_animation_get_progress (animation);
progress = _gtk_css_ease_value_transform (animation->ease, progress);
for (i = 0; i < _gtk_css_keyframes_get_n_properties (animation->keyframes); i++)
{
GtkCssValue *value;
@@ -133,25 +118,20 @@ gtk_css_animation_set_values (GtkStyleAnimation *style_animation,
}
static gboolean
gtk_css_animation_is_finished (GtkStyleAnimation *style_animation,
gint64 at_time_us)
gtk_css_animation_is_finished (GtkStyleAnimation *style_animation)
{
return FALSE;
}
static gboolean
gtk_css_animation_is_static (GtkStyleAnimation *style_animation,
gint64 at_time_us)
gtk_css_animation_is_static (GtkStyleAnimation *style_animation)
{
GtkCssAnimation *animation = GTK_CSS_ANIMATION (style_animation);
double iteration;
if (animation->play_state == GTK_CSS_PLAY_STATE_PAUSED)
return TRUE;
iteration = gtk_css_animation_get_iteration (animation, at_time_us);
return iteration >= animation->iteration_count;
return gtk_progress_tracker_get_state (&animation->tracker) == GTK_PROGRESS_STATE_AFTER;
}
static void
@@ -174,7 +154,8 @@ _gtk_css_animation_class_init (GtkCssAnimationClass *klass)
object_class->finalize = gtk_css_animation_finalize;
animation_class->set_values = gtk_css_animation_set_values;
animation_class->advance = gtk_css_animation_advance;
animation_class->apply_values = gtk_css_animation_apply_values;
animation_class->is_finished = gtk_css_animation_is_finished;
animation_class->is_static = gtk_css_animation_is_static;
}
@@ -207,17 +188,16 @@ _gtk_css_animation_new (const char *name,
animation->name = g_strdup (name);
animation->keyframes = _gtk_css_keyframes_ref (keyframes);
if (play_state == GTK_CSS_PLAY_STATE_PAUSED)
animation->timestamp = - delay_us;
else
animation->timestamp = timestamp + delay_us;
animation->duration = duration_us;
animation->ease = _gtk_css_value_ref (ease);
animation->direction = direction;
animation->play_state = play_state;
animation->fill_mode = fill_mode;
animation->iteration_count = iteration_count;
gtk_progress_tracker_start (&animation->tracker, duration_us, delay_us, iteration_count);
if (animation->play_state == GTK_CSS_PLAY_STATE_PAUSED)
gtk_progress_tracker_skip_frame (&animation->tracker, timestamp);
else
gtk_progress_tracker_advance_frame (&animation->tracker, timestamp);
return GTK_STYLE_ANIMATION (animation);
}
@@ -231,24 +211,28 @@ _gtk_css_animation_get_name (GtkCssAnimation *animation)
}
GtkStyleAnimation *
_gtk_css_animation_copy (GtkCssAnimation *animation,
gint64 at_time_us,
GtkCssPlayState play_state)
_gtk_css_animation_advance_with_play_state (GtkCssAnimation *source,
gint64 timestamp,
GtkCssPlayState play_state)
{
g_return_val_if_fail (GTK_IS_CSS_ANIMATION (animation), NULL);
GtkCssAnimation *animation;
if (animation->play_state == play_state)
return g_object_ref (animation);
g_return_val_if_fail (GTK_IS_CSS_ANIMATION (source), NULL);
return _gtk_css_animation_new (animation->name,
animation->keyframes,
at_time_us,
- gtk_css_animation_get_elapsed (animation, at_time_us),
animation->duration,
animation->ease,
animation->direction,
play_state,
animation->fill_mode,
animation->iteration_count);
animation = g_object_new (GTK_TYPE_CSS_ANIMATION, NULL);
animation->name = g_strdup (source->name);
animation->keyframes = _gtk_css_keyframes_ref (source->keyframes);
animation->ease = _gtk_css_value_ref (source->ease);
animation->direction = source->direction;
animation->play_state = play_state;
animation->fill_mode = source->fill_mode;
gtk_progress_tracker_init_copy (&source->tracker, &animation->tracker);
if (animation->play_state == GTK_CSS_PLAY_STATE_PAUSED)
gtk_progress_tracker_skip_frame (&animation->tracker, timestamp);
else
gtk_progress_tracker_advance_frame (&animation->tracker, timestamp);
return GTK_STYLE_ANIMATION (animation);
}
+5 -6
View File
@@ -23,6 +23,7 @@
#include "gtkstyleanimationprivate.h"
#include "gtkcsskeyframesprivate.h"
#include "gtkprogresstrackerprivate.h"
G_BEGIN_DECLS
@@ -43,12 +44,10 @@ struct _GtkCssAnimation
char *name;
GtkCssKeyframes *keyframes;
GtkCssValue *ease;
gint64 timestamp; /* elapsed time when paused, start time when playing (can be negative) */
gint64 duration; /* duration of 1 cycle */
double iteration_count;
GtkCssDirection direction;
GtkCssPlayState play_state;
GtkCssFillMode fill_mode;
GtkProgressTracker tracker;
};
struct _GtkCssAnimationClass
@@ -69,9 +68,9 @@ GtkStyleAnimation * _gtk_css_animation_new (const char *
GtkCssFillMode fill_mode,
double iteration_count);
GtkStyleAnimation * _gtk_css_animation_copy (GtkCssAnimation *animation,
gint64 at_time_us,
GtkCssPlayState play_state);
GtkStyleAnimation * _gtk_css_animation_advance_with_play_state (GtkCssAnimation *animation,
gint64 timestamp,
GtkCssPlayState play_state);
const char * _gtk_css_animation_get_name (GtkCssAnimation *animation);
-10
View File
@@ -22,16 +22,6 @@
#include "gtkcssparserprivate.h"
#include "gtkprivate.h"
/**
* GtkCssSection:
*
* Defines a part of a CSS document. Because sections are nested into
* one another, you can use gtk_css_section_get_parent() to get the
* containing region.
*
* Since: 3.2
*/
struct _GtkCssSection
{
gint ref_count;
+5 -2
View File
@@ -69,8 +69,11 @@ typedef enum
/**
* GtkCssSection:
*
* GtkCssSection is an auxiliary object containing information about
* the results of parsing a CSS style sheet.
* Defines a part of a CSS document. Because sections are nested into
* one another, you can use gtk_css_section_get_parent() to get the
* containing region.
*
* Since: 3.2
*/
typedef struct _GtkCssSection GtkCssSection;
+48 -28
View File
@@ -22,60 +22,79 @@
#include "gtkcsstransitionprivate.h"
#include "gtkcsseasevalueprivate.h"
#include "gtkprogresstrackerprivate.h"
G_DEFINE_TYPE (GtkCssTransition, _gtk_css_transition, GTK_TYPE_STYLE_ANIMATION)
static void
gtk_css_transition_set_values (GtkStyleAnimation *animation,
gint64 for_time_us,
GtkCssAnimatedStyle *style)
static GtkStyleAnimation *
gtk_css_transition_advance (GtkStyleAnimation *style_animation,
gint64 timestamp)
{
GtkCssTransition *transition = GTK_CSS_TRANSITION (animation);
GtkCssTransition *source = GTK_CSS_TRANSITION (style_animation);
GtkCssTransition *transition;
transition = g_object_new (GTK_TYPE_CSS_TRANSITION, NULL);
transition->property = source->property;
transition->start = _gtk_css_value_ref (source->start);
transition->ease = _gtk_css_value_ref (source->ease);
gtk_progress_tracker_init_copy (&source->tracker, &transition->tracker);
gtk_progress_tracker_advance_frame (&transition->tracker, timestamp);
return GTK_STYLE_ANIMATION (transition);
}
static void
gtk_css_transition_apply_values (GtkStyleAnimation *style_animation,
GtkCssAnimatedStyle *style)
{
GtkCssTransition *transition = GTK_CSS_TRANSITION (style_animation);
GtkCssValue *value, *end;
double progress;
GtkProgressState state;
end = gtk_css_animated_style_get_intrinsic_value (style, transition->property);
if (transition->start_time >= for_time_us)
state = gtk_progress_tracker_get_state (&transition->tracker);
if (state == GTK_PROGRESS_STATE_BEFORE)
value = _gtk_css_value_ref (transition->start);
else if (transition->end_time > for_time_us)
else if (state == GTK_PROGRESS_STATE_DURING)
{
progress = (double) (for_time_us - transition->start_time) / (transition->end_time - transition->start_time);
progress = gtk_progress_tracker_get_progress (&transition->tracker, FALSE);
progress = _gtk_css_ease_value_transform (transition->ease, progress);
value = _gtk_css_value_transition (transition->start,
end,
transition->property,
progress);
if (value == NULL)
value = _gtk_css_value_ref (end);
}
else
value = NULL;
return;
if (value)
{
gtk_css_animated_style_set_animated_value (style, transition->property, value);
_gtk_css_value_unref (value);
}
if (value == NULL)
value = _gtk_css_value_ref (end);
gtk_css_animated_style_set_animated_value (style, transition->property, value);
_gtk_css_value_unref (value);
}
static gboolean
gtk_css_transition_is_finished (GtkStyleAnimation *animation,
gint64 at_time_us)
gtk_css_transition_is_finished (GtkStyleAnimation *animation)
{
GtkCssTransition *transition = GTK_CSS_TRANSITION (animation);
return at_time_us >= transition->end_time;
return gtk_progress_tracker_get_state (&transition->tracker) == GTK_PROGRESS_STATE_AFTER;
}
static gboolean
gtk_css_transition_is_static (GtkStyleAnimation *animation,
gint64 at_time_us)
gtk_css_transition_is_static (GtkStyleAnimation *animation)
{
GtkCssTransition *transition = GTK_CSS_TRANSITION (animation);
return at_time_us >= transition->end_time;
return gtk_progress_tracker_get_state (&transition->tracker) == GTK_PROGRESS_STATE_AFTER;
}
static void
@@ -97,7 +116,8 @@ _gtk_css_transition_class_init (GtkCssTransitionClass *klass)
object_class->finalize = gtk_css_transition_finalize;
animation_class->set_values = gtk_css_transition_set_values;
animation_class->advance = gtk_css_transition_advance;
animation_class->apply_values = gtk_css_transition_apply_values;
animation_class->is_finished = gtk_css_transition_is_finished;
animation_class->is_static = gtk_css_transition_is_static;
}
@@ -111,22 +131,22 @@ GtkStyleAnimation *
_gtk_css_transition_new (guint property,
GtkCssValue *start,
GtkCssValue *ease,
gint64 start_time_us,
gint64 end_time_us)
gint64 timestamp,
gint64 duration_us,
gint64 delay_us)
{
GtkCssTransition *transition;
g_return_val_if_fail (start != NULL, NULL);
g_return_val_if_fail (ease != NULL, NULL);
g_return_val_if_fail (start_time_us <= end_time_us, NULL);
transition = g_object_new (GTK_TYPE_CSS_TRANSITION, NULL);
transition->property = property;
transition->start = _gtk_css_value_ref (start);
transition->ease = _gtk_css_value_ref (ease);
transition->start_time = start_time_us;
transition->end_time = end_time_us;
gtk_progress_tracker_start (&transition->tracker, duration_us, delay_us, 1.0);
gtk_progress_tracker_advance_frame (&transition->tracker, timestamp);
return GTK_STYLE_ANIMATION (transition);
}
+8 -7
View File
@@ -21,6 +21,7 @@
#define __GTK_CSS_TRANSITION_PRIVATE_H__
#include "gtkstyleanimationprivate.h"
#include "gtkprogresstrackerprivate.h"
G_BEGIN_DECLS
@@ -38,11 +39,10 @@ struct _GtkCssTransition
{
GtkStyleAnimation parent;
guint property;
GtkCssValue *start;
GtkCssValue *ease;
gint64 start_time;
gint64 end_time;
guint property;
GtkCssValue *start;
GtkCssValue *ease;
GtkProgressTracker tracker;
};
struct _GtkCssTransitionClass
@@ -55,8 +55,9 @@ GType _gtk_css_transition_get_type (void) G_GNUC_CONST;
GtkStyleAnimation * _gtk_css_transition_new (guint property,
GtkCssValue *start,
GtkCssValue *ease,
gint64 start_time_us,
gint64 end_time_us);
gint64 timestamp,
gint64 duration_us,
gint64 delay_us);
guint _gtk_css_transition_get_property (GtkCssTransition *transition);
+3 -492
View File
@@ -46,6 +46,7 @@
#include <gdk/wayland/gdkwayland.h>
#endif
#include "gtkdragdest.h"
#include "gtkgesturedrag.h"
#include "gtkgesturesingle.h"
#include "gtkicontheme.h"
@@ -79,7 +80,6 @@
static GSList *source_widgets = NULL;
typedef struct _GtkDragSourceInfo GtkDragSourceInfo;
typedef struct _GtkDragDestSite GtkDragDestSite;
typedef struct _GtkDragDestInfo GtkDragDestInfo;
@@ -121,19 +121,6 @@ struct _GtkDragSourceInfo
guint have_grab : 1; /* Do we still have the pointer grab */
};
struct _GtkDragDestSite
{
GtkDestDefaults flags;
GtkTargetList *target_list;
GdkDragAction actions;
GdkWindow *proxy_window;
GdkDragProtocol proxy_protocol;
guint do_proxy : 1;
guint proxy_coords : 1;
guint have_drag : 1;
guint track_motion : 1;
};
struct _GtkDragDestInfo
{
GtkWidget *widget; /* Widget in which drag is in */
@@ -192,10 +179,6 @@ static gboolean gtk_drag_find_widget (GtkWidget *widget,
static void gtk_drag_proxy_begin (GtkWidget *widget,
GtkDragDestInfo *dest_info,
guint32 time);
static void gtk_drag_dest_realized (GtkWidget *widget);
static void gtk_drag_dest_hierarchy_changed (GtkWidget *widget,
GtkWidget *previous_toplevel);
static void gtk_drag_dest_site_destroy (gpointer data);
static void gtk_drag_dest_leave (GtkWidget *widget,
GdkDragContext *context,
guint time);
@@ -1025,381 +1008,6 @@ gtk_drag_unhighlight (GtkWidget *widget)
gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_DROP_ACTIVE);
}
static void
gtk_drag_dest_set_internal (GtkWidget *widget,
GtkDragDestSite *site)
{
GtkDragDestSite *old_site;
g_return_if_fail (widget != NULL);
/* HACK, do this in the destroy */
old_site = g_object_get_data (G_OBJECT (widget), "gtk-drag-dest");
if (old_site)
{
g_signal_handlers_disconnect_by_func (widget,
gtk_drag_dest_realized,
old_site);
g_signal_handlers_disconnect_by_func (widget,
gtk_drag_dest_hierarchy_changed,
old_site);
site->track_motion = old_site->track_motion;
}
if (gtk_widget_get_realized (widget))
gtk_drag_dest_realized (widget);
g_signal_connect (widget, "realize",
G_CALLBACK (gtk_drag_dest_realized), site);
g_signal_connect (widget, "hierarchy-changed",
G_CALLBACK (gtk_drag_dest_hierarchy_changed), site);
g_object_set_data_full (G_OBJECT (widget), I_("gtk-drag-dest"),
site, gtk_drag_dest_site_destroy);
}
/**
* gtk_drag_dest_set: (method)
* @widget: a #GtkWidget
* @flags: which types of default drag behavior to use
* @targets: (allow-none) (array length=n_targets): a pointer to an array of
* #GtkTargetEntrys indicating the drop types that this @widget will
* accept, or %NULL. Later you can access the list with
* gtk_drag_dest_get_target_list() and gtk_drag_dest_find_target().
* @n_targets: the number of entries in @targets
* @actions: a bitmask of possible actions for a drop onto this @widget.
*
* Sets a widget as a potential drop destination, and adds default behaviors.
*
* The default behaviors listed in @flags have an effect similar
* to installing default handlers for the widgets drag-and-drop signals
* (#GtkWidget::drag-motion, #GtkWidget::drag-drop, ...). They all exist
* for convenience. When passing #GTK_DEST_DEFAULT_ALL for instance it is
* sufficient to connect to the widgets #GtkWidget::drag-data-received
* signal to get primitive, but consistent drag-and-drop support.
*
* Things become more complicated when you try to preview the dragged data,
* as described in the documentation for #GtkWidget::drag-motion. The default
* behaviors described by @flags make some assumptions, that can conflict
* with your own signal handlers. For instance #GTK_DEST_DEFAULT_DROP causes
* invokations of gdk_drag_status() in the context of #GtkWidget::drag-motion,
* and invokations of gtk_drag_finish() in #GtkWidget::drag-data-received.
* Especially the later is dramatic, when your own #GtkWidget::drag-motion
* handler calls gtk_drag_get_data() to inspect the dragged data.
*
* Theres no way to set a default action here, you can use the
* #GtkWidget::drag-motion callback for that. Heres an example which selects
* the action to use depending on whether the control key is pressed or not:
* |[<!-- language="C" -->
* static void
* drag_motion (GtkWidget *widget,
* GdkDragContext *context,
* gint x,
* gint y,
* guint time)
* {
* GdkModifierType mask;
*
* gdk_window_get_pointer (gtk_widget_get_window (widget),
* NULL, NULL, &mask);
* if (mask & GDK_CONTROL_MASK)
* gdk_drag_status (context, GDK_ACTION_COPY, time);
* else
* gdk_drag_status (context, GDK_ACTION_MOVE, time);
* }
* ]|
*/
void
gtk_drag_dest_set (GtkWidget *widget,
GtkDestDefaults flags,
const GtkTargetEntry *targets,
gint n_targets,
GdkDragAction actions)
{
GtkDragDestSite *site;
g_return_if_fail (GTK_IS_WIDGET (widget));
site = g_slice_new0 (GtkDragDestSite);
site->flags = flags;
site->have_drag = FALSE;
if (targets)
site->target_list = gtk_target_list_new (targets, n_targets);
else
site->target_list = NULL;
site->actions = actions;
site->do_proxy = FALSE;
site->proxy_window = NULL;
site->track_motion = FALSE;
gtk_drag_dest_set_internal (widget, site);
}
/**
* gtk_drag_dest_set_proxy: (method)
* @widget: a #GtkWidget
* @proxy_window: the window to which to forward drag events
* @protocol: the drag protocol which the @proxy_window accepts
* (You can use gdk_drag_get_protocol() to determine this)
* @use_coordinates: If %TRUE, send the same coordinates to the
* destination, because it is an embedded
* subwindow.
*
* Sets this widget as a proxy for drops to another window.
*/
void
gtk_drag_dest_set_proxy (GtkWidget *widget,
GdkWindow *proxy_window,
GdkDragProtocol protocol,
gboolean use_coordinates)
{
GtkDragDestSite *site;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (!proxy_window || GDK_IS_WINDOW (proxy_window));
site = g_slice_new (GtkDragDestSite);
site->flags = 0;
site->have_drag = FALSE;
site->target_list = NULL;
site->actions = 0;
site->proxy_window = proxy_window;
if (proxy_window)
g_object_ref (proxy_window);
site->do_proxy = TRUE;
site->proxy_protocol = protocol;
site->proxy_coords = use_coordinates;
site->track_motion = FALSE;
gtk_drag_dest_set_internal (widget, site);
}
/**
* gtk_drag_dest_unset: (method)
* @widget: a #GtkWidget
*
* Clears information about a drop destination set with
* gtk_drag_dest_set(). The widget will no longer receive
* notification of drags.
*/
void
gtk_drag_dest_unset (GtkWidget *widget)
{
GtkDragDestSite *old_site;
g_return_if_fail (GTK_IS_WIDGET (widget));
old_site = g_object_get_data (G_OBJECT (widget),
"gtk-drag-dest");
if (old_site)
{
g_signal_handlers_disconnect_by_func (widget,
gtk_drag_dest_realized,
old_site);
g_signal_handlers_disconnect_by_func (widget,
gtk_drag_dest_hierarchy_changed,
old_site);
}
g_object_set_data (G_OBJECT (widget), I_("gtk-drag-dest"), NULL);
}
/**
* gtk_drag_dest_get_target_list: (method)
* @widget: a #GtkWidget
*
* Returns the list of targets this widget can accept from
* drag-and-drop.
*
* Returns: (nullable) (transfer none): the #GtkTargetList, or %NULL if none
*/
GtkTargetList*
gtk_drag_dest_get_target_list (GtkWidget *widget)
{
GtkDragDestSite *site;
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
site = g_object_get_data (G_OBJECT (widget), "gtk-drag-dest");
return site ? site->target_list : NULL;
}
/**
* gtk_drag_dest_set_target_list: (method)
* @widget: a #GtkWidget thats a drag destination
* @target_list: (allow-none): list of droppable targets, or %NULL for none
*
* Sets the target types that this widget can accept from drag-and-drop.
* The widget must first be made into a drag destination with
* gtk_drag_dest_set().
*/
void
gtk_drag_dest_set_target_list (GtkWidget *widget,
GtkTargetList *target_list)
{
GtkDragDestSite *site;
g_return_if_fail (GTK_IS_WIDGET (widget));
site = g_object_get_data (G_OBJECT (widget), "gtk-drag-dest");
if (!site)
{
g_warning ("Can't set a target list on a widget until you've called gtk_drag_dest_set() "
"to make the widget into a drag destination");
return;
}
if (target_list)
gtk_target_list_ref (target_list);
if (site->target_list)
gtk_target_list_unref (site->target_list);
site->target_list = target_list;
}
/**
* gtk_drag_dest_add_text_targets: (method)
* @widget: a #GtkWidget thats a drag destination
*
* Add the text targets supported by #GtkSelectionData to
* the target list of the drag destination. The targets
* are added with @info = 0. If you need another value,
* use gtk_target_list_add_text_targets() and
* gtk_drag_dest_set_target_list().
*
* Since: 2.6
*/
void
gtk_drag_dest_add_text_targets (GtkWidget *widget)
{
GtkTargetList *target_list;
target_list = gtk_drag_dest_get_target_list (widget);
if (target_list)
gtk_target_list_ref (target_list);
else
target_list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_text_targets (target_list, 0);
gtk_drag_dest_set_target_list (widget, target_list);
gtk_target_list_unref (target_list);
}
/**
* gtk_drag_dest_add_image_targets: (method)
* @widget: a #GtkWidget thats a drag destination
*
* Add the image targets supported by #GtkSelectionData to
* the target list of the drag destination. The targets
* are added with @info = 0. If you need another value,
* use gtk_target_list_add_image_targets() and
* gtk_drag_dest_set_target_list().
*
* Since: 2.6
*/
void
gtk_drag_dest_add_image_targets (GtkWidget *widget)
{
GtkTargetList *target_list;
target_list = gtk_drag_dest_get_target_list (widget);
if (target_list)
gtk_target_list_ref (target_list);
else
target_list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_image_targets (target_list, 0, FALSE);
gtk_drag_dest_set_target_list (widget, target_list);
gtk_target_list_unref (target_list);
}
/**
* gtk_drag_dest_add_uri_targets: (method)
* @widget: a #GtkWidget thats a drag destination
*
* Add the URI targets supported by #GtkSelectionData to
* the target list of the drag destination. The targets
* are added with @info = 0. If you need another value,
* use gtk_target_list_add_uri_targets() and
* gtk_drag_dest_set_target_list().
*
* Since: 2.6
*/
void
gtk_drag_dest_add_uri_targets (GtkWidget *widget)
{
GtkTargetList *target_list;
target_list = gtk_drag_dest_get_target_list (widget);
if (target_list)
gtk_target_list_ref (target_list);
else
target_list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_uri_targets (target_list, 0);
gtk_drag_dest_set_target_list (widget, target_list);
gtk_target_list_unref (target_list);
}
/**
* gtk_drag_dest_set_track_motion: (method)
* @widget: a #GtkWidget thats a drag destination
* @track_motion: whether to accept all targets
*
* Tells the widget to emit #GtkWidget::drag-motion and
* #GtkWidget::drag-leave events regardless of the targets and the
* %GTK_DEST_DEFAULT_MOTION flag.
*
* This may be used when a widget wants to do generic
* actions regardless of the targets that the source offers.
*
* Since: 2.10
*/
void
gtk_drag_dest_set_track_motion (GtkWidget *widget,
gboolean track_motion)
{
GtkDragDestSite *site;
g_return_if_fail (GTK_IS_WIDGET (widget));
site = g_object_get_data (G_OBJECT (widget), "gtk-drag-dest");
g_return_if_fail (site != NULL);
site->track_motion = track_motion != FALSE;
}
/**
* gtk_drag_dest_get_track_motion: (method)
* @widget: a #GtkWidget thats a drag destination
*
* Returns whether the widget has been configured to always
* emit #GtkWidget::drag-motion signals.
*
* Returns: %TRUE if the widget always emits
* #GtkWidget::drag-motion events
*
* Since: 2.10
*/
gboolean
gtk_drag_dest_get_track_motion (GtkWidget *widget)
{
GtkDragDestSite *site;
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
site = g_object_get_data (G_OBJECT (widget), "gtk-drag-dest");
if (site)
return site->track_motion;
return FALSE;
}
/*
* _gtk_drag_dest_handle_event:
* @toplevel: Toplevel widget that received the event
@@ -1506,70 +1114,6 @@ _gtk_drag_dest_handle_event (GtkWidget *toplevel,
}
}
/**
* gtk_drag_dest_find_target: (method)
* @widget: drag destination widget
* @context: drag context
* @target_list: (allow-none): list of droppable targets, or %NULL to use
* gtk_drag_dest_get_target_list (@widget).
*
* Looks for a match between the supported targets of @context and the
* @dest_target_list, returning the first matching target, otherwise
* returning %GDK_NONE. @dest_target_list should usually be the return
* value from gtk_drag_dest_get_target_list(), but some widgets may
* have different valid targets for different parts of the widget; in
* that case, they will have to implement a drag_motion handler that
* passes the correct target list to this function.
*
* Returns: (transfer none): first target that the source offers
* and the dest can accept, or %GDK_NONE
*/
GdkAtom
gtk_drag_dest_find_target (GtkWidget *widget,
GdkDragContext *context,
GtkTargetList *target_list)
{
GList *tmp_target;
GList *tmp_source = NULL;
GtkWidget *source_widget;
g_return_val_if_fail (GTK_IS_WIDGET (widget), GDK_NONE);
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), GDK_NONE);
source_widget = gtk_drag_get_source_widget (context);
if (target_list == NULL)
target_list = gtk_drag_dest_get_target_list (widget);
if (target_list == NULL)
return GDK_NONE;
tmp_target = target_list->list;
while (tmp_target)
{
GtkTargetPair *pair = tmp_target->data;
tmp_source = gdk_drag_context_list_targets (context);
while (tmp_source)
{
if (tmp_source->data == GUINT_TO_POINTER (pair->target))
{
if ((!(pair->flags & GTK_TARGET_SAME_APP) || source_widget) &&
(!(pair->flags & GTK_TARGET_SAME_WIDGET) || (source_widget == widget)) &&
(!(pair->flags & GTK_TARGET_OTHER_APP) || !source_widget) &&
(!(pair->flags & GTK_TARGET_OTHER_WIDGET) || (source_widget != widget)))
return pair->target;
else
break;
}
tmp_source = tmp_source->next;
}
tmp_target = tmp_target->next;
}
return GDK_NONE;
}
static void
gtk_drag_selection_received (GtkWidget *widget,
GtkSelectionData *selection_data,
@@ -1875,39 +1419,6 @@ gtk_drag_clear_source_info (GdkDragContext *context)
g_object_set_qdata (G_OBJECT (context), dest_info_quark, NULL);
}
static void
gtk_drag_dest_realized (GtkWidget *widget)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
if (gtk_widget_is_toplevel (toplevel))
gdk_window_register_dnd (gtk_widget_get_window (toplevel));
}
static void
gtk_drag_dest_hierarchy_changed (GtkWidget *widget,
GtkWidget *previous_toplevel)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
if (gtk_widget_is_toplevel (toplevel) && gtk_widget_get_realized (toplevel))
gdk_window_register_dnd (gtk_widget_get_window (toplevel));
}
static void
gtk_drag_dest_site_destroy (gpointer data)
{
GtkDragDestSite *site = data;
if (site->proxy_window)
g_object_unref (site->proxy_window);
if (site->target_list)
gtk_target_list_unref (site->target_list);
g_slice_free (GtkDragDestSite, site);
}
/*
* Default drag handlers
*/
@@ -2765,7 +2276,6 @@ gtk_drag_set_icon_surface (GdkDragContext *context,
rgba_visual != NULL &&
gdk_screen_is_composited (screen);
gtk_window_set_screen (GTK_WINDOW (window), screen);
if (has_rgba)
@@ -2793,7 +2303,8 @@ gtk_drag_set_icon_surface (GdkDragContext *context,
cairo_region_destroy (region);
/* Need to saturate the colors, so it doesn't look like semi-transparent
* pixels were painted on black. */
* pixels were painted on black.
*/
saturated = gdk_window_create_similar_surface (gtk_widget_get_window (window),
CAIRO_CONTENT_COLOR,
extents.width,
-88
View File
@@ -37,56 +37,6 @@
G_BEGIN_DECLS
/**
* GtkDestDefaults:
* @GTK_DEST_DEFAULT_MOTION: If set for a widget, GTK+, during a drag over this
* widget will check if the drag matches this widgets list of possible targets
* and actions.
* GTK+ will then call gdk_drag_status() as appropriate.
* @GTK_DEST_DEFAULT_HIGHLIGHT: If set for a widget, GTK+ will draw a highlight on
* this widget as long as a drag is over this widget and the widget drag format
* and action are acceptable.
* @GTK_DEST_DEFAULT_DROP: If set for a widget, when a drop occurs, GTK+ will
* will check if the drag matches this widgets list of possible targets and
* actions. If so, GTK+ will call gtk_drag_get_data() on behalf of the widget.
* Whether or not the drop is successful, GTK+ will call gtk_drag_finish(). If
* the action was a move, then if the drag was successful, then %TRUE will be
* passed for the @delete parameter to gtk_drag_finish().
* @GTK_DEST_DEFAULT_ALL: If set, specifies that all default actions should
* be taken.
*
* The #GtkDestDefaults enumeration specifies the various
* types of action that will be taken on behalf
* of the user for a drag destination site.
*/
typedef enum {
GTK_DEST_DEFAULT_MOTION = 1 << 0,
GTK_DEST_DEFAULT_HIGHLIGHT = 1 << 1,
GTK_DEST_DEFAULT_DROP = 1 << 2,
GTK_DEST_DEFAULT_ALL = 0x07
} GtkDestDefaults;
/**
* GtkTargetFlags:
* @GTK_TARGET_SAME_APP: If this is set, the target will only be selected
* for drags within a single application.
* @GTK_TARGET_SAME_WIDGET: If this is set, the target will only be selected
* for drags within a single widget.
* @GTK_TARGET_OTHER_APP: If this is set, the target will not be selected
* for drags within a single application.
* @GTK_TARGET_OTHER_WIDGET: If this is set, the target will not be selected
* for drags withing a single widget.
*
* The #GtkTargetFlags enumeration is used to specify
* constraints on a #GtkTargetEntry.
*/
typedef enum {
GTK_TARGET_SAME_APP = 1 << 0, /*< nick=same-app >*/
GTK_TARGET_SAME_WIDGET = 1 << 1, /*< nick=same-widget >*/
GTK_TARGET_OTHER_APP = 1 << 2, /*< nick=other-app >*/
GTK_TARGET_OTHER_WIDGET = 1 << 3 /*< nick=other-widget >*/
} GtkTargetFlags;
/* Destination side */
GDK_AVAILABLE_IN_ALL
@@ -108,44 +58,6 @@ void gtk_drag_highlight (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_drag_unhighlight (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_drag_dest_set (GtkWidget *widget,
GtkDestDefaults flags,
const GtkTargetEntry *targets,
gint n_targets,
GdkDragAction actions);
GDK_AVAILABLE_IN_ALL
void gtk_drag_dest_set_proxy (GtkWidget *widget,
GdkWindow *proxy_window,
GdkDragProtocol protocol,
gboolean use_coordinates);
GDK_AVAILABLE_IN_ALL
void gtk_drag_dest_unset (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
GdkAtom gtk_drag_dest_find_target (GtkWidget *widget,
GdkDragContext *context,
GtkTargetList *target_list);
GDK_AVAILABLE_IN_ALL
GtkTargetList* gtk_drag_dest_get_target_list (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_drag_dest_set_target_list (GtkWidget *widget,
GtkTargetList *target_list);
GDK_AVAILABLE_IN_ALL
void gtk_drag_dest_add_text_targets (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_drag_dest_add_image_targets (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_drag_dest_add_uri_targets (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_drag_dest_set_track_motion (GtkWidget *widget,
gboolean track_motion);
GDK_AVAILABLE_IN_ALL
gboolean gtk_drag_dest_get_track_motion (GtkWidget *widget);
/* Source side */
GDK_AVAILABLE_IN_3_10
+15
View File
@@ -22,9 +22,24 @@
#include <gtk/gtkwidget.h>
#include <gtk/gtkselection.h>
#include <gtk/gtkdragdest.h>
#include "gtkimagedefinitionprivate.h"
typedef struct _GtkDragDestSite GtkDragDestSite;
struct _GtkDragDestSite
{
GtkDestDefaults flags;
GtkTargetList *target_list;
GdkDragAction actions;
GdkWindow *proxy_window;
GdkDragProtocol proxy_protocol;
guint do_proxy : 1;
guint proxy_coords : 1;
guint have_drag : 1;
guint track_motion : 1;
};
G_BEGIN_DECLS
GdkDragContext * gtk_drag_begin_internal (GtkWidget *widget,
+500
View File
@@ -0,0 +1,500 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1999 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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 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/>.
*/
/*
* 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/.
*/
#include "config.h"
#include "gtkdragdest.h"
#include "gtkdnd.h"
#include "gtkdndprivate.h"
#include "gtkselectionprivate.h"
#include "gtkintl.h"
static void
gtk_drag_dest_realized (GtkWidget *widget)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
if (gtk_widget_is_toplevel (toplevel))
gdk_window_register_dnd (gtk_widget_get_window (toplevel));
}
static void
gtk_drag_dest_hierarchy_changed (GtkWidget *widget,
GtkWidget *previous_toplevel)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
if (gtk_widget_is_toplevel (toplevel) && gtk_widget_get_realized (toplevel))
gdk_window_register_dnd (gtk_widget_get_window (toplevel));
}
static void
gtk_drag_dest_site_destroy (gpointer data)
{
GtkDragDestSite *site = data;
if (site->proxy_window)
g_object_unref (site->proxy_window);
if (site->target_list)
gtk_target_list_unref (site->target_list);
g_slice_free (GtkDragDestSite, site);
}
static void
gtk_drag_dest_set_internal (GtkWidget *widget,
GtkDragDestSite *site)
{
GtkDragDestSite *old_site;
old_site = g_object_get_data (G_OBJECT (widget), I_("gtk-drag-dest"));
if (old_site)
{
g_signal_handlers_disconnect_by_func (widget,
gtk_drag_dest_realized,
old_site);
g_signal_handlers_disconnect_by_func (widget,
gtk_drag_dest_hierarchy_changed,
old_site);
site->track_motion = old_site->track_motion;
}
if (gtk_widget_get_realized (widget))
gtk_drag_dest_realized (widget);
g_signal_connect (widget, "realize",
G_CALLBACK (gtk_drag_dest_realized), site);
g_signal_connect (widget, "hierarchy-changed",
G_CALLBACK (gtk_drag_dest_hierarchy_changed), site);
g_object_set_data_full (G_OBJECT (widget), I_("gtk-drag-dest"),
site, gtk_drag_dest_site_destroy);
}
/**
* gtk_drag_dest_set: (method)
* @widget: a #GtkWidget
* @flags: which types of default drag behavior to use
* @targets: (allow-none) (array length=n_targets): a pointer to an array of
* #GtkTargetEntrys indicating the drop types that this @widget will
* accept, or %NULL. Later you can access the list with
* gtk_drag_dest_get_target_list() and gtk_drag_dest_find_target().
* @n_targets: the number of entries in @targets
* @actions: a bitmask of possible actions for a drop onto this @widget.
*
* Sets a widget as a potential drop destination, and adds default behaviors.
*
* The default behaviors listed in @flags have an effect similar
* to installing default handlers for the widgets drag-and-drop signals
* (#GtkWidget::drag-motion, #GtkWidget::drag-drop, ...). They all exist
* for convenience. When passing #GTK_DEST_DEFAULT_ALL for instance it is
* sufficient to connect to the widgets #GtkWidget::drag-data-received
* signal to get primitive, but consistent drag-and-drop support.
*
* Things become more complicated when you try to preview the dragged data,
* as described in the documentation for #GtkWidget::drag-motion. The default
* behaviors described by @flags make some assumptions, that can conflict
* with your own signal handlers. For instance #GTK_DEST_DEFAULT_DROP causes
* invokations of gdk_drag_status() in the context of #GtkWidget::drag-motion,
* and invokations of gtk_drag_finish() in #GtkWidget::drag-data-received.
* Especially the later is dramatic, when your own #GtkWidget::drag-motion
* handler calls gtk_drag_get_data() to inspect the dragged data.
*
* Theres no way to set a default action here, you can use the
* #GtkWidget::drag-motion callback for that. Heres an example which selects
* the action to use depending on whether the control key is pressed or not:
* |[<!-- language="C" -->
* static void
* drag_motion (GtkWidget *widget,
* GdkDragContext *context,
* gint x,
* gint y,
* guint time)
* {
* GdkModifierType mask;
*
* gdk_window_get_pointer (gtk_widget_get_window (widget),
* NULL, NULL, &mask);
* if (mask & GDK_CONTROL_MASK)
* gdk_drag_status (context, GDK_ACTION_COPY, time);
* else
* gdk_drag_status (context, GDK_ACTION_MOVE, time);
* }
* ]|
*/
void
gtk_drag_dest_set (GtkWidget *widget,
GtkDestDefaults flags,
const GtkTargetEntry *targets,
gint n_targets,
GdkDragAction actions)
{
GtkDragDestSite *site;
g_return_if_fail (GTK_IS_WIDGET (widget));
site = g_slice_new0 (GtkDragDestSite);
site->flags = flags;
site->have_drag = FALSE;
if (targets)
site->target_list = gtk_target_list_new (targets, n_targets);
else
site->target_list = NULL;
site->actions = actions;
site->do_proxy = FALSE;
site->proxy_window = NULL;
site->track_motion = FALSE;
gtk_drag_dest_set_internal (widget, site);
}
/**
* gtk_drag_dest_set_proxy: (method)
* @widget: a #GtkWidget
* @proxy_window: the window to which to forward drag events
* @protocol: the drag protocol which the @proxy_window accepts
* (You can use gdk_drag_get_protocol() to determine this)
* @use_coordinates: If %TRUE, send the same coordinates to the
* destination, because it is an embedded
* subwindow.
*
* Sets this widget as a proxy for drops to another window.
*/
void
gtk_drag_dest_set_proxy (GtkWidget *widget,
GdkWindow *proxy_window,
GdkDragProtocol protocol,
gboolean use_coordinates)
{
GtkDragDestSite *site;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (!proxy_window || GDK_IS_WINDOW (proxy_window));
site = g_slice_new (GtkDragDestSite);
site->flags = 0;
site->have_drag = FALSE;
site->target_list = NULL;
site->actions = 0;
site->proxy_window = proxy_window;
if (proxy_window)
g_object_ref (proxy_window);
site->do_proxy = TRUE;
site->proxy_protocol = protocol;
site->proxy_coords = use_coordinates;
site->track_motion = FALSE;
gtk_drag_dest_set_internal (widget, site);
}
/**
* gtk_drag_dest_unset: (method)
* @widget: a #GtkWidget
*
* Clears information about a drop destination set with
* gtk_drag_dest_set(). The widget will no longer receive
* notification of drags.
*/
void
gtk_drag_dest_unset (GtkWidget *widget)
{
GtkDragDestSite *old_site;
g_return_if_fail (GTK_IS_WIDGET (widget));
old_site = g_object_get_data (G_OBJECT (widget), I_("gtk-drag-dest"));
if (old_site)
{
g_signal_handlers_disconnect_by_func (widget,
gtk_drag_dest_realized,
old_site);
g_signal_handlers_disconnect_by_func (widget,
gtk_drag_dest_hierarchy_changed,
old_site);
}
g_object_set_data (G_OBJECT (widget), I_("gtk-drag-dest"), NULL);
}
/**
* gtk_drag_dest_get_target_list: (method)
* @widget: a #GtkWidget
*
* Returns the list of targets this widget can accept from
* drag-and-drop.
*
* Returns: (transfer none): the #GtkTargetList, or %NULL if none
*/
GtkTargetList *
gtk_drag_dest_get_target_list (GtkWidget *widget)
{
GtkDragDestSite *site;
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
site = g_object_get_data (G_OBJECT (widget), I_("gtk-drag-dest"));
return site ? site->target_list : NULL;
}
/**
* gtk_drag_dest_set_target_list: (method)
* @widget: a #GtkWidget thats a drag destination
* @target_list: (allow-none): list of droppable targets, or %NULL for none
*
* Sets the target types that this widget can accept from drag-and-drop.
* The widget must first be made into a drag destination with
* gtk_drag_dest_set().
*/
void
gtk_drag_dest_set_target_list (GtkWidget *widget,
GtkTargetList *target_list)
{
GtkDragDestSite *site;
g_return_if_fail (GTK_IS_WIDGET (widget));
site = g_object_get_data (G_OBJECT (widget), I_("gtk-drag-dest"));
if (!site)
{
g_warning ("Can't set a target list on a widget until you've called gtk_drag_dest_set() "
"to make the widget into a drag destination");
return;
}
if (target_list)
gtk_target_list_ref (target_list);
if (site->target_list)
gtk_target_list_unref (site->target_list);
site->target_list = target_list;
}
/**
* gtk_drag_dest_add_text_targets: (method)
* @widget: a #GtkWidget thats a drag destination
*
* Add the text targets supported by #GtkSelectionData to
* the target list of the drag destination. The targets
* are added with @info = 0. If you need another value,
* use gtk_target_list_add_text_targets() and
* gtk_drag_dest_set_target_list().
*
* Since: 2.6
*/
void
gtk_drag_dest_add_text_targets (GtkWidget *widget)
{
GtkTargetList *target_list;
target_list = gtk_drag_dest_get_target_list (widget);
if (target_list)
gtk_target_list_ref (target_list);
else
target_list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_text_targets (target_list, 0);
gtk_drag_dest_set_target_list (widget, target_list);
gtk_target_list_unref (target_list);
}
/**
* gtk_drag_dest_add_image_targets: (method)
* @widget: a #GtkWidget thats a drag destination
*
* Add the image targets supported by #GtkSelectionData to
* the target list of the drag destination. The targets
* are added with @info = 0. If you need another value,
* use gtk_target_list_add_image_targets() and
* gtk_drag_dest_set_target_list().
*
* Since: 2.6
*/
void
gtk_drag_dest_add_image_targets (GtkWidget *widget)
{
GtkTargetList *target_list;
target_list = gtk_drag_dest_get_target_list (widget);
if (target_list)
gtk_target_list_ref (target_list);
else
target_list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_image_targets (target_list, 0, FALSE);
gtk_drag_dest_set_target_list (widget, target_list);
gtk_target_list_unref (target_list);
}
/**
* gtk_drag_dest_add_uri_targets: (method)
* @widget: a #GtkWidget thats a drag destination
*
* Add the URI targets supported by #GtkSelectionData to
* the target list of the drag destination. The targets
* are added with @info = 0. If you need another value,
* use gtk_target_list_add_uri_targets() and
* gtk_drag_dest_set_target_list().
*
* Since: 2.6
*/
void
gtk_drag_dest_add_uri_targets (GtkWidget *widget)
{
GtkTargetList *target_list;
target_list = gtk_drag_dest_get_target_list (widget);
if (target_list)
gtk_target_list_ref (target_list);
else
target_list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_uri_targets (target_list, 0);
gtk_drag_dest_set_target_list (widget, target_list);
gtk_target_list_unref (target_list);
}
/**
* gtk_drag_dest_set_track_motion: (method)
* @widget: a #GtkWidget thats a drag destination
* @track_motion: whether to accept all targets
*
* Tells the widget to emit #GtkWidget::drag-motion and
* #GtkWidget::drag-leave events regardless of the targets and the
* %GTK_DEST_DEFAULT_MOTION flag.
*
* This may be used when a widget wants to do generic
* actions regardless of the targets that the source offers.
*
* Since: 2.10
*/
void
gtk_drag_dest_set_track_motion (GtkWidget *widget,
gboolean track_motion)
{
GtkDragDestSite *site;
g_return_if_fail (GTK_IS_WIDGET (widget));
site = g_object_get_data (G_OBJECT (widget), I_("gtk-drag-dest"));
g_return_if_fail (site != NULL);
site->track_motion = track_motion != FALSE;
}
/**
* gtk_drag_dest_get_track_motion: (method)
* @widget: a #GtkWidget thats a drag destination
*
* Returns whether the widget has been configured to always
* emit #GtkWidget::drag-motion signals.
*
* Returns: %TRUE if the widget always emits
* #GtkWidget::drag-motion events
*
* Since: 2.10
*/
gboolean
gtk_drag_dest_get_track_motion (GtkWidget *widget)
{
GtkDragDestSite *site;
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
site = g_object_get_data (G_OBJECT (widget), I_("gtk-drag-dest"));
if (site)
return site->track_motion;
return FALSE;
}
/**
* gtk_drag_dest_find_target: (method)
* @widget: drag destination widget
* @context: drag context
* @target_list: (allow-none): list of droppable targets, or %NULL to use
* gtk_drag_dest_get_target_list (@widget).
*
* Looks for a match between the supported targets of @context and the
* @dest_target_list, returning the first matching target, otherwise
* returning %GDK_NONE. @dest_target_list should usually be the return
* value from gtk_drag_dest_get_target_list(), but some widgets may
* have different valid targets for different parts of the widget; in
* that case, they will have to implement a drag_motion handler that
* passes the correct target list to this function.
*
* Returns: (transfer none): first target that the source offers
* and the dest can accept, or %GDK_NONE
*/
GdkAtom
gtk_drag_dest_find_target (GtkWidget *widget,
GdkDragContext *context,
GtkTargetList *target_list)
{
GList *tmp_target;
GList *tmp_source = NULL;
GtkWidget *source_widget;
g_return_val_if_fail (GTK_IS_WIDGET (widget), GDK_NONE);
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), GDK_NONE);
source_widget = gtk_drag_get_source_widget (context);
if (target_list == NULL)
target_list = gtk_drag_dest_get_target_list (widget);
if (target_list == NULL)
return GDK_NONE;
tmp_target = target_list->list;
while (tmp_target)
{
GtkTargetPair *pair = tmp_target->data;
tmp_source = gdk_drag_context_list_targets (context);
while (tmp_source)
{
if (tmp_source->data == GUINT_TO_POINTER (pair->target))
{
if ((!(pair->flags & GTK_TARGET_SAME_APP) || source_widget) &&
(!(pair->flags & GTK_TARGET_SAME_WIDGET) || (source_widget == widget)) &&
(!(pair->flags & GTK_TARGET_OTHER_APP) || !source_widget) &&
(!(pair->flags & GTK_TARGET_OTHER_WIDGET) || (source_widget != widget)))
return pair->target;
else
break;
}
tmp_source = tmp_source->next;
}
tmp_target = tmp_target->next;
}
return GDK_NONE;
}
+110
View File
@@ -0,0 +1,110 @@
/* -*- Mode: C; c-file-style: "gnu"; tab-width: 8 -*- */
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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 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/>.
*/
/*
* 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/.
*/
#ifndef __GTK_DRAG_DEST_H__
#define __GTK_DRAG_DEST_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/gtkselection.h>
#include <gtk/gtkwidget.h>
G_BEGIN_DECLS
/**
* GtkDestDefaults:
* @GTK_DEST_DEFAULT_MOTION: If set for a widget, GTK+, during a drag over this
* widget will check if the drag matches this widgets list of possible targets
* and actions.
* GTK+ will then call gdk_drag_status() as appropriate.
* @GTK_DEST_DEFAULT_HIGHLIGHT: If set for a widget, GTK+ will draw a highlight on
* this widget as long as a drag is over this widget and the widget drag format
* and action are acceptable.
* @GTK_DEST_DEFAULT_DROP: If set for a widget, when a drop occurs, GTK+ will
* will check if the drag matches this widgets list of possible targets and
* actions. If so, GTK+ will call gtk_drag_get_data() on behalf of the widget.
* Whether or not the drop is successful, GTK+ will call gtk_drag_finish(). If
* the action was a move, then if the drag was successful, then %TRUE will be
* passed for the @delete parameter to gtk_drag_finish().
* @GTK_DEST_DEFAULT_ALL: If set, specifies that all default actions should
* be taken.
*
* The #GtkDestDefaults enumeration specifies the various
* types of action that will be taken on behalf
* of the user for a drag destination site.
*/
typedef enum {
GTK_DEST_DEFAULT_MOTION = 1 << 0,
GTK_DEST_DEFAULT_HIGHLIGHT = 1 << 1,
GTK_DEST_DEFAULT_DROP = 1 << 2,
GTK_DEST_DEFAULT_ALL = 0x07
} GtkDestDefaults;
GDK_AVAILABLE_IN_ALL
void gtk_drag_dest_set (GtkWidget *widget,
GtkDestDefaults flags,
const GtkTargetEntry *targets,
gint n_targets,
GdkDragAction actions);
GDK_AVAILABLE_IN_ALL
void gtk_drag_dest_set_proxy (GtkWidget *widget,
GdkWindow *proxy_window,
GdkDragProtocol protocol,
gboolean use_coordinates);
GDK_AVAILABLE_IN_ALL
void gtk_drag_dest_unset (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
GdkAtom gtk_drag_dest_find_target (GtkWidget *widget,
GdkDragContext *context,
GtkTargetList *target_list);
GDK_AVAILABLE_IN_ALL
GtkTargetList* gtk_drag_dest_get_target_list (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_drag_dest_set_target_list (GtkWidget *widget,
GtkTargetList *target_list);
GDK_AVAILABLE_IN_ALL
void gtk_drag_dest_add_text_targets (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_drag_dest_add_image_targets (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_drag_dest_add_uri_targets (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_drag_dest_set_track_motion (GtkWidget *widget,
gboolean track_motion);
GDK_AVAILABLE_IN_ALL
gboolean gtk_drag_dest_get_track_motion (GtkWidget *widget);
G_END_DECLS
#endif /* __GTK_DRAG_DEST_H__ */
+29 -21
View File
@@ -70,6 +70,7 @@
#include "gtkmagnifierprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtkcsscustomgadgetprivate.h"
#include "gtkprogresstrackerprivate.h"
#include "a11y/gtkentryaccessible.h"
@@ -196,10 +197,11 @@ struct _GtkEntryPrivate
gdouble progress_pulse_fraction;
gdouble progress_pulse_current;
guint tick_id;
gint64 pulse1;
gint64 pulse2;
gint64 frame1;
guint tick_id;
GtkProgressTracker tracker;
gint64 pulse1;
gint64 pulse2;
gdouble last_iteration;
gchar *placeholder_text;
@@ -10394,31 +10396,30 @@ tick_cb (GtkWidget *widget,
{
GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = entry->priv;
gint64 frame2;
gdouble fraction;
gint64 frame_time;
gdouble iteration, pulse_iterations, current_iterations, fraction;
frame2 = gdk_frame_clock_get_frame_time (frame_clock);
if (priv->frame1 == 0)
priv->frame1 = frame2 - 16667;
if (priv->pulse1 == 0)
priv->pulse1 = priv->pulse2 - 250 * 1000000;
if (priv->pulse2 == 0 && priv->pulse1 == 0)
return G_SOURCE_CONTINUE;
frame_time = gdk_frame_clock_get_frame_time (frame_clock);
gtk_progress_tracker_advance_frame (&priv->tracker, frame_time);
g_assert (priv->pulse2 > priv->pulse1);
g_assert (frame2 > priv->frame1);
if (frame2 - priv->pulse2 > 3 * (priv->pulse2 - priv->pulse1))
{
priv->pulse1 = 0;
return G_SOURCE_CONTINUE;
}
pulse_iterations = (priv->pulse2 - priv->pulse1) / (gdouble) G_USEC_PER_SEC;
current_iterations = (frame_time - priv->pulse1) / (gdouble) G_USEC_PER_SEC;
iteration = gtk_progress_tracker_get_iteration (&priv->tracker);
/* Determine the fraction to move the block from one frame
* to the next when pulse_fraction is how far the block should
* move between two calls to gtk_entry_progress_pulse().
*/
fraction = priv->progress_pulse_fraction * (frame2 - priv->frame1) / MAX (frame2 - priv->pulse2, priv->pulse2 - priv->pulse1);
fraction = priv->progress_pulse_fraction * (iteration - priv->last_iteration) / MAX (pulse_iterations, current_iterations);
priv->last_iteration = iteration;
priv->frame1 = frame2;
if (current_iterations > 3 * pulse_iterations)
return G_SOURCE_CONTINUE;
/* advance the block */
if (priv->progress_pulse_way_back)
@@ -10483,6 +10484,9 @@ gtk_entry_start_pulse_mode (GtkEntry *entry)
gtk_css_gadget_add_class (priv->progress_gadget, GTK_STYLE_CLASS_PULSE);
priv->progress_pulse_mode = TRUE;
/* How long each pulse should last depends on calls to gtk_entry_progress_pulse.
* Just start the tracker to repeat forever with iterations every second. */
gtk_progress_tracker_start (&priv->tracker, G_USEC_PER_SEC, 0, INFINITY);
priv->tick_id = gtk_widget_add_tick_callback (GTK_WIDGET (entry), tick_cb, NULL, NULL);
priv->progress_fraction = 0.0;
@@ -10491,7 +10495,7 @@ gtk_entry_start_pulse_mode (GtkEntry *entry)
priv->pulse2 = 0;
priv->pulse1 = 0;
priv->frame1 = 0;
priv->last_iteration = 0;
}
static void
@@ -10514,9 +10518,13 @@ static void
gtk_entry_update_pulse (GtkEntry *entry)
{
GtkEntryPrivate *priv = entry->priv;
gint64 pulse_time = g_get_monotonic_time ();
if (priv->pulse2 == pulse_time)
return;
priv->pulse1 = priv->pulse2;
priv->pulse2 = g_get_monotonic_time ();
priv->pulse2 = pulse_time;
}
/**
+1
View File
@@ -36,6 +36,7 @@
#include "gtkcombobox.h"
#include "gtkcssiconthemevalueprivate.h"
#include "gtkdnd.h"
#include "gtkdragdest.h"
#include "gtkicontheme.h"
#include "deprecated/gtkiconfactory.h"
#include "gtkimage.h"
-36
View File
@@ -352,25 +352,6 @@ file_chooser_widget_file_activated (GtkFileChooser *chooser,
gtk_widget_activate (widget);
}
#if 0
/* FIXME: to see why this function is ifdef-ed out, see the comment below in
* file_chooser_widget_default_size_changed().
*/
static void
load_position (int *out_xpos, int *out_ypos)
{
GtkFileChooserSettings *settings;
int x, y, width, height;
settings = _gtk_file_chooser_settings_new ();
_gtk_file_chooser_settings_get_geometry (settings, &x, &y, &width, &height);
g_object_unref (settings);
*out_xpos = x;
*out_ypos = y;
}
#endif
static void
file_chooser_widget_default_size_changed (GtkWidget *widget,
GtkFileChooserDialog *dialog)
@@ -397,23 +378,6 @@ file_chooser_widget_default_size_changed (GtkWidget *widget,
&default_width, &default_height);
gtk_window_resize (GTK_WINDOW (dialog), default_width, default_height);
if (!gtk_widget_get_mapped (GTK_WIDGET (dialog)))
{
#if 0
/* FIXME: the code to restore the position does not work yet. It is not
* clear whether it is actually desirable --- if enabled, applications
* would not be able to say "center the file chooser on top of my toplevel
* window". So, we don't use this code at all.
*/
load_position (&xpos, &ypos);
if (xpos >= 0 && ypos >= 0)
{
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_NONE);
gtk_window_move (GTK_WINDOW (dialog), xpos, ypos);
}
#endif
}
}
static void
+1
View File
@@ -31,6 +31,7 @@
#include "gtkclipboard.h"
#include "gtkcomboboxtext.h"
#include "gtkdragsource.h"
#include "gtkdragdest.h"
#include "gtkentry.h"
#include "gtkexpander.h"
#include "gtkfilechooserprivate.h"
+6 -1
View File
@@ -646,7 +646,12 @@ gtk_header_bar_get_size (GtkWidget *widget,
center_min = center_nat = 0;
if (priv->label_box != NULL)
{
if (add_child_size (priv->label_sizing_box, orientation, &center_min, &center_nat))
if (orientation == GTK_ORIENTATION_HORIZONTAL)
add_child_size (priv->label_box, orientation, &center_min, &center_nat);
else
add_child_size (priv->label_sizing_box, orientation, &center_min, &center_nat);
if (_gtk_widget_get_visible (priv->label_sizing_box))
nvis_children += 1;
}
+16 -1
View File
@@ -1091,18 +1091,33 @@ static const gchar builtin_hicolor_index[] =
"[Icon Theme]\n"
"Name=Hicolor\n"
"Hidden=True\n"
"Directories=16x16/actions,22x22/actions,24x24/actions,32x32/actions\n"
"Directories=16x16/actions,16x16/status,22x22/actions,24x24/actions,24x24/status,32x32/actions,32x32/status,48x48/status,64x64/actions\n"
"[16x16/actions]\n"
"Size=16\n"
"Type=Threshold\n"
"[16x16/status]\n"
"Size=16\n"
"Type=Threshold\n"
"[22x22/actions]\n"
"Size=22\n"
"Type=Threshold\n"
"[24x24/actions]\n"
"Size=24\n"
"Type=Threshold\n"
"[24x24/status]\n"
"Size=24\n"
"Type=Threshold\n"
"[32x32/actions]\n"
"Size=32\n"
"Type=Threshold\n"
"[32x32/status]\n"
"Size=32\n"
"Type=Threshold\n"
"[48x48/status]\n"
"Size=48\n"
"Type=Threshold\n"
"[64x64/actions]\n"
"Size=64\n"
"Type=Threshold\n";
static void
+10 -150
View File
@@ -35,6 +35,7 @@
#include "gtkimcontextsimple.h"
#include "gtksettings.h"
#include "gtkprivate.h"
#include "gtkutilsprivate.h"
#include "gtkintl.h"
#ifdef GDK_WINDOWING_X11
@@ -331,147 +332,6 @@ add_builtin_module (const gchar *module_name,
return module;
}
static gboolean
scan_string (const char **pos, GString *out)
{
const char *p = *pos, *q = *pos;
char *tmp, *tmp2;
gboolean quoted;
while (g_ascii_isspace (*p))
p++;
if (!*p)
return FALSE;
else if (*p == '"')
{
p++;
quoted = FALSE;
for (q = p; (*q != '"') || quoted; q++)
{
if (!*q)
return FALSE;
quoted = (*q == '\\') && !quoted;
}
tmp = g_strndup (p, q - p);
tmp2 = g_strcompress (tmp);
g_string_truncate (out, 0);
g_string_append (out, tmp2);
g_free (tmp);
g_free (tmp2);
}
q++;
*pos = q;
return TRUE;
}
static gboolean
skip_space (const char **pos)
{
const char *p = *pos;
while (g_ascii_isspace (*p))
p++;
*pos = p;
return !(*p == '\0');
}
static gint
read_line (FILE *stream, GString *str)
{
gboolean quoted = FALSE;
gboolean comment = FALSE;
int n_read = 0;
int lines = 1;
flockfile (stream);
g_string_truncate (str, 0);
while (1)
{
int c;
c = getc_unlocked (stream);
if (c == EOF)
{
if (quoted)
g_string_append_c (str, '\\');
goto done;
}
else
n_read++;
if (quoted)
{
quoted = FALSE;
switch (c)
{
case '#':
g_string_append_c (str, '#');
break;
case '\r':
case '\n':
{
int next_c = getc_unlocked (stream);
if (!(next_c == EOF ||
(c == '\r' && next_c == '\n') ||
(c == '\n' && next_c == '\r')))
ungetc (next_c, stream);
lines++;
break;
}
default:
g_string_append_c (str, '\\');
g_string_append_c (str, c);
}
}
else
{
switch (c)
{
case '#':
comment = TRUE;
break;
case '\\':
if (!comment)
quoted = TRUE;
break;
case '\n':
{
int next_c = getc_unlocked (stream);
if (!(c == EOF ||
(c == '\r' && next_c == '\n') ||
(c == '\n' && next_c == '\r')))
ungetc (next_c, stream);
goto done;
}
default:
if (!comment)
g_string_append_c (str, c);
}
}
}
done:
funlockfile (stream);
return (n_read > 0) ? lines : 0;
}
static void
gtk_im_module_initialize (void)
{
@@ -558,13 +418,13 @@ gtk_im_module_initialize (void)
return;
}
while (!have_error && read_line (file, line_buf))
while (!have_error && gtk_read_line (file, line_buf))
{
const char *p;
p = line_buf->str;
if (!skip_space (&p))
if (!gtk_skip_space (&p))
{
/* Blank line marking the end of a module
*/
@@ -584,7 +444,7 @@ gtk_im_module_initialize (void)
*/
module = g_object_new (GTK_TYPE_IM_MODULE, NULL);
if (!scan_string (&p, tmp_buf) || skip_space (&p))
if (!gtk_scan_string (&p, tmp_buf) || gtk_skip_space (&p))
{
g_warning ("Error parsing context info in '%s'\n %s", filename, line_buf->str);
have_error = TRUE;
@@ -602,19 +462,19 @@ gtk_im_module_initialize (void)
/* Read information about a context type
*/
if (!scan_string (&p, tmp_buf))
if (!gtk_scan_string (&p, tmp_buf))
goto context_error;
info->context_id = g_strdup (tmp_buf->str);
if (!scan_string (&p, tmp_buf))
if (!gtk_scan_string (&p, tmp_buf))
goto context_error;
info->context_name = g_strdup (tmp_buf->str);
if (!scan_string (&p, tmp_buf))
if (!gtk_scan_string (&p, tmp_buf))
goto context_error;
info->domain = g_strdup (tmp_buf->str);
if (!scan_string (&p, tmp_buf))
if (!gtk_scan_string (&p, tmp_buf))
goto context_error;
info->domain_dirname = g_strdup (tmp_buf->str);
@@ -622,11 +482,11 @@ gtk_im_module_initialize (void)
correct_localedir_prefix ((char **) &info->domain_dirname);
#endif
if (!scan_string (&p, tmp_buf))
if (!gtk_scan_string (&p, tmp_buf))
goto context_error;
info->default_locales = g_strdup (tmp_buf->str);
if (skip_space (&p))
if (gtk_skip_space (&p))
goto context_error;
infos = g_slist_prepend (infos, info);
+9 -1
View File
@@ -113,7 +113,7 @@
#include "gtkaccelmapprivate.h"
#include "gtkbox.h"
#include "gtkclipboard.h"
#include "gtkclipboardprivate.h"
#include "gtkdebug.h"
#include "gtkdndprivate.h"
#include "gtkmain.h"
@@ -636,6 +636,7 @@ do_pre_parse_initialization (int *argc,
char ***argv)
{
const gchar *env_string;
double slowdown;
if (pre_initialized)
return;
@@ -673,6 +674,13 @@ do_pre_parse_initialization (int *argc,
g_string_append (gtk_modules_string, env_string);
}
env_string = g_getenv ("GTK_SLOWDOWN");
if (env_string)
{
slowdown = g_ascii_strtod (env_string, NULL);
_gtk_set_slowdown (slowdown);
}
}
static void
+4 -7
View File
@@ -26,6 +26,7 @@
#include "gtkprivate.h"
#include "gtkmodulesprivate.h"
#include "gtkintl.h"
#include "gtkutilsprivate.h"
#include <gmodule.h>
@@ -77,9 +78,7 @@ get_module_path (void)
g_free (default_dir);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
result = pango_split_file_list (module_path);
G_GNUC_END_IGNORE_DEPRECATIONS
result = gtk_split_file_list (module_path);
g_free (module_path);
return result;
@@ -419,10 +418,8 @@ load_modules (const char *module_str)
GTK_NOTE (MODULES, g_message ("Loading module list: %s", module_str));
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
module_names = pango_split_file_list (module_str);
G_GNUC_END_IGNORE_DEPRECATIONS
for (i = 0; module_names[i]; i++)
module_names = gtk_split_file_list (module_str);
for (i = 0; module_names[i]; i++)
module_list = load_module (module_list, module_names[i]);
module_list = g_slist_reverse (module_list);
+8 -2
View File
@@ -52,6 +52,7 @@
#include "gtkbutton.h"
#include "gtklistbox.h"
#include "gtkselection.h"
#include "gtkdragdest.h"
#include "gtkdnd.h"
#include "gtkseparator.h"
#include "gtkentry.h"
@@ -893,8 +894,13 @@ static void
update_trash_icon (GtkPlacesSidebar *sidebar)
{
if (sidebar->trash_row)
gtk_sidebar_row_set_icon (GTK_SIDEBAR_ROW (sidebar->trash_row),
_gtk_trash_monitor_get_icon (sidebar->trash_monitor));
{
GIcon *icon;
icon = _gtk_trash_monitor_get_icon (sidebar->trash_monitor);
gtk_sidebar_row_set_icon (GTK_SIDEBAR_ROW (sidebar->trash_row), icon);
g_object_unref (icon);
}
}
static void
+1 -1
View File
@@ -129,7 +129,7 @@ measure_available_space_finished (GObject *object,
* should be based on the free space available.
* i.e. 1 GB / 24 GB available.
*/
label = g_strdup_printf (ngettext ("%s / %s available", "%s / %s available", plural_form),
label = g_strdup_printf (dngettext (GETTEXT_PACKAGE, "%s / %s available", "%s / %s available", plural_form),
formatted_free_size, formatted_total_size);
gtk_label_set_label (row->available_space_label, label);
+7 -23
View File
@@ -110,6 +110,7 @@
#include "gtkmenusectionbox.h"
#include "gtkroundedboxprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkprogresstrackerprivate.h"
#ifdef GDK_WINDOWING_WAYLAND
#include "wayland/gdkwayland.h"
@@ -156,6 +157,7 @@ struct _GtkPopoverPrivate
GtkAdjustment *hadj;
GdkRectangle pointing_to;
GtkPopoverConstraint constraint;
GtkProgressTracker tracker;
guint prev_focus_unmap_id;
guint hierarchy_changed_id;
guint size_allocate_id;
@@ -173,7 +175,6 @@ struct _GtkPopoverPrivate
guint transitions_enabled : 1;
guint state : 2;
guint visible : 1;
gint64 start_time;
gint transition_diff;
guint tick_id;
@@ -510,17 +511,6 @@ gtk_popover_apply_modality (GtkPopover *popover,
}
}
/* From clutter-easing.c, based on Robert Penner's
* infamous easing equations, MIT license.
*/
static double
ease_out_cubic (double t)
{
double p = t - 1;
return p * p * p + 1;
}
static gboolean
show_animate_cb (GtkWidget *widget,
GdkFrameClock *frame_clock,
@@ -528,15 +518,11 @@ show_animate_cb (GtkWidget *widget,
{
GtkPopover *popover = GTK_POPOVER (widget);
GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
gint64 now = gdk_frame_clock_get_frame_time (frame_clock);
gdouble t;
if (now < (priv->start_time + TRANSITION_DURATION))
t = (now - priv->start_time) / (gdouble) (TRANSITION_DURATION);
else
t = 1.0;
t = ease_out_cubic (t);
gtk_progress_tracker_advance_frame (&priv->tracker,
gdk_frame_clock_get_frame_time (frame_clock));
t = gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE);
if (priv->state == STATE_SHOWING)
{
@@ -551,7 +537,7 @@ show_animate_cb (GtkWidget *widget,
gtk_popover_update_position (popover);
if (t >= 1.0)
if (gtk_progress_tracker_get_state (&priv->tracker) == GTK_PROGRESS_STATE_AFTER)
{
if (priv->state == STATE_SHOWING)
{
@@ -573,13 +559,11 @@ static void
gtk_popover_start_transition (GtkPopover *popover)
{
GtkPopoverPrivate *priv = popover->priv;
GdkFrameClock *clock;
if (priv->tick_id != 0)
return;
clock = gtk_widget_get_frame_clock (GTK_WIDGET (popover));
priv->start_time = gdk_frame_clock_get_frame_time (clock);
gtk_progress_tracker_start (&priv->tracker, TRANSITION_DURATION, 0, 1.0);
priv->tick_id = gtk_widget_add_tick_callback (GTK_WIDGET (popover),
show_animate_cb,
popover, NULL);
+4
View File
@@ -91,6 +91,10 @@ gboolean _gtk_propagate_captured_event (GtkWidget *widget,
GdkEvent *event,
GtkWidget *topmost);
gdouble _gtk_get_slowdown ();
void _gtk_set_slowdown (gdouble slowdown_factor);
#ifdef G_OS_WIN32
void _gtk_load_dll_with_libgtk3_manifest (const char *dllname);
#endif
+30 -21
View File
@@ -38,6 +38,7 @@
#include "gtkcssstylepropertyprivate.h"
#include "gtkcsscustomgadgetprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkprogresstrackerprivate.h"
#include "a11y/gtkprogressbaraccessible.h"
@@ -92,6 +93,7 @@
#define MIN_VERTICAL_BAR_WIDTH 7
#define MIN_VERTICAL_BAR_HEIGHT 80
#define DEFAULT_PULSE_DURATION 250000000
struct _GtkProgressBarPrivate
{
@@ -110,10 +112,11 @@ struct _GtkProgressBarPrivate
GtkOrientation orientation;
guint tick_id;
gint64 pulse1;
gint64 pulse2;
gint64 frame1;
guint tick_id;
GtkProgressTracker tracker;
gint64 pulse1;
gint64 pulse2;
gdouble last_iteration;
guint activity_dir : 1;
guint activity_mode : 1;
@@ -1142,31 +1145,30 @@ tick_cb (GtkWidget *widget,
{
GtkProgressBar *pbar = GTK_PROGRESS_BAR (widget);
GtkProgressBarPrivate *priv = pbar->priv;
gint64 frame2;
gdouble fraction;
gint64 frame_time;
gdouble iteration, pulse_iterations, current_iterations, fraction;
frame2 = gdk_frame_clock_get_frame_time (frame_clock);
if (priv->frame1 == 0)
priv->frame1 = frame2 - 16667;
if (priv->pulse1 == 0)
priv->pulse1 = priv->pulse2 - 250 * 1000000;
if (priv->pulse2 == 0 && priv->pulse1 == 0)
return G_SOURCE_CONTINUE;
frame_time = gdk_frame_clock_get_frame_time (frame_clock);
gtk_progress_tracker_advance_frame (&priv->tracker, frame_time);
g_assert (priv->pulse2 > priv->pulse1);
g_assert (frame2 > priv->frame1);
if (frame2 - priv->pulse2 > 3 * (priv->pulse2 - priv->pulse1))
{
priv->pulse1 = 0;
return G_SOURCE_CONTINUE;
}
pulse_iterations = (priv->pulse2 - priv->pulse1) / (gdouble) G_USEC_PER_SEC;
current_iterations = (frame_time - priv->pulse1) / (gdouble) G_USEC_PER_SEC;
iteration = gtk_progress_tracker_get_iteration (&priv->tracker);
/* Determine the fraction to move the block from one frame
* to the next when pulse_fraction is how far the block should
* move between two calls to gtk_progress_bar_pulse().
*/
fraction = priv->pulse_fraction * (frame2 - priv->frame1) / MAX (frame2 - priv->pulse2, priv->pulse2 - priv->pulse1);
fraction = priv->pulse_fraction * (iteration - priv->last_iteration) / MAX (pulse_iterations, current_iterations);
priv->last_iteration = iteration;
priv->frame1 = frame2;
if (current_iterations > 3 * pulse_iterations)
return G_SOURCE_CONTINUE;
/* advance the block */
if (priv->activity_dir == 0)
@@ -1243,10 +1245,13 @@ gtk_progress_bar_act_mode_enter (GtkProgressBar *pbar)
}
update_node_classes (pbar);
/* No fixed schedule for pulses, will adapt after calls to update_pulse. Just
* start the tracker to repeat forever with iterations every second.*/
gtk_progress_tracker_start (&priv->tracker, G_USEC_PER_SEC, 0, INFINITY);
priv->tick_id = gtk_widget_add_tick_callback (widget, tick_cb, NULL, NULL);
priv->pulse2 = 0;
priv->pulse1 = 0;
priv->frame1 = 0;
priv->last_iteration = 0;
}
static void
@@ -1406,9 +1411,13 @@ static void
gtk_progress_bar_update_pulse (GtkProgressBar *pbar)
{
GtkProgressBarPrivate *priv = pbar->priv;
gint64 pulse_time = g_get_monotonic_time ();
if (priv->pulse2 == pulse_time)
return;
priv->pulse1 = priv->pulse2;
priv->pulse2 = g_get_monotonic_time ();
priv->pulse2 = pulse_time;
}
/**
+268
View File
@@ -0,0 +1,268 @@
/*
* Copyright © 2016 Endless Mobile 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/>.
*
* Authors: Matthew Watson <mattdangerw@gmail.com>
*/
#include "gtkprogresstrackerprivate.h"
#include "gtkprivate.h"
#include "gtkcsseasevalueprivate.h"
#include <math.h>
#include <string.h>
/*
* Progress tracker is small helper for tracking progress through gtk
* animations. It's a simple zero-initable struct, meant to be thrown in a
* widget's private data without the need for setup or teardown.
*
* Progress tracker will handle translating frame clock timestamps to a
* fractional progress value for interpolating between animation targets.
*
* Progress tracker will use the GTK_SLOWDOWN environment variable to control
* the speed of animations. This can be useful for debugging.
*/
static gdouble gtk_slowdown = 1.0;
void
_gtk_set_slowdown (gdouble factor)
{
gtk_slowdown = factor;
}
gdouble
_gtk_get_slowdown (gdouble factor)
{
return gtk_slowdown;
}
/**
* gtk_progress_tracker_init_copy:
* @source: The source progress tracker
* @dest: The destination progress tracker
*
* Copy all progress tracker state from the source tracker to dest tracker.
**/
void
gtk_progress_tracker_init_copy (GtkProgressTracker *source,
GtkProgressTracker *dest)
{
memcpy (dest, source, sizeof (GtkProgressTracker));
}
/**
* gtk_progress_tracker_start:
* @tracker: The progress tracker
* @duration: Animation duration in us
* @delay: Animation delay in us
* @iteration_count: Number of iterations to run the animation, must be >= 0
*
* Begins tracking progress for a new animation. Clears all previous state.
**/
void
gtk_progress_tracker_start (GtkProgressTracker *tracker,
guint64 duration,
gint64 delay,
gdouble iteration_count)
{
tracker->is_running = TRUE;
tracker->last_frame_time = 0;
tracker->duration = duration;
tracker->iteration = - delay / (gdouble) duration;
tracker->iteration_count = iteration_count;
}
/**
* gtk_progress_tracker_finish:
* @tracker: The progress tracker
*
* Stops running the current animation.
**/
void
gtk_progress_tracker_finish (GtkProgressTracker *tracker)
{
tracker->is_running = FALSE;
}
/**
* gtk_progress_tracker_advance_frame:
* @tracker: The progress tracker
* @frame_time: The current frame time, usually from the frame clock.
*
* Increments the progress of the animation forward a frame. If no animation has
* been started, does nothing.
**/
void
gtk_progress_tracker_advance_frame (GtkProgressTracker *tracker,
guint64 frame_time)
{
gdouble delta;
if (!tracker->is_running)
return;
if (tracker->last_frame_time == 0)
{
tracker->last_frame_time = frame_time;
return;
}
if (frame_time < tracker->last_frame_time)
{
g_warning ("Progress tracker frame set backwards, ignoring.");
return;
}
delta = (frame_time - tracker->last_frame_time) / gtk_slowdown / tracker->duration;
tracker->last_frame_time = frame_time;
tracker->iteration += delta;
}
/**
* gtk_progress_tracker_skip_frame:
* @tracker: The progress tracker
* @frame_time: The current frame time, usually from the frame clock.
*
* Does not update the progress of the animation forward, but records the frame
* to calculate future deltas. Calling this each frame will effectively pause
* the animation.
**/
void
gtk_progress_tracker_skip_frame (GtkProgressTracker *tracker,
guint64 frame_time)
{
if (!tracker->is_running)
return;
tracker->last_frame_time = frame_time;
}
/**
* gtk_progress_tracker_get_state:
* @tracker: The progress tracker
*
* Returns whether the tracker is before, during or after the currently started
* animation. The tracker will only ever be in the before state if the animation
* was started with a delay. If no animation has been started, returns
* %GTK_PROGRESS_STATE_AFTER.
*
* Returns: A GtkProgressState
**/
GtkProgressState
gtk_progress_tracker_get_state (GtkProgressTracker *tracker)
{
if (!tracker->is_running || tracker->iteration > tracker->iteration_count)
return GTK_PROGRESS_STATE_AFTER;
if (tracker->iteration < 0)
return GTK_PROGRESS_STATE_BEFORE;
return GTK_PROGRESS_STATE_DURING;
}
/**
* gtk_progress_tracker_get_iteration:
* @tracker: The progress tracker
*
* Returns the fractional number of cycles the animation has completed. For
* example, it you started an animation with iteration-count of 2 and are half
* way through the second animation, this returns 1.5.
*
* Returns: The current iteration.
**/
gdouble
gtk_progress_tracker_get_iteration (GtkProgressTracker *tracker)
{
return tracker->is_running ? CLAMP (tracker->iteration, 0.0, tracker->iteration_count) : 1.0;
}
/**
* gtk_progress_tracker_get_iteration_cycle:
* @tracker: The progress tracker
*
* Returns an integer index of the current iteration cycle tracker is
* progressing through. Handles edge cases, such as an iteration value of 2.0
* which could be considered the end of the second iteration of the beginning of
* the third, in the same way as gtk_progress_tracker_get_progress().
*
* Returns: The integer count of the current animation cycle.
**/
guint64
gtk_progress_tracker_get_iteration_cycle (GtkProgressTracker *tracker)
{
gdouble iteration = gtk_progress_tracker_get_iteration (tracker);
/* Some complexity here. We want an iteration of 0.0 to always map to 0 (start
* of the first iteration), but an iteration of 1.0 to also map to 0 (end of
* first iteration) and 2.0 to 1 (end of the second iteration).
*/
if (iteration == 0.0)
return 0;
return (guint64) ceil (iteration) - 1;
}
/**
* gtk_progress_tracker_get_progress:
* @tracker: The progress tracker
* @reversed: If progress should be reversed.
*
* Gets the progress through the current animation iteration, from [0, 1]. Use
* to interpolate between animation targets. If reverse is true each iteration
* will begin at 1 and end at 0.
*
* Returns: The progress value.
**/
gdouble
gtk_progress_tracker_get_progress (GtkProgressTracker *tracker,
gboolean reversed)
{
gdouble progress, iteration;
guint64 iteration_cycle;
iteration = gtk_progress_tracker_get_iteration (tracker);
iteration_cycle = gtk_progress_tracker_get_iteration_cycle (tracker);
progress = iteration - iteration_cycle;
return reversed ? 1.0 - progress : progress;
}
/* From clutter-easing.c, based on Robert Penner's
* infamous easing equations, MIT license.
*/
static gdouble
ease_out_cubic (gdouble t)
{
gdouble p = t - 1;
return p * p * p + 1;
}
/**
* gtk_progress_tracker_get_ease_out_cubic:
* @tracker: The progress tracker
* @reversed: If progress should be reversed before applying the ease function.
*
* Applies a simple ease out cubic function to the result of
* gtk_progress_tracker_get_progress().
*
* Returns: The eased progress value.
**/
gdouble
gtk_progress_tracker_get_ease_out_cubic (GtkProgressTracker *tracker,
gboolean reversed)
{
gdouble progress = gtk_progress_tracker_get_progress (tracker, reversed);
return ease_out_cubic (progress);
}
+75
View File
@@ -0,0 +1,75 @@
/*
* Copyright © 2016 Endless Mobile 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/>.
*
* Authors: Matthew Watson <mattdangerw@gmail.com>
*/
#ifndef __GTK_PROGRESS_TRACKER_PRIVATE_H__
#define __GTK_PROGRESS_TRACKER_PRIVATE_H__
#include <glib-object.h>
#include "gtkcsseasevalueprivate.h"
G_BEGIN_DECLS
typedef enum {
GTK_PROGRESS_STATE_BEFORE,
GTK_PROGRESS_STATE_DURING,
GTK_PROGRESS_STATE_AFTER,
} GtkProgressState;
typedef struct _GtkProgressTracker GtkProgressTracker;
struct _GtkProgressTracker
{
gboolean is_running;
guint64 last_frame_time;
guint64 duration;
gdouble iteration;
gdouble iteration_count;
};
void gtk_progress_tracker_init_copy (GtkProgressTracker *source,
GtkProgressTracker *dest);
void gtk_progress_tracker_start (GtkProgressTracker *tracker,
guint64 duration,
gint64 delay,
gdouble iteration_count);
void gtk_progress_tracker_finish (GtkProgressTracker *tracker);
void gtk_progress_tracker_advance_frame (GtkProgressTracker *tracker,
guint64 frame_time);
void gtk_progress_tracker_skip_frame (GtkProgressTracker *tracker,
guint64 frame_time);
GtkProgressState gtk_progress_tracker_get_state (GtkProgressTracker *tracker);
gdouble gtk_progress_tracker_get_iteration (GtkProgressTracker *tracker);
guint64 gtk_progress_tracker_get_iteration_cycle (GtkProgressTracker *tracker);
gdouble gtk_progress_tracker_get_progress (GtkProgressTracker *tracker,
gboolean reverse);
gdouble gtk_progress_tracker_get_ease_out_cubic (GtkProgressTracker *tracker,
gboolean reverse);
G_END_DECLS
#endif /* __GTK_PROGRESS_TRACKER_PRIVATE_H__ */
+103 -152
View File
@@ -73,24 +73,13 @@
typedef struct _GtkRangeStepTimer GtkRangeStepTimer;
typedef enum {
MOUSE_OUTSIDE,
MOUSE_STEPPER_A,
MOUSE_STEPPER_B,
MOUSE_STEPPER_C,
MOUSE_STEPPER_D,
MOUSE_TROUGH,
MOUSE_SLIDER,
MOUSE_WIDGET /* inside widget but not in any of the above GUI elements */
} MouseLocation;
struct _GtkRangePrivate
{
MouseLocation mouse_location;
GtkCssGadget *mouse_location;
/* last mouse coords we got, or G_MININT if mouse is outside the range */
gint mouse_x;
gint mouse_y;
MouseLocation grab_location; /* "grabbed" mouse location, OUTSIDE for no grab */
GtkCssGadget *grab_location; /* "grabbed" mouse location, NULL for no grab */
GtkRangeStepTimer *timer;
@@ -180,13 +169,6 @@ enum {
LAST_SIGNAL
};
typedef enum {
STEPPER_A = MOUSE_STEPPER_A,
STEPPER_B = MOUSE_STEPPER_B,
STEPPER_C = MOUSE_STEPPER_C,
STEPPER_D = MOUSE_STEPPER_D
} Stepper;
static void gtk_range_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -270,8 +252,6 @@ static void gtk_range_adjustment_changed (GtkAdjustment *adjustme
static void gtk_range_add_step_timer (GtkRange *range,
GtkScrollType step);
static void gtk_range_remove_step_timer (GtkRange *range);
static void gtk_range_queue_allocate_location (GtkRange *range,
MouseLocation location);
static gboolean gtk_range_real_change_value (GtkRange *range,
GtkScrollType scroll,
gdouble value);
@@ -811,10 +791,8 @@ gtk_range_init (GtkRange *range)
priv->flippable = FALSE;
priv->min_slider_size = 1;
priv->round_digits = -1;
priv->mouse_location = MOUSE_OUTSIDE;
priv->mouse_x = G_MININT;
priv->mouse_y = G_MININT;
priv->grab_location = MOUSE_OUTSIDE;
priv->lower_sensitivity = GTK_SENSITIVITY_AUTO;
priv->upper_sensitivity = GTK_SENSITIVITY_AUTO;
priv->lower_sensitive = TRUE;
@@ -1021,7 +999,6 @@ update_fill_position (GtkRange *range)
static void
update_stepper_state (GtkRange *range,
Stepper stepper,
GtkCssGadget *gadget)
{
GtkRangePrivate *priv = range->priv;
@@ -1030,10 +1007,10 @@ update_stepper_state (GtkRange *range,
state = gtk_widget_get_state_flags (GTK_WIDGET (range));
if ((!priv->inverted && (stepper == STEPPER_A ||
stepper == STEPPER_C)) ||
(priv->inverted && (stepper == STEPPER_B ||
stepper == STEPPER_D)))
if ((!priv->inverted &&
(gadget == priv->stepper_a_gadget || gadget == priv->stepper_c_gadget)) ||
(priv->inverted &&
(gadget == priv->stepper_b_gadget || gadget == priv->stepper_d_gadget)))
arrow_sensitive = priv->lower_sensitive;
else
arrow_sensitive = priv->upper_sensitive;
@@ -1046,9 +1023,9 @@ update_stepper_state (GtkRange *range,
}
else
{
if (priv->grab_location == (MouseLocation)stepper)
if (priv->grab_location == gadget)
state |= GTK_STATE_FLAG_ACTIVE;
if (priv->mouse_location == (MouseLocation)stepper)
if (priv->mouse_location == gadget)
state |= GTK_STATE_FLAG_PRELIGHT;
}
@@ -1061,13 +1038,13 @@ update_steppers_state (GtkRange *range)
GtkRangePrivate *priv = range->priv;
if (priv->stepper_a_gadget)
update_stepper_state (range, STEPPER_A, priv->stepper_a_gadget);
update_stepper_state (range, priv->stepper_a_gadget);
if (priv->stepper_b_gadget)
update_stepper_state (range, STEPPER_B, priv->stepper_b_gadget);
update_stepper_state (range, priv->stepper_b_gadget);
if (priv->stepper_c_gadget)
update_stepper_state (range, STEPPER_C, priv->stepper_c_gadget);
update_stepper_state (range, priv->stepper_c_gadget);
if (priv->stepper_d_gadget)
update_stepper_state (range, STEPPER_D, priv->stepper_d_gadget);
update_stepper_state (range, priv->stepper_d_gadget);
}
/**
@@ -2006,8 +1983,6 @@ gtk_range_allocate_trough (GtkCssGadget *gadget,
{
GtkAllocation highlight_alloc, highlight_clip;
gtk_css_gadget_get_content_allocation (priv->slider_gadget,
&slider_alloc, NULL);
highlight_alloc = *allocation;
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
@@ -2283,10 +2258,11 @@ update_slider_state (GtkRange *range)
state &= ~(GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_ACTIVE);
if (priv->mouse_location == MOUSE_SLIDER && !(state & GTK_STATE_FLAG_INSENSITIVE))
if (priv->mouse_location == priv->slider_gadget &&
!(state & GTK_STATE_FLAG_INSENSITIVE))
state |= GTK_STATE_FLAG_PRELIGHT;
if (priv->grab_location == MOUSE_SLIDER)
if (priv->grab_location == priv->slider_gadget)
state |= GTK_STATE_FLAG_ACTIVE;
gtk_css_gadget_set_state (priv->slider_gadget, state);
@@ -2304,10 +2280,11 @@ update_trough_state (GtkRange *range)
gtk_css_gadget_set_state (priv->contents_gadget, state);
if (priv->mouse_location == MOUSE_TROUGH && !(state & GTK_STATE_FLAG_INSENSITIVE))
if (priv->mouse_location == priv->trough_gadget &&
!(state & GTK_STATE_FLAG_INSENSITIVE))
state |= GTK_STATE_FLAG_PRELIGHT;
if (priv->grab_location == MOUSE_TROUGH)
if (priv->grab_location == priv->trough_gadget)
state |= GTK_STATE_FLAG_ACTIVE;
gtk_css_gadget_set_state (priv->trough_gadget, state);
@@ -2407,7 +2384,7 @@ gtk_range_draw (GtkWidget *widget,
static void
range_grab_add (GtkRange *range,
MouseLocation location)
GtkCssGadget *location)
{
GtkRangePrivate *priv = range->priv;
GtkStyleContext *context;
@@ -2420,7 +2397,7 @@ range_grab_add (GtkRange *range,
* is the only widget receiving the pointer events.
*/
priv->grab_location = location;
gtk_range_queue_allocate_location (range, location);
gtk_css_gadget_queue_allocate (location);
update_trough_state (range);
update_slider_state (range);
@@ -2451,10 +2428,13 @@ range_grab_remove (GtkRange *range)
GtkRangePrivate *priv = range->priv;
GtkStyleContext *context;
if (!priv->grab_location)
return;
context = gtk_widget_get_style_context (GTK_WIDGET (range));
gtk_range_queue_allocate_location (range, priv->grab_location);
priv->grab_location = MOUSE_OUTSIDE;
gtk_css_gadget_queue_allocate (priv->grab_location);
priv->grab_location = NULL;
gtk_range_update_mouse_location (range);
@@ -2475,11 +2455,13 @@ range_get_scroll_for_grab (GtkRange *range)
invert = should_invert (range);
grab_button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (range->priv->multipress_gesture));
switch (priv->grab_location)
if (!priv->grab_location)
return GTK_SCROLL_NONE;
/* Backward stepper */
if (priv->grab_location == priv->stepper_a_gadget ||
priv->grab_location == priv->stepper_c_gadget)
{
/* Backward stepper */
case MOUSE_STEPPER_A:
case MOUSE_STEPPER_C:
switch (grab_button)
{
case GDK_BUTTON_PRIMARY:
@@ -2491,12 +2473,15 @@ range_get_scroll_for_grab (GtkRange *range)
case GDK_BUTTON_MIDDLE:
return invert ? GTK_SCROLL_END : GTK_SCROLL_START;
break;
default:
return GTK_SCROLL_NONE;
}
break;
}
/* Forward stepper */
case MOUSE_STEPPER_B:
case MOUSE_STEPPER_D:
/* Forward stepper */
if (priv->grab_location == priv->stepper_b_gadget ||
priv->grab_location == priv->stepper_d_gadget)
{
switch (grab_button)
{
case GDK_BUTTON_PRIMARY:
@@ -2508,23 +2493,18 @@ range_get_scroll_for_grab (GtkRange *range)
case GDK_BUTTON_MIDDLE:
return invert ? GTK_SCROLL_START : GTK_SCROLL_END;
break;
}
break;
default:
return GTK_SCROLL_NONE;
}
}
/* In the trough */
case MOUSE_TROUGH:
{
if (priv->trough_click_forward)
return GTK_SCROLL_PAGE_FORWARD;
else
return GTK_SCROLL_PAGE_BACKWARD;
}
break;
case MOUSE_OUTSIDE:
case MOUSE_SLIDER:
case MOUSE_WIDGET:
break;
/* In the trough */
if (priv->grab_location == priv->trough_gadget)
{
if (priv->trough_click_forward)
return GTK_SCROLL_PAGE_FORWARD;
else
return GTK_SCROLL_PAGE_BACKWARD;
}
return GTK_SCROLL_NONE;
@@ -2587,7 +2567,7 @@ gtk_range_key_press (GtkWidget *widget,
if (gtk_gesture_is_active (priv->drag_gesture) &&
device == gtk_gesture_get_device (priv->drag_gesture) &&
event->keyval == GDK_KEY_Escape &&
priv->grab_location != MOUSE_OUTSIDE)
priv->grab_location != NULL)
{
stop_scrolling (range);
@@ -2643,7 +2623,7 @@ gtk_range_long_press_gesture_pressed (GtkGestureLongPress *gesture,
gtk_range_update_mouse_location (range);
if (priv->mouse_location == MOUSE_SLIDER && !priv->zoom)
if (priv->mouse_location == priv->slider_gadget && !priv->zoom)
{
GtkAllocation slider_alloc;
@@ -2694,7 +2674,7 @@ gtk_range_multipress_gesture_pressed (GtkGestureMultiPress *gesture,
"gtk-primary-button-warps-slider", &primary_warps,
NULL);
if (priv->mouse_location == MOUSE_SLIDER &&
if (priv->mouse_location == priv->slider_gadget &&
gdk_event_triggers_context_menu ((GdkEvent *)event))
{
gboolean handled;
@@ -2704,21 +2684,21 @@ gtk_range_multipress_gesture_pressed (GtkGestureMultiPress *gesture,
return;
}
if (priv->mouse_location == MOUSE_SLIDER)
if (priv->mouse_location == priv->slider_gadget)
{
/* Shift-click in the slider = fine adjustment */
if (shift_pressed)
update_zoom_state (range, TRUE);
update_initial_slider_position (range, x, y, &slider_alloc);
range_grab_add (range, MOUSE_SLIDER);
range_grab_add (range, priv->slider_gadget);
gtk_widget_queue_draw (widget);
}
else if (priv->mouse_location == MOUSE_STEPPER_A ||
priv->mouse_location == MOUSE_STEPPER_B ||
priv->mouse_location == MOUSE_STEPPER_C ||
priv->mouse_location == MOUSE_STEPPER_D)
else if (priv->mouse_location == priv->stepper_a_gadget ||
priv->mouse_location == priv->stepper_b_gadget ||
priv->mouse_location == priv->stepper_c_gadget ||
priv->mouse_location == priv->stepper_d_gadget)
{
GtkScrollType scroll;
@@ -2734,7 +2714,7 @@ gtk_range_multipress_gesture_pressed (GtkGestureMultiPress *gesture,
add_autoscroll (range);
}
}
else if (priv->mouse_location == MOUSE_TROUGH &&
else if (priv->mouse_location == priv->trough_gadget &&
(source == GDK_SOURCE_TOUCHSCREEN ||
(button == GDK_BUTTON_PRIMARY &&
((primary_warps && !shift_pressed) ||
@@ -2760,13 +2740,13 @@ gtk_range_multipress_gesture_pressed (GtkGestureMultiPress *gesture,
gtk_range_compute_slider_position (range, new_value, &slider);
update_initial_slider_position (range, x, y, &slider);
range_grab_add (range, MOUSE_SLIDER);
range_grab_add (range, priv->slider_gadget);
gtk_widget_queue_draw (widget);
update_slider_position (range, x, y);
}
else if (priv->mouse_location == MOUSE_TROUGH &&
else if (priv->mouse_location == priv->trough_gadget &&
button == GDK_BUTTON_PRIMARY &&
((primary_warps && shift_pressed) ||
(!primary_warps && !shift_pressed)))
@@ -2780,12 +2760,12 @@ gtk_range_multipress_gesture_pressed (GtkGestureMultiPress *gesture,
y : x);
priv->trough_click_forward = click_value > gtk_adjustment_get_value (priv->adjustment);
range_grab_add (range, MOUSE_TROUGH);
range_grab_add (range, priv->trough_gadget);
scroll = range_get_scroll_for_grab (range);
gtk_range_add_step_timer (range, scroll);
}
else if (priv->mouse_location == MOUSE_TROUGH &&
else if (priv->mouse_location == priv->trough_gadget &&
button == GDK_BUTTON_SECONDARY)
{
/* autoscroll */
@@ -2796,16 +2776,16 @@ gtk_range_multipress_gesture_pressed (GtkGestureMultiPress *gesture,
y : x);
priv->trough_click_forward = click_value > gtk_adjustment_get_value (priv->adjustment);
range_grab_add (range, MOUSE_TROUGH);
range_grab_add (range, priv->trough_gadget);
remove_autoscroll (range);
range->priv->autoscroll_mode = priv->trough_click_forward ? GTK_SCROLL_END : GTK_SCROLL_START;
add_autoscroll (range);
}
if (priv->grab_location == MOUSE_SLIDER);
if (priv->grab_location == priv->slider_gadget);
/* leave it to ::drag-begin to claim the sequence */
else if (priv->grab_location != MOUSE_OUTSIDE)
else if (priv->grab_location != NULL)
gtk_gesture_set_state (priv->multipress_gesture, GTK_EVENT_SEQUENCE_CLAIMED);
}
@@ -3135,7 +3115,7 @@ gtk_range_drag_gesture_update (GtkGestureDrag *gesture,
GtkRangePrivate *priv = range->priv;
gdouble start_x, start_y;
if (range->priv->grab_location == MOUSE_SLIDER)
if (priv->grab_location == priv->slider_gadget)
{
gtk_gesture_drag_get_start_point (gesture, &start_x, &start_y);
priv->mouse_x = start_x + offset_x;
@@ -3154,8 +3134,10 @@ gtk_range_drag_gesture_begin (GtkGestureDrag *gesture,
gdouble offset_y,
GtkRange *range)
{
if (range->priv->grab_location == MOUSE_SLIDER)
gtk_gesture_set_state (range->priv->drag_gesture, GTK_EVENT_SEQUENCE_CLAIMED);
GtkRangePrivate *priv = range->priv;
if (priv->grab_location == priv->slider_gadget)
gtk_gesture_set_state (priv->drag_gesture, GTK_EVENT_SEQUENCE_CLAIMED);
}
static gboolean
@@ -3446,11 +3428,11 @@ gtk_range_update_mouse_location (GtkRange *range)
{
GtkRangePrivate *priv = range->priv;
gint x, y;
MouseLocation old;
GtkCssGadget *old_location;
GtkWidget *widget = GTK_WIDGET (range);
GdkRectangle trough_alloc, slider_alloc, slider_trace;
old = priv->mouse_location;
old_location = priv->mouse_location;
x = priv->mouse_x;
y = priv->mouse_y;
@@ -3459,38 +3441,43 @@ gtk_range_update_mouse_location (GtkRange *range)
gtk_css_gadget_get_border_box (priv->slider_gadget, &slider_alloc);
gdk_rectangle_union (&slider_alloc, &trough_alloc, &slider_trace);
if (priv->grab_location != MOUSE_OUTSIDE)
if (priv->grab_location != NULL)
priv->mouse_location = priv->grab_location;
else if (priv->stepper_a_gadget &&
gtk_css_gadget_border_box_contains_point (priv->stepper_a_gadget, x, y))
priv->mouse_location = MOUSE_STEPPER_A;
priv->mouse_location = priv->stepper_a_gadget;
else if (priv->stepper_b_gadget &&
gtk_css_gadget_border_box_contains_point (priv->stepper_b_gadget, x, y))
priv->mouse_location = MOUSE_STEPPER_B;
priv->mouse_location = priv->stepper_b_gadget;
else if (priv->stepper_c_gadget &&
gtk_css_gadget_border_box_contains_point (priv->stepper_c_gadget, x, y))
priv->mouse_location = MOUSE_STEPPER_C;
priv->mouse_location = priv->stepper_c_gadget;
else if (priv->stepper_d_gadget &&
gtk_css_gadget_border_box_contains_point (priv->stepper_d_gadget, x, y))
priv->mouse_location = MOUSE_STEPPER_D;
priv->mouse_location = priv->stepper_d_gadget;
else if (gtk_css_gadget_border_box_contains_point (priv->slider_gadget, x, y))
priv->mouse_location = MOUSE_SLIDER;
priv->mouse_location = priv->slider_gadget;
else if (rectangle_contains_point (&slider_trace, x, y))
priv->mouse_location = MOUSE_TROUGH;
priv->mouse_location = priv->trough_gadget;
else if (gtk_css_gadget_margin_box_contains_point (priv->gadget, x, y))
priv->mouse_location = MOUSE_WIDGET;
priv->mouse_location = priv->gadget;
else
priv->mouse_location = MOUSE_OUTSIDE;
priv->mouse_location = NULL;
if (old != priv->mouse_location)
if (old_location != priv->mouse_location)
{
gtk_range_queue_allocate_location (range, old);
gtk_range_queue_allocate_location (range, priv->mouse_location);
if (old_location != NULL)
gtk_css_gadget_queue_allocate (old_location);
if (priv->mouse_location == MOUSE_OUTSIDE)
gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_PRELIGHT);
if (priv->mouse_location != NULL)
{
gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_PRELIGHT, FALSE);
gtk_css_gadget_queue_allocate (priv->mouse_location);
}
else
gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_PRELIGHT, FALSE);
{
gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_PRELIGHT);
}
update_trough_state (range);
update_slider_state (range);
@@ -3636,10 +3623,10 @@ gtk_range_calc_slider (GtkRange *range)
gtk_css_gadget_set_visible (priv->slider_gadget, visible);
gtk_range_queue_allocate_location (range, MOUSE_SLIDER);
gtk_css_gadget_queue_allocate (priv->slider_gadget);
if (priv->has_origin)
gtk_range_queue_allocate_location (range, MOUSE_TROUGH);
gtk_css_gadget_queue_allocate (priv->trough_gadget);
gtk_range_update_mouse_location (range);
}
@@ -3693,53 +3680,17 @@ gtk_range_calc_stepper_sensitivity (GtkRange *range)
{
update_steppers_state (range);
gtk_range_queue_allocate_location (range, MOUSE_STEPPER_A);
gtk_range_queue_allocate_location (range, MOUSE_STEPPER_B);
gtk_range_queue_allocate_location (range, MOUSE_STEPPER_C);
gtk_range_queue_allocate_location (range, MOUSE_STEPPER_D);
if (priv->stepper_a_gadget)
gtk_css_gadget_queue_allocate (priv->stepper_a_gadget);
if (priv->stepper_b_gadget)
gtk_css_gadget_queue_allocate (priv->stepper_b_gadget);
if (priv->stepper_c_gadget)
gtk_css_gadget_queue_allocate (priv->stepper_c_gadget);
if (priv->stepper_d_gadget)
gtk_css_gadget_queue_allocate (priv->stepper_d_gadget);
}
}
static void
gtk_range_queue_allocate_location (GtkRange *range,
MouseLocation location)
{
GtkRangePrivate *priv = range->priv;
GtkCssGadget *gadget;
switch (location)
{
case MOUSE_STEPPER_A:
gadget = priv->stepper_a_gadget;
break;
case MOUSE_STEPPER_B:
gadget = priv->stepper_b_gadget;
break;
case MOUSE_STEPPER_C:
gadget = priv->stepper_c_gadget;
break;
case MOUSE_STEPPER_D:
gadget = priv->stepper_d_gadget;
break;
case MOUSE_TROUGH:
gadget = priv->trough_gadget;
break;
case MOUSE_SLIDER:
gadget = priv->slider_gadget;
break;
case MOUSE_WIDGET:
case MOUSE_OUTSIDE:
return;
default:
g_assert_not_reached ();
return;
}
/* FIXME: should we queue draw instead in some cases? */
if (gadget)
gtk_css_gadget_queue_allocate (gadget);
}
static void
gtk_range_calc_marks (GtkRange *range)
{
+14 -36
View File
@@ -25,6 +25,7 @@
#include <gdk/gdk.h>
#include "gtktypebuiltins.h"
#include "gtkprivate.h"
#include "gtkprogresstrackerprivate.h"
#include "gtkintl.h"
#include "fallback-c89.c"
@@ -85,8 +86,7 @@ typedef struct {
gdouble target_pos;
guint tick_id;
gint64 start_time;
gint64 end_time;
GtkProgressTracker tracker;
} GtkRevealerPrivate;
static GParamSpec *props[LAST_PROP] = { NULL, };
@@ -568,33 +568,6 @@ gtk_revealer_set_position (GtkRevealer *revealer,
g_object_notify_by_pspec (G_OBJECT (revealer), props[PROP_CHILD_REVEALED]);
}
/* From clutter-easing.c, based on Robert Penner's
* infamous easing equations, MIT license.
*/
static double
ease_out_cubic (double t)
{
double p = t - 1;
return p * p * p + 1;
}
static void
gtk_revealer_animate_step (GtkRevealer *revealer,
gint64 now)
{
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
gdouble t;
if (now < priv->end_time)
t = (now - priv->start_time) / (gdouble) (priv->end_time - priv->start_time);
else
t = 1.0;
t = ease_out_cubic (t);
gtk_revealer_set_position (revealer,
priv->source_pos + (t * (priv->target_pos - priv->source_pos)));
}
static gboolean
gtk_revealer_animate_cb (GtkWidget *widget,
GdkFrameClock *frame_clock,
@@ -602,11 +575,15 @@ gtk_revealer_animate_cb (GtkWidget *widget,
{
GtkRevealer *revealer = GTK_REVEALER (widget);
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
gint64 now;
gdouble ease;
now = gdk_frame_clock_get_frame_time (frame_clock);
gtk_revealer_animate_step (revealer, now);
if (priv->current_pos == priv->target_pos)
gtk_progress_tracker_advance_frame (&priv->tracker,
gdk_frame_clock_get_frame_time (frame_clock));
ease = gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE);
gtk_revealer_set_position (revealer,
priv->source_pos + (ease * (priv->target_pos - priv->source_pos)));
if (gtk_progress_tracker_get_state (&priv->tracker) == GTK_PROGRESS_STATE_AFTER)
{
priv->tick_id = 0;
return FALSE;
@@ -641,12 +618,13 @@ gtk_revealer_start_animation (GtkRevealer *revealer,
animations_enabled)
{
priv->source_pos = priv->current_pos;
priv->start_time = gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (widget));
priv->end_time = priv->start_time + (priv->transition_duration * 1000);
if (priv->tick_id == 0)
priv->tick_id =
gtk_widget_add_tick_callback (widget, gtk_revealer_animate_cb, revealer, NULL);
gtk_revealer_animate_step (revealer, priv->start_time);
gtk_progress_tracker_start (&priv->tracker,
priv->transition_duration * 1000,
0,
1.0);
}
else
{
+20 -22
View File
@@ -149,6 +149,7 @@ struct _GtkScaleMark
gdouble value;
int stop_position;
gchar *markup;
PangoLayout *layout;
GtkCssGadget *gadget;
GtkCssGadget *indicator_gadget;
GtkCssGadget *label_gadget;
@@ -1538,25 +1539,22 @@ gtk_scale_measure_mark_label (GtkCssGadget *gadget,
{
GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
GtkScaleMark *mark = user_data;
PangoRectangle logical_rect;
*minimum = *natural = 0;
if (mark->markup)
if (!mark->layout)
{
PangoLayout *layout;
PangoRectangle logical_rect;
layout = gtk_widget_create_pango_layout (widget, NULL);
pango_layout_set_markup (layout, mark->markup, -1);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
*minimum = *natural = logical_rect.width;
else
*minimum = *natural = logical_rect.height;
g_object_unref (layout);
mark->layout = gtk_widget_create_pango_layout (widget, NULL);
pango_layout_set_markup (mark->layout, mark->markup, -1);
}
pango_layout_get_pixel_extents (mark->layout, NULL, &logical_rect);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
*minimum = *natural = logical_rect.width;
else
*minimum = *natural = logical_rect.height;
}
static void
@@ -1741,18 +1739,13 @@ gtk_scale_render_mark_label (GtkCssGadget *gadget,
GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
GtkScaleMark *mark = user_data;
GtkStyleContext *context;
PangoLayout *layout;
context = gtk_widget_get_style_context (widget);
gtk_style_context_save_to_node (context, gtk_css_gadget_get_node (gadget));
layout = gtk_widget_create_pango_layout (widget, NULL);
pango_layout_set_markup (layout, mark->markup, -1);
gtk_render_layout (context, cr, x, y, layout);
gtk_render_layout (context, cr, x, y, mark->layout);
gtk_style_context_restore (context);
g_object_unref (layout);
return FALSE;
}
@@ -1975,6 +1968,7 @@ gtk_scale_mark_free (gpointer data)
g_object_unref (mark->indicator_gadget);
gtk_css_node_set_parent (gtk_css_gadget_get_node (mark->gadget), NULL);
g_object_unref (mark->gadget);
g_clear_object (&mark->layout);
g_free (mark->markup);
g_free (mark);
}
@@ -2081,7 +2075,9 @@ gtk_scale_add_mark (GtkScale *scale,
NULL, NULL);
gtk_css_node_insert_after (widget_node,
gtk_css_gadget_get_node (priv->top_marks_gadget),
priv->value_gadget ? gtk_css_gadget_get_node (priv->value_gadget) : NULL);
(priv->value_gadget &&
(priv->value_pos == GTK_POS_TOP || priv->value_pos == GTK_POS_LEFT)) ?
gtk_css_gadget_get_node (priv->value_gadget) : NULL);
gtk_css_gadget_add_class (priv->top_marks_gadget, GTK_STYLE_CLASS_TOP);
gtk_css_gadget_set_state (priv->top_marks_gadget, gtk_css_node_get_state (widget_node));
}
@@ -2100,7 +2096,9 @@ gtk_scale_add_mark (GtkScale *scale,
NULL, NULL);
gtk_css_node_insert_before (widget_node,
gtk_css_gadget_get_node (priv->bottom_marks_gadget),
priv->value_gadget ? gtk_css_gadget_get_node (priv->value_gadget) : NULL);
(priv->value_gadget &&
(priv->value_pos == GTK_POS_BOTTOM || priv->value_pos == GTK_POS_RIGHT)) ?
gtk_css_gadget_get_node (priv->value_gadget) : NULL);
gtk_css_gadget_add_class (priv->bottom_marks_gadget, GTK_STYLE_CLASS_BOTTOM);
gtk_css_gadget_set_state (priv->bottom_marks_gadget, gtk_css_node_get_state (widget_node));
}
+16 -35
View File
@@ -45,6 +45,7 @@
#include "gtkkineticscrolling.h"
#include "a11y/gtkscrolledwindowaccessible.h"
#include "gtkstylecontextprivate.h"
#include "gtkprogresstrackerprivate.h"
#include <math.h>
@@ -193,8 +194,7 @@ typedef struct
gdouble current_pos;
gdouble source_pos;
gdouble target_pos;
gint64 start_time;
gint64 end_time;
GtkProgressTracker tracker;
guint tick_id;
guint over_timeout_id;
} Indicator;
@@ -4002,40 +4002,22 @@ indicator_set_fade (Indicator *indicator,
}
}
static double
ease_out_cubic (double t)
{
double p = t - 1;
return p * p * p + 1;
}
static void
indicator_fade_step (Indicator *indicator,
gint64 now)
{
gdouble t;
if (now < indicator->end_time)
t = (now - indicator->start_time) / (gdouble) (indicator->end_time - indicator->start_time);
else
t = 1.0;
t = ease_out_cubic (t);
indicator_set_fade (indicator,
indicator->source_pos + (t * (indicator->target_pos - indicator->source_pos)));
}
static gboolean
indicator_fade_cb (GtkWidget *widget,
GdkFrameClock *frame_clock,
gpointer user_data)
{
Indicator *indicator = user_data;
gint64 now;
gdouble t;
now = gdk_frame_clock_get_frame_time (frame_clock);
indicator_fade_step (indicator, now);
if (indicator->current_pos == indicator->target_pos)
gtk_progress_tracker_advance_frame (&indicator->tracker,
gdk_frame_clock_get_frame_time (frame_clock));
t = gtk_progress_tracker_get_ease_out_cubic (&indicator->tracker, FALSE);
indicator_set_fade (indicator,
indicator->source_pos + (t * (indicator->target_pos - indicator->source_pos)));
if (gtk_progress_tracker_get_state (&indicator->tracker) == GTK_PROGRESS_STATE_AFTER)
{
indicator->tick_id = 0;
return FALSE;
@@ -4065,12 +4047,9 @@ indicator_start_fade (Indicator *indicator,
if (gtk_widget_get_mapped (indicator->scrollbar) && animations_enabled)
{
indicator->source_pos = indicator->current_pos;
indicator->start_time = gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (indicator->scrollbar));
indicator->end_time = indicator->start_time + INDICATOR_FADE_OUT_DURATION * 1000;
gtk_progress_tracker_start (&indicator->tracker, INDICATOR_FADE_OUT_DURATION * 1000, 0, 1.0);
if (indicator->tick_id == 0)
indicator->tick_id = gtk_widget_add_tick_callback (indicator->scrollbar, indicator_fade_cb, indicator, NULL);
indicator_fade_step (indicator, indicator->start_time);
}
else
indicator_set_fade (indicator, target);
@@ -4093,8 +4072,9 @@ indicator_stop_fade (Indicator *indicator)
}
gdk_window_hide (indicator->window);
gtk_progress_tracker_finish (&indicator->tracker);
indicator->current_pos = indicator->source_pos = indicator->target_pos = 0;
indicator->start_time = indicator->end_time = indicator->last_scroll_time = 0;
indicator->last_scroll_time = 0;
}
static gboolean
@@ -4297,8 +4277,9 @@ indicator_reset (Indicator *indicator)
indicator->scrollbar = NULL;
indicator->over = FALSE;
gtk_progress_tracker_finish (&indicator->tracker);
indicator->current_pos = indicator->source_pos = indicator->target_pos = 0;
indicator->start_time = indicator->end_time = indicator->last_scroll_time = 0;
indicator->last_scroll_time = 0;
}
static void
+21
View File
@@ -69,6 +69,27 @@ typedef struct _GtkTargetEntry GtkTargetEntry;
#define GTK_TYPE_SELECTION_DATA (gtk_selection_data_get_type ())
#define GTK_TYPE_TARGET_LIST (gtk_target_list_get_type ())
/**
* GtkTargetFlags:
* @GTK_TARGET_SAME_APP: If this is set, the target will only be selected
* for drags within a single application.
* @GTK_TARGET_SAME_WIDGET: If this is set, the target will only be selected
* for drags within a single widget.
* @GTK_TARGET_OTHER_APP: If this is set, the target will not be selected
* for drags within a single application.
* @GTK_TARGET_OTHER_WIDGET: If this is set, the target will not be selected
* for drags withing a single widget.
*
* The #GtkTargetFlags enumeration is used to specify
* constraints on a #GtkTargetEntry.
*/
typedef enum {
GTK_TARGET_SAME_APP = 1 << 0, /*< nick=same-app >*/
GTK_TARGET_SAME_WIDGET = 1 << 1, /*< nick=same-widget >*/
GTK_TARGET_OTHER_APP = 1 << 2, /*< nick=other-app >*/
GTK_TARGET_OTHER_WIDGET = 1 << 3 /*< nick=other-widget >*/
} GtkTargetFlags;
/**
* GtkTargetEntry:
* @target: a string representation of the target type
+1
View File
@@ -36,6 +36,7 @@
#include "gtkprivate.h"
#include "gtkrender.h"
#include "gtkdnd.h"
#include "gtkdragdest.h"
#include "gtkdebug.h"
#include "gtkintl.h"
#include "gtkmain.h"
+39 -52
View File
@@ -27,6 +27,7 @@
#include "gtkintl.h"
#include "gtkcsscustomgadgetprivate.h"
#include "gtkcontainerprivate.h"
#include "gtkprogresstrackerprivate.h"
#include "gtkwidgetprivate.h"
#include <math.h>
#include <string.h>
@@ -143,10 +144,9 @@ typedef struct {
GtkStackChildInfo *last_visible_child;
cairo_surface_t *last_visible_surface;
GtkAllocation last_visible_surface_allocation;
gdouble transition_pos;
guint tick_id;
gint64 start_time;
gint64 end_time;
GtkProgressTracker tracker;
gboolean first_frame_skipped;
gint last_visible_widget_width;
gint last_visible_widget_height;
@@ -765,16 +765,6 @@ gtk_stack_set_child_property (GtkContainer *container,
}
}
/* From clutter-easing.c, based on Robert Penner's
* infamous easing equations, MIT license.
*/
static double
ease_out_cubic (double t)
{
double p = t - 1;
return p * p * p + 1;
}
static inline gboolean
is_left_transition (GtkStackTransitionType transition_type)
{
@@ -863,12 +853,12 @@ get_bin_window_x (GtkStack *stack,
GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
int x = 0;
if (priv->transition_pos < 1.0)
if (gtk_progress_tracker_get_state (&priv->tracker) != GTK_PROGRESS_STATE_AFTER)
{
if (is_left_transition (priv->active_transition_type))
x = allocation->width * (1 - ease_out_cubic (priv->transition_pos));
x = allocation->width * (1 - gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
if (is_right_transition (priv->active_transition_type))
x = -allocation->width * (1 - ease_out_cubic (priv->transition_pos));
x = -allocation->width * (1 - gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
}
return x;
@@ -881,25 +871,22 @@ get_bin_window_y (GtkStack *stack,
GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
int y = 0;
if (priv->transition_pos < 1.0)
if (gtk_progress_tracker_get_state (&priv->tracker) != GTK_PROGRESS_STATE_AFTER)
{
if (is_up_transition (priv->active_transition_type))
y = allocation->height * (1 - ease_out_cubic (priv->transition_pos));
y = allocation->height * (1 - gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
if (is_down_transition(priv->active_transition_type))
y = -allocation->height * (1 - ease_out_cubic (priv->transition_pos));
y = -allocation->height * (1 - gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
}
return y;
}
static gboolean
gtk_stack_set_transition_position (GtkStack *stack,
gdouble pos)
static void
gtk_stack_progress_updated (GtkStack *stack)
{
GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
gboolean done;
priv->transition_pos = pos;
gtk_widget_queue_draw (GTK_WIDGET (stack));
if (!priv->vhomogeneous || !priv->hhomogeneous)
@@ -914,9 +901,7 @@ gtk_stack_set_transition_position (GtkStack *stack,
get_bin_window_x (stack, &allocation), get_bin_window_y (stack, &allocation));
}
done = pos >= 1.0;
if (done)
if (gtk_progress_tracker_get_state (&priv->tracker) == GTK_PROGRESS_STATE_AFTER)
{
if (priv->last_visible_surface != NULL)
{
@@ -930,8 +915,6 @@ gtk_stack_set_transition_position (GtkStack *stack,
priv->last_visible_child = NULL;
}
}
return done;
}
static gboolean
@@ -941,20 +924,20 @@ gtk_stack_transition_cb (GtkWidget *widget,
{
GtkStack *stack = GTK_STACK (widget);
GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
gint64 now;
gdouble t;
now = gdk_frame_clock_get_frame_time (frame_clock);
t = 1.0;
if (now < priv->end_time)
t = (now - priv->start_time) / (double) (priv->end_time - priv->start_time);
if (priv->first_frame_skipped)
gtk_progress_tracker_advance_frame (&priv->tracker,
gdk_frame_clock_get_frame_time (frame_clock));
else
priv->first_frame_skipped = TRUE;
/* Finish animation early if not mapped anymore */
if (!gtk_widget_get_mapped (widget))
t = 1.0;
gtk_progress_tracker_finish (&priv->tracker);
if (gtk_stack_set_transition_position (stack, t))
gtk_stack_progress_updated (GTK_STACK (widget));
if (gtk_progress_tracker_get_state (&priv->tracker) == GTK_PROGRESS_STATE_AFTER)
{
priv->tick_id = 0;
g_object_notify_by_pspec (G_OBJECT (stack), stack_props[PROP_TRANSITION_RUNNING]);
@@ -1037,17 +1020,20 @@ gtk_stack_start_transition (GtkStack *stack,
transition_duration != 0 &&
priv->last_visible_child != NULL)
{
priv->transition_pos = 0.0;
priv->start_time = gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (widget));
priv->end_time = priv->start_time + (transition_duration * 1000);
priv->active_transition_type = effective_transition_type (stack, transition_type);
priv->first_frame_skipped = FALSE;
gtk_stack_schedule_ticks (stack);
gtk_progress_tracker_start (&priv->tracker,
priv->transition_duration * 1000,
0,
1.0);
}
else
{
gtk_stack_unschedule_ticks (stack);
priv->active_transition_type = GTK_STACK_TRANSITION_TYPE_NONE;
gtk_stack_set_transition_position (stack, 1.0);
gtk_progress_tracker_finish (&priv->tracker);
gtk_stack_progress_updated (GTK_STACK (widget));
}
}
@@ -1962,6 +1948,7 @@ gtk_stack_draw_crossfade (GtkWidget *widget,
{
GtkStack *stack = GTK_STACK (widget);
GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
gdouble progress = gtk_progress_tracker_get_progress (&priv->tracker, FALSE);
cairo_push_group (cr);
gtk_container_propagate_draw (GTK_CONTAINER (stack),
@@ -1969,8 +1956,8 @@ gtk_stack_draw_crossfade (GtkWidget *widget,
cr);
cairo_save (cr);
/* Multiply alpha by transition pos */
cairo_set_source_rgba (cr, 1, 1, 1, priv->transition_pos);
/* Multiply alpha by progress */
cairo_set_source_rgba (cr, 1, 1, 1, progress);
cairo_set_operator (cr, CAIRO_OPERATOR_DEST_IN);
cairo_paint (cr);
@@ -1980,7 +1967,7 @@ gtk_stack_draw_crossfade (GtkWidget *widget,
priv->last_visible_surface_allocation.x,
priv->last_visible_surface_allocation.y);
cairo_set_operator (cr, CAIRO_OPERATOR_ADD);
cairo_paint_with_alpha (cr, MAX (1.0 - priv->transition_pos, 0));
cairo_paint_with_alpha (cr, MAX (1.0 - progress, 0));
}
cairo_restore (cr);
@@ -2009,22 +1996,22 @@ gtk_stack_draw_under (GtkWidget *widget,
{
case GTK_STACK_TRANSITION_TYPE_UNDER_DOWN:
y = 0;
height = allocation.height * (ease_out_cubic (priv->transition_pos));
height = allocation.height * (gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
pos_y = height;
break;
case GTK_STACK_TRANSITION_TYPE_UNDER_UP:
y = allocation.height * (1 - ease_out_cubic (priv->transition_pos));
y = allocation.height * (1 - gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
height = allocation.height - y;
pos_y = y - allocation.height;
break;
case GTK_STACK_TRANSITION_TYPE_UNDER_LEFT:
x = allocation.width * (1 - ease_out_cubic (priv->transition_pos));
x = allocation.width * (1 - gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
width = allocation.width - x;
pos_x = x - allocation.width;
break;
case GTK_STACK_TRANSITION_TYPE_UNDER_RIGHT:
x = 0;
width = allocation.width * (ease_out_cubic (priv->transition_pos));
width = allocation.width * (gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
pos_x = width;
break;
default:
@@ -2155,7 +2142,7 @@ gtk_stack_render (GtkCssGadget *gadget,
if (priv->visible_child)
{
if (priv->transition_pos < 1.0)
if (gtk_progress_tracker_get_state (&priv->tracker) != GTK_PROGRESS_STATE_AFTER)
{
if (priv->last_visible_surface == NULL &&
priv->last_visible_child != NULL)
@@ -2428,13 +2415,13 @@ gtk_stack_measure (GtkCssGadget *gadget,
{
if (orientation == GTK_ORIENTATION_VERTICAL && !priv->vhomogeneous)
{
gdouble t = priv->interpolate_size ? ease_out_cubic (priv->transition_pos) : 1.0;
gdouble t = priv->interpolate_size ? gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE) : 1.0;
*minimum = LERP (*minimum, priv->last_visible_widget_height, t);
*natural = LERP (*natural, priv->last_visible_widget_height, t);
}
if (orientation == GTK_ORIENTATION_HORIZONTAL && !priv->hhomogeneous)
{
gdouble t = priv->interpolate_size ? ease_out_cubic (priv->transition_pos) : 1.0;
gdouble t = priv->interpolate_size ? gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE) : 1.0;
*minimum = LERP (*minimum, priv->last_visible_widget_width, t);
*natural = LERP (*natural, priv->last_visible_widget_width, t);
}
+1
View File
@@ -22,6 +22,7 @@
#include "gtkradiobutton.h"
#include "gtklabel.h"
#include "gtkdnd.h"
#include "gtkdragdest.h"
#include "gtkorientable.h"
#include "gtkprivate.h"
#include "gtkintl.h"
+33 -18
View File
@@ -23,23 +23,27 @@
G_DEFINE_ABSTRACT_TYPE (GtkStyleAnimation, _gtk_style_animation, G_TYPE_OBJECT)
static GtkStyleAnimation *
gtk_style_animation_real_advance (GtkStyleAnimation *animation,
gint64 timestamp)
{
return NULL;
}
static void
gtk_style_animation_real_set_values (GtkStyleAnimation *animation,
gint64 for_time_us,
GtkCssAnimatedStyle *style)
gtk_style_animation_real_apply_values (GtkStyleAnimation *animation,
GtkCssAnimatedStyle *style)
{
}
static gboolean
gtk_style_animation_real_is_finished (GtkStyleAnimation *animation,
gint64 at_time_us)
gtk_style_animation_real_is_finished (GtkStyleAnimation *animation)
{
return TRUE;
}
static gboolean
gtk_style_animation_real_is_static (GtkStyleAnimation *animation,
gint64 at_time_us)
gtk_style_animation_real_is_static (GtkStyleAnimation *animation)
{
return FALSE;
}
@@ -47,7 +51,8 @@ gtk_style_animation_real_is_static (GtkStyleAnimation *animation,
static void
_gtk_style_animation_class_init (GtkStyleAnimationClass *klass)
{
klass->set_values = gtk_style_animation_real_set_values;
klass->advance = gtk_style_animation_real_advance;
klass->apply_values = gtk_style_animation_real_apply_values;
klass->is_finished = gtk_style_animation_real_is_finished;
klass->is_static = gtk_style_animation_real_is_static;
}
@@ -57,10 +62,22 @@ _gtk_style_animation_init (GtkStyleAnimation *animation)
{
}
GtkStyleAnimation *
_gtk_style_animation_advance (GtkStyleAnimation *animation,
gint64 timestamp)
{
GtkStyleAnimationClass *klass;
g_return_val_if_fail (GTK_IS_STYLE_ANIMATION (animation), NULL);
klass = GTK_STYLE_ANIMATION_GET_CLASS (animation);
return klass->advance (animation, timestamp);
}
void
_gtk_style_animation_set_values (GtkStyleAnimation *animation,
gint64 for_time_us,
GtkCssAnimatedStyle *style)
_gtk_style_animation_apply_values (GtkStyleAnimation *animation,
GtkCssAnimatedStyle *style)
{
GtkStyleAnimationClass *klass;
@@ -69,12 +86,11 @@ _gtk_style_animation_set_values (GtkStyleAnimation *animation,
klass = GTK_STYLE_ANIMATION_GET_CLASS (animation);
klass->set_values (animation, for_time_us, style);
klass->apply_values (animation, style);
}
gboolean
_gtk_style_animation_is_finished (GtkStyleAnimation *animation,
gint64 at_time_us)
_gtk_style_animation_is_finished (GtkStyleAnimation *animation)
{
GtkStyleAnimationClass *klass;
@@ -82,7 +98,7 @@ _gtk_style_animation_is_finished (GtkStyleAnimation *animation,
klass = GTK_STYLE_ANIMATION_GET_CLASS (animation);
return klass->is_finished (animation, at_time_us);
return klass->is_finished (animation);
}
/**
@@ -97,8 +113,7 @@ _gtk_style_animation_is_finished (GtkStyleAnimation *animation,
* Returns: %TRUE if @animation will not change anymore after @at_time_us
**/
gboolean
_gtk_style_animation_is_static (GtkStyleAnimation *animation,
gint64 at_time_us)
_gtk_style_animation_is_static (GtkStyleAnimation *animation)
{
GtkStyleAnimationClass *klass;
@@ -106,5 +121,5 @@ _gtk_style_animation_is_static (GtkStyleAnimation *animation,
klass = GTK_STYLE_ANIMATION_GET_CLASS (animation);
return klass->is_static (animation, at_time_us);
return klass->is_static (animation);
}
+10 -12
View File
@@ -43,24 +43,22 @@ struct _GtkStyleAnimationClass
{
GObjectClass parent_class;
gboolean (* is_finished) (GtkStyleAnimation *animation,
gint64 at_time_us);
gboolean (* is_static) (GtkStyleAnimation *animation,
gint64 at_time_us);
void (* set_values) (GtkStyleAnimation *animation,
gint64 for_time_us,
gboolean (* is_finished) (GtkStyleAnimation *animation);
gboolean (* is_static) (GtkStyleAnimation *animation);
void (* apply_values) (GtkStyleAnimation *animation,
GtkCssAnimatedStyle *style);
GtkStyleAnimation * (* advance) (GtkStyleAnimation *animation,
gint64 timestamp);
};
GType _gtk_style_animation_get_type (void) G_GNUC_CONST;
void _gtk_style_animation_set_values (GtkStyleAnimation *animation,
gint64 for_time_us,
GtkStyleAnimation * _gtk_style_animation_advance (GtkStyleAnimation *animation,
gint64 timestamp);
void _gtk_style_animation_apply_values (GtkStyleAnimation *animation,
GtkCssAnimatedStyle *style);
gboolean _gtk_style_animation_is_finished (GtkStyleAnimation *animation,
gint64 at_time_us);
gboolean _gtk_style_animation_is_static (GtkStyleAnimation *animation,
gint64 at_time_us);
gboolean _gtk_style_animation_is_finished (GtkStyleAnimation *animation);
gboolean _gtk_style_animation_is_static (GtkStyleAnimation *animation);
G_END_DECLS
+8 -25
View File
@@ -67,6 +67,7 @@
#include "gtkwidgetprivate.h"
#include "gtkcssshadowsvalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkprogresstrackerprivate.h"
#include "fallback-c89.c"
@@ -86,9 +87,8 @@ struct _GtkSwitchPrivate
GtkCssGadget *slider_gadget;
double handle_pos;
gint64 start_time;
gint64 end_time;
guint tick_id;
GtkProgressTracker tracker;
guint state : 1;
guint is_active : 1;
@@ -131,17 +131,6 @@ G_DEFINE_TYPE_WITH_CODE (GtkSwitch, gtk_switch, GTK_TYPE_WIDGET,
gtk_switch_activatable_interface_init));
G_GNUC_END_IGNORE_DEPRECATIONS;
/* From clutter-easing.c, based on Robert Penner's
* infamous easing equations, MIT license.
*/
static gdouble
ease_out_cubic (gdouble t)
{
gdouble p = t - 1;
return p * p * p + 1;
}
static void
gtk_switch_end_toggle_animation (GtkSwitch *sw)
{
@@ -161,20 +150,16 @@ gtk_switch_on_frame_clock_update (GtkWidget *widget,
{
GtkSwitch *sw = GTK_SWITCH (widget);
GtkSwitchPrivate *priv = sw->priv;
gint64 now;
now = gdk_frame_clock_get_frame_time (clock);
gtk_progress_tracker_advance_frame (&priv->tracker,
gdk_frame_clock_get_frame_time (clock));
if (now < priv->end_time)
if (gtk_progress_tracker_get_state (&priv->tracker) != GTK_PROGRESS_STATE_AFTER)
{
gdouble t;
t = (now - priv->start_time) / (gdouble) (priv->end_time - priv->start_time);
t = ease_out_cubic (t);
if (priv->is_active)
priv->handle_pos = 1.0 - t;
priv->handle_pos = 1.0 - gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE);
else
priv->handle_pos = t;
priv->handle_pos = gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE);
}
else
{
@@ -200,9 +185,7 @@ gtk_switch_begin_toggle_animation (GtkSwitch *sw)
if (animate)
{
GdkFrameClock *clock = gtk_widget_get_frame_clock (GTK_WIDGET (sw));
priv->start_time = gdk_frame_clock_get_frame_time (clock);
priv->end_time = priv->start_time + 1000 * ANIMATION_DURATION;
gtk_progress_tracker_start (&priv->tracker, 1000 * ANIMATION_DURATION, 0, 1.0);
if (priv->tick_id == 0)
priv->tick_id = gtk_widget_add_tick_callback (GTK_WIDGET (sw),
gtk_switch_on_frame_clock_update,
+28 -50
View File
@@ -97,79 +97,57 @@ static void
update_has_trash_and_notify (GtkTrashMonitor *monitor,
gboolean has_trash)
{
if (monitor->has_trash == !!has_trash)
return;
monitor->has_trash = !!has_trash;
g_signal_emit (monitor, signals[TRASH_STATE_CHANGED], 0);
}
/* Use G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT since we only want to know whether the
* trash is empty or not, not access its children. This is available for the
* trash backend since it uses a cache. In this way we prevent flooding the
* trash backend with enumeration requests when trashing > 1000 files
*/
static void
trash_enumerate_next_files_cb (GObject *source,
GAsyncResult *result,
gpointer user_data)
trash_query_info_cb (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
GtkTrashMonitor *monitor = GTK_TRASH_MONITOR (user_data);
GFileEnumerator *enumerator;
GList *infos;
GFileInfo *info;
guint32 item_count;
gboolean has_trash = FALSE;
enumerator = G_FILE_ENUMERATOR (source);
info = g_file_query_info_finish (G_FILE (source), result, NULL);
infos = g_file_enumerator_next_files_finish (enumerator, result, NULL);
if (infos)
if (info != NULL)
{
update_has_trash_and_notify (monitor, TRUE);
g_list_free_full (infos, g_object_unref);
}
else
{
update_has_trash_and_notify (monitor, FALSE);
item_count = g_file_info_get_attribute_uint32 (info,
G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT);
has_trash = item_count > 0;
g_object_unref (info);
}
update_has_trash_and_notify (monitor, has_trash);
g_object_unref (monitor); /* was reffed in recompute_trash_state() */
}
/* Callback used from g_file_enumerate_children_async() - this is what enumerates "trash:///" */
static void
trash_enumerate_children_cb (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
GtkTrashMonitor *monitor = GTK_TRASH_MONITOR (user_data);
GFileEnumerator *enumerator;
enumerator = g_file_enumerate_children_finish (G_FILE (source), result, NULL);
if (enumerator)
{
g_file_enumerator_next_files_async (enumerator,
1,
G_PRIORITY_DEFAULT,
NULL,
trash_enumerate_next_files_cb,
monitor);
g_object_unref (enumerator);
}
else
{
update_has_trash_and_notify (monitor, FALSE);
g_object_unref (monitor); /* was reffed in recompute_trash_state() */
}
}
/* Asynchronously recomputes whether there is trash or not */
static void
recompute_trash_state (GtkTrashMonitor *monitor)
{
GFile *file;
g_object_ref (monitor);
file = g_file_new_for_uri ("trash:///");
g_file_enumerate_children_async (file,
G_FILE_ATTRIBUTE_STANDARD_TYPE,
G_FILE_QUERY_INFO_NONE,
G_PRIORITY_DEFAULT,
NULL,
trash_enumerate_children_cb,
monitor);
g_file_query_info_async (file,
G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT,
G_FILE_QUERY_INFO_NONE,
G_PRIORITY_DEFAULT, NULL,
trash_query_info_cb, g_object_ref (monitor));
g_object_unref (file);
}
+4 -7
View File
@@ -526,22 +526,19 @@ gtk_tree_model_filter_class_init (GtkTreeModelFilterClass *filter_class)
filter_class->visible = gtk_tree_model_filter_real_visible;
filter_class->modify = gtk_tree_model_filter_real_modify;
/* Properties -- FIXME: disabled translations for now, until I can come up with a
* better description
*/
g_object_class_install_property (object_class,
PROP_CHILD_MODEL,
g_param_spec_object ("child-model",
("The child model"),
("The model for the filtermodel to filter"),
P_("The child model"),
P_("The model for the filtermodel to filter"),
GTK_TYPE_TREE_MODEL,
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_VIRTUAL_ROOT,
g_param_spec_boxed ("virtual-root",
("The virtual root"),
("The virtual root (relative to the child model) for this filtermodel"),
P_("The virtual root"),
P_("The virtual root (relative to the child model) for this filtermodel"),
GTK_TYPE_TREE_PATH,
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
+266
View File
@@ -0,0 +1,266 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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 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/>.Free
*/
/*
* 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/.
*/
#include "config.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gstdio.h>
#include <gmodule.h>
/* Copied from pango-utils.c */
/* We need to call getc() a lot in a loop. This is suboptimal,
* as getc() does thread locking on the FILE it is given.
* To optimize that, lock the file first, then call getc(),
* then unlock.
* If locking functions are not present in libc, fall back
* to the suboptimal getc().
*/
#if !defined(HAVE_FLOCKFILE) && !defined(HAVE__LOCK_FILE)
# define flockfile(f) (void)1
# define funlockfile(f) (void)1
# define getc_unlocked(f) getc(f)
#elif !defined(HAVE_FLOCKFILE) && defined(HAVE__LOCK_FILE)
# define flockfile(f) _lock_file(f)
# define funlockfile(f) _unlock_file(f)
# define getc_unlocked(f) _getc_nolock(f)
#endif
gboolean
gtk_scan_string (const char **pos, GString *out)
{
const char *p = *pos, *q = *pos;
char *tmp, *tmp2;
gboolean quoted;
while (g_ascii_isspace (*p))
p++;
if (!*p)
return FALSE;
else if (*p == '"')
{
p++;
quoted = FALSE;
for (q = p; (*q != '"') || quoted; q++)
{
if (!*q)
return FALSE;
quoted = (*q == '\\') && !quoted;
}
tmp = g_strndup (p, q - p);
tmp2 = g_strcompress (tmp);
g_string_truncate (out, 0);
g_string_append (out, tmp2);
g_free (tmp);
g_free (tmp2);
}
q++;
*pos = q;
return TRUE;
}
gboolean
gtk_skip_space (const char **pos)
{
const char *p = *pos;
while (g_ascii_isspace (*p))
p++;
*pos = p;
return !(*p == '\0');
}
gint
gtk_read_line (FILE *stream, GString *str)
{
gboolean quoted = FALSE;
gboolean comment = FALSE;
int n_read = 0;
int lines = 1;
flockfile (stream);
g_string_truncate (str, 0);
while (1)
{
int c;
c = getc_unlocked (stream);
if (c == EOF)
{
if (quoted)
g_string_append_c (str, '\\');
goto done;
}
else
n_read++;
if (quoted)
{
quoted = FALSE;
switch (c)
{
case '#':
g_string_append_c (str, '#');
break;
case '\r':
case '\n':
{
int next_c = getc_unlocked (stream);
if (!(next_c == EOF ||
(c == '\r' && next_c == '\n') ||
(c == '\n' && next_c == '\r')))
ungetc (next_c, stream);
lines++;
break;
}
default:
g_string_append_c (str, '\\');
g_string_append_c (str, c);
}
}
else
{
switch (c)
{
case '#':
comment = TRUE;
break;
case '\\':
if (!comment)
quoted = TRUE;
break;
case '\n':
{
int next_c = getc_unlocked (stream);
if (!(c == EOF ||
(c == '\r' && next_c == '\n') ||
(c == '\n' && next_c == '\r')))
ungetc (next_c, stream);
goto done;
}
default:
if (!comment)
g_string_append_c (str, c);
}
}
}
done:
funlockfile (stream);
return (n_read > 0) ? lines : 0;
}
char *
gtk_trim_string (const char *str)
{
int len;
g_return_val_if_fail (str != NULL, NULL);
while (*str && g_ascii_isspace (*str))
str++;
len = strlen (str);
while (len > 0 && g_ascii_isspace (str[len - 1]))
len--;
return g_strndup (str, len);
}
char **
gtk_split_file_list (const char *str)
{
int i = 0;
int j;
char **files;
files = g_strsplit (str, G_SEARCHPATH_SEPARATOR_S, -1);
while (files[i])
{
char *file = gtk_trim_string (files[i]);
/* If the resulting file is empty, skip it */
if (file[0] == '\0')
{
g_free (file);
g_free (files[i]);
for (j = i + 1; files[j]; j++)
files[j - 1] = files[j];
files[j - 1] = NULL;
continue;
}
#ifndef G_OS_WIN32
/* '~' is a quite normal and common character in file names on
* Windows, especially in the 8.3 versions of long file names, which
* still occur now and then. Also, few Windows user are aware of the
* Unix shell convention that '~' stands for the home directory,
* even if they happen to have a home directory.
*/
if (file[0] == '~' && file[1] == G_DIR_SEPARATOR)
{
char *tmp = g_strconcat (g_get_home_dir(), file + 1, NULL);
g_free (file);
file = tmp;
}
else if (file[0] == '~' && file[1] == '\0')
{
g_free (file);
file = g_strdup (g_get_home_dir ());
}
#endif
g_free (files[i]);
files[i] = file;
i++;
}
return files;
}
+18
View File
@@ -0,0 +1,18 @@
#ifndef __GTKUTILS_H__
#define __GTKUTILS_H__
#include <glib.h>
G_BEGIN_DECLS
gboolean gtk_scan_string (const char **pos,
GString *out);
gboolean gtk_skip_space (const char **pos);
gint gtk_read_line (FILE *stream,
GString *str);
char * gtk_trim_string (const char *str);
char ** gtk_split_file_list (const char *str);
G_END_DECLS
#endif
+14 -16
View File
@@ -5959,8 +5959,11 @@ gtk_widget_size_allocate_with_baseline (GtkWidget *widget,
gtk_widget_push_verify_invariants (widget);
#ifdef G_ENABLE_DEBUG
priv->highlight_resize = TRUE;
gtk_widget_queue_draw (widget);
if (GTK_DEBUG_CHECK (RESIZE))
{
priv->highlight_resize = TRUE;
gtk_widget_queue_draw (widget);
}
if (gtk_widget_get_resize_needed (widget))
{
@@ -6032,17 +6035,14 @@ gtk_widget_size_allocate_with_baseline (GtkWidget *widget,
}
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (GEOMETRY))
{
if ((min_width > real_allocation.width || min_height > real_allocation.height) &&
!GTK_IS_SCROLLABLE (widget))
g_warning ("gtk_widget_size_allocate(): attempt to underallocate %s%s %s %p. "
"Allocation is %dx%d, but minimum required size is %dx%d.",
priv->parent ? G_OBJECT_TYPE_NAME (priv->parent) : "", priv->parent ? "'s child" : "toplevel",
G_OBJECT_TYPE_NAME (widget), widget,
real_allocation.width, real_allocation.height,
min_width, min_height);
}
if ((min_width > real_allocation.width || min_height > real_allocation.height) &&
!GTK_IS_SCROLLABLE (widget))
g_warning ("gtk_widget_size_allocate(): attempt to underallocate %s%s %s %p. "
"Allocation is %dx%d, but minimum required size is %dx%d.",
priv->parent ? G_OBJECT_TYPE_NAME (priv->parent) : "", priv->parent ? "'s child" : "toplevel",
G_OBJECT_TYPE_NAME (widget), widget,
real_allocation.width, real_allocation.height,
min_width, min_height);
#endif
/* Now that we have the right natural height and width, go ahead and remove any margins from the
* allocated sizes and possibly limit them to the natural sizes */
@@ -7005,8 +7005,7 @@ gtk_widget_draw_internal (GtkWidget *widget,
cairo_restore (cr);
}
}
if (GTK_DISPLAY_DEBUG_CHECK (gtk_widget_get_display (widget), RESIZE) &&
widget->priv->highlight_resize)
if (widget->priv->highlight_resize)
{
GtkAllocation alloc;
gtk_widget_get_allocation (widget, &alloc);
@@ -7018,7 +7017,6 @@ gtk_widget_draw_internal (GtkWidget *widget,
gtk_widget_queue_draw (widget);
widget->priv->highlight_resize = FALSE;
}
#endif
+10 -7
View File
@@ -3996,7 +3996,7 @@ gtk_window_get_geometry_info (GtkWindow *window,
* gtk_window_set_geometry_hints:
* @window: a #GtkWindow
* @geometry_widget: (allow-none): widget the geometry hints used to be applied to
* or %NULL. Since 3.18 this argument is ignored and GTK behaves as if %NULL was
* or %NULL. Since 3.20 this argument is ignored and GTK behaves as if %NULL was
* set.
* @geometry: (allow-none): struct containing geometry information or %NULL
* @geom_mask: mask indicating which struct fields should be paid attention to
@@ -7623,7 +7623,7 @@ gtk_window_restack_popovers (GtkWindow *window)
GtkWindowPopover *popover = link->data;
link = link->next;
if (popover->window && gdk_window_is_visible (popover->window))
if (popover->window)
gdk_window_raise (popover->window);
}
}
@@ -9983,14 +9983,16 @@ gtk_window_update_fixed_size (GtkWindow *window,
if (info->default_width > -1)
{
new_geometry->min_width = MAX (default_width_csd, new_width);
new_geometry->max_width = new_geometry->min_width;
gint w = MAX (MAX (default_width_csd, new_width), new_geometry->min_width);
new_geometry->min_width = w;
new_geometry->max_width = w;
}
if (info->default_height > -1)
{
new_geometry->min_height = MAX (default_height_csd, new_height);
new_geometry->max_height = new_geometry->min_height;
gint h = MAX (MAX (default_height_csd, new_height), new_geometry->min_height);
new_geometry->min_height = h;
new_geometry->max_height = h;
}
}
}
@@ -11362,7 +11364,7 @@ gtk_XParseGeometry (const char *string,
* gtk_widget_show_all (vbox);
*
* gtk_window_set_geometry_hints (GTK_WINDOW (window),
* window,
* NULL,
* &size_hints,
* GDK_HINT_MIN_SIZE |
* GDK_HINT_BASE_SIZE |
@@ -12398,6 +12400,7 @@ _gtk_window_raise_popover (GtkWindow *window,
g_list_free (link);
break;
}
gtk_window_restack_popovers (window);
}
static GtkWidget *inspector_window = NULL;
+91
View File
@@ -27,15 +27,20 @@
#include "gtkprivate.h"
#include "gtksettings.h"
#include "gtkswitch.h"
#include "gtkscale.h"
#include "gtkwindow.h"
#include "gtkcssproviderprivate.h"
#include <math.h>
#ifdef GDK_WINDOWING_X11
#include "x11/gdkx.h"
#endif
#include "gdk/gdk-private.h"
#define EPSILON 1e-10
struct _GtkInspectorVisualPrivate
{
GtkWidget *visual_box;
@@ -48,8 +53,12 @@ struct _GtkInspectorVisualPrivate
GtkWidget *font_button;
GtkWidget *hidpi_spin;
GtkWidget *animation_switch;
GtkWidget *font_scale_scale;
GtkAdjustment *scale_adjustment;
GtkAdjustment *slowdown_adjustment;
GtkWidget *slowdown_entry;
GtkAdjustment *cursor_size_adjustment;
GtkAdjustment *font_scale_adjustment;
GtkWidget *debug_box;
GtkWidget *rendering_mode_combo;
@@ -130,6 +139,16 @@ redraw_everything (void)
g_list_free (toplevels);
}
static void
font_scale_changed (GtkAdjustment *adjustment)
{
gdouble factor;
factor = gtk_adjustment_get_value (adjustment);
g_object_set (gtk_settings_get_default (), "gtk-xft-dpi",
(gint)(factor * 96 * 1024), NULL);
}
static void
updates_activate (GtkSwitch *sw)
{
@@ -491,6 +510,16 @@ init_font (GtkInspectorVisual *vis)
G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE);
}
static void
init_font_scale (GtkInspectorVisual *vis)
{
gtk_scale_add_mark (GTK_SCALE (vis->priv->font_scale_scale), 1.0, GTK_POS_TOP, NULL);
/* There is no backend agnostic way to get the default value, so use 1.0 */
gtk_adjustment_set_value (vis->priv->font_scale_adjustment, 1.0);
g_signal_connect (vis->priv->font_scale_adjustment, "value-changed",
G_CALLBACK (font_scale_changed), NULL);
}
#if defined (GDK_WINDOWING_X11)
static void
scale_changed (GtkAdjustment *adjustment, GtkInspectorVisual *vis)
@@ -538,6 +567,62 @@ init_animation (GtkInspectorVisual *vis)
G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE);
}
static void
update_slowdown (GtkInspectorVisual *vis,
gdouble slowdown,
gboolean update_adjustment,
gboolean update_entry)
{
_gtk_set_slowdown (slowdown);
if (update_adjustment)
gtk_adjustment_set_value (vis->priv->slowdown_adjustment,
log2 (slowdown));
if (update_entry)
{
gchar *str = g_strdup_printf ("%0.*f", 2, slowdown);
gtk_entry_set_text (GTK_ENTRY (vis->priv->slowdown_entry), str);
g_free (str);
}
}
static void
slowdown_adjustment_changed (GtkAdjustment *adjustment,
GtkInspectorVisual *vis)
{
gdouble value = gtk_adjustment_get_value (adjustment);
gdouble previous = CLAMP (log2 (_gtk_get_slowdown ()),
gtk_adjustment_get_lower (adjustment),
gtk_adjustment_get_upper (adjustment));
if (fabs (value - previous) > EPSILON)
update_slowdown (vis, exp2 (value), FALSE, TRUE);
}
static void
slowdown_entry_activated (GtkEntry *entry,
GtkInspectorVisual *vis)
{
gdouble slowdown;
gchar *err = NULL;
slowdown = g_strtod (gtk_entry_get_text (entry), &err);
if (err != NULL)
update_slowdown (vis, slowdown, TRUE, FALSE);
}
static void
init_slowdown (GtkInspectorVisual *vis)
{
update_slowdown (vis, _gtk_get_slowdown (), TRUE, TRUE);
g_signal_connect (vis->priv->slowdown_adjustment, "value-changed",
G_CALLBACK (slowdown_adjustment_changed), vis);
g_signal_connect (vis->priv->slowdown_entry, "activate",
G_CALLBACK (slowdown_entry_activated), vis);
}
static void
update_touchscreen (GtkSwitch *sw)
{
@@ -715,10 +800,12 @@ gtk_inspector_visual_init (GtkInspectorVisual *vis)
init_cursors (vis);
init_cursor_size (vis);
init_font (vis);
init_font_scale (vis);
init_scale (vis);
init_rendering_mode (vis);
init_updates (vis);
init_animation (vis);
init_slowdown (vis);
init_touchscreen (vis);
init_gl (vis);
}
@@ -762,6 +849,8 @@ gtk_inspector_visual_class_init (GtkInspectorVisualClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, hidpi_spin);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, scale_adjustment);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, animation_switch);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, slowdown_adjustment);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, slowdown_entry);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, touchscreen_switch);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, visual_box);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, debug_box);
@@ -771,6 +860,8 @@ gtk_inspector_visual_class_init (GtkInspectorVisualClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, software_gl_switch);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, software_surface_switch);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, texture_rectangle_switch);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, font_scale_scale);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, font_scale_adjustment);
gtk_widget_class_bind_template_callback (widget_class, updates_activate);
gtk_widget_class_bind_template_callback (widget_class, direction_changed);
+92
View File
@@ -6,6 +6,18 @@
<property name="step-increment">1</property>
<property name="page-increment">1</property>
</object>
<object class="GtkAdjustment" id="font_scale_adjustment">
<property name="lower">0.5</property>
<property name="upper">2</property>
<property name="step-increment">0.01</property>
<property name="page-increment">0.01</property>
</object>
<object class="GtkAdjustment" id="slowdown_adjustment">
<property name="lower">-3</property>
<property name="upper">3</property>
<property name="step-increment">1</property>
<property name="page-increment">1</property>
</object>
<object class="GtkAdjustment" id="cursor_size_adjustment">
<property name="lower">24</property>
<property name="upper">64</property>
@@ -235,6 +247,41 @@
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="activatable">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
<property name="margin">10</property>
<property name="spacing">40</property>
<child>
<object class="GtkLabel" id="font_scale_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Font Scale</property>
<property name="halign">start</property>
<property name="valign">baseline</property>
<property name="xalign">0.0</property>
</object>
</child>
<child>
<object class="GtkScale" id="font_scale_scale">
<property name="visible">True</property>
<property name="halign">end</property>
<property name="valign">baseline</property>
<property name="digits">2</property>
<property name="adjustment">font_scale_adjustment</property>
</object>
<packing>
<property name="expand">True</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
@@ -341,6 +388,50 @@
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="activatable">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
<property name="margin">10</property>
<property name="spacing">20</property>
<child>
<object class="GtkLabel" id="slowdown_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Slowdown</property>
<property name="halign">start</property>
<property name="valign">baseline</property>
<property name="xalign">0.0</property>
</object>
</child>
<child>
<object class="GtkScale" id="slowdown_scale">
<property name="visible">1</property>
<property name="can_focus">1</property>
<property name="adjustment">slowdown_adjustment</property>
<property name="valign">baseline</property>
<property name="draw_value">0</property>
</object>
<packing>
<property name="expand">True</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="slowdown_entry">
<property name="visible">True</property>
<property name="halign">end</property>
<property name="valign">baseline</property>
<property name="width-chars">4</property>
<property name="input-purpose">number</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
@@ -785,6 +876,7 @@
<widget name="icon_combo"/>
<widget name="cursor_combo"/>
<widget name="font_button"/>
<widget name="font_scale_scale"/>
<widget name="direction_combo"/>
<widget name="rendering_mode_combo"/>
<widget name="gl_combo"/>
+2 -3
View File
@@ -36,6 +36,7 @@
#include "gtk/gtkimcontextinfo.h"
#include "gtk/gtkversion.h"
#include "gtk/gtkutilsprivate.h"
#include "gtk/deprecated/gtkrc.h"
@@ -189,9 +190,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
g_string_append_printf (contents, "# ModulesPath = %s\n#\n", path);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
dirs = pango_split_file_list (path);
G_GNUC_END_IGNORE_DEPRECATIONS
dirs = gtk_split_file_list (path);
dirs_done = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
for (i = 0; dirs[i]; i++)
+43 -14
View File
@@ -39,6 +39,8 @@ $button_transition: all 200ms $ease-out-quad;
outline-offset: -3px;
outline-width: 1px;
-gtk-outline-radius: 2px;
-gtk-secondary-caret-color: $selected_bg_color
}
@@ -119,6 +121,34 @@ textview {
}
}
textview border {
background-color: mix($bg_color, $base_color, 50%);
background-image: image(transparentize(black, 0.8)); // HACK: the border node just draws background so,
background-repeat: no-repeat; // using a background-image to draw the border
&:backdrop { background-color: mix($backdrop_bg_color, $backdrop_base_color, 50%); }
&.bottom {
background-size: 100% 1px;
background-position: top;
}
&.top {
background-size: 100% 1px;
background-position: bottom;
}
&.left {
background-size: 1px 100%;
background-position: right;
}
&.right {
background-size: 1px 100%;
background-position: left;
}
}
iconview { @extend .view; }
.rubberband,
@@ -197,12 +227,6 @@ assistant {
.sidebar label.highlight { background-color: mix($bg_color, $fg_color, 80%); }
}
textview { // This will get overridden by .view, needed by gedit line numbers
background-color: mix($bg_color, $base_color, 50%);
&:backdrop { background-color: mix($backdrop_bg_color, $backdrop_base_color, 50%); }
}
%osd, .osd {
color: $osd_fg_color;
border: none;
@@ -303,7 +327,7 @@ entry {
}
}
& image { // entry icons colors
image { // entry icons colors
color: mix($fg_color, $base_color, 80%);
&:hover { color: $fg_color; }
@@ -401,6 +425,10 @@ entry {
}
}
treeview acceleditor > label {
background-color: $selected_bg_color;
}
treeview entry {
&.flat, & {
border-radius: 0;
@@ -828,7 +856,7 @@ button {
// More inline toolbar buttons
toolbar.inline-toolbar toolbutton,
toolbar.inline-toolbar toolbutton:backdrop {
& > button.flat { @extend %linked_middle; }
> button.flat { @extend %linked_middle; }
&:first-child > button.flat { @extend %linked:first-child; }
@@ -1568,7 +1596,7 @@ treeview.view {
border-left-color: mix($fg_color, $base_color, 50%); // this is actually the tree lines color,
border-top-color: $bg_color; // while this is the grid lines color, better then nothing
& rubberband { @extend rubberband; } // to avoid borders being overridden by the previously set props
rubberband { @extend rubberband; } // to avoid borders being overridden by the previously set props
&:selected {
&:focus, & {
@@ -1917,7 +1945,7 @@ popover.background {
border-radius: 5px;
background-color: $popover_bg_color;
&, .csd & { border: 1px solid $borders_color; }
.csd &, & { border: 1px solid $borders_color; }
box-shadow: 0 1px 2px transparentize(black, 0.7);
@@ -1933,7 +1961,7 @@ popover.background {
background-color: transparent;
}
&, .csd & {
.csd &, & {
&.touch-selection,
&.magnifier {
@extend %osd;
@@ -2734,7 +2762,7 @@ treeview.view radio:selected { &:focus, & { @extend %radio; }} // This is a work
}
// ...on selected list rows
row:selected & { &, &:disabled { border-color: $selected_borders_color; } }
row:selected & { &:disabled, & { border-color: $selected_borders_color; } }
// OSD
.osd & {
@@ -3881,7 +3909,7 @@ infobar { border-style: none; }
}
}
& label:selected { &:focus, &:hover, & { background-color: darken($selected_bg_color, 10%); }}
label:selected { &:focus, &:hover, & { background-color: darken($selected_bg_color, 10%); }}
*:link { @extend %link_selected; }
}
@@ -4086,7 +4114,7 @@ colorchooser .popover.osd { border-radius: 5px; }
border-radius: 5px;
}
&:backdrop { &:hover, &:disabled, & {@extend %undecorated_button; }}
&:backdrop { &:hover, &:disabled, & { @extend %undecorated_button; }}
}
}
@@ -4277,6 +4305,7 @@ button.circular { // FIXME: aggregate to buttons
*:drop(active) { // FIXME needs to be done widget by widget, this wildcard should really die
border-color: $drop_target_color;
box-shadow: inset 0 0 0 1px $drop_target_color;
caret-color: $drop_target_color;
}
stackswitcher button.text-button { min-width: 100px; } // FIXME aggregate with buttons
+31 -12
View File
@@ -14,7 +14,8 @@
outline-style: dashed;
outline-offset: -3px;
outline-width: 1px;
-gtk-outline-radius: 2px; }
-gtk-outline-radius: 2px;
-gtk-secondary-caret-color: #215d9c; }
/***************
* Base States *
@@ -74,6 +75,25 @@ textview text {
textview text:selected {
border-radius: 3px; }
textview border {
background-color: #313434;
background-image: image(rgba(0, 0, 0, 0.2));
background-repeat: no-repeat; }
textview border:backdrop {
background-color: #333636; }
textview border.bottom {
background-size: 100% 1px;
background-position: top; }
textview border.top {
background-size: 100% 1px;
background-position: bottom; }
textview border.left {
background-size: 1px 100%;
background-position: right; }
textview border.right {
background-size: 1px 100%;
background-position: left; }
.rubberband,
rubberband,
flowbox rubberband,
@@ -120,12 +140,7 @@ assistant .sidebar label {
assistant .sidebar label.highlight {
background-color: #5d6262; }
textview {
background-color: #313434; }
textview:backdrop {
background-color: #333636; }
popover.background.touch-selection, popover.background.magnifier, .csd popover.background.touch-selection, .csd popover.background.magnifier, popover.background.osd, .csd popover.background.osd, .app-notification,
.csd popover.background.touch-selection, .csd popover.background.magnifier, popover.background.touch-selection, popover.background.magnifier, .csd popover.background.osd, popover.background.osd, .app-notification,
.app-notification.frame, .osd .scale-popup, .osd {
color: #eeeeec;
border: none;
@@ -387,6 +402,9 @@ entry:drop(active):not(:only-child) + button,
entry:drop(active):not(:only-child) + combobox > box > button.combo {
border-top-color: #4e9a06; }
treeview acceleditor > label {
background-color: #215d9c; }
treeview entry.flat, treeview entry {
border-radius: 0;
background-image: none;
@@ -638,7 +656,7 @@ button.osd {
text-shadow: none;
-gtk-icon-shadow: none;
border: none; }
popover.background.touch-selection button, popover.background.magnifier button, .csd popover.background.touch-selection button, .csd popover.background.magnifier button, .app-notification button,
.csd popover.background.touch-selection button, .csd popover.background.magnifier button, popover.background.touch-selection button, popover.background.magnifier button, .app-notification button,
.app-notification.frame button, .osd
button {
color: #eeeeec;
@@ -2213,7 +2231,7 @@ popover.background {
border-radius: 5px;
background-color: #393f3f;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
popover.background, .csd popover.background {
.csd popover.background, popover.background {
border: 1px solid #1c1f1f; }
popover.background:backdrop {
background-color: #393f3f;
@@ -2224,7 +2242,7 @@ popover.background {
popover.background > toolbar {
border-style: none;
background-color: transparent; }
popover.background.touch-selection, popover.background.magnifier, .csd popover.background.touch-selection, .csd popover.background.magnifier {
.csd popover.background.touch-selection, .csd popover.background.magnifier, popover.background.touch-selection, popover.background.magnifier {
border: 1px solid rgba(255, 255, 255, 0.1); }
popover.background separator {
margin: 3px; }
@@ -2940,7 +2958,7 @@ scale highlight, progressbar progress {
scale highlight:backdrop:disabled, progressbar progress:backdrop:disabled, progressbar:backdrop progress:disabled {
background-color: transparent;
border-color: transparent; }
row:selected scale highlight, scale row:selected highlight, row:selected progressbar progress, progressbar row:selected progress, row:selected scale highlight:disabled, scale row:selected highlight:disabled, row:selected progressbar progress:disabled, progressbar row:selected progress:disabled {
row:selected scale highlight:disabled, scale row:selected highlight:disabled, row:selected progressbar progress:disabled, progressbar row:selected progress:disabled, row:selected scale highlight, scale row:selected highlight, row:selected progressbar progress, progressbar row:selected progress {
border-color: #0f2b48; }
.osd scale highlight, scale .osd highlight, .osd progressbar progress, progressbar .osd progress {
border-color: rgba(0, 0, 0, 0.7); }
@@ -4504,7 +4522,8 @@ button.circular {
*:drop(active):focus,
*:drop(active) {
border-color: #4e9a06;
box-shadow: inset 0 0 0 1px #4e9a06; }
box-shadow: inset 0 0 0 1px #4e9a06;
caret-color: #4e9a06; }
stackswitcher button.text-button {
min-width: 100px; }
+31 -12
View File
@@ -14,7 +14,8 @@
outline-style: dashed;
outline-offset: -3px;
outline-width: 1px;
-gtk-outline-radius: 2px; }
-gtk-outline-radius: 2px;
-gtk-secondary-caret-color: #4a90d9; }
/***************
* Base States *
@@ -74,6 +75,25 @@ textview text {
textview text:selected {
border-radius: 3px; }
textview border {
background-color: #f4f4f3;
background-image: image(rgba(0, 0, 0, 0.2));
background-repeat: no-repeat; }
textview border:backdrop {
background-color: #f2f2f2; }
textview border.bottom {
background-size: 100% 1px;
background-position: top; }
textview border.top {
background-size: 100% 1px;
background-position: bottom; }
textview border.left {
background-size: 1px 100%;
background-position: right; }
textview border.right {
background-size: 1px 100%;
background-position: left; }
.rubberband,
rubberband,
flowbox rubberband,
@@ -120,12 +140,7 @@ assistant .sidebar label {
assistant .sidebar label.highlight {
background-color: #c3c4c4; }
textview {
background-color: #f4f4f3; }
textview:backdrop {
background-color: #f2f2f2; }
popover.background.touch-selection, popover.background.magnifier, .csd popover.background.touch-selection, .csd popover.background.magnifier, popover.background.osd, .csd popover.background.osd, .app-notification,
.csd popover.background.touch-selection, .csd popover.background.magnifier, popover.background.touch-selection, popover.background.magnifier, .csd popover.background.osd, popover.background.osd, .app-notification,
.app-notification.frame, .osd .scale-popup, .osd {
color: #eeeeec;
border: none;
@@ -387,6 +402,9 @@ entry:drop(active):not(:only-child) + button,
entry:drop(active):not(:only-child) + combobox > box > button.combo {
border-top-color: #4e9a06; }
treeview acceleditor > label {
background-color: #4a90d9; }
treeview entry.flat, treeview entry {
border-radius: 0;
background-image: none;
@@ -641,7 +659,7 @@ button.osd {
text-shadow: none;
-gtk-icon-shadow: none;
border: none; }
popover.background.touch-selection button, popover.background.magnifier button, .csd popover.background.touch-selection button, .csd popover.background.magnifier button, .app-notification button,
.csd popover.background.touch-selection button, .csd popover.background.magnifier button, popover.background.touch-selection button, popover.background.magnifier button, .app-notification button,
.app-notification.frame button, .osd
button {
color: #eeeeec;
@@ -2226,7 +2244,7 @@ popover.background {
border-radius: 5px;
background-color: #e8e8e7;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
popover.background, .csd popover.background {
.csd popover.background, popover.background {
border: 1px solid #9d9d99; }
popover.background:backdrop {
background-color: #e8e8e7;
@@ -2237,7 +2255,7 @@ popover.background {
popover.background > toolbar {
border-style: none;
background-color: transparent; }
popover.background.touch-selection, popover.background.magnifier, .csd popover.background.touch-selection, .csd popover.background.magnifier {
.csd popover.background.touch-selection, .csd popover.background.magnifier, popover.background.touch-selection, popover.background.magnifier {
border: 1px solid rgba(255, 255, 255, 0.1); }
popover.background separator {
margin: 3px; }
@@ -2969,7 +2987,7 @@ scale highlight, progressbar progress {
scale highlight:backdrop:disabled, progressbar progress:backdrop:disabled, progressbar:backdrop progress:disabled {
background-color: transparent;
border-color: transparent; }
row:selected scale highlight, scale row:selected highlight, row:selected progressbar progress, progressbar row:selected progress, row:selected scale highlight:disabled, scale row:selected highlight:disabled, row:selected progressbar progress:disabled, progressbar row:selected progress:disabled {
row:selected scale highlight:disabled, scale row:selected highlight:disabled, row:selected progressbar progress:disabled, progressbar row:selected progress:disabled, row:selected scale highlight, scale row:selected highlight, row:selected progressbar progress, progressbar row:selected progress {
border-color: #184472; }
.osd scale highlight, scale .osd highlight, .osd progressbar progress, progressbar .osd progress {
border-color: rgba(0, 0, 0, 0.7); }
@@ -4534,7 +4552,8 @@ button.circular {
*:drop(active):focus,
*:drop(active) {
border-color: #4e9a06;
box-shadow: inset 0 0 0 1px #4e9a06; }
box-shadow: inset 0 0 0 1px #4e9a06;
caret-color: #4e9a06; }
stackswitcher button.text-button {
min-width: 100px; }
+9 -9
View File
@@ -555,10 +555,10 @@ button {
}
// Suggested and Destructive Action buttons
@each $b_type, $b_color in (suggested-action, $selected_bg_color),
(destructive-action, $destructive_color) {
@each $b_type, $b_color, $f_color in (suggested-action, $selected_bg_color, $selected_fg_color),
(destructive-action, $destructive_color, white) {
&.#{$b_type} {
@include button(normal, $b_color, white);
@include button(normal, $b_color, $f_color);
&.flat {
@include button(undecorated);
@@ -566,23 +566,23 @@ button {
color: $b_color; //FIXME: does it work on the dark variant?
}
&:hover { @include button(hover, $b_color, white); }
&:hover { @include button(hover, $b_color, $f_color); }
&:active,
&:checked { @include button(active, $b_color, white); }
&:checked { @include button(active, $b_color, $f_color); }
&:backdrop,
&.flat:backdrop {
@include button(backdrop, $b_color, white);
@include button(backdrop, $b_color, $f_color);
&:active,
&:checked { @include button(backdrop-active, $b_color, white); }
&:checked { @include button(backdrop-active, $b_color, $f_color); }
&:disabled {
@include button(backdrop-insensitive);
&:active,
&:checked { @include button(backdrop-insensitive-active, $b_color, white); }
&:checked { @include button(backdrop-insensitive-active, $b_color, $f_color); }
}
}
@@ -598,7 +598,7 @@ button {
@include button(insensitive);
&:active,
&:checked { @include button(insensitive-active, $b_color, white); }
&:checked { @include button(insensitive-active, $b_color, $f_color); }
}
.osd & {
@@ -600,7 +600,7 @@ popover.background.touch-selection button, popover.background.magnifier button,
button.suggested-action {
border-width: 2px;
border-style: solid;
color: white;
color: #000;
background-image: none;
background-color: #ddd;
border-color: #9d9d9d; }
@@ -615,7 +615,7 @@ button.suggested-action {
button.suggested-action:hover {
border-width: 2px;
border-style: solid;
color: white;
color: #000;
background-color: #ddd;
border-color: #9d9d9d;
background-image: none; }
@@ -623,13 +623,13 @@ button.suggested-action {
border-width: 2px;
border-style: solid;
background-image: none;
color: black;
color: white;
background-color: #222222;
border-color: #9d9d9d; }
button.suggested-action:backdrop, button.suggested-action.flat:backdrop {
border-width: 2px;
border-style: solid;
color: white;
color: #000;
background-color: #ddd;
border-color: #ddd;
background-image: none; }
+3 -3
View File
@@ -602,7 +602,7 @@ popover.background.touch-selection button, popover.background.magnifier button,
button.suggested-action {
border-width: 2px;
border-style: solid;
color: white;
color: #fff;
background-image: none;
background-color: #000;
border-color: black; }
@@ -617,7 +617,7 @@ button.suggested-action {
button.suggested-action:hover {
border-width: 2px;
border-style: solid;
color: white;
color: #fff;
background-color: #000;
border-color: black;
background-image: none; }
@@ -631,7 +631,7 @@ button.suggested-action {
button.suggested-action:backdrop, button.suggested-action.flat:backdrop {
border-width: 2px;
border-style: solid;
color: white;
color: #fff;
background-color: #000;
border-color: #000;
background-image: none; }
+1
View File
@@ -131,6 +131,7 @@ gtk/gtkcustompaperunixdialog.c
gtk/gtkdialog.c
gtk/gtkdnd.c
gtk/gtkdnd-quartz.c
gtk/gtkdragdest.c
gtk/gtkdragsource.c
gtk/gtkdrawingarea.c
gtk/gtkeditable.c
+11 -17
View File
@@ -14,7 +14,7 @@
# Hendrik Richter <hendrikr@gnome.org>, 2004-2009.
# Hendrik Brandt <heb@gnome-de.org>, 2005.
# Mario Blättermann <mario.blaettermann@gmail.com>, 2010-2013.
# Wolfgang Stöggl <c72578@yahoo.de>, 2011-2012, 2014-2015.
# Wolfgang Stöggl <c72578@yahoo.de>, 2011-2012, 2014-2016.
# Hendrik Knackstedt <hendrik.knackstedt@t-online.de>, 2011.
# Christian Kirbach <christian.kirbach@gmail.com>, 2009, 2010, 2011, 2012, 2013.
# Benjamin Steinwender <b@stbe.at>, 2014.
@@ -23,16 +23,16 @@ msgid ""
msgstr ""
"Project-Id-Version: GTK+ master\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-03-20 12:26+0000\n"
"PO-Revision-Date: 2016-03-20 15:13+0100\n"
"Last-Translator: Mario Blättermann <mario.blaettermann@gmail.com>\n"
"POT-Creation-Date: 2016-03-25 12:54+0000\n"
"PO-Revision-Date: 2016-03-25 16:42+0100\n"
"Last-Translator: Wolfgang Stoeggl <c72578@yahoo.de>\n"
"Language-Team: Deutsch <gnome-de@gnome.org>\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.8.7.1\n"
"X-Generator: Poedit 1.8.7\n"
#: gdk/gdkapplaunchcontext.c:127 gdk/gdkcursor.c:139 gdk/gdkdevicemanager.c:181
#: gdk/gdkglcontext.c:265 gdk/gdkseat.c:158 gdk/gdkseat.c:159
@@ -124,10 +124,8 @@ msgid "Seat"
msgstr "Platz"
#: gdk/gdkdevice.c:302 gdk/gdkdevice.c:303
#, fuzzy
#| msgid "Number of columns"
msgid "Number of concurrent touches"
msgstr "Spaltenanzahl"
msgstr "Anzahl gleichzeitiger Berührungen"
#: gdk/gdkdevicemanager.c:182
msgid "Display for the device manager"
@@ -3751,7 +3749,7 @@ msgstr "Auto-Vervollständigung"
#: gtk/gtkentrycompletion.c:388
msgid "Whether the common prefix should be inserted automatically"
msgstr "Soll der übliche Präfix automatisch eingefügt werden?"
msgstr "Soll das übliche Präfix automatisch eingefügt werden?"
#: gtk/gtkentrycompletion.c:402
msgid "Popup completion"
@@ -7506,10 +7504,8 @@ msgid "Whether to show cursor in text"
msgstr "Soll eine Eingabemarke im Text dargestellt werden?"
#: gtk/gtkshortcutlabel.c:427 gtk/gtkshortcutsshortcut.c:490
#, fuzzy
#| msgid "Accelerator key"
msgid "Accelerator"
msgstr "Tastaturkürzel"
msgstr "Kürzel"
#: gtk/gtkshortcutsgroup.c:303
msgid "View"
@@ -7517,15 +7513,13 @@ msgstr "Ansicht"
#: gtk/gtkshortcutsgroup.c:316 gtk/gtkshortcutsgroup.c:317
#: gtk/gtkshortcutsshortcut.c:571 gtk/gtkshortcutsshortcut.c:572
#, fuzzy
#| msgid "Accelerator Group"
msgid "Accelerator Size Group"
msgstr "Tastenkürzelgruppe"
msgstr "Kürzelgrößen-Gruppe"
#: gtk/gtkshortcutsgroup.c:330 gtk/gtkshortcutsgroup.c:331
#: gtk/gtkshortcutsshortcut.c:585 gtk/gtkshortcutsshortcut.c:586
msgid "Title Size Group"
msgstr ""
msgstr "Titelgrößen-Gruppe"
#: gtk/gtkshortcutssection.c:349 gtk/gtkshortcutswindow.c:718
msgid "Section Name"
@@ -7541,7 +7535,7 @@ msgstr "Maximale Höhe"
#: gtk/gtkshortcutsshortcut.c:491
msgid "The accelerator keys for shortcuts of type 'Accelerator'"
msgstr "DDie Zugriffstasten für Kürzel des Typs »Accelerator«"
msgstr "Die Zugriffstasten für Kürzel des Typs »Accelerator«"
# Bin mir nicht sicher, ob man »Other Gesture« hier übersetzen darf.
#: gtk/gtkshortcutsshortcut.c:505
+4401 -2922
View File
File diff suppressed because it is too large Load Diff
+11 -11
View File
@@ -34,8 +34,8 @@ msgid ""
msgstr ""
"Project-Id-Version: gtk+-properties\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-03-14 23:11+0000\n"
"PO-Revision-Date: 2016-03-17 21:02+0100\n"
"POT-Creation-Date: 2016-03-25 03:34+0000\n"
"PO-Revision-Date: 2016-03-25 11:57+0100\n"
"Last-Translator: Milo Casagrande <milo@milo.name>\n"
"Language-Team: Italian <tp@lists.linux.it>\n"
"Language: it\n"
@@ -3959,7 +3959,7 @@ msgid "The current filter for selecting which files are displayed"
msgstr "Il filtro attualmente usato per selezionare i file da visualizzare"
#: gtk/gtkfilechooser.c:388 gtk/gtkplacessidebar.c:4484
#: gtk/gtkplacesview.c:2179
#: gtk/gtkplacesview.c:2178
msgid "Local Only"
msgstr "Solo locale"
@@ -5074,7 +5074,7 @@ msgstr "Spazio aggiuntivo al di sopra e al di sotto del menù"
#: gtk/gtkmenu.c:734
msgid "Vertical Offset"
msgstr "Offset verticale"
msgstr "Spostamento verticale"
#: gtk/gtkmenu.c:735
msgid ""
@@ -5652,11 +5652,11 @@ msgstr "Posizione da selezionare"
msgid "The location to highlight in the sidebar"
msgstr "La posizione da evidenziare nel riquadro laterale"
#: gtk/gtkplacessidebar.c:4453 gtk/gtkplacesview.c:2200
#: gtk/gtkplacessidebar.c:4453 gtk/gtkplacesview.c:2199
msgid "Open Flags"
msgstr "Flag apertura"
#: gtk/gtkplacessidebar.c:4454 gtk/gtkplacesview.c:2201
#: gtk/gtkplacessidebar.c:4454 gtk/gtkplacesview.c:2200
msgid ""
"Modes in which the calling application can open locations selected in the "
"sidebar"
@@ -5706,7 +5706,7 @@ msgstr ""
"Indica se il riquadro laterale contiene una scorciatoia per inserire una "
"posizione"
#: gtk/gtkplacessidebar.c:4485 gtk/gtkplacesview.c:2180
#: gtk/gtkplacessidebar.c:4485 gtk/gtkplacesview.c:2179
msgid "Whether the sidebar only includes local files"
msgstr "Indica se il riquadro laterale contiene solo i file locali"
@@ -5732,19 +5732,19 @@ msgstr ""
msgid "Whether to emit ::populate-popup for popups that are not menus"
msgstr "Indica se emettere ::populate-popup per pop-up che non sono menù"
#: gtk/gtkplacesview.c:2186
#: gtk/gtkplacesview.c:2185
msgid "Loading"
msgstr "Caricamento"
#: gtk/gtkplacesview.c:2187
#: gtk/gtkplacesview.c:2186
msgid "Whether the view is loading locations"
msgstr "Indica se la view sta caricando le posizioni"
#: gtk/gtkplacesview.c:2193
#: gtk/gtkplacesview.c:2192
msgid "Fetching networks"
msgstr "Recupero reti"
#: gtk/gtkplacesview.c:2194
#: gtk/gtkplacesview.c:2193
msgid "Whether the view is fetching networks"
msgstr "Indica se la view sta recuperando le reti"

Some files were not shown because too many files have changed in this diff Show More