Compare commits
290 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b8092a2ba | |||
| ab3b1d9d2a | |||
| 24d871cf93 | |||
| a193c7620e | |||
| c0cbf9db5f | |||
| db82eaec0a | |||
| f4e200708d | |||
| ba1944ded2 | |||
| 8eeef54b2e | |||
| 8e549d73a0 | |||
| 102d2a36f3 | |||
| f046e27bb4 | |||
| 1c5cf17f1c | |||
| ddb3a4be3e | |||
| 994f32704b | |||
| 1f798643c8 | |||
| 2f8d5e2dcd | |||
| df30741535 | |||
| 762748028a | |||
| f7c5cf137c | |||
| 455d91b0fc | |||
| e834e51c0f | |||
| bce518b214 | |||
| 3656994f82 | |||
| fd5f6ef57f | |||
| 386b63b85d | |||
| 803103640a | |||
| 469a4a73f9 | |||
| f401b05e7b | |||
| 42ed8a2748 | |||
| f872eb64b5 | |||
| 29d054c421 | |||
| 7be6afe84d | |||
| cf1fbdf8b5 | |||
| 6d2860efb7 | |||
| 5f29b8fcec | |||
| 59a8106373 | |||
| c1d90273ca | |||
| 31b95ce47f | |||
| 4fe608e423 | |||
| 2cfeb1048c | |||
| e8210d5865 | |||
| fff981b220 | |||
| a3f4caa291 | |||
| ec54399d89 | |||
| 83f22fcce2 | |||
| 34a12f47f1 | |||
| 518462d882 | |||
| 1912513d7a | |||
| 1643e81c47 | |||
| 7ff427b456 | |||
| 91a96d27f1 | |||
| a0f6ff101e | |||
| 9bcf401ef7 | |||
| 67a7ad069f | |||
| 367d24be7f | |||
| 1791c637d0 | |||
| c6fe8818ed | |||
| 53a30eaa12 | |||
| 692cc42e10 | |||
| 9faaa5e8be | |||
| 418bbb2685 | |||
| fb148027d9 | |||
| 05736afaf8 | |||
| 8a91d1d1ce | |||
| 2df139cf40 | |||
| 9f1208b595 | |||
| 9fd3212241 | |||
| 293f2e6b1c | |||
| f83aa16f59 | |||
| c73dd9ecaf | |||
| 607f08e79b | |||
| 511e5f39fa | |||
| 7d409dd2e0 | |||
| 9b8c0f3c7f | |||
| 727a78a74f | |||
| a928ea6c57 | |||
| d3f7dea624 | |||
| 456b7628ee | |||
| f149beb474 | |||
| 1b0451761a | |||
| 1d26341b03 | |||
| 8348a113c6 | |||
| bfdede7acc | |||
| 70894b48af | |||
| b0c6b282fd | |||
| 393054dd3f | |||
| 97b10df723 | |||
| 62b214ffdf | |||
| 3549f43902 | |||
| 45167d5c0d | |||
| 0214b98c5e | |||
| 19c38158fc | |||
| 7ff35340ca | |||
| a10340859d | |||
| 8475d88af0 | |||
| 79b1d24128 | |||
| ad98e72884 | |||
| 3fab2b55cc | |||
| 2842030e59 | |||
| 7c2d21892f | |||
| 677bfe6857 | |||
| b7ddf0b2e5 | |||
| eb25fc1d5a | |||
| 395d40485d | |||
| 17af979b24 | |||
| 8511f25b97 | |||
| 290611f9ce | |||
| 6280066207 | |||
| f054c317ee | |||
| 9555e611e1 | |||
| 5629ac3c63 | |||
| 110c316810 | |||
| 470a1aabdd | |||
| b299d62a73 | |||
| 02b293b59c | |||
| c659a231d6 | |||
| 4e56581222 | |||
| e8ba16d9c2 | |||
| 4a43c77f66 | |||
| 55936087e0 | |||
| 3141eaecd0 | |||
| 69e14ba02f | |||
| dffbcd8fdf | |||
| ff3b03c5e2 | |||
| 32f4aa12cd | |||
| fbb7948c13 | |||
| d81a5a8338 | |||
| 652323a4bf | |||
| e45518fb5f | |||
| 424e46849a | |||
| 68886ba847 | |||
| da85815399 | |||
| 3bd648e72e | |||
| 2ae8ace784 | |||
| 1f89f21ca9 | |||
| c6921cdc9d | |||
| 7c9f2949ce | |||
| 0b13e68bca | |||
| 5dde4c0a39 | |||
| b2875d7b19 | |||
| 0c1cfbbad1 | |||
| ddacf8cc43 | |||
| 395d13d5f1 | |||
| 1e6e522a93 | |||
| f49a02e5b5 | |||
| 1e4dc90d62 | |||
| 2c3a41a81a | |||
| 203bb42cc1 | |||
| 461497e8d4 | |||
| a974c83423 | |||
| 5eb181281a | |||
| 9eaeb04863 | |||
| 5e6c316603 | |||
| 77b4f6d68e | |||
| a614716d0f | |||
| 1c856a208f | |||
| c7916c8e48 | |||
| 0c023bb5bb | |||
| df73bf38c2 | |||
| 7a1df3f914 | |||
| 3f78199cd5 | |||
| 0a55d4c981 | |||
| 7e03288724 | |||
| 979bf5c6fb | |||
| a7f5b2e8fc | |||
| 94f246240d | |||
| bd5fcf2998 | |||
| c0cf839729 | |||
| 2a51d4fba8 | |||
| cd1078563d | |||
| a9943922d5 | |||
| b46bfcafd1 | |||
| 6141c139e6 | |||
| 0fb83d7619 | |||
| f64d0d8cbf | |||
| e5d6bb68ce | |||
| 74899599a6 | |||
| 12c38c1d57 | |||
| d243c6d7f9 | |||
| c5481a125e | |||
| 68d80babce | |||
| 981c71c497 | |||
| 10bcbae68c | |||
| 1b265a7971 | |||
| 29c0dfb1d2 | |||
| dbec5a8ce5 | |||
| 53eb85ba64 | |||
| 73fdefd65c | |||
| 86562a6c5a | |||
| ceb63b83f2 | |||
| 7373e73067 | |||
| 985ba832fb | |||
| de729e936d | |||
| 019f4b6b34 | |||
| 5bcb01e182 | |||
| 25c2059abb | |||
| 2a9c92f8e2 | |||
| d468ea3efa | |||
| d2cfe9f69a | |||
| 8dbe9e975b | |||
| dd6174c496 | |||
| 7c1cf7781b | |||
| 9b363a62fe | |||
| 2cc39fe282 | |||
| 6255bd6c08 | |||
| ab50d2090d | |||
| c8843d0730 | |||
| 687da2ca6b | |||
| 990a87fd79 | |||
| c4215a2bec | |||
| 342400d155 | |||
| 1ca308a5fd | |||
| 37eb0496b6 | |||
| 6a13bbbfef | |||
| c175a7a470 | |||
| 937317e674 | |||
| 4248835ba1 | |||
| 180f7e4861 | |||
| b526722000 | |||
| b25bba4862 | |||
| 02ce417279 | |||
| b0d2ae612f | |||
| 23e3d48eb9 | |||
| 14f26d2345 | |||
| 7c357423a3 | |||
| cf2d6f6ec5 | |||
| 1443ef85be | |||
| 887aa2abdd | |||
| 9c5d6eaa71 | |||
| c49318e973 | |||
| 131cc6497a | |||
| d9d591ff7a | |||
| f16b34f286 | |||
| 85d822b2e8 | |||
| 4e5689abeb | |||
| b046c8d4ad | |||
| 72c72d0b37 | |||
| 5e69181d8d | |||
| 9c5a9fb100 | |||
| ceb2349823 | |||
| 818b7c44be | |||
| 044026d330 | |||
| 66882f3825 | |||
| 1d0235780c | |||
| 770d6cb2bd | |||
| 106e1080ae | |||
| 07ecb3cb78 | |||
| 74ac435ae6 | |||
| c80ba49a60 | |||
| 404d79153e | |||
| ed9941ec2c | |||
| c3b43f2ad2 | |||
| 86718439be | |||
| 933e373b07 | |||
| e6dcd55480 | |||
| 0d901ef174 | |||
| 716e0db690 | |||
| 90b78132d4 | |||
| c2285d923d | |||
| 4a79ac4473 | |||
| 2a3e5422ad | |||
| e0c39dbf7e | |||
| 8c670b3b5d | |||
| 5dddec4dd9 | |||
| 93017bb8db | |||
| 059c45a85b | |||
| 63692a491d | |||
| bbe79c1ef9 | |||
| 4b241f8da2 | |||
| bdd6ae3252 | |||
| 24a3ff3aef | |||
| ba988cd899 | |||
| 1bf1646d25 | |||
| 2c82151d65 | |||
| d2235b71f3 | |||
| ecc6c255ef | |||
| 57135acd2d | |||
| 54c098761f | |||
| 2f98400b80 | |||
| ea7c9b93ea | |||
| 4317c008f0 | |||
| d605d9ae73 | |||
| c9fad25131 | |||
| 693200f1eb | |||
| 5f087a9dff | |||
| b9cde6f8ea | |||
| 86eece78b1 | |||
| 8cb50ac6e9 | |||
| e7c9e2060c |
+3
-3
@@ -20,7 +20,7 @@ variables:
|
||||
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true -Dvulkan=yes"
|
||||
FEATURE_FLAGS: "-Dcloudproviders=true"
|
||||
MESON_TEST_TIMEOUT_MULTIPLIER: 2
|
||||
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v18"
|
||||
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v17"
|
||||
FLATPAK_IMAGE: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master"
|
||||
DOCS_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora-docs:v19"
|
||||
|
||||
@@ -107,10 +107,10 @@ release-build:
|
||||
- subprojects/libepoxy/
|
||||
- subprojects/pango/
|
||||
|
||||
msys2-mingw32:
|
||||
msys2-mingw64:
|
||||
extends: .mingw-defaults
|
||||
variables:
|
||||
MSYSTEM: "MINGW32"
|
||||
MSYSTEM: "MINGW64"
|
||||
CHERE_INVOKING: "yes"
|
||||
|
||||
.flatpak-defaults:
|
||||
|
||||
@@ -42,7 +42,6 @@ RUN dnf -y install \
|
||||
json-glib-devel \
|
||||
lcov \
|
||||
libattr-devel \
|
||||
libcloudproviders-devel \
|
||||
libepoxy-devel \
|
||||
libffi-devel \
|
||||
libmount-devel \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v20
|
||||
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v19
|
||||
|
||||
ARG HOST_USER_ID=5555
|
||||
ENV HOST_USER_ID ${HOST_USER_ID}
|
||||
|
||||
@@ -94,7 +94,7 @@ do_css_basics (GtkWidget *do_widget)
|
||||
|
||||
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
|
||||
|
||||
container = gtk_scrolled_window_new (NULL, NULL);
|
||||
container = gtk_scrolled_window_new ();
|
||||
gtk_window_set_child (GTK_WINDOW (window), container);
|
||||
child = gtk_text_view_new_with_buffer (text);
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (container), child);
|
||||
|
||||
@@ -132,7 +132,7 @@ do_css_multiplebgs (GtkWidget *do_widget)
|
||||
|
||||
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_paned_set_end_child (GTK_PANED (paned), sw);
|
||||
child = gtk_text_view_new_with_buffer (text);
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), child);
|
||||
|
||||
@@ -101,7 +101,7 @@ do_css_pixbufs (GtkWidget *do_widget)
|
||||
|
||||
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
|
||||
|
||||
container = gtk_scrolled_window_new (NULL, NULL);
|
||||
container = gtk_scrolled_window_new ();
|
||||
gtk_paned_set_end_child (GTK_PANED (paned), container);
|
||||
child = gtk_text_view_new_with_buffer (text);
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (container), child);
|
||||
|
||||
@@ -119,7 +119,7 @@ do_css_shadows (GtkWidget *do_widget)
|
||||
|
||||
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
|
||||
|
||||
container = gtk_scrolled_window_new (NULL, NULL);
|
||||
container = gtk_scrolled_window_new ();
|
||||
gtk_paned_set_end_child (GTK_PANED (paned), container);
|
||||
child = gtk_text_view_new_with_buffer (text);
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (container), child);
|
||||
|
||||
@@ -105,6 +105,9 @@
|
||||
<file>zoom_in_cursor.png</file>
|
||||
<file>zoom_out_cursor.png</file>
|
||||
</gresource>
|
||||
<gresource prefix="/dnd">
|
||||
<file>dnd.css</file>
|
||||
</gresource>
|
||||
<gresource prefix="/fishbowl">
|
||||
<file>fishbowl.ui</file>
|
||||
<file>gtkfishbowl.c</file>
|
||||
@@ -296,6 +299,7 @@
|
||||
</gresource>
|
||||
<gresource prefix="/transparent">
|
||||
<file>portland-rose.jpg</file>
|
||||
<file>bluroverlay.h</file>
|
||||
<file>bluroverlay.c</file>
|
||||
</gresource>
|
||||
<gresource prefix="/markup">
|
||||
|
||||
@@ -25,31 +25,36 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtk/gtk-a11y.h>
|
||||
|
||||
typedef struct {
|
||||
struct _DemoTaggedEntry
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
|
||||
GtkWidget *box;
|
||||
GtkWidget *entry;
|
||||
} DemoTaggedEntryPrivate;
|
||||
};
|
||||
|
||||
struct _DemoTaggedEntryClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
static void demo_tagged_entry_editable_init (GtkEditableInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (DemoTaggedEntry, demo_tagged_entry, GTK_TYPE_WIDGET,
|
||||
G_ADD_PRIVATE (DemoTaggedEntry)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE, demo_tagged_entry_editable_init))
|
||||
|
||||
static void
|
||||
demo_tagged_entry_init (DemoTaggedEntry *entry)
|
||||
{
|
||||
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
|
||||
entry->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_widget_set_parent (entry->box, GTK_WIDGET (entry));
|
||||
|
||||
priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_widget_set_parent (priv->box, GTK_WIDGET (entry));
|
||||
|
||||
priv->entry = gtk_text_new ();
|
||||
gtk_widget_set_hexpand (priv->entry, TRUE);
|
||||
gtk_widget_set_vexpand (priv->entry, TRUE);
|
||||
gtk_widget_set_hexpand (priv->box, FALSE);
|
||||
gtk_widget_set_vexpand (priv->box, FALSE);
|
||||
gtk_box_append (GTK_BOX (priv->box), priv->entry);
|
||||
entry->entry = gtk_text_new ();
|
||||
gtk_widget_set_hexpand (entry->entry, TRUE);
|
||||
gtk_widget_set_vexpand (entry->entry, TRUE);
|
||||
gtk_widget_set_hexpand (entry->box, FALSE);
|
||||
gtk_widget_set_vexpand (entry->box, FALSE);
|
||||
gtk_box_append (GTK_BOX (entry->box), entry->entry);
|
||||
gtk_editable_init_delegate (GTK_EDITABLE (entry));
|
||||
}
|
||||
|
||||
@@ -57,23 +62,16 @@ static void
|
||||
demo_tagged_entry_dispose (GObject *object)
|
||||
{
|
||||
DemoTaggedEntry *entry = DEMO_TAGGED_ENTRY (object);
|
||||
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
|
||||
|
||||
if (priv->entry)
|
||||
if (entry->entry)
|
||||
gtk_editable_finish_delegate (GTK_EDITABLE (entry));
|
||||
|
||||
g_clear_pointer (&priv->entry, gtk_widget_unparent);
|
||||
g_clear_pointer (&priv->box, gtk_widget_unparent);
|
||||
g_clear_pointer (&entry->entry, gtk_widget_unparent);
|
||||
g_clear_pointer (&entry->box, gtk_widget_unparent);
|
||||
|
||||
G_OBJECT_CLASS (demo_tagged_entry_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
demo_tagged_entry_finalize (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (demo_tagged_entry_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
demo_tagged_entry_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
@@ -98,44 +96,12 @@ demo_tagged_entry_get_property (GObject *object,
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
demo_tagged_entry_measure (GtkWidget *widget,
|
||||
GtkOrientation orientation,
|
||||
int for_size,
|
||||
int *minimum,
|
||||
int *natural,
|
||||
int *minimum_baseline,
|
||||
int *natural_baseline)
|
||||
{
|
||||
DemoTaggedEntry *entry = DEMO_TAGGED_ENTRY (widget);
|
||||
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
|
||||
|
||||
gtk_widget_measure (priv->box, orientation, for_size,
|
||||
minimum, natural,
|
||||
minimum_baseline, natural_baseline);
|
||||
}
|
||||
|
||||
static void
|
||||
demo_tagged_entry_size_allocate (GtkWidget *widget,
|
||||
int width,
|
||||
int height,
|
||||
int baseline)
|
||||
{
|
||||
DemoTaggedEntry *entry = DEMO_TAGGED_ENTRY (widget);
|
||||
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
|
||||
|
||||
gtk_widget_size_allocate (priv->box,
|
||||
&(GtkAllocation) { 0, 0, width, height },
|
||||
baseline);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
demo_tagged_entry_grab_focus (GtkWidget *widget)
|
||||
{
|
||||
DemoTaggedEntry *entry = DEMO_TAGGED_ENTRY (widget);
|
||||
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
|
||||
|
||||
return gtk_widget_grab_focus (priv->entry);
|
||||
return gtk_widget_grab_focus (entry->entry);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -145,16 +111,14 @@ demo_tagged_entry_class_init (DemoTaggedEntryClass *klass)
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->dispose = demo_tagged_entry_dispose;
|
||||
object_class->finalize = demo_tagged_entry_finalize;
|
||||
object_class->get_property = demo_tagged_entry_get_property;
|
||||
object_class->set_property = demo_tagged_entry_set_property;
|
||||
|
||||
widget_class->measure = demo_tagged_entry_measure;
|
||||
widget_class->size_allocate = demo_tagged_entry_size_allocate;
|
||||
widget_class->grab_focus = demo_tagged_entry_grab_focus;
|
||||
|
||||
|
||||
gtk_editable_install_properties (object_class, 1);
|
||||
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_ENTRY_ACCESSIBLE);
|
||||
gtk_widget_class_set_css_name (widget_class, "entry");
|
||||
}
|
||||
@@ -162,10 +126,7 @@ demo_tagged_entry_class_init (DemoTaggedEntryClass *klass)
|
||||
static GtkEditable *
|
||||
demo_tagged_entry_get_delegate (GtkEditable *editable)
|
||||
{
|
||||
DemoTaggedEntry *entry = DEMO_TAGGED_ENTRY (editable);
|
||||
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
|
||||
|
||||
return GTK_EDITABLE (priv->entry);
|
||||
return GTK_EDITABLE (DEMO_TAGGED_ENTRY (editable)->entry);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -184,11 +145,9 @@ void
|
||||
demo_tagged_entry_add_tag (DemoTaggedEntry *entry,
|
||||
GtkWidget *tag)
|
||||
{
|
||||
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
|
||||
|
||||
g_return_if_fail (DEMO_IS_TAGGED_ENTRY (entry));
|
||||
|
||||
gtk_box_append (GTK_BOX (priv->box), tag);
|
||||
gtk_box_append (GTK_BOX (entry->box), tag);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -196,30 +155,27 @@ demo_tagged_entry_insert_tag_after (DemoTaggedEntry *entry,
|
||||
GtkWidget *tag,
|
||||
GtkWidget *sibling)
|
||||
{
|
||||
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
|
||||
|
||||
g_return_if_fail (DEMO_IS_TAGGED_ENTRY (entry));
|
||||
|
||||
if (sibling == NULL)
|
||||
gtk_box_append (GTK_BOX (priv->box), tag);
|
||||
gtk_box_append (GTK_BOX (entry->box), tag);
|
||||
else
|
||||
gtk_box_insert_child_after (GTK_BOX (priv->box), tag, sibling);
|
||||
gtk_box_insert_child_after (GTK_BOX (entry->box), tag, sibling);
|
||||
}
|
||||
|
||||
void
|
||||
demo_tagged_entry_remove_tag (DemoTaggedEntry *entry,
|
||||
GtkWidget *tag)
|
||||
{
|
||||
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
|
||||
|
||||
g_return_if_fail (DEMO_IS_TAGGED_ENTRY (entry));
|
||||
|
||||
gtk_box_remove (GTK_BOX (priv->box), tag);
|
||||
gtk_box_remove (GTK_BOX (entry->box), tag);
|
||||
}
|
||||
|
||||
struct _DemoTaggedEntryTag
|
||||
{
|
||||
GtkWidget parent;
|
||||
|
||||
GtkWidget *box;
|
||||
GtkWidget *label;
|
||||
GtkWidget *button;
|
||||
@@ -250,11 +206,11 @@ static guint signals[LAST_SIGNAL] = { 0, };
|
||||
G_DEFINE_TYPE (DemoTaggedEntryTag, demo_tagged_entry_tag, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
on_released (GtkGestureClick *gesture,
|
||||
int n_press,
|
||||
double x,
|
||||
double y,
|
||||
DemoTaggedEntryTag *tag)
|
||||
on_released (GtkGestureClick *gesture,
|
||||
int n_press,
|
||||
double x,
|
||||
double y,
|
||||
DemoTaggedEntryTag *tag)
|
||||
{
|
||||
g_signal_emit (tag, signals[SIGNAL_CLICKED], 0);
|
||||
}
|
||||
@@ -469,7 +425,7 @@ demo_tagged_entry_tag_set_has_close_button (DemoTaggedEntryTag *tag,
|
||||
|
||||
image = gtk_image_new_from_icon_name ("window-close-symbolic");
|
||||
tag->button = gtk_button_new ();
|
||||
gtk_box_append (GTK_BOX (tag->button), image);
|
||||
gtk_button_set_child (GTK_BUTTON (tag->button), image);
|
||||
gtk_widget_set_halign (tag->button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (tag->button, GTK_ALIGN_CENTER);
|
||||
gtk_button_set_has_frame (GTK_BUTTON (tag->button), FALSE);
|
||||
|
||||
@@ -25,39 +25,11 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define DEMO_TYPE_TAGGED_ENTRY (demo_tagged_entry_get_type ())
|
||||
#define DEMO_TAGGED_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEMO_TYPE_TAGGED_ENTRY, DemoTaggedEntry))
|
||||
#define DEMO_TAGGED_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEMO_TYPE_TAGGED_ENTRY, DemoTaggedEntryClass))
|
||||
#define DEMO_IS_TAGGED_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEMO_TYPE_TAGGED_ENTRY))
|
||||
#define DEMO_IS_TAGGED_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEMO_TYPE_TAGGED_ENTRY))
|
||||
#define DEMO_TAGGED_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEMO_TYPE_TAGGED_ENTRY, DemoTaggedEntryClass))
|
||||
#define DEMO_TYPE_TAGGED_ENTRY (demo_tagged_entry_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (DemoTaggedEntry, demo_tagged_entry, DEMO, TAGGED_ENTRY, GtkWidget)
|
||||
|
||||
typedef struct _DemoTaggedEntry DemoTaggedEntry;
|
||||
typedef struct _DemoTaggedEntryClass DemoTaggedEntryClass;
|
||||
|
||||
struct _DemoTaggedEntry
|
||||
{
|
||||
GtkWidget parent;
|
||||
};
|
||||
|
||||
struct _DemoTaggedEntryClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
#define DEMO_TYPE_TAGGED_ENTRY_TAG (demo_tagged_entry_tag_get_type ())
|
||||
#define DEMO_TAGGED_ENTRY_TAG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEMO_TYPE_TAGGED_ENTRY_TAG, DemoTaggedEntryTag))
|
||||
#define DEMO_TAGGED_ENTRY_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEMO_TYPE_TAGGED_ENTRY_TAG, DemoTaggedEntryTag))
|
||||
#define DEMO_IS_TAGGED_ENTRY_TAG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEMO_TYPE_TAGGED_ENTRY_TAG))
|
||||
#define DEMO_IS_TAGGED_ENTRY_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEMO_TYPE_TAGGED_ENTRY_TAG))
|
||||
#define DEMO_TAGGED_ENTRY_TAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEMO_TYPE_TAGGED_ENTRY_TAG, DemoTaggedEntryTagClass))
|
||||
|
||||
typedef struct _DemoTaggedEntryTag DemoTaggedEntryTag;
|
||||
typedef struct _DemoTaggedEntryTagClass DemoTaggedEntryTagClass;
|
||||
|
||||
|
||||
GType demo_tagged_entry_get_type (void) G_GNUC_CONST;
|
||||
GType demo_tagged_entry_tag_get_type (void) G_GNUC_CONST;
|
||||
#define DEMO_TYPE_TAGGED_ENTRY_TAG (demo_tagged_entry_tag_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (DemoTaggedEntryTag, demo_tagged_entry_tag, DEMO, TAGGED_ENTRY_TAG, GtkWidget)
|
||||
|
||||
GtkWidget * demo_tagged_entry_new (void);
|
||||
|
||||
|
||||
+21
-32
@@ -1,6 +1,7 @@
|
||||
/* Dialogs and Message Boxes
|
||||
/* Dialogs
|
||||
*
|
||||
* Dialog widgets are used to pop up a transient window for user feedback.
|
||||
* Dialogs are used to pop up transient windows for information
|
||||
* and user feedback.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
@@ -21,10 +22,9 @@ message_dialog_clicked (GtkButton *button,
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_OK_CANCEL,
|
||||
"This message box has been popped up the following\n"
|
||||
"number of times:");
|
||||
"Test message");
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
"%d", i);
|
||||
ngettext ("Has been shown once", "Has been shown %d times", i), i);
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
|
||||
gtk_widget_show (dialog);
|
||||
i++;
|
||||
@@ -61,8 +61,6 @@ interactive_dialog_clicked (GtkButton *button,
|
||||
{
|
||||
GtkWidget *content_area;
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *image;
|
||||
GtkWidget *table;
|
||||
GtkWidget *local_entry1;
|
||||
GtkWidget *local_entry2;
|
||||
@@ -71,26 +69,24 @@ interactive_dialog_clicked (GtkButton *button,
|
||||
|
||||
dialog = gtk_dialog_new_with_buttons ("Interactive Dialog",
|
||||
GTK_WINDOW (window),
|
||||
GTK_DIALOG_MODAL| GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
_("_OK"),
|
||||
GTK_RESPONSE_OK,
|
||||
"_Cancel",
|
||||
GTK_RESPONSE_CANCEL,
|
||||
GTK_DIALOG_MODAL| GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_USE_HEADER_BAR,
|
||||
_("_OK"), GTK_RESPONSE_OK,
|
||||
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||
NULL);
|
||||
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
||||
|
||||
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
|
||||
gtk_box_append (GTK_BOX (content_area), hbox);
|
||||
|
||||
image = gtk_image_new_from_icon_name ("dialog-question");
|
||||
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
|
||||
gtk_box_append (GTK_BOX (hbox), image);
|
||||
|
||||
table = gtk_grid_new ();
|
||||
gtk_grid_set_row_spacing (GTK_GRID (table), 4);
|
||||
gtk_grid_set_column_spacing (GTK_GRID (table), 4);
|
||||
gtk_box_append (GTK_BOX (hbox), table);
|
||||
gtk_widget_set_hexpand (table, TRUE);
|
||||
gtk_widget_set_vexpand (table, TRUE);
|
||||
gtk_widget_set_halign (table, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (table, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (content_area), table);
|
||||
gtk_grid_set_row_spacing (GTK_GRID (table), 6);
|
||||
gtk_grid_set_column_spacing (GTK_GRID (table), 6);
|
||||
|
||||
label = gtk_label_new_with_mnemonic ("_Entry 1");
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
|
||||
local_entry1 = gtk_entry_new ();
|
||||
@@ -123,7 +119,6 @@ interactive_dialog_clicked (GtkButton *button,
|
||||
GtkWidget *
|
||||
do_dialog (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *vbox2;
|
||||
GtkWidget *hbox;
|
||||
@@ -136,22 +131,16 @@ do_dialog (GtkWidget *do_widget)
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Dialogs and Message Boxes");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Dialogs");
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
frame = gtk_frame_new ("Dialogs");
|
||||
gtk_widget_set_margin_start (frame, 8);
|
||||
gtk_widget_set_margin_end (frame, 8);
|
||||
gtk_widget_set_margin_top (frame, 8);
|
||||
gtk_widget_set_margin_bottom (frame, 8);
|
||||
gtk_window_set_child (GTK_WINDOW (window), frame);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_widget_set_margin_start (vbox, 8);
|
||||
gtk_widget_set_margin_end (vbox, 8);
|
||||
gtk_widget_set_margin_top (vbox, 8);
|
||||
gtk_widget_set_margin_bottom (vbox, 8);
|
||||
gtk_frame_set_child (GTK_FRAME (frame), vbox);
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
|
||||
/* Standard message dialog */
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
|
||||
|
||||
+84
-4
@@ -38,15 +38,20 @@ set_color (CanvasItem *item,
|
||||
char *str;
|
||||
GtkStyleContext *context;
|
||||
GtkCssProvider *provider;
|
||||
const char *old_class;
|
||||
|
||||
str = gdk_rgba_to_string (color);
|
||||
css = g_strdup_printf ("* { background: %s; padding: 10px; margin: 1px; }", str);
|
||||
css = g_strdup_printf ("* { background: %s; }", str);
|
||||
|
||||
context = gtk_widget_get_style_context (item->label);
|
||||
provider = g_object_get_data (G_OBJECT (context), "style-provider");
|
||||
if (provider)
|
||||
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (provider));
|
||||
|
||||
old_class = (const char *)g_object_get_data (G_OBJECT (item->label), "css-class");
|
||||
if (old_class)
|
||||
gtk_widget_remove_css_class (item->label, old_class);
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_style_context_add_provider (gtk_widget_get_style_context (item->label), GTK_STYLE_PROVIDER (provider), 800);
|
||||
@@ -56,6 +61,27 @@ set_color (CanvasItem *item,
|
||||
g_free (css);
|
||||
}
|
||||
|
||||
static void
|
||||
set_css (CanvasItem *item,
|
||||
const char *class)
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
GtkCssProvider *provider;
|
||||
const char *old_class;
|
||||
|
||||
context = gtk_widget_get_style_context (item->label);
|
||||
provider = g_object_get_data (G_OBJECT (context), "style-provider");
|
||||
if (provider)
|
||||
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (provider));
|
||||
|
||||
old_class = (const char *)g_object_get_data (G_OBJECT (item->label), "css-class");
|
||||
if (old_class)
|
||||
gtk_widget_remove_css_class (item->label, old_class);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (item->label), "css-class", g_strdup (class), g_free);
|
||||
gtk_widget_add_css_class (item->label, class);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
item_drag_drop (GtkDropTarget *dest,
|
||||
const GValue *value,
|
||||
@@ -65,7 +91,10 @@ item_drag_drop (GtkDropTarget *dest,
|
||||
GtkWidget *label = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (dest));
|
||||
CanvasItem *item = CANVAS_ITEM (gtk_widget_get_parent (gtk_widget_get_parent (label)));
|
||||
|
||||
set_color (item, g_value_get_boxed (value));
|
||||
if (G_VALUE_TYPE (value) == GDK_TYPE_RGBA)
|
||||
set_color (item, g_value_get_boxed (value));
|
||||
else if (G_VALUE_TYPE (value) == G_TYPE_STRING)
|
||||
set_css (item, g_value_get_string (value));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -132,11 +161,13 @@ canvas_item_init (CanvasItem *item)
|
||||
GdkRGBA rgba;
|
||||
GtkDropTarget *dest;
|
||||
GtkGesture *gesture;
|
||||
GType types[2] = { GDK_TYPE_RGBA, G_TYPE_STRING };
|
||||
|
||||
n_items++;
|
||||
|
||||
text = g_strdup_printf ("Item %d", n_items);
|
||||
item->label = gtk_label_new (text);
|
||||
gtk_widget_add_css_class (item->label, "canvasitem");
|
||||
g_free (text);
|
||||
|
||||
item->fixed = gtk_fixed_new ();
|
||||
@@ -154,7 +185,8 @@ canvas_item_init (CanvasItem *item)
|
||||
|
||||
item->angle = 0;
|
||||
|
||||
dest = gtk_drop_target_new (GDK_TYPE_RGBA, GDK_ACTION_COPY);
|
||||
dest = gtk_drop_target_new (G_TYPE_INVALID, GDK_ACTION_COPY);
|
||||
gtk_drop_target_set_gtypes (dest, types, G_N_ELEMENTS (types));
|
||||
g_signal_connect (dest, "drop", G_CALLBACK (item_drag_drop), NULL);
|
||||
gtk_widget_add_controller (GTK_WIDGET (item->label), GTK_EVENT_CONTROLLER (dest));
|
||||
|
||||
@@ -529,6 +561,42 @@ canvas_new (void)
|
||||
return canvas;
|
||||
}
|
||||
|
||||
static GdkContentProvider *
|
||||
css_drag_prepare (GtkDragSource *source,
|
||||
double x,
|
||||
double y,
|
||||
GtkWidget *button)
|
||||
{
|
||||
const char *class;
|
||||
GdkPaintable *paintable;
|
||||
|
||||
class = (const char *)g_object_get_data (G_OBJECT (button), "css-class");
|
||||
|
||||
paintable = gtk_widget_paintable_new (button);
|
||||
gtk_drag_source_set_icon (source, paintable, 0, 0);
|
||||
g_object_unref (paintable);
|
||||
|
||||
return gdk_content_provider_new_typed (G_TYPE_STRING, class);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
css_button_new (const char *class)
|
||||
{
|
||||
GtkWidget *button;
|
||||
GtkDragSource *source;
|
||||
|
||||
button = gtk_image_new ();
|
||||
gtk_widget_set_size_request (button, 48, 32);
|
||||
gtk_widget_add_css_class (button, class);
|
||||
g_object_set_data (G_OBJECT (button), "css-class", (gpointer)class);
|
||||
|
||||
source = gtk_drag_source_new ();
|
||||
g_signal_connect (source, "prepare", G_CALLBACK (css_drag_prepare), button);
|
||||
gtk_widget_add_controller (button, GTK_EVENT_CONTROLLER (source));
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
GtkWidget *
|
||||
@@ -548,10 +616,18 @@ do_dnd (GtkWidget *do_widget)
|
||||
};
|
||||
int i;
|
||||
int x, y;
|
||||
GtkCssProvider *provider;
|
||||
|
||||
button = gtk_color_button_new ();
|
||||
g_object_unref (g_object_ref_sink (button));
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_resource (provider, "/dnd/dnd.css");
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
g_object_unref (provider);
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
@@ -583,7 +659,7 @@ do_dnd (GtkWidget *do_widget)
|
||||
y += 100;
|
||||
}
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_NEVER);
|
||||
@@ -606,6 +682,10 @@ do_dnd (GtkWidget *do_widget)
|
||||
NULL);
|
||||
gtk_box_append (GTK_BOX (box3), swatch);
|
||||
}
|
||||
|
||||
gtk_box_append (GTK_BOX (box3), css_button_new ("rainbow1"));
|
||||
gtk_box_append (GTK_BOX (box3), css_button_new ("rainbow2"));
|
||||
gtk_box_append (GTK_BOX (box3), css_button_new ("rainbow3"));
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
label.canvasitem {
|
||||
padding: 10px;
|
||||
margin: 1px;
|
||||
}
|
||||
|
||||
.canvasitem.rainbow1,
|
||||
image.rainbow1 {
|
||||
background: linear-gradient(140deg,red,orange,yellow,green,blue,purple);
|
||||
}
|
||||
|
||||
.canvasitem.rainbow2,
|
||||
image.rainbow2 {
|
||||
animation: rainbow2 1s infinite linear;
|
||||
}
|
||||
|
||||
@keyframes rainbow2 {
|
||||
0% { background: linear-gradient(0deg,red,orange,yellow,green,blue,purple); }
|
||||
25% { background: linear-gradient(90deg,red,orange,yellow,green,blue,purple); }
|
||||
50% { background: linear-gradient(180deg,red,orange,yellow,green,blue,purple); }
|
||||
75% { background: linear-gradient(270deg,red,orange,yellow,green,blue,purple); }
|
||||
100% { background: linear-gradient(360deg,red,orange,yellow,green,blue,purple); }
|
||||
}
|
||||
|
||||
.canvasitem.rainbow3,
|
||||
image.rainbow3 {
|
||||
animation: rainbow3 1s infinite linear;
|
||||
}
|
||||
|
||||
@keyframes rainbow3 {
|
||||
0% { background: linear-gradient(140deg,red,orange,yellow,green,blue,purple); }
|
||||
16.6% { background: linear-gradient(140deg,purple,red,orange,yellow,green,blue); }
|
||||
33.2% { background: linear-gradient(140deg,blue,purple,red,orange,yellow,green); }
|
||||
50% { background: linear-gradient(140deg,green,blue,purple,red,orange,yellow); }
|
||||
66.6% { background: linear-gradient(140deg,yellow,green,blue,purple,red,orange); }
|
||||
83.2% { background: linear-gradient(140deg,orange,yellow,green,blue,purple,red); }
|
||||
100% { background: linear-gradient(140deg,red,orange,yellow,green,blue,purple); }
|
||||
}
|
||||
@@ -364,7 +364,7 @@ do_editable_cells (GtkWidget *do_widget)
|
||||
gtk_box_append (GTK_BOX (vbox),
|
||||
gtk_label_new ("Shopping list (you can edit the cells!)"));
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Entry/Entry Completion
|
||||
/* Entry/Completion
|
||||
*
|
||||
* GtkEntryCompletion provides a mechanism for adding support for
|
||||
* completion in GtkEntry.
|
||||
@@ -8,28 +8,42 @@
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
/* Creates a tree model containing the completions */
|
||||
static GtkTreeModel *
|
||||
/* Creates a list model containing the completions */
|
||||
static GListModel *
|
||||
create_completion_model (void)
|
||||
{
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
const char *strings[] = {
|
||||
"GNOME",
|
||||
"gnominious",
|
||||
"Gnomonic projection",
|
||||
"Gnosophy",
|
||||
"total",
|
||||
"totally",
|
||||
"toto",
|
||||
"tottery",
|
||||
"totterer",
|
||||
"Totten trust",
|
||||
"Tottenham hotspurs",
|
||||
"totipotent",
|
||||
"totipotency",
|
||||
"totemism",
|
||||
"totem pole",
|
||||
"Totara",
|
||||
"totalizer",
|
||||
"totalizator",
|
||||
"totalitarianism",
|
||||
"total parenteral nutrition",
|
||||
"total eclipse",
|
||||
"Totipresence",
|
||||
"Totipalmi",
|
||||
"zombie",
|
||||
"aæx",
|
||||
"aæy",
|
||||
"aæz",
|
||||
NULL
|
||||
};
|
||||
|
||||
store = gtk_list_store_new (1, G_TYPE_STRING);
|
||||
|
||||
/* Append one word */
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, 0, "GNOME", -1);
|
||||
|
||||
/* Append another word */
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, 0, "total", -1);
|
||||
|
||||
/* And another word */
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, 0, "totally", -1);
|
||||
|
||||
return GTK_TREE_MODEL (store);
|
||||
return G_LIST_MODEL (gtk_string_list_new (strings));
|
||||
}
|
||||
|
||||
|
||||
@@ -41,14 +55,14 @@ do_entry_completion (GtkWidget *do_widget)
|
||||
GtkWidget *label;
|
||||
GtkWidget *entry;
|
||||
GtkEntryCompletion *completion;
|
||||
GtkTreeModel *completion_model;
|
||||
GListModel *completion_model;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Entry Completion");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Completion");
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
@@ -60,7 +74,7 @@ do_entry_completion (GtkWidget *do_widget)
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label), "Completion demo, try writing <b>total</b> or <b>gnome</b> for example.");
|
||||
gtk_label_set_markup (GTK_LABEL (label), "Try writing <b>total</b> or <b>gnome</b> for example.");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
/* Create our entry */
|
||||
@@ -79,8 +93,8 @@ do_entry_completion (GtkWidget *do_widget)
|
||||
gtk_entry_completion_set_model (completion, completion_model);
|
||||
g_object_unref (completion_model);
|
||||
|
||||
/* Use model column 0 as the text column */
|
||||
gtk_entry_completion_set_text_column (completion, 0);
|
||||
gtk_entry_completion_set_inline_completion (completion, TRUE);
|
||||
gtk_entry_completion_set_inline_selection (completion, TRUE);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* Entry/Entry Undo
|
||||
/* Entry/Undo and Redo
|
||||
*
|
||||
* GtkEntry can provide basic Undo/Redo support using standard keyboard
|
||||
* accelerators such as Primary+z to undo and Primary+Shift+z to redo.
|
||||
* Additionally, Primary+y can be used to redo.
|
||||
* accelerators such as Control+z to undo and Control+Shift+z to redo.
|
||||
* Additionally, Control+y can be used to redo.
|
||||
*
|
||||
* Use gtk_entry_set_enable_undo() to enable undo/redo support.
|
||||
*/
|
||||
@@ -23,7 +23,7 @@ do_entry_undo (GtkWidget *do_widget)
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Entry Undo");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Undo and Redo");
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ do_expander (GtkWidget *do_widget)
|
||||
|
||||
expander = gtk_expander_new ("Details:");
|
||||
gtk_widget_set_vexpand (expander, TRUE);
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (sw), 100);
|
||||
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
|
||||
@@ -130,7 +130,7 @@ create_demo_window (GtkWidget *do_widget)
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (close_window), NULL);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_window_set_child (GTK_WINDOW (window), sw);
|
||||
|
||||
fixed = gtk_fixed_new ();
|
||||
|
||||
@@ -727,7 +727,7 @@ do_flowbox (GtkWidget *do_widget)
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
scrolled = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||
flowbox = gtk_flow_box_new ();
|
||||
gtk_widget_set_valign (flowbox, GTK_ALIGN_START);
|
||||
|
||||
@@ -108,10 +108,6 @@ gtk_fishbowl_measure (GtkWidget *widget,
|
||||
{
|
||||
child = value;
|
||||
|
||||
if (!gtk_widget_get_visible (child->widget))
|
||||
continue;
|
||||
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
gtk_widget_measure (child->widget, orientation, -1, &child_min, &child_nat, NULL, NULL);
|
||||
@@ -148,9 +144,6 @@ gtk_fishbowl_size_allocate (GtkWidget *widget,
|
||||
{
|
||||
child = value;
|
||||
|
||||
if (!gtk_widget_get_visible (child->widget))
|
||||
continue;
|
||||
|
||||
gtk_widget_get_preferred_size (child->widget, &child_requisition, NULL);
|
||||
child_allocation.x = round (child->x * (width - child_requisition.width));
|
||||
child_allocation.y = round (child->y * (height - child_requisition.height));
|
||||
@@ -197,17 +190,11 @@ gtk_fishbowl_remove (GtkFishbowl *fishbowl,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
|
||||
GtkWidget *widget_bowl = GTK_WIDGET (fishbowl);
|
||||
|
||||
if (g_hash_table_remove (priv->children, widget))
|
||||
{
|
||||
gboolean was_visible = gtk_widget_get_visible (widget);
|
||||
|
||||
gtk_widget_unparent (widget);
|
||||
|
||||
if (was_visible && gtk_widget_get_visible (widget_bowl))
|
||||
gtk_widget_queue_resize (widget_bowl);
|
||||
|
||||
priv->count--;
|
||||
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_COUNT]);
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ do_hypertext (GtkWidget *do_widget)
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
gtk_text_buffer_set_enable_undo (buffer, TRUE);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
||||
@@ -276,7 +276,7 @@ do_iconview (GtkWidget *do_widget)
|
||||
gtk_box_append (GTK_BOX (tool_bar), home_button);
|
||||
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
|
||||
@@ -269,7 +269,7 @@ do_list_store (GtkWidget *do_widget)
|
||||
label = gtk_label_new ("This is the bug list (note: not based on real data, it would be nice to have a nice ODBC interface to bugzilla or so, though).");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_NEVER,
|
||||
|
||||
@@ -358,7 +358,7 @@ do_listbox (GtkWidget *do_widget)
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
label = gtk_label_new ("Messages from GTK and friends");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
scrolled = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
gtk_box_append (GTK_BOX (vbox), scrolled);
|
||||
|
||||
@@ -188,7 +188,7 @@ do_listview_applauncher (GtkWidget *do_widget)
|
||||
* because otherwise they might get too large or they might not
|
||||
* be scrollable.
|
||||
*/
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_window_set_child (GTK_WINDOW (window), sw);
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ gtk_clock_tick (gpointer unused)
|
||||
{
|
||||
GtkClock *clock = l->data;
|
||||
|
||||
/* We will now return a different value for the time porperty,
|
||||
/* We will now return a different value for the time property,
|
||||
* so notify about that.
|
||||
*/
|
||||
g_object_notify_by_pspec (G_OBJECT (clock), properties[PROP_TIME]);
|
||||
@@ -323,16 +323,16 @@ gtk_clock_init (GtkClock *self)
|
||||
|
||||
static GtkClock *
|
||||
gtk_clock_new (const char *location,
|
||||
GTimeZone *_timezone)
|
||||
GTimeZone *_tz)
|
||||
{
|
||||
GtkClock *result;
|
||||
|
||||
result = g_object_new (GTK_TYPE_CLOCK,
|
||||
"location", location,
|
||||
"timezone", _timezone,
|
||||
"timezone", _tz,
|
||||
NULL);
|
||||
|
||||
g_clear_pointer (&_timezone, g_time_zone_unref);
|
||||
g_clear_pointer (&_tz, g_time_zone_unref);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -474,7 +474,7 @@ do_listview_clocks (GtkWidget *do_widget)
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
|
||||
|
||||
/* List widgets go into a scrolled window. Always. */
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_window_set_child (GTK_WINDOW (window), sw);
|
||||
|
||||
/* Create the factory that creates the listitems. Because we
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
/* Lists/Colors
|
||||
*
|
||||
* This demo displays a list of named colors.
|
||||
* This demo displays a grid of colors.
|
||||
*
|
||||
* It is using a GtkGridView, and shows how to display
|
||||
* and sort the data in various ways. The controls for
|
||||
* this are implemented using GtkDropDown.
|
||||
*
|
||||
* The dataset used here has 9 283 items.
|
||||
* The dataset used here has up to 16 777 216 items.
|
||||
*
|
||||
* Note that this demo also functions as a performance
|
||||
* test for some of the list model machinery, and biggest
|
||||
* sizes here can lock up the application for extended
|
||||
* times when used with sorting.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
@@ -23,7 +28,7 @@ struct _GtkColor
|
||||
GObject parent_instance;
|
||||
|
||||
char *name;
|
||||
GdkRGBA *color;
|
||||
GdkRGBA color;
|
||||
int h, s, v;
|
||||
gboolean selected;
|
||||
};
|
||||
@@ -40,7 +45,7 @@ enum {
|
||||
PROP_VALUE,
|
||||
PROP_SELECTED,
|
||||
|
||||
N_PROPS
|
||||
N_COLOR_PROPS
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -51,7 +56,7 @@ gtk_color_snapshot (GdkPaintable *paintable,
|
||||
{
|
||||
GtkColor *self = GTK_COLOR (paintable);
|
||||
|
||||
gtk_snapshot_append_color (snapshot, self->color, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
gtk_snapshot_append_color (snapshot, &self->color, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -82,7 +87,82 @@ G_DEFINE_TYPE_WITH_CODE (GtkColor, gtk_color, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
|
||||
gtk_color_paintable_init))
|
||||
|
||||
static GParamSpec *properties[N_PROPS] = { NULL, };
|
||||
static GParamSpec *color_properties[N_COLOR_PROPS] = { NULL, };
|
||||
|
||||
static void
|
||||
rgb_to_hsv (GdkRGBA *rgba,
|
||||
gdouble *h_out,
|
||||
gdouble *s_out,
|
||||
gdouble *v_out)
|
||||
{
|
||||
gdouble red, green, blue;
|
||||
gdouble h, s, v;
|
||||
gdouble min, max;
|
||||
gdouble delta;
|
||||
|
||||
red = rgba->red;
|
||||
green = rgba->green;
|
||||
blue = rgba->blue;
|
||||
|
||||
h = 0.0;
|
||||
|
||||
if (red > green)
|
||||
{
|
||||
if (red > blue)
|
||||
max = red;
|
||||
else
|
||||
max = blue;
|
||||
|
||||
if (green < blue)
|
||||
min = green;
|
||||
else
|
||||
min = blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (green > blue)
|
||||
max = green;
|
||||
else
|
||||
max = blue;
|
||||
|
||||
if (red < blue)
|
||||
min = red;
|
||||
else
|
||||
min = blue;
|
||||
}
|
||||
|
||||
v = max;
|
||||
|
||||
if (max != 0.0)
|
||||
s = (max - min) / max;
|
||||
else
|
||||
s = 0.0;
|
||||
|
||||
if (s == 0.0)
|
||||
h = 0.0;
|
||||
else
|
||||
{
|
||||
delta = max - min;
|
||||
|
||||
if (red == max)
|
||||
h = (green - blue) / delta;
|
||||
else if (green == max)
|
||||
h = 2 + (blue - red) / delta;
|
||||
else if (blue == max)
|
||||
h = 4 + (red - green) / delta;
|
||||
|
||||
h /= 6.0;
|
||||
|
||||
if (h < 0.0)
|
||||
h += 1.0;
|
||||
else if (h > 1.0)
|
||||
h -= 1.0;
|
||||
}
|
||||
|
||||
*h_out = h;
|
||||
*s_out = s;
|
||||
*v_out = v;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_get_property (GObject *object,
|
||||
@@ -99,19 +179,19 @@ gtk_color_get_property (GObject *object,
|
||||
break;
|
||||
|
||||
case PROP_COLOR:
|
||||
g_value_set_boxed (value, self->color);
|
||||
g_value_set_boxed (value, &self->color);
|
||||
break;
|
||||
|
||||
case PROP_RED:
|
||||
g_value_set_float (value, self->color->red);
|
||||
g_value_set_float (value, self->color.red);
|
||||
break;
|
||||
|
||||
case PROP_GREEN:
|
||||
g_value_set_float (value, self->color->green);
|
||||
g_value_set_float (value, self->color.green);
|
||||
break;
|
||||
|
||||
case PROP_BLUE:
|
||||
g_value_set_float (value, self->color->blue);
|
||||
g_value_set_float (value, self->color.blue);
|
||||
break;
|
||||
|
||||
case PROP_HUE:
|
||||
@@ -143,6 +223,7 @@ gtk_color_set_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkColor *self = GTK_COLOR (object);
|
||||
double h, s, v;
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
@@ -151,19 +232,11 @@ gtk_color_set_property (GObject *object,
|
||||
break;
|
||||
|
||||
case PROP_COLOR:
|
||||
self->color = g_value_dup_boxed (value);
|
||||
break;
|
||||
|
||||
case PROP_HUE:
|
||||
self->h = g_value_get_int (value);
|
||||
break;
|
||||
|
||||
case PROP_SATURATION:
|
||||
self->s = g_value_get_int (value);
|
||||
break;
|
||||
|
||||
case PROP_VALUE:
|
||||
self->v = g_value_get_int (value);
|
||||
self->color = *(GdkRGBA *) g_value_dup_boxed (value);
|
||||
rgb_to_hsv (&self->color, &h, &s, &v);
|
||||
self->h = round (360 * h);
|
||||
self->s = round (100 * s);
|
||||
self->v = round (100 * v);
|
||||
break;
|
||||
|
||||
case PROP_SELECTED:
|
||||
@@ -182,7 +255,6 @@ gtk_color_finalize (GObject *object)
|
||||
GtkColor *self = GTK_COLOR (object);
|
||||
|
||||
g_free (self->name);
|
||||
g_clear_pointer (&self->color, gdk_rgba_free);
|
||||
|
||||
G_OBJECT_CLASS (gtk_color_parent_class)->finalize (object);
|
||||
}
|
||||
@@ -196,26 +268,26 @@ gtk_color_class_init (GtkColorClass *klass)
|
||||
gobject_class->set_property = gtk_color_set_property;
|
||||
gobject_class->finalize = gtk_color_finalize;
|
||||
|
||||
properties[PROP_NAME] =
|
||||
color_properties[PROP_NAME] =
|
||||
g_param_spec_string ("name", NULL, NULL, NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
properties[PROP_COLOR] =
|
||||
color_properties[PROP_COLOR] =
|
||||
g_param_spec_boxed ("color", NULL, NULL, GDK_TYPE_RGBA, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
properties[PROP_RED] =
|
||||
color_properties[PROP_RED] =
|
||||
g_param_spec_float ("red", NULL, NULL, 0, 1, 0, G_PARAM_READABLE);
|
||||
properties[PROP_GREEN] =
|
||||
color_properties[PROP_GREEN] =
|
||||
g_param_spec_float ("green", NULL, NULL, 0, 1, 0, G_PARAM_READABLE);
|
||||
properties[PROP_BLUE] =
|
||||
color_properties[PROP_BLUE] =
|
||||
g_param_spec_float ("blue", NULL, NULL, 0, 1, 0, G_PARAM_READABLE);
|
||||
properties[PROP_HUE] =
|
||||
g_param_spec_int ("hue", NULL, NULL, 0, 360, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
properties[PROP_SATURATION] =
|
||||
g_param_spec_int ("saturation", NULL, NULL, 0, 100, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
properties[PROP_VALUE] =
|
||||
g_param_spec_int ("value", NULL, NULL, 0, 100, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
properties[PROP_SELECTED] =
|
||||
color_properties[PROP_HUE] =
|
||||
g_param_spec_int ("hue", NULL, NULL, 0, 360, 0, G_PARAM_READABLE);
|
||||
color_properties[PROP_SATURATION] =
|
||||
g_param_spec_int ("saturation", NULL, NULL, 0, 100, 0, G_PARAM_READABLE);
|
||||
color_properties[PROP_VALUE] =
|
||||
g_param_spec_int ("value", NULL, NULL, 0, 100, 0, G_PARAM_READABLE);
|
||||
color_properties[PROP_SELECTED] =
|
||||
g_param_spec_boolean ("selected", NULL, NULL, FALSE, G_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
||||
g_object_class_install_properties (gobject_class, N_COLOR_PROPS, color_properties);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -225,8 +297,7 @@ gtk_color_init (GtkColor *self)
|
||||
|
||||
static GtkColor *
|
||||
gtk_color_new (const char *name,
|
||||
float r, float g, float b,
|
||||
int h, int s, int v)
|
||||
float r, float g, float b)
|
||||
{
|
||||
GtkColor *result;
|
||||
GdkRGBA color = { r, g, b, 1.0 };
|
||||
@@ -234,24 +305,206 @@ gtk_color_new (const char *name,
|
||||
result = g_object_new (GTK_TYPE_COLOR,
|
||||
"name", name,
|
||||
"color", &color,
|
||||
"hue", h,
|
||||
"saturation", s,
|
||||
"value", v,
|
||||
NULL);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
create_colors_model (void)
|
||||
#define N_COLORS (256 * 256 * 256)
|
||||
|
||||
#define GTK_TYPE_COLOR_LIST (gtk_color_list_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (GtkColorList, gtk_color_list, GTK, COLOR_LIST, GObject)
|
||||
|
||||
enum {
|
||||
LIST_PROP_0,
|
||||
LIST_PROP_SIZE,
|
||||
|
||||
N_LIST_PROPS
|
||||
};
|
||||
|
||||
typedef struct _GtkColorList GtkColorList;
|
||||
struct _GtkColorList
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GtkColor **colors; /* Always N_COLORS */
|
||||
|
||||
guint size; /* How many colors we allow */
|
||||
};
|
||||
|
||||
static GType
|
||||
gtk_color_list_get_item_type (GListModel *list)
|
||||
{
|
||||
return GTK_TYPE_COLOR;
|
||||
}
|
||||
|
||||
static guint
|
||||
gtk_color_list_get_n_items (GListModel *list)
|
||||
{
|
||||
GtkColorList *self = GTK_COLOR_LIST (list);
|
||||
|
||||
return self->size;
|
||||
}
|
||||
|
||||
static guint
|
||||
position_to_color (guint position)
|
||||
{
|
||||
static guint map[] = {
|
||||
0xFF0000, 0x00FF00, 0x0000FF,
|
||||
0x7F0000, 0x007F00, 0x00007F,
|
||||
0x3F0000, 0x003F00, 0x00003F,
|
||||
0x1F0000, 0x001F00, 0x00001F,
|
||||
0x0F0000, 0x000F00, 0x00000F,
|
||||
0x070000, 0x000700, 0x000007,
|
||||
0x030000, 0x000300, 0x000003,
|
||||
0x010000, 0x000100, 0x000001
|
||||
};
|
||||
guint result, i;
|
||||
|
||||
result = 0;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (map); i++)
|
||||
{
|
||||
if (position & (1 << i))
|
||||
result ^= map[i];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
gtk_color_list_get_item (GListModel *list,
|
||||
guint position)
|
||||
{
|
||||
GtkColorList *self = GTK_COLOR_LIST (list);
|
||||
|
||||
if (position >= self->size)
|
||||
return NULL;
|
||||
|
||||
position = position_to_color (position);
|
||||
|
||||
if (self->colors[position] == NULL)
|
||||
{
|
||||
guint red, green, blue;
|
||||
|
||||
red = (position >> 16) & 0xFF;
|
||||
green = (position >> 8) & 0xFF;
|
||||
blue = position & 0xFF;
|
||||
|
||||
self->colors[position] = gtk_color_new ("", red / 255., green / 255., blue / 255.);
|
||||
}
|
||||
|
||||
return g_object_ref (self->colors[position]);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_list_model_init (GListModelInterface *iface)
|
||||
{
|
||||
iface->get_item_type = gtk_color_list_get_item_type;
|
||||
iface->get_n_items = gtk_color_list_get_n_items;
|
||||
iface->get_item = gtk_color_list_get_item;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkColorList, gtk_color_list, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL,
|
||||
gtk_color_list_model_init))
|
||||
|
||||
static GParamSpec *list_properties[N_LIST_PROPS] = { NULL, };
|
||||
|
||||
static void
|
||||
gtk_color_list_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkColorList *self = GTK_COLOR_LIST (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case LIST_PROP_SIZE:
|
||||
g_value_set_uint (value, self->size);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_list_set_size (GtkColorList *self,
|
||||
guint size)
|
||||
{
|
||||
guint old_size = self->size;
|
||||
|
||||
self->size = size;
|
||||
if (self->size > old_size)
|
||||
g_list_model_items_changed (G_LIST_MODEL (self), old_size, 0, self->size - old_size);
|
||||
else if (old_size > self->size)
|
||||
g_list_model_items_changed (G_LIST_MODEL (self), self->size, old_size - self->size, 0);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), list_properties[LIST_PROP_SIZE]);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_list_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkColorList *self = GTK_COLOR_LIST (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case LIST_PROP_SIZE:
|
||||
gtk_color_list_set_size (self, g_value_get_uint (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_list_dispose (GObject *object)
|
||||
{
|
||||
GtkColorList *self = GTK_COLOR_LIST (object);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < N_COLORS; i++)
|
||||
{
|
||||
g_clear_object (&self->colors[i]);
|
||||
}
|
||||
g_free (self->colors);
|
||||
|
||||
G_OBJECT_CLASS (gtk_color_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_list_class_init (GtkColorListClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->get_property = gtk_color_list_get_property;
|
||||
gobject_class->set_property = gtk_color_list_set_property;
|
||||
gobject_class->dispose = gtk_color_list_dispose;
|
||||
|
||||
list_properties[LIST_PROP_SIZE] =
|
||||
g_param_spec_uint ("size", NULL, NULL, 0, N_COLORS, 0, G_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_LIST_PROPS, list_properties);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_list_init (GtkColorList *self)
|
||||
{
|
||||
GListStore *result;
|
||||
GtkColor *color;
|
||||
GBytes *data;
|
||||
char **lines;
|
||||
guint i;
|
||||
|
||||
result = g_list_store_new (GTK_TYPE_COLOR);
|
||||
self->colors = g_new0 (GtkColor *, N_COLORS);
|
||||
|
||||
data = g_resources_lookup_data ("/listview_colors/color.names.txt", 0, NULL);
|
||||
lines = g_strsplit (g_bytes_get_data (data, NULL), "\n", 0);
|
||||
|
||||
@@ -260,7 +513,7 @@ create_colors_model (void)
|
||||
const char *name;
|
||||
char **fields;
|
||||
int red, green, blue;
|
||||
int h, s, v;
|
||||
guint pos;
|
||||
|
||||
if (lines[i][0] == '#' || lines[i][0] == '\0')
|
||||
continue;
|
||||
@@ -270,21 +523,24 @@ create_colors_model (void)
|
||||
red = atoi (fields[3]);
|
||||
green = atoi (fields[4]);
|
||||
blue = atoi (fields[5]);
|
||||
h = atoi (fields[9]);
|
||||
s = atoi (fields[10]);
|
||||
v = atoi (fields[11]);
|
||||
|
||||
color = gtk_color_new (name, red / 255., green / 255., blue / 255., h, s, v);
|
||||
g_list_store_append (result, color);
|
||||
g_object_unref (color);
|
||||
pos = ((red & 0xFF) << 16) | ((green & 0xFF) << 8) | blue;
|
||||
if (self->colors[pos] == NULL)
|
||||
self->colors[pos] = gtk_color_new (name, red / 255., green / 255., blue / 255.);
|
||||
|
||||
g_strfreev (fields);
|
||||
}
|
||||
g_strfreev (lines);
|
||||
|
||||
g_bytes_unref (data);
|
||||
}
|
||||
|
||||
return G_LIST_MODEL (result);
|
||||
static GListModel *
|
||||
gtk_color_list_new (guint size)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_COLOR_LIST,
|
||||
"size", size,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static char *
|
||||
@@ -295,9 +551,9 @@ get_rgb_markup (gpointer this,
|
||||
return NULL;
|
||||
|
||||
return g_strdup_printf ("<b>R:</b> %d <b>G:</b> %d <b>B:</b> %d",
|
||||
(int)(color->color->red * 255),
|
||||
(int)(color->color->green * 255),
|
||||
(int)(color->color->blue * 255));
|
||||
(int)(color->color.red * 255),
|
||||
(int)(color->color.green * 255),
|
||||
(int)(color->color.blue * 255));
|
||||
}
|
||||
|
||||
static char *
|
||||
@@ -396,29 +652,6 @@ get_title (gpointer item)
|
||||
return g_strdup ((char *)g_object_get_data (G_OBJECT (item), "title"));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
set_item (GBinding *binding,
|
||||
const GValue *from,
|
||||
GValue *to,
|
||||
gpointer data)
|
||||
{
|
||||
GObject *source = g_binding_get_source (binding);
|
||||
GListModel *model;
|
||||
guint selected;
|
||||
gpointer item;
|
||||
|
||||
selected = g_value_get_uint (from);
|
||||
|
||||
model = gtk_drop_down_get_model (GTK_DROP_DOWN (source));
|
||||
item = g_list_model_get_item (model, selected);
|
||||
|
||||
g_value_set_object (to, item);
|
||||
|
||||
g_clear_object (&item);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
create_color_grid (void)
|
||||
{
|
||||
@@ -438,7 +671,8 @@ create_color_grid (void)
|
||||
gtk_grid_view_set_max_columns (GTK_GRID_VIEW (gridview), 24);
|
||||
gtk_grid_view_set_enable_rubberband (GTK_GRID_VIEW (gridview), TRUE);
|
||||
|
||||
model = G_LIST_MODEL (gtk_sort_list_model_new (create_colors_model (), NULL));
|
||||
model = G_LIST_MODEL (gtk_sort_list_model_new (gtk_color_list_new (0), NULL));
|
||||
|
||||
selection = G_LIST_MODEL (gtk_property_selection_new (model, "selected"));
|
||||
gtk_grid_view_set_model (GTK_GRID_VIEW (gridview), selection);
|
||||
g_object_unref (selection);
|
||||
@@ -447,6 +681,80 @@ create_color_grid (void)
|
||||
return gridview;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
add_colors (GtkWidget *widget,
|
||||
GdkFrameClock *clock,
|
||||
gpointer data)
|
||||
{
|
||||
GtkColorList *colors = data;
|
||||
guint limit;
|
||||
|
||||
limit = GPOINTER_TO_UINT (g_object_get_data (data, "limit"));
|
||||
gtk_color_list_set_size (colors, MIN (limit, colors->size + MAX (1, limit / 4096)));
|
||||
|
||||
if (colors->size >= limit)
|
||||
return G_SOURCE_REMOVE;
|
||||
else
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
static void
|
||||
refill (GtkWidget *button,
|
||||
GtkColorList *colors)
|
||||
{
|
||||
gtk_color_list_set_size (colors, 0);
|
||||
gtk_widget_add_tick_callback (button, add_colors, g_object_ref (colors), g_object_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
limit_changed_cb (GtkDropDown *dropdown,
|
||||
GParamSpec *pspec,
|
||||
GtkColorList *colors)
|
||||
{
|
||||
guint new_limit, old_limit;
|
||||
|
||||
old_limit = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (colors), "limit"));
|
||||
new_limit = 1 << (3 * (gtk_drop_down_get_selected (dropdown) + 1));
|
||||
|
||||
g_object_set_data (G_OBJECT (colors), "limit", GUINT_TO_POINTER (new_limit));
|
||||
|
||||
if (old_limit == colors->size)
|
||||
gtk_color_list_set_size (colors, new_limit);
|
||||
}
|
||||
|
||||
static void
|
||||
limit_changed_cb2 (GtkDropDown *dropdown,
|
||||
GParamSpec *pspec,
|
||||
GtkLabel *label)
|
||||
{
|
||||
gpointer item;
|
||||
char *string;
|
||||
int len;
|
||||
|
||||
item = gtk_drop_down_get_selected_item (dropdown);
|
||||
g_object_get (item, "string", &string, NULL);
|
||||
len = g_utf8_strlen (string, -1);
|
||||
g_free (string);
|
||||
|
||||
gtk_label_set_max_width_chars (label, len + 2); /* for " /" */
|
||||
}
|
||||
|
||||
static void
|
||||
items_changed_cb (GListModel *model,
|
||||
guint position,
|
||||
guint removed,
|
||||
guint added,
|
||||
GtkWidget *label)
|
||||
{
|
||||
guint n = g_list_model_get_n_items (model);
|
||||
char *text;
|
||||
|
||||
text = g_strdup_printf ("%u /", n);
|
||||
gtk_label_set_label (GTK_LABEL (label), text);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
GtkWidget *
|
||||
@@ -458,11 +766,13 @@ do_listview_colors (GtkWidget *do_widget)
|
||||
GtkListItemFactory *factory;
|
||||
GListStore *factories;
|
||||
GListModel *model;
|
||||
|
||||
GtkSorter *sorter;
|
||||
GtkSorter *multi_sorter;
|
||||
GListStore *sorters;
|
||||
GtkExpression *expression;
|
||||
GtkWidget *button;
|
||||
GtkWidget *label;
|
||||
PangoAttrList *attrs;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Colors");
|
||||
@@ -475,7 +785,7 @@ do_listview_colors (GtkWidget *do_widget)
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer*)&window);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_window_set_child (GTK_WINDOW (window), sw);
|
||||
|
||||
gridview = create_color_grid ();
|
||||
@@ -483,8 +793,45 @@ do_listview_colors (GtkWidget *do_widget)
|
||||
model = gtk_grid_view_get_model (GTK_GRID_VIEW (gridview));
|
||||
g_object_get (model, "model", &model, NULL);
|
||||
|
||||
button = gtk_button_new_with_mnemonic ("_Refill");
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (refill),
|
||||
gtk_sort_list_model_get_model (GTK_SORT_LIST_MODEL (model)));
|
||||
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button);
|
||||
|
||||
label = gtk_label_new ("0 /");
|
||||
attrs = pango_attr_list_new ();
|
||||
pango_attr_list_insert (attrs, pango_attr_font_features_new ("tnum"));
|
||||
gtk_label_set_attributes (GTK_LABEL (label), attrs);
|
||||
pango_attr_list_unref (attrs);
|
||||
gtk_label_set_width_chars (GTK_LABEL (label), 6);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 1);
|
||||
g_signal_connect (gtk_grid_view_get_model (GTK_GRID_VIEW (gridview)),
|
||||
"items-changed", G_CALLBACK (items_changed_cb), label);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), label);
|
||||
|
||||
dropdown = gtk_drop_down_new ();
|
||||
gtk_drop_down_set_from_strings (GTK_DROP_DOWN (dropdown), (const char *[]) { "8", "64", "512", "4096", "32768", "262144", "2097152", "16777216", NULL });
|
||||
g_signal_connect (dropdown, "notify::selected",
|
||||
G_CALLBACK (limit_changed_cb),
|
||||
gtk_sort_list_model_get_model (GTK_SORT_LIST_MODEL (model)));
|
||||
g_signal_connect (dropdown, "notify::selected",
|
||||
G_CALLBACK (limit_changed_cb2),
|
||||
label);
|
||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (dropdown), 3); /* 4096 */
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), dropdown);
|
||||
|
||||
sorters = g_list_store_new (GTK_TYPE_SORTER);
|
||||
|
||||
/* An empty multisorter doesn't do any sorting and the sortmodel is
|
||||
* smart enough to know that.
|
||||
*/
|
||||
sorter = gtk_multi_sorter_new ();
|
||||
set_title (sorter, "Unsorted");
|
||||
g_list_store_append (sorters, sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
sorter = gtk_string_sorter_new (gtk_property_expression_new (GTK_TYPE_COLOR, NULL, "name"));
|
||||
set_title (sorter, "Name");
|
||||
g_list_store_append (sorters, sorter);
|
||||
@@ -555,11 +902,7 @@ do_listview_colors (GtkWidget *do_widget)
|
||||
gtk_drop_down_set_model (GTK_DROP_DOWN (dropdown), G_LIST_MODEL (sorters));
|
||||
g_object_unref (sorters);
|
||||
|
||||
g_object_bind_property_full (dropdown, "selected",
|
||||
model, "sorter",
|
||||
G_BINDING_SYNC_CREATE,
|
||||
set_item, NULL,
|
||||
NULL, NULL);
|
||||
g_object_bind_property (dropdown, "selected-item", model, "sorter", G_BINDING_SYNC_CREATE);
|
||||
|
||||
factories = g_list_store_new (GTK_TYPE_LIST_ITEM_FACTORY);
|
||||
|
||||
@@ -590,11 +933,7 @@ do_listview_colors (GtkWidget *do_widget)
|
||||
gtk_drop_down_set_model (GTK_DROP_DOWN (dropdown), G_LIST_MODEL (factories));
|
||||
g_object_unref (factories);
|
||||
|
||||
g_object_bind_property_full (dropdown, "selected",
|
||||
gridview, "factory",
|
||||
G_BINDING_SYNC_CREATE,
|
||||
set_item, NULL,
|
||||
NULL, NULL);
|
||||
g_object_bind_property (dropdown, "selected-item", gridview, "factory", G_BINDING_SYNC_CREATE);
|
||||
g_object_unref (model);
|
||||
}
|
||||
|
||||
|
||||
@@ -143,8 +143,9 @@ settings_key_new (GSettings *settings,
|
||||
}
|
||||
|
||||
static void
|
||||
item_value_changed (GtkListItem *item,
|
||||
GtkEntry *entry)
|
||||
item_value_changed (GtkEditableLabel *label,
|
||||
GParamSpec *pspec,
|
||||
GtkListItem *item)
|
||||
{
|
||||
SettingsKey *self;
|
||||
const char *text;
|
||||
@@ -152,8 +153,9 @@ item_value_changed (GtkListItem *item,
|
||||
GVariant *variant;
|
||||
GError *error = NULL;
|
||||
const char *name;
|
||||
char *value;
|
||||
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (label));
|
||||
|
||||
g_object_get (item, "item", &self, NULL);
|
||||
g_object_unref (self);
|
||||
@@ -166,17 +168,25 @@ item_value_changed (GtkListItem *item,
|
||||
{
|
||||
g_warning ("%s", error->message);
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
goto revert;
|
||||
}
|
||||
|
||||
if (!g_settings_schema_key_range_check (self->key, variant))
|
||||
{
|
||||
g_warning ("Not a valid value for %s", name);
|
||||
return;
|
||||
goto revert;
|
||||
}
|
||||
|
||||
g_settings_set_value (self->settings, name, variant);
|
||||
g_variant_unref (variant);
|
||||
return;
|
||||
|
||||
revert:
|
||||
gtk_widget_error_bell (GTK_WIDGET (label));
|
||||
|
||||
g_object_get (self, "value", &value, NULL);
|
||||
gtk_editable_set_text (GTK_EDITABLE (label), value);
|
||||
g_free (value);
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -113,14 +113,13 @@
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkEntry">
|
||||
<signal name="activate" handler="item_value_changed" object="GtkListItem" swapped="yes"/>
|
||||
<property name="xalign">0</property>
|
||||
<object class="GtkEditableLabel">
|
||||
<binding name="text">
|
||||
<lookup name="value" type="SettingsKey">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
<signal name="notify::label" handler="item_value_changed"/>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
|
||||
@@ -70,7 +70,6 @@ gtk_weather_info_new (GDateTime *timestamp,
|
||||
{
|
||||
result->temperature = copy_from->temperature;
|
||||
result->weather_type = copy_from->weather_type;
|
||||
g_object_unref (copy_from);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -78,13 +77,13 @@ gtk_weather_info_new (GDateTime *timestamp,
|
||||
|
||||
static GDateTime *
|
||||
parse_timestamp (const char *string,
|
||||
GTimeZone *_timezone)
|
||||
GTimeZone *_tz)
|
||||
{
|
||||
char *with_seconds;
|
||||
GDateTime *result;
|
||||
|
||||
with_seconds = g_strconcat (string, ":00", NULL);
|
||||
result = g_date_time_new_from_iso8601 (with_seconds, _timezone);
|
||||
result = g_date_time_new_from_iso8601 (with_seconds, _tz);
|
||||
g_free (with_seconds);
|
||||
|
||||
return result;
|
||||
@@ -161,6 +160,7 @@ create_weather_model (void)
|
||||
timestamp = g_date_time_new (utc, 2011, 1, 1, 0, 0, 0);
|
||||
info = gtk_weather_info_new (timestamp, NULL);
|
||||
g_list_store_append (store, info);
|
||||
g_object_unref (info);
|
||||
|
||||
for (i = 0; lines[i] != NULL && *lines[i]; i++)
|
||||
{
|
||||
@@ -176,6 +176,7 @@ create_weather_model (void)
|
||||
timestamp = new_timestamp;
|
||||
info = gtk_weather_info_new (timestamp, info);
|
||||
g_list_store_append (store, info);
|
||||
g_object_unref (info);
|
||||
}
|
||||
|
||||
info->temperature = parse_temperature (fields[1], info->temperature);
|
||||
@@ -184,6 +185,7 @@ create_weather_model (void)
|
||||
g_strfreev (fields);
|
||||
}
|
||||
|
||||
g_date_time_unref (timestamp);
|
||||
g_strfreev (lines);
|
||||
g_bytes_unref (data);
|
||||
g_time_zone_unref (utc);
|
||||
@@ -311,7 +313,7 @@ do_listview_weather (GtkWidget *do_widget)
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Weather");
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_window_set_child (GTK_WINDOW (window), sw);
|
||||
listview = create_weather_view ();
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
|
||||
|
||||
@@ -602,7 +602,7 @@ display_image (const char *resource)
|
||||
image = gtk_picture_new_for_resource (resource);
|
||||
gtk_widget_set_halign (image, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (image, GTK_ALIGN_CENTER);
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), image);
|
||||
|
||||
return sw;
|
||||
@@ -642,7 +642,7 @@ display_text (const char *resource)
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
@@ -1035,8 +1035,6 @@ activate (GApplication *app)
|
||||
listview = GTK_WIDGET (gtk_builder_get_object (builder, "listview"));
|
||||
g_signal_connect (listview, "activate", G_CALLBACK (activate_cb), window);
|
||||
|
||||
load_file (gtk_demos[0].name, gtk_demos[0].filename);
|
||||
|
||||
listmodel = create_demo_model ();
|
||||
treemodel = gtk_tree_list_model_new (FALSE,
|
||||
G_LIST_MODEL (listmodel),
|
||||
@@ -1046,8 +1044,9 @@ activate (GApplication *app)
|
||||
NULL);
|
||||
selection = gtk_single_selection_new (G_LIST_MODEL (treemodel));
|
||||
g_signal_connect (selection, "notify::selected-item", G_CALLBACK (selection_cb), NULL);
|
||||
gtk_list_view_set_model (GTK_LIST_VIEW (listview),
|
||||
G_LIST_MODEL (selection));
|
||||
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selection));
|
||||
|
||||
selection_cb (selection, NULL, NULL);
|
||||
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ do_markup (GtkWidget *do_widget)
|
||||
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);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
@@ -94,7 +94,7 @@ do_markup (GtkWidget *do_widget)
|
||||
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);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
||||
@@ -40,7 +40,7 @@ do_overlay2 (GtkWidget *do_widget)
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Decorative Overlay");
|
||||
|
||||
overlay = gtk_overlay_new ();
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
||||
@@ -443,7 +443,7 @@ do_sliding_puzzle (GtkWidget *do_widget)
|
||||
gtk_media_stream_set_muted (media, TRUE);
|
||||
gtk_media_stream_play (media);
|
||||
add_choice (choices, GDK_PAINTABLE (media));
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), choices);
|
||||
gtk_grid_attach (GTK_GRID (tweaks), sw, 0, 0, 2, 1);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ do_tabs (GtkWidget *do_widget)
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
gtk_text_buffer_set_text (buffer, "one\ttwo\tthree\nfour\tfive\tsix\nseven\teight\tnine", -1);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
||||
@@ -57,7 +57,6 @@ do_tagged_entry (GtkWidget *do_widget)
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *box;
|
||||
GtkWidget *box2;
|
||||
GtkWidget *header;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *button;
|
||||
|
||||
@@ -66,12 +65,9 @@ do_tagged_entry (GtkWidget *do_widget)
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), FALSE);
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "A tagged entry");
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
|
||||
gtk_window_set_deletable (GTK_WINDOW (window), FALSE);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Tagged Entry");
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
||||
@@ -95,13 +91,6 @@ do_tagged_entry (GtkWidget *do_widget)
|
||||
button = gtk_check_button_new_with_mnemonic ("_Spinner");
|
||||
g_signal_connect (button, "toggled", G_CALLBACK (toggle_spinner), entry);
|
||||
gtk_box_append (GTK_BOX (box2), button);
|
||||
|
||||
button = gtk_button_new_with_mnemonic ("_Done");
|
||||
gtk_widget_add_css_class (button, "suggested-action");
|
||||
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window);
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
|
||||
|
||||
gtk_window_set_default_widget (GTK_WINDOW (window), button);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
||||
@@ -156,7 +156,7 @@ create_text_view (GtkWidget *hbox,
|
||||
GtkWidget *textview;
|
||||
guint timeout;
|
||||
|
||||
swindow = gtk_scrolled_window_new (NULL, NULL);
|
||||
swindow = gtk_scrolled_window_new ();
|
||||
gtk_box_append (GTK_BOX (hbox), swindow);
|
||||
textview = gtk_text_view_new ();
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (swindow), textview);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* GtkTextBuffer. You can enable or disable undo support using
|
||||
* gtk_text_buffer_set_enable_undo().
|
||||
*
|
||||
* Use Primary+Z to undo and Primary+Shift+Z or Primary+Y to
|
||||
* Use Control+z to undo and Control+Shift+z or Control+y to
|
||||
* redo previously undone operations.
|
||||
*/
|
||||
|
||||
@@ -29,7 +29,7 @@ do_textundo (GtkWidget *do_widget)
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 450, 450);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), "TextView Undo");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Undo and Redo");
|
||||
|
||||
view = gtk_text_view_new ();
|
||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
|
||||
@@ -46,7 +46,7 @@ do_textundo (GtkWidget *do_widget)
|
||||
-1);
|
||||
gtk_text_buffer_end_irreversible_action (buffer);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
||||
@@ -494,7 +494,7 @@ do_textview (GtkWidget *do_widget)
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view1));
|
||||
view2 = gtk_text_view_new_with_buffer (buffer);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
@@ -504,7 +504,7 @@ do_textview (GtkWidget *do_widget)
|
||||
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), view1);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
@@ -590,7 +590,7 @@ easter_egg_callback (GtkWidget *button,
|
||||
g_object_unref (buffer);
|
||||
|
||||
window = gtk_window_new ();
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
||||
@@ -84,7 +84,7 @@ static TreeItem may[] =
|
||||
static TreeItem june[] =
|
||||
{
|
||||
{ "June Fathers' Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
|
||||
{ "Juneteenth (Liberation of Slaves)", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ "Juneteenth (Liberation Day)", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ "Flag Day", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
|
||||
{ NULL }
|
||||
};
|
||||
@@ -406,7 +406,7 @@ do_tree_store (GtkWidget *do_widget)
|
||||
gtk_box_append (GTK_BOX (vbox),
|
||||
gtk_label_new ("Jonathan's Holiday Card Planning Sheet"));
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<gresources>
|
||||
<gresource prefix="/org/gtk/iconbrowser/gtk">
|
||||
<file preprocess="xml-stripblanks">window.ui</file>
|
||||
<file preprocess="xml-stripblanks">menus.ui</file>
|
||||
<file>icon.list</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
#include "iconbrowsercontext.h"
|
||||
|
||||
struct _IbContext
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
char *id;
|
||||
char *name;
|
||||
char *description;
|
||||
};
|
||||
|
||||
struct _IbContextClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_ID = 1,
|
||||
PROP_NAME,
|
||||
PROP_DESCRIPTION,
|
||||
PROP_NUM_PROPERTIES
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (IbContext, ib_context, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
ib_context_init (IbContext *context)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
ib_context_finalize (GObject *object)
|
||||
{
|
||||
IbContext *context = IB_CONTEXT (object);
|
||||
|
||||
g_free (context->id);
|
||||
g_free (context->name);
|
||||
g_free (context->description);
|
||||
|
||||
G_OBJECT_CLASS (ib_context_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
ib_context_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
IbContext *context = IB_CONTEXT (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_ID:
|
||||
g_free (context->id);
|
||||
context->id = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
g_free (context->name);
|
||||
context->name = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
case PROP_DESCRIPTION:
|
||||
g_free (context->description);
|
||||
context->description = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ib_context_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
IbContext *context = IB_CONTEXT (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_ID:
|
||||
g_value_set_string (value, context->id);
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
g_value_set_string (value, context->name);
|
||||
break;
|
||||
|
||||
case PROP_DESCRIPTION:
|
||||
g_value_set_string (value, context->description);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ib_context_class_init (IbContextClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
GParamSpec *pspec;
|
||||
|
||||
object_class->finalize = ib_context_finalize;
|
||||
object_class->set_property = ib_context_set_property;
|
||||
object_class->get_property = ib_context_get_property;
|
||||
|
||||
pspec = g_param_spec_string ("id", "Id", "Id",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
g_object_class_install_property (object_class, PROP_ID, pspec);
|
||||
|
||||
pspec = g_param_spec_string ("name", "Name", "Name",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
g_object_class_install_property (object_class, PROP_NAME, pspec);
|
||||
|
||||
pspec = g_param_spec_string ("description", "Description", "Description",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
g_object_class_install_property (object_class, PROP_DESCRIPTION, pspec);
|
||||
}
|
||||
|
||||
IbContext *
|
||||
ib_context_new (const char *id,
|
||||
const char *name,
|
||||
const char *description)
|
||||
{
|
||||
return g_object_new (IB_TYPE_CONTEXT,
|
||||
"id", id,
|
||||
"name", name,
|
||||
"description", description,
|
||||
NULL);
|
||||
}
|
||||
|
||||
const char *
|
||||
ib_context_get_id (IbContext *context)
|
||||
{
|
||||
return context->id;
|
||||
}
|
||||
|
||||
const char *
|
||||
ib_context_get_name (IbContext *context)
|
||||
{
|
||||
return context->name;
|
||||
}
|
||||
|
||||
const char *
|
||||
ib_context_get_description (IbContext *context)
|
||||
{
|
||||
return context->description;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtk.h>
|
||||
|
||||
#define IB_TYPE_CONTEXT (ib_context_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (IbContext, ib_context, IB, CONTEXT, GObject)
|
||||
|
||||
IbContext *ib_context_new (const char *id,
|
||||
const char *name,
|
||||
const char *description);
|
||||
|
||||
const char *ib_context_get_id (IbContext *context);
|
||||
const char *ib_context_get_name (IbContext *context);
|
||||
const char *ib_context_get_description (IbContext *context);
|
||||
@@ -0,0 +1,228 @@
|
||||
#include "iconbrowsericon.h"
|
||||
|
||||
struct _IbIcon
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
gboolean use_symbolic;
|
||||
|
||||
char *regular_name;
|
||||
char *symbolic_name;
|
||||
char *description;
|
||||
char *context;
|
||||
};
|
||||
|
||||
struct _IbIconClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_NAME = 1,
|
||||
PROP_REGULAR_NAME,
|
||||
PROP_SYMBOLIC_NAME,
|
||||
PROP_USE_SYMBOLIC,
|
||||
PROP_DESCRIPTION,
|
||||
PROP_CONTEXT,
|
||||
PROP_NUM_PROPERTIES
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (IbIcon, ib_icon, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
ib_icon_init (IbIcon *icon)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
ib_icon_finalize (GObject *object)
|
||||
{
|
||||
IbIcon *icon = IB_ICON (object);
|
||||
|
||||
g_free (icon->regular_name);
|
||||
g_free (icon->symbolic_name);
|
||||
g_free (icon->description);
|
||||
g_free (icon->context);
|
||||
|
||||
G_OBJECT_CLASS (ib_icon_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
ib_icon_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
IbIcon *icon = IB_ICON (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_REGULAR_NAME:
|
||||
g_free (icon->regular_name);
|
||||
icon->regular_name = g_value_dup_string (value);
|
||||
if (!icon->use_symbolic)
|
||||
g_object_notify (object, "name");
|
||||
break;
|
||||
|
||||
case PROP_SYMBOLIC_NAME:
|
||||
g_free (icon->symbolic_name);
|
||||
icon->symbolic_name = g_value_dup_string (value);
|
||||
if (icon->use_symbolic)
|
||||
g_object_notify (object, "name");
|
||||
break;
|
||||
|
||||
case PROP_USE_SYMBOLIC:
|
||||
icon->use_symbolic = g_value_get_boolean (value);
|
||||
g_object_notify (object, "name");
|
||||
break;
|
||||
|
||||
case PROP_DESCRIPTION:
|
||||
g_free (icon->description);
|
||||
icon->description = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
case PROP_CONTEXT:
|
||||
g_free (icon->context);
|
||||
icon->context = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ib_icon_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
IbIcon *icon = IB_ICON (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_NAME:
|
||||
g_value_set_string (value, ib_icon_get_name (icon));
|
||||
break;
|
||||
|
||||
case PROP_REGULAR_NAME:
|
||||
g_value_set_string (value, icon->regular_name);
|
||||
break;
|
||||
|
||||
case PROP_SYMBOLIC_NAME:
|
||||
g_value_set_string (value, icon->symbolic_name);
|
||||
break;
|
||||
|
||||
case PROP_USE_SYMBOLIC:
|
||||
g_value_set_boolean (value, icon->use_symbolic);
|
||||
break;
|
||||
|
||||
case PROP_DESCRIPTION:
|
||||
g_value_set_string (value, icon->description);
|
||||
break;
|
||||
|
||||
case PROP_CONTEXT:
|
||||
g_value_set_string (value, icon->context);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ib_icon_class_init (IbIconClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
GParamSpec *pspec;
|
||||
|
||||
object_class->finalize = ib_icon_finalize;
|
||||
object_class->set_property = ib_icon_set_property;
|
||||
object_class->get_property = ib_icon_get_property;
|
||||
|
||||
pspec = g_param_spec_string ("name", "Name", "Name",
|
||||
NULL,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||
g_object_class_install_property (object_class, PROP_NAME, pspec);
|
||||
|
||||
pspec = g_param_spec_string ("regular-name", "Regular Name", "Regular Name",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
g_object_class_install_property (object_class, PROP_REGULAR_NAME, pspec);
|
||||
|
||||
pspec = g_param_spec_string ("symbolic-name", "Symbolic Name", "Symbolic Name",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
g_object_class_install_property (object_class, PROP_SYMBOLIC_NAME, pspec);
|
||||
|
||||
pspec = g_param_spec_boolean ("use-symbolic", "Use Symbolic", "Use Symbolic",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
g_object_class_install_property (object_class, PROP_USE_SYMBOLIC, pspec);
|
||||
|
||||
pspec = g_param_spec_string ("description", "Description", "Description",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
g_object_class_install_property (object_class, PROP_DESCRIPTION, pspec);
|
||||
|
||||
pspec = g_param_spec_string ("context", "Context", "Context",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
g_object_class_install_property (object_class, PROP_CONTEXT, pspec);
|
||||
}
|
||||
|
||||
IbIcon *
|
||||
ib_icon_new (const char *regular_name,
|
||||
const char *symbolic_name,
|
||||
const char *description,
|
||||
const char *context)
|
||||
{
|
||||
return g_object_new (IB_TYPE_ICON,
|
||||
"regular-name", regular_name,
|
||||
"symbolic-name", symbolic_name,
|
||||
"description", description,
|
||||
"context", context,
|
||||
NULL);
|
||||
}
|
||||
|
||||
const char *
|
||||
ib_icon_get_name (IbIcon *icon)
|
||||
{
|
||||
if (icon->use_symbolic)
|
||||
return icon->symbolic_name;
|
||||
else
|
||||
return icon->regular_name;
|
||||
}
|
||||
|
||||
const char *
|
||||
ib_icon_get_regular_name (IbIcon *icon)
|
||||
{
|
||||
return icon->regular_name;
|
||||
}
|
||||
|
||||
const char *
|
||||
ib_icon_get_symbolic_name (IbIcon *icon)
|
||||
{
|
||||
return icon->symbolic_name;
|
||||
}
|
||||
|
||||
gboolean
|
||||
ib_icon_get_use_symbolic (IbIcon *icon)
|
||||
{
|
||||
return icon->use_symbolic;
|
||||
}
|
||||
|
||||
const char *
|
||||
ib_icon_get_description (IbIcon *icon)
|
||||
{
|
||||
return icon->description;
|
||||
}
|
||||
|
||||
const char *
|
||||
ib_icon_get_context (IbIcon *icon)
|
||||
{
|
||||
return icon->context;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtk.h>
|
||||
|
||||
#define IB_TYPE_ICON (ib_icon_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (IbIcon, ib_icon, IB, ICON, GObject)
|
||||
|
||||
IbIcon *ib_icon_new (const char *regular_name,
|
||||
const char *symbolic_name,
|
||||
const char *description,
|
||||
const char *context);
|
||||
|
||||
const char *ib_icon_get_name (IbIcon *icon);
|
||||
const char *ib_icon_get_regular_name (IbIcon *icon);
|
||||
const char *ib_icon_get_symbolic_name (IbIcon *icon);
|
||||
gboolean ib_icon_get_use_symbolic (IbIcon *icon);
|
||||
const char *ib_icon_get_description (IbIcon *icon);
|
||||
const char *ib_icon_get_context (IbIcon *icon);
|
||||
@@ -1,48 +1,22 @@
|
||||
#include <string.h>
|
||||
#include "iconbrowserapp.h"
|
||||
#include "iconbrowserwin.h"
|
||||
#include "iconstore.h"
|
||||
#include "iconbrowsericon.h"
|
||||
#include "iconbrowsercontext.h"
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
/* Drag 'n Drop */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gchar *id;
|
||||
gchar *name;
|
||||
gchar *description;
|
||||
} Context;
|
||||
|
||||
static void
|
||||
context_free (gpointer data)
|
||||
{
|
||||
Context *context = data;
|
||||
|
||||
g_free (context->id);
|
||||
g_free (context->name);
|
||||
g_free (context->description);
|
||||
g_free (context);
|
||||
}
|
||||
|
||||
struct _IconBrowserWindow
|
||||
{
|
||||
GtkApplicationWindow parent;
|
||||
GHashTable *contexts;
|
||||
|
||||
GtkWidget *context_list;
|
||||
Context *current_context;
|
||||
gboolean symbolic;
|
||||
GtkWidget *symbolic_radio;
|
||||
GtkTreeModelFilter *filter_model;
|
||||
GtkWidget *details;
|
||||
|
||||
GtkListStore *store;
|
||||
GtkCellRenderer *cell;
|
||||
GtkCellRenderer *text_cell;
|
||||
GtkWidget *search;
|
||||
GtkWidget *searchbar;
|
||||
GtkWidget *searchentry;
|
||||
GtkWidget *list;
|
||||
GListModel *icon_filter_model;
|
||||
GListStore *icon_store;
|
||||
GListStore *context_store;
|
||||
GtkFilter *name_filter;
|
||||
GtkWidget *details;
|
||||
GtkWidget *image1;
|
||||
GtkWidget *image2;
|
||||
GtkWidget *image3;
|
||||
@@ -68,87 +42,6 @@ icon_browser_window_get_icon_theme (IconBrowserWindow *win)
|
||||
return gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (win)));
|
||||
}
|
||||
|
||||
static void
|
||||
search_text_changed (GtkEntry *entry, IconBrowserWindow *win)
|
||||
{
|
||||
const gchar *text;
|
||||
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
||||
|
||||
if (text[0] == '\0')
|
||||
return;
|
||||
|
||||
gtk_tree_model_filter_refilter (win->filter_model);
|
||||
}
|
||||
|
||||
static void
|
||||
set_image (GtkWidget *image, const gchar *name, gint size)
|
||||
{
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (image), name);
|
||||
gtk_image_set_pixel_size (GTK_IMAGE (image), size);
|
||||
}
|
||||
|
||||
static void
|
||||
item_activated (GtkIconView *icon_view, GtkTreePath *path, IconBrowserWindow *win)
|
||||
{
|
||||
GtkIconTheme *icon_theme = icon_browser_window_get_icon_theme (win);
|
||||
GtkTreeIter iter;
|
||||
gchar *name;
|
||||
gchar *description;
|
||||
gint column;
|
||||
|
||||
gtk_tree_model_get_iter (GTK_TREE_MODEL (win->filter_model), &iter, path);
|
||||
|
||||
if (win->symbolic)
|
||||
column = ICON_STORE_SYMBOLIC_NAME_COLUMN;
|
||||
else
|
||||
column = ICON_STORE_NAME_COLUMN;
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (win->filter_model), &iter,
|
||||
column, &name,
|
||||
ICON_STORE_DESCRIPTION_COLUMN, &description,
|
||||
-1);
|
||||
|
||||
if (name == NULL || !gtk_icon_theme_has_icon (icon_theme, name))
|
||||
{
|
||||
g_free (description);
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (win->details), name);
|
||||
set_image (win->image1, name, 8);
|
||||
set_image (win->image2, name, 16);
|
||||
set_image (win->image3, name, 18);
|
||||
set_image (win->image4, name, 24);
|
||||
set_image (win->image5, name, 32);
|
||||
set_image (win->image6, name, 48);
|
||||
set_image (win->image7, name, 64);
|
||||
if (win->symbolic)
|
||||
{
|
||||
gtk_widget_show (win->image8);
|
||||
gtk_widget_show (win->label8);
|
||||
set_image (win->image8, name, 64);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide (win->image8);
|
||||
gtk_widget_hide (win->label8);
|
||||
}
|
||||
if (description && description[0])
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (win->description), description);
|
||||
gtk_widget_show (win->description);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide (win->description);
|
||||
}
|
||||
|
||||
gtk_window_present (GTK_WINDOW (win->details));
|
||||
|
||||
g_free (name);
|
||||
g_free (description);
|
||||
}
|
||||
|
||||
static void
|
||||
add_icon (IconBrowserWindow *win,
|
||||
const gchar *name,
|
||||
@@ -158,6 +51,7 @@ add_icon (IconBrowserWindow *win,
|
||||
GtkIconTheme *icon_theme = icon_browser_window_get_icon_theme (win);
|
||||
gchar *regular_name;
|
||||
gchar *symbolic_name;
|
||||
IbIcon *icon;
|
||||
|
||||
regular_name = g_strdup (name);
|
||||
if (!gtk_icon_theme_has_icon (icon_theme, regular_name))
|
||||
@@ -173,12 +67,12 @@ add_icon (IconBrowserWindow *win,
|
||||
symbolic_name = NULL;
|
||||
}
|
||||
|
||||
gtk_list_store_insert_with_values (win->store, NULL, -1,
|
||||
ICON_STORE_NAME_COLUMN, regular_name,
|
||||
ICON_STORE_SYMBOLIC_NAME_COLUMN, symbolic_name,
|
||||
ICON_STORE_DESCRIPTION_COLUMN, description,
|
||||
ICON_STORE_CONTEXT_COLUMN, context,
|
||||
-1);
|
||||
icon = ib_icon_new (regular_name, symbolic_name, description, context);
|
||||
g_object_bind_property (win->symbolic_radio, "active",
|
||||
icon, "use-symbolic",
|
||||
G_BINDING_DEFAULT);
|
||||
g_list_store_append (win->icon_store, icon);
|
||||
g_object_unref (icon);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -187,50 +81,11 @@ add_context (IconBrowserWindow *win,
|
||||
const gchar *name,
|
||||
const gchar *description)
|
||||
{
|
||||
Context *c;
|
||||
GtkWidget *row;
|
||||
IbContext *context;
|
||||
|
||||
c = g_new (Context, 1);
|
||||
c->id = g_strdup (id);
|
||||
c->name = g_strdup (name);
|
||||
c->description = g_strdup (description);
|
||||
|
||||
g_hash_table_insert (win->contexts, c->id, c);
|
||||
|
||||
row = gtk_label_new (name);
|
||||
gtk_label_set_xalign (GTK_LABEL (row), 0);
|
||||
g_object_set_data (G_OBJECT (row), "context", c);
|
||||
gtk_widget_show (row);
|
||||
gtk_widget_set_margin_start (row, 10);
|
||||
gtk_widget_set_margin_end (row, 10);
|
||||
gtk_widget_set_margin_top (row, 10);
|
||||
gtk_widget_set_margin_bottom (row, 10);
|
||||
|
||||
gtk_list_box_insert (GTK_LIST_BOX (win->context_list), row, -1);
|
||||
|
||||
/* set the tooltip on the list box row */
|
||||
row = gtk_widget_get_parent (row);
|
||||
gtk_widget_set_tooltip_text (row, description);
|
||||
|
||||
if (win->current_context == NULL)
|
||||
win->current_context = c;
|
||||
}
|
||||
|
||||
static void
|
||||
selected_context_changed (GtkListBox *list, IconBrowserWindow *win)
|
||||
{
|
||||
GtkWidget *row;
|
||||
GtkWidget *label;
|
||||
|
||||
row = GTK_WIDGET (gtk_list_box_get_selected_row (list));
|
||||
if (row == NULL)
|
||||
return;
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (win->search), FALSE);
|
||||
|
||||
label = gtk_list_box_row_get_child (GTK_LIST_BOX_ROW (row));
|
||||
win->current_context = g_object_get_data (G_OBJECT (label), "context");
|
||||
gtk_tree_model_filter_refilter (win->filter_model);
|
||||
context = ib_context_new (id, name, description);
|
||||
g_list_store_append (win->context_store, context);
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -282,6 +137,19 @@ populate (IconBrowserWindow *win)
|
||||
g_strfreev (groups);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
filter_by_icon_name (gpointer item,
|
||||
gpointer data)
|
||||
{
|
||||
return ib_icon_get_name (IB_ICON (item)) != NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
symbolic_toggled (IconBrowserWindow *win)
|
||||
{
|
||||
gtk_filter_changed (win->name_filter, GTK_FILTER_CHANGE_DIFFERENT);
|
||||
}
|
||||
|
||||
static void
|
||||
copy_to_clipboard (GtkButton *button,
|
||||
IconBrowserWindow *win)
|
||||
@@ -292,70 +160,60 @@ copy_to_clipboard (GtkButton *button,
|
||||
gdk_clipboard_set_text (clipboard, gtk_window_get_title (GTK_WINDOW (win->details)));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
icon_visible_func (GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
static void
|
||||
set_image (GtkWidget *image, const gchar *name, gint size)
|
||||
{
|
||||
IconBrowserWindow *win = data;
|
||||
gchar *context;
|
||||
gchar *name;
|
||||
gint column;
|
||||
gboolean search;
|
||||
const gchar *search_text;
|
||||
gboolean visible;
|
||||
|
||||
search = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (win->search));
|
||||
search_text = gtk_editable_get_text (GTK_EDITABLE (win->searchentry));
|
||||
|
||||
if (win->symbolic)
|
||||
column = ICON_STORE_SYMBOLIC_NAME_COLUMN;
|
||||
else
|
||||
column = ICON_STORE_NAME_COLUMN;
|
||||
|
||||
gtk_tree_model_get (model, iter,
|
||||
column, &name,
|
||||
ICON_STORE_CONTEXT_COLUMN, &context,
|
||||
-1);
|
||||
if (!name)
|
||||
visible = FALSE;
|
||||
else if (search)
|
||||
visible = strstr (name, search_text) != NULL;
|
||||
else
|
||||
visible = win->current_context != NULL && g_strcmp0 (context, win->current_context->id) == 0;
|
||||
|
||||
g_free (name);
|
||||
g_free (context);
|
||||
|
||||
return visible;
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (image), name);
|
||||
gtk_image_set_pixel_size (GTK_IMAGE (image), size);
|
||||
}
|
||||
|
||||
static void
|
||||
symbolic_toggled (GtkToggleButton *toggle, IconBrowserWindow *win)
|
||||
item_activated (GtkGridView *view,
|
||||
guint position,
|
||||
IconBrowserWindow *win)
|
||||
{
|
||||
gint column;
|
||||
GListModel *model = gtk_grid_view_get_model (view);
|
||||
IbIcon *icon = g_list_model_get_item (model, position);
|
||||
const char *name;
|
||||
const char *description;
|
||||
gboolean symbolic;
|
||||
|
||||
win->symbolic = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (toggle));
|
||||
name = ib_icon_get_name (icon);
|
||||
description = ib_icon_get_description (icon);
|
||||
symbolic = ib_icon_get_use_symbolic (icon);
|
||||
|
||||
if (win->symbolic)
|
||||
column = ICON_STORE_SYMBOLIC_NAME_COLUMN;
|
||||
gtk_window_set_title (GTK_WINDOW (win->details), name);
|
||||
set_image (win->image1, name, 8);
|
||||
set_image (win->image2, name, 16);
|
||||
set_image (win->image3, name, 18);
|
||||
set_image (win->image4, name, 24);
|
||||
set_image (win->image5, name, 32);
|
||||
set_image (win->image6, name, 48);
|
||||
set_image (win->image7, name, 64);
|
||||
if (symbolic)
|
||||
{
|
||||
gtk_widget_show (win->image8);
|
||||
gtk_widget_show (win->label8);
|
||||
set_image (win->image8, name, 64);
|
||||
}
|
||||
else
|
||||
column = ICON_STORE_NAME_COLUMN;
|
||||
{
|
||||
gtk_widget_hide (win->image8);
|
||||
gtk_widget_hide (win->label8);
|
||||
}
|
||||
if (description && description[0])
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (win->description), description);
|
||||
gtk_widget_show (win->description);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide (win->description);
|
||||
}
|
||||
|
||||
icon_store_set_text_column (ICON_STORE (win->store), column);
|
||||
gtk_window_present (GTK_WINDOW (win->details));
|
||||
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (win->list), win->cell, "icon-name", column, NULL);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (win->list), win->text_cell, "text", column, NULL);
|
||||
|
||||
gtk_tree_model_filter_refilter (win->filter_model);
|
||||
gtk_widget_queue_draw (win->list);
|
||||
}
|
||||
|
||||
static void
|
||||
search_mode_toggled (GObject *searchbar, GParamSpec *pspec, IconBrowserWindow *win)
|
||||
{
|
||||
if (gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (searchbar)))
|
||||
gtk_list_box_unselect_all (GTK_LIST_BOX (win->context_list));
|
||||
g_object_unref (icon);
|
||||
}
|
||||
|
||||
static GdkPaintable *
|
||||
@@ -381,7 +239,10 @@ get_image_paintable (GtkImage *image)
|
||||
gtk_widget_get_direction (GTK_WIDGET (image)),
|
||||
0);
|
||||
if (icon == NULL)
|
||||
return NULL;
|
||||
{
|
||||
g_print ("no icon for %s\n", icon_name);
|
||||
return NULL;
|
||||
}
|
||||
return GDK_PAINTABLE (icon);
|
||||
case GTK_IMAGE_GICON:
|
||||
case GTK_IMAGE_EMPTY:
|
||||
@@ -419,10 +280,10 @@ drag_prepare_texture (GtkDragSource *source,
|
||||
{
|
||||
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (widget));
|
||||
|
||||
if (!GDK_IS_TEXTURE (paintable))
|
||||
if (!GDK_IS_PAINTABLE (paintable))
|
||||
return NULL;
|
||||
|
||||
return gdk_content_provider_new_typed (GDK_TYPE_TEXTURE, paintable);
|
||||
return gdk_content_provider_new_typed (GDK_TYPE_PAINTABLE, paintable);
|
||||
}
|
||||
|
||||
static GdkContentProvider *
|
||||
@@ -476,17 +337,10 @@ setup_scalable_image_dnd (GtkWidget *image)
|
||||
static void
|
||||
icon_browser_window_init (IconBrowserWindow *win)
|
||||
{
|
||||
GdkContentFormats *list;
|
||||
GtkFilter *filter;
|
||||
|
||||
gtk_widget_init_template (GTK_WIDGET (win));
|
||||
|
||||
list = gdk_content_formats_new_for_gtype (G_TYPE_STRING);
|
||||
gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (win->list),
|
||||
GDK_BUTTON1_MASK,
|
||||
list,
|
||||
GDK_ACTION_COPY);
|
||||
gdk_content_formats_unref (list);
|
||||
|
||||
setup_image_dnd (win->image1);
|
||||
setup_image_dnd (win->image2);
|
||||
setup_image_dnd (win->image3);
|
||||
@@ -496,19 +350,16 @@ icon_browser_window_init (IconBrowserWindow *win)
|
||||
setup_image_dnd (win->image7);
|
||||
setup_scalable_image_dnd (win->image8);
|
||||
|
||||
win->contexts = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, context_free);
|
||||
|
||||
gtk_tree_model_filter_set_visible_func (win->filter_model, icon_visible_func, win, NULL);
|
||||
gtk_window_set_transient_for (GTK_WINDOW (win->details), GTK_WINDOW (win));
|
||||
|
||||
g_signal_connect (win->searchbar, "notify::search-mode-enabled",
|
||||
G_CALLBACK (search_mode_toggled), win);
|
||||
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (win->searchbar),
|
||||
GTK_WIDGET (win));
|
||||
|
||||
symbolic_toggled (GTK_TOGGLE_BUTTON (win->symbolic_radio), win);
|
||||
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (win->searchbar), GTK_WIDGET (win));
|
||||
|
||||
populate (win);
|
||||
|
||||
filter = gtk_filter_list_model_get_filter (GTK_FILTER_LIST_MODEL (win->icon_filter_model));
|
||||
|
||||
win->name_filter = gtk_custom_filter_new (filter_by_icon_name, NULL, NULL);
|
||||
|
||||
gtk_multi_filter_append (GTK_MULTI_FILTER (filter), g_object_ref (win->name_filter));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -516,7 +367,7 @@ icon_browser_window_finalize (GObject *object)
|
||||
{
|
||||
IconBrowserWindow *win = ICON_BROWSER_WINDOW (object);
|
||||
|
||||
g_hash_table_unref (win->contexts);
|
||||
g_clear_object (&win->name_filter);
|
||||
|
||||
G_OBJECT_CLASS (icon_browser_window_parent_class)->finalize (object);
|
||||
}
|
||||
@@ -528,23 +379,19 @@ icon_browser_window_class_init (IconBrowserWindowClass *class)
|
||||
|
||||
object_class->finalize = icon_browser_window_finalize;
|
||||
|
||||
g_type_ensure (ICON_STORE_TYPE);
|
||||
g_type_ensure (IB_TYPE_ICON);
|
||||
g_type_ensure (IB_TYPE_CONTEXT);
|
||||
|
||||
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
|
||||
"/org/gtk/iconbrowser/gtk/window.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, context_list);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, filter_model);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, symbolic_radio);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, details);
|
||||
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, store);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, cell);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, text_cell);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, search);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, searchbar);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, searchentry);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, list);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, icon_store);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, icon_filter_model);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, context_store);
|
||||
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, details);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image1);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image2);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image3);
|
||||
@@ -556,11 +403,9 @@ icon_browser_window_class_init (IconBrowserWindowClass *class)
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, label8);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, description);
|
||||
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), search_text_changed);
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), item_activated);
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), selected_context_changed);
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), symbolic_toggled);
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), copy_to_clipboard);
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), symbolic_toggled);
|
||||
}
|
||||
|
||||
IconBrowserWindow *
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
#include "iconstore.h"
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
struct _IconStore
|
||||
{
|
||||
GtkListStore parent;
|
||||
|
||||
gint text_column;
|
||||
};
|
||||
|
||||
struct _IconStoreClass
|
||||
{
|
||||
GtkListStoreClass parent_class;
|
||||
};
|
||||
|
||||
static void icon_store_drag_source_init (GtkTreeDragSourceIface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (IconStore, icon_store, GTK_TYPE_LIST_STORE,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_SOURCE,
|
||||
icon_store_drag_source_init))
|
||||
|
||||
|
||||
static void
|
||||
icon_store_init (IconStore *store)
|
||||
{
|
||||
GType types[4] = { G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING };
|
||||
|
||||
gtk_list_store_set_column_types (GTK_LIST_STORE (store), 4, types);
|
||||
|
||||
store->text_column = ICON_STORE_NAME_COLUMN;
|
||||
}
|
||||
|
||||
static void
|
||||
icon_store_class_init (IconStoreClass *class)
|
||||
{
|
||||
}
|
||||
|
||||
static gboolean
|
||||
row_draggable (GtkTreeDragSource *drag_source,
|
||||
GtkTreePath *path)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
drag_data_delete (GtkTreeDragSource *drag_source,
|
||||
GtkTreePath *path)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
|
||||
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (drag_source), &iter, path))
|
||||
return gtk_list_store_remove (GTK_LIST_STORE (drag_source), &iter);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GdkContentProvider *
|
||||
drag_data_get (GtkTreeDragSource *drag_source,
|
||||
GtkTreePath *path)
|
||||
{
|
||||
GdkContentProvider *content;
|
||||
GtkTreeIter iter;
|
||||
gchar *text;
|
||||
|
||||
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (drag_source), &iter, path))
|
||||
return NULL;
|
||||
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (drag_source), &iter,
|
||||
ICON_STORE (drag_source)->text_column, &text,
|
||||
-1);
|
||||
|
||||
content = gdk_content_provider_new_typed (G_TYPE_STRING, text);
|
||||
|
||||
g_free (text);
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
icon_store_drag_source_init (GtkTreeDragSourceIface *iface)
|
||||
{
|
||||
iface->row_draggable = row_draggable;
|
||||
iface->drag_data_delete = drag_data_delete;
|
||||
iface->drag_data_get = drag_data_get;
|
||||
}
|
||||
|
||||
void
|
||||
icon_store_set_text_column (IconStore *store, gint text_column)
|
||||
{
|
||||
store->text_column = text_column;
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
#ifndef __ICON_STORE_H
|
||||
#define __ICON_STORE_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
|
||||
#define ICON_STORE_TYPE (icon_store_get_type ())
|
||||
#define ICON_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ICON_STORE_TYPE, IconStore))
|
||||
|
||||
|
||||
typedef struct _IconStore IconStore;
|
||||
typedef struct _IconStoreClass IconStoreClass;
|
||||
|
||||
enum {
|
||||
ICON_STORE_NAME_COLUMN,
|
||||
ICON_STORE_SYMBOLIC_NAME_COLUMN,
|
||||
ICON_STORE_DESCRIPTION_COLUMN,
|
||||
ICON_STORE_CONTEXT_COLUMN
|
||||
};
|
||||
|
||||
GType icon_store_get_type (void);
|
||||
|
||||
void icon_store_set_text_column (IconStore *store,
|
||||
gint column);
|
||||
|
||||
#endif /* __ICON_STORE_H */
|
||||
@@ -1,10 +0,0 @@
|
||||
<interface>
|
||||
<menu id="app-menu">
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Quit</attribute>
|
||||
<attribute name="action">app.quit</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
</interface>
|
||||
@@ -2,7 +2,8 @@ iconbrowser_sources = [
|
||||
'main.c',
|
||||
'iconbrowserapp.c',
|
||||
'iconbrowserwin.c',
|
||||
'iconstore.c'
|
||||
'iconbrowsericon.c',
|
||||
'iconbrowsercontext.c'
|
||||
]
|
||||
|
||||
iconbrowser_resources = gnome.compile_resources('iconbrowser_resources',
|
||||
@@ -17,14 +18,3 @@ executable('gtk4-icon-browser',
|
||||
gui_app: true,
|
||||
link_args: extra_demo_ldflags,
|
||||
install: true)
|
||||
|
||||
install_data('org.gtk.IconBrowser4.desktop', install_dir: gtk_applicationsdir)
|
||||
|
||||
# icons
|
||||
icontheme_dir = join_paths(gtk_datadir, 'icons/hicolor')
|
||||
|
||||
foreach size: ['scalable', 'symbolic']
|
||||
install_subdir('data/' + size,
|
||||
install_dir: icontheme_dir
|
||||
)
|
||||
endforeach
|
||||
|
||||
+127
-34
@@ -12,10 +12,6 @@
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
<object class="IconStore" id="store"/>
|
||||
<object class="GtkTreeModelFilter" id="filter_model">
|
||||
<property name="child-model">store</property>
|
||||
</object>
|
||||
<template class="IconBrowserWindow" parent="GtkApplicationWindow">
|
||||
<style>
|
||||
<class name="devel"/>
|
||||
@@ -42,7 +38,7 @@
|
||||
<property name="draw-indicator">0</property>
|
||||
<property name="label" translatable="yes">Symbolic</property>
|
||||
<property name="group">normal_radio</property>
|
||||
<signal name="toggled" handler="symbolic_toggled"/>
|
||||
<signal name="notify::active" handler="symbolic_toggled" swapped="yes" after="yes"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@@ -71,8 +67,44 @@
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkListBox" id="context_list">
|
||||
<signal name="selected-rows-changed" handler="selected_context_changed"/>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<child>
|
||||
<object class="GtkListView">
|
||||
<property name="model">
|
||||
<object class="GtkSingleSelection" id="context_model">
|
||||
<property name="model">
|
||||
<object class="GListStore" id="context_store">
|
||||
<property name="item-type">IbContext</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes">
|
||||
<![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0</property>
|
||||
<binding name="label">
|
||||
<lookup name="name" type="IbContext">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]>
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
@@ -88,7 +120,6 @@
|
||||
<property name="search-mode-enabled" bind-source="search" bind-property="active" bind-flags="bidirectional"/>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="searchentry">
|
||||
<signal name="search-changed" handler="search_text_changed"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@@ -99,23 +130,91 @@
|
||||
<property name="vexpand">1</property>
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<child>
|
||||
<object class="GtkIconView" id="list">
|
||||
<property name="model">filter_model</property>
|
||||
<property name="selection-mode">none</property>
|
||||
<property name="activate-on-single-click">1</property>
|
||||
<signal name="item_activated" handler="item_activated"/>
|
||||
<child>
|
||||
<object class="GtkCellRendererPixbuf" id="cell">
|
||||
<property name="xpad">10</property>
|
||||
<property name="ypad">10</property>
|
||||
<object class="GtkGridView" id="list">
|
||||
<signal name="activate" handler="item_activated"/>
|
||||
<property name="single-click-activate">1</property>
|
||||
<property name="model">
|
||||
<object class="GtkNoSelection">
|
||||
<property name="model">
|
||||
<object class="GtkFilterListModel" id="icon_filter_model">
|
||||
<property name="filter">
|
||||
<object class="GtkEveryFilter">
|
||||
<child>
|
||||
<object class="GtkStringFilter">
|
||||
<property name="expression">
|
||||
<lookup name="name" type="IbIcon"/>
|
||||
</property>
|
||||
<binding name="search">
|
||||
<lookup name="text" type="GtkSearchEntry">
|
||||
searchentry
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStringFilter">
|
||||
<property name="ignore-case">0</property>
|
||||
<property name="match-mode">exact</property>
|
||||
<property name="expression">
|
||||
<lookup name="context" type="IbIcon"/>
|
||||
</property>
|
||||
<binding name="search">
|
||||
<lookup name="id" type="IbContext">
|
||||
<lookup name="selected-item" type="GtkSingleSelection">
|
||||
context_model
|
||||
</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
<property name="model">
|
||||
<object class="GListStore" id="icon_store">
|
||||
<property name="item-type">IbIcon</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="text_cell">
|
||||
<property name="xpad">10</property>
|
||||
<property name="ypad">10</property>
|
||||
</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes">
|
||||
<![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="pixel-size">48</property>
|
||||
<binding name="icon-name">
|
||||
<lookup name="name" type="IbIcon">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<binding name="label">
|
||||
<lookup name="name" type="IbIcon">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@@ -125,14 +224,7 @@
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
<object class="GtkSizeGroup">
|
||||
<property name="mode">vertical</property>
|
||||
<widgets>
|
||||
<widget name="normal_radio"/>
|
||||
<widget name="symbolic_radio"/>
|
||||
<widget name="search"/>
|
||||
</widgets>
|
||||
</object>
|
||||
|
||||
<object class="GtkDialog" id="details">
|
||||
<property name="modal">1</property>
|
||||
<property name="use-header-bar">1</property>
|
||||
@@ -164,7 +256,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="image2">
|
||||
<object class="GtkImage" id="image2">
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">end</property>
|
||||
<accessibility>
|
||||
@@ -373,7 +465,7 @@
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label8">
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">baseline</property>
|
||||
@@ -404,7 +496,7 @@
|
||||
<signal name="clicked" handler="copy_to_clipboard"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="description">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
@@ -419,3 +511,4 @@
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
||||
|
||||
@@ -768,7 +768,7 @@ activate (GApplication *app)
|
||||
gtk_window_set_child (GTK_WINDOW (main_window), box);
|
||||
|
||||
/* Create document */
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
|
||||
@@ -408,6 +408,8 @@ activate_print (GSimpleAction *action,
|
||||
g_signal_connect (op, "draw-page", G_CALLBACK (print_operation_page), window);
|
||||
g_signal_connect (op, "done", G_CALLBACK (print_operation_done), NULL);
|
||||
|
||||
gtk_print_operation_set_embed_page_setup (op, TRUE);
|
||||
|
||||
res = gtk_print_operation_run (op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, window, NULL);
|
||||
|
||||
if (res == GTK_PRINT_OPERATION_RESULT_IN_PROGRESS)
|
||||
|
||||
@@ -200,18 +200,18 @@
|
||||
</row>
|
||||
</data>
|
||||
</object>
|
||||
<object class="GtkStringList" id="name_list">
|
||||
<items>
|
||||
<item>Andrea</item>
|
||||
<item>Otto</item>
|
||||
<item>Orville</item>
|
||||
<item>Benjamin</item>
|
||||
</items>
|
||||
</object>
|
||||
<object class="GtkEntryCompletion" id="name_completion">
|
||||
<property name="model">liststore1</property>
|
||||
<property name="text-column">2</property>
|
||||
<property name="model">name_list</property>
|
||||
<property name="inline-completion">1</property>
|
||||
<property name="popup-single-match">0</property>
|
||||
<property name="inline-selection">1</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="text">2</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkListStore" id="lrmodel">
|
||||
<columns>
|
||||
|
||||
@@ -207,8 +207,6 @@ GdkModifierType
|
||||
GDK_MODIFIER_MASK
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_surface_get_support_multidevice
|
||||
gdk_surface_set_support_multidevice
|
||||
gdk_surface_get_device_cursor
|
||||
gdk_surface_set_device_cursor
|
||||
|
||||
@@ -357,17 +355,13 @@ gdk_device_get_name
|
||||
gdk_device_get_vendor_id
|
||||
gdk_device_get_product_id
|
||||
gdk_device_get_source
|
||||
gdk_device_set_key
|
||||
gdk_device_get_key
|
||||
gdk_device_set_axis_use
|
||||
gdk_device_get_axis_use
|
||||
gdk_device_get_associated_device
|
||||
gdk_device_list_slave_devices
|
||||
gdk_device_list_physical_devices
|
||||
gdk_device_get_device_type
|
||||
gdk_device_get_display
|
||||
gdk_device_get_has_cursor
|
||||
gdk_device_get_n_axes
|
||||
gdk_device_get_n_keys
|
||||
gdk_device_get_axes
|
||||
gdk_device_get_seat
|
||||
gdk_device_get_num_touches
|
||||
@@ -385,8 +379,6 @@ gdk_device_get_surface_at_position
|
||||
GdkTimeCoord
|
||||
gdk_device_get_axis
|
||||
gdk_device_get_axis_names
|
||||
gdk_device_get_axis_value
|
||||
gdk_device_get_last_event_surface
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_device_tool_get_serial
|
||||
@@ -447,8 +439,7 @@ gdk_seat_get_display
|
||||
gdk_seat_get_capabilities
|
||||
gdk_seat_get_pointer
|
||||
gdk_seat_get_keyboard
|
||||
gdk_seat_get_slaves
|
||||
gdk_seat_get_master_pointers
|
||||
gdk_seat_get_physical_devices
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GDK_SEAT
|
||||
@@ -498,6 +489,7 @@ gdk_event_get_modifier_state
|
||||
gdk_event_get_position
|
||||
gdk_event_get_axes
|
||||
gdk_event_get_axis
|
||||
gdk_event_get_history
|
||||
gdk_event_get_pointer_emulated
|
||||
gdk_event_triggers_context_menu
|
||||
gdk_button_event_get_button
|
||||
@@ -529,7 +521,6 @@ gdk_touchpad_event_get_pinch_scale
|
||||
gdk_pad_event_get_axis_value
|
||||
gdk_pad_event_get_button
|
||||
gdk_pad_event_get_group_mode
|
||||
gdk_motion_event_get_history
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_events_get_angle
|
||||
|
||||
@@ -74,7 +74,9 @@
|
||||
<xi:include href="xml/gtkmultiselection.xml" />
|
||||
<xi:include href="xml/gtkpropertyselection.xml" />
|
||||
</section>
|
||||
<xi:include href="xml/gtkbookmarklist.xml" />
|
||||
<xi:include href="xml/gtkdirectorylist.xml" />
|
||||
<xi:include href="xml/gtkstringlist.xml" />
|
||||
</chapter>
|
||||
|
||||
<chapter id="ListContainers">
|
||||
@@ -216,6 +218,7 @@
|
||||
<xi:include href="xml/gtkspinbutton.xml" />
|
||||
<xi:include href="xml/gtksearchentry.xml" />
|
||||
<xi:include href="xml/gtksearchbar.xml" />
|
||||
<xi:include href="xml/gtkeditablelabel.xml" />
|
||||
</chapter>
|
||||
|
||||
<chapter id="TextWidgetObjects">
|
||||
|
||||
@@ -409,6 +409,8 @@ gtk_multi_selection_get_type
|
||||
<TITLE>GtkPropertySelection</TITLE>
|
||||
GtkPropertySelection
|
||||
gtk_property_selection_new
|
||||
gtk_property_selection_get_model
|
||||
gtk_property_selection_get_property
|
||||
<SUBSECTION Private>
|
||||
gtk_property_selection_get_type
|
||||
</SECTION>
|
||||
@@ -980,6 +982,18 @@ GTK_EDITABLE_GET_IFACE
|
||||
gtk_editable_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkeditablelabel</FILE>
|
||||
<TITLE>GtkEditableLabel</TITLE>
|
||||
GtkEditableLabel
|
||||
gtk_editable_label_new
|
||||
gtk_editable_label_get_editing
|
||||
gtk_editable_label_start_editing
|
||||
gtk_editable_label_stop_editing
|
||||
<SUBSECTION Private>
|
||||
gtk_editable_label_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtktext</FILE>
|
||||
<TITLE>GtkText</TITLE>
|
||||
@@ -1148,24 +1162,20 @@ gtk_entry_buffer_get_type
|
||||
<FILE>gtkentrycompletion</FILE>
|
||||
<TITLE>GtkEntryCompletion</TITLE>
|
||||
GtkEntryCompletion
|
||||
GtkEntryCompletionMatchFunc
|
||||
gtk_entry_completion_new
|
||||
gtk_entry_completion_new_with_area
|
||||
gtk_entry_completion_get_entry
|
||||
gtk_entry_completion_set_model
|
||||
gtk_entry_completion_get_model
|
||||
gtk_entry_completion_set_match_func
|
||||
gtk_entry_completion_set_expression
|
||||
gtk_entry_completion_get_expression
|
||||
gtk_entry_completion_set_factory
|
||||
gtk_entry_completion_get_factory
|
||||
gtk_entry_completion_set_minimum_key_length
|
||||
gtk_entry_completion_get_minimum_key_length
|
||||
gtk_entry_completion_compute_prefix
|
||||
gtk_entry_completion_complete
|
||||
gtk_entry_completion_get_completion_prefix
|
||||
gtk_entry_completion_insert_prefix
|
||||
gtk_entry_completion_insert_action_text
|
||||
gtk_entry_completion_insert_action_markup
|
||||
gtk_entry_completion_delete_action
|
||||
gtk_entry_completion_set_text_column
|
||||
gtk_entry_completion_get_text_column
|
||||
gtk_entry_completion_set_inline_completion
|
||||
gtk_entry_completion_get_inline_completion
|
||||
gtk_entry_completion_set_inline_selection
|
||||
@@ -1400,6 +1410,21 @@ GTK_DIRECTORY_LIST_GET_CLASS
|
||||
gtk_directory_list_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkbookmarklist</FILE>
|
||||
<TITLE>GtkBookmarkList</TITLE>
|
||||
GtkBookmarkList
|
||||
gtk_bookmark_list_new
|
||||
gtk_bookmark_list_get_filename
|
||||
gtk_bookmark_list_set_attributes
|
||||
gtk_bookmark_list_get_attributes
|
||||
gtk_bookmark_list_set_io_priority
|
||||
gtk_bookmark_list_get_io_priority
|
||||
gtk_bookmark_list_is_loading
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_BOOKMARK_LIST
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkfilter</FILE>
|
||||
<TITLE>GtkFilter</TITLE>
|
||||
@@ -4472,11 +4497,8 @@ gtk_widget_has_visible_focus
|
||||
gtk_widget_is_drawable
|
||||
gtk_widget_set_receives_default
|
||||
gtk_widget_get_receives_default
|
||||
gtk_widget_set_support_multidevice
|
||||
gtk_widget_get_support_multidevice
|
||||
gtk_widget_get_realized
|
||||
gtk_widget_get_mapped
|
||||
gtk_widget_device_is_shadowed
|
||||
gtk_widget_get_opacity
|
||||
gtk_widget_set_opacity
|
||||
gtk_widget_get_overflow
|
||||
@@ -6031,6 +6053,16 @@ gtk_header_bar_get_type
|
||||
GtkStackPage
|
||||
gtk_stack_page_get_visible
|
||||
gtk_stack_page_set_visible
|
||||
gtk_stack_page_get_title
|
||||
gtk_stack_page_set_title
|
||||
gtk_stack_page_get_name
|
||||
gtk_stack_page_set_name
|
||||
gtk_stack_page_get_needs_attention
|
||||
gtk_stack_page_set_needs_attention
|
||||
gtk_stack_page_get_use_underline
|
||||
gtk_stack_page_set_use_underline
|
||||
gtk_stack_page_get_icon_name
|
||||
gtk_stack_page_set_icon_name
|
||||
gtk_stack_page_get_child
|
||||
GtkStack
|
||||
gtk_stack_new
|
||||
@@ -7501,6 +7533,7 @@ gtk_drop_down_set_model
|
||||
gtk_drop_down_get_model
|
||||
gtk_drop_down_set_selected
|
||||
gtk_drop_down_get_selected
|
||||
gtk_drop_down_get_selected_item
|
||||
gtk_drop_down_set_factory
|
||||
gtk_drop_down_get_factory
|
||||
gtk_drop_down_set_list_factory
|
||||
@@ -7514,3 +7547,17 @@ GTK_TYPE_DROP_DOWN
|
||||
<SUBSECTION Private>
|
||||
gtk_drop_down_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkstringlist</FILE>
|
||||
<TITLE>GtkStringList</TITLE>
|
||||
GtkStringList
|
||||
gtk_string_list_new
|
||||
gtk_string_list_append
|
||||
gtk_string_list_take
|
||||
gtk_string_list_remove
|
||||
gtk_string_list_splice
|
||||
gtk_string_list_get_string
|
||||
GtkStringObject
|
||||
gtk_string_object_get_string
|
||||
</SECTION>
|
||||
|
||||
@@ -18,6 +18,7 @@ gtk_aspect_frame_get_type
|
||||
gtk_assistant_get_type
|
||||
gtk_assistant_page_get_type
|
||||
gtk_bin_layout_get_type
|
||||
gtk_bookmark_list_get_type
|
||||
gtk_box_get_type
|
||||
gtk_box_layout_get_type
|
||||
gtk_buildable_get_type
|
||||
@@ -68,6 +69,7 @@ gtk_drop_target_get_type
|
||||
gtk_drop_target_async_get_type
|
||||
gtk_drop_down_get_type
|
||||
gtk_editable_get_type
|
||||
gtk_editable_label_get_type
|
||||
gtk_emoji_chooser_get_type
|
||||
gtk_entry_buffer_get_type
|
||||
gtk_entry_completion_get_type
|
||||
@@ -208,6 +210,8 @@ gtk_stack_sidebar_get_type
|
||||
gtk_stack_switcher_get_type
|
||||
gtk_statusbar_get_type
|
||||
gtk_string_filter_get_type
|
||||
gtk_string_list_get_type
|
||||
gtk_string_object_get_type
|
||||
gtk_string_sorter_get_type
|
||||
gtk_switch_get_type
|
||||
gtk_level_bar_get_type
|
||||
|
||||
@@ -5,7 +5,7 @@ in what happens to translate a key press or mouse motion of the users into a
|
||||
change of a GTK widget, you should read this chapter. This knowledge will also
|
||||
be useful if you decide to implement your own widgets.
|
||||
|
||||
Devices and events
|
||||
## Devices and events
|
||||
|
||||
The most basic input devices that every computer user has interacted with are
|
||||
keyboards and mice; beyond these, GTK supports touchpads, touchscreens and
|
||||
@@ -13,14 +13,14 @@ more exotic input devices such as graphics tablets. Inside GTK, every such
|
||||
input device is represented by a #GdkDevice object.
|
||||
|
||||
To simplify dealing with the variability between these input devices, GTK
|
||||
has a concept of master and slave devices. The concrete physical devices that
|
||||
has a concept of logical and physical devices. The concrete physical devices that
|
||||
have many different characteristics (mice may have 2 or 3 or 8 buttons,
|
||||
keyboards have different layouts and may or may not have a separate number
|
||||
block, etc) are represented as slave devices. Each slave device is
|
||||
associated with a virtual master device. Master devices always come in
|
||||
block, etc) are represented as physical devices. Each physical device is
|
||||
associated with a virtual logical device. Logical devices always come in
|
||||
pointer/keyboard pairs - you can think of such a pair as a 'seat'.
|
||||
|
||||
GTK widgets generally deal with the master devices, and thus can be used
|
||||
GTK widgets generally deal with the logical devices, and thus can be used
|
||||
with any pointing device or keyboard.
|
||||
|
||||
When a user interacts with an input device (e.g. moves a mouse or presses
|
||||
|
||||
@@ -881,7 +881,7 @@ create_scrolledwindow (void)
|
||||
{
|
||||
GtkWidget *scrolledwin, *label;
|
||||
|
||||
scrolledwin = gtk_scrolled_window_new (NULL, NULL);
|
||||
scrolledwin = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwin),
|
||||
GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
|
||||
label = gtk_label_new ("Scrolled Window");
|
||||
|
||||
@@ -258,7 +258,7 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
|
||||
basename = g_file_get_basename (file);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
scrolled = gtk_scrolled_window_new ();
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
|
||||
@@ -43,7 +43,7 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
|
||||
basename = g_file_get_basename (file);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
scrolled = gtk_scrolled_window_new ();
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
|
||||
@@ -53,7 +53,7 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
|
||||
basename = g_file_get_basename (file);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
scrolled = gtk_scrolled_window_new ();
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
|
||||
@@ -76,7 +76,7 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
|
||||
basename = g_file_get_basename (file);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
scrolled = gtk_scrolled_window_new ();
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
|
||||
@@ -77,7 +77,7 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
|
||||
basename = g_file_get_basename (file);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
scrolled = gtk_scrolled_window_new ();
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
|
||||
@@ -130,7 +130,7 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
|
||||
basename = g_file_get_basename (file);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
scrolled = gtk_scrolled_window_new ();
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
|
||||
@@ -222,7 +222,7 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
|
||||
basename = g_file_get_basename (file);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
scrolled = gtk_scrolled_window_new ();
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
|
||||
@@ -256,7 +256,7 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
|
||||
basename = g_file_get_basename (file);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
scrolled = gtk_scrolled_window_new ();
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
|
||||
@@ -252,7 +252,7 @@ new_window (GApplication *app,
|
||||
|
||||
gtk_grid_attach (GTK_GRID (grid), toolbar, 0, 0, 1, 1);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
scrolled = gtk_scrolled_window_new ();
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ new_window (GApplication *app,
|
||||
grid = gtk_grid_new ();
|
||||
gtk_window_set_child (GTK_WINDOW (window), grid);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
scrolled = gtk_scrolled_window_new ();
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ new_window (GApplication *app,
|
||||
overlay = gtk_overlay_new ();
|
||||
gtk_window_set_child (GTK_WINDOW (window), overlay);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
scrolled = gtk_scrolled_window_new ();
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
|
||||
@@ -73,8 +73,8 @@ gdk_broadway_device_init (GdkBroadwayDevice *device_core)
|
||||
|
||||
device = GDK_DEVICE (device_core);
|
||||
|
||||
_gdk_device_add_axis (device, NULL, GDK_AXIS_X, 0, 0, 1);
|
||||
_gdk_device_add_axis (device, NULL, GDK_AXIS_Y, 0, 0, 1);
|
||||
_gdk_device_add_axis (device, GDK_AXIS_X, 0, 0, 1);
|
||||
_gdk_device_add_axis (device, GDK_AXIS_Y, 0, 0, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -157,7 +157,7 @@ _gdk_broadway_surface_grab_check_unmap (GdkSurface *surface,
|
||||
|
||||
seat = gdk_display_get_default_seat (display);
|
||||
|
||||
devices = gdk_seat_get_slaves (seat, GDK_SEAT_CAPABILITY_ALL);
|
||||
devices = gdk_seat_get_physical_devices (seat, GDK_SEAT_CAPABILITY_ALL);
|
||||
devices = g_list_prepend (devices, gdk_seat_get_keyboard (seat));
|
||||
devices = g_list_prepend (devices, gdk_seat_get_pointer (seat));
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ create_core_pointer (GdkDisplay *display)
|
||||
{
|
||||
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
|
||||
"name", "Core Pointer",
|
||||
"type", GDK_DEVICE_TYPE_MASTER,
|
||||
"type", GDK_DEVICE_TYPE_LOGICAL,
|
||||
"source", GDK_SOURCE_MOUSE,
|
||||
"has-cursor", TRUE,
|
||||
"display", display,
|
||||
@@ -131,7 +131,7 @@ create_core_keyboard (GdkDisplay *display)
|
||||
{
|
||||
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
|
||||
"name", "Core Keyboard",
|
||||
"type", GDK_DEVICE_TYPE_MASTER,
|
||||
"type", GDK_DEVICE_TYPE_LOGICAL,
|
||||
"source", GDK_SOURCE_KEYBOARD,
|
||||
"has-cursor", FALSE,
|
||||
"display", display,
|
||||
@@ -143,7 +143,7 @@ create_pointer (GdkDisplay *display)
|
||||
{
|
||||
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
|
||||
"name", "Pointer",
|
||||
"type", GDK_DEVICE_TYPE_SLAVE,
|
||||
"type", GDK_DEVICE_TYPE_PHYSICAL,
|
||||
"source", GDK_SOURCE_MOUSE,
|
||||
"has-cursor", TRUE,
|
||||
"display", display,
|
||||
@@ -155,7 +155,7 @@ create_keyboard (GdkDisplay *display)
|
||||
{
|
||||
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
|
||||
"name", "Keyboard",
|
||||
"type", GDK_DEVICE_TYPE_SLAVE,
|
||||
"type", GDK_DEVICE_TYPE_PHYSICAL,
|
||||
"source", GDK_SOURCE_KEYBOARD,
|
||||
"has-cursor", FALSE,
|
||||
"display", display,
|
||||
@@ -167,7 +167,7 @@ create_touchscreen (GdkDisplay *display)
|
||||
{
|
||||
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
|
||||
"name", "Touchscreen",
|
||||
"type", GDK_DEVICE_TYPE_SLAVE,
|
||||
"type", GDK_DEVICE_TYPE_PHYSICAL,
|
||||
"source", GDK_SOURCE_TOUCHSCREEN,
|
||||
"has-cursor", FALSE,
|
||||
"display", display,
|
||||
@@ -196,15 +196,15 @@ _gdk_broadway_display_open (const gchar *display_name)
|
||||
_gdk_device_set_associated_device (broadway_display->pointer, broadway_display->core_pointer);
|
||||
_gdk_device_set_associated_device (broadway_display->keyboard, broadway_display->core_keyboard);
|
||||
_gdk_device_set_associated_device (broadway_display->touchscreen, broadway_display->core_pointer);
|
||||
_gdk_device_add_slave (broadway_display->core_pointer, broadway_display->touchscreen);
|
||||
_gdk_device_add_physical_device (broadway_display->core_pointer, broadway_display->touchscreen);
|
||||
|
||||
seat = gdk_seat_default_new_for_master_pair (broadway_display->core_pointer,
|
||||
broadway_display->core_keyboard);
|
||||
seat = gdk_seat_default_new_for_logical_pair (broadway_display->core_pointer,
|
||||
broadway_display->core_keyboard);
|
||||
|
||||
gdk_display_add_seat (display, seat);
|
||||
gdk_seat_default_add_slave (GDK_SEAT_DEFAULT (seat), broadway_display->pointer);
|
||||
gdk_seat_default_add_slave (GDK_SEAT_DEFAULT (seat), broadway_display->keyboard);
|
||||
gdk_seat_default_add_slave (GDK_SEAT_DEFAULT (seat), broadway_display->touchscreen);
|
||||
gdk_seat_default_add_physical_device (GDK_SEAT_DEFAULT (seat), broadway_display->pointer);
|
||||
gdk_seat_default_add_physical_device (GDK_SEAT_DEFAULT (seat), broadway_display->keyboard);
|
||||
gdk_seat_default_add_physical_device (GDK_SEAT_DEFAULT (seat), broadway_display->touchscreen);
|
||||
g_object_unref (seat);
|
||||
|
||||
gdk_event_init (display);
|
||||
|
||||
@@ -1107,13 +1107,12 @@ create_moveresize_surface (MoveResizeData *mv_resize,
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
status = gdk_device_grab (pointer,
|
||||
mv_resize->moveresize_emulation_surface,
|
||||
GDK_OWNERSHIP_APPLICATION,
|
||||
FALSE,
|
||||
GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_POINTER_MOTION_MASK,
|
||||
NULL,
|
||||
timestamp);
|
||||
mv_resize->moveresize_emulation_surface,
|
||||
FALSE,
|
||||
GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_POINTER_MOTION_MASK,
|
||||
NULL,
|
||||
timestamp);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
|
||||
if (status != GDK_GRAB_SUCCESS)
|
||||
|
||||
+1
-1
@@ -1290,7 +1290,7 @@ gdk_clipboard_set_valist (GdkClipboard *clipboard,
|
||||
g_warning ("%s: %s", G_STRLOC, error);
|
||||
g_free (error);
|
||||
/* we purposely leak the value here, it might not be
|
||||
* in a sane state if an error condition occoured
|
||||
* in a sane state if an error condition occurred
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ gdk_content_provider_new_typed (GType type,
|
||||
g_warning ("%s: %s", G_STRLOC, error);
|
||||
g_free (error);
|
||||
/* we purposely leak the value here, it might not be
|
||||
* in a sane state if an error condition occoured
|
||||
* in a sane state if an error condition occurred
|
||||
*/
|
||||
}
|
||||
va_end (args);
|
||||
|
||||
+72
-326
@@ -36,7 +36,7 @@
|
||||
* as a keyboard, a mouse, a touchpad, etc.
|
||||
*
|
||||
* See the #GdkSeat documentation for more information
|
||||
* about the various kinds of master and slave devices, and their
|
||||
* about the various kinds of logical and physical devices, and their
|
||||
* relationships.
|
||||
*/
|
||||
|
||||
@@ -51,9 +51,7 @@ typedef struct _GdkAxisInfo GdkAxisInfo;
|
||||
|
||||
struct _GdkAxisInfo
|
||||
{
|
||||
char *label;
|
||||
GdkAxisUse use;
|
||||
|
||||
gdouble min_axis;
|
||||
gdouble max_axis;
|
||||
gdouble min_value;
|
||||
@@ -154,15 +152,16 @@ gdk_device_class_init (GdkDeviceClass *klass)
|
||||
P_("Device type"),
|
||||
P_("Device role in the device manager"),
|
||||
GDK_TYPE_DEVICE_TYPE,
|
||||
GDK_DEVICE_TYPE_MASTER,
|
||||
GDK_DEVICE_TYPE_LOGICAL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkDevice:associated-device:
|
||||
*
|
||||
* Associated pointer or keyboard with this device, if any. Devices of type #GDK_DEVICE_TYPE_MASTER
|
||||
* always come in keyboard/pointer pairs. Other device types will have a %NULL associated device.
|
||||
* Associated pointer or keyboard with this device, if any. Devices of
|
||||
* type #GDK_DEVICE_TYPE_LOGICAL always come in keyboard/pointer pairs.
|
||||
* Other device types will have a %NULL associated device.
|
||||
*/
|
||||
device_props[PROP_ASSOCIATED_DEVICE] =
|
||||
g_param_spec_object ("associated-device",
|
||||
@@ -189,7 +188,7 @@ gdk_device_class_init (GdkDeviceClass *klass)
|
||||
* GdkDevice:has-cursor:
|
||||
*
|
||||
* Whether the device is represented by a cursor on the screen. Devices of type
|
||||
* %GDK_DEVICE_TYPE_MASTER will have %TRUE here.
|
||||
* %GDK_DEVICE_TYPE_LOGICAL will have %TRUE here.
|
||||
*/
|
||||
device_props[PROP_HAS_CURSOR] =
|
||||
g_param_spec_boolean ("has-cursor",
|
||||
@@ -335,11 +334,11 @@ gdk_device_class_init (GdkDeviceClass *klass)
|
||||
*
|
||||
* The ::changed signal is emitted either when the #GdkDevice
|
||||
* has changed the number of either axes or keys. For example
|
||||
* In X this will normally happen when the slave device routing
|
||||
* events through the master device changes (for example, user
|
||||
* switches from the USB mouse to a tablet), in that case the
|
||||
* master device will change to reflect the new slave device
|
||||
* axes and keys.
|
||||
* on X11 this will normally happen when the physical device
|
||||
* routing events through the logical device changes (for
|
||||
* example, user switches from the USB mouse to a tablet); in
|
||||
* that case the logical device will change to reflect the axes
|
||||
* and keys on the new physical device.
|
||||
*/
|
||||
signals[CHANGED] =
|
||||
g_signal_new (g_intern_static_string ("changed"),
|
||||
@@ -366,19 +365,10 @@ gdk_device_class_init (GdkDeviceClass *klass)
|
||||
G_TYPE_NONE, 1, GDK_TYPE_DEVICE_TOOL);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_device_axis_info_clear (gpointer data)
|
||||
{
|
||||
GdkAxisInfo *info = data;
|
||||
|
||||
g_free (info->label);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_device_init (GdkDevice *device)
|
||||
{
|
||||
device->axes = g_array_new (FALSE, TRUE, sizeof (GdkAxisInfo));
|
||||
g_array_set_clear_func (device->axes, gdk_device_axis_info_clear);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -393,7 +383,6 @@ gdk_device_finalize (GObject *object)
|
||||
}
|
||||
|
||||
g_clear_pointer (&device->name, g_free);
|
||||
g_clear_pointer (&device->keys, g_free);
|
||||
g_clear_pointer (&device->vendor_id, g_free);
|
||||
g_clear_pointer (&device->product_id, g_free);
|
||||
|
||||
@@ -406,14 +395,14 @@ gdk_device_dispose (GObject *object)
|
||||
GdkDevice *device = GDK_DEVICE (object);
|
||||
GdkDevice *associated = device->associated;
|
||||
|
||||
if (associated && device->type == GDK_DEVICE_TYPE_SLAVE)
|
||||
_gdk_device_remove_slave (associated, device);
|
||||
if (associated && device->type == GDK_DEVICE_TYPE_PHYSICAL)
|
||||
_gdk_device_remove_physical_device (associated, device);
|
||||
|
||||
if (associated)
|
||||
{
|
||||
device->associated = NULL;
|
||||
|
||||
if (device->type == GDK_DEVICE_TYPE_MASTER &&
|
||||
if (device->type == GDK_DEVICE_TYPE_LOGICAL &&
|
||||
associated->associated == device)
|
||||
_gdk_device_set_associated_device (associated, NULL);
|
||||
|
||||
@@ -551,21 +540,23 @@ gdk_device_get_property (GObject *object,
|
||||
* the axes of @device in, or %NULL.
|
||||
* @mask: (optional) (out): location to store the modifiers, or %NULL.
|
||||
*
|
||||
* Gets the current state of a pointer device relative to @surface. As a slave
|
||||
* device’s coordinates are those of its master pointer, this
|
||||
* function may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
|
||||
* unless there is an ongoing grab on them. See gdk_seat_grab().
|
||||
* Gets the current state of a pointer device relative to @surface. As a
|
||||
* physical device’s coordinates are those of its logical pointer, this
|
||||
* function may not be called on devices of type %GDK_DEVICE_TYPE_PHYSICAL,
|
||||
* unless there is an ongoing grab on them.
|
||||
*
|
||||
* See also: gdk_seat_grab().
|
||||
*/
|
||||
void
|
||||
gdk_device_get_state (GdkDevice *device,
|
||||
GdkSurface *surface,
|
||||
GdkSurface *surface,
|
||||
gdouble *axes,
|
||||
GdkModifierType *mask)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DEVICE (device));
|
||||
g_return_if_fail (device->source != GDK_SOURCE_KEYBOARD);
|
||||
g_return_if_fail (GDK_IS_SURFACE (surface));
|
||||
g_return_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_SLAVE ||
|
||||
g_return_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_PHYSICAL ||
|
||||
gdk_display_device_is_grabbed (gdk_device_get_display (device), device));
|
||||
|
||||
if (GDK_DEVICE_GET_CLASS (device)->get_state)
|
||||
@@ -587,7 +578,7 @@ gdk_device_get_position (GdkDevice *device,
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DEVICE (device));
|
||||
g_return_if_fail (device->source != GDK_SOURCE_KEYBOARD);
|
||||
g_return_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_SLAVE ||
|
||||
g_return_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_PHYSICAL ||
|
||||
gdk_display_device_is_grabbed (gdk_device_get_display (device), device));
|
||||
|
||||
_gdk_device_query_state (device, NULL, NULL, x, y, NULL);
|
||||
@@ -605,8 +596,8 @@ gdk_device_get_position (GdkDevice *device,
|
||||
* double precision. Returns %NULL if the surface tree under @device is not known to GDK (for example,
|
||||
* belongs to another application).
|
||||
*
|
||||
* As a slave device coordinates are those of its master pointer, This
|
||||
* function may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
|
||||
* As a physical device coordinates are those of its logical pointer, this
|
||||
* function may not be called on devices of type %GDK_DEVICE_TYPE_PHYSICAL,
|
||||
* unless there is an ongoing grab on them, see gdk_seat_grab().
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the #GdkSurface under the
|
||||
@@ -622,7 +613,7 @@ gdk_device_get_surface_at_position (GdkDevice *device,
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
|
||||
g_return_val_if_fail (device->source != GDK_SOURCE_KEYBOARD, NULL);
|
||||
g_return_val_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_SLAVE ||
|
||||
g_return_val_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_PHYSICAL ||
|
||||
gdk_display_device_is_grabbed (gdk_device_get_display (device), device), NULL);
|
||||
|
||||
surface = _gdk_device_surface_at_position (device, &tmp_x, &tmp_y, NULL);
|
||||
@@ -684,79 +675,6 @@ gdk_device_get_source (GdkDevice *device)
|
||||
return device->source;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_get_n_keys:
|
||||
* @device: a #GdkDevice
|
||||
*
|
||||
* Returns the number of keys the device currently has.
|
||||
*
|
||||
* Returns: the number of keys.
|
||||
**/
|
||||
gint
|
||||
gdk_device_get_n_keys (GdkDevice *device)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DEVICE (device), 0);
|
||||
|
||||
return device->num_keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_get_key:
|
||||
* @device: a #GdkDevice.
|
||||
* @index_: the index of the macro button to get.
|
||||
* @keyval: (out): return value for the keyval.
|
||||
* @modifiers: (out): return value for modifiers.
|
||||
*
|
||||
* If @index_ has a valid keyval, this function will return %TRUE
|
||||
* and fill in @keyval and @modifiers with the keyval settings.
|
||||
*
|
||||
* Returns: %TRUE if keyval is set for @index.
|
||||
**/
|
||||
gboolean
|
||||
gdk_device_get_key (GdkDevice *device,
|
||||
guint index_,
|
||||
guint *keyval,
|
||||
GdkModifierType *modifiers)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
|
||||
g_return_val_if_fail (index_ < device->num_keys, FALSE);
|
||||
|
||||
if (!device->keys[index_].keyval &&
|
||||
!device->keys[index_].modifiers)
|
||||
return FALSE;
|
||||
|
||||
if (keyval)
|
||||
*keyval = device->keys[index_].keyval;
|
||||
|
||||
if (modifiers)
|
||||
*modifiers = device->keys[index_].modifiers;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_set_key:
|
||||
* @device: a #GdkDevice
|
||||
* @index_: the index of the macro button to set
|
||||
* @keyval: the keyval to generate
|
||||
* @modifiers: the modifiers to set
|
||||
*
|
||||
* Specifies the X key event to generate when a macro button of a device
|
||||
* is pressed.
|
||||
**/
|
||||
void
|
||||
gdk_device_set_key (GdkDevice *device,
|
||||
guint index_,
|
||||
guint keyval,
|
||||
GdkModifierType modifiers)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DEVICE (device));
|
||||
g_return_if_fail (index_ < device->num_keys);
|
||||
|
||||
device->keys[index_].keyval = keyval;
|
||||
device->keys[index_].modifiers = modifiers;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_get_axis_use:
|
||||
* @device: a pointer #GdkDevice.
|
||||
@@ -781,47 +699,6 @@ gdk_device_get_axis_use (GdkDevice *device,
|
||||
return info->use;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_set_axis_use:
|
||||
* @device: a pointer #GdkDevice
|
||||
* @index_: the index of the axis
|
||||
* @use: specifies how the axis is used
|
||||
*
|
||||
* Specifies how an axis of a device is used.
|
||||
**/
|
||||
void
|
||||
gdk_device_set_axis_use (GdkDevice *device,
|
||||
guint index_,
|
||||
GdkAxisUse use)
|
||||
{
|
||||
GdkAxisInfo *info;
|
||||
|
||||
g_return_if_fail (GDK_IS_DEVICE (device));
|
||||
g_return_if_fail (device->source != GDK_SOURCE_KEYBOARD);
|
||||
g_return_if_fail (index_ < device->axes->len);
|
||||
|
||||
info = &g_array_index (device->axes, GdkAxisInfo, index_);
|
||||
info->use = use;
|
||||
|
||||
switch ((guint) use)
|
||||
{
|
||||
case GDK_AXIS_X:
|
||||
case GDK_AXIS_Y:
|
||||
info->min_axis = 0;
|
||||
info->max_axis = 0;
|
||||
break;
|
||||
case GDK_AXIS_XTILT:
|
||||
case GDK_AXIS_YTILT:
|
||||
info->min_axis = -1;
|
||||
info->max_axis = 1;
|
||||
break;
|
||||
default:
|
||||
info->min_axis = 0;
|
||||
info->max_axis = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_get_display:
|
||||
* @device: a #GdkDevice
|
||||
@@ -843,15 +720,14 @@ gdk_device_get_display (GdkDevice *device)
|
||||
* gdk_device_get_associated_device:
|
||||
* @device: a #GdkDevice
|
||||
*
|
||||
* Returns the associated device to @device, if @device is of type
|
||||
* %GDK_DEVICE_TYPE_MASTER, it will return the paired pointer or
|
||||
* keyboard.
|
||||
* Returns the #GdkDevice associated to @device:
|
||||
*
|
||||
* If @device is of type %GDK_DEVICE_TYPE_SLAVE, it will return
|
||||
* the master device to which @device is attached to.
|
||||
*
|
||||
* If @device is of type %GDK_DEVICE_TYPE_FLOATING, %NULL will be
|
||||
* returned, as there is no associated device.
|
||||
* - if @device is of type %GDK_DEVICE_TYPE_LOGICAL, it will return
|
||||
* the paired pointer or keyboard.
|
||||
* - if @device is of type %GDK_DEVICE_TYPE_PHYSICAL, it will return
|
||||
* the logical device to which @device is attached to.
|
||||
* - if @device is of type %GDK_DEVICE_TYPE_FLOATING, %NULL will be
|
||||
* returned, as there is no associated device.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): The associated device, or
|
||||
* %NULL
|
||||
@@ -895,63 +771,59 @@ _gdk_device_set_associated_device (GdkDevice *device,
|
||||
if (associated)
|
||||
device->associated = g_object_ref (associated);
|
||||
|
||||
if (device->type != GDK_DEVICE_TYPE_MASTER)
|
||||
if (device->type != GDK_DEVICE_TYPE_LOGICAL)
|
||||
{
|
||||
if (device->associated)
|
||||
_gdk_device_set_device_type (device, GDK_DEVICE_TYPE_SLAVE);
|
||||
_gdk_device_set_device_type (device, GDK_DEVICE_TYPE_PHYSICAL);
|
||||
else
|
||||
_gdk_device_set_device_type (device, GDK_DEVICE_TYPE_FLOATING);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_list_slave_devices:
|
||||
* @device: a #GdkDevice
|
||||
* gdk_device_list_physical_devices:
|
||||
* @device: a logical #GdkDevice
|
||||
*
|
||||
* If the device if of type %GDK_DEVICE_TYPE_MASTER, it will return
|
||||
* the list of slave devices attached to it, otherwise it will return
|
||||
* %NULL
|
||||
* Returns the list of physical devices attached to the given logical
|
||||
* #GdkDevice.
|
||||
*
|
||||
* Returns: (nullable) (transfer container) (element-type GdkDevice):
|
||||
* the list of slave devices, or %NULL. The list must be
|
||||
* freed with g_list_free(), the contents of the list are
|
||||
* owned by GTK+ and should not be freed.
|
||||
**/
|
||||
* the list of physical devices attached to a logical #GdkDevice
|
||||
*/
|
||||
GList *
|
||||
gdk_device_list_slave_devices (GdkDevice *device)
|
||||
gdk_device_list_physical_devices (GdkDevice *device)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
|
||||
g_return_val_if_fail (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_MASTER, NULL);
|
||||
g_return_val_if_fail (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_LOGICAL, NULL);
|
||||
|
||||
return g_list_copy (device->slaves);
|
||||
return g_list_copy (device->physical_devices);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_device_add_slave (GdkDevice *device,
|
||||
GdkDevice *slave)
|
||||
_gdk_device_add_physical_device (GdkDevice *device,
|
||||
GdkDevice *physical)
|
||||
{
|
||||
g_return_if_fail (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_MASTER);
|
||||
g_return_if_fail (gdk_device_get_device_type (slave) != GDK_DEVICE_TYPE_MASTER);
|
||||
g_return_if_fail (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_LOGICAL);
|
||||
g_return_if_fail (gdk_device_get_device_type (physical) != GDK_DEVICE_TYPE_LOGICAL);
|
||||
|
||||
if (!g_list_find (device->slaves, slave))
|
||||
device->slaves = g_list_prepend (device->slaves, slave);
|
||||
if (!g_list_find (device->physical_devices, physical))
|
||||
device->physical_devices = g_list_prepend (device->physical_devices, physical);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_device_remove_slave (GdkDevice *device,
|
||||
GdkDevice *slave)
|
||||
_gdk_device_remove_physical_device (GdkDevice *device,
|
||||
GdkDevice *physical)
|
||||
{
|
||||
GList *elem;
|
||||
|
||||
g_return_if_fail (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_MASTER);
|
||||
g_return_if_fail (gdk_device_get_device_type (slave) != GDK_DEVICE_TYPE_MASTER);
|
||||
g_return_if_fail (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_LOGICAL);
|
||||
g_return_if_fail (gdk_device_get_device_type (physical) != GDK_DEVICE_TYPE_LOGICAL);
|
||||
|
||||
elem = g_list_find (device->slaves, slave);
|
||||
|
||||
if (!elem)
|
||||
elem = g_list_find (device->physical_devices, physical);
|
||||
if (elem == NULL)
|
||||
return;
|
||||
|
||||
device->slaves = g_list_delete_link (device->slaves, elem);
|
||||
device->physical_devices = g_list_delete_link (device->physical_devices, elem);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -965,7 +837,7 @@ _gdk_device_remove_slave (GdkDevice *device,
|
||||
GdkDeviceType
|
||||
gdk_device_get_device_type (GdkDevice *device)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DEVICE (device), GDK_DEVICE_TYPE_MASTER);
|
||||
g_return_val_if_fail (GDK_IS_DEVICE (device), GDK_DEVICE_TYPE_LOGICAL);
|
||||
|
||||
return device->type;
|
||||
}
|
||||
@@ -987,89 +859,6 @@ gdk_device_get_n_axes (GdkDevice *device)
|
||||
return device->axes->len;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_get_axis_names:
|
||||
* @device: a #GdkDevice
|
||||
*
|
||||
* Returns a null-terminated array of strings, containing the labels for
|
||||
* the axes that @device currently has.
|
||||
* If the device has no axes, %NULL is returned.
|
||||
*
|
||||
* Returns: (nullable) (transfer full): A null-terminated string array,
|
||||
* free with g_strfreev().
|
||||
**/
|
||||
char **
|
||||
gdk_device_get_axis_names (GdkDevice *device)
|
||||
{
|
||||
GPtrArray *axes;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
|
||||
g_return_val_if_fail (device->source != GDK_SOURCE_KEYBOARD, NULL);
|
||||
|
||||
if (device->axes->len == 0)
|
||||
return NULL;
|
||||
|
||||
axes = g_ptr_array_new ();
|
||||
|
||||
for (i = 0; i < device->axes->len; i++)
|
||||
{
|
||||
GdkAxisInfo axis_info;
|
||||
|
||||
axis_info = g_array_index (device->axes, GdkAxisInfo, i);
|
||||
g_ptr_array_add (axes, g_strdup (axis_info.label));
|
||||
}
|
||||
|
||||
g_ptr_array_add (axes, NULL);
|
||||
|
||||
return (char **) g_ptr_array_free (axes, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_get_axis_value: (skip)
|
||||
* @device: a pointer #GdkDevice.
|
||||
* @axes: (array): pointer to an array of axes
|
||||
* @axis_label: name of the label
|
||||
* @value: (out): location to store the found value.
|
||||
*
|
||||
* Interprets an array of double as axis values for a given device,
|
||||
* and locates the value in the array for a given axis label, as returned
|
||||
* by gdk_device_get_axes()
|
||||
*
|
||||
* Returns: %TRUE if the given axis use was found, otherwise %FALSE.
|
||||
**/
|
||||
gboolean
|
||||
gdk_device_get_axis_value (GdkDevice *device,
|
||||
gdouble *axes,
|
||||
const char *axis_label,
|
||||
gdouble *value)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
|
||||
g_return_val_if_fail (device->source != GDK_SOURCE_KEYBOARD, FALSE);
|
||||
|
||||
if (axes == NULL)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < device->axes->len; i++)
|
||||
{
|
||||
GdkAxisInfo axis_info;
|
||||
|
||||
axis_info = g_array_index (device->axes, GdkAxisInfo, i);
|
||||
|
||||
if (!g_str_equal (axis_info.label, axis_label))
|
||||
continue;
|
||||
|
||||
if (value)
|
||||
*value = axes[i];
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_get_axis: (skip)
|
||||
* @device: a #GdkDevice
|
||||
@@ -1135,7 +924,6 @@ get_native_grab_event_mask (GdkEventMask grab_mask)
|
||||
GdkGrabStatus
|
||||
gdk_device_grab (GdkDevice *device,
|
||||
GdkSurface *surface,
|
||||
GdkGrabOwnership grab_ownership,
|
||||
gboolean owner_events,
|
||||
GdkEventMask event_mask,
|
||||
GdkCursor *cursor,
|
||||
@@ -1169,7 +957,6 @@ gdk_device_grab (GdkDevice *device,
|
||||
_gdk_display_add_device_grab (display,
|
||||
device,
|
||||
surface,
|
||||
grab_ownership,
|
||||
owner_events,
|
||||
event_mask,
|
||||
serial,
|
||||
@@ -1206,7 +993,6 @@ _gdk_device_reset_axes (GdkDevice *device)
|
||||
|
||||
guint
|
||||
_gdk_device_add_axis (GdkDevice *device,
|
||||
const char *label_name,
|
||||
GdkAxisUse use,
|
||||
gdouble min_value,
|
||||
gdouble max_value,
|
||||
@@ -1216,7 +1002,6 @@ _gdk_device_add_axis (GdkDevice *device,
|
||||
guint pos;
|
||||
|
||||
axis_info.use = use;
|
||||
axis_info.label = g_strdup (label_name);
|
||||
axis_info.min_value = min_value;
|
||||
axis_info.max_value = max_value;
|
||||
axis_info.resolution = resolution;
|
||||
@@ -1252,12 +1037,11 @@ _gdk_device_add_axis (GdkDevice *device,
|
||||
|
||||
void
|
||||
_gdk_device_get_axis_info (GdkDevice *device,
|
||||
guint index_,
|
||||
const char **label_name,
|
||||
GdkAxisUse *use,
|
||||
gdouble *min_value,
|
||||
gdouble *max_value,
|
||||
gdouble *resolution)
|
||||
guint index_,
|
||||
GdkAxisUse *use,
|
||||
gdouble *min_value,
|
||||
gdouble *max_value,
|
||||
gdouble *resolution)
|
||||
{
|
||||
GdkAxisInfo *info;
|
||||
|
||||
@@ -1266,23 +1050,12 @@ _gdk_device_get_axis_info (GdkDevice *device,
|
||||
|
||||
info = &g_array_index (device->axes, GdkAxisInfo, index_);
|
||||
|
||||
*label_name = info->label;
|
||||
*use = info->use;
|
||||
*min_value = info->min_value;
|
||||
*max_value = info->max_value;
|
||||
*resolution = info->resolution;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_device_set_keys (GdkDevice *device,
|
||||
guint num_keys)
|
||||
{
|
||||
g_free (device->keys);
|
||||
|
||||
device->num_keys = num_keys;
|
||||
device->keys = g_new0 (GdkDeviceKey, num_keys);
|
||||
}
|
||||
|
||||
static GdkAxisInfo *
|
||||
find_axis_info (GArray *array,
|
||||
GdkAxisUse use)
|
||||
@@ -1303,10 +1076,10 @@ find_axis_info (GArray *array,
|
||||
|
||||
gboolean
|
||||
_gdk_device_translate_surface_coord (GdkDevice *device,
|
||||
GdkSurface *surface,
|
||||
guint index_,
|
||||
gdouble value,
|
||||
gdouble *axis_value)
|
||||
GdkSurface *surface,
|
||||
guint index_,
|
||||
gdouble value,
|
||||
gdouble *axis_value)
|
||||
{
|
||||
GdkAxisInfo axis_info;
|
||||
GdkAxisInfo *axis_info_x, *axis_info_y;
|
||||
@@ -1509,36 +1282,9 @@ _gdk_device_surface_at_position (GdkDevice *device,
|
||||
mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_get_last_event_surface:
|
||||
* @device: a #GdkDevice, with a source other than %GDK_SOURCE_KEYBOARD
|
||||
*
|
||||
* Gets information about which surface the given pointer device is in, based on events
|
||||
* that have been received so far from the display server. If another application
|
||||
* has a pointer grab, or this application has a grab with owner_events = %FALSE,
|
||||
* %NULL may be returned even if the pointer is physically over one of this
|
||||
* application's surfaces.
|
||||
*
|
||||
* Returns: (transfer none) (allow-none): the last surface the device
|
||||
*/
|
||||
GdkSurface *
|
||||
gdk_device_get_last_event_surface (GdkDevice *device)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
GdkPointerSurfaceInfo *info;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
|
||||
g_return_val_if_fail (device->source != GDK_SOURCE_KEYBOARD, NULL);
|
||||
|
||||
display = gdk_device_get_display (device);
|
||||
info = _gdk_display_get_pointer_info (display, device);
|
||||
|
||||
return info->surface_under_pointer;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_get_vendor_id:
|
||||
* @device: a slave #GdkDevice
|
||||
* @device: a physical #GdkDevice
|
||||
*
|
||||
* Returns the vendor ID of this device, or %NULL if this information couldn't
|
||||
* be obtained. This ID is retrieved from the device, and is thus constant for
|
||||
@@ -1573,14 +1319,14 @@ const gchar *
|
||||
gdk_device_get_vendor_id (GdkDevice *device)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
|
||||
g_return_val_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_MASTER, NULL);
|
||||
g_return_val_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_LOGICAL, NULL);
|
||||
|
||||
return device->vendor_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_get_product_id:
|
||||
* @device: a slave #GdkDevice
|
||||
* @device: a physical #GdkDevice
|
||||
*
|
||||
* Returns the product ID of this device, or %NULL if this information couldn't
|
||||
* be obtained. This ID is retrieved from the device, and is thus constant for
|
||||
@@ -1592,7 +1338,7 @@ const gchar *
|
||||
gdk_device_get_product_id (GdkDevice *device)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
|
||||
g_return_val_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_MASTER, NULL);
|
||||
g_return_val_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_LOGICAL, NULL);
|
||||
|
||||
return device->product_id;
|
||||
}
|
||||
@@ -1647,7 +1393,7 @@ gdk_device_update_tool (GdkDevice *device,
|
||||
GdkDeviceTool *tool)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DEVICE (device));
|
||||
g_return_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_MASTER);
|
||||
g_return_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_LOGICAL);
|
||||
|
||||
if (g_set_object (&device->last_tool, tool))
|
||||
{
|
||||
|
||||
+12
-45
@@ -40,8 +40,6 @@ typedef struct _GdkTimeCoord GdkTimeCoord;
|
||||
* @GDK_SOURCE_MOUSE: the device is a mouse. (This will be reported for the core
|
||||
* pointer, even if it is something else, such as a trackball.)
|
||||
* @GDK_SOURCE_PEN: the device is a stylus of a graphics tablet or similar device.
|
||||
* @GDK_SOURCE_ERASER: the device is an eraser. Typically, this would be the other end
|
||||
* of a stylus on a graphics tablet.
|
||||
* @GDK_SOURCE_CURSOR: the device is a graphics tablet “puck” or similar device.
|
||||
* @GDK_SOURCE_KEYBOARD: the device is a keyboard.
|
||||
* @GDK_SOURCE_TOUCHSCREEN: the device is a direct-input touch device, such
|
||||
@@ -60,7 +58,6 @@ typedef enum
|
||||
{
|
||||
GDK_SOURCE_MOUSE,
|
||||
GDK_SOURCE_PEN,
|
||||
GDK_SOURCE_ERASER,
|
||||
GDK_SOURCE_CURSOR,
|
||||
GDK_SOURCE_KEYBOARD,
|
||||
GDK_SOURCE_TOUCHSCREEN,
|
||||
@@ -71,36 +68,34 @@ typedef enum
|
||||
|
||||
/**
|
||||
* GdkDeviceType:
|
||||
* @GDK_DEVICE_TYPE_MASTER: Device is a master (or virtual) device. There will
|
||||
* be an associated focus indicator on the screen.
|
||||
* @GDK_DEVICE_TYPE_SLAVE: Device is a slave (or physical) device.
|
||||
* @GDK_DEVICE_TYPE_FLOATING: Device is a physical device, currently not attached to
|
||||
* any seat.
|
||||
* @GDK_DEVICE_TYPE_LOGICAL: Device is a logical device. There will
|
||||
* be an associated focus indicator on the screen.
|
||||
* @GDK_DEVICE_TYPE_PHYSICAL: Device is a physical device.
|
||||
* @GDK_DEVICE_TYPE_FLOATING: Device is a physical device, currently
|
||||
* not attached to any seat.
|
||||
*
|
||||
* Indicates the device type.
|
||||
*/
|
||||
typedef enum {
|
||||
GDK_DEVICE_TYPE_MASTER,
|
||||
GDK_DEVICE_TYPE_SLAVE,
|
||||
GDK_DEVICE_TYPE_LOGICAL,
|
||||
GDK_DEVICE_TYPE_PHYSICAL,
|
||||
GDK_DEVICE_TYPE_FLOATING
|
||||
} GdkDeviceType;
|
||||
|
||||
/* We don't allocate each coordinate this big, but we use it to
|
||||
* be ANSI compliant and avoid accessing past the defined limits.
|
||||
*/
|
||||
#define GDK_MAX_TIMECOORD_AXES 128
|
||||
|
||||
/**
|
||||
* GdkTimeCoord:
|
||||
* @time: The timestamp for this event.
|
||||
* @axes: the values of the device’s axes.
|
||||
* @flags: Flags indicating what axes are present
|
||||
* @axes: axis values
|
||||
*
|
||||
* A #GdkTimeCoord stores a single event in a motion history.
|
||||
*/
|
||||
struct _GdkTimeCoord
|
||||
{
|
||||
guint32 time;
|
||||
gdouble axes[GDK_MAX_TIMECOORD_AXES];
|
||||
GdkAxisFlags flags;
|
||||
double axes[GDK_AXIS_LAST];
|
||||
};
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
@@ -115,26 +110,9 @@ gboolean gdk_device_get_has_cursor (GdkDevice *device);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkInputSource gdk_device_get_source (GdkDevice *device);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gint gdk_device_get_n_keys (GdkDevice *device);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_device_get_key (GdkDevice *device,
|
||||
guint index_,
|
||||
guint *keyval,
|
||||
GdkModifierType *modifiers);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_device_set_key (GdkDevice *device,
|
||||
guint index_,
|
||||
guint keyval,
|
||||
GdkModifierType modifiers);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkAxisUse gdk_device_get_axis_use (GdkDevice *device,
|
||||
guint index_);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_device_set_axis_use (GdkDevice *device,
|
||||
guint index_,
|
||||
GdkAxisUse use);
|
||||
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
@@ -149,14 +127,6 @@ GdkSurface * gdk_device_get_surface_at_position (GdkDevice *device,
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gint gdk_device_get_n_axes (GdkDevice *device);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
char ** gdk_device_get_axis_names (GdkDevice *device);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_device_get_axis_value (GdkDevice *device,
|
||||
gdouble *axes,
|
||||
const char *axis_label,
|
||||
gdouble *value);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_device_get_axis (GdkDevice *device,
|
||||
gdouble *axes,
|
||||
@@ -168,14 +138,11 @@ GdkDisplay * gdk_device_get_display (GdkDevice *device);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDevice * gdk_device_get_associated_device (GdkDevice *device);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GList * gdk_device_list_slave_devices (GdkDevice *device);
|
||||
GList * gdk_device_list_physical_devices (GdkDevice *device);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDeviceType gdk_device_get_device_type (GdkDevice *device);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkSurface *gdk_device_get_last_event_surface (GdkDevice *device);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const gchar *gdk_device_get_vendor_id (GdkDevice *device);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
||||
+13
-26
@@ -31,13 +31,6 @@ G_BEGIN_DECLS
|
||||
#define GDK_DEVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_DEVICE, GdkDeviceClass))
|
||||
|
||||
typedef struct _GdkDeviceClass GdkDeviceClass;
|
||||
typedef struct _GdkDeviceKey GdkDeviceKey;
|
||||
|
||||
struct _GdkDeviceKey
|
||||
{
|
||||
guint keyval;
|
||||
GdkModifierType modifiers;
|
||||
};
|
||||
|
||||
struct _GdkDevice
|
||||
{
|
||||
@@ -46,15 +39,13 @@ struct _GdkDevice
|
||||
gchar *name;
|
||||
GdkInputSource source;
|
||||
gboolean has_cursor;
|
||||
gint num_keys;
|
||||
GdkAxisFlags axis_flags;
|
||||
GdkDeviceKey *keys;
|
||||
GdkDisplay *display;
|
||||
/* Paired master for master,
|
||||
* associated master for slaves
|
||||
/* The paired logical device for logical devices,
|
||||
* or the associated logical device for physical ones
|
||||
*/
|
||||
GdkDevice *associated;
|
||||
GList *slaves;
|
||||
GList *physical_devices;
|
||||
GdkDeviceType type;
|
||||
GArray *axes;
|
||||
guint num_touches;
|
||||
@@ -106,21 +97,16 @@ void _gdk_device_set_associated_device (GdkDevice *device,
|
||||
|
||||
void _gdk_device_reset_axes (GdkDevice *device);
|
||||
guint _gdk_device_add_axis (GdkDevice *device,
|
||||
const char *label_atom,
|
||||
GdkAxisUse use,
|
||||
gdouble min_value,
|
||||
gdouble max_value,
|
||||
gdouble resolution);
|
||||
void _gdk_device_get_axis_info (GdkDevice *device,
|
||||
guint index,
|
||||
const char**label_atom,
|
||||
GdkAxisUse *use,
|
||||
gdouble *min_value,
|
||||
gdouble *max_value,
|
||||
gdouble *resolution);
|
||||
|
||||
void _gdk_device_set_keys (GdkDevice *device,
|
||||
guint num_keys);
|
||||
guint index,
|
||||
GdkAxisUse *use,
|
||||
gdouble *min_value,
|
||||
gdouble *max_value,
|
||||
gdouble *resolution);
|
||||
|
||||
gboolean _gdk_device_translate_surface_coord (GdkDevice *device,
|
||||
GdkSurface *surface,
|
||||
@@ -146,10 +132,11 @@ gboolean _gdk_device_translate_axis (GdkDevice *device,
|
||||
GdkTimeCoord ** _gdk_device_allocate_history (GdkDevice *device,
|
||||
gint n_events);
|
||||
|
||||
void _gdk_device_add_slave (GdkDevice *device,
|
||||
GdkDevice *slave);
|
||||
void _gdk_device_remove_slave (GdkDevice *device,
|
||||
GdkDevice *slave);
|
||||
void _gdk_device_add_physical_device (GdkDevice *device,
|
||||
GdkDevice *physical);
|
||||
void _gdk_device_remove_physical_device (GdkDevice *device,
|
||||
GdkDevice *physical);
|
||||
|
||||
void _gdk_device_query_state (GdkDevice *device,
|
||||
GdkSurface *surface,
|
||||
GdkSurface **child_surface,
|
||||
|
||||
+3
-60
@@ -521,7 +521,6 @@ GdkDeviceGrabInfo *
|
||||
_gdk_display_add_device_grab (GdkDisplay *display,
|
||||
GdkDevice *device,
|
||||
GdkSurface *surface,
|
||||
GdkGrabOwnership grab_ownership,
|
||||
gboolean owner_events,
|
||||
GdkEventMask event_mask,
|
||||
unsigned long serial_start,
|
||||
@@ -540,7 +539,6 @@ _gdk_display_add_device_grab (GdkDisplay *display,
|
||||
info->event_mask = event_mask;
|
||||
info->time = time;
|
||||
info->implicit = implicit;
|
||||
info->ownership = grab_ownership;
|
||||
|
||||
grabs = g_hash_table_lookup (display->device_grabs, device);
|
||||
|
||||
@@ -643,12 +641,12 @@ switch_to_pointer_grab (GdkDisplay *display,
|
||||
if (grab == NULL /* ungrab */ ||
|
||||
(!last_grab->owner_events && grab->owner_events) /* switched to owner_events */ )
|
||||
{
|
||||
/* Ungrabbed slave devices don't have a position by
|
||||
* itself, rather depend on its master pointer, so
|
||||
/* Ungrabbed physical devices don't have a position by
|
||||
* itself, rather depend on its logical pointer, so
|
||||
* it doesn't make sense to track any position for
|
||||
* these after the grab
|
||||
*/
|
||||
if (grab || gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_SLAVE)
|
||||
if (grab || gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_PHYSICAL)
|
||||
new_toplevel = get_current_toplevel (display, device, &x, &y, &state);
|
||||
|
||||
if (new_toplevel)
|
||||
@@ -816,61 +814,6 @@ _gdk_display_end_device_grab (GdkDisplay *display,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Returns TRUE if device events are not blocked by any grab */
|
||||
gboolean
|
||||
_gdk_display_check_grab_ownership (GdkDisplay *display,
|
||||
GdkDevice *device,
|
||||
gulong serial)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
gpointer key, value;
|
||||
GdkGrabOwnership higher_ownership, device_ownership;
|
||||
gboolean device_is_keyboard;
|
||||
|
||||
g_hash_table_iter_init (&iter, display->device_grabs);
|
||||
higher_ownership = device_ownership = GDK_OWNERSHIP_NONE;
|
||||
device_is_keyboard = (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD);
|
||||
|
||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||
{
|
||||
GdkDeviceGrabInfo *grab;
|
||||
GdkDevice *dev;
|
||||
GList *grabs;
|
||||
|
||||
dev = key;
|
||||
grabs = value;
|
||||
grabs = grab_list_find (grabs, serial);
|
||||
|
||||
if (!grabs)
|
||||
continue;
|
||||
|
||||
/* Discard device if it's not of the same type */
|
||||
if ((device_is_keyboard && gdk_device_get_source (dev) != GDK_SOURCE_KEYBOARD) ||
|
||||
(!device_is_keyboard && gdk_device_get_source (dev) == GDK_SOURCE_KEYBOARD))
|
||||
continue;
|
||||
|
||||
grab = grabs->data;
|
||||
|
||||
if (dev == device)
|
||||
device_ownership = grab->ownership;
|
||||
else
|
||||
{
|
||||
if (grab->ownership > higher_ownership)
|
||||
higher_ownership = grab->ownership;
|
||||
}
|
||||
}
|
||||
|
||||
if (higher_ownership > device_ownership)
|
||||
{
|
||||
/* There's a higher priority ownership
|
||||
* going on for other device(s)
|
||||
*/
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GdkPointerSurfaceInfo *
|
||||
_gdk_display_get_pointer_info (GdkDisplay *display,
|
||||
GdkDevice *device)
|
||||
|
||||
@@ -45,7 +45,6 @@ typedef struct
|
||||
gulong serial_end; /* exclusive, i.e. not active on serial_end */
|
||||
guint event_mask;
|
||||
guint32 time;
|
||||
GdkGrabOwnership ownership;
|
||||
|
||||
guint activated : 1;
|
||||
guint implicit_ungrab : 1;
|
||||
@@ -66,7 +65,7 @@ typedef struct
|
||||
gdouble toplevel_x, toplevel_y;
|
||||
guint32 state;
|
||||
guint32 button;
|
||||
GdkDevice *last_slave;
|
||||
GdkDevice *last_physical_device;
|
||||
} GdkPointerSurfaceInfo;
|
||||
|
||||
struct _GdkDisplay
|
||||
@@ -187,7 +186,6 @@ GdkDeviceGrabInfo * _gdk_display_get_last_device_grab (GdkDisplay *display,
|
||||
GdkDeviceGrabInfo * _gdk_display_add_device_grab (GdkDisplay *display,
|
||||
GdkDevice *device,
|
||||
GdkSurface *surface,
|
||||
GdkGrabOwnership grab_ownership,
|
||||
gboolean owner_events,
|
||||
GdkEventMask event_mask,
|
||||
gulong serial_start,
|
||||
@@ -201,9 +199,6 @@ gboolean _gdk_display_end_device_grab (GdkDisplay *display
|
||||
gulong serial,
|
||||
GdkSurface *if_child,
|
||||
gboolean implicit);
|
||||
gboolean _gdk_display_check_grab_ownership (GdkDisplay *display,
|
||||
GdkDevice *device,
|
||||
gulong serial);
|
||||
GdkPointerSurfaceInfo * _gdk_display_get_pointer_info (GdkDisplay *display,
|
||||
GdkDevice *device);
|
||||
void _gdk_display_pointer_info_foreach (GdkDisplay *display,
|
||||
|
||||
+168
-20
@@ -619,6 +619,114 @@ _gdk_event_unqueue (GdkDisplay *display)
|
||||
return event;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the last N events in the event queue are smooth scroll events
|
||||
* for the same surface and device, combine them into one.
|
||||
*/
|
||||
void
|
||||
gdk_event_queue_handle_scroll_compression (GdkDisplay *display)
|
||||
{
|
||||
GList *l;
|
||||
GdkSurface *surface = NULL;
|
||||
GdkDevice *device = NULL;
|
||||
GdkEvent *last_event = NULL;
|
||||
GList *scrolls = NULL;
|
||||
double delta_x, delta_y;
|
||||
GArray *history = NULL;
|
||||
GdkTimeCoord hist;
|
||||
|
||||
l = g_queue_peek_tail_link (&display->queued_events);
|
||||
|
||||
while (l)
|
||||
{
|
||||
GdkEvent *event = l->data;
|
||||
|
||||
if (event->flags & GDK_EVENT_PENDING)
|
||||
break;
|
||||
|
||||
if (event->event_type != GDK_SCROLL ||
|
||||
gdk_scroll_event_get_direction (event) != GDK_SCROLL_SMOOTH)
|
||||
break;
|
||||
|
||||
if (surface != NULL &&
|
||||
surface != event->surface)
|
||||
break;
|
||||
|
||||
if (device != NULL &&
|
||||
device != event->device)
|
||||
break;
|
||||
|
||||
if (!last_event)
|
||||
last_event = event;
|
||||
|
||||
surface = event->surface;
|
||||
device = event->device;
|
||||
scrolls = l;
|
||||
|
||||
l = l->prev;
|
||||
}
|
||||
|
||||
delta_x = delta_y = 0;
|
||||
|
||||
while (scrolls && scrolls->next != NULL)
|
||||
{
|
||||
GdkEvent *event = scrolls->data;
|
||||
GList *next = scrolls->next;
|
||||
double dx, dy;
|
||||
|
||||
if (!history)
|
||||
history = g_array_new (FALSE, TRUE, sizeof (GdkTimeCoord));
|
||||
|
||||
gdk_scroll_event_get_deltas (event, &dx, &dy);
|
||||
delta_x += dx;
|
||||
delta_y += dy;
|
||||
|
||||
memset (&hist, 0, sizeof (GdkTimeCoord));
|
||||
hist.time = gdk_event_get_time (event);
|
||||
hist.flags = GDK_AXIS_FLAG_DELTA_X | GDK_AXIS_FLAG_DELTA_Y;
|
||||
hist.axes[GDK_AXIS_DELTA_X] = dx;
|
||||
hist.axes[GDK_AXIS_DELTA_Y] = dy;
|
||||
|
||||
g_array_append_val (history, hist);
|
||||
|
||||
gdk_event_unref (event);
|
||||
g_queue_delete_link (&display->queued_events, scrolls);
|
||||
scrolls = next;
|
||||
}
|
||||
|
||||
if (scrolls)
|
||||
{
|
||||
GdkEvent *old_event, *event;
|
||||
double dx, dy;
|
||||
|
||||
old_event = scrolls->data;
|
||||
|
||||
gdk_scroll_event_get_deltas (old_event, &dx, &dy);
|
||||
event = gdk_scroll_event_new (surface,
|
||||
device,
|
||||
gdk_event_get_source_device (old_event),
|
||||
gdk_event_get_device_tool (old_event),
|
||||
gdk_event_get_time (old_event),
|
||||
gdk_event_get_modifier_state (old_event),
|
||||
delta_x + dx,
|
||||
delta_y + dy,
|
||||
gdk_scroll_event_is_stop (old_event));
|
||||
|
||||
((GdkScrollEvent *)event)->history = history;
|
||||
|
||||
g_queue_delete_link (&display->queued_events, scrolls);
|
||||
g_queue_push_tail (&display->queued_events, event);
|
||||
}
|
||||
|
||||
if (g_queue_get_length (&display->queued_events) == 1 &&
|
||||
g_queue_peek_head_link (&display->queued_events) == scrolls)
|
||||
{
|
||||
GdkFrameClock *clock = gdk_surface_get_frame_clock (surface);
|
||||
if (clock) /* might be NULL if surface was destroyed */
|
||||
gdk_frame_clock_request_phase (clock, GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_motion_event_push_history (GdkEvent *event,
|
||||
GdkEvent *history_event)
|
||||
@@ -634,14 +742,20 @@ gdk_motion_event_push_history (GdkEvent *event,
|
||||
device = gdk_event_get_device (history_event);
|
||||
n_axes = gdk_device_get_n_axes (device);
|
||||
|
||||
for (i = 0; i <= MIN (n_axes, GDK_MAX_TIMECOORD_AXES); i++)
|
||||
gdk_event_get_axis (history_event, i, &hist.axes[i]);
|
||||
memset (&hist, 0, sizeof (GdkTimeCoord));
|
||||
hist.time = gdk_event_get_time (history_event);
|
||||
hist.flags = gdk_device_get_axes (device);
|
||||
|
||||
for (i = 0; i < n_axes; i++)
|
||||
{
|
||||
GdkAxisUse use = gdk_device_get_axis_use (device, i);
|
||||
gdk_event_get_axis (history_event, use, &hist.axes[use]);
|
||||
}
|
||||
|
||||
if (G_UNLIKELY (!self->history))
|
||||
self->history = g_array_new (FALSE, TRUE, sizeof (GdkTimeCoord));
|
||||
|
||||
g_array_append_val (self->history, hist);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@@ -710,7 +824,7 @@ _gdk_event_queue_handle_motion_compression (GdkDisplay *display)
|
||||
{
|
||||
GdkFrameClock *clock = gdk_surface_get_frame_clock (pending_motion_surface);
|
||||
if (clock) /* might be NULL if surface was destroyed */
|
||||
gdk_frame_clock_request_phase (clock, GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS);
|
||||
gdk_frame_clock_request_phase (clock, GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1071,6 +1185,22 @@ gdk_event_get_surface (GdkEvent *event)
|
||||
return event->surface;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_seat:
|
||||
* @event: a #GdkEvent.
|
||||
*
|
||||
* Returns the seat that originated the event.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): a #GdkSeat.
|
||||
*/
|
||||
GdkSeat *
|
||||
gdk_event_get_seat (GdkEvent *event)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_EVENT (event), NULL);
|
||||
|
||||
return event->device ? gdk_device_get_seat (event->device) : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_device:
|
||||
* @event: a #GdkEvent.
|
||||
@@ -1091,9 +1221,9 @@ gdk_event_get_device (GdkEvent *event)
|
||||
* gdk_event_get_source_device:
|
||||
* @event: a #GdkEvent
|
||||
*
|
||||
* This function returns the hardware (slave) #GdkDevice that has
|
||||
* triggered the event, falling back to the virtual (master) device
|
||||
* (as in gdk_event_get_device()) if the event wasn’t caused by
|
||||
* This function returns the physical #GdkDevice that has triggered
|
||||
* the event, falling back to the logical device, as returned by
|
||||
* gdk_event_get_device(), if the event wasn’t caused by
|
||||
* interaction with a hardware device. This may happen for example
|
||||
* in synthesized crossing events after a #GdkSurface updates its
|
||||
* geometry or a grab is acquired/released.
|
||||
@@ -2158,6 +2288,8 @@ gdk_scroll_event_finalize (GdkEvent *event)
|
||||
GdkScrollEvent *self = (GdkScrollEvent *) event;
|
||||
|
||||
g_clear_object (&self->tool);
|
||||
if (self->history)
|
||||
g_array_free (self->history, TRUE);
|
||||
|
||||
GDK_EVENT_SUPER (self)->finalize (event);
|
||||
}
|
||||
@@ -2777,35 +2909,51 @@ gdk_motion_event_new (GdkSurface *surface,
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_motion_event_get_history:
|
||||
* @event: (type GdkMotionEvent): a motion #GdkEvent
|
||||
* gdk_event_get_history:
|
||||
* @event: a motion or scroll #GdkEvent
|
||||
* @out_n_coords: (out): Return location for the length of the returned array
|
||||
*
|
||||
* Retrieves the history of the @event motion, as a list of time and
|
||||
* coordinates.
|
||||
* Retrieves the history of the @event, as a list of time and coordinates.
|
||||
*
|
||||
* The history includes events that are not delivered to the application
|
||||
* because they occurred in the same frame as @event.
|
||||
*
|
||||
* Note that only motion and scroll events record history, and motion
|
||||
* events only if one of the mouse buttons is down.
|
||||
*
|
||||
* Returns: (transfer container) (array length=out_n_coords) (nullable): an
|
||||
* array of time and coordinates
|
||||
*/
|
||||
GdkTimeCoord *
|
||||
gdk_motion_event_get_history (GdkEvent *event,
|
||||
guint *out_n_coords)
|
||||
gdk_event_get_history (GdkEvent *event,
|
||||
guint *out_n_coords)
|
||||
{
|
||||
GdkMotionEvent *self = (GdkMotionEvent *) event;
|
||||
GArray *history;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_EVENT (event), NULL);
|
||||
g_return_val_if_fail (GDK_IS_EVENT_TYPE (event, GDK_MOTION_NOTIFY), NULL);
|
||||
g_return_val_if_fail (GDK_IS_EVENT_TYPE (event, GDK_MOTION_NOTIFY) ||
|
||||
GDK_IS_EVENT_TYPE (event, GDK_SCROLL), NULL);
|
||||
g_return_val_if_fail (out_n_coords != NULL, NULL);
|
||||
|
||||
if (self->history &&
|
||||
self->history->len > 0)
|
||||
if (GDK_IS_EVENT_TYPE (event, GDK_MOTION_NOTIFY))
|
||||
{
|
||||
GdkMotionEvent *self = (GdkMotionEvent *) event;
|
||||
history = self->history;
|
||||
}
|
||||
else
|
||||
{
|
||||
GdkScrollEvent *self = (GdkScrollEvent *) event;
|
||||
history = self->history;
|
||||
}
|
||||
|
||||
if (history && history->len > 0)
|
||||
{
|
||||
GdkTimeCoord *result;
|
||||
|
||||
*out_n_coords = self->history->len;
|
||||
*out_n_coords = history->len;
|
||||
|
||||
result = g_malloc (sizeof (GdkTimeCoord) * self->history->len);
|
||||
memcpy (result, self->history->data, sizeof (GdkTimeCoord) * self->history->len);
|
||||
result = g_malloc (sizeof (GdkTimeCoord) * history->len);
|
||||
memcpy (result, history->data, sizeof (GdkTimeCoord) * history->len);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
+7
-3
@@ -344,6 +344,9 @@ GdkEventType gdk_event_get_event_type (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkSurface * gdk_event_get_surface (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkSeat * gdk_event_get_seat (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDevice * gdk_event_get_device (GdkEvent *event);
|
||||
|
||||
@@ -378,6 +381,9 @@ gboolean gdk_event_get_axis (GdkEvent *event,
|
||||
GdkAxisUse axis_use,
|
||||
double *value);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkTimeCoord * gdk_event_get_history (GdkEvent *event,
|
||||
guint *out_n_coords);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_pointer_emulated (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
@@ -392,6 +398,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gdk_scroll_event_get_deltas (GdkEvent *event,
|
||||
double *delta_x,
|
||||
double *delta_y);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_scroll_event_is_stop (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
@@ -470,9 +477,6 @@ gboolean gdk_grab_broken_event_get_implicit (GdkEvent *event)
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gdk_motion_event_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkTimeCoord * gdk_motion_event_get_history (GdkEvent *event,
|
||||
guint *out_n_coords);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gdk_delete_event_get_type (void) G_GNUC_CONST;
|
||||
|
||||
@@ -211,6 +211,9 @@ struct _GdkTouchEvent
|
||||
* @pointer_emulated: whether the scroll event was the result of
|
||||
* a pointer emulation
|
||||
* @tool: a #GdkDeviceTool
|
||||
* @history: (element-type GdkScrollHistory): array of times and deltas
|
||||
* for other scroll events that were compressed before delivering the
|
||||
* current event
|
||||
*
|
||||
* Generated from button presses for the buttons 4 to 7. Wheel mice are
|
||||
* usually configured to generate button press events for buttons 4 and 5
|
||||
@@ -232,6 +235,7 @@ struct _GdkScrollEvent
|
||||
gboolean pointer_emulated;
|
||||
gboolean is_stop;
|
||||
GdkDeviceTool *tool;
|
||||
GArray *history; /* <GdkScrollHistory> */
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
+127
-24
@@ -37,13 +37,25 @@
|
||||
|
||||
#define FRAME_INTERVAL 16667 /* microseconds */
|
||||
|
||||
typedef enum {
|
||||
SMOOTH_PHASE_STATE_VALID = 0, /* explicit, since we count on zero-init */
|
||||
SMOOTH_PHASE_STATE_AWAIT_FIRST,
|
||||
SMOOTH_PHASE_STATE_AWAIT_DRAWN,
|
||||
} SmoothDeltaState;
|
||||
|
||||
struct _GdkFrameClockIdlePrivate
|
||||
{
|
||||
gint64 frame_time; /* The exact time we last ran the clock cycle, or 0 if never */
|
||||
gint64 smoothed_frame_time_base; /* A grid-aligned version of frame_time (grid size == refresh period), never more than half a grid from frame_time */
|
||||
gint64 smoothed_frame_time_period; /* The grid size that smoothed_frame_time_base is aligned to */
|
||||
gint64 smoothed_frame_time_reported; /* Ensures we are always monotonic */
|
||||
gint64 smoothed_frame_time_phase; /* The offset of the first reported frame time, in the current animation sequence, from the preceding vsync */
|
||||
gint64 min_next_frame_time; /* We're not synced to vblank, so wait at least until this before next cycle to avoid busy looping */
|
||||
SmoothDeltaState smooth_phase_state; /* The state of smoothed_frame_time_phase - is it valid, awaiting vsync etc. Thanks to zero-init, the initial value
|
||||
of smoothed_frame_time_phase is `0`. This is valid, since we didn't get a "frame drawn" event yet. Accordingly,
|
||||
the initial value of smooth_phase_state is SMOOTH_PHASE_STATE_VALID. See the comment in gdk_frame_clock_paint_idle()
|
||||
for details. */
|
||||
|
||||
gint64 sleep_serial;
|
||||
gint64 freeze_time;
|
||||
|
||||
@@ -128,6 +140,7 @@ gdk_frame_clock_idle_init (GdkFrameClockIdle *frame_clock_idle)
|
||||
gdk_frame_clock_idle_get_instance_private (frame_clock_idle);
|
||||
|
||||
priv->freeze_count = 0;
|
||||
priv->smoothed_frame_time_period = FRAME_INTERVAL;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -334,23 +347,6 @@ maybe_stop_idle (GdkFrameClockIdle *clock_idle)
|
||||
}
|
||||
}
|
||||
|
||||
static gint64
|
||||
compute_min_next_frame_time (GdkFrameClockIdle *clock_idle,
|
||||
gint64 last_frame_time)
|
||||
{
|
||||
gint64 presentation_time;
|
||||
gint64 refresh_interval;
|
||||
|
||||
gdk_frame_clock_get_refresh_info (GDK_FRAME_CLOCK (clock_idle),
|
||||
last_frame_time,
|
||||
&refresh_interval, &presentation_time);
|
||||
|
||||
if (presentation_time == 0)
|
||||
return last_frame_time + refresh_interval;
|
||||
else
|
||||
return presentation_time + refresh_interval / 2;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_frame_clock_flush_idle (void *data)
|
||||
{
|
||||
@@ -377,6 +373,25 @@ gdk_frame_clock_flush_idle (void *data)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the positive remainder.
|
||||
*
|
||||
* As an example, lets consider (-5) % 16:
|
||||
*
|
||||
* (-5) % 16 = (0 * 16) + (-5) = -5
|
||||
*
|
||||
* If we only want positive remainders, we can instead calculate
|
||||
*
|
||||
* (-5) % 16 = (1 * 16) + (-5) = 11
|
||||
*
|
||||
* The built-in `%` operator returns the former, positive_modulo() returns the latter.
|
||||
*/
|
||||
static int
|
||||
positive_modulo (int i, int n)
|
||||
{
|
||||
return (i % n + n) % n;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_frame_clock_paint_idle (void *data)
|
||||
{
|
||||
@@ -418,21 +433,88 @@ gdk_frame_clock_paint_idle (void *data)
|
||||
|
||||
priv->frame_time = g_get_monotonic_time ();
|
||||
|
||||
/*
|
||||
* The first clock cycle of an animation might have been triggered by some external event. An external
|
||||
* event can be an input event, an expired timer, data arriving over the network etc. This can happen at
|
||||
* any time, so the cycle could have been scheduled at some random time rather then immediately after a
|
||||
* frame completion. The offset between the start of the first animation cycle and the preceding vsync is
|
||||
* called the "phase" of the clock cycle start time (not to be confused with the phase of the frame
|
||||
* clock).
|
||||
*
|
||||
* In this first clock cycle, the "smooth" frame time is simply the time when the cycle was started. This
|
||||
* could be followed by several cycles which are not vsync-related. As long as we don't get a "frame
|
||||
* drawn" signal from the compositor, the clock cycles will occur every about frame_interval. Once we do
|
||||
* get a "frame drawn" signal, from this point on the frame clock cycles will start shortly after the
|
||||
* corresponding vsync signals, again every about frame_interval. The first vsync-related clock cycle
|
||||
* might occur less than a refresh interval away from the last non-vsync-related cycle. See the diagram
|
||||
* below for details. So while the cadence stays the same - a frame clock cycle every about frame_interval
|
||||
* - the phase of the cycles start time has changed.
|
||||
*
|
||||
* Since we might have already reported the frame time to the application in the previous clock cycles, we
|
||||
* have to adjust future reported frame times. We want the first vsync-related smooth time to be separated
|
||||
* by exactly 1 frame_interval from the previous one, in order to maintain the regularity of the reported
|
||||
* frame times. To achieve that, from this point on we add the phase of the first clock cycle start time to
|
||||
* the smooth time. In order to compute that phase, accounting for possible skipped frames (e.g. due to
|
||||
* compositor stalls), we want the following to be true:
|
||||
*
|
||||
* first_vsync_smooth_time = last_non_vsync_smooth_time + frame_interval * (1 + frames_skipped)
|
||||
*
|
||||
* We can assign the following known/desired values to the above equation:
|
||||
*
|
||||
* last_non_vsync_smooth_time = smoothed_frame_time_base
|
||||
* first_vsync_smooth_time = frame_time + smoothed_frame_time_phase
|
||||
*
|
||||
* That leads us to the following, from which we can extract smoothed_frame_time_phase:
|
||||
*
|
||||
* frame_time + smoothed_frame_time_phase = smoothed_frame_time_base +
|
||||
* frame_interval * (1 + frames_skipped)
|
||||
*
|
||||
* In the following diagram, '|' mark a vsync, '*' mark the start of a clock cycle, '+' is the adjusted
|
||||
* frame time, '!' marks the reception of "frame drawn" events from the compositor. Note that the clock
|
||||
* cycle cadence changed after the first vsync-related cycle. This cadence is kept even if we don't
|
||||
* receive a 'frame drawn' signal in a subsequent frame, since then we schedule the clock at intervals of
|
||||
* refresh_interval.
|
||||
*
|
||||
* vsync | | | | | |...
|
||||
* frame drawn | | |! |! | |...
|
||||
* cycle start | * | * |* |* |* |...
|
||||
* adjusted times | * | * | + | + | + |...
|
||||
* phase ^------^
|
||||
*/
|
||||
if (priv->smooth_phase_state == SMOOTH_PHASE_STATE_AWAIT_FIRST)
|
||||
{
|
||||
/* First animation cycle - usually unrelated to vsync */
|
||||
priv->smoothed_frame_time_base = 0;
|
||||
priv->smoothed_frame_time_phase = 0;
|
||||
priv->smooth_phase_state = SMOOTH_PHASE_STATE_AWAIT_DRAWN;
|
||||
}
|
||||
else if (priv->smooth_phase_state == SMOOTH_PHASE_STATE_AWAIT_DRAWN &&
|
||||
priv->paint_is_thaw)
|
||||
{
|
||||
/* First vsync-related animation cycle, we can now compute the phase. We want the phase to satisfy
|
||||
0 <= phase < frame_interval */
|
||||
priv->smoothed_frame_time_phase =
|
||||
positive_modulo (priv->smoothed_frame_time_base - priv->frame_time,
|
||||
frame_interval);
|
||||
priv->smooth_phase_state = SMOOTH_PHASE_STATE_VALID;
|
||||
}
|
||||
|
||||
if (priv->smoothed_frame_time_base == 0)
|
||||
{
|
||||
/* First frame */
|
||||
priv->smoothed_frame_time_base = priv->frame_time;
|
||||
priv->smoothed_frame_time_period = frame_interval;
|
||||
/* First frame ever, or first cycle in a new animation sequence. Ensure monotonicity */
|
||||
priv->smoothed_frame_time_base = MAX (priv->frame_time, priv->smoothed_frame_time_reported);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* compute_smooth_frame_time() ensures monotonicity */
|
||||
priv->smoothed_frame_time_base =
|
||||
compute_smooth_frame_time (clock, priv->frame_time,
|
||||
compute_smooth_frame_time (clock, priv->frame_time + priv->smoothed_frame_time_phase,
|
||||
priv->paint_is_thaw,
|
||||
priv->smoothed_frame_time_base,
|
||||
priv->smoothed_frame_time_period);
|
||||
priv->smoothed_frame_time_period = frame_interval;
|
||||
}
|
||||
|
||||
priv->smoothed_frame_time_period = frame_interval;
|
||||
priv->smoothed_frame_time_reported = priv->smoothed_frame_time_base;
|
||||
|
||||
_gdk_frame_clock_begin_frame (clock);
|
||||
@@ -558,8 +640,19 @@ gdk_frame_clock_paint_idle (void *data)
|
||||
*/
|
||||
if (priv->freeze_count == 0)
|
||||
{
|
||||
priv->min_next_frame_time = compute_min_next_frame_time (clock_idle,
|
||||
priv->smoothed_frame_time_base);
|
||||
/*
|
||||
* If we don't receive "frame drawn" events, smooth_cycle_start will simply be advanced in constant increments of
|
||||
* the refresh interval. That way we get absolute target times for the next cycles, which should prevent skewing
|
||||
* in the scheduling of the frame clock.
|
||||
*
|
||||
* Once we do receive "frame drawn" events, smooth_cycle_start will track the vsync, and do so in a more stable
|
||||
* way compared to frame_time. If we then no longer receive "frame drawn" events, smooth_cycle_start will again be
|
||||
* simply advanced in increments of the refresh interval, but this time we are in sync with the vsync. If we start
|
||||
* receiving "frame drawn" events shortly after loosing them, then we should still be in sync.
|
||||
*/
|
||||
gint64 smooth_cycle_start = priv->smoothed_frame_time_base - priv->smoothed_frame_time_phase;
|
||||
priv->min_next_frame_time = smooth_cycle_start + priv->smoothed_frame_time_period;
|
||||
|
||||
maybe_start_idle (clock_idle, FALSE);
|
||||
}
|
||||
|
||||
@@ -598,6 +691,11 @@ gdk_frame_clock_idle_begin_updating (GdkFrameClock *clock)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (priv->updating_count == 0)
|
||||
{
|
||||
priv->smooth_phase_state = SMOOTH_PHASE_STATE_AWAIT_FIRST;
|
||||
}
|
||||
|
||||
priv->updating_count++;
|
||||
maybe_start_idle (clock_idle, FALSE);
|
||||
}
|
||||
@@ -613,6 +711,11 @@ gdk_frame_clock_idle_end_updating (GdkFrameClock *clock)
|
||||
priv->updating_count--;
|
||||
maybe_stop_idle (clock_idle);
|
||||
|
||||
if (priv->updating_count == 0)
|
||||
{
|
||||
priv->smooth_phase_state = SMOOTH_PHASE_STATE_VALID;
|
||||
}
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
if (priv->updating_count == 0 && priv->begin_period)
|
||||
{
|
||||
|
||||
+7
-7
@@ -348,7 +348,7 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
||||
paint_data = gdk_gl_context_get_paint_data (paint_context);
|
||||
|
||||
if (paint_data->tmp_framebuffer == 0)
|
||||
glGenFramebuffersEXT (1, &paint_data->tmp_framebuffer);
|
||||
glGenFramebuffers (1, &paint_data->tmp_framebuffer);
|
||||
|
||||
if (source_type == GL_RENDERBUFFER)
|
||||
{
|
||||
@@ -390,19 +390,19 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
||||
cairo_surface_set_device_scale (image, buffer_scale, buffer_scale);
|
||||
|
||||
framebuffer = paint_data->tmp_framebuffer;
|
||||
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, framebuffer);
|
||||
glBindFramebuffer (GL_FRAMEBUFFER, framebuffer);
|
||||
|
||||
if (source_type == GL_RENDERBUFFER)
|
||||
{
|
||||
/* Create a framebuffer with the source renderbuffer and
|
||||
make it the current target for reads */
|
||||
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_RENDERBUFFER_EXT, source);
|
||||
glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
||||
GL_RENDERBUFFER, source);
|
||||
}
|
||||
else
|
||||
{
|
||||
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_TEXTURE_2D, source, 0);
|
||||
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
||||
GL_TEXTURE_2D, source, 0);
|
||||
}
|
||||
|
||||
glPixelStorei (GL_PACK_ALIGNMENT, 4);
|
||||
@@ -418,7 +418,7 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
||||
|
||||
glPixelStorei (GL_PACK_ROW_LENGTH, 0);
|
||||
|
||||
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
|
||||
glBindFramebuffer (GL_FRAMEBUFFER, 0);
|
||||
|
||||
cairo_surface_mark_dirty (image);
|
||||
|
||||
|
||||
+1
-16
@@ -123,6 +123,7 @@ GList* _gdk_event_queue_append (GdkDisplay *display,
|
||||
GdkEvent *event);
|
||||
|
||||
void _gdk_event_queue_handle_motion_compression (GdkDisplay *display);
|
||||
void gdk_event_queue_handle_scroll_compression (GdkDisplay *display);
|
||||
void _gdk_event_queue_flush (GdkDisplay *display);
|
||||
|
||||
gboolean _gdk_cairo_surface_extents (cairo_surface_t *surface,
|
||||
@@ -228,21 +229,6 @@ typedef enum
|
||||
GDK_GRAB_FAILED = 5
|
||||
} GdkGrabStatus;
|
||||
|
||||
/**
|
||||
* GdkGrabOwnership:
|
||||
* @GDK_OWNERSHIP_NONE: All other devices’ events are allowed.
|
||||
* @GDK_OWNERSHIP_SURFACE: Other devices’ events are blocked for the grab surface.
|
||||
* @GDK_OWNERSHIP_APPLICATION: Other devices’ events are blocked for the whole application.
|
||||
*
|
||||
* Defines how device grabs interact with other devices.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_OWNERSHIP_NONE,
|
||||
GDK_OWNERSHIP_SURFACE,
|
||||
GDK_OWNERSHIP_APPLICATION
|
||||
} GdkGrabOwnership;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_EXPOSURE_MASK = 1 << 1,
|
||||
@@ -273,7 +259,6 @@ typedef enum
|
||||
|
||||
GdkGrabStatus gdk_device_grab (GdkDevice *device,
|
||||
GdkSurface *surface,
|
||||
GdkGrabOwnership grab_ownership,
|
||||
gboolean owner_events,
|
||||
GdkEventMask event_mask,
|
||||
GdkCursor *cursor,
|
||||
|
||||
+3
-3
@@ -452,7 +452,7 @@ gdk_keymap_have_bidi_layouts (GdkKeymap *keymap)
|
||||
* gdk_keymap_get_caps_lock_state:
|
||||
* @keymap: a #GdkKeymap
|
||||
*
|
||||
* Returns whether the Caps Lock modifer is locked.
|
||||
* Returns whether the Caps Lock modifier is locked.
|
||||
*
|
||||
* Returns: %TRUE if Caps Lock is on
|
||||
*/
|
||||
@@ -468,7 +468,7 @@ gdk_keymap_get_caps_lock_state (GdkKeymap *keymap)
|
||||
* gdk_keymap_get_num_lock_state:
|
||||
* @keymap: a #GdkKeymap
|
||||
*
|
||||
* Returns whether the Num Lock modifer is locked.
|
||||
* Returns whether the Num Lock modifier is locked.
|
||||
*
|
||||
* Returns: %TRUE if Num Lock is on
|
||||
*/
|
||||
@@ -484,7 +484,7 @@ gdk_keymap_get_num_lock_state (GdkKeymap *keymap)
|
||||
* gdk_keymap_get_scroll_lock_state:
|
||||
* @keymap: a #GdkKeymap
|
||||
*
|
||||
* Returns whether the Scroll Lock modifer is locked.
|
||||
* Returns whether the Scroll Lock modifier is locked.
|
||||
*
|
||||
* Returns: %TRUE if Scroll Lock is on
|
||||
*/
|
||||
|
||||
+7
-13
@@ -878,11 +878,15 @@ static const struct {
|
||||
|
||||
/**
|
||||
* gdk_keyval_to_unicode:
|
||||
* @keyval: a GDK key symbol
|
||||
*
|
||||
* @keyval: a GDK key symbol
|
||||
*
|
||||
* Convert from a GDK key symbol to the corresponding ISO10646 (Unicode)
|
||||
* character.
|
||||
*
|
||||
*
|
||||
* Note that the conversion does not take the current locale
|
||||
* into consideration, which might be expected for particular
|
||||
* keyvals, such as %GDK_KEY_KP_Decimal.
|
||||
*
|
||||
* Returns: the corresponding unicode character, or 0 if there
|
||||
* is no corresponding character.
|
||||
**/
|
||||
@@ -903,16 +907,6 @@ gdk_keyval_to_unicode (guint keyval)
|
||||
if ((keyval & 0xff000000) == 0x01000000)
|
||||
return keyval & 0x00ffffff;
|
||||
|
||||
#if defined(GDK_WINDOWING_WIN32)
|
||||
if (GDK_IS_WIN32_DISPLAY (gdk_display_get_default ()) &&
|
||||
keyval == 0xffae)
|
||||
{
|
||||
GdkWin32Keymap *keymap = GDK_WIN32_KEYMAP (gdk_display_get_keymap (gdk_display_get_default ()));
|
||||
|
||||
return (guint32) _gdk_win32_keymap_get_decimal_mark (keymap);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* binary search in table */
|
||||
while (max >= min) {
|
||||
mid = (min + max) / 2;
|
||||
|
||||
+11
-35
@@ -323,35 +323,35 @@ gdk_seat_ungrab (GdkSeat *seat)
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_seat_get_slaves:
|
||||
* gdk_seat_get_physical_devices:
|
||||
* @seat: a #GdkSeat
|
||||
* @capabilities: capabilities to get devices for
|
||||
*
|
||||
* Returns the slave devices that match the given capabilities.
|
||||
* Returns the physical 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
|
||||
* by GDK and must not be freed.
|
||||
**/
|
||||
GList *
|
||||
gdk_seat_get_slaves (GdkSeat *seat,
|
||||
GdkSeatCapabilities capabilities)
|
||||
gdk_seat_get_physical_devices (GdkSeat *seat,
|
||||
GdkSeatCapabilities capabilities)
|
||||
{
|
||||
GdkSeatClass *seat_class;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_SEAT (seat), NULL);
|
||||
|
||||
seat_class = GDK_SEAT_GET_CLASS (seat);
|
||||
return seat_class->get_slaves (seat, capabilities);
|
||||
return seat_class->get_physical_devices (seat, capabilities);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_seat_get_pointer:
|
||||
* @seat: a #GdkSeat
|
||||
*
|
||||
* Returns the master device that routes pointer events.
|
||||
* Returns the logical device that routes pointer events.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): a master #GdkDevice with pointer
|
||||
* Returns: (transfer none) (nullable): a logical #GdkDevice with pointer
|
||||
* capabilities. This object is owned by GTK and must not be freed.
|
||||
**/
|
||||
GdkDevice *
|
||||
@@ -362,16 +362,16 @@ gdk_seat_get_pointer (GdkSeat *seat)
|
||||
g_return_val_if_fail (GDK_IS_SEAT (seat), NULL);
|
||||
|
||||
seat_class = GDK_SEAT_GET_CLASS (seat);
|
||||
return seat_class->get_master (seat, GDK_SEAT_CAPABILITY_POINTER);
|
||||
return seat_class->get_logical_device (seat, GDK_SEAT_CAPABILITY_POINTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_seat_get_keyboard:
|
||||
* @seat: a #GdkSeat
|
||||
*
|
||||
* Returns the master device that routes keyboard events.
|
||||
* Returns the logical device that routes keyboard events.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): a master #GdkDevice with keyboard
|
||||
* Returns: (transfer none) (nullable): a logical #GdkDevice with keyboard
|
||||
* capabilities. This object is owned by GTK and must not be freed.
|
||||
**/
|
||||
GdkDevice *
|
||||
@@ -382,7 +382,7 @@ gdk_seat_get_keyboard (GdkSeat *seat)
|
||||
g_return_val_if_fail (GDK_IS_SEAT (seat), NULL);
|
||||
|
||||
seat_class = GDK_SEAT_GET_CLASS (seat);
|
||||
return seat_class->get_master (seat, GDK_SEAT_CAPABILITY_KEYBOARD);
|
||||
return seat_class->get_logical_device (seat, GDK_SEAT_CAPABILITY_KEYBOARD);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -446,27 +446,3 @@ gdk_seat_get_tool (GdkSeat *seat,
|
||||
seat_class = GDK_SEAT_GET_CLASS (seat);
|
||||
return seat_class->get_tool (seat, serial, hw_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_seat_get_master_pointers:
|
||||
* @seat: The #GdkSeat
|
||||
* @capabilities: Queried capabilities
|
||||
*
|
||||
* Returns all master pointers with the given capabilities driven by this @seat.
|
||||
* On most backends this function will return a list with a single element (meaning
|
||||
* that all input devices drive the same onscreen cursor).
|
||||
*
|
||||
* In other backends where there can possibly be multiple foci (eg. wayland),
|
||||
* this function will return all master #GdkDevices that represent these.
|
||||
*
|
||||
* Returns: (transfer container) (element-type GdkDevice): A list
|
||||
* of master pointing devices
|
||||
*/
|
||||
GList *
|
||||
gdk_seat_get_master_pointers (GdkSeat *seat,
|
||||
GdkSeatCapabilities capabilities)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_SEAT (seat), NULL);
|
||||
|
||||
return GDK_SEAT_GET_CLASS (seat)->get_master_pointers (seat, capabilities);
|
||||
}
|
||||
|
||||
+6
-10
@@ -68,24 +68,20 @@ GDK_AVAILABLE_IN_ALL
|
||||
GType gdk_seat_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDisplay * gdk_seat_get_display (GdkSeat *seat);
|
||||
GdkDisplay * gdk_seat_get_display (GdkSeat *seat);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkSeatCapabilities
|
||||
gdk_seat_get_capabilities (GdkSeat *seat);
|
||||
gdk_seat_get_capabilities (GdkSeat *seat);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GList * gdk_seat_get_slaves (GdkSeat *seat,
|
||||
GdkSeatCapabilities capabilities);
|
||||
GList * gdk_seat_get_physical_devices (GdkSeat *seat,
|
||||
GdkSeatCapabilities capabilities);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDevice * gdk_seat_get_pointer (GdkSeat *seat);
|
||||
GdkDevice * gdk_seat_get_pointer (GdkSeat *seat);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDevice * gdk_seat_get_keyboard (GdkSeat *seat);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GList * gdk_seat_get_master_pointers (GdkSeat *seat,
|
||||
GdkSeatCapabilities capabilities);
|
||||
GdkDevice * gdk_seat_get_keyboard (GdkSeat *seat);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+51
-65
@@ -25,10 +25,10 @@ typedef struct _GdkSeatDefaultPrivate GdkSeatDefaultPrivate;
|
||||
|
||||
struct _GdkSeatDefaultPrivate
|
||||
{
|
||||
GdkDevice *master_pointer;
|
||||
GdkDevice *master_keyboard;
|
||||
GList *slave_pointers;
|
||||
GList *slave_keyboards;
|
||||
GdkDevice *logical_pointer;
|
||||
GdkDevice *logical_keyboard;
|
||||
GList *physical_pointers;
|
||||
GList *physical_keyboards;
|
||||
GdkSeatCapabilities capabilities;
|
||||
|
||||
GPtrArray *tools;
|
||||
@@ -55,25 +55,25 @@ gdk_seat_dispose (GObject *object)
|
||||
GdkSeatDefaultPrivate *priv = gdk_seat_default_get_instance_private (seat);
|
||||
GList *l;
|
||||
|
||||
if (priv->master_pointer)
|
||||
if (priv->logical_pointer)
|
||||
{
|
||||
gdk_seat_device_removed (GDK_SEAT (seat), priv->master_pointer);
|
||||
g_clear_object (&priv->master_pointer);
|
||||
gdk_seat_device_removed (GDK_SEAT (seat), priv->logical_pointer);
|
||||
g_clear_object (&priv->logical_pointer);
|
||||
}
|
||||
|
||||
if (priv->master_keyboard)
|
||||
if (priv->logical_keyboard)
|
||||
{
|
||||
gdk_seat_device_removed (GDK_SEAT (seat), priv->master_keyboard);
|
||||
g_clear_object (&priv->master_pointer);
|
||||
gdk_seat_device_removed (GDK_SEAT (seat), priv->logical_keyboard);
|
||||
g_clear_object (&priv->logical_pointer);
|
||||
}
|
||||
|
||||
for (l = priv->slave_pointers; l; l = l->next)
|
||||
for (l = priv->physical_pointers; l; l = l->next)
|
||||
{
|
||||
gdk_seat_device_removed (GDK_SEAT (seat), l->data);
|
||||
g_object_unref (l->data);
|
||||
}
|
||||
|
||||
for (l = priv->slave_keyboards; l; l = l->next)
|
||||
for (l = priv->physical_keyboards; l; l = l->next)
|
||||
{
|
||||
gdk_seat_device_removed (GDK_SEAT (seat), l->data);
|
||||
g_object_unref (l->data);
|
||||
@@ -85,10 +85,10 @@ gdk_seat_dispose (GObject *object)
|
||||
priv->tools = NULL;
|
||||
}
|
||||
|
||||
g_list_free (priv->slave_pointers);
|
||||
g_list_free (priv->slave_keyboards);
|
||||
priv->slave_pointers = NULL;
|
||||
priv->slave_keyboards = NULL;
|
||||
g_list_free (priv->physical_pointers);
|
||||
g_list_free (priv->physical_keyboards);
|
||||
priv->physical_pointers = NULL;
|
||||
priv->physical_keyboards = NULL;
|
||||
|
||||
G_OBJECT_CLASS (gdk_seat_default_parent_class)->dispose (object);
|
||||
}
|
||||
@@ -148,8 +148,8 @@ gdk_seat_default_grab (GdkSeat *seat,
|
||||
if (capabilities & GDK_SEAT_CAPABILITY_TOUCH)
|
||||
pointer_evmask |= TOUCH_EVENTS;
|
||||
|
||||
status = gdk_device_grab (priv->master_pointer, surface,
|
||||
GDK_OWNERSHIP_NONE, owner_events,
|
||||
status = gdk_device_grab (priv->logical_pointer, surface,
|
||||
owner_events,
|
||||
pointer_evmask, cursor,
|
||||
evtime);
|
||||
}
|
||||
@@ -157,15 +157,15 @@ gdk_seat_default_grab (GdkSeat *seat,
|
||||
if (status == GDK_GRAB_SUCCESS &&
|
||||
capabilities & GDK_SEAT_CAPABILITY_KEYBOARD)
|
||||
{
|
||||
status = gdk_device_grab (priv->master_keyboard, surface,
|
||||
GDK_OWNERSHIP_NONE, owner_events,
|
||||
status = gdk_device_grab (priv->logical_keyboard, surface,
|
||||
owner_events,
|
||||
KEYBOARD_EVENTS, cursor,
|
||||
evtime);
|
||||
|
||||
if (status != GDK_GRAB_SUCCESS)
|
||||
{
|
||||
if (capabilities & ~GDK_SEAT_CAPABILITY_KEYBOARD)
|
||||
gdk_device_ungrab (priv->master_pointer, evtime);
|
||||
gdk_device_ungrab (priv->logical_pointer, evtime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,14 +185,14 @@ gdk_seat_default_ungrab (GdkSeat *seat)
|
||||
priv = gdk_seat_default_get_instance_private (GDK_SEAT_DEFAULT (seat));
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
gdk_device_ungrab (priv->master_pointer, GDK_CURRENT_TIME);
|
||||
gdk_device_ungrab (priv->master_keyboard, GDK_CURRENT_TIME);
|
||||
gdk_device_ungrab (priv->logical_pointer, GDK_CURRENT_TIME);
|
||||
gdk_device_ungrab (priv->logical_keyboard, GDK_CURRENT_TIME);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
}
|
||||
|
||||
static GdkDevice *
|
||||
gdk_seat_default_get_master (GdkSeat *seat,
|
||||
GdkSeatCapabilities capability)
|
||||
gdk_seat_default_get_logical_device (GdkSeat *seat,
|
||||
GdkSeatCapabilities capability)
|
||||
{
|
||||
GdkSeatDefaultPrivate *priv;
|
||||
|
||||
@@ -203,9 +203,9 @@ gdk_seat_default_get_master (GdkSeat *seat,
|
||||
{
|
||||
case GDK_SEAT_CAPABILITY_POINTER:
|
||||
case GDK_SEAT_CAPABILITY_TOUCH:
|
||||
return priv->master_pointer;
|
||||
return priv->logical_pointer;
|
||||
case GDK_SEAT_CAPABILITY_KEYBOARD:
|
||||
return priv->master_keyboard;
|
||||
return priv->logical_keyboard;
|
||||
default:
|
||||
g_warning ("Unhandled capability %x", capability);
|
||||
break;
|
||||
@@ -228,7 +228,6 @@ device_get_capability (GdkDevice *device)
|
||||
case GDK_SOURCE_TOUCHSCREEN:
|
||||
return GDK_SEAT_CAPABILITY_TOUCH;
|
||||
case GDK_SOURCE_PEN:
|
||||
case GDK_SOURCE_ERASER:
|
||||
case GDK_SOURCE_CURSOR:
|
||||
return GDK_SEAT_CAPABILITY_TABLET_STYLUS;
|
||||
case GDK_SOURCE_TABLET_PAD:
|
||||
@@ -264,8 +263,8 @@ append_filtered (GList *list,
|
||||
}
|
||||
|
||||
static GList *
|
||||
gdk_seat_default_get_slaves (GdkSeat *seat,
|
||||
GdkSeatCapabilities capabilities)
|
||||
gdk_seat_default_get_physical_devices (GdkSeat *seat,
|
||||
GdkSeatCapabilities capabilities)
|
||||
{
|
||||
GdkSeatDefaultPrivate *priv;
|
||||
GList *devices = NULL;
|
||||
@@ -273,10 +272,10 @@ gdk_seat_default_get_slaves (GdkSeat *seat,
|
||||
priv = gdk_seat_default_get_instance_private (GDK_SEAT_DEFAULT (seat));
|
||||
|
||||
if (capabilities & (GDK_SEAT_CAPABILITY_ALL_POINTING))
|
||||
devices = append_filtered (devices, priv->slave_pointers, capabilities);
|
||||
devices = append_filtered (devices, priv->physical_pointers, capabilities);
|
||||
|
||||
if (capabilities & (GDK_SEAT_CAPABILITY_KEYBOARD | GDK_SEAT_CAPABILITY_TABLET_PAD))
|
||||
devices = append_filtered (devices, priv->slave_keyboards, capabilities);
|
||||
devices = append_filtered (devices, priv->physical_keyboards, capabilities);
|
||||
|
||||
return devices;
|
||||
}
|
||||
@@ -306,18 +305,6 @@ gdk_seat_default_get_tool (GdkSeat *seat,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GList *
|
||||
gdk_seat_default_get_master_pointers (GdkSeat *seat,
|
||||
GdkSeatCapabilities capabilities)
|
||||
{
|
||||
GList *masters = NULL;
|
||||
|
||||
if (capabilities & GDK_SEAT_CAPABILITY_ALL_POINTING)
|
||||
masters = g_list_prepend (masters, gdk_seat_get_pointer (seat));
|
||||
|
||||
return masters;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_seat_default_class_init (GdkSeatDefaultClass *klass)
|
||||
{
|
||||
@@ -331,9 +318,8 @@ gdk_seat_default_class_init (GdkSeatDefaultClass *klass)
|
||||
seat_class->grab = gdk_seat_default_grab;
|
||||
seat_class->ungrab = gdk_seat_default_ungrab;
|
||||
|
||||
seat_class->get_master = gdk_seat_default_get_master;
|
||||
seat_class->get_slaves = gdk_seat_default_get_slaves;
|
||||
seat_class->get_master_pointers = gdk_seat_default_get_master_pointers;
|
||||
seat_class->get_logical_device = gdk_seat_default_get_logical_device;
|
||||
seat_class->get_physical_devices = gdk_seat_default_get_physical_devices;
|
||||
|
||||
seat_class->get_tool = gdk_seat_default_get_tool;
|
||||
}
|
||||
@@ -344,8 +330,8 @@ gdk_seat_default_init (GdkSeatDefault *seat)
|
||||
}
|
||||
|
||||
GdkSeat *
|
||||
gdk_seat_default_new_for_master_pair (GdkDevice *pointer,
|
||||
GdkDevice *keyboard)
|
||||
gdk_seat_default_new_for_logical_pair (GdkDevice *pointer,
|
||||
GdkDevice *keyboard)
|
||||
{
|
||||
GdkSeatDefaultPrivate *priv;
|
||||
GdkDisplay *display;
|
||||
@@ -358,18 +344,18 @@ gdk_seat_default_new_for_master_pair (GdkDevice *pointer,
|
||||
NULL);
|
||||
|
||||
priv = gdk_seat_default_get_instance_private (GDK_SEAT_DEFAULT (seat));
|
||||
priv->master_pointer = g_object_ref (pointer);
|
||||
priv->master_keyboard = g_object_ref (keyboard);
|
||||
priv->logical_pointer = g_object_ref (pointer);
|
||||
priv->logical_keyboard = g_object_ref (keyboard);
|
||||
|
||||
gdk_seat_device_added (seat, priv->master_pointer);
|
||||
gdk_seat_device_added (seat, priv->master_keyboard);
|
||||
gdk_seat_device_added (seat, priv->logical_pointer);
|
||||
gdk_seat_device_added (seat, priv->logical_keyboard);
|
||||
|
||||
return seat;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_seat_default_add_slave (GdkSeatDefault *seat,
|
||||
GdkDevice *device)
|
||||
gdk_seat_default_add_physical_device (GdkSeatDefault *seat,
|
||||
GdkDevice *device)
|
||||
{
|
||||
GdkSeatDefaultPrivate *priv;
|
||||
GdkSeatCapabilities capability;
|
||||
@@ -381,9 +367,9 @@ gdk_seat_default_add_slave (GdkSeatDefault *seat,
|
||||
capability = device_get_capability (device);
|
||||
|
||||
if (capability & GDK_SEAT_CAPABILITY_ALL_POINTING)
|
||||
priv->slave_pointers = g_list_prepend (priv->slave_pointers, g_object_ref (device));
|
||||
priv->physical_pointers = g_list_prepend (priv->physical_pointers, g_object_ref (device));
|
||||
else if (capability & (GDK_SEAT_CAPABILITY_KEYBOARD | GDK_SEAT_CAPABILITY_TABLET_PAD))
|
||||
priv->slave_keyboards = g_list_prepend (priv->slave_keyboards, g_object_ref (device));
|
||||
priv->physical_keyboards = g_list_prepend (priv->physical_keyboards, g_object_ref (device));
|
||||
else
|
||||
{
|
||||
g_critical ("Unhandled capability %x for device '%s'",
|
||||
@@ -397,8 +383,8 @@ gdk_seat_default_add_slave (GdkSeatDefault *seat,
|
||||
}
|
||||
|
||||
void
|
||||
gdk_seat_default_remove_slave (GdkSeatDefault *seat,
|
||||
GdkDevice *device)
|
||||
gdk_seat_default_remove_physical_device (GdkSeatDefault *seat,
|
||||
GdkDevice *device)
|
||||
{
|
||||
GdkSeatDefaultPrivate *priv;
|
||||
GList *l;
|
||||
@@ -408,23 +394,23 @@ gdk_seat_default_remove_slave (GdkSeatDefault *seat,
|
||||
|
||||
priv = gdk_seat_default_get_instance_private (seat);
|
||||
|
||||
if (g_list_find (priv->slave_pointers, device))
|
||||
if (g_list_find (priv->physical_pointers, device))
|
||||
{
|
||||
priv->slave_pointers = g_list_remove (priv->slave_pointers, device);
|
||||
priv->physical_pointers = g_list_remove (priv->physical_pointers, device);
|
||||
|
||||
priv->capabilities &= ~(GDK_SEAT_CAPABILITY_ALL_POINTING);
|
||||
for (l = priv->slave_pointers; l; l = l->next)
|
||||
for (l = priv->physical_pointers; l; l = l->next)
|
||||
priv->capabilities |= device_get_capability (GDK_DEVICE (l->data));
|
||||
|
||||
gdk_seat_device_removed (GDK_SEAT (seat), device);
|
||||
g_object_unref (device);
|
||||
}
|
||||
else if (g_list_find (priv->slave_keyboards, device))
|
||||
else if (g_list_find (priv->physical_keyboards, device))
|
||||
{
|
||||
priv->slave_keyboards = g_list_remove (priv->slave_keyboards, device);
|
||||
priv->physical_keyboards = g_list_remove (priv->physical_keyboards, device);
|
||||
|
||||
priv->capabilities &= ~(GDK_SEAT_CAPABILITY_KEYBOARD | GDK_SEAT_CAPABILITY_TABLET_PAD);
|
||||
for (l = priv->slave_keyboards; l; l = l->next)
|
||||
for (l = priv->physical_keyboards; l; l = l->next)
|
||||
priv->capabilities |= device_get_capability (GDK_DEVICE (l->data));
|
||||
|
||||
gdk_seat_device_removed (GDK_SEAT (seat), device);
|
||||
|
||||
+14
-10
@@ -23,6 +23,8 @@
|
||||
#include "gdkseat.h"
|
||||
#include "gdkseatprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GDK_TYPE_SEAT_DEFAULT (gdk_seat_default_get_type ())
|
||||
#define GDK_SEAT_DEFAULT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_SEAT_DEFAULT, GdkSeatDefault))
|
||||
#define GDK_IS_SEAT_DEFAULT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_SEAT_DEFAULT))
|
||||
@@ -45,16 +47,18 @@ struct _GdkSeatDefaultClass
|
||||
|
||||
GType gdk_seat_default_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GdkSeat * gdk_seat_default_new_for_master_pair (GdkDevice *pointer,
|
||||
GdkDevice *keyboard);
|
||||
GdkSeat * gdk_seat_default_new_for_logical_pair (GdkDevice *pointer,
|
||||
GdkDevice *keyboard);
|
||||
|
||||
void gdk_seat_default_add_slave (GdkSeatDefault *seat,
|
||||
GdkDevice *device);
|
||||
void gdk_seat_default_remove_slave (GdkSeatDefault *seat,
|
||||
GdkDevice *device);
|
||||
void gdk_seat_default_add_tool (GdkSeatDefault *seat,
|
||||
GdkDeviceTool *tool);
|
||||
void gdk_seat_default_remove_tool (GdkSeatDefault *seat,
|
||||
GdkDeviceTool *tool);
|
||||
void gdk_seat_default_add_physical_device (GdkSeatDefault *seat,
|
||||
GdkDevice *device);
|
||||
void gdk_seat_default_remove_physical_device (GdkSeatDefault *seat,
|
||||
GdkDevice *device);
|
||||
void gdk_seat_default_add_tool (GdkSeatDefault *seat,
|
||||
GdkDeviceTool *tool);
|
||||
void gdk_seat_default_remove_tool (GdkSeatDefault *seat,
|
||||
GdkDeviceTool *tool);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_SEAT_DEFAULT_PRIVATE_H__ */
|
||||
|
||||
@@ -52,16 +52,14 @@ struct _GdkSeatClass
|
||||
gpointer prepare_func_data);
|
||||
void (* ungrab) (GdkSeat *seat);
|
||||
|
||||
GdkDevice * (* get_master) (GdkSeat *seat,
|
||||
GdkSeatCapabilities capability);
|
||||
GList * (* get_slaves) (GdkSeat *seat,
|
||||
GdkSeatCapabilities capabilities);
|
||||
GdkDevice * (* get_logical_device) (GdkSeat *seat,
|
||||
GdkSeatCapabilities capability);
|
||||
GList * (* get_physical_devices) (GdkSeat *seat,
|
||||
GdkSeatCapabilities capabilities);
|
||||
|
||||
GdkDeviceTool * (* get_tool) (GdkSeat *seat,
|
||||
guint64 serial,
|
||||
guint64 tool_id);
|
||||
GList * (* get_master_pointers) (GdkSeat *seat,
|
||||
GdkSeatCapabilities capabilities);
|
||||
};
|
||||
|
||||
void gdk_seat_device_added (GdkSeat *seat,
|
||||
|
||||
+13
-69
@@ -1762,7 +1762,7 @@ gdk_surface_hide (GdkSurface *surface)
|
||||
seat = gdk_display_get_default_seat (display);
|
||||
if (seat)
|
||||
{
|
||||
devices = gdk_seat_get_slaves (seat, GDK_SEAT_CAPABILITY_ALL);
|
||||
devices = gdk_seat_get_physical_devices (seat, GDK_SEAT_CAPABILITY_ALL);
|
||||
devices = g_list_prepend (devices, gdk_seat_get_keyboard (seat));
|
||||
devices = g_list_prepend (devices, gdk_seat_get_pointer (seat));
|
||||
}
|
||||
@@ -1880,7 +1880,7 @@ gdk_surface_set_cursor (GdkSurface *surface,
|
||||
device = gdk_seat_get_pointer (s->data);
|
||||
gdk_surface_set_cursor_internal (surface, device, surface->cursor);
|
||||
|
||||
devices = gdk_seat_get_slaves (s->data, GDK_SEAT_CAPABILITY_TABLET_STYLUS);
|
||||
devices = gdk_seat_get_physical_devices (s->data, GDK_SEAT_CAPABILITY_TABLET_STYLUS);
|
||||
for (d = devices; d; d = d->next)
|
||||
{
|
||||
device = gdk_device_get_associated_device (d->data);
|
||||
@@ -1897,7 +1897,7 @@ gdk_surface_set_cursor (GdkSurface *surface,
|
||||
/**
|
||||
* gdk_surface_get_device_cursor:
|
||||
* @surface: a #GdkSurface.
|
||||
* @device: a master, pointer #GdkDevice.
|
||||
* @device: a logical, pointer #GdkDevice.
|
||||
*
|
||||
* Retrieves a #GdkCursor pointer for the @device currently set on the
|
||||
* specified #GdkSurface, or %NULL. If the return value is %NULL then
|
||||
@@ -1916,7 +1916,7 @@ gdk_surface_get_device_cursor (GdkSurface *surface,
|
||||
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
|
||||
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
|
||||
g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, NULL);
|
||||
g_return_val_if_fail (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_MASTER, NULL);
|
||||
g_return_val_if_fail (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_LOGICAL, NULL);
|
||||
|
||||
return g_hash_table_lookup (surface->device_cursor, device);
|
||||
}
|
||||
@@ -1924,7 +1924,7 @@ gdk_surface_get_device_cursor (GdkSurface *surface,
|
||||
/**
|
||||
* gdk_surface_set_device_cursor:
|
||||
* @surface: a #GdkSurface
|
||||
* @device: a master, pointer #GdkDevice
|
||||
* @device: a logical, pointer #GdkDevice
|
||||
* @cursor: a #GdkCursor
|
||||
*
|
||||
* Sets a specific #GdkCursor for a given device when it gets inside @surface.
|
||||
@@ -1942,7 +1942,7 @@ gdk_surface_set_device_cursor (GdkSurface *surface,
|
||||
g_return_if_fail (GDK_IS_SURFACE (surface));
|
||||
g_return_if_fail (GDK_IS_DEVICE (device));
|
||||
g_return_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD);
|
||||
g_return_if_fail (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_MASTER);
|
||||
g_return_if_fail (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_LOGICAL);
|
||||
|
||||
if (!cursor)
|
||||
g_hash_table_remove (surface->device_cursor, device);
|
||||
@@ -2186,53 +2186,6 @@ gdk_surface_beep (GdkSurface *surface)
|
||||
gdk_display_beep (surface->display);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_surface_set_support_multidevice:
|
||||
* @surface: a #GdkSurface.
|
||||
* @support_multidevice: %TRUE to enable multidevice support in @surface.
|
||||
*
|
||||
* This function will enable multidevice features in @surface.
|
||||
*
|
||||
* Multidevice aware surfaces will need to handle properly multiple,
|
||||
* per device enter/leave events, device grabs and grab ownerships.
|
||||
**/
|
||||
void
|
||||
gdk_surface_set_support_multidevice (GdkSurface *surface,
|
||||
gboolean support_multidevice)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_SURFACE (surface));
|
||||
|
||||
if (GDK_SURFACE_DESTROYED (surface))
|
||||
return;
|
||||
|
||||
if (surface->support_multidevice == support_multidevice)
|
||||
return;
|
||||
|
||||
surface->support_multidevice = support_multidevice;
|
||||
|
||||
/* FIXME: What to do if called when some pointers are inside the surface ? */
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_surface_get_support_multidevice:
|
||||
* @surface: a #GdkSurface.
|
||||
*
|
||||
* Returns %TRUE if the surface is aware of the existence of multiple
|
||||
* devices.
|
||||
*
|
||||
* Returns: %TRUE if the surface handles multidevice features.
|
||||
**/
|
||||
gboolean
|
||||
gdk_surface_get_support_multidevice (GdkSurface *surface)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_SURFACE (surface), FALSE);
|
||||
|
||||
if (GDK_SURFACE_DESTROYED (surface))
|
||||
return FALSE;
|
||||
|
||||
return surface->support_multidevice;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_display_set_surface_under_pointer (GdkDisplay *display,
|
||||
GdkDevice *device,
|
||||
@@ -2284,21 +2237,14 @@ _gdk_windowing_got_event (GdkDisplay *display,
|
||||
{
|
||||
pointer_info = _gdk_display_get_pointer_info (display, device);
|
||||
|
||||
if (source_device != pointer_info->last_slave &&
|
||||
gdk_device_get_device_type (source_device) == GDK_DEVICE_TYPE_SLAVE)
|
||||
pointer_info->last_slave = source_device;
|
||||
else if (pointer_info->last_slave)
|
||||
source_device = pointer_info->last_slave;
|
||||
if (source_device != pointer_info->last_physical_device &&
|
||||
gdk_device_get_device_type (source_device) == GDK_DEVICE_TYPE_PHYSICAL)
|
||||
pointer_info->last_physical_device = source_device;
|
||||
else if (pointer_info->last_physical_device)
|
||||
source_device = pointer_info->last_physical_device;
|
||||
}
|
||||
|
||||
_gdk_display_device_grab_update (display, device, source_device, serial);
|
||||
|
||||
if (!_gdk_display_check_grab_ownership (display, device, serial))
|
||||
{
|
||||
/* Device events are blocked by another device grab */
|
||||
unlink_event = TRUE;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
event_surface = gdk_event_get_surface (event);
|
||||
@@ -2321,7 +2267,6 @@ _gdk_windowing_got_event (GdkDisplay *display,
|
||||
_gdk_display_add_device_grab (display,
|
||||
device,
|
||||
event_surface,
|
||||
GDK_OWNERSHIP_NONE,
|
||||
FALSE,
|
||||
GDK_ALL_EVENTS_MASK,
|
||||
serial,
|
||||
@@ -2366,6 +2311,7 @@ _gdk_windowing_got_event (GdkDisplay *display,
|
||||
* candidate it queues up flushing the event queue.
|
||||
*/
|
||||
_gdk_event_queue_handle_motion_compression (display);
|
||||
gdk_event_queue_handle_scroll_compression (display);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3001,11 +2947,9 @@ gdk_surface_get_seat_from_event (GdkSurface *surface,
|
||||
{
|
||||
if (event)
|
||||
{
|
||||
GdkDevice *device = gdk_event_get_device (event);
|
||||
GdkSeat *seat = NULL;
|
||||
|
||||
if (device)
|
||||
seat = gdk_device_get_seat (device);
|
||||
seat = gdk_event_get_seat (event);
|
||||
|
||||
if (seat)
|
||||
return seat;
|
||||
|
||||
@@ -213,12 +213,6 @@ void gdk_surface_freeze_updates (GdkSurface *surface);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_surface_thaw_updates (GdkSurface *surface);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_surface_set_support_multidevice (GdkSurface *surface,
|
||||
gboolean support_multidevice);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_surface_get_support_multidevice (GdkSurface *surface);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkFrameClock* gdk_surface_get_frame_clock (GdkSurface *surface);
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ struct _GdkSurface
|
||||
|
||||
guint destroyed : 2;
|
||||
|
||||
guint support_multidevice : 1;
|
||||
guint in_update : 1;
|
||||
guint frame_clock_events_paused : 1;
|
||||
guint autohide : 1;
|
||||
|
||||
+1
-1
@@ -375,7 +375,7 @@ gdk_texture_new_from_resource (const char *resource_path)
|
||||
* Creates a new texture by loading an image from a file. The file format is
|
||||
* detected automatically. If %NULL is returned, then @error will be set.
|
||||
*
|
||||
* Return value: A newly-created #GdkTexture or %NULL if an error occured.
|
||||
* Return value: A newly-created #GdkTexture or %NULL if an error occurred.
|
||||
**/
|
||||
GdkTexture *
|
||||
gdk_texture_new_from_file (GFile *file,
|
||||
|
||||
@@ -247,6 +247,8 @@ typedef enum {
|
||||
* @GDK_AXIS_IGNORE: the axis is ignored.
|
||||
* @GDK_AXIS_X: the axis is used as the x axis.
|
||||
* @GDK_AXIS_Y: the axis is used as the y axis.
|
||||
* @GDK_AXIS_DELTA_X: the axis is used as the scroll x delta
|
||||
* @GDK_AXIS_DELTA_Y: the axis is used as the scroll y delta
|
||||
* @GDK_AXIS_PRESSURE: the axis is used for pressure information.
|
||||
* @GDK_AXIS_XTILT: the axis is used for x tilt information.
|
||||
* @GDK_AXIS_YTILT: the axis is used for y tilt information.
|
||||
@@ -269,6 +271,8 @@ typedef enum
|
||||
GDK_AXIS_IGNORE,
|
||||
GDK_AXIS_X,
|
||||
GDK_AXIS_Y,
|
||||
GDK_AXIS_DELTA_X,
|
||||
GDK_AXIS_DELTA_Y,
|
||||
GDK_AXIS_PRESSURE,
|
||||
GDK_AXIS_XTILT,
|
||||
GDK_AXIS_YTILT,
|
||||
@@ -283,6 +287,8 @@ typedef enum
|
||||
* GdkAxisFlags:
|
||||
* @GDK_AXIS_FLAG_X: X axis is present
|
||||
* @GDK_AXIS_FLAG_Y: Y axis is present
|
||||
* @GDK_AXIS_FLAG_DELTA_X: Scroll X delta axis is present
|
||||
* @GDK_AXIS_FLAG_DELTA_Y: Scroll Y delta axis is present
|
||||
* @GDK_AXIS_FLAG_PRESSURE: Pressure axis is present
|
||||
* @GDK_AXIS_FLAG_XTILT: X tilt axis is present
|
||||
* @GDK_AXIS_FLAG_YTILT: Y tilt axis is present
|
||||
@@ -297,6 +303,8 @@ typedef enum
|
||||
{
|
||||
GDK_AXIS_FLAG_X = 1 << GDK_AXIS_X,
|
||||
GDK_AXIS_FLAG_Y = 1 << GDK_AXIS_Y,
|
||||
GDK_AXIS_FLAG_DELTA_X = 1 << GDK_AXIS_DELTA_X,
|
||||
GDK_AXIS_FLAG_DELTA_Y = 1 << GDK_AXIS_DELTA_Y,
|
||||
GDK_AXIS_FLAG_PRESSURE = 1 << GDK_AXIS_PRESSURE,
|
||||
GDK_AXIS_FLAG_XTILT = 1 << GDK_AXIS_XTILT,
|
||||
GDK_AXIS_FLAG_YTILT = 1 << GDK_AXIS_YTILT,
|
||||
|
||||
@@ -54,7 +54,7 @@ create_core_pointer (GdkQuartzDeviceManagerCore *device_manager,
|
||||
{
|
||||
return g_object_new (GDK_TYPE_QUARTZ_DEVICE_CORE,
|
||||
"name", "Core Pointer",
|
||||
"type", GDK_DEVICE_TYPE_MASTER,
|
||||
"type", GDK_DEVICE_TYPE_LOGICAL,
|
||||
"input-source", GDK_SOURCE_MOUSE,
|
||||
"input-mode", GDK_MODE_SCREEN,
|
||||
"has-cursor", TRUE,
|
||||
@@ -69,7 +69,7 @@ create_core_keyboard (GdkQuartzDeviceManagerCore *device_manager,
|
||||
{
|
||||
return g_object_new (GDK_TYPE_QUARTZ_DEVICE_CORE,
|
||||
"name", "Core Keyboard",
|
||||
"type", GDK_DEVICE_TYPE_MASTER,
|
||||
"type", GDK_DEVICE_TYPE_LOGICAL,
|
||||
"input-source", GDK_SOURCE_KEYBOARD,
|
||||
"input-mode", GDK_MODE_SCREEN,
|
||||
"has-cursor", FALSE,
|
||||
@@ -112,8 +112,8 @@ gdk_quartz_device_manager_core_constructed (GObject *object)
|
||||
_gdk_device_set_associated_device (device_manager->core_pointer, device_manager->core_keyboard);
|
||||
_gdk_device_set_associated_device (device_manager->core_keyboard, device_manager->core_pointer);
|
||||
|
||||
seat = gdk_seat_default_new_for_master_pair (device_manager->core_pointer,
|
||||
device_manager->core_keyboard);
|
||||
seat = gdk_seat_default_new_for_logical_pair (device_manager->core_pointer,
|
||||
device_manager->core_keyboard);
|
||||
gdk_display_add_seat (display, seat);
|
||||
g_object_unref (seat);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user