Compare commits
276 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c9f4c86b1f | |||
| 945f4a45d5 | |||
| e56a1ddce3 | |||
| b1c94375e8 | |||
| 865201f11f | |||
| f5a8201b0f | |||
| 4bf81e6ab5 | |||
| a09586175e | |||
| 3fed034b0c | |||
| c2b97c1b22 | |||
| 5d5ee76a8b | |||
| abc8b34683 | |||
| d3961dacad | |||
| e962ebab82 | |||
| ed75fa655b | |||
| 44a9c0e36d | |||
| 85e37925f0 | |||
| d5b78d474a | |||
| 2f0354fcf9 | |||
| 8ef12fda83 | |||
| 9bfc8371fe | |||
| 59e40f3d6f | |||
| 62a7447c5f | |||
| f052f1554b | |||
| 58891c1fe5 | |||
| d23c6c6246 | |||
| f2f1725b40 | |||
| 2784eacf00 | |||
| b1205a9c96 | |||
| 4bfa6c30bf | |||
| 84dfda1a2b | |||
| 4c698bc824 | |||
| 4c10800bcc | |||
| d1acb786a7 | |||
| a93e477a4d | |||
| 6faafbff6e | |||
| d8da5879aa | |||
| 72178fd0c9 | |||
| 71a5f07620 | |||
| fd143a2b38 | |||
| bde5281ae8 | |||
| cfbb8c5252 | |||
| f853283d7b | |||
| b0131616b2 | |||
| b420c53773 | |||
| 2ea96cf946 | |||
| 0ce217cf94 | |||
| 27a1b50bc6 | |||
| 6267b6b6eb | |||
| 77eebbda5c | |||
| cea8c29a26 | |||
| 38f94194a6 | |||
| e7cd3dddd8 | |||
| 43a568395b | |||
| 669336cf95 | |||
| 785a425516 | |||
| 6f2d5a6290 | |||
| a91237d65e | |||
| aeed695e26 | |||
| a9f94ba67f | |||
| 568feffa69 | |||
| 5dabfa7b39 | |||
| b6b53fc19c | |||
| efea673c31 | |||
| 26f9dc6508 | |||
| 9f48b6b07a | |||
| 6efc06ef5c | |||
| b989910293 | |||
| 7e15ac8927 | |||
| 100cf2442e | |||
| cb738bc201 | |||
| 0d0980f30e | |||
| b1b271ab09 | |||
| 543ad3aabb | |||
| 59d8cba482 | |||
| 7249897dc8 | |||
| 8d874cf0f8 | |||
| 6994fe03ee | |||
| e2d89b9931 | |||
| 1057f249bd | |||
| f06fc8d378 | |||
| ce0074b034 | |||
| c6cdddd68d | |||
| 89973118f3 | |||
| aa4c5459b7 | |||
| c448061d49 | |||
| 7fe1037e84 | |||
| e33188ad41 | |||
| 2374e2aa3b | |||
| e48e29db3b | |||
| 8206b824fa | |||
| 120c296ff6 | |||
| 82bde5b84d | |||
| fab9c17b89 | |||
| 258ba6c8a4 | |||
| 12bc02db94 | |||
| b9b67e05e1 | |||
| 692c3b11ff | |||
| c4c00299b2 | |||
| 24d2f85b23 | |||
| 72346cb209 | |||
| 826f729b6f | |||
| 6ac7b54378 | |||
| db93386f23 | |||
| ea21ee3039 | |||
| d47c7f7ba0 | |||
| 4c8557fa35 | |||
| 5d34cf64a2 | |||
| 19034a2352 | |||
| fae1effec9 | |||
| 65687ba392 | |||
| 40e777ae30 | |||
| caa804613d | |||
| 447325b1e4 | |||
| 24f54d50c4 | |||
| 1716e0b038 | |||
| b3ad4af969 | |||
| cd78fa15ed | |||
| 31a032e042 | |||
| b08ba9def0 | |||
| 5875101a34 | |||
| 1f16eb4344 | |||
| ac62bc0df9 | |||
| 7ac7b523d8 | |||
| adb2b5c758 | |||
| 7e72f42483 | |||
| a4ed154b03 | |||
| 16dc164292 | |||
| f5b6ab4557 | |||
| aa821429b1 | |||
| dc2e5fdf9c | |||
| 41195f6300 | |||
| 3f077ec36f | |||
| 3a5848820c | |||
| 1355f00825 | |||
| 0ab7be8d57 | |||
| aac8b0120f | |||
| d6ca66b712 | |||
| 65927caf84 | |||
| 052e82db04 | |||
| f46aad3a32 | |||
| 4173360bb3 | |||
| 3e375a6c81 | |||
| 7cb36aba40 | |||
| 475d916eb9 | |||
| c48bc48dda | |||
| 7c2f81bcd9 | |||
| ee94f9ff89 | |||
| 73fe852be0 | |||
| 45dfdbce3f | |||
| 031978cb6b | |||
| ce822c5bd4 | |||
| 219eedd7c8 | |||
| 1597f31eba | |||
| 81f0d23744 | |||
| c9f9163544 | |||
| 08a0257893 | |||
| 26617bb9b4 | |||
| 4ae057f07b | |||
| 12c5ca5c01 | |||
| a5a51e325d | |||
| ca63330b19 | |||
| 5107c4a75f | |||
| 068d382689 | |||
| 2407f157c7 | |||
| f988f1131b | |||
| 06062028e2 | |||
| a449cc80de | |||
| 9025ceabde | |||
| 7a1b82828e | |||
| 8f5471f1df | |||
| 5c6979e520 | |||
| 69cb072cd6 | |||
| 615f55d6d1 | |||
| de4cb363c2 | |||
| 09ea0c9110 | |||
| e4d3987b17 | |||
| 105f9acfdf | |||
| 3409ec56ca | |||
| 1c692c64fe | |||
| 404a7185be | |||
| f732fa6883 | |||
| bee669ee66 | |||
| 5c63ab26da | |||
| 1dcd88961e | |||
| 4973b55ad9 | |||
| 44e225e50b | |||
| eacd632e5e | |||
| 6598dca783 | |||
| 2e2c423c78 | |||
| 33247293ee | |||
| de466e7b28 | |||
| 524ca3c2d5 | |||
| 7da594e7b7 | |||
| f64612ca56 | |||
| c867b17cc8 | |||
| 7224dd76db | |||
| 4e6f9660c0 | |||
| d457b4f4a5 | |||
| 710285104b | |||
| e397468964 | |||
| 5091bc9d16 | |||
| 9782a2b729 | |||
| 318a9c4634 | |||
| 8cebc125da | |||
| d42ba8a82a | |||
| 07a69b7247 | |||
| 471cdee97f | |||
| 5db1c987ee | |||
| ca3607c219 | |||
| c76424a842 | |||
| 58b7512b53 | |||
| 3308122c32 | |||
| c6834a002f | |||
| 397bacee6e | |||
| 0174803149 | |||
| 38211ff800 | |||
| ec50042228 | |||
| e079b92a55 | |||
| 20a8ac5542 | |||
| 8f2213836c | |||
| 43937c6aa0 | |||
| 99e2f91dfe | |||
| 5a0aeec3f4 | |||
| 80732a951c | |||
| 50b5820669 | |||
| 48fb37f341 | |||
| a46058451e | |||
| 7d27fd087e | |||
| 3b1484f57c | |||
| ad9865126a | |||
| fe31c5f4fd | |||
| 3a529614e5 | |||
| 4fc5832cfd | |||
| c94afa01c4 | |||
| a076df852b | |||
| b88020ec92 | |||
| 71eac292bb | |||
| 0e171dd45c | |||
| 7d2a7a5626 | |||
| 54d36efa61 | |||
| 1bd5be6b7c | |||
| 3e3d29f7b7 | |||
| 4ddd29d8c0 | |||
| 450704b28a | |||
| 1bf3f40cc5 | |||
| 09168806a2 | |||
| e942aee13d | |||
| 52c362721c | |||
| b0a25b3aa9 | |||
| 981985ee50 | |||
| 4a58e751fb | |||
| 4455ef1c90 | |||
| 9b4eff6ed9 | |||
| e9de5f1083 | |||
| 51f34f4b90 | |||
| b0b06ffbf2 | |||
| 1ae5643f59 | |||
| 3e6eca537b | |||
| 5e629bc26b | |||
| b73f428a86 | |||
| e4f6c76cf8 | |||
| 6228233a9e | |||
| 6ccaa8e3ca | |||
| ef8ef299c4 | |||
| 286437000b | |||
| e5e8ffa3f7 | |||
| 985121813e | |||
| 6f3a3ea7f3 | |||
| 3e567b4900 | |||
| abfdad3c3d | |||
| c6dcc6ee62 | |||
| 87c410d420 | |||
| e44617b351 | |||
| 7018a41ce9 | |||
| 186ecdf0fa |
+1
-1
@@ -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 \
|
||||
|
||||
@@ -1,3 +1,84 @@
|
||||
Overview of Changes in GTK+ 3.20.1
|
||||
==================================
|
||||
|
||||
* Active GtkSwitch widgets now use the :checked state, to match GtkToggleButton
|
||||
|
||||
* Bugs fixed:
|
||||
641354 Look for themes in XDG folders
|
||||
763350 drawing performance worse than X
|
||||
763604 The search button of a GtkShortcutsWindow should have the image-button...
|
||||
763659 DND Drop on root with Pixbuf leaves image behind
|
||||
763731 Return GTK_PRINT_OPERATION_RESULT_ERROR even if error == NULL
|
||||
763741 Wavy/squiggly underline not properly removed
|
||||
763758 Do not use fixed values for widgets size in foreign drawing demo
|
||||
763779 [PATCH] quartz: fix pixelated image surfaces in retina/hidpi mode
|
||||
763802 [HighContrastInverse] the “ON” text of a GtkSwitch should be black (on...
|
||||
763804 [HighContrastInverse] menuitem:hover colors
|
||||
763808 .dnd styleclass still used
|
||||
763859 gdkdevice-wayland.c cleanups
|
||||
763900 stack: fix warnings during GtkStack size_allocate
|
||||
764118 Glitches in menu scroll arrow rendering
|
||||
|
||||
* Translation updates:
|
||||
Basque
|
||||
Bulgarian
|
||||
Danish
|
||||
Galician
|
||||
Greek
|
||||
Russian
|
||||
Slovak
|
||||
Slovenian
|
||||
Spanish
|
||||
Swedish
|
||||
|
||||
|
||||
Overview of Changes in GTK+ 3.20.0
|
||||
==================================
|
||||
|
||||
* Themes:
|
||||
- The HighContrast theme has been brought back up to par with Adwaita
|
||||
- Adwaita has received detail fixes for many widgets
|
||||
- Adwaita now transitions to backdrop
|
||||
|
||||
* Some recently publicized static analysis findings have been fixed
|
||||
|
||||
* Bugs fixed:
|
||||
746490 [HighContrast] insensitive ToggleButtons are rendered similarly ac...
|
||||
763609 [HighContrast] model-generated menu-like popovers are unthemed
|
||||
763610 [HighContrast] GtkSearchEntry’s “search” icon needs left&right pad...
|
||||
763612 [HighContrast] “:selected .circular” should be visible
|
||||
763613 [HighContrast] GtkScale is unreadable
|
||||
763696 [HighContrast] spinbuttons broken
|
||||
763706 [HighContrast] linked horizontal dropboxes broken
|
||||
763707 [HighContrast] active and hover states for radios and checkboxes b...
|
||||
763774 [HighContrast] GtkPlacesSidebar row need more top&bottom padding
|
||||
763775 [HighContrast] the “enter server adress” entry in GtkPlacesView ha...
|
||||
763777 [HighContrast] GtkMenuBar needs a bottom box-shadow
|
||||
763781 [HighContrast] .app-notification border { border:none; }
|
||||
763797 [HighContrast] scrollbars invisible (whity on white)
|
||||
763823 [HighContrast] dnd on a vertical spinbutton does a weird resizing
|
||||
763846 [HighContrast] spinbuttons in osd look bad
|
||||
763955 treeview: inline editing shows old text as background
|
||||
763796 excessive Gtk-WARNING **: State 0 for EMailShellSidebar doesn't ma...
|
||||
763835 W32: Layered windows don't become minimized
|
||||
763749 Nautilus desktop window is too small with gtk 3.19
|
||||
|
||||
* Translation updates
|
||||
Brazilian Portuguese
|
||||
Czech
|
||||
Danish
|
||||
Finnish
|
||||
Hungarian
|
||||
Italian
|
||||
Kazakh
|
||||
Korean
|
||||
Latvian
|
||||
Serbian
|
||||
Serbian Latin
|
||||
Swedish
|
||||
Ukrainian
|
||||
|
||||
|
||||
Overview of Changes in GTK+ 3.19.12
|
||||
===================================
|
||||
|
||||
@@ -604,7 +685,8 @@ Overview of Changes in GTK+ 3.19.3
|
||||
758407 Could not send the search request \ GDBus.Error:org.freedesktop.Tr...
|
||||
758442 gtk_style_context_save() destroys style information
|
||||
|
||||
* Translation updates:
|
||||
|
||||
Overview of Changes in GTK+ 3.19.2
|
||||
==================================
|
||||
|
||||
* Most widgets have been ported to CSS nodes. The element names and
|
||||
|
||||
@@ -72,48 +72,48 @@ and attach the patch to that bug report.
|
||||
Patches should be in unified diff form. (The -up option to GNU diff)
|
||||
Even better are git-formatted patches. (Use git format-patch)
|
||||
|
||||
|
||||
Release notes for 3.20
|
||||
======================
|
||||
|
||||
* The way theming works in GTK+ has been reworked pretty fundamentally
|
||||
in this release, to be able to implement many more CSS features and
|
||||
generally give themes more power. As a result, custom CSS that is
|
||||
shipped with applications and third-party themes will need adjustments.
|
||||
Widgets now use element names much more than style classes; type
|
||||
names are no longer used in style matching. Every widget now documents
|
||||
the element names it has and the style classes it uses. The GTK+
|
||||
inspector can also be helpful in finding this information.
|
||||
* The way theming works in GTK+ has been reworked fundamentally, to
|
||||
implement many more CSS features and make themes more expressive.
|
||||
As a result, custom CSS that is shipped with applications and third-
|
||||
party themes will need adjustments. Widgets now use element names much
|
||||
more than style classes; type names are no longer used in style matching.
|
||||
Every widget now documents the element names it has and the style classes
|
||||
it uses. The GTK+ inspector can also help with finding this information.
|
||||
|
||||
* GTK+ now uses internal subobjects (also known as gadgets) for allocating
|
||||
and drawing widget parts. Applications that subclass GTK+ widgets may
|
||||
see warnings if they override size_allocate and don't chain up. The
|
||||
proper way to subclass is to chain up in size_allocate. If you don't
|
||||
want to do that for some reason, you have to override draw as well.
|
||||
and drawing widget parts. Applications that subclass GTK+ widgets may see
|
||||
warnings if they override the size_allocate vfunc and don't chain up.
|
||||
The proper way to subclass is to chain up in size_allocate. If you do not
|
||||
want to do that for some reason, you have to override the draw vfunc as
|
||||
well.
|
||||
|
||||
* Several fixes for window sizing and placement with client-side
|
||||
decorations may affect applications that are saving and restoring
|
||||
window sizes. The recommended best practice for this which is known
|
||||
to work with client-side and server-side decorations and with older
|
||||
and newer versions of GTK+ is to use gtk_window_get_size() to save
|
||||
and gtk_window_set_default_size() to restore the window size. See
|
||||
https://wiki.gnome.org/HowDoI/SaveWindowState for a detailed example.
|
||||
* Several fixes for window sizing and window placement with client-side
|
||||
decorations may affect applications that are saving and restoring window
|
||||
sizes. The recommended best practice for this which is known to work with
|
||||
client-side and server-side decorations and with older and newer versions
|
||||
of GTK+ is to use gtk_window_get_size() to save window sizes and
|
||||
gtk_window_set_default_size() to restore it.
|
||||
See https://wiki.gnome.org/HowDoI/SaveWindowState for a detailed example.
|
||||
|
||||
* GtkDrawingArea used to implicitly render the theme background before
|
||||
calling the ::draw handler. This is no longer the case. If you rely
|
||||
on having a theme-provided background, call gtk_render_background()
|
||||
from your ::draw handler.
|
||||
|
||||
* The GtkFileChooser interface pre-requisite changed from GtkWidget
|
||||
* The GtkFileChooser interface prerequisite changed from GtkWidget
|
||||
to GObject, allowing non-widget implementations of this interface.
|
||||
This is a minor change in ABI, as apps are no longer guaranteed
|
||||
that a GtkFileChooser interface also supports all GtkWidget methods.
|
||||
However, all previously existing objects still derive from GtkWidget,
|
||||
so no existing code should break.
|
||||
This is a minor change in ABI, as applications are no longer guaranteed
|
||||
that a GtkFileChooser also supports all GtkWidget methods. However, all
|
||||
previously existing implementations still derive from GtkWidget, so no
|
||||
existing code should break.
|
||||
|
||||
* The way in which GtkLevelBar determines the offset to apply was
|
||||
a bit inconsistent in the past; this has been fixed. Applications
|
||||
that are using custom offsets should double-check that their
|
||||
levels look as expected.
|
||||
* The way in which GtkLevelBar determines the offset to apply was a bit
|
||||
inconsistent in the past; this has been fixed. Applications that are using
|
||||
custom offsets should double-check that their levels look as expected.
|
||||
|
||||
Release notes for 3.18
|
||||
======================
|
||||
|
||||
+2
-2
@@ -9,8 +9,8 @@
|
||||
# set GTK_BINARY_AGE and GTK_INTERFACE_AGE to 0.
|
||||
|
||||
m4_define([gtk_major_version], [3])
|
||||
m4_define([gtk_minor_version], [19])
|
||||
m4_define([gtk_micro_version], [12])
|
||||
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)])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* CSS Theming/CSS Accordion
|
||||
/* Theming/CSS Accordion
|
||||
*
|
||||
* A simple accordion demo written using CSS transitions and multiple backgrounds
|
||||
*
|
||||
|
||||
@@ -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,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,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,4 +1,4 @@
|
||||
/* CSS Theming/Shadows
|
||||
/* Theming/Shadows
|
||||
*
|
||||
* This demo shows how to use CSS shadows.
|
||||
*/
|
||||
|
||||
+542
-192
@@ -5,9 +5,7 @@
|
||||
* rest of the desktop, and follow GTK+ themes. This demo shows how to
|
||||
* use GtkStyleContext and the gtk_render_ APIs to achieve this.
|
||||
*
|
||||
* Note that this is a very simple, non-interactive example and does
|
||||
* not show how to come up with theme-compliant sizes by using CSS padding,
|
||||
* margins and min-width or min-height.
|
||||
* Note that this is a very simple, non-interactive example.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
@@ -110,19 +108,11 @@ append_element (GtkWidgetPath *path,
|
||||
}
|
||||
|
||||
static GtkStyleContext *
|
||||
get_style (GtkStyleContext *parent,
|
||||
const char *selector)
|
||||
create_context_for_path (GtkWidgetPath *path,
|
||||
GtkStyleContext *parent)
|
||||
{
|
||||
GtkWidgetPath *path;
|
||||
GtkStyleContext *context;
|
||||
|
||||
if (parent)
|
||||
path = gtk_widget_path_copy (gtk_style_context_get_path (parent));
|
||||
else
|
||||
path = gtk_widget_path_new ();
|
||||
|
||||
append_element (path, selector);
|
||||
|
||||
context = gtk_style_context_new ();
|
||||
gtk_style_context_set_path (context, path);
|
||||
gtk_style_context_set_parent (context, parent);
|
||||
@@ -135,93 +125,273 @@ get_style (GtkStyleContext *parent,
|
||||
return context;
|
||||
}
|
||||
|
||||
static GtkStyleContext *
|
||||
get_style (GtkStyleContext *parent,
|
||||
const char *selector)
|
||||
{
|
||||
GtkWidgetPath *path;
|
||||
|
||||
if (parent)
|
||||
path = gtk_widget_path_copy (gtk_style_context_get_path (parent));
|
||||
else
|
||||
path = gtk_widget_path_new ();
|
||||
|
||||
append_element (path, selector);
|
||||
|
||||
return create_context_for_path (path, parent);
|
||||
}
|
||||
|
||||
static GtkStyleContext *
|
||||
get_style_with_siblings (GtkStyleContext *parent,
|
||||
const char *selector,
|
||||
const char **siblings,
|
||||
gint position)
|
||||
{
|
||||
GtkWidgetPath *path, *siblings_path;
|
||||
guint i;
|
||||
|
||||
if (parent)
|
||||
path = gtk_widget_path_copy (gtk_style_context_get_path (parent));
|
||||
else
|
||||
path = gtk_widget_path_new ();
|
||||
|
||||
siblings_path = gtk_widget_path_new ();
|
||||
for (i = 0; siblings[i]; i++)
|
||||
append_element (siblings_path, siblings[i]);
|
||||
|
||||
gtk_widget_path_append_with_siblings (path, siblings_path, position);
|
||||
gtk_widget_path_unref (siblings_path);
|
||||
|
||||
return create_context_for_path (path, parent);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_menu (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
draw_style_common (GtkStyleContext *context,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
gint *contents_x,
|
||||
gint *contents_y,
|
||||
gint *contents_width,
|
||||
gint *contents_height)
|
||||
{
|
||||
GtkBorder margin, border, padding;
|
||||
int min_width, min_height;
|
||||
|
||||
gtk_style_context_get_margin (context, gtk_style_context_get_state (context), &margin);
|
||||
gtk_style_context_get_border (context, gtk_style_context_get_state (context), &border);
|
||||
gtk_style_context_get_padding (context, gtk_style_context_get_state (context), &padding);
|
||||
|
||||
gtk_style_context_get (context, gtk_style_context_get_state (context),
|
||||
"min-width", &min_width,
|
||||
"min-height", &min_height,
|
||||
NULL);
|
||||
x += margin.left;
|
||||
y += margin.top;
|
||||
width -= margin.left + margin.right;
|
||||
height -= margin.top + margin.bottom;
|
||||
|
||||
width = MAX (width, min_width);
|
||||
height = MAX (height, min_height);
|
||||
|
||||
gtk_render_background (context, cr, x, y, width, height);
|
||||
gtk_render_frame (context, cr, x, y, width, height);
|
||||
|
||||
if (contents_x)
|
||||
*contents_x = x + border.left + padding.left;
|
||||
if (contents_y)
|
||||
*contents_y = y + border.top + padding.top;
|
||||
if (contents_width)
|
||||
*contents_width = width - border.left - border.right - padding.left - padding.right;
|
||||
if (contents_height)
|
||||
*contents_height = height - border.top - border.bottom - padding.top - padding.bottom;
|
||||
}
|
||||
|
||||
static void
|
||||
query_size (GtkStyleContext *context,
|
||||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
GtkBorder margin, border, padding;
|
||||
int min_width, min_height;
|
||||
|
||||
gtk_style_context_get_margin (context, gtk_style_context_get_state (context), &margin);
|
||||
gtk_style_context_get_border (context, gtk_style_context_get_state (context), &border);
|
||||
gtk_style_context_get_padding (context, gtk_style_context_get_state (context), &padding);
|
||||
|
||||
gtk_style_context_get (context, gtk_style_context_get_state (context),
|
||||
"min-width", &min_width,
|
||||
"min-height", &min_height,
|
||||
NULL);
|
||||
|
||||
min_width += margin.left + margin.right + border.left + border.right + padding.left + padding.right;
|
||||
min_height += margin.top + margin.bottom + border.top + border.bottom + padding.top + padding.bottom;
|
||||
|
||||
if (width)
|
||||
*width = MAX (*width, min_width);
|
||||
if (height)
|
||||
*height = MAX (*height, min_height);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_menu (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint *height)
|
||||
{
|
||||
GtkStyleContext *menu_context;
|
||||
GtkStyleContext *menuitem_context;
|
||||
GtkStyleContext *hovermenuitem_context;
|
||||
GtkStyleContext *hoveredarrowmenuitem_context;
|
||||
GtkStyleContext *arrowmenuitem_context;
|
||||
GtkStyleContext *checkmenuitem_context;
|
||||
GtkStyleContext *disabledarrowmenuitem_context;
|
||||
GtkStyleContext *disabledcheckmenuitem_context;
|
||||
GtkStyleContext *radiomenuitem_context;
|
||||
GtkStyleContext *disablemenuitem_context;
|
||||
GtkStyleContext *disabledradiomenuitem_context;
|
||||
GtkStyleContext *separatormenuitem_context;
|
||||
gint menuitem1_height, menuitem2_height, menuitem3_height, menuitem4_height, menuitem5_height;
|
||||
gint contents_x, contents_y, contents_width, contents_height;
|
||||
gint menu_x, menu_y, menu_width, menu_height;
|
||||
gint arrow_width, arrow_height, arrow_size;
|
||||
gint toggle_x, toggle_y, toggle_width, toggle_height;
|
||||
|
||||
/* This information is taken from the GtkMenu docs, see "CSS nodes" */
|
||||
menu_context = get_style (gtk_widget_get_style_context(widget), "menu");
|
||||
|
||||
gtk_render_background (menu_context, cr, x, y, width, height);
|
||||
gtk_render_frame (menu_context, cr, x, y, width, height);
|
||||
|
||||
hovermenuitem_context = get_style (menu_context, "menuitem:hover");
|
||||
gtk_render_background (hovermenuitem_context, cr, x, y, width, 20);
|
||||
gtk_render_frame (hovermenuitem_context, cr, x, y, width, 20);
|
||||
|
||||
/* arrow for left to right */
|
||||
arrowmenuitem_context = get_style (hovermenuitem_context, "arrow:dir(ltr)");
|
||||
gtk_render_arrow (arrowmenuitem_context, cr, G_PI / 2, x + width - 20, y, 20);
|
||||
g_object_unref (arrowmenuitem_context);
|
||||
|
||||
hoveredarrowmenuitem_context = get_style (hovermenuitem_context, "arrow.right:dir(ltr)");
|
||||
menuitem_context = get_style (menu_context, "menuitem");
|
||||
gtk_render_background (menuitem_context, cr, x, y + 20, width, 20);
|
||||
gtk_render_frame (menuitem_context, cr, x, y + 20, width, 20);
|
||||
|
||||
disablemenuitem_context = get_style (menu_context, "menuitem:disabled");
|
||||
|
||||
/* arrow for right to left, sensitive */
|
||||
arrowmenuitem_context = get_style (menuitem_context, "arrow:dir(rtl)");
|
||||
gtk_render_arrow (arrowmenuitem_context, cr, G_PI / 2, x, y + 20, 20);
|
||||
g_object_unref (arrowmenuitem_context);
|
||||
|
||||
/* arrow for right to left, insensitive */
|
||||
arrowmenuitem_context = get_style (disablemenuitem_context, "arrow:dir(rtl)");
|
||||
gtk_render_arrow (arrowmenuitem_context, cr, G_PI / 2, x + width - 20, y + 20, 20);
|
||||
|
||||
gtk_render_background (menuitem_context, cr, x, y + 40, width, 20);
|
||||
gtk_render_frame (menuitem_context, cr, x, y + 40, width, 20);
|
||||
|
||||
/* check enabled, sensitive */
|
||||
disablemenuitem_context = get_style (menu_context, "menuitem:disabled");
|
||||
disabledarrowmenuitem_context = get_style (disablemenuitem_context, "arrow:dir(rtl)");
|
||||
checkmenuitem_context = get_style (menuitem_context, "check:checked");
|
||||
gtk_render_frame (checkmenuitem_context, cr, x + 2, y + 40, 16, 16);
|
||||
gtk_render_check (checkmenuitem_context, cr, x + 2, y + 40, 16, 16);
|
||||
g_object_unref (checkmenuitem_context);
|
||||
|
||||
/* check unchecked, insensitive */
|
||||
checkmenuitem_context = get_style (disablemenuitem_context, "check");
|
||||
gtk_render_frame (checkmenuitem_context, cr, x + width - 18, y + 40, 16, 16);
|
||||
gtk_render_check (checkmenuitem_context, cr, x + width - 18, y + 40, 16, 16);
|
||||
|
||||
/* draw separator */
|
||||
separatormenuitem_context = get_style (menuitem_context, "separator:disabled");
|
||||
gtk_render_line (separatormenuitem_context, cr, x + 1, y + 60, x + width - 2, y + 60);
|
||||
|
||||
gtk_render_background (menuitem_context, cr, x, y + 70, width, 20);
|
||||
gtk_render_frame (menuitem_context, cr, x, y + 70, width, 20);
|
||||
|
||||
/* radio checked, sensitive */
|
||||
disabledcheckmenuitem_context = get_style (disablemenuitem_context, "check");
|
||||
separatormenuitem_context = get_style (menu_context, "separator:disabled");
|
||||
radiomenuitem_context = get_style (menuitem_context, "radio:checked");
|
||||
gtk_render_frame (radiomenuitem_context, cr, x + 2, y + 70, 16, 16);
|
||||
gtk_render_option (radiomenuitem_context, cr, x + 2, y + 70, 16, 16);
|
||||
g_object_unref (radiomenuitem_context);
|
||||
disabledradiomenuitem_context = get_style (disablemenuitem_context, "radio");
|
||||
|
||||
/* radio unchecked, insensitive */
|
||||
radiomenuitem_context = get_style (disablemenuitem_context, "radio");
|
||||
gtk_render_frame (radiomenuitem_context, cr, x + width - 18, y + 70, 16, 16);
|
||||
gtk_render_option (radiomenuitem_context, cr, x + width - 18, y + 70, 16, 16);
|
||||
*height = 0;
|
||||
query_size (menu_context, NULL, height);
|
||||
menuitem1_height = 0;
|
||||
query_size (hovermenuitem_context, NULL, &menuitem1_height);
|
||||
query_size (hoveredarrowmenuitem_context, NULL, &menuitem1_height);
|
||||
*height += menuitem1_height;
|
||||
menuitem2_height = 0;
|
||||
query_size (menu_context, NULL, &menuitem5_height);
|
||||
query_size (menuitem_context, NULL, &menuitem2_height);
|
||||
query_size (arrowmenuitem_context, NULL, &menuitem2_height);
|
||||
query_size (disabledarrowmenuitem_context, NULL, &menuitem2_height);
|
||||
*height += menuitem2_height;
|
||||
menuitem3_height = 0;
|
||||
query_size (menu_context, NULL, &menuitem5_height);
|
||||
query_size (menuitem_context, NULL, &menuitem3_height);
|
||||
query_size (checkmenuitem_context, NULL, &menuitem3_height);
|
||||
query_size (disabledcheckmenuitem_context, NULL, &menuitem3_height);
|
||||
*height += menuitem3_height;
|
||||
menuitem4_height = 0;
|
||||
query_size (menu_context, NULL, &menuitem5_height);
|
||||
query_size (separatormenuitem_context, NULL, &menuitem4_height);
|
||||
*height += menuitem4_height;
|
||||
menuitem5_height = 0;
|
||||
query_size (menu_context, NULL, &menuitem5_height);
|
||||
query_size (menuitem_context, NULL, &menuitem5_height);
|
||||
query_size (radiomenuitem_context, NULL, &menuitem5_height);
|
||||
query_size (disabledradiomenuitem_context, NULL, &menuitem5_height);
|
||||
*height += menuitem5_height;
|
||||
|
||||
draw_style_common (menu_context, cr, x, y, width, *height,
|
||||
&menu_x, &menu_y, &menu_width, &menu_height);
|
||||
|
||||
/* Hovered with right arrow */
|
||||
gtk_style_context_get (hoveredarrowmenuitem_context, gtk_style_context_get_state (hoveredarrowmenuitem_context),
|
||||
"min-width", &arrow_width, "min-height", &arrow_height, NULL);
|
||||
arrow_size = MIN (arrow_width, arrow_height);
|
||||
draw_style_common (hovermenuitem_context, cr, menu_x, menu_y, menu_width, menuitem1_height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
gtk_render_arrow (hoveredarrowmenuitem_context, cr, G_PI / 2,
|
||||
contents_x + contents_width - arrow_size,
|
||||
contents_y + (contents_height - arrow_size) / 2, arrow_size);
|
||||
|
||||
/* Left arrow sensitive, and right arrow insensitive */
|
||||
draw_style_common (menuitem_context, cr, menu_x, menu_y + menuitem1_height, menu_width, menuitem2_height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
gtk_style_context_get (arrowmenuitem_context, gtk_style_context_get_state (arrowmenuitem_context),
|
||||
"min-width", &arrow_width, "min-height", &arrow_height, NULL);
|
||||
arrow_size = MIN (arrow_width, arrow_height);
|
||||
gtk_render_arrow (arrowmenuitem_context, cr, G_PI / 2,
|
||||
contents_x,
|
||||
contents_y + (contents_height - arrow_size) / 2, arrow_size);
|
||||
gtk_style_context_get (disabledarrowmenuitem_context, gtk_style_context_get_state (disabledarrowmenuitem_context),
|
||||
"min-width", &arrow_width, "min-height", &arrow_height, NULL);
|
||||
arrow_size = MIN (arrow_width, arrow_height);
|
||||
gtk_render_arrow (disabledarrowmenuitem_context, cr, G_PI / 2,
|
||||
contents_x + contents_width - arrow_size,
|
||||
contents_y + (contents_height - arrow_size) / 2, arrow_size);
|
||||
|
||||
|
||||
/* Left check enabled, sensitive, and right check unchecked, insensitive */
|
||||
draw_style_common (menuitem_context, cr, menu_x, menu_y + menuitem1_height + menuitem2_height, menu_width, menuitem3_height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
gtk_style_context_get (checkmenuitem_context, gtk_style_context_get_state (checkmenuitem_context),
|
||||
"min-width", &toggle_width, "min-height", &toggle_height, NULL);
|
||||
draw_style_common (checkmenuitem_context, cr,
|
||||
contents_x,
|
||||
contents_y,
|
||||
toggle_width, toggle_height,
|
||||
&toggle_x, &toggle_y, &toggle_width, &toggle_height);
|
||||
gtk_render_check (checkmenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
|
||||
gtk_style_context_get (disabledcheckmenuitem_context, gtk_style_context_get_state (disabledcheckmenuitem_context),
|
||||
"min-width", &toggle_width, "min-height", &toggle_height, NULL);
|
||||
draw_style_common (disabledcheckmenuitem_context, cr,
|
||||
contents_x + contents_width - toggle_width,
|
||||
contents_y,
|
||||
toggle_width, toggle_height,
|
||||
&toggle_x, &toggle_y, &toggle_width, &toggle_height);
|
||||
gtk_render_check (disabledcheckmenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
|
||||
|
||||
/* Separator */
|
||||
draw_style_common (separatormenuitem_context, cr, menu_x, menu_y + menuitem1_height + menuitem2_height + menuitem3_height,
|
||||
menu_width, menuitem4_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
/* Left check enabled, sensitive, and right check unchecked, insensitive */
|
||||
draw_style_common (menuitem_context, cr, menu_x, menu_y + menuitem1_height + menuitem2_height + menuitem3_height + menuitem4_height,
|
||||
menu_width, menuitem5_height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
gtk_style_context_get (radiomenuitem_context, gtk_style_context_get_state (radiomenuitem_context),
|
||||
"min-width", &toggle_width, "min-height", &toggle_height, NULL);
|
||||
draw_style_common (radiomenuitem_context, cr,
|
||||
contents_x,
|
||||
contents_y,
|
||||
toggle_width, toggle_height,
|
||||
&toggle_x, &toggle_y, &toggle_width, &toggle_height);
|
||||
gtk_render_check (radiomenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
|
||||
gtk_style_context_get (disabledradiomenuitem_context, gtk_style_context_get_state (disabledradiomenuitem_context),
|
||||
"min-width", &toggle_width, "min-height", &toggle_height, NULL);
|
||||
draw_style_common (disabledradiomenuitem_context, cr,
|
||||
contents_x + contents_width - toggle_width,
|
||||
contents_y,
|
||||
toggle_width, toggle_height,
|
||||
&toggle_x, &toggle_y, &toggle_width, &toggle_height);
|
||||
gtk_render_check (disabledradiomenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
|
||||
|
||||
g_object_unref (separatormenuitem_context);
|
||||
g_object_unref (disablemenuitem_context);
|
||||
g_object_unref (radiomenuitem_context);
|
||||
g_object_unref (checkmenuitem_context);
|
||||
g_object_unref (arrowmenuitem_context);
|
||||
g_object_unref (hovermenuitem_context);
|
||||
g_object_unref (menuitem_context);
|
||||
g_object_unref (menu_context);
|
||||
g_object_unref (menuitem_context);
|
||||
g_object_unref (hovermenuitem_context);
|
||||
g_object_unref (hoveredarrowmenuitem_context);
|
||||
g_object_unref (arrowmenuitem_context);
|
||||
g_object_unref (checkmenuitem_context);
|
||||
g_object_unref (disabledarrowmenuitem_context);
|
||||
g_object_unref (disabledcheckmenuitem_context);
|
||||
g_object_unref (radiomenuitem_context);
|
||||
g_object_unref (disablemenuitem_context);
|
||||
g_object_unref (disabledradiomenuitem_context);
|
||||
g_object_unref (separatormenuitem_context);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -230,28 +400,49 @@ draw_menubar (GtkWidget *widget,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
gint *height)
|
||||
{
|
||||
GtkStyleContext *frame_context;
|
||||
GtkStyleContext *border_context;
|
||||
GtkStyleContext *menubar_context;
|
||||
GtkStyleContext *hovered_menuitem_context;
|
||||
GtkStyleContext *menuitem_context;
|
||||
gint item_width = width / 3;
|
||||
gint contents_x, contents_y, contents_width, contents_height;
|
||||
gint item_width;
|
||||
|
||||
/* Menubar background is the same color as our base background, so use a frame */
|
||||
frame_context = get_style (NULL, "frame");
|
||||
border_context = get_style (frame_context, "border");
|
||||
|
||||
/* This information is taken from the GtkMenuBar docs, see "CSS nodes" */
|
||||
menubar_context = get_style (NULL, "menubar.background");
|
||||
menubar_context = get_style (NULL, "menubar");
|
||||
hovered_menuitem_context = get_style (menubar_context, "menuitem:hover");
|
||||
menuitem_context = get_style (menubar_context, "menuitem");
|
||||
|
||||
gtk_render_background (menubar_context, cr, x, y, width, height);
|
||||
gtk_render_frame (menubar_context, cr, x, y, width, height);
|
||||
*height = 0;
|
||||
query_size (frame_context, NULL, height);
|
||||
query_size (border_context, NULL, height);
|
||||
query_size (menubar_context, NULL, height);
|
||||
query_size (hovered_menuitem_context, NULL, height);
|
||||
query_size (menuitem_context, NULL, height);
|
||||
|
||||
menuitem_context = get_style (menubar_context, "menuitem:hover");
|
||||
|
||||
gtk_render_background (menuitem_context, cr, x, y, item_width, 20);
|
||||
gtk_render_frame (menuitem_context, cr, x, y, item_width, 20);
|
||||
|
||||
gtk_render_background (menuitem_context, cr, x + item_width * 2, y, item_width, 20);
|
||||
gtk_render_frame (menuitem_context, cr, x + item_width * 2, y, item_width, 20);
|
||||
draw_style_common (frame_context, cr, x, y, width, *height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
draw_style_common (border_context, cr, x, y, width, *height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
draw_style_common (menubar_context, cr, contents_x, contents_y, contents_width, contents_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
item_width = contents_width / 3;
|
||||
draw_style_common (hovered_menuitem_context, cr, contents_x, contents_y, item_width, contents_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
draw_style_common (menuitem_context, cr, contents_x + item_width * 2, contents_y, item_width, contents_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
g_object_unref (menuitem_context);
|
||||
g_object_unref (hovered_menuitem_context);
|
||||
g_object_unref (menubar_context);
|
||||
g_object_unref (border_context);
|
||||
g_object_unref (frame_context);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -265,39 +456,40 @@ draw_notebook (GtkWidget *widget,
|
||||
GtkStyleContext *notebook_context;
|
||||
GtkStyleContext *header_context;
|
||||
GtkStyleContext *tabs_context;
|
||||
GtkStyleContext *tab_context;
|
||||
GtkStyleContext *tab1_context, *tab2_context;
|
||||
GtkStyleContext *stack_context;
|
||||
gint header_height = 40;
|
||||
gint header_height;
|
||||
gint contents_x, contents_y, contents_width, contents_height;
|
||||
|
||||
/* This information is taken from the GtkNotebook docs, see "CSS nodes" */
|
||||
notebook_context = get_style (NULL, "notebook.frame");
|
||||
gtk_render_background (notebook_context, cr, x, y, width, height);
|
||||
gtk_render_frame (notebook_context, cr, x, y, width, height);
|
||||
|
||||
header_context = get_style (notebook_context, "header.top");
|
||||
gtk_render_background (header_context, cr, x, y, width, header_height);
|
||||
gtk_render_frame (header_context, cr, x, y, width, header_height);
|
||||
|
||||
tabs_context = get_style (header_context, "tabs");
|
||||
gtk_render_background (tabs_context, cr, x, y, width, header_height);
|
||||
gtk_render_frame (tabs_context, cr, x, y, width, header_height);
|
||||
|
||||
tab_context = get_style (tabs_context, "tab:active");
|
||||
gtk_render_background (tab_context, cr, x, y, width/2, header_height);
|
||||
gtk_render_frame (tab_context, cr, x, y, width/2, header_height);
|
||||
g_object_unref (tab_context);
|
||||
|
||||
tab_context = get_style (tabs_context, "tab");
|
||||
gtk_render_background (tab_context, cr, x + width/2, y, width/2, header_height);
|
||||
gtk_render_frame (tab_context, cr, x + width/2, y, width/2, header_height);
|
||||
|
||||
tab1_context = get_style (tabs_context, "tab:checked");
|
||||
tab2_context = get_style (tabs_context, "tab:hover");
|
||||
stack_context = get_style (notebook_context, "stack");
|
||||
gtk_render_background (stack_context, cr, x, y + header_height, width, height - header_height);
|
||||
gtk_render_frame (stack_context, cr, x, y + header_height, width, height - header_height);
|
||||
|
||||
header_height = 0;
|
||||
query_size (notebook_context, NULL, &header_height);
|
||||
query_size (header_context, NULL, &header_height);
|
||||
query_size (tabs_context, NULL, &header_height);
|
||||
query_size (tab1_context, NULL, &header_height);
|
||||
query_size (tab2_context, NULL, &header_height);
|
||||
|
||||
draw_style_common (notebook_context, cr, x, y, width, height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (header_context, cr, x, y, width, header_height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (tabs_context, cr, x, y, width, header_height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (tab1_context, cr, x, y, width / 2, header_height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
draw_style_common (tab2_context, cr, x + width / 2, y, width / 2, header_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
draw_style_common (stack_context, cr, x, y + header_height, width,height - header_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
g_object_unref (stack_context);
|
||||
g_object_unref (tab_context);
|
||||
g_object_unref (tabs_context);
|
||||
g_object_unref (tab1_context);
|
||||
g_object_unref (tab2_context);
|
||||
g_object_unref (header_context);
|
||||
g_object_unref (notebook_context);
|
||||
}
|
||||
@@ -308,17 +500,18 @@ draw_horizontal_scrollbar (GtkWidget *widget,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
gint position,
|
||||
GtkStateFlags state)
|
||||
GtkStateFlags state,
|
||||
gint *height)
|
||||
{
|
||||
GtkStyleContext *scrollbar_context;
|
||||
GtkStyleContext *contents_context;
|
||||
GtkStyleContext *trough_context;
|
||||
GtkStyleContext *slider_context;
|
||||
gint slider_width;
|
||||
|
||||
/* This information is taken from the GtkScrollbar docs, see "CSS nodes" */
|
||||
scrollbar_context = get_style (NULL, "scrollbar.horizontal");
|
||||
scrollbar_context = get_style (NULL, "scrollbar.horizontal.bottom");
|
||||
contents_context = get_style (scrollbar_context, "contents");
|
||||
trough_context = get_style (contents_context, "trough");
|
||||
slider_context = get_style (trough_context, "slider");
|
||||
@@ -328,15 +521,19 @@ draw_horizontal_scrollbar (GtkWidget *widget,
|
||||
gtk_style_context_set_state (trough_context, state);
|
||||
gtk_style_context_set_state (slider_context, state);
|
||||
|
||||
gtk_render_background (scrollbar_context, cr, x, y, width, height);
|
||||
gtk_render_frame (scrollbar_context, cr, x, y, width, height);
|
||||
gtk_render_background (contents_context, cr, x, y, width, height);
|
||||
gtk_render_frame (contents_context, cr, x, y, width, height);
|
||||
gtk_render_background (trough_context, cr, x, y, width, height);
|
||||
gtk_render_frame (trough_context, cr, x, y, width, height);
|
||||
/* The theme uses negative margins, this is where the -1 comes from */
|
||||
gtk_render_background (slider_context, cr, x + position, y - 1, 30, height + 2);
|
||||
gtk_render_frame (slider_context, cr, x + position, y - 1, 30, height + 2);
|
||||
*height = 0;
|
||||
query_size (scrollbar_context, NULL, height);
|
||||
query_size (contents_context, NULL, height);
|
||||
query_size (trough_context, NULL, height);
|
||||
query_size (slider_context, NULL, height);
|
||||
|
||||
gtk_style_context_get (slider_context, gtk_style_context_get_state (slider_context),
|
||||
"min-width", &slider_width, NULL);
|
||||
|
||||
draw_style_common (scrollbar_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (contents_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (trough_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (slider_context, cr, x + position, y, slider_width, *height, NULL, NULL, NULL, NULL);
|
||||
|
||||
g_object_unref (slider_context);
|
||||
g_object_unref (trough_context);
|
||||
@@ -387,10 +584,13 @@ draw_check (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
GtkStateFlags state)
|
||||
GtkStateFlags state,
|
||||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
GtkStyleContext *button_context;
|
||||
GtkStyleContext *check_context;
|
||||
gint contents_x, contents_y, contents_width, contents_height;
|
||||
|
||||
/* This information is taken from the GtkCheckButton docs, see "CSS nodes" */
|
||||
button_context = get_style (NULL, "checkbutton");
|
||||
@@ -398,9 +598,14 @@ draw_check (GtkWidget *widget,
|
||||
|
||||
gtk_style_context_set_state (check_context, state);
|
||||
|
||||
gtk_render_background (check_context, cr, x, y, 20, 20);
|
||||
gtk_render_frame (check_context, cr, x, y, 20, 20);
|
||||
gtk_render_check (check_context, cr, x, y, 20, 20);
|
||||
*width = *height = 0;
|
||||
query_size (button_context, width, height);
|
||||
query_size (check_context, width, height);
|
||||
|
||||
draw_style_common (button_context, cr, x, y, *width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (check_context, cr, x, y, *width, *height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
gtk_render_check (check_context, cr, contents_x, contents_y, contents_width, contents_height);
|
||||
|
||||
g_object_unref (check_context);
|
||||
g_object_unref (button_context);
|
||||
@@ -412,10 +617,13 @@ draw_radio (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
GtkStateFlags state)
|
||||
GtkStateFlags state,
|
||||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
GtkStyleContext *button_context;
|
||||
GtkStyleContext *check_context;
|
||||
gint contents_x, contents_y, contents_width, contents_height;
|
||||
|
||||
/* This information is taken from the GtkRadioButton docs, see "CSS nodes" */
|
||||
button_context = get_style (NULL, "radiobutton");
|
||||
@@ -423,9 +631,14 @@ draw_radio (GtkWidget *widget,
|
||||
|
||||
gtk_style_context_set_state (check_context, state);
|
||||
|
||||
gtk_render_background (check_context, cr, x, y, 20, 20);
|
||||
gtk_render_frame (check_context, cr, x, y, 20, 20);
|
||||
gtk_render_option (check_context, cr, x, y, 20, 20);
|
||||
*width = *height = 0;
|
||||
query_size (button_context, width, height);
|
||||
query_size (check_context, width, height);
|
||||
|
||||
draw_style_common (button_context, cr, x, y, *width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (check_context, cr, x, y, *width, *height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
gtk_render_check (check_context, cr, contents_x, contents_y, contents_width, contents_height);
|
||||
|
||||
g_object_unref (check_context);
|
||||
g_object_unref (button_context);
|
||||
@@ -438,69 +651,166 @@ draw_progress (GtkWidget *widget,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
gint position)
|
||||
gint position,
|
||||
gint *height)
|
||||
{
|
||||
GtkStyleContext *bar_context;
|
||||
GtkStyleContext *trough_context;
|
||||
GtkStyleContext *progress_context;
|
||||
|
||||
/* This information is taken from the GtkProgressBar docs, see "CSS nodes" */
|
||||
bar_context = get_style (NULL, "progressbar");
|
||||
bar_context = get_style (NULL, "progressbar.horizontal");
|
||||
trough_context = get_style (bar_context, "trough");
|
||||
progress_context = get_style (trough_context, "progress");
|
||||
progress_context = get_style (trough_context, "progress.left");
|
||||
|
||||
gtk_render_background (trough_context, cr, x, y, width, height);
|
||||
gtk_render_frame (trough_context, cr, x, y, width, height);
|
||||
gtk_render_background (progress_context, cr, x, y, position, height);
|
||||
gtk_render_frame (progress_context, cr, x, y, position, height);
|
||||
*height = 0;
|
||||
query_size (bar_context, NULL, height);
|
||||
query_size (trough_context, NULL, height);
|
||||
query_size (progress_context, NULL, height);
|
||||
|
||||
draw_style_common (bar_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (trough_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (progress_context, cr, x, y, position, *height, NULL, NULL, NULL, NULL);
|
||||
|
||||
g_object_unref (progress_context);
|
||||
g_object_unref (trough_context);
|
||||
g_object_unref (bar_context);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_scale (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint position,
|
||||
gint *height)
|
||||
{
|
||||
GtkStyleContext *scale_context;
|
||||
GtkStyleContext *contents_context;
|
||||
GtkStyleContext *trough_context;
|
||||
GtkStyleContext *slider_context;
|
||||
GtkStyleContext *highlight_context;
|
||||
gint contents_x, contents_y, contents_width, contents_height;
|
||||
gint trough_height, slider_height;
|
||||
|
||||
scale_context = get_style (NULL, "scale.horizontal");
|
||||
contents_context = get_style (scale_context, "contents");
|
||||
trough_context = get_style (contents_context, "trough");
|
||||
slider_context = get_style (trough_context, "slider");
|
||||
highlight_context = get_style (trough_context, "highlight.top");
|
||||
|
||||
*height = 0;
|
||||
query_size (scale_context, NULL, height);
|
||||
query_size (contents_context, NULL, height);
|
||||
query_size (trough_context, NULL, height);
|
||||
query_size (slider_context, NULL, height);
|
||||
query_size (highlight_context, NULL, height);
|
||||
|
||||
draw_style_common (scale_context, cr, x, y, width, *height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
draw_style_common (contents_context, cr, contents_x, contents_y, contents_width, contents_height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
/* Scale trough defines its size querying slider and highlight */
|
||||
trough_height = 0;
|
||||
query_size (trough_context, NULL, &trough_height);
|
||||
slider_height = 0;
|
||||
query_size (slider_context, NULL, &slider_height);
|
||||
query_size (highlight_context, NULL, &slider_height);
|
||||
trough_height += slider_height;
|
||||
draw_style_common (trough_context, cr, contents_x, contents_y, contents_width, trough_height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
draw_style_common (highlight_context, cr, contents_x, contents_y,
|
||||
contents_width / 2, contents_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
draw_style_common (slider_context, cr, contents_x + position, contents_y, contents_height, contents_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
g_object_unref (scale_context);
|
||||
g_object_unref (contents_context);
|
||||
g_object_unref (trough_context);
|
||||
g_object_unref (slider_context);
|
||||
g_object_unref (highlight_context);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_combobox (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gboolean has_entry)
|
||||
gboolean has_entry,
|
||||
gint *height)
|
||||
{
|
||||
GtkStyleContext *combo_context;
|
||||
GtkStyleContext *box_context;
|
||||
GtkStyleContext *button_context;
|
||||
GtkStyleContext *button_box_context;
|
||||
GtkStyleContext *entry_context;
|
||||
GtkStyleContext *arrow_context;
|
||||
gint contents_x, contents_y, contents_width, contents_height;
|
||||
gint button_width;
|
||||
gint arrow_width, arrow_height, arrow_size;
|
||||
|
||||
/* This information is taken from the GtkComboBox docs, see "CSS nodes" */
|
||||
combo_context = get_style (NULL, "combobox:focus");
|
||||
button_context = get_style (combo_context, "button:focus");
|
||||
entry_context = get_style (combo_context, "entry:focus");
|
||||
arrow_context = get_style (button_context, "arrow");
|
||||
|
||||
gtk_render_background (combo_context, cr, x, y, width, 30);
|
||||
gtk_render_frame (combo_context, cr, x, y, width, 30);
|
||||
|
||||
box_context = get_style (combo_context, "box.horizontal.linked");
|
||||
if (has_entry)
|
||||
{
|
||||
gtk_style_context_set_junction_sides (entry_context, GTK_JUNCTION_RIGHT);
|
||||
gtk_render_background (entry_context, cr, x, y, width - 30, 30);
|
||||
gtk_render_frame (entry_context, cr, x, y, width - 30, 30);
|
||||
const char *siblings[3] = { "entry.combo:focus", "button.combo" , NULL };
|
||||
|
||||
gtk_render_background (button_context, cr, x + width - 30, y, 30, 30);
|
||||
gtk_render_frame (button_context, cr, x + width - 30, y, 30, 30);
|
||||
entry_context = get_style_with_siblings (box_context, "entry.combo:focus", siblings, 0);
|
||||
button_context = get_style_with_siblings (box_context, "button.combo", siblings, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_render_background (button_context, cr, x, y, width, 30);
|
||||
gtk_render_frame (button_context, cr, x, y, width, 30);
|
||||
const char *siblings[2] = { "button.combo" , NULL };
|
||||
|
||||
button_context = get_style_with_siblings (box_context, "button.combo", siblings, 0);
|
||||
}
|
||||
button_box_context = get_style (button_context, "box.horizontal");
|
||||
arrow_context = get_style (button_box_context, "arrow");
|
||||
|
||||
*height = 0;
|
||||
query_size (combo_context, NULL, height);
|
||||
query_size (box_context, NULL, height);
|
||||
if (has_entry)
|
||||
query_size (entry_context, NULL, height);
|
||||
query_size (button_context, NULL, height);
|
||||
query_size (button_box_context, NULL, height);
|
||||
query_size (arrow_context, NULL, height);
|
||||
|
||||
gtk_style_context_get (arrow_context, gtk_style_context_get_state (arrow_context),
|
||||
"min-width", &arrow_width, "min-height", &arrow_height, NULL);
|
||||
arrow_size = MIN (arrow_width, arrow_height);
|
||||
|
||||
draw_style_common (combo_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (box_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
|
||||
if (has_entry)
|
||||
{
|
||||
button_width = *height;
|
||||
draw_style_common (entry_context, cr, x, y, width - button_width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (button_context, cr, x + width - button_width, y, button_width, *height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
}
|
||||
else
|
||||
{
|
||||
button_width = width;
|
||||
draw_style_common (button_context, cr, x, y, width, *height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
}
|
||||
|
||||
gtk_render_arrow (arrow_context, cr, G_PI / 2, x + width - 25, y+5, 20);
|
||||
draw_style_common (button_box_context, cr, contents_x, contents_y, contents_width, contents_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
draw_style_common (arrow_context, cr, contents_x, contents_y, contents_width, contents_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
gtk_render_arrow (arrow_context, cr, G_PI / 2,
|
||||
contents_x + contents_width - arrow_size,
|
||||
contents_y + (contents_height - arrow_size) / 2, arrow_size);
|
||||
|
||||
g_object_unref (arrow_context);
|
||||
g_object_unref (entry_context);
|
||||
if (has_entry)
|
||||
g_object_unref (entry_context);
|
||||
g_object_unref (button_context);
|
||||
g_object_unref (combo_context);
|
||||
}
|
||||
@@ -510,44 +820,59 @@ draw_spinbutton (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width)
|
||||
gint width,
|
||||
gint *height)
|
||||
{
|
||||
GtkStyleContext *spin_context;
|
||||
GtkStyleContext *entry_context;
|
||||
GtkStyleContext *up_context;
|
||||
GtkStyleContext *down_context;
|
||||
|
||||
GtkIconTheme *icon_theme;
|
||||
GtkIconInfo *icon_info;
|
||||
GdkPixbuf *pixbuf;
|
||||
gint icon_width, icon_height, icon_size;
|
||||
gint button_width;
|
||||
gint contents_x, contents_y, contents_width, contents_height;
|
||||
|
||||
/* This information is taken from the GtkSpinButton docs, see "CSS nodes" */
|
||||
spin_context = get_style (NULL, "spinbutton:focus");
|
||||
spin_context = get_style (NULL, "spinbutton.horizontal:focus");
|
||||
entry_context = get_style (NULL, "entry:focus");
|
||||
up_context = get_style (spin_context, "button.up:active");
|
||||
down_context = get_style (spin_context, "button.down");
|
||||
up_context = get_style (spin_context, "button.up:focus:active");
|
||||
down_context = get_style (spin_context, "button.down:focus");
|
||||
|
||||
gtk_render_background (entry_context, cr, x, y, width, 30);
|
||||
gtk_render_frame (entry_context, cr, x, y, width, 30);
|
||||
*height = 0;
|
||||
query_size (spin_context, NULL, height);
|
||||
query_size (entry_context, NULL, height);
|
||||
query_size (up_context, NULL, height);
|
||||
query_size (down_context, NULL, height);
|
||||
button_width = *height;
|
||||
|
||||
gtk_render_background (up_context, cr, x + width - 30, y, 30, 30);
|
||||
gtk_render_frame (up_context, cr, x + width - 30, y, 30, 30);
|
||||
|
||||
gtk_render_background (down_context, cr, x + width - 60, y, 30, 30);
|
||||
gtk_render_frame (down_context, cr, x + width - 60, y, 30, 30);
|
||||
draw_style_common (spin_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (entry_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
|
||||
|
||||
icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
|
||||
|
||||
icon_info = gtk_icon_theme_lookup_icon (icon_theme, "list-add-symbolic", 20, 0);
|
||||
gtk_style_context_get (up_context, gtk_style_context_get_state (up_context),
|
||||
"min-width", &icon_width, "min-height", &icon_height, NULL);
|
||||
icon_size = MIN (icon_width, icon_height);
|
||||
icon_info = gtk_icon_theme_lookup_icon (icon_theme, "list-add-symbolic", icon_size, 0);
|
||||
pixbuf = gtk_icon_info_load_symbolic_for_context (icon_info, up_context, NULL, NULL);
|
||||
g_object_unref (icon_info);
|
||||
gtk_render_icon (up_context, cr, pixbuf, x + width - 30 + 5, y + 5);
|
||||
draw_style_common (up_context, cr, x + width - button_width, y, button_width, *height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
gtk_render_icon (up_context, cr, pixbuf, contents_x, contents_y + (contents_height - icon_size) / 2);
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
icon_info = gtk_icon_theme_lookup_icon (icon_theme, "list-remove-symbolic", 20, 0);
|
||||
|
||||
gtk_style_context_get (down_context, gtk_style_context_get_state (down_context),
|
||||
"min-width", &icon_width, "min-height", &icon_height, NULL);
|
||||
icon_size = MIN (icon_width, icon_height);
|
||||
icon_info = gtk_icon_theme_lookup_icon (icon_theme, "list-remove-symbolic", icon_size, 0);
|
||||
pixbuf = gtk_icon_info_load_symbolic_for_context (icon_info, down_context, NULL, NULL);
|
||||
g_object_unref (icon_info);
|
||||
gtk_render_icon (down_context, cr, pixbuf, x + width - 60 + 5, y + 5);
|
||||
draw_style_common (down_context, cr, x + width - 2 * button_width, y, button_width, *height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
gtk_render_icon (down_context, cr, pixbuf, contents_x, contents_y + (contents_height - icon_size) / 2);
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
g_object_unref (down_context);
|
||||
@@ -561,39 +886,64 @@ draw_cb (GtkWidget *widget,
|
||||
cairo_t *cr)
|
||||
{
|
||||
gint panewidth, width, height;
|
||||
gint x, y;
|
||||
|
||||
width = gtk_widget_get_allocated_width (widget);
|
||||
panewidth = width / 2;
|
||||
height = gtk_widget_get_allocated_height (widget);
|
||||
|
||||
cairo_rectangle (cr, 0, 0, width, height);
|
||||
cairo_set_source_rgb (cr, 0.6, 0.6, 0.6);
|
||||
cairo_set_source_rgb (cr, 0.9, 0.9, 0.9);
|
||||
cairo_fill (cr);
|
||||
|
||||
draw_horizontal_scrollbar (widget, cr, 10, 10, panewidth - 20, 12, 30, GTK_STATE_FLAG_NORMAL);
|
||||
draw_horizontal_scrollbar (widget, cr, 10, 30, panewidth - 20, 12, 40, GTK_STATE_FLAG_PRELIGHT);
|
||||
draw_horizontal_scrollbar (widget, cr, 10, 50, panewidth - 20, 12, 50, GTK_STATE_FLAG_ACTIVE|GTK_STATE_FLAG_PRELIGHT);
|
||||
x = y = 10;
|
||||
draw_horizontal_scrollbar (widget, cr, x, y, panewidth - 20, 30, GTK_STATE_FLAG_NORMAL, &height);
|
||||
y += height + 8;
|
||||
draw_horizontal_scrollbar (widget, cr, x, y, panewidth - 20, 40, GTK_STATE_FLAG_PRELIGHT, &height);
|
||||
y += height + 8;
|
||||
draw_horizontal_scrollbar (widget, cr, x, y, panewidth - 20, 50, GTK_STATE_FLAG_ACTIVE|GTK_STATE_FLAG_PRELIGHT, &height);
|
||||
|
||||
draw_text (widget, cr, 10, 70, panewidth - 20, 20, "Not selected", GTK_STATE_FLAG_NORMAL);
|
||||
draw_text (widget, cr, 10, 100, panewidth - 20, 20, "Selected", GTK_STATE_FLAG_SELECTED);
|
||||
y += height + 8;
|
||||
draw_text (widget, cr, x, y, panewidth - 20, 20, "Not selected", GTK_STATE_FLAG_NORMAL);
|
||||
y += 20 + 10;
|
||||
draw_text (widget, cr, x, y, panewidth - 20, 20, "Selected", GTK_STATE_FLAG_SELECTED);
|
||||
|
||||
draw_check (widget, cr, 10, 130, GTK_STATE_FLAG_NORMAL);
|
||||
draw_check (widget, cr, 40, 130, GTK_STATE_FLAG_CHECKED);
|
||||
draw_radio (widget, cr, 70, 130, GTK_STATE_FLAG_NORMAL);
|
||||
draw_radio (widget, cr, 100, 130, GTK_STATE_FLAG_CHECKED);
|
||||
draw_progress (widget, cr, 10, 160, panewidth - 20, 6, 50);
|
||||
x = 10;
|
||||
y += 20 + 10;
|
||||
draw_check (widget, cr, x, y, GTK_STATE_FLAG_NORMAL, &width, &height);
|
||||
x += width + 10;
|
||||
draw_check (widget, cr, x, y, GTK_STATE_FLAG_CHECKED, &width, &height);
|
||||
x += width + 10;
|
||||
draw_radio (widget, cr, x, y, GTK_STATE_FLAG_NORMAL, &width, &height);
|
||||
x += width + 10;
|
||||
draw_radio (widget, cr, x, y, GTK_STATE_FLAG_CHECKED, &width, &height);
|
||||
x = 10;
|
||||
|
||||
draw_menu (widget, cr, 10 + panewidth, 10, panewidth - 20, 90);
|
||||
y += height + 10;
|
||||
draw_progress (widget, cr, x, y, panewidth - 20, 50, &height);
|
||||
|
||||
draw_menubar (widget, cr, 10 + panewidth, 110, panewidth - 20, 20);
|
||||
y += height + 10;
|
||||
draw_scale (widget, cr, x, y, panewidth - 20, 75, &height);
|
||||
|
||||
draw_spinbutton (widget, cr, 10 + panewidth, 140, panewidth - 20);
|
||||
y += height + 20;
|
||||
draw_notebook (widget, cr, x, y, panewidth - 20, 160);
|
||||
|
||||
draw_notebook (widget, cr, 10, 200, panewidth - 20, 160);
|
||||
/* Second column */
|
||||
x += panewidth;
|
||||
y = 10;
|
||||
draw_menu (widget, cr, x, y, panewidth - 20, &height);
|
||||
|
||||
draw_combobox (widget, cr, 10 + panewidth, 200, panewidth - 20, FALSE);
|
||||
y += height + 10;
|
||||
draw_menubar (widget, cr, x, y, panewidth - 20, &height);
|
||||
|
||||
draw_combobox (widget, cr, 10 + panewidth, 240, panewidth - 20, TRUE);
|
||||
y += height + 20;
|
||||
draw_spinbutton (widget, cr, x, y, panewidth - 20, &height);
|
||||
|
||||
y += height + 30;
|
||||
draw_combobox (widget, cr, x, y, panewidth - 20, FALSE, &height);
|
||||
|
||||
y += height + 10;
|
||||
draw_combobox (widget, cr, 10 + panewidth, y, panewidth - 20, TRUE, &height);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
+67
-4
@@ -8,6 +8,34 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static GtkWidget *stack;
|
||||
static GtkWidget *view;
|
||||
static GtkWidget *view2;
|
||||
|
||||
static void
|
||||
source_toggled (GtkToggleButton *button)
|
||||
{
|
||||
if (gtk_toggle_button_get_active (button))
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (stack), "source");
|
||||
else
|
||||
{
|
||||
GtkTextBuffer *buffer;
|
||||
GtkTextIter start, end;
|
||||
gchar *markup;
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view2));
|
||||
gtk_text_buffer_get_bounds (buffer, &start, &end);
|
||||
markup = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
gtk_text_buffer_get_start_iter (buffer, &start);
|
||||
gtk_text_buffer_insert_markup (buffer, &start, markup, -1);
|
||||
g_free (markup);
|
||||
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (stack), "formatted");
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_markup (GtkWidget *do_widget)
|
||||
{
|
||||
@@ -15,12 +43,13 @@ do_markup (GtkWidget *do_widget)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkWidget *view;
|
||||
GtkWidget *sw;
|
||||
GtkTextBuffer *buffer;
|
||||
GtkTextIter iter;
|
||||
GBytes *bytes;
|
||||
const gchar *markup;
|
||||
GtkWidget *header;
|
||||
GtkWidget *show_source;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
@@ -29,19 +58,49 @@ do_markup (GtkWidget *do_widget)
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
||||
stack = gtk_stack_new ();
|
||||
gtk_widget_show (stack);
|
||||
gtk_container_add (GTK_CONTAINER (window), stack);
|
||||
|
||||
show_source = gtk_check_button_new_with_label ("Source");
|
||||
gtk_widget_set_valign (show_source, GTK_ALIGN_CENTER);
|
||||
g_signal_connect (show_source, "toggled", G_CALLBACK (source_toggled), stack);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), show_source);
|
||||
gtk_widget_show_all (header);
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Markup");
|
||||
|
||||
view = gtk_text_view_new ();
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
|
||||
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 10);
|
||||
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 10);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_NEVER,
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_container_add (GTK_CONTAINER (window), sw);
|
||||
gtk_container_add (GTK_CONTAINER (sw), view);
|
||||
gtk_widget_show_all (sw);
|
||||
|
||||
gtk_stack_add_named (GTK_STACK (stack), sw, "formatted");
|
||||
|
||||
view2 = gtk_text_view_new ();
|
||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view2), GTK_WRAP_WORD);
|
||||
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view2), 10);
|
||||
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view2), 10);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_container_add (GTK_CONTAINER (sw), view2);
|
||||
gtk_widget_show_all (sw);
|
||||
|
||||
gtk_stack_add_named (GTK_STACK (stack), sw, "source");
|
||||
|
||||
bytes = g_resources_lookup_data ("/markup/markup.txt", 0, NULL);
|
||||
markup = (const gchar *)g_bytes_get_data (bytes, NULL);
|
||||
@@ -50,9 +109,13 @@ do_markup (GtkWidget *do_widget)
|
||||
gtk_text_buffer_get_start_iter (buffer, &iter);
|
||||
gtk_text_buffer_insert_markup (buffer, &iter, markup, -1);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view2));
|
||||
gtk_text_buffer_get_start_iter (buffer, &iter);
|
||||
gtk_text_buffer_insert (buffer, &iter, markup, -1);
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
gtk_widget_show_all (sw);
|
||||
gtk_widget_show (stack);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
Text sizes: <span size="xx-small">tiny</span> <span size="x-small">very small</span> <span size="small">small</span> <span size="medium">normal</span> <span size="large">large</span> <span size="x-large">very large</span> <span size="xx-large">huge</span>
|
||||
|
||||
Text <span color="gray">c<span color="green">o</span>l<span color="tomato">o</span>rs</span>
|
||||
Text <span color="gray">c<span color="green">o</span>l<span color="tomato">o</span>rs</span> and <span background="pink">backgrounds</span>
|
||||
|
||||
Colorful <span underline="low" underline-color="blue"><span underline="double" underline-color="red">under</span>lines</span>
|
||||
Colorful <span underline="low" underline-color="blue"><span underline="double" underline-color="red">under</span>lines</span> and <span background="pink"><span underline="error">mo</span><span underline="error" underline-color="green">re</span></span>
|
||||
|
||||
Colorful <span strikethrough="true" strikethrough-color="magenta">strikethroughs</span>
|
||||
|
||||
|
||||
@@ -345,7 +345,7 @@ gtk_mirror_bin_get_preferred_height (GtkWidget *widget,
|
||||
|
||||
gtk_mirror_bin_size_request (widget, &requisition);
|
||||
|
||||
*minimum = *natural = requisition.width;
|
||||
*minimum = *natural = requisition.height;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -26,12 +26,27 @@ IGNORE_HFILES= \
|
||||
gdkkeysyms.h \
|
||||
gdkinternals.h \
|
||||
gdkprivate.h \
|
||||
gdk*private.h \
|
||||
gdk-private.h \
|
||||
gdkapplaunchcontextprivate.h \
|
||||
gdkcursorprivate.h \
|
||||
gdkdevicemanagerprivate.h \
|
||||
gdkdeviceprivate.h \
|
||||
gdkdisplaymanagerprivate.h \
|
||||
gdkdisplayprivate.h \
|
||||
gdkdndprivate.h \
|
||||
gdkframeclockprivate.h \
|
||||
gdkglcontextprivate.h \
|
||||
gdkkeysprivate.h \
|
||||
gdkscreenprivate.h \
|
||||
gdkseatdefaultprivate.h \
|
||||
gdkseatprivate.h \
|
||||
gdkvisualprivate.h \
|
||||
keyname-table.h \
|
||||
wayland/xdg-shell-client-protocol.h \
|
||||
win32 \
|
||||
x11 \
|
||||
quartz
|
||||
quartz \
|
||||
broadway \
|
||||
wayland
|
||||
|
||||
# Extra files to add when scanning
|
||||
EXTRA_HFILES= \
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -1005,6 +1005,7 @@ gdk_drag_context_get_dest_window
|
||||
gdk_drag_context_get_protocol
|
||||
gdk_drag_context_get_drag_window
|
||||
gdk_drag_context_set_hotspot
|
||||
gdk_drag_context_manage_dnd
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GDK_DRAG_CONTEXT
|
||||
@@ -1343,6 +1344,7 @@ gdk_gl_context_set_debug_enabled
|
||||
gdk_gl_context_get_debug_enabled
|
||||
gdk_gl_context_set_forward_compatible
|
||||
gdk_gl_context_get_forward_compatible
|
||||
gdk_gl_context_is_legacy
|
||||
|
||||
<SUBSECTION>
|
||||
GdkGLError
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -577,14 +577,14 @@ parse_input (BroadwayInput *input)
|
||||
is_mask = buf[1] & 0x80;
|
||||
data = buf + 2;
|
||||
|
||||
if (payload_len > 125)
|
||||
if (payload_len == 126)
|
||||
{
|
||||
if (len < 4)
|
||||
return;
|
||||
payload_len = GUINT16_FROM_BE( *(guint16 *) data );
|
||||
data += 2;
|
||||
}
|
||||
else if (payload_len > 126)
|
||||
else if (payload_len == 127)
|
||||
{
|
||||
if (len < 10)
|
||||
return;
|
||||
|
||||
@@ -1611,7 +1611,6 @@ gdk_window_impl_broadway_class_init (GdkWindowImplBroadwayClass *klass)
|
||||
impl_class->set_decorations = gdk_broadway_window_set_decorations;
|
||||
impl_class->get_decorations = gdk_broadway_window_get_decorations;
|
||||
impl_class->set_functions = gdk_broadway_window_set_functions;
|
||||
impl_class->set_functions = gdk_broadway_window_set_functions;
|
||||
impl_class->begin_resize_drag = gdk_broadway_window_begin_resize_drag;
|
||||
impl_class->begin_move_drag = gdk_broadway_window_begin_move_drag;
|
||||
impl_class->set_opacity = gdk_broadway_window_set_opacity;
|
||||
|
||||
@@ -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,
|
||||
|
||||
+3
-2
@@ -686,6 +686,8 @@ gdk_drag_drop_done (GdkDragContext *context,
|
||||
* cancelled through other means.
|
||||
*
|
||||
* Returns: #TRUE if the drag and drop operation is managed.
|
||||
*
|
||||
* Since: 3.20
|
||||
**/
|
||||
gboolean
|
||||
gdk_drag_context_manage_dnd (GdkDragContext *context,
|
||||
@@ -696,8 +698,7 @@ gdk_drag_context_manage_dnd (GdkDragContext *context,
|
||||
g_return_val_if_fail (GDK_IS_WINDOW (ipc_window), FALSE);
|
||||
|
||||
if (GDK_DRAG_CONTEXT_GET_CLASS (context)->manage_dnd)
|
||||
return GDK_DRAG_CONTEXT_GET_CLASS (context)->manage_dnd (context, ipc_window,
|
||||
actions);
|
||||
return GDK_DRAG_CONTEXT_GET_CLASS (context)->manage_dnd (context, ipc_window, actions);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
+12
-13
@@ -33,7 +33,7 @@
|
||||
* @See_also: #GdkDisplay, #GdkDevice
|
||||
*
|
||||
* The #GdkSeat object represents a collection of input devices
|
||||
* that belong to an user.
|
||||
* that belong to a user.
|
||||
*/
|
||||
|
||||
typedef struct _GdkSeatPrivate GdkSeatPrivate;
|
||||
@@ -208,8 +208,9 @@ gdk_seat_get_capabilities (GdkSeat *seat)
|
||||
* elsewhere.
|
||||
* @event: (nullable): the event that is triggering the grab, or %NULL if none
|
||||
* is available.
|
||||
* @prepare_func: (nullable) (scope call) (closure prepare_func_data): function to prepare the window to be
|
||||
* grabbed, it can be %NULL if @window is visible before this call.
|
||||
* @prepare_func: (nullable) (scope call) (closure prepare_func_data): function to
|
||||
* prepare the window to be grabbed, it can be %NULL if @window is
|
||||
* visible before this call.
|
||||
* @prepare_func_data: user data to pass to @prepare_func
|
||||
*
|
||||
* Grabs the seat so that all events corresponding to the given @capabilities
|
||||
@@ -230,8 +231,8 @@ gdk_seat_get_capabilities (GdkSeat *seat)
|
||||
* Note that if the event mask of a #GdkWindow has selected both button press
|
||||
* and button release events, or touch begin and touch end, then a press event
|
||||
* will cause an automatic grab until the button is released, equivalent to a
|
||||
* grab on the window with @owner_events set to %TRUE. This performed as most
|
||||
* applications expect to receive presses and releases in pairs.
|
||||
* grab on the window with @owner_events set to %TRUE. This is done because most
|
||||
* applications expect to receive paired press and release events.
|
||||
*
|
||||
* If you set up anything at the time you take the grab that needs to be
|
||||
* cleaned up when the grab ends, you should handle the #GdkEventGrabBroken
|
||||
@@ -291,8 +292,8 @@ gdk_seat_ungrab (GdkSeat *seat)
|
||||
*
|
||||
* Returns the slave devices that match the given capabilities.
|
||||
*
|
||||
* Returns: (transfer container) (element-type GdkDevice): A list of #GdkDevices. The list
|
||||
* must be freed with g_list_free(), the elements are owned
|
||||
* Returns: (transfer container) (element-type GdkDevice): A list of #GdkDevices.
|
||||
* The list must be freed with g_list_free(), the elements are owned
|
||||
* by GDK and must not be freed.
|
||||
*
|
||||
* Since: 3.20
|
||||
@@ -316,8 +317,7 @@ gdk_seat_get_slaves (GdkSeat *seat,
|
||||
* Returns the master device that routes pointer events.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): a master #GdkDevice with pointer
|
||||
* capabilities. This object is owned by GTK+ and must not be
|
||||
* freed.
|
||||
* capabilities. This object is owned by GTK+ and must not be freed.
|
||||
*
|
||||
* Since: 3.20
|
||||
**/
|
||||
@@ -339,8 +339,7 @@ gdk_seat_get_pointer (GdkSeat *seat)
|
||||
* Returns the master device that routes keyboard events.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): a master #GdkDevice with keyboard
|
||||
* capabilities. This object is owned by GTK+ and must not be
|
||||
* freed.
|
||||
* capabilities. This object is owned by GTK+ and must not be freed.
|
||||
*
|
||||
* Since: 3.20
|
||||
**/
|
||||
@@ -377,8 +376,8 @@ gdk_seat_device_removed (GdkSeat *seat,
|
||||
*
|
||||
* Returns the #GdkDisplay this seat belongs to.
|
||||
*
|
||||
* Returns: (transfer none): a #GdkDisplay. This memory is owned by GTK+ and
|
||||
* must not be freed.
|
||||
* Returns: (transfer none): a #GdkDisplay. This object is owned by GTK+
|
||||
* and must not be freed.
|
||||
**/
|
||||
GdkDisplay *
|
||||
gdk_seat_get_display (GdkSeat *seat)
|
||||
|
||||
@@ -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
@@ -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
@@ -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
@@ -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))
|
||||
|
||||
@@ -921,6 +921,9 @@ fill_pinch_event (GdkWindow *window,
|
||||
FP_STATE_IDLE,
|
||||
FP_STATE_UPDATE
|
||||
} last_state = FP_STATE_IDLE;
|
||||
GdkQuartzDeviceManagerCore *device_manager;
|
||||
|
||||
device_manager = GDK_QUARTZ_DEVICE_MANAGER_CORE (_gdk_display->device_manager);
|
||||
|
||||
event->any.type = GDK_TOUCHPAD_PINCH;
|
||||
event->touchpad_pinch.window = window;
|
||||
@@ -933,7 +936,7 @@ fill_pinch_event (GdkWindow *window,
|
||||
event->touchpad_pinch.n_fingers = 2;
|
||||
event->touchpad_pinch.dx = 0.0;
|
||||
event->touchpad_pinch.dy = 0.0;
|
||||
gdk_event_set_device (event, _gdk_display->core_pointer);
|
||||
gdk_event_set_device (event, device_manager->core_pointer);
|
||||
|
||||
switch ([nsevent phase])
|
||||
{
|
||||
|
||||
@@ -121,6 +121,7 @@ gdk_window_impl_quartz_get_context (GdkWindowImplQuartz *window_impl,
|
||||
gboolean antialias)
|
||||
{
|
||||
CGContextRef cg_context;
|
||||
CGSize scale;
|
||||
|
||||
if (GDK_WINDOW_DESTROYED (window_impl->wrapper))
|
||||
return NULL;
|
||||
@@ -141,6 +142,12 @@ gdk_window_impl_quartz_get_context (GdkWindowImplQuartz *window_impl,
|
||||
CGContextSaveGState (cg_context);
|
||||
CGContextSetAllowsAntialiasing (cg_context, antialias);
|
||||
|
||||
/* Undo the default scaling transform, since we apply our own
|
||||
* in gdk_quartz_ref_cairo_surface () */
|
||||
scale = CGContextConvertSizeToDeviceSpace (cg_context,
|
||||
CGSizeMake (1.0, 1.0));
|
||||
CGContextScaleCTM (cg_context, 1.0 / scale.width, 1.0 / scale.height);
|
||||
|
||||
return cg_context;
|
||||
}
|
||||
|
||||
@@ -317,10 +324,14 @@ gdk_quartz_ref_cairo_surface (GdkWindow *window)
|
||||
|
||||
if (!impl->cairo_surface)
|
||||
{
|
||||
gint scale = gdk_window_get_scale_factor (impl->wrapper);
|
||||
|
||||
impl->cairo_surface =
|
||||
gdk_quartz_create_cairo_surface (impl,
|
||||
gdk_window_get_width (impl->wrapper),
|
||||
gdk_window_get_height (impl->wrapper));
|
||||
gdk_window_get_width (impl->wrapper) * scale,
|
||||
gdk_window_get_height (impl->wrapper) * scale);
|
||||
|
||||
cairo_surface_set_device_scale (impl->cairo_surface, scale, scale);
|
||||
}
|
||||
else
|
||||
cairo_surface_reference (impl->cairo_surface);
|
||||
|
||||
+588
-570
File diff suppressed because it is too large
Load Diff
@@ -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)
|
||||
{
|
||||
|
||||
@@ -445,6 +445,19 @@ gdk_wayland_drag_context_cancel (GdkDragContext *context,
|
||||
gdk_drag_context_set_cursor (context, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_context_drop_done (GdkDragContext *context,
|
||||
gboolean success)
|
||||
{
|
||||
GdkWaylandDragContext *context_wayland = GDK_WAYLAND_DRAG_CONTEXT (context);
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (context_wayland->dnd_window)
|
||||
gdk_window_hide (context_wayland->dnd_window);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_context_class_init (GdkWaylandDragContextClass *klass)
|
||||
{
|
||||
@@ -464,6 +477,7 @@ gdk_wayland_drag_context_class_init (GdkWaylandDragContextClass *klass)
|
||||
context_class->get_selection = gdk_wayland_drag_context_get_selection;
|
||||
context_class->get_drag_window = gdk_wayland_drag_context_get_drag_window;
|
||||
context_class->set_hotspot = gdk_wayland_drag_context_set_hotspot;
|
||||
context_class->drop_done = gdk_wayland_drag_context_drop_done;
|
||||
context_class->manage_dnd = gdk_wayland_drag_context_manage_dnd;
|
||||
context_class->set_cursor = gdk_wayland_drag_context_set_cursor;
|
||||
context_class->action_changed = gdk_wayland_drag_context_action_changed;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#define GDK_IS_WAYLAND_SEAT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_WAYLAND_SEAT))
|
||||
#define GDK_WAYLAND_SEAT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_WAYLAND_SEAT, GdkWaylandSeatClass))
|
||||
|
||||
typedef struct _GdkWaylandSeat GdkWaylandDeviceData;
|
||||
typedef struct _GdkWaylandSeat GdkWaylandSeat;
|
||||
typedef struct _GdkWaylandSeatClass GdkWaylandSeatClass;
|
||||
|
||||
|
||||
@@ -256,6 +256,11 @@ gdk_wayland_window_update_size (GdkWindow *window,
|
||||
GdkRectangle area;
|
||||
cairo_region_t *region;
|
||||
|
||||
if ((window->width == width) &&
|
||||
(window->height == height) &&
|
||||
(impl->scale == scale))
|
||||
return;
|
||||
|
||||
drop_cairo_surfaces (window);
|
||||
|
||||
window->width = width;
|
||||
|
||||
@@ -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
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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++)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
+1814
-24
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
|
||||
@@ -2616,7 +2616,10 @@ gdk_x11_drag_context_drop_done (GdkDragContext *context,
|
||||
cairo_t *cr;
|
||||
|
||||
if (success)
|
||||
return;
|
||||
{
|
||||
gdk_window_hide (x11_context->drag_window);
|
||||
return;
|
||||
}
|
||||
|
||||
win_surface = _gdk_window_ref_cairo_surface (x11_context->drag_window);
|
||||
surface = gdk_window_create_similar_surface (x11_context->drag_window,
|
||||
|
||||
@@ -738,8 +738,7 @@ gdk_x11_display_utf8_to_compound_text (GdkDisplay *display,
|
||||
|
||||
if (!locale_str)
|
||||
{
|
||||
if (!(error->domain = G_CONVERT_ERROR &&
|
||||
error->code == G_CONVERT_ERROR_ILLEGAL_SEQUENCE))
|
||||
if (!g_error_matches (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE))
|
||||
{
|
||||
g_warning ("Error converting from UTF-8 to '%s': %s",
|
||||
charset, error->message);
|
||||
|
||||
@@ -4510,7 +4510,7 @@ gdk_x11_window_get_decorations(GdkWindow *window,
|
||||
|
||||
static void
|
||||
gdk_x11_window_set_functions (GdkWindow *window,
|
||||
GdkWMFunction functions)
|
||||
GdkWMFunction functions)
|
||||
{
|
||||
MotifWmHints hints;
|
||||
|
||||
@@ -5764,7 +5764,6 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
|
||||
impl_class->set_decorations = gdk_x11_window_set_decorations;
|
||||
impl_class->get_decorations = gdk_x11_window_get_decorations;
|
||||
impl_class->set_functions = gdk_x11_window_set_functions;
|
||||
impl_class->set_functions = gdk_x11_window_set_functions;
|
||||
impl_class->begin_resize_drag = gdk_x11_window_begin_resize_drag;
|
||||
impl_class->begin_move_drag = gdk_x11_window_begin_move_drag;
|
||||
impl_class->set_opacity = gdk_x11_window_set_opacity;
|
||||
|
||||
+15
-1
@@ -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 \
|
||||
@@ -1249,6 +1255,14 @@ gtk.gresource.xml: Makefile.am inspector/Makefile.inc
|
||||
echo " <file alias='theme/HighContrastInverse/gtk.css'>theme/HighContrast/gtk-inverse.css</file>" >> $@; \
|
||||
echo " <file>theme/HighContrast/gtk-contained.css</file>" >> $@; \
|
||||
echo " <file>theme/HighContrast/gtk-contained-inverse.css</file>" >> $@; \
|
||||
for f in $(srcdir)/theme/HighContrast/assets/*.png; do \
|
||||
n=`basename $$f`; \
|
||||
echo " <file preprocess='to-pixdata'>theme/HighContrast/assets/$$n</file>" >> $@; \
|
||||
done; \
|
||||
for f in $(srcdir)/theme/HighContrast/assets/*.svg; do \
|
||||
n=`basename $$f`; \
|
||||
echo " <file>theme/HighContrast/assets/$$n</file>" >> $@; \
|
||||
done; \
|
||||
echo " <file>theme/win32/gtk-win32-base.css</file>" >> $@; \
|
||||
echo " <file>theme/win32/gtk.css</file>" >> $@; \
|
||||
for f in $(srcdir)/cursor/*.png; do \
|
||||
@@ -1499,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 \
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -881,7 +881,7 @@ gtk_style_properties_merge (GtkStyleProperties *props,
|
||||
{
|
||||
PropertyData *prop_to_merge = val;
|
||||
PropertyData *prop;
|
||||
guint i;
|
||||
guint i, j;
|
||||
|
||||
prop = g_hash_table_lookup (priv->properties, key);
|
||||
|
||||
@@ -932,8 +932,8 @@ gtk_style_properties_merge (GtkStyleProperties *props,
|
||||
array = g_value_get_boxed (_gtk_css_typed_value_get (value->value));
|
||||
array_to_merge = g_value_get_boxed (_gtk_css_typed_value_get (data->value));
|
||||
|
||||
for (i = 0; i < array_to_merge->len; i++)
|
||||
g_ptr_array_add (array, g_ptr_array_index (array_to_merge, i));
|
||||
for (j = 0; j < array_to_merge->len; j++)
|
||||
g_ptr_array_add (array, g_ptr_array_index (array_to_merge, j));
|
||||
}
|
||||
else if (replace || value->value == NULL)
|
||||
{
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
+2
-1
@@ -73,6 +73,7 @@
|
||||
|
||||
#include "gtkcalendar.h"
|
||||
#include "gtkdnd.h"
|
||||
#include "gtkdragdest.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkmarshalers.h"
|
||||
@@ -397,7 +398,7 @@ gtk_calendar_class_init (GtkCalendarClass *class)
|
||||
P_("Year"),
|
||||
P_("The selected year"),
|
||||
0, G_MAXINT >> 9, 0,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY|G_PARAM_EXPLICIT_NOTIFY));
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
||||
|
||||
/**
|
||||
* GtkCalendar:month:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
+46
-20
@@ -61,12 +61,15 @@
|
||||
* gtk_style_context_add_provider_for_screen().
|
||||
|
||||
* In addition, certain files will be read when GTK+ is initialized. First, the
|
||||
* file $XDG_CONFIG_HOME/gtk-3.0/gtk.css` is loaded if it exists. Then, GTK+ tries
|
||||
* to load `$HOME/.themes/theme-name/gtk-3.0/gtk.css`, falling back to
|
||||
* file $XDG_CONFIG_HOME/gtk-3.0/gtk.css` is loaded if it exists. Then, GTK+
|
||||
* loads the first existing file among
|
||||
* `XDG_DATA_HOME/themes/theme-name/gtk-VERSION/gtk.css`,
|
||||
* `$HOME/.themes/theme-name/gtk-VERSION/gtk.css`,
|
||||
* `$XDG_DATA_DIRS/themes/theme-name/gtk-VERSION/gtk.css` and
|
||||
* `DATADIR/share/themes/THEME/gtk-VERSION/gtk.css`, where THEME is the name of
|
||||
* the current theme (see the #GtkSettings:gtk-theme-name setting), DATADIR
|
||||
* is the prefix configured when GTK+ was compiled, unless overridden by the
|
||||
* `GTK_DATA_PREFIX` environment variable, and VERSION is the GTK+ version number.
|
||||
* is the prefix configured when GTK+ was compiled (unless overridden by the
|
||||
* `GTK_DATA_PREFIX` environment variable), and VERSION is the GTK+ version number.
|
||||
* If no file is found for the current version, GTK+ tries older versions all the
|
||||
* way back to 3.0.
|
||||
*
|
||||
@@ -127,6 +130,7 @@ struct _GtkCssProviderPrivate
|
||||
GArray *rulesets;
|
||||
GtkCssSelectorTree *tree;
|
||||
GResource *resource;
|
||||
gchar *path;
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -824,6 +828,8 @@ gtk_css_provider_finalize (GObject *object)
|
||||
priv->resource = NULL;
|
||||
}
|
||||
|
||||
g_free (priv->path);
|
||||
|
||||
G_OBJECT_CLASS (gtk_css_provider_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
@@ -901,7 +907,7 @@ gtk_css_provider_invalid_token (GtkCssProvider *provider,
|
||||
"expected %s", expected);
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
css_provider_commit (GtkCssProvider *css_provider,
|
||||
GSList *selectors,
|
||||
GtkCssRuleset *ruleset)
|
||||
@@ -944,6 +950,12 @@ gtk_css_provider_reset (GtkCssProvider *css_provider)
|
||||
priv->resource = NULL;
|
||||
}
|
||||
|
||||
if (priv->path)
|
||||
{
|
||||
g_free (priv->path);
|
||||
priv->path = NULL;
|
||||
}
|
||||
|
||||
g_hash_table_remove_all (priv->symbolic_colors);
|
||||
g_hash_table_remove_all (priv->keyframes);
|
||||
|
||||
@@ -1973,18 +1985,23 @@ gtk_css_provider_get_default (void)
|
||||
}
|
||||
|
||||
gchar *
|
||||
_gtk_css_provider_get_theme_dir (void)
|
||||
_gtk_get_theme_dir (void)
|
||||
{
|
||||
const gchar *var;
|
||||
gchar *path;
|
||||
|
||||
var = g_getenv ("GTK_DATA_PREFIX");
|
||||
if (var)
|
||||
path = g_build_filename (var, "share", "themes", NULL);
|
||||
else
|
||||
path = g_build_filename (_gtk_get_data_prefix (), "share", "themes", NULL);
|
||||
if (var == NULL)
|
||||
var = _gtk_get_data_prefix ();
|
||||
return g_build_filename (var, "share", "themes", NULL);
|
||||
}
|
||||
|
||||
return path;
|
||||
/* Return the path that this providers gtk.css was loaded from,
|
||||
* if it is part of a theme, otherwise NULL.
|
||||
*/
|
||||
const gchar *
|
||||
_gtk_css_provider_get_theme_dir (GtkCssProvider *provider)
|
||||
{
|
||||
return provider->priv->path;
|
||||
}
|
||||
|
||||
#if (GTK_MINOR_VERSION % 2)
|
||||
@@ -2055,9 +2072,11 @@ _gtk_css_find_theme (const gchar *name,
|
||||
const gchar *variant)
|
||||
{
|
||||
gchar *path;
|
||||
const gchar *var;
|
||||
const char *const *dirs;
|
||||
int i;
|
||||
char *dir;
|
||||
|
||||
/* First look in the user's config directory */
|
||||
/* First look in the user's data directory */
|
||||
path = _gtk_css_find_theme_dir (g_get_user_data_dir (), "themes", name, variant);
|
||||
if (path)
|
||||
return path;
|
||||
@@ -2067,12 +2086,19 @@ _gtk_css_find_theme (const gchar *name,
|
||||
if (path)
|
||||
return path;
|
||||
|
||||
/* Finally, try in the default theme directory */
|
||||
var = g_getenv ("GTK_DATA_PREFIX");
|
||||
if (!var)
|
||||
var = _gtk_get_data_prefix ();
|
||||
/* Look in system data directories */
|
||||
dirs = g_get_system_data_dirs ();
|
||||
for (i = 0; dirs[i]; i++)
|
||||
{
|
||||
path = _gtk_css_find_theme_dir (dirs[i], "themes", name, variant);
|
||||
if (path)
|
||||
return path;
|
||||
}
|
||||
|
||||
path = _gtk_css_find_theme_dir (var, "share" G_DIR_SEPARATOR_S "themes", name, variant);
|
||||
/* Finally, try in the default theme directory */
|
||||
dir = _gtk_get_theme_dir ();
|
||||
path = _gtk_css_find_theme_dir (dir, NULL, name, variant);
|
||||
g_free (dir);
|
||||
|
||||
return path;
|
||||
}
|
||||
@@ -2137,9 +2163,9 @@ _gtk_css_provider_load_named (GtkCssProvider *provider,
|
||||
|
||||
/* Only set this after load, as load_from_path will clear it */
|
||||
provider->priv->resource = resource;
|
||||
provider->priv->path = dir;
|
||||
|
||||
g_free (path);
|
||||
g_free (dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gchar *_gtk_css_provider_get_theme_dir (void);
|
||||
gchar *_gtk_get_theme_dir (void);
|
||||
|
||||
const gchar *_gtk_css_provider_get_theme_dir (GtkCssProvider *provider);
|
||||
|
||||
void _gtk_css_provider_load_named (GtkCssProvider *provider,
|
||||
const gchar *name,
|
||||
|
||||
@@ -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
@@ -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;
|
||||
|
||||
|
||||
@@ -682,7 +682,7 @@ draw_shadow_corner (const GtkCssValue *shadow,
|
||||
x2 = ceil (box->box.x + box->corner[corner].horizontal + clip_radius);
|
||||
x = x1;
|
||||
sx = 1;
|
||||
max_other = MAX(box->corner[GTK_CSS_TOP_RIGHT].horizontal, box->corner[GTK_CSS_TOP_RIGHT].horizontal);
|
||||
max_other = MAX(box->corner[GTK_CSS_TOP_RIGHT].horizontal, box->corner[GTK_CSS_BOTTOM_RIGHT].horizontal);
|
||||
x3 = floor (box->box.x + box->box.width - max_other - clip_radius);
|
||||
if (x2 > x3)
|
||||
overlapped = TRUE;
|
||||
@@ -693,7 +693,7 @@ draw_shadow_corner (const GtkCssValue *shadow,
|
||||
x2 = ceil (box->box.x + box->box.width + clip_radius);
|
||||
x = x2;
|
||||
sx = -1;
|
||||
max_other = MAX(box->corner[GTK_CSS_TOP_LEFT].horizontal, box->corner[GTK_CSS_TOP_LEFT].horizontal);
|
||||
max_other = MAX(box->corner[GTK_CSS_TOP_LEFT].horizontal, box->corner[GTK_CSS_BOTTOM_LEFT].horizontal);
|
||||
x3 = ceil (box->box.x + max_other + clip_radius);
|
||||
if (x3 > x1)
|
||||
overlapped = TRUE;
|
||||
|
||||
+48
-28
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
+2
-46
@@ -337,42 +337,6 @@ gtk_drag_get_source_widget (GdkDragContext *context)
|
||||
return info->source_widget;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* gtk_drag_highlight_draw:
|
||||
* Callback for expose_event for highlighted widgets.
|
||||
* arguments:
|
||||
* widget:
|
||||
* event:
|
||||
* data:
|
||||
* results:
|
||||
*************************************************************/
|
||||
|
||||
static gboolean
|
||||
gtk_drag_highlight_draw (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gpointer data)
|
||||
{
|
||||
int width = gtk_widget_get_allocated_width (widget);
|
||||
int height = gtk_widget_get_allocated_height (widget);
|
||||
GtkStyleContext *context = gtk_widget_get_style_context (widget);
|
||||
|
||||
gtk_style_context_save (context);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_DND);
|
||||
|
||||
gtk_render_frame (context, cr, 0, 0, width, height);
|
||||
|
||||
gtk_style_context_restore (context);
|
||||
|
||||
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); /* black */
|
||||
cairo_set_line_width (cr, 1.0);
|
||||
cairo_rectangle (cr,
|
||||
0.5, 0.5,
|
||||
width - 1, height - 1);
|
||||
cairo_stroke (cr);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_drag_highlight: (method)
|
||||
* @widget: a widget to highlight
|
||||
@@ -382,11 +346,7 @@ gtk_drag_highlight (GtkWidget *widget)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
g_signal_connect_after (widget, "draw",
|
||||
G_CALLBACK (gtk_drag_highlight_draw),
|
||||
NULL);
|
||||
|
||||
gtk_widget_queue_draw (widget);
|
||||
gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_DROP_ACTIVE, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -398,11 +358,7 @@ gtk_drag_unhighlight (GtkWidget *widget)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
g_signal_handlers_disconnect_by_func (widget,
|
||||
gtk_drag_highlight_draw,
|
||||
NULL);
|
||||
|
||||
gtk_widget_queue_draw (widget);
|
||||
gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_DROP_ACTIVE);
|
||||
}
|
||||
|
||||
static NSWindow *
|
||||
|
||||
+3
-492
@@ -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 widget’s 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 widget’s #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.
|
||||
*
|
||||
* There’s no way to set a default action here, you can use the
|
||||
* #GtkWidget::drag-motion callback for that. Here’s 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 that’s 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 that’s 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 that’s 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 that’s 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 that’s 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 that’s 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,
|
||||
|
||||
@@ -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 widget’s 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 widget’s 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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 widget’s 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 widget’s #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.
|
||||
*
|
||||
* There’s no way to set a default action here, you can use the
|
||||
* #GtkWidget::drag-motion callback for that. Here’s 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 that’s 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 that’s 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 that’s 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 that’s 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 that’s 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 that’s 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;
|
||||
}
|
||||
|
||||
@@ -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 widget’s 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 widget’s 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
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
@@ -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, ¢er_min, ¢er_nat))
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
add_child_size (priv->label_box, orientation, ¢er_min, ¢er_nat);
|
||||
else
|
||||
add_child_size (priv->label_sizing_box, orientation, ¢er_min, ¢er_nat);
|
||||
|
||||
if (_gtk_widget_get_visible (priv->label_sizing_box))
|
||||
nvis_children += 1;
|
||||
}
|
||||
|
||||
|
||||
+16
-1
@@ -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
@@ -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
@@ -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
|
||||
|
||||
+13
-1
@@ -3011,7 +3011,19 @@ gtk_menu_draw (GtkWidget *widget,
|
||||
gtk_css_gadget_draw (priv->bottom_arrow_gadget, cr);
|
||||
}
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_menu_parent_class)->draw (widget, cr);
|
||||
if (gtk_cairo_should_draw_window (cr, priv->bin_window))
|
||||
{
|
||||
int x, y;
|
||||
|
||||
gdk_window_get_position (priv->view_window, &x, &y);
|
||||
cairo_rectangle (cr,
|
||||
x, y,
|
||||
gdk_window_get_width (priv->view_window),
|
||||
gdk_window_get_height (priv->view_window));
|
||||
cairo_clip (cr);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_menu_parent_class)->draw (widget, cr);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
+1
-2
@@ -272,8 +272,7 @@ gtk_menu_bar_class_init (GtkMenuBarClass *class)
|
||||
0,
|
||||
G_MAXINT,
|
||||
0,
|
||||
GTK_PARAM_READABLE |
|
||||
G_PARAM_DEPRECATED|G_PARAM_DEPRECATED));
|
||||
GTK_PARAM_READABLE|G_PARAM_DEPRECATED));
|
||||
|
||||
gtk_container_class_handle_border_width (container_class);
|
||||
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_MENU_BAR);
|
||||
|
||||
+4
-7
@@ -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);
|
||||
|
||||
+4
-4
@@ -1618,16 +1618,16 @@ gtk_path_bar_set_file_finish (struct SetFileInfo *info,
|
||||
gtk_path_bar_clear_buttons (info->path_bar);
|
||||
info->path_bar->priv->button_list = g_list_reverse (info->new_buttons);
|
||||
info->path_bar->priv->fake_root = info->fake_root;
|
||||
prev = gtk_widget_get_css_node (info->path_bar->priv->up_slider_button);
|
||||
prev = gtk_widget_get_css_node (info->path_bar->priv->down_slider_button);
|
||||
|
||||
for (l = info->path_bar->priv->button_list; l; l = l->next)
|
||||
{
|
||||
GtkWidget *button = BUTTON_DATA (l->data)->button;
|
||||
GtkCssNode *node = gtk_widget_get_css_node (button);
|
||||
|
||||
gtk_css_node_insert_after (gtk_widget_get_css_node (GTK_WIDGET (info->path_bar)),
|
||||
node,
|
||||
prev);
|
||||
gtk_css_node_insert_before (gtk_widget_get_css_node (GTK_WIDGET (info->path_bar)),
|
||||
node,
|
||||
prev);
|
||||
gtk_container_add (GTK_CONTAINER (info->path_bar), button);
|
||||
prev = node;
|
||||
}
|
||||
|
||||
@@ -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
-2
@@ -705,8 +705,7 @@ add_volume (GtkPlacesView *view,
|
||||
name = g_volume_get_name (volume);
|
||||
path = !is_network ? g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE) : NULL;
|
||||
|
||||
if (!mount ||
|
||||
(mount && !g_mount_is_shadowed (mount)))
|
||||
if (!mount || !g_mount_is_shadowed (mount))
|
||||
{
|
||||
GtkWidget *row;
|
||||
|
||||
|
||||
@@ -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
@@ -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);
|
||||
|
||||
@@ -3283,9 +3283,10 @@ gtk_print_operation_run (GtkPrintOperation *op,
|
||||
if (run_print_pages)
|
||||
print_pages (op, parent, do_print, result);
|
||||
|
||||
if (priv->error && error)
|
||||
if (priv->error)
|
||||
{
|
||||
*error = g_error_copy (priv->error);
|
||||
if (error)
|
||||
*error = g_error_copy (priv->error);
|
||||
result = GTK_PRINT_OPERATION_RESULT_ERROR;
|
||||
}
|
||||
else if (priv->cancelled)
|
||||
|
||||
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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__ */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user