Compare commits
1 Commits
wip/matthi
...
devel-them
Author | SHA1 | Date | |
---|---|---|---|
|
bb54bc7d14 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/subprojects/*/
|
@@ -1,7 +1,6 @@
|
||||
stages:
|
||||
- build
|
||||
- flatpak
|
||||
- deploy
|
||||
|
||||
.cache-paths: &cache-paths
|
||||
paths:
|
||||
@@ -13,7 +12,7 @@ stages:
|
||||
- subprojects/pango/
|
||||
|
||||
fedora-x86_64:
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/master:v2
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/master:v1
|
||||
stage: build
|
||||
script:
|
||||
- bash -x ./.gitlab-ci/test-docker.sh
|
||||
@@ -44,7 +43,7 @@ msys2-mingw32:
|
||||
<<: *mingw-defaults
|
||||
|
||||
.flatpak-defaults: &flatpak-defaults
|
||||
image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master
|
||||
image: registry.gitlab.com/alatiera/gnome-nightly-oci/gnome-master:latest
|
||||
stage: flatpak
|
||||
artifacts:
|
||||
paths:
|
||||
@@ -62,21 +61,3 @@ flatpak:widget-factory:
|
||||
variables:
|
||||
APPID: org.gtk.WidgetFactory
|
||||
<<: *flatpak-defaults
|
||||
|
||||
pages:
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/master:v2
|
||||
stage: deploy
|
||||
script:
|
||||
- meson -Ddocumentation=true _build .
|
||||
- ninja -C _build
|
||||
- ninja -C _build gdk4-doc gsk4-doc gtk4-doc
|
||||
|
||||
- mkdir -p public/
|
||||
- mv _build/docs/reference/gtk/html/ public/gtk/
|
||||
- mv _build/docs/reference/gdk/html/ public/gdk/
|
||||
- mv _build/docs/reference/gsk/html/ public/gsk/
|
||||
artifacts:
|
||||
paths:
|
||||
- public
|
||||
only:
|
||||
- master
|
||||
|
@@ -1,7 +1,6 @@
|
||||
FROM fedora:29
|
||||
FROM fedora:28
|
||||
|
||||
RUN dnf -y install \
|
||||
hicolor-icon-theme \
|
||||
adwaita-icon-theme \
|
||||
atk-devel \
|
||||
at-spi2-atk-devel \
|
||||
@@ -33,7 +32,6 @@ RUN dnf -y install \
|
||||
iso-codes \
|
||||
itstool \
|
||||
json-glib-devel \
|
||||
lcov \
|
||||
libattr-devel \
|
||||
libepoxy-devel \
|
||||
libffi-devel \
|
||||
@@ -70,7 +68,7 @@ RUN dnf -y install \
|
||||
xorg-x11-server-Xvfb \
|
||||
&& dnf clean all
|
||||
|
||||
RUN pip3 install meson==0.49.0
|
||||
RUN pip3 install meson
|
||||
|
||||
ARG HOST_USER_ID=5555
|
||||
ENV HOST_USER_ID ${HOST_USER_ID}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
TAG="registry.gitlab.gnome.org/gnome/gtk/master:v2"
|
||||
TAG="registry.gitlab.gnome.org/gnome/gtk/master:v1"
|
||||
|
||||
sudo docker build --build-arg HOST_USER_ID="$UID" --tag "${TAG}" \
|
||||
--file "Dockerfile" .
|
||||
|
@@ -45,7 +45,6 @@ meson \
|
||||
-Denable-x11-backend=false \
|
||||
-Denable-wayland-backend=false \
|
||||
-Denable-win32-backend=true \
|
||||
-Dvulkan=no \
|
||||
_build
|
||||
unset CCACHE_DISABLE
|
||||
|
||||
|
@@ -48,9 +48,9 @@ $ ninja
|
||||
```
|
||||
|
||||
**Note**: For information about submitting patches and pushing changes
|
||||
to Git, see the [README.md](./README.md) and [README.commits.md](./README.commits.md) files. In particular,
|
||||
to Git, see the `README.md` and `README.commits` files. In particular,
|
||||
don't, under any circumstances, push anything to Git before reading and
|
||||
understanding [README.commits.md](./README.commits.md).
|
||||
understanding `README.commmits`.
|
||||
|
||||
Typically, you should work on your own branch:
|
||||
|
||||
@@ -60,6 +60,6 @@ $ git checkout -b your-branch
|
||||
|
||||
Once you've finished working on the bug fix or feature, push the branch
|
||||
to the Git repository and open a new merge request, to let the GTK
|
||||
maintainers review your contribution. The [CODE-OWNERS](./docs/CODE-OWNERS)
|
||||
maintainers review your contribution. The [CODE-OWNERS](./docs-CODE-OWNERS)
|
||||
document contains the list of core contributors to GTK and the areas for
|
||||
which they are responsible.
|
||||
|
8
NEWS
8
NEWS
@@ -27,8 +27,8 @@ Overview of Changes in GTK+ 3.94.0
|
||||
* Applications can now create their own GtkSnapshot objects for
|
||||
intermediate rendering.
|
||||
|
||||
* Widget event signals have been replaced by event controllers,
|
||||
and some new event controllers have been introduced for this:
|
||||
* Widget event signals have been replaced by event controller, and
|
||||
some new event controllers have been introduced for this:
|
||||
GtkEventControllerMotion
|
||||
GtkEventControllerKey
|
||||
GtkGestureStylus
|
||||
@@ -68,10 +68,6 @@ Overview of Changes in GTK+ 3.94.0
|
||||
gtk_widget_draw
|
||||
gtk_render_icon_surface
|
||||
|
||||
* Incomplete transitions:
|
||||
The ::event signal is not still there, but it will be removed
|
||||
The DND apis are not finalized yet
|
||||
|
||||
* Translation updates:
|
||||
Croatian
|
||||
Esperanto
|
||||
|
@@ -7,23 +7,25 @@ avoid unnecessary breakage, and to take advantage of the knowledge
|
||||
about GTK+ that has been built up over the years, we'd like to ask
|
||||
people committing to GTK+ to follow a few rules:
|
||||
|
||||
0. Ask first. If your changes are major, or could possibly break existing
|
||||
0) Ask first. If your changes are major, or could possibly break existing
|
||||
code, you should always ask. If your change is minor and you've
|
||||
been working on GTK+ for a while it probably isn't necessary
|
||||
to ask. But when in doubt, ask. Even if your change is correct,
|
||||
somebody may know a better way to do things.
|
||||
|
||||
If you are making changes to GTK+, you should be subscribed
|
||||
to gtk-devel-list@gnome.org. (Subscription address:
|
||||
gtk-devel-list-request@gnome.org.) This is a good place to ask
|
||||
about intended changes.
|
||||
|
||||
#gtk+ on GIMPNet (irc.gimp.org, irc.us.gimp.org, irc.eu.gimp.org, ...)
|
||||
is also a good place to find GTK+ developers to discuss changes with,
|
||||
however, email to gtk-devel-list is the most certain and preferred
|
||||
method.
|
||||
|
||||
0. Ask _first_.
|
||||
1) Ask _first_.
|
||||
|
||||
0. With git, we no longer maintain a ChangeLog file, but you are expected
|
||||
2) With git, we no longer maintain a ChangeLog file, but you are expected
|
||||
to produce a meaningful commit message. Changes without a sufficient
|
||||
commit message will be reverted. See below for the expected format
|
||||
of commit messages.
|
||||
@@ -37,13 +39,13 @@ Notes:
|
||||
|
||||
* The expected format for git commit messages is as follows:
|
||||
|
||||
```
|
||||
=== begin example commit ===
|
||||
Short explanation of the commit
|
||||
|
||||
Longer explanation explaining exactly what's changed, whether any
|
||||
external or private interfaces changed, what bugs were fixed (with bug
|
||||
tracker reference if applicable) and so forth. Be concise but not too brief.
|
||||
```
|
||||
=== end example commit ===
|
||||
|
||||
- Always add a brief description of the commit to the _first_ line of
|
||||
the commit and terminate by two newlines (it will work without the
|
||||
@@ -58,8 +60,8 @@ tracker reference if applicable) and so forth. Be concise but not too brief.
|
||||
punctuation and capital letters where appropriate. Normally, for patches
|
||||
sent to a mailing list it's copied from there.
|
||||
|
||||
- When committing code on behalf of others use the `--author` option, e.g.
|
||||
`git commit -a --author "Joe Coder <joe@coder.org>"` and `--signoff`.
|
||||
- When committing code on behalf of others use the --author option, e.g.
|
||||
git commit -a --author "Joe Coder <joe@coder.org>" and --signoff.
|
||||
|
||||
|
||||
Owen Taylor
|
||||
@@ -68,4 +70,3 @@ Owen Taylor
|
||||
|
||||
Matthias Clasen
|
||||
31 Mar 2009
|
||||
|
@@ -31,11 +31,6 @@ Information about mailing lists can be found at
|
||||
|
||||
- http://www.gtk.org/mailing-lists.php
|
||||
|
||||
Nightly documentation can be found at
|
||||
- Gtk: https://gnome.pages.gitlab.gnome.org/gtk/gtk/
|
||||
- Gdk: https://gnome.pages.gitlab.gnome.org/gtk/gdk/
|
||||
- Gsk: https://gnome.pages.gitlab.gnome.org/gtk/gsk/
|
||||
|
||||
Building and installing
|
||||
-----------------------
|
||||
|
||||
|
@@ -5,6 +5,7 @@
|
||||
"sdk": "org.gnome.Sdk",
|
||||
"command": "gtk4-demo",
|
||||
"tags": ["devel", "development", "nightly"],
|
||||
"rename-desktop-file": "gtk4-demo.desktop",
|
||||
"rename-icon": "gtk4-demo",
|
||||
"desktop-file-name-prefix": "(Development) ",
|
||||
"finish-args": [
|
||||
@@ -45,9 +46,7 @@
|
||||
"buildsystem": "meson",
|
||||
"builddir": true,
|
||||
"config-opts": [
|
||||
"--libdir=/app/lib",
|
||||
"-Dtests=false",
|
||||
"-Dbenchmarks=false"
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources": [
|
||||
{
|
||||
|
@@ -5,6 +5,7 @@
|
||||
"sdk": "org.gnome.Sdk",
|
||||
"command": "gtk4-widget-factory",
|
||||
"tags": ["devel", "development", "nightly"],
|
||||
"rename-desktop-file": "gtk4-widget-factory.desktop",
|
||||
"rename-icon": "gtk4-widget-factory",
|
||||
"desktop-file-name-prefix": "(Development) ",
|
||||
"finish-args": [
|
||||
@@ -45,9 +46,7 @@
|
||||
"buildsystem": "meson",
|
||||
"builddir": true,
|
||||
"config-opts": [
|
||||
"--libdir=/app/lib",
|
||||
"-Dtests=false",
|
||||
"-Dbenchmarks=false"
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources": [
|
||||
{
|
||||
|
@@ -305,13 +305,3 @@
|
||||
#mesondefine HAVE_PANGOFT
|
||||
|
||||
#mesondefine ISO_CODES_PREFIX
|
||||
|
||||
#mesondefine MALLOC_IS_ALIGNED16
|
||||
|
||||
#mesondefine HAVE_POSIX_MEMALIGN
|
||||
|
||||
#mesondefine HAVE_MEMALIGN
|
||||
|
||||
#mesondefine HAVE_ALIGNED_ALLOC
|
||||
|
||||
#mesondefine HAVE__ALIGNED_MALLOC
|
||||
|
@@ -455,16 +455,13 @@ demo_application_window_constructed (GObject *object)
|
||||
}
|
||||
|
||||
static void
|
||||
demo_application_window_size_allocate (GtkWidget *widget,
|
||||
int width,
|
||||
int height,
|
||||
int baseline)
|
||||
demo_application_window_size_allocate (GtkWidget *widget,
|
||||
const GtkAllocation *allocation,
|
||||
int baseline)
|
||||
{
|
||||
DemoApplicationWindow *window = (DemoApplicationWindow *)widget;
|
||||
|
||||
GTK_WIDGET_CLASS (demo_application_window_parent_class)->size_allocate (widget,
|
||||
width,
|
||||
height,
|
||||
GTK_WIDGET_CLASS (demo_application_window_parent_class)->size_allocate (widget, allocation,
|
||||
baseline);
|
||||
|
||||
if (!window->maximized && !window->fullscreen)
|
||||
|
@@ -87,14 +87,14 @@ find_toplevel_at_pointer (GdkDisplay *display)
|
||||
return widget ? gtk_widget_get_toplevel (widget) : NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
released_cb (GtkGestureMultiPress *gesture,
|
||||
guint n_press,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gboolean *clicked)
|
||||
static gboolean
|
||||
release_event_cb (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gboolean *clicked)
|
||||
{
|
||||
*clicked = TRUE;
|
||||
if (gdk_event_get_event_type (event) == GDK_BUTTON_RELEASE)
|
||||
*clicked = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Asks the user to click on a window, then waits for them click
|
||||
@@ -132,12 +132,10 @@ query_for_toplevel (GdkDisplay *display,
|
||||
GDK_SEAT_CAPABILITY_ALL_POINTING,
|
||||
FALSE, cursor, NULL, NULL, NULL) == GDK_GRAB_SUCCESS)
|
||||
{
|
||||
GtkGesture *gesture = gtk_gesture_multi_press_new ();
|
||||
gboolean clicked = FALSE;
|
||||
|
||||
g_signal_connect (gesture, "released",
|
||||
G_CALLBACK (released_cb), &clicked);
|
||||
gtk_widget_add_controller (popup, GTK_EVENT_CONTROLLER (gesture));
|
||||
g_signal_connect (popup, "event",
|
||||
G_CALLBACK (release_event_cb), &clicked);
|
||||
|
||||
/* Process events until clicked is set by our button release event handler.
|
||||
* We pass in may_block=TRUE since we want to wait if there
|
||||
@@ -146,8 +144,6 @@ query_for_toplevel (GdkDisplay *display,
|
||||
while (!clicked)
|
||||
g_main_context_iteration (NULL, TRUE);
|
||||
|
||||
gdk_seat_ungrab (gdk_device_get_seat (device));
|
||||
|
||||
toplevel = find_toplevel_at_pointer (display);
|
||||
if (toplevel == popup)
|
||||
toplevel = NULL;
|
||||
|
@@ -120,7 +120,7 @@ get_image_paintable (GtkImage *image)
|
||||
|
||||
static void
|
||||
drag_begin (GtkWidget *widget,
|
||||
GdkDrag *drag,
|
||||
GdkDragContext *context,
|
||||
gpointer data)
|
||||
{
|
||||
GdkPaintable *paintable;
|
||||
@@ -128,16 +128,17 @@ drag_begin (GtkWidget *widget,
|
||||
paintable = get_image_paintable (GTK_IMAGE (widget));
|
||||
if (paintable)
|
||||
{
|
||||
gtk_drag_set_icon_paintable (drag, paintable, -2, -2);
|
||||
gtk_drag_set_icon_paintable (context, paintable, -2, -2);
|
||||
g_object_unref (paintable);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
drag_data_get (GtkWidget *widget,
|
||||
GdkDrag *drag,
|
||||
GdkDragContext *context,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time,
|
||||
gpointer data)
|
||||
{
|
||||
GdkPaintable *paintable;
|
||||
@@ -149,8 +150,9 @@ drag_data_get (GtkWidget *widget,
|
||||
|
||||
static void
|
||||
drag_data_received (GtkWidget *widget,
|
||||
GdkDrop *drop,
|
||||
GdkDragContext *context,
|
||||
GtkSelectionData *selection_data,
|
||||
guint32 time,
|
||||
gpointer data)
|
||||
{
|
||||
if (gtk_selection_data_get_length (selection_data) > 0)
|
||||
|
@@ -144,7 +144,7 @@ create_capital_store (void)
|
||||
{ NULL, "Jackson" },
|
||||
{ NULL, "Jefferson City" },
|
||||
{ NULL, "Juneau" },
|
||||
{ "K - O", NULL },
|
||||
{ "K - O" },
|
||||
{ NULL, "Lansing" },
|
||||
{ NULL, "Lincoln" },
|
||||
{ NULL, "Little Rock" },
|
||||
@@ -154,7 +154,7 @@ create_capital_store (void)
|
||||
{ NULL, "Nashville" },
|
||||
{ NULL, "Oklahoma City" },
|
||||
{ NULL, "Olympia" },
|
||||
{ "P - S", NULL },
|
||||
{ NULL, "P - S" },
|
||||
{ NULL, "Phoenix" },
|
||||
{ NULL, "Pierre" },
|
||||
{ NULL, "Providence" },
|
||||
|
@@ -3,6 +3,7 @@
|
||||
<gresource prefix="/ui">
|
||||
<file preprocess="xml-stripblanks">main.ui</file>
|
||||
<file preprocess="xml-stripblanks">appmenu.ui</file>
|
||||
<file>theme.css</file>
|
||||
</gresource>
|
||||
<gresource prefix="/application_demo">
|
||||
<file>application.c</file>
|
||||
@@ -105,6 +106,9 @@
|
||||
<file>gnome-fs-directory.png</file>
|
||||
<file>gnome-fs-regular.png</file>
|
||||
</gresource>
|
||||
<gresource prefix="/stack">
|
||||
<file>stack.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/shortcuts">
|
||||
<file>shortcuts.ui</file>
|
||||
<file>shortcuts-builder.ui</file>
|
||||
@@ -112,14 +116,6 @@
|
||||
<file>shortcuts-clocks.ui</file>
|
||||
<file>shortcuts-boxes.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/sliding_puzzle">
|
||||
<file>puzzlepiece.c</file>
|
||||
<file>puzzlepiece.h</file>
|
||||
<file>portland-rose.jpg</file>
|
||||
</gresource>
|
||||
<gresource prefix="/stack">
|
||||
<file>stack.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/revealer">
|
||||
<file>revealer.ui</file>
|
||||
</gresource>
|
||||
@@ -161,6 +157,7 @@
|
||||
<file>editable_cells.c</file>
|
||||
<file>entry_buffer.c</file>
|
||||
<file>entry_completion.c</file>
|
||||
<file>event_axes.c</file>
|
||||
<file>expander.c</file>
|
||||
<file>filtermodel.c</file>
|
||||
<file>fishbowl.c</file>
|
||||
@@ -179,7 +176,6 @@
|
||||
<file>links.c</file>
|
||||
<file>listbox.c</file>
|
||||
<file>list_store.c</file>
|
||||
<file>listview.c</file>
|
||||
<file>markup.c</file>
|
||||
<file>menus.c</file>
|
||||
<file>modelbutton.c</file>
|
||||
@@ -203,7 +199,6 @@
|
||||
<file>shortcuts.c</file>
|
||||
<file>sizegroup.c</file>
|
||||
<file>sidebar.c</file>
|
||||
<file>sliding_puzzle.c</file>
|
||||
<file>stack.c</file>
|
||||
<file>spinbutton.c</file>
|
||||
<file>spinner.c</file>
|
||||
@@ -224,11 +219,6 @@
|
||||
<file>messages.txt</file>
|
||||
<file>apple-red.png</file>
|
||||
</gresource>
|
||||
<gresource prefix="/listview">
|
||||
<file>listview.ui</file>
|
||||
<file>messages.txt</file>
|
||||
<file>apple-red.png</file>
|
||||
</gresource>
|
||||
<gresource prefix="/popover">
|
||||
<file>popover.ui</file>
|
||||
</gresource>
|
||||
|
666
demos/gtk-demo/event_axes.c
Normal file
666
demos/gtk-demo/event_axes.c
Normal file
@@ -0,0 +1,666 @@
|
||||
/* Touch and Drawing Tablets
|
||||
*
|
||||
* Demonstrates advanced handling of event information from exotic
|
||||
* input devices.
|
||||
*
|
||||
* On one hand, this snippet demonstrates management of drawing tablets,
|
||||
* those contain additional information for the pointer other than
|
||||
* X/Y coordinates. Tablet pads events are mapped to actions, which
|
||||
* are both defined and interpreted by the application.
|
||||
*
|
||||
* Input axes are dependent on hardware devices, on linux/unix you
|
||||
* can see the device axes through xinput list <device>. Each time
|
||||
* a different hardware device is used to move the pointer, the
|
||||
* master device will be updated to match the axes it provides,
|
||||
* these changes can be tracked through GdkDevice::changed, or
|
||||
* checking gdk_event_get_source_device().
|
||||
*
|
||||
* On the other hand, this demo handles basic multitouch events,
|
||||
* each event coming from an specific touchpoint will contain a
|
||||
* GdkEventSequence that's unique for its lifetime, so multiple
|
||||
* touchpoints can be tracked.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
typedef struct {
|
||||
GdkDevice *last_source;
|
||||
GdkDeviceTool *last_tool;
|
||||
gdouble *axes;
|
||||
GdkRGBA color;
|
||||
gdouble x;
|
||||
gdouble y;
|
||||
} AxesInfo;
|
||||
|
||||
typedef struct {
|
||||
GHashTable *pointer_info; /* GdkDevice -> AxesInfo */
|
||||
GHashTable *touch_info; /* GdkEventSequence -> AxesInfo */
|
||||
} EventData;
|
||||
|
||||
const gchar *colors[] = {
|
||||
"black",
|
||||
"orchid",
|
||||
"fuchsia",
|
||||
"indigo",
|
||||
"thistle",
|
||||
"sienna",
|
||||
"azure",
|
||||
"plum",
|
||||
"lime",
|
||||
"navy",
|
||||
"maroon",
|
||||
"burlywood"
|
||||
};
|
||||
|
||||
static GtkPadActionEntry pad_actions[] = {
|
||||
{ GTK_PAD_ACTION_BUTTON, 1, -1, N_("Nuclear strike"), "pad.nuke" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 2, -1, N_("Release siberian methane reserves"), "pad.heat" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 3, -1, N_("Release solar flare"), "pad.fry" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 4, -1, N_("De-stabilize Oort cloud"), "pad.fall" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 5, -1, N_("Ignite WR-104"), "pad.burst" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 6, -1, N_("Lart whoever asks about this button"), "pad.lart" },
|
||||
{ GTK_PAD_ACTION_RING, -1, -1, N_("Earth axial tilt"), "pad.tilt" },
|
||||
{ GTK_PAD_ACTION_STRIP, -1, -1, N_("Extent of weak nuclear force"), "pad.dissolve" },
|
||||
};
|
||||
|
||||
static const gchar *pad_action_results[] = {
|
||||
"☢",
|
||||
"♨",
|
||||
"☼",
|
||||
"☄",
|
||||
"⚡",
|
||||
"💫",
|
||||
"◑",
|
||||
"⚛"
|
||||
};
|
||||
|
||||
static guint cur_color = 0;
|
||||
static guint pad_action_timeout_id = 0;
|
||||
|
||||
static AxesInfo *
|
||||
axes_info_new (void)
|
||||
{
|
||||
AxesInfo *info;
|
||||
|
||||
info = g_new0 (AxesInfo, 1);
|
||||
gdk_rgba_parse (&info->color, colors[cur_color]);
|
||||
|
||||
cur_color = (cur_color + 1) % G_N_ELEMENTS (colors);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static EventData *
|
||||
event_data_new (void)
|
||||
{
|
||||
EventData *data;
|
||||
|
||||
data = g_new0 (EventData, 1);
|
||||
data->pointer_info = g_hash_table_new_full (NULL, NULL, NULL,
|
||||
(GDestroyNotify) g_free);
|
||||
data->touch_info = g_hash_table_new_full (NULL, NULL, NULL,
|
||||
(GDestroyNotify) g_free);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static void
|
||||
event_data_free (EventData *data)
|
||||
{
|
||||
g_hash_table_destroy (data->pointer_info);
|
||||
g_hash_table_destroy (data->touch_info);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
static void
|
||||
update_axes_from_event (GdkEvent *event,
|
||||
EventData *data)
|
||||
{
|
||||
GdkDevice *device, *source_device;
|
||||
GdkEventSequence *sequence;
|
||||
GdkDeviceTool *tool;
|
||||
GdkEventType type;
|
||||
gdouble x, y;
|
||||
AxesInfo *info;
|
||||
|
||||
device = gdk_event_get_device (event);
|
||||
source_device = gdk_event_get_source_device (event);
|
||||
sequence = gdk_event_get_event_sequence (event);
|
||||
tool = gdk_event_get_device_tool (event);
|
||||
type = gdk_event_get_event_type (event);
|
||||
|
||||
if (type == GDK_TOUCH_END ||
|
||||
type == GDK_TOUCH_CANCEL)
|
||||
{
|
||||
g_hash_table_remove (data->touch_info, sequence);
|
||||
return;
|
||||
}
|
||||
else if (type == GDK_LEAVE_NOTIFY)
|
||||
{
|
||||
g_hash_table_remove (data->pointer_info, device);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!source_device)
|
||||
return;
|
||||
|
||||
if (!sequence)
|
||||
{
|
||||
info = g_hash_table_lookup (data->pointer_info, device);
|
||||
|
||||
if (!info)
|
||||
{
|
||||
info = axes_info_new ();
|
||||
g_hash_table_insert (data->pointer_info, device, info);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
info = g_hash_table_lookup (data->touch_info, sequence);
|
||||
|
||||
if (!info)
|
||||
{
|
||||
info = axes_info_new ();
|
||||
g_hash_table_insert (data->touch_info, sequence, info);
|
||||
}
|
||||
}
|
||||
|
||||
if (info->last_source != source_device)
|
||||
info->last_source = source_device;
|
||||
|
||||
if (info->last_tool != tool)
|
||||
info->last_tool = tool;
|
||||
|
||||
g_clear_pointer (&info->axes, g_free);
|
||||
|
||||
if (type == GDK_TOUCH_BEGIN ||
|
||||
type == GDK_TOUCH_UPDATE)
|
||||
{
|
||||
gboolean emulating_pointer;
|
||||
|
||||
gdk_event_get_touch_emulating_pointer (event, &emulating_pointer);
|
||||
if (sequence && emulating_pointer)
|
||||
g_hash_table_remove (data->pointer_info, device);
|
||||
}
|
||||
if (type == GDK_MOTION_NOTIFY ||
|
||||
type == GDK_BUTTON_PRESS ||
|
||||
type == GDK_BUTTON_RELEASE)
|
||||
{
|
||||
gdouble *axes;
|
||||
guint n_axes;
|
||||
|
||||
gdk_event_get_axes (event, &axes, &n_axes);
|
||||
info->axes = g_memdup (axes, sizeof (double) * n_axes);
|
||||
}
|
||||
|
||||
if (gdk_event_get_coords (event, &x, &y))
|
||||
{
|
||||
info->x = x;
|
||||
info->y = y;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
event_cb (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
update_axes_from_event (event, user_data);
|
||||
gtk_widget_queue_draw (widget);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
render_arrow (cairo_t *cr,
|
||||
gdouble x_diff,
|
||||
gdouble y_diff,
|
||||
const gchar *label)
|
||||
{
|
||||
cairo_save (cr);
|
||||
|
||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||
cairo_new_path (cr);
|
||||
cairo_move_to (cr, 0, 0);
|
||||
cairo_line_to (cr, x_diff, y_diff);
|
||||
cairo_stroke (cr);
|
||||
|
||||
cairo_move_to (cr, x_diff, y_diff);
|
||||
cairo_show_text (cr, label);
|
||||
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_axes_info (cairo_t *cr,
|
||||
AxesInfo *info,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
gdouble pressure, tilt_x, tilt_y, distance, wheel, rotation, slider;
|
||||
GdkAxisFlags axes = gdk_device_get_axes (info->last_source);
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
cairo_set_line_width (cr, 1);
|
||||
gdk_cairo_set_source_rgba (cr, &info->color);
|
||||
|
||||
cairo_move_to (cr, 0, info->y);
|
||||
cairo_line_to (cr, width, info->y);
|
||||
cairo_move_to (cr, info->x, 0);
|
||||
cairo_line_to (cr, info->x, height);
|
||||
cairo_stroke (cr);
|
||||
|
||||
cairo_translate (cr, info->x, info->y);
|
||||
|
||||
if (!info->axes)
|
||||
{
|
||||
cairo_restore (cr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (axes & GDK_AXIS_FLAG_PRESSURE)
|
||||
{
|
||||
cairo_pattern_t *pattern;
|
||||
|
||||
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_PRESSURE,
|
||||
&pressure);
|
||||
|
||||
pattern = cairo_pattern_create_radial (0, 0, 0, 0, 0, 100);
|
||||
cairo_pattern_add_color_stop_rgba (pattern, pressure, 1, 0, 0, pressure);
|
||||
cairo_pattern_add_color_stop_rgba (pattern, 1, 0, 0, 1, 0);
|
||||
|
||||
cairo_set_source (cr, pattern);
|
||||
|
||||
cairo_arc (cr, 0, 0, 100, 0, 2 * G_PI);
|
||||
cairo_fill (cr);
|
||||
|
||||
cairo_pattern_destroy (pattern);
|
||||
}
|
||||
|
||||
if (axes & GDK_AXIS_FLAG_XTILT &&
|
||||
axes & GDK_AXIS_FLAG_YTILT)
|
||||
{
|
||||
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_XTILT,
|
||||
&tilt_x);
|
||||
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_YTILT,
|
||||
&tilt_y);
|
||||
|
||||
render_arrow (cr, tilt_x * 100, tilt_y * 100, "Tilt");
|
||||
}
|
||||
|
||||
if (axes & GDK_AXIS_FLAG_DISTANCE)
|
||||
{
|
||||
double dashes[] = { 5.0, 5.0 };
|
||||
cairo_text_extents_t extents;
|
||||
|
||||
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_DISTANCE,
|
||||
&distance);
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
cairo_move_to (cr, distance * 100, 0);
|
||||
|
||||
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
|
||||
cairo_set_dash (cr, dashes, 2, 0.0);
|
||||
cairo_arc (cr, 0, 0, distance * 100, 0, 2 * G_PI);
|
||||
cairo_stroke (cr);
|
||||
|
||||
cairo_move_to (cr, 0, -distance * 100);
|
||||
cairo_text_extents (cr, "Distance", &extents);
|
||||
cairo_rel_move_to (cr, -extents.width / 2, 0);
|
||||
cairo_show_text (cr, "Distance");
|
||||
|
||||
cairo_move_to (cr, 0, 0);
|
||||
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
if (axes & GDK_AXIS_FLAG_WHEEL)
|
||||
{
|
||||
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_WHEEL,
|
||||
&wheel);
|
||||
|
||||
cairo_save (cr);
|
||||
cairo_set_line_width (cr, 10);
|
||||
cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
|
||||
|
||||
cairo_new_sub_path (cr);
|
||||
cairo_arc (cr, 0, 0, 100, 0, wheel * 2 * G_PI);
|
||||
cairo_stroke (cr);
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
if (axes & GDK_AXIS_FLAG_ROTATION)
|
||||
{
|
||||
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_ROTATION,
|
||||
&rotation);
|
||||
rotation *= 2 * G_PI;
|
||||
|
||||
cairo_save (cr);
|
||||
cairo_rotate (cr, - G_PI / 2);
|
||||
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
|
||||
cairo_set_line_width (cr, 5);
|
||||
|
||||
cairo_new_sub_path (cr);
|
||||
cairo_arc (cr, 0, 0, 100, 0, rotation);
|
||||
cairo_stroke (cr);
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
if (axes & GDK_AXIS_FLAG_SLIDER)
|
||||
{
|
||||
cairo_pattern_t *pattern, *mask;
|
||||
|
||||
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_SLIDER,
|
||||
&slider);
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
cairo_move_to (cr, 0, -10);
|
||||
cairo_rel_line_to (cr, 0, -50);
|
||||
cairo_rel_line_to (cr, 10, 0);
|
||||
cairo_rel_line_to (cr, -5, 50);
|
||||
cairo_close_path (cr);
|
||||
|
||||
cairo_clip_preserve (cr);
|
||||
|
||||
pattern = cairo_pattern_create_linear (0, -10, 0, -60);
|
||||
cairo_pattern_add_color_stop_rgb (pattern, 0, 0, 1, 0);
|
||||
cairo_pattern_add_color_stop_rgb (pattern, 1, 1, 0, 0);
|
||||
cairo_set_source (cr, pattern);
|
||||
cairo_pattern_destroy (pattern);
|
||||
|
||||
mask = cairo_pattern_create_linear (0, -10, 0, -60);
|
||||
cairo_pattern_add_color_stop_rgba (mask, 0, 0, 0, 0, 1);
|
||||
cairo_pattern_add_color_stop_rgba (mask, slider, 0, 0, 0, 1);
|
||||
cairo_pattern_add_color_stop_rgba (mask, slider, 0, 0, 0, 0);
|
||||
cairo_pattern_add_color_stop_rgba (mask, 1, 0, 0, 0, 0);
|
||||
cairo_mask (cr, mask);
|
||||
cairo_pattern_destroy (mask);
|
||||
|
||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||
cairo_stroke (cr);
|
||||
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
tool_type_to_string (GdkDeviceToolType tool_type)
|
||||
{
|
||||
switch (tool_type)
|
||||
{
|
||||
case GDK_DEVICE_TOOL_TYPE_PEN:
|
||||
return "Pen";
|
||||
case GDK_DEVICE_TOOL_TYPE_ERASER:
|
||||
return "Eraser";
|
||||
case GDK_DEVICE_TOOL_TYPE_BRUSH:
|
||||
return "Brush";
|
||||
case GDK_DEVICE_TOOL_TYPE_PENCIL:
|
||||
return "Pencil";
|
||||
case GDK_DEVICE_TOOL_TYPE_AIRBRUSH:
|
||||
return "Airbrush";
|
||||
case GDK_DEVICE_TOOL_TYPE_MOUSE:
|
||||
return "Mouse";
|
||||
case GDK_DEVICE_TOOL_TYPE_LENS:
|
||||
return "Lens cursor";
|
||||
case GDK_DEVICE_TOOL_TYPE_UNKNOWN:
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_device_info (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
GdkEventSequence *sequence,
|
||||
gint *y,
|
||||
AxesInfo *info)
|
||||
{
|
||||
PangoLayout *layout;
|
||||
GString *string;
|
||||
gint height;
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
string = g_string_new (NULL);
|
||||
g_string_append_printf (string, "Source: %s",
|
||||
gdk_device_get_name (info->last_source));
|
||||
|
||||
if (sequence)
|
||||
g_string_append_printf (string, "\nSequence: %d",
|
||||
GPOINTER_TO_UINT (sequence));
|
||||
|
||||
if (info->last_tool)
|
||||
{
|
||||
const gchar *tool_type;
|
||||
guint64 serial;
|
||||
|
||||
tool_type = tool_type_to_string (gdk_device_tool_get_tool_type (info->last_tool));
|
||||
serial = gdk_device_tool_get_serial (info->last_tool);
|
||||
g_string_append_printf (string, "\nTool: %s", tool_type);
|
||||
|
||||
if (serial != 0)
|
||||
g_string_append_printf (string, ", Serial: %lx", serial);
|
||||
}
|
||||
|
||||
cairo_move_to (cr, 10, *y);
|
||||
layout = gtk_widget_create_pango_layout (widget, string->str);
|
||||
pango_cairo_show_layout (cr, layout);
|
||||
cairo_stroke (cr);
|
||||
|
||||
pango_layout_get_pixel_size (layout, NULL, &height);
|
||||
|
||||
gdk_cairo_set_source_rgba (cr, &info->color);
|
||||
cairo_set_line_width (cr, 10);
|
||||
cairo_move_to (cr, 0, *y);
|
||||
|
||||
*y = *y + height;
|
||||
cairo_line_to (cr, 0, *y);
|
||||
cairo_stroke (cr);
|
||||
|
||||
cairo_restore (cr);
|
||||
|
||||
g_object_unref (layout);
|
||||
g_string_free (string, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_cb (GtkDrawingArea *da,
|
||||
cairo_t *cr,
|
||||
int width,
|
||||
int height,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (da);
|
||||
EventData *data = user_data;
|
||||
AxesInfo *info;
|
||||
GHashTableIter iter;
|
||||
gpointer key, value;
|
||||
gint y = 0;
|
||||
|
||||
/* Draw Abs info */
|
||||
g_hash_table_iter_init (&iter, data->pointer_info);
|
||||
|
||||
while (g_hash_table_iter_next (&iter, NULL, &value))
|
||||
{
|
||||
info = value;
|
||||
draw_axes_info (cr, info, width, height);
|
||||
}
|
||||
|
||||
g_hash_table_iter_init (&iter, data->touch_info);
|
||||
|
||||
while (g_hash_table_iter_next (&iter, NULL, &value))
|
||||
{
|
||||
info = value;
|
||||
draw_axes_info (cr, info, width, height);
|
||||
}
|
||||
|
||||
/* Draw name, color legend and misc data */
|
||||
g_hash_table_iter_init (&iter, data->pointer_info);
|
||||
|
||||
while (g_hash_table_iter_next (&iter, NULL, &value))
|
||||
{
|
||||
info = value;
|
||||
draw_device_info (widget, cr, NULL, &y, info);
|
||||
}
|
||||
|
||||
g_hash_table_iter_init (&iter, data->touch_info);
|
||||
|
||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||
{
|
||||
info = value;
|
||||
draw_device_info (widget, cr, key, &y, info);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_label_text (GtkWidget *label,
|
||||
const gchar *text)
|
||||
{
|
||||
gchar *markup = NULL;
|
||||
|
||||
if (text)
|
||||
markup = g_strdup_printf ("<span font='48.0'>%s</span>", text);
|
||||
gtk_label_set_markup (GTK_LABEL (label), markup);
|
||||
g_free (markup);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
reset_label_text_timeout_cb (gpointer user_data)
|
||||
{
|
||||
GtkWidget *label = user_data;
|
||||
|
||||
update_label_text (label, NULL);
|
||||
pad_action_timeout_id = 0;
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void
|
||||
update_label_and_timeout (GtkWidget *label,
|
||||
const gchar *text)
|
||||
{
|
||||
if (pad_action_timeout_id)
|
||||
g_source_remove (pad_action_timeout_id);
|
||||
|
||||
update_label_text (label, text);
|
||||
pad_action_timeout_id = g_timeout_add (200, reset_label_text_timeout_cb, label);
|
||||
}
|
||||
|
||||
static void
|
||||
on_action_activate (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *label = user_data;
|
||||
const gchar *result;
|
||||
gchar *str;
|
||||
|
||||
result = g_object_get_data (G_OBJECT (action), "action-result");
|
||||
|
||||
if (!parameter)
|
||||
update_label_and_timeout (label, result);
|
||||
else
|
||||
{
|
||||
str = g_strdup_printf ("%s %.2f", result, g_variant_get_double (parameter));
|
||||
update_label_and_timeout (label, str);
|
||||
g_free (str);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
init_pad_controller (GtkWidget *window,
|
||||
GtkWidget *label)
|
||||
{
|
||||
GtkPadController *pad_controller;
|
||||
GSimpleActionGroup *action_group;
|
||||
GSimpleAction *action;
|
||||
gint i;
|
||||
|
||||
action_group = g_simple_action_group_new ();
|
||||
pad_controller = gtk_pad_controller_new (G_ACTION_GROUP (action_group),
|
||||
NULL);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (pad_actions); i++)
|
||||
{
|
||||
if (pad_actions[i].type == GTK_PAD_ACTION_BUTTON)
|
||||
{
|
||||
action = g_simple_action_new (pad_actions[i].action_name, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
action = g_simple_action_new_stateful (pad_actions[i].action_name,
|
||||
G_VARIANT_TYPE_DOUBLE, NULL);
|
||||
}
|
||||
|
||||
g_signal_connect (action, "activate",
|
||||
G_CALLBACK (on_action_activate), label);
|
||||
g_object_set_data (G_OBJECT (action), "action-result",
|
||||
(gpointer) pad_action_results[i]);
|
||||
g_action_map_add_action (G_ACTION_MAP (action_group), G_ACTION (action));
|
||||
g_object_unref (action);
|
||||
}
|
||||
|
||||
gtk_pad_controller_set_action_entries (pad_controller, pad_actions,
|
||||
G_N_ELEMENTS (pad_actions));
|
||||
gtk_widget_add_controller (window, GTK_EVENT_CONTROLLER (pad_controller));
|
||||
|
||||
g_object_unref (action_group);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_event_axes (GtkWidget *toplevel)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
EventData *event_data;
|
||||
GtkWidget *label;
|
||||
GtkWidget *overlay;
|
||||
GtkWidget *da;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Touch and Drawing Tablets");
|
||||
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
||||
gtk_widget_set_support_multidevice (window, TRUE);
|
||||
|
||||
event_data = event_data_new ();
|
||||
g_object_set_data_full (G_OBJECT (window), "gtk-demo-event-data",
|
||||
event_data, (GDestroyNotify) event_data_free);
|
||||
|
||||
da = gtk_drawing_area_new ();
|
||||
gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (da), 400);
|
||||
gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (da), 400);
|
||||
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), draw_cb, event_data, NULL);
|
||||
gtk_widget_set_can_focus (da, TRUE);
|
||||
gtk_widget_grab_focus (da);
|
||||
|
||||
g_signal_connect (da, "event",
|
||||
G_CALLBACK (event_cb), event_data);
|
||||
|
||||
label = gtk_label_new ("");
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_START);
|
||||
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
|
||||
|
||||
overlay = gtk_overlay_new ();
|
||||
gtk_container_add (GTK_CONTAINER (window), overlay);
|
||||
gtk_container_add (GTK_CONTAINER (overlay), da);
|
||||
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), label);
|
||||
|
||||
init_pad_controller (da, label);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
|
||||
return window;
|
||||
}
|
@@ -134,9 +134,7 @@ static GtkWidget *
|
||||
create_video (void)
|
||||
{
|
||||
GtkMediaStream *stream = gtk_media_file_new_for_resource ("/images/gtk-logo.webm");
|
||||
GtkWidget *w = gtk_picture_new_for_paintable (GDK_PAINTABLE (stream));
|
||||
|
||||
gtk_widget_set_size_request (w, 64, 64);
|
||||
GtkWidget *w = gtk_image_new_from_paintable (GDK_PAINTABLE (stream));
|
||||
gtk_media_stream_set_loop (stream, TRUE);
|
||||
gtk_media_stream_play (stream);
|
||||
g_object_unref (stream);
|
||||
|
@@ -166,6 +166,7 @@ do_gestures (GtkWidget *do_widget)
|
||||
|
||||
/* 3fg swipe for touchpads */
|
||||
gesture = g_object_new (GTK_TYPE_GESTURE_SWIPE,
|
||||
"widget", drawing_area,
|
||||
"n-points", 3,
|
||||
NULL);
|
||||
g_signal_connect (gesture, "begin",
|
||||
@@ -174,8 +175,7 @@ do_gestures (GtkWidget *do_widget)
|
||||
G_CALLBACK (swipe_gesture_swept), drawing_area);
|
||||
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
|
||||
GTK_PHASE_BUBBLE);
|
||||
gtk_widget_add_controller (drawing_area, GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
g_object_weak_ref (G_OBJECT (drawing_area), (GWeakNotify) g_object_unref, gesture);
|
||||
|
||||
/* Long press */
|
||||
gesture = gtk_gesture_long_press_new ();
|
||||
|
@@ -128,10 +128,9 @@ gtk_fishbowl_measure (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_fishbowl_size_allocate (GtkWidget *widget,
|
||||
int width,
|
||||
int height,
|
||||
int baseline)
|
||||
gtk_fishbowl_size_allocate (GtkWidget *widget,
|
||||
const GtkAllocation *allocation,
|
||||
int baseline)
|
||||
{
|
||||
GtkFishbowl *fishbowl = GTK_FISHBOWL (widget);
|
||||
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
|
||||
@@ -148,8 +147,8 @@ gtk_fishbowl_size_allocate (GtkWidget *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));
|
||||
child_allocation.x = allocation->x + round (child->x * (allocation->width - child_requisition.width));
|
||||
child_allocation.y = allocation->y + round (child->y * (allocation->height - child_requisition.height));
|
||||
child_allocation.width = child_requisition.width;
|
||||
child_allocation.height = child_requisition.height;
|
||||
|
||||
|
@@ -135,42 +135,55 @@ static void set_cursor_if_appropriate (GtkTextView *text_view,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
static void
|
||||
released_cb (GtkGestureMultiPress *gesture,
|
||||
guint n_press,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
GtkWidget *text_view)
|
||||
/* Links can also be activated by clicking or tapping.
|
||||
*/
|
||||
static gboolean
|
||||
event_cb (GtkWidget *text_view,
|
||||
GdkEvent *ev)
|
||||
{
|
||||
GtkTextIter start, end, iter;
|
||||
GtkTextBuffer *buffer;
|
||||
int tx, ty;
|
||||
gdouble ex, ey;
|
||||
int x, y;
|
||||
GdkEventType type;
|
||||
|
||||
if (gtk_gesture_single_get_button (GTK_GESTURE_SINGLE (gesture)) > 1)
|
||||
return;
|
||||
type = gdk_event_get_event_type (ev);
|
||||
|
||||
gdk_event_get_coords (ev, &ex, &ey);
|
||||
gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
|
||||
GTK_TEXT_WINDOW_WIDGET,
|
||||
x, y, &tx, &ty);
|
||||
ex, ey, &x, &y);
|
||||
|
||||
if (type == GDK_BUTTON_RELEASE)
|
||||
{
|
||||
guint button;
|
||||
|
||||
gdk_event_get_button (ev, &button);
|
||||
if (button != GDK_BUTTON_PRIMARY)
|
||||
return FALSE;
|
||||
}
|
||||
else if (type == GDK_MOTION_NOTIFY)
|
||||
{
|
||||
set_cursor_if_appropriate (GTK_TEXT_VIEW (text_view), x, y);
|
||||
return FALSE;
|
||||
}
|
||||
else if (type == GDK_TOUCH_END)
|
||||
{
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
|
||||
|
||||
/* we shouldn't follow a link if the user has selected something */
|
||||
gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
|
||||
if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
|
||||
return;
|
||||
return FALSE;
|
||||
|
||||
if (gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y))
|
||||
follow_if_link (text_view, &iter);
|
||||
}
|
||||
|
||||
static void
|
||||
motion_cb (GtkEventControllerMotion *controller,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
GtkTextView *text_view)
|
||||
{
|
||||
set_cursor_if_appropriate (text_view, x, y);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean hovering_over_link = FALSE;
|
||||
@@ -246,16 +259,8 @@ do_hypertext (GtkWidget *do_widget)
|
||||
controller = gtk_event_controller_key_new ();
|
||||
g_signal_connect (controller, "key-pressed", G_CALLBACK (key_pressed), view);
|
||||
gtk_widget_add_controller (view, controller);
|
||||
|
||||
controller = GTK_EVENT_CONTROLLER (gtk_gesture_multi_press_new ());
|
||||
g_signal_connect (controller, "released",
|
||||
G_CALLBACK (released_cb), view);
|
||||
gtk_widget_add_controller (view, controller);
|
||||
|
||||
controller = gtk_event_controller_motion_new ();
|
||||
g_signal_connect (controller, "motion",
|
||||
G_CALLBACK (motion_cb), view);
|
||||
gtk_widget_add_controller (view, controller);
|
||||
g_signal_connect (view, "event",
|
||||
G_CALLBACK (event_cb), NULL);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
|
@@ -1,15 +1,15 @@
|
||||
/* Images
|
||||
*
|
||||
* GtkImage and GtkPicture are used to display an image; the image can be
|
||||
* in a number of formats.
|
||||
*
|
||||
* GtkImage is the widget used to display icons or images that should be
|
||||
* sized and styled like an icon, while GtkPicture is used for images
|
||||
* that should be displayed as-is.
|
||||
* GtkImage is used to display an image; the image can be in a number of formats.
|
||||
* Typically, you load an image into a GdkPixbuf, then display the pixbuf.
|
||||
*
|
||||
* This demo code shows some of the more obscure cases, in the simple
|
||||
* case a call to gtk_picture_new_for_file() or
|
||||
* gtk_image_new_from_icon_name() is all you need.
|
||||
* case a call to gtk_image_new_from_file() is all you need.
|
||||
*
|
||||
* If you want to put image data in your program as a C variable,
|
||||
* use the make-inline-pixbuf program that comes with GTK+.
|
||||
* This way you won't need to depend on loading external files, your
|
||||
* application binary can be self-contained.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
@@ -27,9 +27,9 @@ progressive_prepared_callback (GdkPixbufLoader *loader,
|
||||
gpointer data)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GtkWidget *picture;
|
||||
GtkWidget *image;
|
||||
|
||||
picture = GTK_WIDGET (data);
|
||||
image = GTK_WIDGET (data);
|
||||
|
||||
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
|
||||
|
||||
@@ -38,7 +38,7 @@ progressive_prepared_callback (GdkPixbufLoader *loader,
|
||||
*/
|
||||
gdk_pixbuf_fill (pixbuf, 0xaaaaaaff);
|
||||
|
||||
gtk_picture_set_pixbuf (GTK_PICTURE (picture), pixbuf);
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -49,21 +49,21 @@ progressive_updated_callback (GdkPixbufLoader *loader,
|
||||
gint height,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *picture;
|
||||
GtkWidget *image;
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
picture = GTK_WIDGET (data);
|
||||
image = GTK_WIDGET (data);
|
||||
|
||||
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
|
||||
gtk_picture_set_pixbuf (GTK_PICTURE (picture), pixbuf);
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
|
||||
}
|
||||
|
||||
static gint
|
||||
progressive_timeout (gpointer data)
|
||||
{
|
||||
GtkWidget *picture;
|
||||
GtkWidget *image;
|
||||
|
||||
picture = GTK_WIDGET (data);
|
||||
image = GTK_WIDGET (data);
|
||||
|
||||
/* This shows off fully-paranoid error handling, so looks scary.
|
||||
* You could factor out the error handling code into a nice separate
|
||||
@@ -241,10 +241,10 @@ progressive_timeout (gpointer data)
|
||||
pixbuf_loader = gdk_pixbuf_loader_new ();
|
||||
|
||||
g_signal_connect (pixbuf_loader, "area-prepared",
|
||||
G_CALLBACK (progressive_prepared_callback), picture);
|
||||
G_CALLBACK (progressive_prepared_callback), image);
|
||||
|
||||
g_signal_connect (pixbuf_loader, "area-updated",
|
||||
G_CALLBACK (progressive_updated_callback), picture);
|
||||
G_CALLBACK (progressive_updated_callback), image);
|
||||
}
|
||||
|
||||
/* leave timeout installed */
|
||||
@@ -252,7 +252,7 @@ progressive_timeout (gpointer data)
|
||||
}
|
||||
|
||||
static void
|
||||
start_progressive_loading (GtkWidget *picture)
|
||||
start_progressive_loading (GtkWidget *image)
|
||||
{
|
||||
/* This is obviously totally contrived (we slow down loading
|
||||
* on purpose to show how incremental loading works).
|
||||
@@ -261,7 +261,7 @@ start_progressive_loading (GtkWidget *picture)
|
||||
* The timeout simply simulates a slow data source by inserting
|
||||
* pauses in the reading process.
|
||||
*/
|
||||
load_timeout = g_timeout_add (150, progressive_timeout, picture);
|
||||
load_timeout = g_timeout_add (150, progressive_timeout, image);
|
||||
g_source_set_name_by_id (load_timeout, "[gtk+] progressive_timeout");
|
||||
}
|
||||
|
||||
@@ -323,7 +323,6 @@ do_images (GtkWidget *do_widget)
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *base_vbox;
|
||||
GtkWidget *image;
|
||||
GtkWidget *picture;
|
||||
GtkWidget *label;
|
||||
GtkWidget *button;
|
||||
GdkPaintable *paintable;
|
||||
@@ -381,9 +380,9 @@ do_images (GtkWidget *do_widget)
|
||||
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame);
|
||||
|
||||
picture = gtk_picture_new_for_resource ("/images/floppybuddy.gif");
|
||||
image = gtk_image_new_from_resource ("/images/floppybuddy.gif");
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame), picture);
|
||||
gtk_container_add (GTK_CONTAINER (frame), image);
|
||||
|
||||
/* Symbolic icon */
|
||||
|
||||
@@ -423,10 +422,10 @@ do_images (GtkWidget *do_widget)
|
||||
/* Create an empty image for now; the progressive loader
|
||||
* will create the pixbuf and fill it in.
|
||||
*/
|
||||
picture = gtk_picture_new ();
|
||||
gtk_container_add (GTK_CONTAINER (frame), picture);
|
||||
image = gtk_image_new_from_pixbuf (NULL);
|
||||
gtk_container_add (GTK_CONTAINER (frame), image);
|
||||
|
||||
start_progressive_loading (picture);
|
||||
start_progressive_loading (image);
|
||||
|
||||
/* Video */
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
@@ -457,10 +456,11 @@ do_images (GtkWidget *do_widget)
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label);
|
||||
|
||||
paintable = gtk_widget_paintable_new (do_widget);
|
||||
picture = gtk_picture_new_for_paintable (paintable);
|
||||
gtk_widget_set_size_request (picture, 100, 100);
|
||||
gtk_widget_set_valign (picture, GTK_ALIGN_START);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), picture);
|
||||
image = gtk_image_new_from_paintable (paintable);
|
||||
gtk_image_set_can_shrink (GTK_IMAGE (image), TRUE);
|
||||
gtk_widget_set_size_request (image, 100, 100);
|
||||
gtk_widget_set_valign (image, GTK_ALIGN_START);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), image);
|
||||
|
||||
/* Sensitivity control */
|
||||
button = gtk_toggle_button_new_with_mnemonic ("_Insensitive");
|
||||
|
@@ -9,11 +9,16 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "message.h"
|
||||
|
||||
static GdkPixbuf *avatar_pixbuf_other;
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
#define GTK_TYPE_MESSAGE (gtk_message_get_type ())
|
||||
#define GTK_MESSAGE(message) (G_TYPE_CHECK_INSTANCE_CAST ((message), GTK_TYPE_MESSAGE, GtkMessage))
|
||||
#define GTK_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MESSAGE, GtkMessageClass))
|
||||
#define GTK_IS_MESSAGE(message) (G_TYPE_CHECK_INSTANCE_TYPE ((message), GTK_TYPE_MESSAGE))
|
||||
#define GTK_IS_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MESSAGE))
|
||||
#define GTK_MESSAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MESSAGE, GtkMessageClass))
|
||||
|
||||
#define GTK_TYPE_MESSAGE_ROW (gtk_message_row_get_type ())
|
||||
#define GTK_MESSAGE_ROW(message_row) (G_TYPE_CHECK_INSTANCE_CAST ((message_row), GTK_TYPE_MESSAGE_ROW, GtkMessageRow))
|
||||
#define GTK_MESSAGE_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MESSAGE_ROW, GtkMessageRowClass))
|
||||
@@ -21,10 +26,33 @@ static GtkWidget *window = NULL;
|
||||
#define GTK_IS_MESSAGE_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MESSAGE_ROW))
|
||||
#define GTK_MESSAGE_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MESSAGE_ROW, GtkMessageRowClass))
|
||||
|
||||
typedef struct _GtkMessage GtkMessage;
|
||||
typedef struct _GtkMessageClass GtkMessageClass;
|
||||
typedef struct _GtkMessageRow GtkMessageRow;
|
||||
typedef struct _GtkMessageRowClass GtkMessageRowClass;
|
||||
typedef struct _GtkMessageRowPrivate GtkMessageRowPrivate;
|
||||
|
||||
|
||||
struct _GtkMessage
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
guint id;
|
||||
char *sender_name;
|
||||
char *sender_nick;
|
||||
char *message;
|
||||
gint64 time;
|
||||
guint reply_to;
|
||||
char *resent_by;
|
||||
int n_favorites;
|
||||
int n_reshares;
|
||||
};
|
||||
|
||||
struct _GtkMessageClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
struct _GtkMessageRow
|
||||
{
|
||||
GtkListBoxRow parent;
|
||||
@@ -55,10 +83,84 @@ struct _GtkMessageRowPrivate
|
||||
GtkButton *expand_button;
|
||||
};
|
||||
|
||||
GType gtk_message_get_type (void) G_GNUC_CONST;
|
||||
GType gtk_message_row_get_type (void) G_GNUC_CONST;
|
||||
|
||||
G_DEFINE_TYPE (GtkMessage, gtk_message, G_TYPE_OBJECT);
|
||||
|
||||
static void
|
||||
gtk_message_finalize (GObject *obj)
|
||||
{
|
||||
GtkMessage *msg = GTK_MESSAGE (obj);
|
||||
|
||||
g_free (msg->sender_name);
|
||||
g_free (msg->sender_nick);
|
||||
g_free (msg->message);
|
||||
g_free (msg->resent_by);
|
||||
|
||||
G_OBJECT_CLASS (gtk_message_parent_class)->finalize (obj);
|
||||
}
|
||||
static void
|
||||
gtk_message_class_init (GtkMessageClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
object_class->finalize = gtk_message_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_message_init (GtkMessage *msg)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_message_parse (GtkMessage *msg, const char *str)
|
||||
{
|
||||
char **strv;
|
||||
int i;
|
||||
|
||||
strv = g_strsplit (str, "|", 0);
|
||||
|
||||
i = 0;
|
||||
msg->id = strtol (strv[i++], NULL, 10);
|
||||
msg->sender_name = g_strdup (strv[i++]);
|
||||
msg->sender_nick = g_strdup (strv[i++]);
|
||||
msg->message = g_strdup (strv[i++]);
|
||||
msg->time = strtol (strv[i++], NULL, 10);
|
||||
if (strv[i])
|
||||
{
|
||||
msg->reply_to = strtol (strv[i++], NULL, 10);
|
||||
if (strv[i])
|
||||
{
|
||||
if (*strv[i])
|
||||
msg->resent_by = g_strdup (strv[i]);
|
||||
i++;
|
||||
if (strv[i])
|
||||
{
|
||||
msg->n_favorites = strtol (strv[i++], NULL, 10);
|
||||
if (strv[i])
|
||||
{
|
||||
msg->n_reshares = strtol (strv[i++], NULL, 10);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_strfreev (strv);
|
||||
}
|
||||
|
||||
static GtkMessage *
|
||||
gtk_message_new (const char *str)
|
||||
{
|
||||
GtkMessage *msg;
|
||||
msg = g_object_new (gtk_message_get_type (), NULL);
|
||||
gtk_message_parse (msg, str);
|
||||
return msg;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkMessageRow, gtk_message_row, GTK_TYPE_LIST_BOX_ROW);
|
||||
|
||||
|
||||
static void
|
||||
gtk_message_row_update (GtkMessageRow *row)
|
||||
{
|
||||
@@ -231,48 +333,15 @@ row_activated (GtkListBox *listbox, GtkListBoxRow *row)
|
||||
gtk_message_row_expand (GTK_MESSAGE_ROW (row));
|
||||
}
|
||||
|
||||
static void
|
||||
update_count (GtkListBox *listbox, GtkLabel *label)
|
||||
{
|
||||
GList *children = gtk_container_get_children (GTK_CONTAINER (listbox));
|
||||
guint n_items = g_list_length (children);
|
||||
g_list_free (children);
|
||||
|
||||
char *text = g_strdup_printf ("%u rows", n_items);
|
||||
gtk_label_set_label (label, text);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
static GtkWidget *header_label;
|
||||
|
||||
static void
|
||||
add_more (GtkListBox *listbox)
|
||||
{
|
||||
GBytes *data;
|
||||
char **lines;
|
||||
int i;
|
||||
|
||||
data = g_resources_lookup_data ("/listbox/messages.txt", 0, NULL);
|
||||
lines = g_strsplit (g_bytes_get_data (data, NULL), "\n", 0);
|
||||
|
||||
for (i = 0; lines[i] != NULL && *lines[i]; i++)
|
||||
{
|
||||
GtkMessage *message = gtk_message_new (lines[i]);
|
||||
GtkMessageRow *row = gtk_message_row_new (message);
|
||||
gtk_container_add (GTK_CONTAINER (listbox), GTK_WIDGET (row));
|
||||
}
|
||||
|
||||
g_strfreev (lines);
|
||||
g_bytes_unref (data);
|
||||
|
||||
update_count (listbox, GTK_LABEL (header_label));
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_listbox (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *scrolled, *listbox, *vbox, *label;
|
||||
GtkWidget *header, *more;
|
||||
GtkMessage *message;
|
||||
GtkMessageRow *row;
|
||||
GBytes *data;
|
||||
char **lines;
|
||||
int i;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
@@ -281,27 +350,15 @@ do_listbox (GtkWidget *do_widget)
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "List Box");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window),
|
||||
400, 600);
|
||||
|
||||
/* NULL window variable when window is closed */
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed),
|
||||
&window);
|
||||
|
||||
listbox = gtk_list_box_new ();
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
|
||||
gtk_header_bar_set_title (GTK_HEADER_BAR (header), "List View");
|
||||
header_label = gtk_label_new ("");
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), header_label);
|
||||
more = gtk_button_new_from_icon_name ("list-add");
|
||||
|
||||
g_signal_connect_swapped (more, "clicked", G_CALLBACK (add_more), listbox);
|
||||
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), more);
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
label = gtk_label_new ("Messages from Gtk+ and friends");
|
||||
@@ -310,14 +367,26 @@ do_listbox (GtkWidget *do_widget)
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scrolled);
|
||||
listbox = gtk_list_box_new ();
|
||||
gtk_container_add (GTK_CONTAINER (scrolled), listbox);
|
||||
|
||||
gtk_list_box_set_sort_func (GTK_LIST_BOX (listbox), (GtkListBoxSortFunc)gtk_message_row_sort, listbox, NULL);
|
||||
gtk_list_box_set_activate_on_single_click (GTK_LIST_BOX (listbox), FALSE);
|
||||
g_signal_connect (listbox, "row-activated", G_CALLBACK (row_activated), NULL);
|
||||
|
||||
add_more (listbox);
|
||||
update_count (listbox, header_label);
|
||||
data = g_resources_lookup_data ("/listbox/messages.txt", 0, NULL);
|
||||
lines = g_strsplit (g_bytes_get_data (data, NULL), "\n", 0);
|
||||
|
||||
for (i = 0; lines[i] != NULL && *lines[i]; i++)
|
||||
{
|
||||
message = gtk_message_new (lines[i]);
|
||||
row = gtk_message_row_new (message);
|
||||
gtk_widget_show (GTK_WIDGET (row));
|
||||
gtk_container_add (GTK_CONTAINER (listbox), GTK_WIDGET (row));
|
||||
}
|
||||
|
||||
g_strfreev (lines);
|
||||
g_bytes_unref (data);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
@@ -154,7 +154,6 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="extra_buttons_box">
|
||||
<property name="visible">0</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="reply-button">
|
||||
|
@@ -1,323 +0,0 @@
|
||||
/* List View
|
||||
*
|
||||
* GtkListView allows lists with complicated layouts, using
|
||||
* models to hold the data, and creating rows on demand.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "message.h"
|
||||
|
||||
static GdkPixbuf *avatar_pixbuf_other;
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
#define GTK_TYPE_MSG_ROW (gtk_msg_row_get_type ())
|
||||
#define GTK_MSG_ROW(msg_row) (G_TYPE_CHECK_INSTANCE_CAST ((msg_row), GTK_TYPE_MSG_ROW, GtkMsgRow))
|
||||
#define GTK_MSG_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MSG_ROW, GtkMsgRowClass))
|
||||
#define GTK_IS_MSG_ROW(msg_row) (G_TYPE_CHECK_INSTANCE_TYPE ((msg_row), GTK_TYPE_MSG_ROW))
|
||||
#define GTK_IS_MSG_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MSG_ROW))
|
||||
#define GTK_MSG_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MSG_ROW, GtkMsgRowClass))
|
||||
|
||||
typedef struct _GtkMsgRow GtkMsgRow;
|
||||
typedef struct _GtkMsgRowClass GtkMsgRowClass;
|
||||
|
||||
struct _GtkMsgRow
|
||||
{
|
||||
GtkBin parent;
|
||||
|
||||
GtkMessage *message;
|
||||
GtkRevealer *details_revealer;
|
||||
GtkImage *avatar_image;
|
||||
GtkWidget *extra_buttons_box;
|
||||
GtkLabel *content_label;
|
||||
GtkLabel *source_name;
|
||||
GtkLabel *source_nick;
|
||||
GtkLabel *short_time_label;
|
||||
GtkLabel *detailed_time_label;
|
||||
GtkBox *resent_box;
|
||||
GtkLinkButton *resent_by_button;
|
||||
GtkLabel *n_favorites_label;
|
||||
GtkLabel *n_reshares_label;
|
||||
GtkButton *expand_button;
|
||||
};
|
||||
|
||||
struct _GtkMsgRowClass
|
||||
{
|
||||
GtkBinClass parent_class;
|
||||
};
|
||||
|
||||
static GType gtk_msg_row_get_type (void) G_GNUC_CONST;
|
||||
|
||||
G_DEFINE_TYPE (GtkMsgRow, gtk_msg_row, GTK_TYPE_BIN);
|
||||
|
||||
static void
|
||||
gtk_msg_row_update (GtkMsgRow *row)
|
||||
{
|
||||
GDateTime *t;
|
||||
char *s;
|
||||
|
||||
gtk_label_set_text (row->source_name, row->message->sender_name);
|
||||
gtk_label_set_text (row->source_nick, row->message->sender_nick);
|
||||
gtk_label_set_text (row->content_label, row->message->message);
|
||||
t = g_date_time_new_from_unix_utc (row->message->time);
|
||||
s = g_date_time_format (t, "%e %b %y");
|
||||
gtk_label_set_text (row->short_time_label, s);
|
||||
g_free (s);
|
||||
s = g_date_time_format (t, "%X - %e %b %Y");
|
||||
gtk_label_set_text (row->detailed_time_label, s);
|
||||
g_free (s);
|
||||
g_date_time_unref (t);
|
||||
|
||||
gtk_widget_set_visible (GTK_WIDGET(row->n_favorites_label),
|
||||
row->message->n_favorites != 0);
|
||||
s = g_strdup_printf ("<b>%d</b>\nFavorites", row->message->n_favorites);
|
||||
gtk_label_set_markup (row->n_favorites_label, s);
|
||||
g_free (s);
|
||||
|
||||
gtk_widget_set_visible (GTK_WIDGET(row->n_reshares_label),
|
||||
row->message->n_reshares != 0);
|
||||
s = g_strdup_printf ("<b>%d</b>\nReshares", row->message->n_reshares);
|
||||
gtk_label_set_markup (row->n_reshares_label, s);
|
||||
g_free (s);
|
||||
|
||||
gtk_widget_set_visible (GTK_WIDGET (row->resent_box), row->message->resent_by != NULL);
|
||||
if (row->message->resent_by)
|
||||
gtk_button_set_label (GTK_BUTTON (row->resent_by_button), row->message->resent_by);
|
||||
|
||||
if (strcmp (row->message->sender_nick, "@GTKtoolkit") == 0)
|
||||
{
|
||||
gtk_image_set_from_icon_name (row->avatar_image, "gtk3-demo");
|
||||
gtk_image_set_icon_size (row->avatar_image, GTK_ICON_SIZE_LARGE);
|
||||
}
|
||||
else
|
||||
gtk_image_set_from_pixbuf (row->avatar_image, avatar_pixbuf_other);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_msg_row_expand (GtkMsgRow *row)
|
||||
{
|
||||
gboolean expand;
|
||||
|
||||
expand = !gtk_revealer_get_reveal_child (row->details_revealer);
|
||||
|
||||
gtk_revealer_set_reveal_child (row->details_revealer, expand);
|
||||
if (expand)
|
||||
gtk_button_set_label (row->expand_button, "Hide");
|
||||
else
|
||||
gtk_button_set_label (row->expand_button, "Expand");
|
||||
}
|
||||
|
||||
static void
|
||||
expand_clicked (GtkMsgRow *row,
|
||||
GtkButton *button)
|
||||
{
|
||||
gtk_msg_row_expand (row);
|
||||
}
|
||||
|
||||
static void
|
||||
reshare_clicked (GtkMsgRow *row,
|
||||
GtkButton *button)
|
||||
{
|
||||
row->message->n_reshares++;
|
||||
gtk_msg_row_update (row);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
favorite_clicked (GtkMsgRow *row,
|
||||
GtkButton *button)
|
||||
{
|
||||
row->message->n_favorites++;
|
||||
gtk_msg_row_update (row);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_msg_row_state_flags_changed (GtkWidget *widget,
|
||||
GtkStateFlags previous_state_flags)
|
||||
{
|
||||
GtkMsgRow *row = GTK_MSG_ROW (widget);
|
||||
GtkStateFlags flags;
|
||||
|
||||
flags = gtk_widget_get_state_flags (widget);
|
||||
|
||||
gtk_widget_set_visible (row->extra_buttons_box,
|
||||
flags & (GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_SELECTED));
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_msg_row_parent_class)->state_flags_changed (widget, previous_state_flags);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_msg_row_finalize (GObject *obj)
|
||||
{
|
||||
G_OBJECT_CLASS (gtk_msg_row_parent_class)->finalize(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_msg_row_class_init (GtkMsgRowClass *klass)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gtk_msg_row_finalize;
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/listview/listview.ui");
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkMsgRow, content_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkMsgRow, source_name);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkMsgRow, source_nick);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkMsgRow, short_time_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkMsgRow, detailed_time_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkMsgRow, extra_buttons_box);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkMsgRow, details_revealer);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkMsgRow, avatar_image);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkMsgRow, resent_box);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkMsgRow, resent_by_button);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkMsgRow, n_reshares_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkMsgRow, n_favorites_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkMsgRow, expand_button);
|
||||
gtk_widget_class_bind_template_callback (widget_class, expand_clicked);
|
||||
gtk_widget_class_bind_template_callback (widget_class, reshare_clicked);
|
||||
gtk_widget_class_bind_template_callback (widget_class, favorite_clicked);
|
||||
|
||||
widget_class->state_flags_changed = gtk_msg_row_state_flags_changed;
|
||||
}
|
||||
|
||||
static void
|
||||
row_activated (GtkGestureMultiPress *gesture,
|
||||
int n_press,
|
||||
double x,
|
||||
double y,
|
||||
GtkMsgRow *row)
|
||||
{
|
||||
if (n_press == 2)
|
||||
gtk_msg_row_expand (row);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_msg_row_init (GtkMsgRow *row)
|
||||
{
|
||||
GtkGesture *double_click;
|
||||
|
||||
gtk_widget_init_template (GTK_WIDGET (row));
|
||||
|
||||
double_click = gtk_gesture_multi_press_new ();
|
||||
g_signal_connect (double_click, "pressed", G_CALLBACK (row_activated), row);
|
||||
gtk_widget_add_controller (GTK_WIDGET (row), GTK_EVENT_CONTROLLER (double_click));
|
||||
}
|
||||
|
||||
static int
|
||||
gtk_message_sort (gconstpointer a, gconstpointer b, gpointer data)
|
||||
{
|
||||
return ((const GtkMessage *)b)->time - ((const GtkMessage *)a)->time;
|
||||
}
|
||||
|
||||
static void
|
||||
bind_msg_row (GObject *list_item, GParamSpec *pspec, gpointer data)
|
||||
{
|
||||
GtkMessage *message = (GtkMessage *)gtk_list_item_get_item (GTK_LIST_ITEM (list_item));
|
||||
GtkMsgRow *row = (GtkMsgRow *) gtk_bin_get_child (GTK_BIN (list_item));
|
||||
|
||||
row->message = message;
|
||||
if (message)
|
||||
gtk_msg_row_update (row);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_row (GtkListItem *item,
|
||||
gpointer data)
|
||||
{
|
||||
g_signal_connect (item, "notify::item", G_CALLBACK (bind_msg_row), data);
|
||||
gtk_container_add (GTK_CONTAINER (item), g_object_new (gtk_msg_row_get_type (), NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
update_count (GListModel *model, guint position, guint removed, guint added, GtkLabel *label)
|
||||
{
|
||||
guint n_items = g_list_model_get_n_items (model);
|
||||
char *text = g_strdup_printf ("%u rows", n_items);
|
||||
gtk_label_set_label (label, text);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
static void
|
||||
add_more (GListModel *model)
|
||||
{
|
||||
GBytes *data;
|
||||
char **lines;
|
||||
int i;
|
||||
|
||||
data = g_resources_lookup_data ("/listview/messages.txt", 0, NULL);
|
||||
lines = g_strsplit (g_bytes_get_data (data, NULL), "\n", 0);
|
||||
|
||||
for (i = 0; lines[i] != NULL && *lines[i]; i++)
|
||||
{
|
||||
GtkMessage *message = gtk_message_new (lines[i]);
|
||||
g_list_store_append (G_LIST_STORE (model), message);
|
||||
}
|
||||
|
||||
g_strfreev (lines);
|
||||
g_bytes_unref (data);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_listview (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *scrolled, *listview, *vbox, *label;
|
||||
GtkWidget *header, *header_label, *more;
|
||||
GListModel *model;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
avatar_pixbuf_other = gdk_pixbuf_new_from_resource_at_scale ("/listbox/apple-red.png", 32, 32, FALSE, NULL);
|
||||
|
||||
model = G_LIST_MODEL (g_list_store_new (gtk_message_get_type ()));
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
|
||||
|
||||
/* NULL window variable when window is closed */
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed),
|
||||
&window);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
|
||||
gtk_header_bar_set_title (GTK_HEADER_BAR (header), "List View");
|
||||
header_label = gtk_label_new ("");
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), header_label);
|
||||
more = gtk_button_new_from_icon_name ("list-add");
|
||||
|
||||
g_signal_connect_swapped (more, "clicked", G_CALLBACK (add_more), model);
|
||||
g_signal_connect (model, "items-changed", G_CALLBACK (update_count), header_label);
|
||||
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), more);
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
label = gtk_label_new ("Messages from Gtk+ and friends");
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label);
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scrolled);
|
||||
listview = gtk_list_view_new ();
|
||||
gtk_container_add (GTK_CONTAINER (scrolled), listview);
|
||||
|
||||
gtk_list_view_set_functions (GTK_LIST_VIEW (listview), setup_row, NULL, NULL, NULL);
|
||||
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (gtk_sort_list_model_new (model, gtk_message_sort, NULL, NULL)));
|
||||
|
||||
add_more (model);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
|
||||
return window;
|
||||
}
|
@@ -1,302 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface domain="gtk40">
|
||||
<!-- interface-requires gtk+ 3.10 -->
|
||||
<!-- interface-requires gtkdemo 3.10 -->
|
||||
<object class="GtkMenu" id="menu1">
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="menuitem1">
|
||||
<property name="label" translatable="yes">Email message</property>
|
||||
<property name="use-underline">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="menuitem2">
|
||||
<property name="label" translatable="yes">Embed message</property>
|
||||
<property name="use-underline">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<template class="GtkMsgRow" parent="GtkBin">
|
||||
<child>
|
||||
<object class="GtkGrid" id="grid1">
|
||||
<property name="hexpand">1</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="avatar_image">
|
||||
<property name="width-request">32</property>
|
||||
<property name="height-request">32</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="margin-top">8</property>
|
||||
<property name="margin-bottom">8</property>
|
||||
<property name="margin-start">8</property>
|
||||
<property name="margin-end">8</property>
|
||||
<property name="icon-name">image-missing</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">0</property>
|
||||
<property name="height">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box1">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="baseline-position">top</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="button2">
|
||||
<property name="can-focus">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="relief">none</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="source_name">
|
||||
<property name="valign">baseline</property>
|
||||
<property name="label" translatable="0">Username</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
</attributes>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="source_nick">
|
||||
<property name="valign">baseline</property>
|
||||
<property name="label" translatable="0">@nick</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="short_time_label">
|
||||
<property name="valign">baseline</property>
|
||||
<property name="label" translatable="yes">38m</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="content_label">
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0</property>
|
||||
<property name="label" translatable="0">Message</property>
|
||||
<property name="wrap">1</property>
|
||||
<accessibility>
|
||||
<role type="static"/>
|
||||
</accessibility>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="resent_box">
|
||||
<child>
|
||||
<object class="GtkImage" id="image2">
|
||||
<property name="icon-name">media-playlist-repeat</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label4">
|
||||
<property name="label" translatable="yes">Resent by</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLinkButton" id="resent_by_button">
|
||||
<property name="label" translatable="0">reshareer</property>
|
||||
<property name="can-focus">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="relief">none</property>
|
||||
<property name="uri">http://www.gtk.org</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box3">
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="expand_button">
|
||||
<property name="label" translatable="yes">Expand</property>
|
||||
<property name="can-focus">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="relief">none</property>
|
||||
<signal name="clicked" handler="expand_clicked" swapped="yes"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="extra_buttons_box">
|
||||
<property name="visible">0</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="reply-button">
|
||||
<property name="label" translatable="yes">Reply</property>
|
||||
<property name="can-focus">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="relief">none</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="reshare-button">
|
||||
<property name="label" translatable="yes">Reshare</property>
|
||||
<property name="can-focus">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="relief">none</property>
|
||||
<signal name="clicked" handler="reshare_clicked" swapped="yes"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="favorite-buttton">
|
||||
<property name="label" translatable="yes">Favorite</property>
|
||||
<property name="can-focus">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="relief">none</property>
|
||||
<signal name="clicked" handler="favorite_clicked" swapped="yes"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuButton" id="more-button">
|
||||
<property name="can-focus">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="relief">none</property>
|
||||
<property name="popup">menu1</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label7">
|
||||
<property name="label" translatable="yes">More...</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRevealer" id="details_revealer">
|
||||
<child>
|
||||
<object class="GtkBox" id="box5">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box7">
|
||||
<property name="margin-top">2</property>
|
||||
<property name="margin-bottom">2</property>
|
||||
<property name="spacing">8</property>
|
||||
<child>
|
||||
<object class="GtkFrame" id="frame1">
|
||||
<property name="shadow-type">none</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="n_reshares_label">
|
||||
<property name="label" translatable="0"><b>2</b>
|
||||
Reshares</property>
|
||||
<property name="use-markup">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label_item"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame" id="frame2">
|
||||
<property name="shadow-type">none</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="n_favorites_label">
|
||||
<property name="label" translatable="0"><b>2</b>
|
||||
FAVORITES</property>
|
||||
<property name="use-markup">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label_item"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box6">
|
||||
<child>
|
||||
<object class="GtkLabel" id="detailed_time_label">
|
||||
<property name="label" translatable="0">4:25 AM - 14 Jun 13 </property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button5">
|
||||
<property name="label" translatable="yes">Details</property>
|
||||
<property name="can-focus">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="relief">none</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
@@ -831,14 +831,15 @@ load_file (const gchar *demoname,
|
||||
/* Skipping blank lines */
|
||||
while (g_ascii_isspace (*p))
|
||||
p++;
|
||||
|
||||
if (!*p)
|
||||
if (*p)
|
||||
{
|
||||
p = lines[i];
|
||||
state++;
|
||||
/* Fall through */
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
p = lines[i];
|
||||
state++;
|
||||
/* Fall through */
|
||||
|
||||
case 3:
|
||||
/* Reading program body */
|
||||
gtk_text_buffer_insert (source_buffer, &start, p, -1);
|
||||
@@ -996,6 +997,41 @@ scrollbar_popup (GtkWidget *scrollbar, GtkWidget *menu)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
settings__notify_gtk_theme_name (GObject *gobject,
|
||||
GParamSpec *pspec,
|
||||
gpointer data)
|
||||
{
|
||||
static GtkCssProvider *css_provider;
|
||||
|
||||
GtkWidget *window = data;
|
||||
char *theme_name;
|
||||
|
||||
g_object_get (gobject, "gtk-theme-name", &theme_name, NULL);
|
||||
if (g_strcmp0 (theme_name, "Adwaita") == 0)
|
||||
{
|
||||
if (css_provider == NULL)
|
||||
{
|
||||
css_provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_resource (css_provider, "/ui/theme.css");
|
||||
gtk_style_context_add_provider_for_display (gtk_widget_get_display (window),
|
||||
GTK_STYLE_PROVIDER (css_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (css_provider != NULL)
|
||||
{
|
||||
gtk_style_context_remove_provider_for_display (gtk_widget_get_display (window),
|
||||
GTK_STYLE_PROVIDER (css_provider));
|
||||
g_clear_object (&css_provider);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (theme_name);
|
||||
}
|
||||
|
||||
static void
|
||||
activate (GApplication *app)
|
||||
{
|
||||
@@ -1028,6 +1064,20 @@ activate (GApplication *app)
|
||||
win_entries, G_N_ELEMENTS (win_entries),
|
||||
window);
|
||||
|
||||
g_signal_connect (gtk_settings_get_default (), "notify::gtk-theme-name",
|
||||
G_CALLBACK (settings__notify_gtk_theme_name),
|
||||
window);
|
||||
|
||||
if (gtk_get_minor_version () % 2 != 0)
|
||||
{
|
||||
GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (window));
|
||||
gtk_style_context_add_class (context, "devel");
|
||||
}
|
||||
|
||||
settings__notify_gtk_theme_name (G_OBJECT (gtk_widget_get_settings (GTK_WIDGET (window))),
|
||||
NULL,
|
||||
window);
|
||||
|
||||
notebook = (GtkWidget *)gtk_builder_get_object (builder, "notebook");
|
||||
|
||||
info_view = (GtkWidget *)gtk_builder_get_object (builder, "info-textview");
|
||||
|
@@ -16,7 +16,6 @@
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkApplicationWindow" id="window">
|
||||
<style><class name="devel"/></style>
|
||||
<property name="default-width">800</property>
|
||||
<property name="default-height">600</property>
|
||||
<property name="title">GTK+ Demo</property>
|
||||
|
@@ -22,6 +22,7 @@ demos = files([
|
||||
'editable_cells.c',
|
||||
'entry_buffer.c',
|
||||
'entry_completion.c',
|
||||
'event_axes.c',
|
||||
'expander.c',
|
||||
'filtermodel.c',
|
||||
'fishbowl.c',
|
||||
@@ -36,7 +37,6 @@ demos = files([
|
||||
'infobar.c',
|
||||
'links.c',
|
||||
'listbox.c',
|
||||
'listview.c',
|
||||
'flowbox.c',
|
||||
'list_store.c',
|
||||
'markup.c',
|
||||
@@ -61,7 +61,6 @@ demos = files([
|
||||
'shortcuts.c',
|
||||
'sidebar.c',
|
||||
'sizegroup.c',
|
||||
'sliding_puzzle.c',
|
||||
'spinbutton.c',
|
||||
'spinner.c',
|
||||
'stack.c',
|
||||
@@ -77,7 +76,7 @@ demos = files([
|
||||
|
||||
gtkdemo_deps = [ libgtk_dep, ]
|
||||
|
||||
extra_demo_sources = files(['main.c', 'gtkfishbowl.c', 'fontplane.c', 'gtkgears.c', 'puzzlepiece.c', 'message.c'])
|
||||
extra_demo_sources = files(['main.c', 'gtkfishbowl.c', 'fontplane.c', 'gtkgears.c'])
|
||||
|
||||
if harfbuzz_dep.found() and pangoft_dep.found()
|
||||
demos += files('font_features.c')
|
||||
@@ -130,7 +129,7 @@ foreach icon_size: [ '16x16', '22x22', '24x24', '32x32', '48x48', '256x256', ]
|
||||
endforeach
|
||||
|
||||
# desktop file
|
||||
install_data('org.gtk.Demo.desktop', install_dir: gtk_applicationsdir)
|
||||
install_data('gtk4-demo.desktop', install_dir: gtk_applicationsdir)
|
||||
|
||||
# GSettings
|
||||
install_data('org.gtk.Demo.gschema.xml', install_dir: gtk_schemasdir)
|
||||
|
@@ -1,79 +0,0 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "message.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
G_DEFINE_TYPE (GtkMessage, gtk_message, G_TYPE_OBJECT);
|
||||
|
||||
static void
|
||||
gtk_message_finalize (GObject *obj)
|
||||
{
|
||||
GtkMessage *msg = GTK_MESSAGE (obj);
|
||||
|
||||
g_free (msg->sender_name);
|
||||
g_free (msg->sender_nick);
|
||||
g_free (msg->message);
|
||||
g_free (msg->resent_by);
|
||||
|
||||
G_OBJECT_CLASS (gtk_message_parent_class)->finalize (obj);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_message_class_init (GtkMessageClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
object_class->finalize = gtk_message_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_message_init (GtkMessage *msg)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_message_parse (GtkMessage *msg, const char *str)
|
||||
{
|
||||
char **strv;
|
||||
int i;
|
||||
|
||||
strv = g_strsplit (str, "|", 0);
|
||||
|
||||
i = 0;
|
||||
msg->id = strtol (strv[i++], NULL, 10);
|
||||
msg->sender_name = g_strdup (strv[i++]);
|
||||
msg->sender_nick = g_strdup (strv[i++]);
|
||||
msg->message = g_strdup (strv[i++]);
|
||||
msg->time = strtol (strv[i++], NULL, 10);
|
||||
if (strv[i])
|
||||
{
|
||||
msg->reply_to = strtol (strv[i++], NULL, 10);
|
||||
if (strv[i])
|
||||
{
|
||||
if (*strv[i])
|
||||
msg->resent_by = g_strdup (strv[i]);
|
||||
i++;
|
||||
if (strv[i])
|
||||
{
|
||||
msg->n_favorites = strtol (strv[i++], NULL, 10);
|
||||
if (strv[i])
|
||||
{
|
||||
msg->n_reshares = strtol (strv[i++], NULL, 10);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_strfreev (strv);
|
||||
}
|
||||
|
||||
GtkMessage *
|
||||
gtk_message_new (const char *str)
|
||||
{
|
||||
GtkMessage *msg;
|
||||
msg = g_object_new (gtk_message_get_type (), NULL);
|
||||
gtk_message_parse (msg, str);
|
||||
return msg;
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#define GTK_TYPE_MESSAGE (gtk_message_get_type ())
|
||||
#define GTK_MESSAGE(message) (G_TYPE_CHECK_INSTANCE_CAST ((message), GTK_TYPE_MESSAGE, GtkMessage))
|
||||
#define GTK_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MESSAGE, GtkMessageClass))
|
||||
#define GTK_IS_MESSAGE(message) (G_TYPE_CHECK_INSTANCE_TYPE ((message), GTK_TYPE_MESSAGE))
|
||||
#define GTK_IS_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MESSAGE))
|
||||
#define GTK_MESSAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MESSAGE, GtkMessageClass))
|
||||
|
||||
typedef struct _GtkMessage GtkMessage;
|
||||
typedef struct _GtkMessageClass GtkMessageClass;
|
||||
|
||||
struct _GtkMessage
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
guint id;
|
||||
char *sender_name;
|
||||
char *sender_nick;
|
||||
char *message;
|
||||
gint64 time;
|
||||
guint reply_to;
|
||||
char *resent_by;
|
||||
int n_favorites;
|
||||
int n_reshares;
|
||||
};
|
||||
|
||||
struct _GtkMessageClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
GType gtk_message_get_type (void) G_GNUC_CONST;
|
||||
GtkMessage * gtk_message_new (const char *str);
|
@@ -3,24 +3,14 @@
|
||||
* Demonstrates practical handling of drawing tablets in a real world
|
||||
* usecase.
|
||||
*/
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
enum {
|
||||
COLOR_SET,
|
||||
N_SIGNALS
|
||||
};
|
||||
|
||||
static guint area_signals[N_SIGNALS] = { 0, };
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
GdkRGBA draw_color;
|
||||
GtkPadController *pad_controller;
|
||||
gdouble brush_size;
|
||||
} DrawingArea;
|
||||
|
||||
typedef struct
|
||||
@@ -28,30 +18,8 @@ typedef struct
|
||||
GtkWidgetClass parent_class;
|
||||
} DrawingAreaClass;
|
||||
|
||||
static GtkPadActionEntry pad_actions[] = {
|
||||
{ GTK_PAD_ACTION_BUTTON, 1, -1, N_("Black"), "pad.black" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 2, -1, N_("Pink"), "pad.pink" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 3, -1, N_("Green"), "pad.green" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 4, -1, N_("Red"), "pad.red" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 5, -1, N_("Purple"), "pad.purple" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 6, -1, N_("Orange"), "pad.orange" },
|
||||
{ GTK_PAD_ACTION_STRIP, -1, -1, N_("Brush size"), "pad.brush_size" },
|
||||
};
|
||||
|
||||
static const gchar *pad_colors[] = {
|
||||
"black",
|
||||
"pink",
|
||||
"green",
|
||||
"red",
|
||||
"purple",
|
||||
"orange"
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (DrawingArea, drawing_area, GTK_TYPE_WIDGET)
|
||||
|
||||
static void drawing_area_set_color (DrawingArea *area,
|
||||
GdkRGBA *color);
|
||||
|
||||
static void
|
||||
drawing_area_ensure_surface (DrawingArea *area,
|
||||
gint width,
|
||||
@@ -84,16 +52,15 @@ drawing_area_ensure_surface (DrawingArea *area,
|
||||
}
|
||||
|
||||
static void
|
||||
drawing_area_size_allocate (GtkWidget *widget,
|
||||
int width,
|
||||
int height,
|
||||
int baseline)
|
||||
drawing_area_size_allocate (GtkWidget *widget,
|
||||
const GtkAllocation *allocation,
|
||||
int baseline)
|
||||
{
|
||||
DrawingArea *area = (DrawingArea *) widget;
|
||||
|
||||
drawing_area_ensure_surface (area, width, height);
|
||||
drawing_area_ensure_surface (area, allocation->width, allocation->height);
|
||||
|
||||
GTK_WIDGET_CLASS (drawing_area_parent_class)->size_allocate (widget, width, height, baseline);
|
||||
GTK_WIDGET_CLASS (drawing_area_parent_class)->size_allocate (widget, allocation, baseline);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -148,82 +115,6 @@ drawing_area_snapshot (GtkWidget *widget,
|
||||
cairo_destroy (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
on_pad_button_activate (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
DrawingArea *area)
|
||||
{
|
||||
const gchar *color = g_object_get_data (G_OBJECT (action), "color");
|
||||
GdkRGBA rgba;
|
||||
|
||||
gdk_rgba_parse (&rgba, color);
|
||||
drawing_area_set_color (area, &rgba);
|
||||
}
|
||||
|
||||
static void
|
||||
on_pad_knob_change (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
DrawingArea *area)
|
||||
{
|
||||
gdouble value = g_variant_get_double (parameter);
|
||||
|
||||
area->brush_size = value;
|
||||
}
|
||||
|
||||
static void
|
||||
drawing_area_hierarchy_changed (GtkWidget *widget,
|
||||
GtkWidget *previous_toplevel)
|
||||
{
|
||||
DrawingArea *area = (DrawingArea *) widget;
|
||||
GSimpleActionGroup *action_group;
|
||||
GSimpleAction *action;
|
||||
GtkWidget *toplevel;
|
||||
gint i;
|
||||
|
||||
if (previous_toplevel && area->pad_controller)
|
||||
{
|
||||
gtk_widget_remove_controller (previous_toplevel,
|
||||
GTK_EVENT_CONTROLLER (area->pad_controller));
|
||||
area->pad_controller = NULL;
|
||||
}
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (area));
|
||||
if (!GTK_IS_WINDOW (toplevel))
|
||||
return;
|
||||
|
||||
action_group = g_simple_action_group_new ();
|
||||
area->pad_controller = gtk_pad_controller_new (G_ACTION_GROUP (action_group),
|
||||
NULL);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (pad_actions); i++)
|
||||
{
|
||||
if (pad_actions[i].type == GTK_PAD_ACTION_BUTTON)
|
||||
{
|
||||
action = g_simple_action_new (pad_actions[i].action_name, NULL);
|
||||
g_object_set_data (G_OBJECT (action), "color",
|
||||
(gpointer) pad_colors[i]);
|
||||
g_signal_connect (action, "activate",
|
||||
G_CALLBACK (on_pad_button_activate), area);
|
||||
}
|
||||
else
|
||||
{
|
||||
action = g_simple_action_new_stateful (pad_actions[i].action_name,
|
||||
G_VARIANT_TYPE_DOUBLE, NULL);
|
||||
g_signal_connect (action, "activate",
|
||||
G_CALLBACK (on_pad_knob_change), area);
|
||||
}
|
||||
|
||||
g_action_map_add_action (G_ACTION_MAP (action_group), G_ACTION (action));
|
||||
g_object_unref (action);
|
||||
}
|
||||
|
||||
gtk_pad_controller_set_action_entries (area->pad_controller, pad_actions,
|
||||
G_N_ELEMENTS (pad_actions));
|
||||
|
||||
gtk_widget_add_controller (toplevel,
|
||||
GTK_EVENT_CONTROLLER (area->pad_controller));
|
||||
}
|
||||
|
||||
static void
|
||||
drawing_area_class_init (DrawingAreaClass *klass)
|
||||
{
|
||||
@@ -233,14 +124,6 @@ drawing_area_class_init (DrawingAreaClass *klass)
|
||||
widget_class->snapshot = drawing_area_snapshot;
|
||||
widget_class->map = drawing_area_map;
|
||||
widget_class->unmap = drawing_area_unmap;
|
||||
widget_class->hierarchy_changed = drawing_area_hierarchy_changed;
|
||||
|
||||
area_signals[COLOR_SET] =
|
||||
g_signal_new ("color-set",
|
||||
G_TYPE_FROM_CLASS (widget_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
0, NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1, GDK_TYPE_RGBA);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -252,12 +135,12 @@ drawing_area_apply_stroke (DrawingArea *area,
|
||||
{
|
||||
if (gdk_device_tool_get_tool_type (tool) == GDK_DEVICE_TOOL_TYPE_ERASER)
|
||||
{
|
||||
cairo_set_line_width (area->cr, 10 * pressure * area->brush_size);
|
||||
cairo_set_line_width (area->cr, 10 * pressure);
|
||||
cairo_set_operator (area->cr, CAIRO_OPERATOR_DEST_OUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
cairo_set_line_width (area->cr, 4 * pressure * area->brush_size);
|
||||
cairo_set_line_width (area->cr, 4 * pressure);
|
||||
cairo_set_operator (area->cr, CAIRO_OPERATOR_SATURATE);
|
||||
}
|
||||
|
||||
@@ -265,6 +148,8 @@ drawing_area_apply_stroke (DrawingArea *area,
|
||||
area->draw_color.green, area->draw_color.blue,
|
||||
area->draw_color.alpha * pressure);
|
||||
|
||||
//cairo_set_source_rgba (area->cr, 0, 0, 0, pressure);
|
||||
|
||||
cairo_line_to (area->cr, x, y);
|
||||
cairo_stroke (area->cr);
|
||||
cairo_move_to (area->cr, x, y);
|
||||
@@ -340,15 +225,11 @@ drawing_area_new (void)
|
||||
return g_object_new (drawing_area_get_type (), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
drawing_area_set_color (DrawingArea *area,
|
||||
GdkRGBA *color)
|
||||
{
|
||||
if (gdk_rgba_equal (&area->draw_color, color))
|
||||
return;
|
||||
|
||||
area->draw_color = *color;
|
||||
g_signal_emit (area, area_signals[COLOR_SET], 0, &area->draw_color);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -361,14 +242,6 @@ color_button_color_set (GtkColorButton *button,
|
||||
drawing_area_set_color (draw_area, &color);
|
||||
}
|
||||
|
||||
static void
|
||||
drawing_area_color_set (DrawingArea *area,
|
||||
GdkRGBA *color,
|
||||
GtkColorButton *button)
|
||||
{
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button), color);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_paint (GtkWidget *toplevel)
|
||||
{
|
||||
@@ -390,8 +263,6 @@ do_paint (GtkWidget *toplevel)
|
||||
colorbutton = gtk_color_button_new ();
|
||||
g_signal_connect (colorbutton, "color-set",
|
||||
G_CALLBACK (color_button_color_set), draw_area);
|
||||
g_signal_connect (draw_area, "color-set",
|
||||
G_CALLBACK (drawing_area_color_set), colorbutton);
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (colorbutton),
|
||||
&(GdkRGBA) { 0, 0, 0, 1 });
|
||||
|
||||
|
@@ -55,11 +55,10 @@ create_complex_popover (GtkWidget *parent,
|
||||
}
|
||||
|
||||
static void
|
||||
entry_size_allocate_cb (GtkEntry *entry,
|
||||
int width,
|
||||
int height,
|
||||
int baseline,
|
||||
gpointer user_data)
|
||||
entry_size_allocate_cb (GtkEntry *entry,
|
||||
const GtkAllocation *allocation,
|
||||
int baseline,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkEntryIconPosition popover_pos;
|
||||
GtkPopover *popover = user_data;
|
||||
@@ -78,6 +77,7 @@ entry_size_allocate_cb (GtkEntry *entry,
|
||||
static void
|
||||
entry_icon_press_cb (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos,
|
||||
GdkEvent *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *popover = user_data;
|
||||
@@ -119,7 +119,7 @@ day_selected_cb (GtkCalendar *calendar,
|
||||
|
||||
gtk_widget_show (popover);
|
||||
|
||||
g_object_unref (event);
|
||||
gdk_event_free (event);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
@@ -1,220 +0,0 @@
|
||||
/* Paintable/A simple paintable
|
||||
*
|
||||
* GdkPaintable is an interface used by GTK for drawings of any sort
|
||||
* that do not require layouting or positioning.
|
||||
*
|
||||
* This demo code gives a simple example on how a paintable can
|
||||
* be created.
|
||||
*
|
||||
* Paintables can be used in many places inside GTK widgets, but the
|
||||
* most common usage is inside GtkImage and that's what we're going
|
||||
* to do here.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "puzzlepiece.h"
|
||||
|
||||
/* Declare the struct. */
|
||||
struct _GtkPuzzlePiece
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GdkPaintable *puzzle;
|
||||
guint x;
|
||||
guint y;
|
||||
guint width;
|
||||
guint height;
|
||||
};
|
||||
|
||||
struct _GtkPuzzlePieceClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
/* This is the function that draws the puzzle piece.
|
||||
* It just draws a rectangular cutout of the puzzle by clipping
|
||||
* away the rest.
|
||||
*/
|
||||
static void
|
||||
gtk_puzzle_piece_snapshot (GdkPaintable *paintable,
|
||||
GdkSnapshot *snapshot,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
GtkPuzzlePiece *self = GTK_PUZZLE_PIECE (paintable);
|
||||
|
||||
gtk_snapshot_push_clip (snapshot,
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
|
||||
gtk_snapshot_offset (snapshot,
|
||||
- width * self->x,
|
||||
- height * self->y);
|
||||
gdk_paintable_snapshot (self->puzzle,
|
||||
snapshot,
|
||||
width * self->width,
|
||||
height * self->height);
|
||||
|
||||
gtk_snapshot_pop (snapshot);
|
||||
}
|
||||
|
||||
static GdkPaintableFlags
|
||||
gtk_puzzle_piece_get_flags (GdkPaintable *paintable)
|
||||
{
|
||||
GtkPuzzlePiece *self = GTK_PUZZLE_PIECE (paintable);
|
||||
|
||||
/* The flags are the same as the ones of the puzzle.
|
||||
* If the puzzle changes in some way, so do the pieces.
|
||||
*/
|
||||
return gdk_paintable_get_flags (self->puzzle);
|
||||
}
|
||||
|
||||
static int
|
||||
gtk_puzzle_piece_get_intrinsic_width (GdkPaintable *paintable)
|
||||
{
|
||||
GtkPuzzlePiece *self = GTK_PUZZLE_PIECE (paintable);
|
||||
|
||||
/* We can compute our width relative to the puzzle.
|
||||
* This logic even works for the case where the puzzle
|
||||
* has no width, because the 0 return value is unchanged.
|
||||
* Round up the value.
|
||||
*/
|
||||
return (gdk_paintable_get_intrinsic_width (self->puzzle) + self->width - 1) / self->width;
|
||||
}
|
||||
|
||||
static int
|
||||
gtk_puzzle_piece_get_intrinsic_height (GdkPaintable *paintable)
|
||||
{
|
||||
GtkPuzzlePiece *self = GTK_PUZZLE_PIECE (paintable);
|
||||
|
||||
/* Do the same thing we did for the width with the height.
|
||||
*/
|
||||
return (gdk_paintable_get_intrinsic_height (self->puzzle) + self->height - 1) / self->height;
|
||||
}
|
||||
|
||||
static double
|
||||
gtk_puzzle_piece_get_intrinsic_aspect_ratio (GdkPaintable *paintable)
|
||||
{
|
||||
GtkPuzzlePiece *self = GTK_PUZZLE_PIECE (paintable);
|
||||
|
||||
/* We can compute our aspect ratio relative to the puzzle.
|
||||
* This logic again works for the case where the puzzle
|
||||
* has no aspect ratio, because the 0 return value is unchanged.
|
||||
*/
|
||||
return gdk_paintable_get_intrinsic_aspect_ratio (self->puzzle) * self->height / self->width;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_puzzle_piece_paintable_init (GdkPaintableInterface *iface)
|
||||
{
|
||||
iface->snapshot = gtk_puzzle_piece_snapshot;
|
||||
iface->get_flags = gtk_puzzle_piece_get_flags;
|
||||
iface->get_intrinsic_width = gtk_puzzle_piece_get_intrinsic_width;
|
||||
iface->get_intrinsic_height = gtk_puzzle_piece_get_intrinsic_height;
|
||||
iface->get_intrinsic_aspect_ratio = gtk_puzzle_piece_get_intrinsic_aspect_ratio;
|
||||
}
|
||||
|
||||
/* When defining the GType, we need to implement the GdkPaintable interface */
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkPuzzlePiece, gtk_puzzle_piece, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
|
||||
gtk_puzzle_piece_paintable_init))
|
||||
|
||||
/* We need to declare a destructor to release our reference to the
|
||||
* puzzle paintable and disconnect our signal handlers.
|
||||
*/
|
||||
static void
|
||||
gtk_puzzle_piece_dispose (GObject *object)
|
||||
{
|
||||
GtkPuzzlePiece *self = GTK_PUZZLE_PIECE (object);
|
||||
|
||||
if (self->puzzle)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (self->puzzle, gdk_paintable_invalidate_contents, self);
|
||||
g_signal_handlers_disconnect_by_func (self->puzzle, gdk_paintable_invalidate_size, self);
|
||||
g_clear_object (&self->puzzle);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (gtk_puzzle_piece_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
/* Here's the boilerplate for the GObject declaration.
|
||||
*/
|
||||
static void
|
||||
gtk_puzzle_piece_class_init (GtkPuzzlePieceClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->dispose = gtk_puzzle_piece_dispose;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_puzzle_piece_init (GtkPuzzlePiece *self)
|
||||
{
|
||||
}
|
||||
|
||||
/* And finally, we add a constructor.
|
||||
* It is declared in the header so that the other examples
|
||||
* can use it.
|
||||
*/
|
||||
GdkPaintable *
|
||||
gtk_puzzle_piece_new (GdkPaintable *puzzle,
|
||||
guint x,
|
||||
guint y,
|
||||
guint width,
|
||||
guint height)
|
||||
{
|
||||
GtkPuzzlePiece *self;
|
||||
|
||||
/* These are sanity checks, so that we get warnings if we accidentally
|
||||
* do anything stupid. */
|
||||
g_return_val_if_fail (GDK_IS_PAINTABLE (puzzle), NULL);
|
||||
g_return_val_if_fail (width > 0, NULL);
|
||||
g_return_val_if_fail (height > 0, NULL);
|
||||
g_return_val_if_fail (x < width, NULL);
|
||||
g_return_val_if_fail (y < height, NULL);
|
||||
|
||||
self = g_object_new (GTK_TYPE_PUZZLE_PIECE, NULL);
|
||||
|
||||
self->puzzle = g_object_ref (puzzle);
|
||||
g_signal_connect_swapped (puzzle, "invalidate-contents", G_CALLBACK (gdk_paintable_invalidate_contents), self);
|
||||
g_signal_connect_swapped (puzzle, "invalidate-size", G_CALLBACK (gdk_paintable_invalidate_size), self);
|
||||
self->x = x;
|
||||
self->y = y;
|
||||
self->width = width;
|
||||
self->height = height;
|
||||
|
||||
return GDK_PAINTABLE (self);
|
||||
}
|
||||
|
||||
/* Here are the accessors that we need to inspect the puzzle
|
||||
* pieces in other code.
|
||||
*/
|
||||
GdkPaintable *
|
||||
gtk_puzzle_piece_get_puzzle (GtkPuzzlePiece *self)
|
||||
{
|
||||
/* Add sanity checks here, too.
|
||||
* If you make a habit out of this, you can always rely
|
||||
* on your code having sanity checks, which makes it
|
||||
* way easier to debug.
|
||||
*/
|
||||
g_return_val_if_fail (GTK_IS_PUZZLE_PIECE (self), NULL);
|
||||
|
||||
return self->puzzle;
|
||||
}
|
||||
|
||||
guint
|
||||
gtk_puzzle_piece_get_x (GtkPuzzlePiece *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PUZZLE_PIECE (self), 0);
|
||||
|
||||
return self->x;
|
||||
}
|
||||
|
||||
guint
|
||||
gtk_puzzle_piece_get_y (GtkPuzzlePiece *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PUZZLE_PIECE (self), 0);
|
||||
|
||||
return self->y;
|
||||
}
|
||||
|
@@ -1,23 +0,0 @@
|
||||
#ifndef __PUZZLE_PIECE_H__
|
||||
#define __PUZZLE_PIECE_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
/* First, add the boilerplate for the object itself.
|
||||
*/
|
||||
#define GTK_TYPE_PUZZLE_PIECE (gtk_puzzle_piece_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (GtkPuzzlePiece, gtk_puzzle_piece, GTK, PUZZLE_PIECE, GObject)
|
||||
|
||||
/* Then, declare all constructors */
|
||||
GdkPaintable * gtk_puzzle_piece_new (GdkPaintable *puzzle,
|
||||
guint x,
|
||||
guint y,
|
||||
guint width,
|
||||
guint height);
|
||||
|
||||
/* Next, add the getters and setters for object properties */
|
||||
GdkPaintable * gtk_puzzle_piece_get_puzzle (GtkPuzzlePiece *self);
|
||||
guint gtk_puzzle_piece_get_x (GtkPuzzlePiece *self);
|
||||
guint gtk_puzzle_piece_get_y (GtkPuzzlePiece *self);
|
||||
|
||||
#endif /* __PUZZLE_PIECE_H__ */
|
@@ -151,10 +151,11 @@ create_search_menu (GtkWidget *entry)
|
||||
static void
|
||||
icon_press_cb (GtkEntry *entry,
|
||||
gint position,
|
||||
GdkEventButton *event,
|
||||
gpointer data)
|
||||
{
|
||||
if (position == GTK_ENTRY_ICON_PRIMARY)
|
||||
gtk_menu_popup_at_pointer (GTK_MENU (menu), NULL);
|
||||
gtk_menu_popup_at_pointer (GTK_MENU (menu), (GdkEvent *) event);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -26,6 +26,17 @@ changed_cb (GtkEditable *editable)
|
||||
g_message ("changed: %s", text);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
window_key_press_event_cb (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
GtkSearchBar *bar)
|
||||
{
|
||||
if (gdk_event_get_event_type (event) == GDK_KEY_PRESS)
|
||||
return gtk_search_bar_handle_event (bar, event);
|
||||
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
static void
|
||||
search_changed (GtkSearchEntry *entry,
|
||||
GtkLabel *label)
|
||||
@@ -91,7 +102,7 @@ do_search_entry2 (GtkWidget *do_widget)
|
||||
gtk_box_pack_start (GTK_BOX (vbox), searchbar);
|
||||
|
||||
/* Hook the search bar to key presses */
|
||||
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (searchbar), window);
|
||||
g_signal_connect (window, "event", G_CALLBACK (window_key_press_event_cb), searchbar);
|
||||
|
||||
/* Help */
|
||||
label = gtk_label_new ("Start Typing to search");
|
||||
|
@@ -1,486 +0,0 @@
|
||||
/* Sliding puzzle
|
||||
*
|
||||
* This demo demonstrates how to use gestures and paintables to create a
|
||||
* small sliding puzzle game.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
/* Include the header for the puzzle piece */
|
||||
#include "puzzlepiece.h"
|
||||
#include "paintable.h"
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
static GtkWidget *frame = NULL;
|
||||
static GtkWidget *choices = NULL;
|
||||
static GtkWidget *size_spin = NULL;
|
||||
static GdkPaintable *puzzle = NULL;
|
||||
|
||||
static gboolean solved = TRUE;
|
||||
static guint width = 3;
|
||||
static guint height = 3;
|
||||
static guint pos_x;
|
||||
static guint pos_y;
|
||||
|
||||
static gboolean
|
||||
move_puzzle (GtkWidget *grid,
|
||||
int dx,
|
||||
int dy)
|
||||
{
|
||||
GtkWidget *pos, *next;
|
||||
GdkPaintable *piece;
|
||||
guint next_x, next_y;
|
||||
|
||||
/* We don't move anything if the puzzle is solved */
|
||||
if (solved)
|
||||
return FALSE;
|
||||
|
||||
/* Return FALSE if we can't move to where the call
|
||||
* wants us to move.
|
||||
*/
|
||||
if ((dx < 0 && pos_x < -dx) ||
|
||||
dx + pos_x >= width ||
|
||||
(dy < 0 && pos_y < -dy) ||
|
||||
dy + pos_y >= height)
|
||||
return FALSE;
|
||||
|
||||
/* Compute the new position */
|
||||
next_x = pos_x + dx;
|
||||
next_y = pos_y + dy;
|
||||
|
||||
/* Get the current and next image */
|
||||
pos = gtk_grid_get_child_at (GTK_GRID (grid), pos_x, pos_y);
|
||||
next = gtk_grid_get_child_at (GTK_GRID (grid), next_x, next_y);
|
||||
|
||||
/* Move the displayed piece. */
|
||||
piece = gtk_picture_get_paintable (GTK_PICTURE (next));
|
||||
gtk_picture_set_paintable (GTK_PICTURE (pos), piece);
|
||||
gtk_picture_set_paintable (GTK_PICTURE (next), NULL);
|
||||
|
||||
/* Update the current position */
|
||||
pos_x = next_x;
|
||||
pos_y = next_y;
|
||||
|
||||
/* Return TRUE because we successfully moved the piece */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
shuffle_puzzle (GtkWidget *grid)
|
||||
{
|
||||
guint i, n_steps;
|
||||
|
||||
/* Do this many random moves */
|
||||
n_steps = width * height * 50;
|
||||
|
||||
for (i = 0; i < n_steps; i++)
|
||||
{
|
||||
/* Get a random number for the direction to move in */
|
||||
switch (g_random_int_range (0, 4))
|
||||
{
|
||||
case 0:
|
||||
/* left */
|
||||
move_puzzle (grid, -1, 0);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
/* up */
|
||||
move_puzzle (grid, 0, -1);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
/* right */
|
||||
move_puzzle (grid, 1, 0);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
/* down */
|
||||
move_puzzle (grid, 0, 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_solved (GtkWidget *grid)
|
||||
{
|
||||
GtkWidget *picture;
|
||||
GdkPaintable *piece;
|
||||
guint x, y;
|
||||
|
||||
/* Nothing to check if the puzzle is already solved */
|
||||
if (solved)
|
||||
return TRUE;
|
||||
|
||||
/* If the empty cell isn't in the bottom right,
|
||||
* the puzzle is obviously not solved */
|
||||
if (pos_x != width - 1 ||
|
||||
pos_y != height - 1)
|
||||
return FALSE;
|
||||
|
||||
/* Check that all pieces are in the right position */
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
picture = gtk_grid_get_child_at (GTK_GRID (grid), x, y);
|
||||
piece = gtk_picture_get_paintable (GTK_PICTURE (picture));
|
||||
|
||||
/* empty cell */
|
||||
if (piece == NULL)
|
||||
continue;
|
||||
|
||||
if (gtk_puzzle_piece_get_x (GTK_PUZZLE_PIECE (piece)) != x ||
|
||||
gtk_puzzle_piece_get_y (GTK_PUZZLE_PIECE (piece)) != y)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* We solved the puzzle!
|
||||
*/
|
||||
solved = TRUE;
|
||||
|
||||
/* Fill the empty cell to show that we're done.
|
||||
*/
|
||||
picture = gtk_grid_get_child_at (GTK_GRID (grid), 0, 0);
|
||||
piece = gtk_picture_get_paintable (GTK_PICTURE (picture));
|
||||
|
||||
piece = gtk_puzzle_piece_new (gtk_puzzle_piece_get_puzzle (GTK_PUZZLE_PIECE (piece)),
|
||||
pos_x, pos_y,
|
||||
width, height);
|
||||
picture = gtk_grid_get_child_at (GTK_GRID (grid), pos_x, pos_y);
|
||||
gtk_picture_set_paintable (GTK_PICTURE (picture), piece);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
puzzle_key_pressed (GtkEventControllerKey *controller,
|
||||
guint keyval,
|
||||
guint keycode,
|
||||
GdkModifierType state,
|
||||
GtkWidget *grid)
|
||||
{
|
||||
int dx, dy;
|
||||
|
||||
dx = 0;
|
||||
dy = 0;
|
||||
|
||||
switch (keyval)
|
||||
{
|
||||
case GDK_KEY_KP_Left:
|
||||
case GDK_KEY_Left:
|
||||
/* left */
|
||||
dx = -1;
|
||||
break;
|
||||
|
||||
case GDK_KEY_KP_Up:
|
||||
case GDK_KEY_Up:
|
||||
/* up */
|
||||
dy = -1;
|
||||
break;
|
||||
|
||||
case GDK_KEY_KP_Right:
|
||||
case GDK_KEY_Right:
|
||||
/* right */
|
||||
dx = 1;
|
||||
break;
|
||||
|
||||
case GDK_KEY_KP_Down:
|
||||
case GDK_KEY_Down:
|
||||
/* down */
|
||||
dy = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* We return FALSE here because we didn't handle the key that was pressed */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!move_puzzle (grid, dx, dy))
|
||||
{
|
||||
/* Make the error sound and then return TRUE.
|
||||
* We handled this key, even though we didn't
|
||||
* do anything to the puzzle.
|
||||
*/
|
||||
gtk_widget_error_bell (grid);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
check_solved (grid);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
puzzle_button_pressed (GtkGestureMultiPress *gesture,
|
||||
int n_press,
|
||||
double x,
|
||||
double y,
|
||||
GtkWidget *grid)
|
||||
{
|
||||
GtkWidget *child;
|
||||
int l, t, i;
|
||||
int pos;
|
||||
|
||||
child = gtk_widget_pick (grid, x, y);
|
||||
|
||||
if (!child)
|
||||
{
|
||||
gtk_widget_error_bell (grid);
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_container_child_get (GTK_CONTAINER (grid), child,
|
||||
"left-attach", &l,
|
||||
"top-attach", &t,
|
||||
NULL);
|
||||
|
||||
if (l == pos_x && t == pos_y)
|
||||
{
|
||||
gtk_widget_error_bell (grid);
|
||||
}
|
||||
else if (l == pos_x)
|
||||
{
|
||||
pos = pos_y;
|
||||
for (i = t; i < pos; i++)
|
||||
{
|
||||
if (!move_puzzle (grid, 0, -1))
|
||||
gtk_widget_error_bell (grid);
|
||||
}
|
||||
for (i = pos; i < t; i++)
|
||||
{
|
||||
if (!move_puzzle (grid, 0, 1))
|
||||
gtk_widget_error_bell (grid);
|
||||
}
|
||||
}
|
||||
else if (t == pos_y)
|
||||
{
|
||||
pos = pos_x;
|
||||
for (i = l; i < pos; i++)
|
||||
{
|
||||
if (!move_puzzle (grid, -1, 0))
|
||||
gtk_widget_error_bell (grid);
|
||||
}
|
||||
for (i = pos; i < l; i++)
|
||||
{
|
||||
if (!move_puzzle (grid, 1, 0))
|
||||
gtk_widget_error_bell (grid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_error_bell (grid);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
start_puzzle (GdkPaintable *puzzle)
|
||||
{
|
||||
GtkWidget *picture, *grid;
|
||||
GtkEventController *controller;
|
||||
guint x, y;
|
||||
|
||||
/* Remove the old grid (if there is one) */
|
||||
grid = gtk_bin_get_child (GTK_BIN (frame));
|
||||
if (grid)
|
||||
gtk_container_remove (GTK_CONTAINER (frame), grid);
|
||||
|
||||
/* Create a new grid */
|
||||
grid = gtk_grid_new ();
|
||||
gtk_widget_set_can_focus (grid, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (frame), grid);
|
||||
gtk_aspect_frame_set (GTK_ASPECT_FRAME (frame), 0.5, 0.5, (float) gdk_paintable_get_intrinsic_aspect_ratio (puzzle), FALSE);
|
||||
|
||||
/* Add a key event controller so people can use the arrow
|
||||
* keys to move the puzzle */
|
||||
controller = gtk_event_controller_key_new ();
|
||||
g_signal_connect (controller, "key-pressed",
|
||||
G_CALLBACK (puzzle_key_pressed),
|
||||
grid);
|
||||
gtk_widget_add_controller (GTK_WIDGET (grid), controller);
|
||||
|
||||
controller = GTK_EVENT_CONTROLLER (gtk_gesture_multi_press_new ());
|
||||
g_signal_connect (controller, "pressed",
|
||||
G_CALLBACK (puzzle_button_pressed),
|
||||
grid);
|
||||
gtk_widget_add_controller (GTK_WIDGET (grid), controller);
|
||||
|
||||
/* Make sure the cells have equal size */
|
||||
gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE);
|
||||
gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE);
|
||||
|
||||
/* Reset the variables */
|
||||
solved = FALSE;
|
||||
pos_x = width - 1;
|
||||
pos_y = height - 1;
|
||||
|
||||
/* add a picture for every cell */
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
GdkPaintable *piece;
|
||||
|
||||
/* Don't paint anything for the lsiding part of the video */
|
||||
if (x == pos_x && y == pos_y)
|
||||
piece = NULL;
|
||||
else
|
||||
piece = gtk_puzzle_piece_new (puzzle,
|
||||
x, y,
|
||||
width, height);
|
||||
picture = gtk_picture_new_for_paintable (piece);
|
||||
gtk_picture_set_keep_aspect_ratio (GTK_PICTURE (picture), FALSE);
|
||||
gtk_grid_attach (GTK_GRID (grid),
|
||||
picture,
|
||||
x, y,
|
||||
1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
shuffle_puzzle (grid);
|
||||
}
|
||||
|
||||
static void
|
||||
reshuffle (void)
|
||||
{
|
||||
GtkWidget *grid;
|
||||
|
||||
grid = gtk_bin_get_child (GTK_BIN (frame));
|
||||
if (solved)
|
||||
start_puzzle (puzzle);
|
||||
else
|
||||
shuffle_puzzle (grid);
|
||||
gtk_widget_grab_focus (grid);
|
||||
}
|
||||
|
||||
static void
|
||||
reconfigure (void)
|
||||
{
|
||||
GtkWidget *popover;
|
||||
GtkWidget *grid;
|
||||
GtkWidget *child;
|
||||
GtkWidget *image;
|
||||
GList *selected;
|
||||
|
||||
width = height = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (size_spin));
|
||||
|
||||
selected = gtk_flow_box_get_selected_children (GTK_FLOW_BOX (choices));
|
||||
if (selected == NULL)
|
||||
child = gtk_widget_get_first_child (choices);
|
||||
else
|
||||
{
|
||||
child = selected->data;
|
||||
g_list_free (selected);
|
||||
}
|
||||
image = gtk_bin_get_child (GTK_BIN (child));
|
||||
puzzle = gtk_image_get_paintable (GTK_IMAGE (image));
|
||||
|
||||
start_puzzle (puzzle);
|
||||
popover = gtk_widget_get_ancestor (size_spin, GTK_TYPE_POPOVER);
|
||||
gtk_popover_popdown (GTK_POPOVER (popover));
|
||||
grid = gtk_bin_get_child (GTK_BIN (frame));
|
||||
gtk_widget_grab_focus (grid);
|
||||
}
|
||||
|
||||
static void
|
||||
add_choice (GtkWidget *choices,
|
||||
GdkPaintable *paintable)
|
||||
{
|
||||
GtkWidget *icon;
|
||||
|
||||
icon = gtk_image_new_from_paintable (paintable);
|
||||
gtk_image_set_icon_size (GTK_IMAGE (icon), GTK_ICON_SIZE_LARGE);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (choices), icon);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_sliding_puzzle (GtkWidget *do_widget)
|
||||
{
|
||||
if (!window)
|
||||
{
|
||||
GtkWidget *header;
|
||||
GtkWidget *restart;
|
||||
GtkWidget *tweak;
|
||||
GtkWidget *popover;
|
||||
GtkWidget *tweaks;
|
||||
GtkWidget *apply;
|
||||
GtkWidget *label;
|
||||
GtkWidget *sw;
|
||||
GtkMediaStream *media;
|
||||
|
||||
puzzle = GDK_PAINTABLE (gdk_texture_new_from_resource ("/sliding_puzzle/portland-rose.jpg"));
|
||||
|
||||
tweaks = gtk_grid_new ();
|
||||
gtk_grid_set_row_spacing (GTK_GRID (tweaks), 10);
|
||||
gtk_grid_set_column_spacing (GTK_GRID (tweaks), 10);
|
||||
g_object_set (tweaks, "margin", 10, NULL);
|
||||
|
||||
choices = gtk_flow_box_new ();
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (choices), GTK_STYLE_CLASS_VIEW);
|
||||
add_choice (choices, puzzle);
|
||||
add_choice (choices, gtk_nuclear_animation_new ());
|
||||
media = gtk_media_file_new_for_resource ("/images/gtk-logo.webm");
|
||||
gtk_media_stream_set_loop (media, TRUE);
|
||||
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);
|
||||
gtk_container_add (GTK_CONTAINER (sw), choices);
|
||||
gtk_grid_attach (GTK_GRID (tweaks), sw, 0, 0, 2, 1);
|
||||
|
||||
label = gtk_label_new ("Size");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
gtk_grid_attach (GTK_GRID (tweaks), label, 0, 1, 1, 1);
|
||||
size_spin = gtk_spin_button_new_with_range (2, 10, 1);
|
||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (size_spin), width);
|
||||
gtk_grid_attach (GTK_GRID (tweaks), size_spin, 1, 1, 1, 1);
|
||||
|
||||
apply = gtk_button_new_with_label ("Apply");
|
||||
gtk_widget_set_halign (apply, GTK_ALIGN_END);
|
||||
gtk_grid_attach (GTK_GRID (tweaks), apply, 1, 2, 1, 1);
|
||||
g_signal_connect (apply, "clicked", G_CALLBACK (reconfigure), NULL);
|
||||
|
||||
popover = gtk_popover_new (NULL);
|
||||
gtk_popover_set_modal (GTK_POPOVER (popover), TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (popover), tweaks);
|
||||
|
||||
tweak = gtk_menu_button_new ();
|
||||
gtk_menu_button_set_popover (GTK_MENU_BUTTON (tweak), popover);
|
||||
gtk_button_set_icon_name (GTK_BUTTON (tweak), "emblem-system-symbolic");
|
||||
|
||||
restart = gtk_button_new_from_icon_name ("view-refresh-symbolic");
|
||||
g_signal_connect (restart, "clicked", G_CALLBACK (reshuffle), NULL);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), restart);
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), tweak);
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Sliding Puzzle");
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
||||
frame = gtk_aspect_frame_new (NULL, 0.5, 0.5, (float) gdk_paintable_get_intrinsic_aspect_ratio (puzzle), FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (window), frame);
|
||||
|
||||
start_puzzle (puzzle);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
|
||||
return window;
|
||||
}
|
10
demos/gtk-demo/theme.css
Normal file
10
demos/gtk-demo/theme.css
Normal file
@@ -0,0 +1,10 @@
|
||||
window.devel headerbar {
|
||||
background: #cbd2d9 -gtk-icontheme("system-run-symbolic") 70% 0/64px 64px no-repeat, linear-gradient(to left, #a5b1bd 0%, #a5b1bd 8%, @theme_bg_color 25%);
|
||||
box-shadow: inset 0 1px #f1f3f5;
|
||||
border-color: #909fae;
|
||||
color: rgba(46, 52, 54, 0.2);
|
||||
}
|
||||
|
||||
window.devel headerbar label {
|
||||
color: @theme_fg_color;
|
||||
}
|
@@ -376,9 +376,10 @@ search_mode_toggled (GObject *searchbar, GParamSpec *pspec, IconBrowserWindow *w
|
||||
|
||||
static void
|
||||
get_image_data (GtkWidget *widget,
|
||||
GdkDrag *drag,
|
||||
GdkDragContext *context,
|
||||
GtkSelectionData *selection,
|
||||
guint target_info,
|
||||
guint time,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *image;
|
||||
@@ -398,9 +399,10 @@ get_image_data (GtkWidget *widget,
|
||||
|
||||
static void
|
||||
get_scalable_image_data (GtkWidget *widget,
|
||||
GdkDrag *drag,
|
||||
GdkDragContext *context,
|
||||
GtkSelectionData *selection,
|
||||
guint target_info,
|
||||
guint time,
|
||||
gpointer data)
|
||||
{
|
||||
gchar *uris[2];
|
||||
|
@@ -17,4 +17,4 @@ executable('gtk4-icon-browser',
|
||||
link_args: extra_demo_ldflags,
|
||||
install: true)
|
||||
|
||||
install_data('org.gtk.IconBrowser.desktop', install_dir: gtk_applicationsdir)
|
||||
install_data('gtk4-icon-browser.desktop', install_dir: gtk_applicationsdir)
|
||||
|
@@ -6,7 +6,6 @@
|
||||
<property name="child-model">store</property>
|
||||
</object>
|
||||
<template class="IconBrowserWindow" parent="GtkApplicationWindow">
|
||||
<style><class name="devel"/></style>
|
||||
<property name="title" translatable="yes">Icon Browser</property>
|
||||
<property name="default-width">1024</property>
|
||||
<property name="default-height">768</property>
|
||||
|
19
demos/widget-factory/menus.ui
Normal file
19
demos/widget-factory/menus.ui
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<!-- interface-requires gtk+ 3.0 -->
|
||||
<menu id="app-menu">
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">About</attribute>
|
||||
<attribute name="action">app.about</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Quit</attribute>
|
||||
<attribute name="action">app.quit</attribute>
|
||||
<attribute name="accel"><Primary>q</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
</interface>
|
@@ -13,7 +13,7 @@ executable('gtk4-widget-factory',
|
||||
install: true)
|
||||
|
||||
# desktop file
|
||||
install_data('org.gtk.WidgetFactory.desktop', install_dir: gtk_applicationsdir)
|
||||
install_data('gtk4-widget-factory.desktop', install_dir: gtk_applicationsdir)
|
||||
|
||||
# icons
|
||||
icontheme_dir = join_paths(gtk_datadir, 'icons/hicolor')
|
||||
|
@@ -353,6 +353,7 @@ update_pulse_time (GtkAdjustment *adjustment, GtkWidget *widget)
|
||||
static void
|
||||
on_entry_icon_release (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos,
|
||||
GdkEvent *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (icon_pos != GTK_ENTRY_ICON_SECONDARY)
|
||||
@@ -966,8 +967,8 @@ background_loaded_cb (GObject *source,
|
||||
return;
|
||||
}
|
||||
|
||||
child = gtk_picture_new_for_pixbuf (pixbuf);
|
||||
gtk_widget_set_size_request (child, 110, 70);
|
||||
child = gtk_image_new_from_pixbuf (pixbuf);
|
||||
gtk_widget_show (child);
|
||||
gtk_flow_box_insert (GTK_FLOW_BOX (bd->flowbox), child, -1);
|
||||
child = gtk_widget_get_parent (child);
|
||||
g_object_set_data_full (G_OBJECT (child), "filename", bd->filename, g_free);
|
||||
@@ -995,7 +996,8 @@ populate_flowbox (GtkWidget *flowbox)
|
||||
|
||||
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 110, 70);
|
||||
gdk_pixbuf_fill (pixbuf, 0xffffffff);
|
||||
child = gtk_picture_new_for_pixbuf (pixbuf);
|
||||
child = gtk_image_new_from_pixbuf (pixbuf);
|
||||
gtk_widget_show (child);
|
||||
gtk_flow_box_insert (GTK_FLOW_BOX (flowbox), child, -1);
|
||||
|
||||
location = "/usr/share/backgrounds/gnome";
|
||||
@@ -1080,7 +1082,7 @@ set_accel (GtkApplication *app, GtkWidget *widget)
|
||||
typedef struct
|
||||
{
|
||||
GtkTextView tv;
|
||||
GdkTexture *texture;
|
||||
GdkPixbuf *pixbuf;
|
||||
} MyTextView;
|
||||
|
||||
typedef GtkTextViewClass MyTextViewClass;
|
||||
@@ -1093,23 +1095,18 @@ my_text_view_init (MyTextView *tv)
|
||||
}
|
||||
|
||||
static void
|
||||
my_tv_snapshot_layer (GtkTextView *widget,
|
||||
GtkTextViewLayer layer,
|
||||
GtkSnapshot *snapshot)
|
||||
my_tv_draw_layer (GtkTextView *widget,
|
||||
GtkTextViewLayer layer,
|
||||
cairo_t *cr)
|
||||
{
|
||||
MyTextView *tv = (MyTextView *)widget;
|
||||
|
||||
if (layer == GTK_TEXT_VIEW_LAYER_BELOW_TEXT && tv->texture)
|
||||
if (layer == GTK_TEXT_VIEW_LAYER_BELOW_TEXT && tv->pixbuf)
|
||||
{
|
||||
gtk_snapshot_push_opacity (snapshot, 0.333);
|
||||
gtk_snapshot_append_texture (snapshot,
|
||||
tv->texture,
|
||||
&GRAPHENE_RECT_INIT(
|
||||
0, 0,
|
||||
gdk_texture_get_width (tv->texture),
|
||||
gdk_texture_get_height (tv->texture)
|
||||
));
|
||||
gtk_snapshot_pop (snapshot);
|
||||
cairo_save (cr);
|
||||
gdk_cairo_set_source_pixbuf (cr, tv->pixbuf, 0.0, 0.0);
|
||||
cairo_paint_with_alpha (cr, 0.333);
|
||||
cairo_restore (cr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1118,7 +1115,7 @@ my_tv_finalize (GObject *object)
|
||||
{
|
||||
MyTextView *tv = (MyTextView *)object;
|
||||
|
||||
g_clear_object (&tv->texture);
|
||||
g_clear_object (&tv->pixbuf);
|
||||
|
||||
G_OBJECT_CLASS (my_text_view_parent_class)->finalize (object);
|
||||
}
|
||||
@@ -1130,24 +1127,20 @@ my_text_view_class_init (MyTextViewClass *class)
|
||||
GObjectClass *o_class = G_OBJECT_CLASS (class);
|
||||
|
||||
o_class->finalize = my_tv_finalize;
|
||||
tv_class->snapshot_layer = my_tv_snapshot_layer;
|
||||
tv_class->draw_layer = my_tv_draw_layer;
|
||||
}
|
||||
|
||||
static void
|
||||
my_text_view_set_background (MyTextView *tv, const gchar *filename)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GFile *file;
|
||||
|
||||
g_clear_object (&tv->texture);
|
||||
g_clear_object (&tv->pixbuf);
|
||||
|
||||
if (filename == NULL)
|
||||
return;
|
||||
|
||||
file = g_file_new_for_path (filename);
|
||||
tv->texture = gdk_texture_new_from_file (file, &error);
|
||||
g_object_unref (file);
|
||||
|
||||
tv->pixbuf = gdk_pixbuf_new_from_file (filename, &error);
|
||||
if (error)
|
||||
{
|
||||
g_warning ("%s", error->message);
|
||||
@@ -1612,6 +1605,27 @@ adjustment3_value_changed (GtkAdjustment *adj, GtkProgressBar *pbar)
|
||||
gtk_progress_bar_set_fraction (pbar, fraction);
|
||||
}
|
||||
|
||||
static void
|
||||
settings__notify_gtk_theme_name (GObject *gobject,
|
||||
GParamSpec *pspec,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *window = data;
|
||||
char *theme_name = NULL;
|
||||
|
||||
g_object_get (gobject, "gtk-theme-name", &theme_name, NULL);
|
||||
|
||||
if (g_strcmp0 (theme_name, "Adwaita") == 0)
|
||||
{
|
||||
if (gtk_get_minor_version () % 2 != 0)
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (window), "devel");
|
||||
}
|
||||
else
|
||||
gtk_style_context_remove_class (gtk_widget_get_style_context (window), "devel");
|
||||
|
||||
g_free (theme_name);
|
||||
}
|
||||
|
||||
static void
|
||||
activate (GApplication *app)
|
||||
{
|
||||
@@ -1687,6 +1701,13 @@ activate (GApplication *app)
|
||||
win_entries, G_N_ELEMENTS (win_entries),
|
||||
window);
|
||||
|
||||
g_signal_connect (gtk_settings_get_default (), "notify::gtk-theme-name",
|
||||
G_CALLBACK (settings__notify_gtk_theme_name),
|
||||
window);
|
||||
settings__notify_gtk_theme_name (G_OBJECT (gtk_settings_get_default ()),
|
||||
NULL,
|
||||
window);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (accels); i++)
|
||||
gtk_application_set_accels_for_action (GTK_APPLICATION (app), accels[i].action_and_target, accels[i].accelerators);
|
||||
|
||||
|
@@ -24,3 +24,14 @@
|
||||
.border-ridge {
|
||||
border-width: 2px;
|
||||
}
|
||||
|
||||
window.devel headerbar {
|
||||
background: #cbd2d9 -gtk-icontheme("system-run-symbolic") 70% 0/64px 64px no-repeat, linear-gradient(to left, #a5b1bd 0%, #a5b1bd 8%, @theme_bg_color 25%);
|
||||
box-shadow: inset 0 1px #f1f3f5;
|
||||
border-color: #909fae;
|
||||
color: rgba(46, 52, 54, 0.2);
|
||||
}
|
||||
|
||||
window.devel headerbar label {
|
||||
color: @theme_fg_color;
|
||||
}
|
||||
|
@@ -6,6 +6,9 @@
|
||||
<gresource prefix="/org/gtk/WidgetFactory">
|
||||
<file>widget-factory.css</file>
|
||||
</gresource>
|
||||
<gresource prefix="/org/gtk/WidgetFactory/gtk">
|
||||
<file preprocess="xml-stripblanks">menus.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/org/gtk/WidgetFactory/gtk">
|
||||
<file preprocess="xml-stripblanks">help-overlay.ui</file>
|
||||
</gresource>
|
||||
|
@@ -16,16 +16,6 @@
|
||||
<attribute name="action">win.transition</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
|
||||
<attribute name="action">win.show-help-overlay</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_About Widget Factory</attribute>
|
||||
<attribute name="action">app.about</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
<menu id="dinner_menu">
|
||||
<section>
|
||||
@@ -406,7 +396,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkApplicationWindow" id="window">
|
||||
<style><class name="devel"/></style>
|
||||
<property name="title">GTK+ Widget Factory</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="headerbar1">
|
||||
@@ -2237,9 +2226,6 @@ microphone-sensitivity-medium-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Save the current document</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorToolItem"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton">
|
||||
<property name="label" translatable="yes">Search</property>
|
||||
|
@@ -71,7 +71,7 @@ straightforward manner.
|
||||
void gdk_drag_status (GdkDragContext *context,
|
||||
GdkDragAction action,
|
||||
guint32 time);
|
||||
void gdk_drag_finish (GdkDragContext *context,
|
||||
void gdk_drop_finish (GdkDragContext *context,
|
||||
gboolean success,
|
||||
guint32 time);
|
||||
GdkAtom gdk_drag_get_selection (GdkDragContext *context);
|
||||
|
@@ -171,6 +171,7 @@ gdk_rgba_get_type
|
||||
<FILE>gdksurface</FILE>
|
||||
GdkSurface
|
||||
GdkSurfaceType
|
||||
GdkSurfaceClass
|
||||
GdkSurfaceHints
|
||||
GdkGeometry
|
||||
GdkGravity
|
||||
@@ -193,6 +194,7 @@ gdk_surface_is_visible
|
||||
gdk_surface_is_viewable
|
||||
gdk_surface_is_input_only
|
||||
gdk_surface_get_state
|
||||
gdk_surface_withdraw
|
||||
gdk_surface_iconify
|
||||
gdk_surface_deiconify
|
||||
gdk_surface_stick
|
||||
@@ -280,6 +282,8 @@ gdk_surface_get_toplevel
|
||||
gdk_surface_get_children
|
||||
gdk_surface_get_children_with_user_data
|
||||
gdk_surface_peek_children
|
||||
gdk_surface_get_events
|
||||
gdk_surface_set_events
|
||||
gdk_surface_set_icon_name
|
||||
gdk_surface_set_transient_for
|
||||
gdk_surface_set_role
|
||||
@@ -297,6 +301,8 @@ gdk_surface_get_support_multidevice
|
||||
gdk_surface_set_support_multidevice
|
||||
gdk_surface_get_device_cursor
|
||||
gdk_surface_set_device_cursor
|
||||
gdk_surface_get_device_events
|
||||
gdk_surface_set_device_events
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_surface_coords_from_parent
|
||||
@@ -621,6 +627,7 @@ GDK_BUTTON_SECONDARY
|
||||
<SUBSECTION>
|
||||
gdk_event_new
|
||||
gdk_event_copy
|
||||
gdk_event_free
|
||||
gdk_event_get_axes
|
||||
gdk_event_get_button
|
||||
gdk_event_get_click_count
|
||||
@@ -646,7 +653,7 @@ gdk_event_get_scancode
|
||||
gdk_event_get_pointer_emulated
|
||||
gdk_event_get_crossing_detail
|
||||
gdk_event_get_crossing_mode
|
||||
gdk_event_get_drop
|
||||
gdk_event_get_drag_context
|
||||
gdk_event_get_focus_in
|
||||
gdk_event_get_grab_surface
|
||||
gdk_event_get_motion_history
|
||||
@@ -655,6 +662,7 @@ gdk_event_get_key_is_modifier
|
||||
gdk_event_get_pad_axis_value
|
||||
gdk_event_get_pad_button
|
||||
gdk_event_get_pad_group_mode
|
||||
gdk_event_get_string
|
||||
gdk_event_get_touch_emulating_pointer
|
||||
gdk_event_get_touchpad_angle_delta
|
||||
gdk_event_get_touchpad_deltas
|
||||
@@ -691,7 +699,7 @@ gdk_event_get_type
|
||||
|
||||
<SECTION>
|
||||
<FILE>gdkpaintable</FILE>
|
||||
<TITLE>GdkPaintable</TITLE>
|
||||
<TITLE>GdkPaintable/TITLE>
|
||||
GdkPaintable
|
||||
GdkPaintableFlags
|
||||
gdk_paintable_get_current_image
|
||||
@@ -772,60 +780,38 @@ gdk_cursor_get_type
|
||||
<SECTION>
|
||||
<TITLE>Drag and Drop</TITLE>
|
||||
<FILE>dnd</FILE>
|
||||
GdkDrag
|
||||
GdkDrop
|
||||
GdkDragContext
|
||||
GdkDragCancelReason
|
||||
gdk_drag_drop_done
|
||||
gdk_drag_begin
|
||||
GdkDragAction
|
||||
GDK_ACTION_ALL
|
||||
|
||||
gdk_drag_get_display
|
||||
gdk_drag_get_actions
|
||||
gdk_drag_get_suggested_action
|
||||
gdk_drag_get_selected_action
|
||||
gdk_drag_get_formats
|
||||
gdk_drag_get_device
|
||||
gdk_drag_get_drag_surface
|
||||
gdk_drag_set_hotspot
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_drag_action_is_unique
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_drop_get_display
|
||||
gdk_drop_get_device
|
||||
gdk_drop_get_surface
|
||||
gdk_drop_get_formats
|
||||
gdk_drop_get_actions
|
||||
gdk_drop_get_drag
|
||||
gdk_drop_status
|
||||
gdk_drop_finish
|
||||
gdk_drop_read_async
|
||||
gdk_drop_read_finish
|
||||
gdk_drop_read_value_async
|
||||
gdk_drop_read_value_finish
|
||||
gdk_drop_read_text_async
|
||||
gdk_drop_read_text_finish
|
||||
GdkDragAction
|
||||
gdk_drag_status
|
||||
|
||||
gdk_drag_context_get_display
|
||||
gdk_drag_context_get_actions
|
||||
gdk_drag_context_get_suggested_action
|
||||
gdk_drag_context_get_selected_action
|
||||
gdk_drag_context_get_formats
|
||||
gdk_drag_context_get_device
|
||||
gdk_drag_context_get_source_surface
|
||||
gdk_drag_context_get_dest_surface
|
||||
gdk_drag_context_get_drag_surface
|
||||
gdk_drag_context_set_hotspot
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GDK_DRAG
|
||||
GDK_TYPE_DRAG
|
||||
GDK_IS_DRAG
|
||||
GDK_DRAG_CLASS
|
||||
GDK_DRAG_GET_CLASS
|
||||
GDK_IS_DRAG_CLASS
|
||||
GDK_DRAG_CONTEXT
|
||||
GDK_TYPE_DRAG_CONTEXT
|
||||
GDK_IS_DRAG_CONTEXT
|
||||
GDK_DRAG_CONTEXT_CLASS
|
||||
GDK_DRAG_CONTEXT_GET_CLASS
|
||||
GDK_IS_DRAG_CONTEXT_CLASS
|
||||
GDK_TYPE_DRAG_ACTION
|
||||
GDK_TYPE_DRAG_PROTOCOL
|
||||
GDK_TYPE_DROP
|
||||
GDK_DROP
|
||||
GDK_IS_DROP
|
||||
|
||||
<SUBSECTION Private>
|
||||
GdkDragClass
|
||||
gdk_drag_get_type
|
||||
GdkDropClass
|
||||
gdk_drop_get_type
|
||||
GdkDragContextClass
|
||||
gdk_drag_context_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
@@ -868,6 +854,7 @@ gdk_x11_screen_lookup_visual
|
||||
gdk_x11_screen_supports_net_wm_hint
|
||||
gdk_x11_screen_get_number_of_desktops
|
||||
gdk_x11_screen_get_current_desktop
|
||||
gdk_x11_surface_foreign_new_for_display
|
||||
gdk_x11_surface_lookup_for_display
|
||||
gdk_x11_surface_get_xid
|
||||
gdk_x11_surface_set_theme_variant
|
||||
@@ -1264,7 +1251,6 @@ gdk_clipboard_get_type
|
||||
<SECTION>
|
||||
<FILE>gdkcontentprovider</FILE>
|
||||
GdkContentProvider
|
||||
GdkContentProviderClass
|
||||
gdk_content_provider_new_for_value
|
||||
gdk_content_provider_new_for_bytes
|
||||
gdk_content_provider_ref_formats
|
||||
@@ -1280,6 +1266,7 @@ GDK_CONTENT_PROVIDER_CLASS
|
||||
GDK_CONTENT_PROVIDER_GET_CLASS
|
||||
GDK_IS_CONTENT_PROVIDER
|
||||
GDK_IS_CONTENT_PROVIDER_CLASS
|
||||
GdkContentProviderClass
|
||||
gdk_content_provider_get_type
|
||||
</SECTION>
|
||||
|
||||
|
@@ -2,7 +2,6 @@ gdk_app_launch_context_get_type
|
||||
gdk_clipboard_get_type
|
||||
gdk_content_deserializer_get_type
|
||||
gdk_content_formats_get_type
|
||||
gdk_content_provider_get_type
|
||||
gdk_content_serializer_get_type
|
||||
gdk_cursor_get_type
|
||||
gdk_device_get_type
|
||||
@@ -10,8 +9,7 @@ gdk_device_pad_get_type
|
||||
gdk_device_tool_get_type
|
||||
gdk_display_get_type
|
||||
gdk_display_manager_get_type
|
||||
gdk_drag_get_type
|
||||
gdk_drop_get_type
|
||||
gdk_drag_context_get_type
|
||||
gdk_event_get_type
|
||||
gdk_frame_clock_get_type
|
||||
gdk_gl_context_get_type
|
||||
|
@@ -33,16 +33,14 @@ private_headers = [
|
||||
'gdktextureprivate.h',
|
||||
'gdkvulkancontextprivate.h',
|
||||
'keyname-table.h',
|
||||
'gdkprivate-x11.h',
|
||||
'x11/gdkprivate-x11.h',
|
||||
'x11/gdkeventsource.h',
|
||||
'gtk-primary-selection-client-protocol.h',
|
||||
'gtk-shell-client-protocol.h',
|
||||
'keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h',
|
||||
'pointer-gestures-unstable-v1-client-protocol.h',
|
||||
'server-decoration-client-protocol.h',
|
||||
'tablet-unstable-v2-client-protocol.h',
|
||||
'xdg-foreign-unstable-v1-client-protocol.h',
|
||||
'xdg-shell-unstable-v6-client-protocol.h',
|
||||
'wayland/keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h',
|
||||
'wayland/pointer-gestures-unstable-v1-client-protocol.h',
|
||||
'wayland/server-decoration-client-protocol.h',
|
||||
'wayland/tablet-unstable-v2-client-protocol.h',
|
||||
'wayland/xdg-foreign-unstable-v1-client-protocol.h',
|
||||
'wayland/xdg-shell-unstable-v6-client-protocol.h',
|
||||
'win32',
|
||||
'quartz',
|
||||
'broadway',
|
||||
@@ -87,24 +85,19 @@ images = [
|
||||
'images/zoom_out_cursor.png',
|
||||
]
|
||||
|
||||
src_dir = [ gdkinc ]
|
||||
|
||||
if x11_enabled
|
||||
src_dir += [ gdkx11_inc ]
|
||||
endif
|
||||
|
||||
if wayland_enabled
|
||||
src_dir += [ gdkwayland_inc ]
|
||||
endif
|
||||
|
||||
configure_file(input: 'version.xml.in', output: 'version.xml', configuration: version_conf)
|
||||
|
||||
gnome.gtkdoc('gdk4',
|
||||
mode: 'none',
|
||||
main_xml: 'gdk4-docs.xml',
|
||||
src_dir: src_dir,
|
||||
src_dir: [
|
||||
join_paths(meson.source_root(), 'gdk'),
|
||||
join_paths(meson.source_root(), 'gdk', 'x11'),
|
||||
join_paths(meson.source_root(), 'gdk', 'wayland'),
|
||||
join_paths(meson.build_root(), 'gdk'),
|
||||
],
|
||||
dependencies: libgtk_dep,
|
||||
gobject_typesfile: join_paths(meson.current_source_dir(), 'gdk4.types'),
|
||||
gobject_typesfile: join_paths(meson.source_root(), 'docs/reference/gdk/gdk4.types'),
|
||||
scan_args: [
|
||||
'--ignore-decorators=_GDK_EXTERN|G_GNUC_WARN_UNUSED_RESULT',
|
||||
'--ignore-headers=' + ' '.join(private_headers),
|
||||
|
@@ -40,10 +40,11 @@ gnome.gtkdoc('gsk4',
|
||||
mode: 'none',
|
||||
main_xml: 'gsk4-docs.xml',
|
||||
src_dir: [
|
||||
gskinc,
|
||||
join_paths(meson.source_root(), 'gsk'),
|
||||
join_paths(meson.build_root(), 'gsk'),
|
||||
],
|
||||
dependencies: libgtk_dep,
|
||||
gobject_typesfile: join_paths(meson.current_source_dir(), 'gsk4.types'),
|
||||
gobject_typesfile: join_paths(meson.source_root(), 'docs/reference/gsk/gsk4.types'),
|
||||
scan_args: [
|
||||
'--ignore-decorators=_GDK_EXTERN',
|
||||
'--ignore-headers=' + ' '.join(private_headers),
|
||||
|
@@ -46,7 +46,7 @@ broadwayd :5
|
||||
Then point your web browser at <literal>http://127.0.0.1:8085</literal>.
|
||||
Start your applications like this:
|
||||
<programlisting>
|
||||
GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 gtk4-demo
|
||||
GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 gtk3-demo
|
||||
</programlisting>
|
||||
</para>
|
||||
|
||||
|
@@ -44,13 +44,13 @@
|
||||
|
||||
<informalexample>
|
||||
<para>Create a new file with the following content named <filename>example-0.c.</filename></para>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/window-default.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/window-default.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</informalexample>
|
||||
|
||||
<para>
|
||||
You can compile the program above with GCC using:
|
||||
<literallayout>
|
||||
<literal>gcc `pkg-config --cflags gtk+-4.0` -o example-0 example-0.c `pkg-config --libs gtk+-4.0`</literal>
|
||||
<literal>gcc `pkg-config --cflags gtk+-3.0` -o example-0 example-0.c `pkg-config --libs gtk+-3.0`</literal>
|
||||
</literallayout>
|
||||
</para>
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
here</ulink>.</para>
|
||||
|
||||
<para>Finally the window size is set using gtk_window_set_default_size and
|
||||
the window is then shown by GTK via gtk_widget_show().</para>
|
||||
the window is then shown by GTK via gtk_widget_show_all().</para>
|
||||
|
||||
<para>When you exit the window, by for example pressing the X,
|
||||
the g_application_run() in the main loop returns with a number
|
||||
@@ -153,14 +153,14 @@
|
||||
<example id="gtk-getting-started-hello-world">
|
||||
<title>Hello World in GTK+</title>
|
||||
<para>Create a new file with the following content named example-1.c.</para>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/hello-world.c" parse="text">
|
||||
<programlisting><xi:include href="../../../../examples/hello-world.c" parse="text">
|
||||
<xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
You can compile the program above with GCC using:
|
||||
<literallayout>
|
||||
<literal>gcc `pkg-config --cflags gtk+-4.0` -o example-1 example-1.c `pkg-config --libs gtk+-4.0`</literal>
|
||||
<literal>gcc `pkg-config --cflags gtk+-3.0` -o example-1 example-1.c `pkg-config --libs gtk+-3.0`</literal>
|
||||
</literallayout>
|
||||
</para>
|
||||
</section>
|
||||
@@ -233,12 +233,12 @@
|
||||
<example id="gtk-getting-started-grid-packing">
|
||||
<title>Packing buttons</title>
|
||||
<para>Create a new file with the following content named example-2.c.</para>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/grid-packing.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/grid-packing.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</example>
|
||||
<para>
|
||||
You can compile the program above with GCC using:
|
||||
<literallayout>
|
||||
<literal>gcc `pkg-config --cflags gtk+-4.0` -o example-2 example-2.c `pkg-config --libs gtk+-4.0`</literal>
|
||||
<literal>gcc `pkg-config --cflags gtk+-3.0` -o example-2 example-2.c `pkg-config --libs gtk+-3.0`</literal>
|
||||
</literallayout>
|
||||
</para>
|
||||
</section>
|
||||
@@ -257,14 +257,14 @@
|
||||
<example>
|
||||
<title>Packing buttons with GtkBuilder</title>
|
||||
<para>Create a new file with the following content named example-3.c.</para>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/builder.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/builder.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<para>Create a new file with the following content named builder.ui.</para>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/builder.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/builder.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</example>
|
||||
<para>
|
||||
You can compile the program above with GCC using:
|
||||
<literallayout>
|
||||
<literal>gcc `pkg-config --cflags gtk+-4.0` -o example-3 example-3.c `pkg-config --libs gtk+-4.0`</literal>
|
||||
<literal>gcc `pkg-config --cflags gtk+-3.0` -o example-3 example-3.c `pkg-config --libs gtk+-3.0`</literal>
|
||||
</literallayout>
|
||||
</para>
|
||||
|
||||
@@ -346,7 +346,7 @@
|
||||
of our application class.</para>
|
||||
|
||||
<informalexample>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/application1/main.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/application1/main.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</informalexample>
|
||||
|
||||
<para>All the application logic is in the application class, which
|
||||
@@ -364,7 +364,7 @@
|
||||
GIO <ulink url="https://developer.gnome.org/gio/2.36/GApplication.html#GApplication.description">documentation</ulink>.</para>
|
||||
|
||||
<informalexample>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/application1/exampleapp.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/application1/exampleapp.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</informalexample>
|
||||
|
||||
<para>Another important class that is part of the application support
|
||||
@@ -373,7 +373,7 @@
|
||||
window.</para>
|
||||
|
||||
<informalexample>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/application1/exampleappwin.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/application1/exampleappwin.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</informalexample>
|
||||
|
||||
<para>As part of the initial setup of our application, we also
|
||||
@@ -388,7 +388,7 @@
|
||||
</informalfigure>
|
||||
|
||||
<informalexample>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/application1/org.gtk.exampleapp.desktop" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/application1/exampleapp.desktop" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</informalexample>
|
||||
|
||||
<para>Note that <replaceable>@<!-- -->bindir@</replaceable> needs to be replaced
|
||||
@@ -420,7 +420,7 @@
|
||||
</para>
|
||||
|
||||
<informalexample>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/application2/window.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/application2/window.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</informalexample>
|
||||
|
||||
<para>To make use of this file in our application, we revisit
|
||||
@@ -460,7 +460,7 @@ example_app_window_class_init (ExampleAppWindowClass *class)
|
||||
</para>
|
||||
|
||||
<informalexample>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/application2/exampleapp.gresource.xml" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/application2/exampleapp.gresource.xml" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</informalexample>
|
||||
|
||||
<para>This file has to be converted into a C source file that will be
|
||||
@@ -488,28 +488,23 @@ example_app_window_class_init (ExampleAppWindowClass *class)
|
||||
<para>In this step, we make our application show the content of
|
||||
all the files that it is given on the commandline.</para>
|
||||
|
||||
<para>To this end, we add a member to the struct in application
|
||||
<para>To this end, we add a private struct to our application
|
||||
window subclass and keep a reference to the #GtkStack there.
|
||||
The first member of the struct should be the parent type from
|
||||
which the class is derived. Here, ExampleAppWindow is derived
|
||||
from GtkApplicationWindow.
|
||||
The gtk_widget_class_bind_template_child() function
|
||||
The gtk_widget_class_bind_template_child_private() function
|
||||
arranges things so that after instantiating the template, the
|
||||
@stack member of the struct will point to the widget of
|
||||
@stack member of the private struct will point to the widget of
|
||||
the same name from the template.</para>
|
||||
|
||||
<informalexample>
|
||||
<programlisting><![CDATA[
|
||||
...
|
||||
|
||||
struct _ExampleAppWindow
|
||||
struct _ExampleAppWindowPrivate
|
||||
{
|
||||
GtkApplicationWindow parent;
|
||||
|
||||
GtkWidget *stack;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
|
||||
|
||||
...
|
||||
|
||||
@@ -518,7 +513,7 @@ example_app_window_class_init (ExampleAppWindowClass *class)
|
||||
{
|
||||
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
|
||||
"/org/gtk/exampleapp/window.ui");
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
}
|
||||
|
||||
...
|
||||
@@ -538,21 +533,25 @@ void
|
||||
example_app_window_open (ExampleAppWindow *win,
|
||||
GFile *file)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
gchar *basename;
|
||||
GtkWidget *scrolled, *view;
|
||||
gchar *contents;
|
||||
gsize length;
|
||||
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
basename = g_file_get_basename (file);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_show (scrolled);
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_widget_show (view);
|
||||
gtk_container_add (GTK_CONTAINER (scrolled), view);
|
||||
gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
|
||||
gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
|
||||
|
||||
if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL))
|
||||
{
|
||||
@@ -599,7 +598,7 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
in a ui file, and add it as a resource to our binary.</para>
|
||||
|
||||
<informalexample>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/application4/app-menu.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/application4/app-menu.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</informalexample>
|
||||
|
||||
<para>To associate the app menu with the application, we have to call
|
||||
@@ -698,7 +697,7 @@ example_app_class_init (ExampleAppClass *class)
|
||||
GSettings requires a schema that describes our settings:</para>
|
||||
|
||||
<informalexample>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/application5/org.gtk.exampleapp.gschema.xml" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/application5/org.gtk.exampleapp.gschema.xml" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</informalexample>
|
||||
|
||||
<para>Before we can make use of this schema in our application,
|
||||
@@ -719,11 +718,14 @@ example_app_class_init (ExampleAppClass *class)
|
||||
static void
|
||||
example_app_window_init (ExampleAppWindow *win)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (win));
|
||||
win->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
ExampleAppWindowPrivate *priv;
|
||||
|
||||
g_settings_bind (win->settings, "transition",
|
||||
win->stack, "transition-type",
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
gtk_widget_init_template (GTK_WIDGET (win));
|
||||
priv->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
|
||||
g_settings_bind (priv->settings, "transition",
|
||||
priv->stack, "transition-type",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
}
|
||||
|
||||
@@ -747,13 +749,13 @@ example_app_window_init (ExampleAppWindow *win)
|
||||
<para>Lets start with the template.</para>
|
||||
|
||||
<informalexample>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/application6/prefs.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/application6/prefs.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</informalexample>
|
||||
|
||||
<para>Next comes the dialog subclass.</para>
|
||||
|
||||
<informalexample>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/application6/exampleappprefs.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/application6/exampleappprefs.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</informalexample>
|
||||
|
||||
<para>Now we revisit the <literal>preferences_activated(<!-- -->)</literal> function in our
|
||||
@@ -805,7 +807,7 @@ preferences_activated (GSimpleAction *action,
|
||||
to slide out the search bar below the header bar.</para>
|
||||
|
||||
<informalexample>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/application7/window.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/application7/window.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</informalexample>
|
||||
|
||||
<para>Implementing the search needs quite a few code changes that
|
||||
@@ -821,6 +823,7 @@ static void
|
||||
search_text_changed (GtkEntry *entry,
|
||||
ExampleAppWindow *win)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
const gchar *text;
|
||||
GtkWidget *tab;
|
||||
GtkWidget *view;
|
||||
@@ -832,7 +835,9 @@ search_text_changed (GtkEntry *entry,
|
||||
if (text[0] == '\0')
|
||||
return;
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
|
||||
view = gtk_bin_get_child (GTK_BIN (tab));
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
@@ -882,7 +887,7 @@ example_app_window_init (ExampleAppWindow *win)
|
||||
which demonstrates #GtkMenuButton, #GtkRevealer and #GtkListBox.</para>
|
||||
|
||||
<informalexample>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/application8/window.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/application8/window.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</informalexample>
|
||||
|
||||
<para>The code to populate the sidebar with buttons for the words
|
||||
@@ -893,7 +898,7 @@ example_app_window_init (ExampleAppWindow *win)
|
||||
ui file.</para>
|
||||
|
||||
<informalexample>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/application8/gears-menu.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/application8/gears-menu.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</informalexample>
|
||||
|
||||
<para>To connect the menuitem to the show-words setting, we use
|
||||
@@ -952,7 +957,7 @@ example_app_window_init (ExampleAppWindow *win)
|
||||
triggers the show-lines action:</para>
|
||||
|
||||
<informalexample>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/application9/gears-menu.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/application9/gears-menu.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</informalexample>
|
||||
|
||||
<para>To make this menu item do something, we create a property
|
||||
@@ -973,12 +978,12 @@ example_app_window_init (ExampleAppWindow *win)
|
||||
{
|
||||
...
|
||||
|
||||
action = (GAction*) g_property_action_new ("show-lines", win->lines, "visible");
|
||||
action = (GAction*) g_property_action_new ("show-lines", priv->lines, "visible");
|
||||
g_action_map_add_action (G_ACTION_MAP (win), action);
|
||||
g_object_unref (action);
|
||||
|
||||
g_object_bind_property (win->lines, "visible",
|
||||
win->lines_label, "visible",
|
||||
g_object_bind_property (priv->lines, "visible",
|
||||
priv->lines_label, "visible",
|
||||
G_BINDING_DEFAULT);
|
||||
}
|
||||
|
||||
@@ -1012,7 +1017,7 @@ example_app_window_init (ExampleAppWindow *win)
|
||||
be a direct child of the window, and set its type to be titlebar.</para>
|
||||
|
||||
<informalexample>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/application10/window.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/application10/window.ui" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</informalexample>
|
||||
|
||||
<para>A small extra bonus of using a header bar is that we get
|
||||
@@ -1068,12 +1073,12 @@ example_app_window_init (ExampleAppWindow *win)
|
||||
<example id="gtk-getting-started-drawing">
|
||||
<title>Drawing in response to input</title>
|
||||
<para>Create a new file with the following content named example-4.c.</para>
|
||||
<programlisting><xi:include href="@SRC_DIR@/examples/drawing.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
<programlisting><xi:include href="../../../../examples/drawing.c" parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
|
||||
</example>
|
||||
<para>
|
||||
You can compile the program above with GCC using:
|
||||
<literallayout>
|
||||
<literal>gcc `pkg-config --cflags gtk+-4.0` -o example-4 example-4.c `pkg-config --libs gtk+-4.0`</literal>
|
||||
<literal>gcc `pkg-config --cflags gtk+-3.0` -o example-4 example-4.c `pkg-config --libs gtk+-3.0`</literal>
|
||||
</literallayout>
|
||||
</para>
|
||||
</section>
|
@@ -52,7 +52,7 @@ gtk4-broadwayd :5
|
||||
Then point your web browser at <literal>http://127.0.0.1:8085</literal>.
|
||||
Start your applications like this:
|
||||
<programlisting>
|
||||
GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 gtk4-demo
|
||||
GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 gtk3-demo
|
||||
</programlisting>
|
||||
|
||||
You can add password protection for your session by creating a file in
|
||||
|
@@ -41,16 +41,6 @@
|
||||
<xi:include href="visual_index.xml" />
|
||||
</chapter>
|
||||
|
||||
<chapter id="Lists">
|
||||
<title>GListModel support</title>
|
||||
<xi:include href="xml/gtkfilterlistmodel.xml" />
|
||||
<xi:include href="xml/gtkflattenlistmodel.xml" />
|
||||
<xi:include href="xml/gtkmaplistmodel.xml" />
|
||||
<xi:include href="xml/gtkslicelistmodel.xml" />
|
||||
<xi:include href="xml/gtksortlistmodel.xml" />
|
||||
<xi:include href="xml/gtktreelistmodel.xml" />
|
||||
</chapter>
|
||||
|
||||
<chapter id="Application">
|
||||
<title>Application support</title>
|
||||
<xi:include href="xml/gtkapplication.xml" />
|
||||
@@ -83,7 +73,6 @@
|
||||
<xi:include href="xml/gtkrevealer.xml" />
|
||||
<xi:include href="xml/gtklistbox.xml" />
|
||||
<xi:include href="xml/gtkflowbox.xml" />
|
||||
<xi:include href="xml/gtklistview.xml" />
|
||||
<xi:include href="xml/gtkstack.xml" />
|
||||
<xi:include href="xml/gtkstackswitcher.xml" />
|
||||
<xi:include href="xml/gtkstacksidebar.xml" />
|
||||
@@ -104,7 +93,6 @@
|
||||
<title>Display Widgets</title>
|
||||
<xi:include href="xml/gtklabel.xml" />
|
||||
<xi:include href="xml/gtkimage.xml" />
|
||||
<xi:include href="xml/gtkpicture.xml" />
|
||||
<xi:include href="xml/gtkspinner.xml" />
|
||||
<xi:include href="xml/gtkinfobar.xml" />
|
||||
<xi:include href="xml/gtkprogressbar.xml" />
|
||||
@@ -311,8 +299,6 @@
|
||||
<chapter id="Gestures">
|
||||
<title>Gestures and event handling</title>
|
||||
<xi:include href="xml/gtkeventcontroller.xml" />
|
||||
<xi:include href="xml/gtkeventcontrollerkey.xml" />
|
||||
<xi:include href="xml/gtkeventcontrollerlegacy.xml" />
|
||||
<xi:include href="xml/gtkeventcontrollerscroll.xml" />
|
||||
<xi:include href="xml/gtkeventcontrollermotion.xml" />
|
||||
<xi:include href="xml/gtkgesture.xml" />
|
||||
@@ -397,6 +383,7 @@
|
||||
<xi:include href="osx.sgml" />
|
||||
<xi:include href="broadway.xml" />
|
||||
<xi:include href="wayland.xml" />
|
||||
<xi:include href="mir.xml" />
|
||||
</part>
|
||||
|
||||
<xi:include href="glossary.xml" />
|
||||
|
@@ -442,68 +442,6 @@ gtk_list_box_get_type
|
||||
gtk_list_box_row_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkselectionmodel</FILE>
|
||||
<TITLE>GtkSelectionModel</TITLE>
|
||||
GtkSelectionModel
|
||||
gtk_selection_model_is_selected
|
||||
gtk_selection_model_select_item
|
||||
gtk_selection_model_unselect_item
|
||||
gtk_selection_model_select_range
|
||||
gtk_selection_model_unselect_range
|
||||
gtk_selection_model_select_all
|
||||
gtk_selection_model_unselect_all
|
||||
<SUBSECTION>
|
||||
gtk_selection_model_selection_changed
|
||||
<SUBSECTION Standard>
|
||||
GTK_SELECTION_MODEL
|
||||
GTK_SELECTION_MODEL_CLASS
|
||||
GTK_SELECTION_MODEL_GET_CLASS
|
||||
GTK_IS_SELECTION_MODEL
|
||||
GTK_IS_SELECTION_MODEL_CLASS
|
||||
GTK_TYPE_SELECTION_MODEL
|
||||
<SUBSECTION Private>
|
||||
gtk_selection_model_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtklistitem</FILE>
|
||||
<TITLE>GtkListItem</TITLE>
|
||||
GtkListItem
|
||||
gtk_list_item_get_item
|
||||
gtk_list_item_get_position
|
||||
gtk_list_item_get_selected
|
||||
gtk_list_item_get_selectable
|
||||
gtk_list_item_set_selectable
|
||||
<SUBSECTION Standard>
|
||||
GTK_LIST_ITEM
|
||||
GTK_LIST_ITEM_CLASS
|
||||
GTK_LIST_ITEM_GET_CLASS
|
||||
GTK_IS_LIST_ITEM
|
||||
GTK_IS_LIST_ITEM_CLASS
|
||||
GTK_TYPE_LIST_ITEM
|
||||
<SUBSECTION Private>
|
||||
gtk_list_item_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtklistview</FILE>
|
||||
<TITLE>GtkListView</TITLE>
|
||||
GtkListView
|
||||
gtk_list_view_new
|
||||
gtk_list_view_set_model
|
||||
gtk_list_view_get_model
|
||||
<SUBSECTION Standard>
|
||||
GTK_LIST_VIEW
|
||||
GTK_LIST_VIEW_CLASS
|
||||
GTK_LIST_VIEW_GET_CLASS
|
||||
GTK_IS_LIST_VIEW
|
||||
GTK_IS_LIST_VIEW_CLASS
|
||||
GTK_TYPE_LIST_VIEW
|
||||
<SUBSECTION Private>
|
||||
gtk_list_view_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkbuildable</FILE>
|
||||
GtkBuildable
|
||||
@@ -741,6 +679,8 @@ gtk_combo_box_get_active_id
|
||||
gtk_combo_box_set_active_id
|
||||
gtk_combo_box_get_model
|
||||
gtk_combo_box_set_model
|
||||
gtk_combo_box_popup_for_device
|
||||
gtk_combo_box_popup
|
||||
gtk_combo_box_popdown
|
||||
gtk_combo_box_get_popup_accessible
|
||||
gtk_combo_box_get_row_separator_func
|
||||
@@ -820,6 +760,9 @@ gtk_container_child_set_valist
|
||||
gtk_container_child_notify
|
||||
gtk_container_child_notify_by_pspec
|
||||
gtk_container_forall
|
||||
gtk_container_get_focus_chain
|
||||
gtk_container_set_focus_chain
|
||||
gtk_container_unset_focus_chain
|
||||
gtk_container_class_find_child_property
|
||||
gtk_container_class_install_child_property
|
||||
gtk_container_class_install_child_properties
|
||||
@@ -1301,26 +1244,6 @@ GTK_TYPE_FILE_FILTER
|
||||
gtk_file_filter_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkfilterlistmodel</FILE>
|
||||
<TITLE>GtkFilterListModel</TITLE>
|
||||
GtkFilterListModel
|
||||
gtk_filter_list_model_new
|
||||
gtk_filter_list_model_get_model
|
||||
gtk_filter_list_model_set_filter_func
|
||||
gtk_filter_list_model_has_filter
|
||||
gtk_filter_list_model_refilter
|
||||
<SUBSECTION Standard>
|
||||
GTK_FILTER_LIST_MODEL
|
||||
GTK_IS_FILTER_LIST_MODEL
|
||||
GTK_TYPE_FILTER_LIST_MODEL
|
||||
GTK_FILTER_LIST_MODEL_CLASS
|
||||
GTK_IS_FILTER_LIST_MODEL_CLASS
|
||||
GTK_FILTER_LIST_MODEL_GET_CLASS
|
||||
<SUBSECTION Private>
|
||||
gtk_filter_list_model_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkfixed</FILE>
|
||||
<TITLE>GtkFixed</TITLE>
|
||||
@@ -1341,24 +1264,6 @@ GtkFixedChild
|
||||
gtk_fixed_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkflattenlistmodel</FILE>
|
||||
<TITLE>GtkFlattenListModel</TITLE>
|
||||
GtkFlattenListModel
|
||||
gtk_flatten_list_model_new
|
||||
gtk_flatten_list_model_set_model
|
||||
gtk_flatten_list_model_get_model
|
||||
<SUBSECTION Standard>
|
||||
GTK_FLATTEN_LIST_MODEL
|
||||
GTK_IS_FLATTEN_LIST_MODEL
|
||||
GTK_TYPE_FLATTEN_LIST_MODEL
|
||||
GTK_FLATTEN_LIST_MODEL_CLASS
|
||||
GTK_IS_FLATTEN_LIST_MODEL_CLASS
|
||||
GTK_FLATTEN_LIST_MODEL_GET_CLASS
|
||||
<SUBSECTION Private>
|
||||
gtk_flatten_list_model_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkfontbutton</FILE>
|
||||
<TITLE>GtkFontButton</TITLE>
|
||||
@@ -1598,6 +1503,10 @@ gtk_image_set_pixel_size
|
||||
gtk_image_get_pixel_size
|
||||
gtk_image_set_icon_size
|
||||
gtk_image_get_icon_size
|
||||
gtk_image_set_keep_aspect_ratio
|
||||
gtk_image_get_keep_aspect_ratio
|
||||
gtk_image_set_can_shrink
|
||||
gtk_image_get_can_shrink
|
||||
<SUBSECTION Standard>
|
||||
GTK_IMAGE
|
||||
GTK_IS_IMAGE
|
||||
@@ -1806,27 +1715,6 @@ GtkLinkButtonPrivate
|
||||
gtk_link_button_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkmaplistmodel</FILE>
|
||||
<TITLE>GtkMapListModel</TITLE>
|
||||
GtkMapListModel
|
||||
GtkMapListModelMapFunc
|
||||
gtk_map_list_model_new
|
||||
gtk_map_list_model_set_map_func
|
||||
gtk_map_list_model_set_model
|
||||
gtk_map_list_model_get_model
|
||||
gtk_map_list_model_has_map
|
||||
<SUBSECTION Standard>
|
||||
GTK_MAP_LIST_MODEL
|
||||
GTK_IS_MAP_LIST_MODEL
|
||||
GTK_TYPE_MAP_LIST_MODEL
|
||||
GTK_MAP_LIST_MODEL_CLASS
|
||||
GTK_IS_MAP_LIST_MODEL_CLASS
|
||||
GTK_MAP_LIST_MODEL_GET_CLASS
|
||||
<SUBSECTION Private>
|
||||
gtk_map_list_model_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkmenu</FILE>
|
||||
<TITLE>GtkMenu</TITLE>
|
||||
@@ -1840,6 +1728,8 @@ gtk_menu_attach
|
||||
gtk_menu_popup_at_rect
|
||||
gtk_menu_popup_at_widget
|
||||
gtk_menu_popup_at_pointer
|
||||
gtk_menu_popup_for_device
|
||||
gtk_menu_popup
|
||||
gtk_menu_set_accel_group
|
||||
gtk_menu_get_accel_group
|
||||
gtk_menu_set_accel_path
|
||||
@@ -2159,40 +2049,6 @@ GtkPanedPrivate
|
||||
gtk_paned_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkpicture</FILE>
|
||||
<TITLE>GtkPicture</TITLE>
|
||||
GtkPicture
|
||||
gtk_picture_new
|
||||
gtk_picture_new_for_paintable
|
||||
gtk_picture_new_for_pixbuf
|
||||
gtk_picture_new_for_file
|
||||
gtk_picture_new_for_filename
|
||||
gtk_picture_new_for_resource
|
||||
gtk_picture_set_paintable
|
||||
gtk_picture_get_paintable
|
||||
gtk_picture_set_pixbuf
|
||||
gtk_picture_set_file
|
||||
gtk_picture_get_file
|
||||
gtk_picture_set_filename
|
||||
gtk_picture_set_resource
|
||||
gtk_picture_set_keep_aspect_ratio
|
||||
gtk_picture_get_keep_aspect_ratio
|
||||
gtk_picture_set_can_shrink
|
||||
gtk_picture_get_can_shrink
|
||||
gtk_picture_set_alternative_text
|
||||
gtk_picture_get_alternative_text
|
||||
<SUBSECTION Standard>
|
||||
GTK_PICTURE
|
||||
GTK_IS_PICTURE
|
||||
GTK_TYPE_PICTURE
|
||||
GTK_PICTURE_CLASS
|
||||
GTK_IS_PICTURE_CLASS
|
||||
GTK_PICTURE_GET_CLASS
|
||||
<SUBSECTION Private>
|
||||
gtk_picture_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkprogressbar</FILE>
|
||||
<TITLE>GtkProgressBar</TITLE>
|
||||
@@ -2655,51 +2511,6 @@ GtkSizeGroupPrivate
|
||||
gtk_size_group_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkslicelistmodel</FILE>
|
||||
<TITLE>GtkSliceListModel</TITLE>
|
||||
GtkSliceListModel
|
||||
gtk_slice_list_model_new
|
||||
gtk_slice_list_model_new_for_type
|
||||
gtk_slice_list_model_set_model
|
||||
gtk_slice_list_model_get_model
|
||||
gtk_slice_list_model_set_offset
|
||||
gtk_slice_list_model_get_offset
|
||||
gtk_slice_list_model_set_size
|
||||
gtk_slice_list_model_get_size
|
||||
<SUBSECTION Standard>
|
||||
GTK_SLICE_LIST_MODEL
|
||||
GTK_IS_SLICE_LIST_MODEL
|
||||
GTK_TYPE_SLICE_LIST_MODEL
|
||||
GTK_SLICE_LIST_MODEL_CLASS
|
||||
GTK_IS_SLICE_LIST_MODEL_CLASS
|
||||
GTK_SLICE_LIST_MODEL_GET_CLASS
|
||||
<SUBSECTION Private>
|
||||
gtk_slice_list_model_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtksortlistmodel</FILE>
|
||||
<TITLE>GtkSortListModel</TITLE>
|
||||
GtkSortListModel
|
||||
gtk_sort_list_model_new
|
||||
gtk_sort_list_model_new_for_type
|
||||
gtk_sort_list_model_set_sort_func
|
||||
gtk_sort_list_model_has_sort
|
||||
gtk_sort_list_model_set_model
|
||||
gtk_sort_list_model_get_model
|
||||
gtk_sort_list_model_resort
|
||||
<SUBSECTION Standard>
|
||||
GTK_SORT_LIST_MODEL
|
||||
GTK_IS_SORT_LIST_MODEL
|
||||
GTK_TYPE_SORT_LIST_MODEL
|
||||
GTK_SORT_LIST_MODEL_CLASS
|
||||
GTK_IS_SORT_LIST_MODEL_CLASS
|
||||
GTK_SORT_LIST_MODEL_GET_CLASS
|
||||
<SUBSECTION Private>
|
||||
gtk_sort_list_model_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkspinbutton</FILE>
|
||||
<TITLE>GtkSpinButton</TITLE>
|
||||
@@ -3434,49 +3245,6 @@ GTK_TOOLTIP
|
||||
gtk_tooltip_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtktreelistmodel</FILE>
|
||||
<TITLE>GtkTreeListModel</TITLE>
|
||||
GtkTreeListModel
|
||||
GtkTreeListRow
|
||||
GtkTreeListModelCreateModelFunc
|
||||
gtk_tree_list_model_new
|
||||
gtk_tree_list_model_get_model
|
||||
gtk_tree_list_model_get_passthrough
|
||||
gtk_tree_list_model_set_autoexpand
|
||||
gtk_tree_list_model_get_autoexpand
|
||||
gtk_tree_list_model_get_child_row
|
||||
gtk_tree_list_model_get_row
|
||||
|
||||
<SUBSECTION>
|
||||
gtk_tree_list_row_get_item
|
||||
gtk_tree_list_row_set_expanded
|
||||
gtk_tree_list_row_get_expanded
|
||||
gtk_tree_list_row_is_expandable
|
||||
gtk_tree_list_row_get_position
|
||||
gtk_tree_list_row_get_depth
|
||||
gtk_tree_list_row_get_children
|
||||
gtk_tree_list_row_get_parent
|
||||
gtk_tree_list_row_get_child_row
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TREE_LIST_MODEL
|
||||
GTK_IS_TREE_LIST_MODEL
|
||||
GTK_TYPE_TREE_LIST_MODEL
|
||||
GTK_TREE_LIST_MODEL_CLASS
|
||||
GTK_IS_TREE_LIST_MODEL_CLASS
|
||||
GTK_TREE_LIST_MODEL_GET_CLASS
|
||||
GTK_TREE_LIST_ROW
|
||||
GTK_IS_TREE_LIST_ROW
|
||||
GTK_TYPE_TREE_LIST_ROW
|
||||
GTK_TREE_LIST_ROW_CLASS
|
||||
GTK_IS_TREE_LIST_ROW_CLASS
|
||||
GTK_TREE_LIST_ROW_GET_CLASS
|
||||
<SUBSECTION Private>
|
||||
gtk_tree_list_model_get_type
|
||||
gtk_tree_list_row_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtktreemodel</FILE>
|
||||
<TITLE>GtkTreeModel</TITLE>
|
||||
@@ -4483,6 +4251,7 @@ gtk_widget_list_accel_closures
|
||||
gtk_widget_can_activate_accel
|
||||
gtk_widget_event
|
||||
gtk_widget_activate
|
||||
gtk_widget_intersect
|
||||
gtk_widget_is_focus
|
||||
gtk_widget_grab_focus
|
||||
gtk_widget_grab_default
|
||||
@@ -4565,7 +4334,6 @@ gtk_widget_get_can_focus
|
||||
gtk_widget_set_can_focus
|
||||
gtk_widget_get_focus_on_click
|
||||
gtk_widget_set_focus_on_click
|
||||
gtk_widget_set_focus_child
|
||||
gtk_widget_get_has_surface
|
||||
gtk_widget_set_has_surface
|
||||
gtk_widget_get_sensitive
|
||||
@@ -4665,10 +4433,6 @@ gtk_widget_class_bind_template_callback
|
||||
gtk_widget_class_bind_template_callback_full
|
||||
gtk_widget_class_set_connect_func
|
||||
|
||||
<SUBSECTION>
|
||||
gtk_widget_observe_children
|
||||
gtk_widget_observe_controllers
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_WIDGET
|
||||
GTK_IS_WIDGET
|
||||
@@ -4712,7 +4476,6 @@ gtk_window_set_destroy_with_parent
|
||||
gtk_window_set_display
|
||||
gtk_window_is_active
|
||||
gtk_window_is_maximized
|
||||
gtk_window_get_toplevels
|
||||
gtk_window_list_toplevels
|
||||
gtk_window_add_mnemonic
|
||||
gtk_window_remove_mnemonic
|
||||
@@ -5071,6 +4834,7 @@ gtk_style_context_get_parent
|
||||
gtk_style_context_get_path
|
||||
gtk_style_context_get_property
|
||||
gtk_style_context_get_display
|
||||
gtk_style_context_get_frame_clock
|
||||
gtk_style_context_get_state
|
||||
gtk_style_context_get_valist
|
||||
gtk_style_context_get_section
|
||||
@@ -5093,6 +4857,7 @@ gtk_style_context_remove_class
|
||||
gtk_style_context_has_class
|
||||
gtk_style_context_list_classes
|
||||
gtk_style_context_set_display
|
||||
gtk_style_context_set_frame_clock
|
||||
gtk_style_context_set_state
|
||||
gtk_style_context_set_scale
|
||||
gtk_style_context_get_scale
|
||||
@@ -5113,10 +4878,12 @@ gtk_render_check
|
||||
gtk_render_expander
|
||||
gtk_render_focus
|
||||
gtk_render_frame
|
||||
gtk_render_frame_gap
|
||||
gtk_render_handle
|
||||
gtk_render_layout
|
||||
gtk_render_line
|
||||
gtk_render_option
|
||||
gtk_render_slider
|
||||
gtk_render_activity
|
||||
gtk_render_icon
|
||||
gtk_render_insertion_cursor
|
||||
@@ -5140,6 +4907,7 @@ gtk_border_get_type
|
||||
<FILE>gtkcssprovider</FILE>
|
||||
<TITLE>GtkCssProvider</TITLE>
|
||||
GtkCssProvider
|
||||
gtk_css_provider_get_default
|
||||
gtk_css_provider_get_named
|
||||
gtk_css_provider_load_from_data
|
||||
gtk_css_provider_load_from_file
|
||||
@@ -5216,7 +4984,6 @@ gtk_selection_data_get_type
|
||||
<TITLE>Drag and Drop</TITLE>
|
||||
GtkDestDefaults
|
||||
GtkDragResult
|
||||
|
||||
<SUBSECTION Destination Side>
|
||||
gtk_drag_dest_set
|
||||
gtk_drag_dest_unset
|
||||
@@ -5228,13 +4995,13 @@ gtk_drag_dest_add_image_targets
|
||||
gtk_drag_dest_add_uri_targets
|
||||
gtk_drag_dest_set_track_motion
|
||||
gtk_drag_dest_get_track_motion
|
||||
gtk_drag_finish
|
||||
gtk_drag_get_data
|
||||
gtk_drag_get_source_widget
|
||||
gtk_drag_highlight
|
||||
gtk_drag_unhighlight
|
||||
|
||||
<SUBSECTION Source Side>
|
||||
gtk_drag_begin
|
||||
gtk_drag_begin_with_coordinates
|
||||
gtk_drag_cancel
|
||||
gtk_drag_set_icon_widget
|
||||
gtk_drag_set_icon_paintable
|
||||
@@ -6219,8 +5986,6 @@ gtk_overlay_get_overlay_pass_through
|
||||
gtk_overlay_set_overlay_pass_through
|
||||
gtk_overlay_get_measure_overlay
|
||||
gtk_overlay_set_measure_overlay
|
||||
gtk_overlay_get_clip_overlay
|
||||
gtk_overlay_set_clip_overlay
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_OVERLAY
|
||||
@@ -6666,27 +6431,9 @@ GTK_GESTURE_SINGLE_GET_CLASS
|
||||
gtk_gesture_single_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkeventcontrollerlegacy</FILE>
|
||||
<TITLE>GtkEventControllerlegacy</TITLE>
|
||||
GtkEventControllerlegacy
|
||||
gtk_event_controller_legacy_new
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_EVENT_CONTROLLER_LEGACY
|
||||
GTK_EVENT_CONTROLLER_LEGACY
|
||||
GTK_EVENT_CONTROLLER_LEGACY_CLASS
|
||||
GTK_IS_EVENT_CONTROLLER_LEGACY
|
||||
GTK_IS_EVENT_CONTROLLER_LEGACY_CLASS
|
||||
GTK_EVENT_CONTROLLER_LEGACY_GET_CLASS
|
||||
|
||||
<SUBSECTION Private>
|
||||
gtk_event_controller_legacy_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkeventcontrollerscroll</FILE>
|
||||
<TITLE>GtkEventControllerScroll</TITLE>
|
||||
<TITLE>GtkEventControlerScroll</TITLE>
|
||||
GtkEventControllerScroll
|
||||
GtkEventControllerScrollFlags
|
||||
gtk_event_controller_scroll_new
|
||||
@@ -6707,7 +6454,7 @@ gtk_event_controller_scroll_get_type
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkeventcontrollermotion</FILE>
|
||||
<TITLE>GtkEventControllerMotion</TITLE>
|
||||
<TITLE>GtkEventControlerMotion</TITLE>
|
||||
GtkEventControllerMotion
|
||||
gtk_event_controller_motion_new
|
||||
|
||||
@@ -6723,24 +6470,6 @@ GTK_EVENT_CONTROLLER_MOTION_GET_CLASS
|
||||
gtk_event_controller_motion_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkeventcontrollerkey</FILE>
|
||||
<TITLE>GtkEventControllerKey</TITLE>
|
||||
GtkEventControllerKey
|
||||
gtk_event_controller_key_new
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_EVENT_CONTROLLER_KEY
|
||||
GTK_EVENT_CONTROLLER_KEY
|
||||
GTK_EVENT_CONTROLLER_KEY_CLASS
|
||||
GTK_IS_EVENT_CONTROLLER_KEY
|
||||
GTK_IS_EVENT_CONTROLLER_KEY_CLASS
|
||||
GTK_EVENT_CONTROLLER_KEY_GET_CLASS
|
||||
|
||||
<SUBSECTION Private>
|
||||
gtk_event_controller_key_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkgesturedrag</FILE>
|
||||
<TITLE>GtkGestureDrag</TITLE>
|
||||
|
@@ -54,7 +54,6 @@ gtk_entry_completion_get_type
|
||||
gtk_entry_get_type
|
||||
gtk_event_controller_get_type
|
||||
gtk_event_controller_key_get_type
|
||||
gtk_event_controller_legacy_get_type
|
||||
gtk_event_controller_motion_get_type
|
||||
gtk_event_controller_scroll_get_type
|
||||
gtk_expander_get_type
|
||||
@@ -119,7 +118,6 @@ gtk_page_setup_get_type
|
||||
@DISABLE_ON_W32@gtk_page_setup_unix_dialog_get_type
|
||||
gtk_paned_get_type
|
||||
gtk_paper_size_get_type
|
||||
gtk_picture_get_type
|
||||
gtk_popover_get_type
|
||||
gtk_popover_menu_get_type
|
||||
@DISABLE_ON_W32@gtk_printer_get_type
|
||||
|
@@ -179,6 +179,41 @@
|
||||
</para>
|
||||
</refsect2>
|
||||
|
||||
<refsect2 id="event-masks">
|
||||
<title>Event masks</title>
|
||||
|
||||
<para>
|
||||
Each widget instance has a basic event mask and another per input device,
|
||||
which determine the types of input event it receives. Each event mask set
|
||||
on a widget is added to the corresponding (basic or per-device) event mask
|
||||
for the widget’s #GdkSurface, and all child #GdkSurfaces.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Filtering events against event masks happens inside #GdkSurface, which
|
||||
exposes event masks to the windowing system to reduce the number of events
|
||||
GDK receives from it. On receiving an event, it is filtered against the
|
||||
#GdkSurface’s mask for the input device, if set. Otherwise, it is filtered
|
||||
against the #GdkSurface’s basic event mask.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
This means that widgets must add to the event mask for each event type
|
||||
they expect to receive, using gtk_widget_set_events() or
|
||||
gtk_widget_add_events() to preserve the existing mask. Widgets which are
|
||||
aware of floating devices should use gtk_widget_set_device_events() or
|
||||
gtk_widget_add_device_events(), and must explicitly enable the device
|
||||
using gtk_widget_set_device_enabled(). See the #GdkDeviceManager
|
||||
documentation for more information.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
All standard widgets set the event mask for all events they expect to
|
||||
receive, and it is not necessary to modify this. Masks should be set when
|
||||
implementing a new widget.
|
||||
</para>
|
||||
</refsect2>
|
||||
|
||||
<refsect2>
|
||||
<title>Touch events</title>
|
||||
|
||||
|
@@ -1,195 +1,4 @@
|
||||
private_headers = [
|
||||
'gdkpixbufutilsprivate.h',
|
||||
'gtkaccelgroupprivate.h',
|
||||
'gtkaccelmapprivate.h',
|
||||
'gtkactionhelperprivate.h',
|
||||
'gtkactionmuxerprivate.h',
|
||||
'gtkadjustmentprivate.h',
|
||||
'gtkallocatedbitmaskprivate.h',
|
||||
'gtkappchooserprivate.h',
|
||||
'gtkapplicationaccelsprivate.h',
|
||||
'gtkapplicationprivate.h',
|
||||
'gtkbindingsprivate.h',
|
||||
'gtkbitmaskprivate.h',
|
||||
'gtkboxprivate.h',
|
||||
'gtkbuilderprivate.h',
|
||||
'gtkbuttonprivate.h',
|
||||
'gtkcellareaboxcontextprivate.h',
|
||||
'gtkcheckbuttonprivate.h',
|
||||
'gtkcheckmenuitemprivate.h',
|
||||
'gtkcolorchooserprivate.h',
|
||||
'gtkcoloreditorprivate.h',
|
||||
'gtkcolorplaneprivate.h',
|
||||
'gtkcolorscaleprivate.h',
|
||||
'gtkcolorswatchprivate.h',
|
||||
'gtkcomboboxprivate.h',
|
||||
'gtkcontainerprivate.h',
|
||||
'gtkcssanimatedstyleprivate.h',
|
||||
'gtkcssanimationprivate.h',
|
||||
'gtkcssarrayvalueprivate.h',
|
||||
'gtkcssbgsizevalueprivate.h',
|
||||
'gtkcssbordervalueprivate.h',
|
||||
'gtkcsscalcvalueprivate.h',
|
||||
'gtkcsscolorvalueprivate.h',
|
||||
'gtkcsscornervalueprivate.h',
|
||||
'gtkcssdimensionvalueprivate.h',
|
||||
'gtkcssdynamicprivate.h',
|
||||
'gtkcsseasevalueprivate.h',
|
||||
'gtkcssenumvalueprivate.h',
|
||||
'gtkcssfiltervalueprivate.h',
|
||||
'gtkcssfontfeaturesvalueprivate.h',
|
||||
'gtkcssfontvariationsvalueprivate.h',
|
||||
'gtkcssiconthemevalueprivate.h',
|
||||
'gtkcssimagebuiltinprivate.h',
|
||||
'gtkcssimagecrossfadeprivate.h',
|
||||
'gtkcssimagefallbackprivate.h',
|
||||
'gtkcssimageiconthemeprivate.h',
|
||||
'gtkcssimageinvalidprivate.h',
|
||||
'gtkcssimagelinearprivate.h',
|
||||
'gtkcssimagepaintableprivate.h',
|
||||
'gtkcssimageprivate.h',
|
||||
'gtkcssimageradialprivate.h',
|
||||
'gtkcssimagerecolorprivate.h',
|
||||
'gtkcssimagescaledprivate.h',
|
||||
'gtkcssimageurlprivate.h',
|
||||
'gtkcssimagevalueprivate.h',
|
||||
'gtkcssimagewin32private.h',
|
||||
'gtkcssinheritvalueprivate.h',
|
||||
'gtkcssinitialvalueprivate.h',
|
||||
'gtkcsskeyframesprivate.h',
|
||||
'gtkcsslookupprivate.h',
|
||||
'gtkcssmatcherprivate.h',
|
||||
'gtkcssnodedeclarationprivate.h',
|
||||
'gtkcssnodeprivate.h',
|
||||
'gtkcssnodestylecacheprivate.h',
|
||||
'gtkcssnumbervalueprivate.h',
|
||||
'gtkcsspalettevalueprivate.h',
|
||||
'gtkcssparserprivate.h',
|
||||
'gtkcsspathnodeprivate.h',
|
||||
'gtkcsspositionvalueprivate.h',
|
||||
'gtkcssproviderprivate.h',
|
||||
'gtkcssrepeatvalueprivate.h',
|
||||
'gtkcssrgbavalueprivate.h',
|
||||
'gtkcsssectionprivate.h',
|
||||
'gtkcssselectorprivate.h',
|
||||
'gtkcssshadowsvalueprivate.h',
|
||||
'gtkcssshadowvalueprivate.h',
|
||||
'gtkcssshorthandpropertyprivate.h',
|
||||
'gtkcssstaticstyleprivate.h',
|
||||
'gtkcssstringvalueprivate.h',
|
||||
'gtkcssstylechangeprivate.h',
|
||||
'gtkcssstyleprivate.h',
|
||||
'gtkcssstylepropertyprivate.h',
|
||||
'gtkcsstransformvalueprivate.h',
|
||||
'gtkcsstransientnodeprivate.h',
|
||||
'gtkcsstransitionprivate.h',
|
||||
'gtkcsstypesprivate.h',
|
||||
'gtkcssunsetvalueprivate.h',
|
||||
'gtkcssvalueprivate.h',
|
||||
'gtkcsswidgetnodeprivate.h',
|
||||
'gtkcsswin32sizevalueprivate.h',
|
||||
'gtkdialogprivate.h',
|
||||
'gtkdndprivate.h',
|
||||
'gtkentryprivate.h',
|
||||
'gtkeventcontrollerlegacyprivate.h',
|
||||
'gtkeventcontrollerprivate.h',
|
||||
'gtkfilechoosererrorstackprivate.h',
|
||||
'gtkfilechoosernativeprivate.h',
|
||||
'gtkfilechooserprivate.h',
|
||||
'gtkfilechooserwidgetprivate.h',
|
||||
'gtkfilefilterprivate.h',
|
||||
'gtkfontchooserprivate.h',
|
||||
'gtkfontchooserwidgetprivate.h',
|
||||
'gtkgesturedragprivate.h',
|
||||
'gtkgesturelongpressprivate.h',
|
||||
'gtkgesturemultipressprivate.h',
|
||||
'gtkgesturepanprivate.h',
|
||||
'gtkgestureprivate.h',
|
||||
'gtkgesturerotateprivate.h',
|
||||
'gtkgesturesingleprivate.h',
|
||||
'gtkgesturestylusprivate.h',
|
||||
'gtkgestureswipeprivate.h',
|
||||
'gtkgesturezoomprivate.h',
|
||||
'gtkgizmoprivate.h',
|
||||
'gtkheaderbarprivate.h',
|
||||
'gtkhslaprivate.h',
|
||||
'gtkiconcacheprivate.h',
|
||||
'gtkiconcachevalidatorprivate.h',
|
||||
'gtkiconhelperprivate.h',
|
||||
'gtkiconprivate.h',
|
||||
'gtkiconthemeprivate.h',
|
||||
'gtkiconviewprivate.h',
|
||||
'gtkimagedefinitionprivate.h',
|
||||
'gtkimageprivate.h',
|
||||
'gtkimcontextsimpleprivate.h',
|
||||
'gtkimmoduleprivate.h',
|
||||
'gtkkineticscrollingprivate.h',
|
||||
'gtklabelprivate.h',
|
||||
'gtklockbuttonprivate.h',
|
||||
'gtkmagnifierprivate.h',
|
||||
'gtkmediafileprivate.h',
|
||||
'gtkmenubuttonprivate.h',
|
||||
'gtkmenuitemprivate.h',
|
||||
'gtkmenuprivate.h',
|
||||
'gtkmenushellprivate.h',
|
||||
'gtkmodulesprivate.h',
|
||||
'gtkmountoperationprivate.h',
|
||||
'gtknativedialogprivate.h',
|
||||
'gtknomediafileprivate.h',
|
||||
'gtkorientableprivate.h',
|
||||
'gtkplacessidebarprivate.h',
|
||||
'gtkplacesviewprivate.h',
|
||||
'gtkplacesviewrowprivate.h',
|
||||
'gtkpointerfocusprivate.h',
|
||||
'gtkpopoverprivate.h',
|
||||
'gtkprinter-private.h',
|
||||
'gtkprintoperation-private.h',
|
||||
'gtkprivate.h',
|
||||
'gtkprogresstrackerprivate.h',
|
||||
'gtkrangeprivate.h',
|
||||
'gtkrbtreeprivate.h',
|
||||
'gtkrenderbackgroundprivate.h',
|
||||
'gtkrenderborderprivate.h',
|
||||
'gtkrendericonprivate.h',
|
||||
'gtkrendernodepaintableprivate.h',
|
||||
'gtkroundedboxprivate.h',
|
||||
'gtkscalerprivate.h',
|
||||
'gtksearchentryprivate.h',
|
||||
'gtkselectionprivate.h',
|
||||
'gtksettingsprivate.h',
|
||||
'gtkshortcutsshortcutprivate.h',
|
||||
'gtkshortcutswindowprivate.h',
|
||||
'gtksidebarrowprivate.h',
|
||||
'gtksizegroup-private.h',
|
||||
'gtksizerequestcacheprivate.h',
|
||||
'gtksnapshotprivate.h',
|
||||
'gtkstyleanimationprivate.h',
|
||||
'gtkstylecascadeprivate.h',
|
||||
'gtkstylecontextprivate.h',
|
||||
'gtkstylepropertyprivate.h',
|
||||
'gtkstyleproviderprivate.h',
|
||||
'gtktextbufferprivate.h',
|
||||
'gtktextchildprivate.h',
|
||||
'gtktextdisplayprivate.h',
|
||||
'gtktexthandleprivate.h',
|
||||
'gtktextiterprivate.h',
|
||||
'gtktextlayoutprivate.h',
|
||||
'gtktextmarkprivate.h',
|
||||
'gtktexttagprivate.h',
|
||||
'gtktextviewprivate.h',
|
||||
'gtktogglebuttonprivate.h',
|
||||
'gtktoolbarprivate.h',
|
||||
'gtktooltipprivate.h',
|
||||
'gtktooltipwindowprivate.h',
|
||||
'gtktreeprivate.h',
|
||||
'gtkutilsprivate.h',
|
||||
'gtkwidgetpaintableprivate.h',
|
||||
'gtkwidgetpathprivate.h',
|
||||
'gtkwidgetprivate.h',
|
||||
'gtkwin32drawprivate.h',
|
||||
'gtkwin32themeprivate.h',
|
||||
'gtkwindowprivate.h',
|
||||
'gtk-text-input-client-protocol.h',
|
||||
]
|
||||
|
||||
images = [
|
||||
@@ -340,6 +149,7 @@ content_files = [
|
||||
'css-overview.xml',
|
||||
'css-properties.xml',
|
||||
'drawing-model.xml',
|
||||
'getting_started.xml',
|
||||
'glossary.xml',
|
||||
'gtk4-broadwayd.xml',
|
||||
'gtk4-builder-tool.xml',
|
||||
@@ -354,6 +164,7 @@ content_files = [
|
||||
'input-handling.xml',
|
||||
'migrating-2to4.xml',
|
||||
'migrating-3to4.xml',
|
||||
'mir.xml',
|
||||
'osx.sgml',
|
||||
'other_software.sgml',
|
||||
'overview.xml',
|
||||
@@ -371,6 +182,7 @@ content_files = [
|
||||
expand_content_files = [
|
||||
'compiling.sgml',
|
||||
'drawing-model.xml',
|
||||
'getting_started.xml',
|
||||
'glossary.xml',
|
||||
'input-handling.xml',
|
||||
'migrating-2to4.xml',
|
||||
@@ -381,7 +193,6 @@ expand_content_files = [
|
||||
]
|
||||
|
||||
configure_file(input: 'version.xml.in', output: 'version.xml', configuration: version_conf)
|
||||
configure_file(input: 'getting_started.xml.in', output: 'getting_started.xml', configuration: src_dir_conf)
|
||||
|
||||
types_conf = configuration_data()
|
||||
if os_win32
|
||||
@@ -396,18 +207,17 @@ else
|
||||
types_conf.set('DISABLE_ON_QUARTZ', '')
|
||||
endif
|
||||
|
||||
configure_file(input: 'gtk4.types.in', output: 'gtk4.types', configuration: types_conf)
|
||||
|
||||
gnome.gtkdoc('gtk4',
|
||||
mode: 'none',
|
||||
main_xml: 'gtk4-docs.xml',
|
||||
src_dir: [
|
||||
gtkinc,
|
||||
join_paths(meson.source_root(), 'gtk'),
|
||||
join_paths(meson.build_root(), 'gtk'),
|
||||
],
|
||||
dependencies: libgtk_dep,
|
||||
gobject_typesfile: configure_file(
|
||||
input: 'gtk4.types.in',
|
||||
output: 'gtk4.types',
|
||||
configuration: types_conf,
|
||||
),
|
||||
gobject_typesfile: 'gtk4.types',
|
||||
scan_args: [
|
||||
'--ignore-decorators=_GDK_EXTERN|G_GNUC_WARN_UNUSED_RESULT',
|
||||
'--ignore-headers=' + ' '.join(private_headers),
|
||||
|
@@ -20,11 +20,11 @@
|
||||
|
||||
<para>
|
||||
The steps outlined in the following sections assume that your
|
||||
application is working with GTK+ 3.24, which is the final stable
|
||||
application is working with GTK+ 3.22, which is the final stable
|
||||
release of GTK+ 3.x. It includes all the necessary APIs and tools
|
||||
to help you port your application to GTK+ 4. If you are still using
|
||||
an older version of GTK+ 3.x, you should first get your application
|
||||
to build and work with the latest minor release in the 3.24 series.
|
||||
to build and work with the latest minor release in the 3.22 series.
|
||||
</para>
|
||||
|
||||
<section>
|
||||
@@ -34,7 +34,7 @@
|
||||
widgets have been deprecated. These deprecations are clearly spelled
|
||||
out in the API reference, with hints about the recommended replacements.
|
||||
The API reference for GTK+ 3 also includes an
|
||||
<ulink url="https://developer.gnome.org/gtk3/3.24/api-index-deprecated.html">index</ulink> of all deprecated symbols.
|
||||
<ulink url="https://developer.gnome.org/gtk3/3.22/api-index-deprecated.html">index</ulink> of all deprecated symbols.
|
||||
</para>
|
||||
<para>
|
||||
To verify that your program does not use any deprecated symbols,
|
||||
@@ -79,13 +79,13 @@
|
||||
<title>Review your window creation flags</title>
|
||||
<para>
|
||||
GTK+ 4 removes the GDK_WA_CURSOR flag. Instead, just use
|
||||
gdk_window_set_cursor() to set a cursor on the window after
|
||||
gdk_surface_set_cursor() to set a cursor on the window after
|
||||
creating it.
|
||||
</para>
|
||||
<para>
|
||||
GTK+ 4 also removes the GDK_WA_VISUAL flag, and always uses
|
||||
an RGBA visual for windows. To prepare your code for this,
|
||||
use gdk_window_set_visual (gdk_screen_get_rgba_visual ()) after
|
||||
use gdk_surface_set_visual (gdk_screen_get_rgba_visual ()) after
|
||||
creating your window.
|
||||
</para>
|
||||
<para>
|
||||
@@ -169,30 +169,6 @@
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Stop using GtkWidget event signals</title>
|
||||
<para>
|
||||
Event controllers and #GtkGestures replace event signals in GTK+ 4. They
|
||||
have been backported to GTK+ 3.x so you can prepare for this change.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Set a proper app_id</title>
|
||||
<para>
|
||||
In GTK+4 we want the application's #GApplication
|
||||
'application-id' (and therefore the D-Bus name), the desktop
|
||||
file basename and Wayland's xdg-shell app_id to match. In
|
||||
order to achieve this with GTK+3 call g_set_prgname() with the same
|
||||
application id you passed to #GtkApplication. Rename your
|
||||
desktop files to match the application id if needed.
|
||||
</para>
|
||||
<para>
|
||||
The call to g_set_prgname() can be removed once you fully migrated
|
||||
to GTK+4.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
||||
<section>
|
||||
@@ -286,14 +262,6 @@
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Stop using GtkEventBox</title>
|
||||
<para>
|
||||
GtkEventBox is no longer needed and has been removed.
|
||||
All widgets receive all events.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Adapt to GtkHeaderBar API changes</title>
|
||||
<para>
|
||||
@@ -343,15 +311,6 @@
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Adapt to GtkWidget's size allocation changes</title>
|
||||
<para>
|
||||
The #GtkWidget::size-allocate signal now takes the baseline as an
|
||||
argument, so you no longer need to call gtk_widget_get_allocated_baseline()
|
||||
to get it.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Switch to GtkWidget's children APIs</title>
|
||||
<para>
|
||||
@@ -432,10 +391,6 @@
|
||||
from ui files it run the command <command>gtk4-builder-tool simplify --replace</command>
|
||||
on them.
|
||||
</para>
|
||||
<para>
|
||||
The function gtk_widget_show_all(), the #GtkWidget::no-show-all property
|
||||
and its getter and setter have been removed in GTK+ 4, so you should stop using them.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
@@ -477,7 +432,8 @@
|
||||
<title>GtkWidget event signals are removed</title>
|
||||
<para>
|
||||
Event controllers and #GtkGestures have already been introduced in GTK+ 3 to handle
|
||||
input for many cases. In GTK+ 4, the traditional widget signals for handling input,
|
||||
input for many cases. In GTK+ 4, even more are available, such as #GtkEventControllerScroll
|
||||
and GtkEventControllerMotion, and the traditional widget signals for handling input,
|
||||
such as #GtkWidget::motion-event or #GtkWidget::event have been removed.
|
||||
</para>
|
||||
</section>
|
||||
|
35
docs/reference/gtk/mir.xml
Normal file
35
docs/reference/gtk/mir.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
||||
]>
|
||||
<refentry id="gtk-mir">
|
||||
<refmeta>
|
||||
<refentrytitle>Using GTK+ with Mir</refentrytitle>
|
||||
<manvolnum>3</manvolnum>
|
||||
<refmiscinfo>GTK Library</refmiscinfo>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>Using GTK+ with Mir</refname>
|
||||
<refpurpose>
|
||||
Mir-specific aspects of using GTK+
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1>
|
||||
<title>Using GTK+ with Mir</title>
|
||||
|
||||
<para>
|
||||
The GDK Mir backend provides support for running GTK+ applications
|
||||
under Mir based display servers. To run your application in this way,
|
||||
select the Mir backend by setting <literal>GDK_BACKEND=mir</literal>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Currently, the Mir backend does not use any additional commandline
|
||||
options or environment variables.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
@@ -435,6 +435,11 @@ nevertheless.
|
||||
<listitem><para>Selects the Wayland backend for connecting to Wayland display servers</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>mir</term>
|
||||
<listitem><para>Selects the Mir backend for connecting to Mir display servers</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
Since 3.10, this environment variable can contain a comma-separated list
|
||||
of backend names, which are tried in order. The list may also contain
|
||||
|
@@ -12,9 +12,6 @@ docpath = join_paths(gtk_datadir, 'gtk-doc', 'html')
|
||||
version_conf = configuration_data()
|
||||
version_conf.set('GTK_VERSION', meson.project_version())
|
||||
|
||||
src_dir_conf = configuration_data()
|
||||
src_dir_conf.set('SRC_DIR', meson.source_root())
|
||||
|
||||
subdir('gdk')
|
||||
subdir('gsk')
|
||||
subdir('gtk')
|
||||
|
@@ -2,8 +2,8 @@ To make gnome-shell use the desktop file and icon for this example
|
||||
while running it uninstalled, do the following:
|
||||
|
||||
mkdir -p ~/.local/share/applications
|
||||
sed -e "s#@bindir@#$PWD#" org.gtk.exampleapp.desktop \
|
||||
> ~/.local/share/applications/org.gtk.exampleapp.desktop
|
||||
sed -e "s#@bindir@#$PWD#" exampleapp.desktop \
|
||||
> ~/.local/share/applications/lt-exampleapp.desktop
|
||||
|
||||
mkdir -p ~/.local/share/icons/hicolor/48x48/apps
|
||||
cp exampleapp.png ~/.local/share/icons/hicolor/48x48/apps
|
||||
|
@@ -7,36 +7,43 @@
|
||||
struct _ExampleAppPrefs
|
||||
{
|
||||
GtkDialog parent;
|
||||
};
|
||||
|
||||
typedef struct _ExampleAppPrefsPrivate ExampleAppPrefsPrivate;
|
||||
|
||||
struct _ExampleAppPrefsPrivate
|
||||
{
|
||||
GSettings *settings;
|
||||
GtkWidget *font;
|
||||
GtkWidget *transition;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
|
||||
|
||||
static void
|
||||
example_app_prefs_init (ExampleAppPrefs *prefs)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (prefs));
|
||||
prefs->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
ExampleAppPrefsPrivate *priv;
|
||||
|
||||
g_settings_bind (prefs->settings, "font",
|
||||
prefs->font, "font",
|
||||
priv = example_app_prefs_get_instance_private (prefs);
|
||||
gtk_widget_init_template (GTK_WIDGET (prefs));
|
||||
priv->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
|
||||
g_settings_bind (priv->settings, "font",
|
||||
priv->font, "font",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
g_settings_bind (prefs->settings, "transition",
|
||||
prefs->transition, "active-id",
|
||||
g_settings_bind (priv->settings, "transition",
|
||||
priv->transition, "active-id",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
}
|
||||
|
||||
static void
|
||||
example_app_prefs_dispose (GObject *object)
|
||||
{
|
||||
ExampleAppPrefs *prefs;
|
||||
ExampleAppPrefsPrivate *priv;
|
||||
|
||||
prefs = EXAMPLE_APP_PREFS (object);
|
||||
|
||||
g_clear_object (&prefs->settings);
|
||||
priv = example_app_prefs_get_instance_private (EXAMPLE_APP_PREFS (object));
|
||||
g_clear_object (&priv->settings);
|
||||
|
||||
G_OBJECT_CLASS (example_app_prefs_parent_class)->dispose (object);
|
||||
}
|
||||
@@ -48,8 +55,8 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
|
||||
|
||||
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
|
||||
"/org/gtk/exampleapp/prefs.ui");
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
|
||||
}
|
||||
|
||||
ExampleAppPrefs *
|
||||
|
@@ -6,7 +6,12 @@
|
||||
struct _ExampleAppWindow
|
||||
{
|
||||
GtkApplicationWindow parent;
|
||||
};
|
||||
|
||||
typedef struct _ExampleAppWindowPrivate ExampleAppWindowPrivate;
|
||||
|
||||
struct _ExampleAppWindowPrivate
|
||||
{
|
||||
GSettings *settings;
|
||||
GtkWidget *stack;
|
||||
GtkWidget *search;
|
||||
@@ -19,12 +24,13 @@ struct _ExampleAppWindow
|
||||
GtkWidget *lines_label;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
|
||||
|
||||
static void
|
||||
search_text_changed (GtkEntry *entry,
|
||||
ExampleAppWindow *win)
|
||||
search_text_changed (GtkEntry *entry)
|
||||
{
|
||||
ExampleAppWindow *win;
|
||||
ExampleAppWindowPrivate *priv;
|
||||
const gchar *text;
|
||||
GtkWidget *tab;
|
||||
GtkWidget *view;
|
||||
@@ -36,7 +42,10 @@ search_text_changed (GtkEntry *entry,
|
||||
if (text[0] == '\0')
|
||||
return;
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
|
||||
win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (entry)));
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
|
||||
view = gtk_bin_get_child (GTK_BIN (tab));
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
@@ -55,15 +64,19 @@ static void
|
||||
find_word (GtkButton *button,
|
||||
ExampleAppWindow *win)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
const gchar *word;
|
||||
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
|
||||
word = gtk_button_get_label (button);
|
||||
gtk_entry_set_text (GTK_ENTRY (win->searchentry), word);
|
||||
gtk_entry_set_text (GTK_ENTRY (priv->searchentry), word);
|
||||
}
|
||||
|
||||
static void
|
||||
update_words (ExampleAppWindow *win)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
GHashTable *strings;
|
||||
GHashTableIter iter;
|
||||
GtkWidget *tab, *view, *row;
|
||||
@@ -72,7 +85,9 @@ update_words (ExampleAppWindow *win)
|
||||
GList *children, *l;
|
||||
gchar *word, *key;
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
|
||||
|
||||
if (tab == NULL)
|
||||
return;
|
||||
@@ -100,9 +115,9 @@ update_words (ExampleAppWindow *win)
|
||||
}
|
||||
|
||||
done:
|
||||
children = gtk_container_get_children (GTK_CONTAINER (win->words));
|
||||
children = gtk_container_get_children (GTK_CONTAINER (priv->words));
|
||||
for (l = children; l; l = l->next)
|
||||
gtk_container_remove (GTK_CONTAINER (win->words), GTK_WIDGET (l->data));
|
||||
gtk_container_remove (GTK_CONTAINER (priv->words), GTK_WIDGET (l->data));
|
||||
g_list_free (children);
|
||||
|
||||
g_hash_table_iter_init (&iter, strings);
|
||||
@@ -111,7 +126,8 @@ done:
|
||||
row = gtk_button_new_with_label (key);
|
||||
g_signal_connect (row, "clicked",
|
||||
G_CALLBACK (find_word), win);
|
||||
gtk_container_add (GTK_CONTAINER (win->words), row);
|
||||
gtk_widget_show (row);
|
||||
gtk_container_add (GTK_CONTAINER (priv->words), row);
|
||||
}
|
||||
|
||||
g_hash_table_unref (strings);
|
||||
@@ -120,12 +136,16 @@ done:
|
||||
static void
|
||||
update_lines (ExampleAppWindow *win)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
GtkWidget *tab, *view;
|
||||
GtkTextBuffer *buffer;
|
||||
GtkTextIter iter;
|
||||
int count;
|
||||
gchar *lines;
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
|
||||
|
||||
if (tab == NULL)
|
||||
return;
|
||||
@@ -133,21 +153,34 @@ update_lines (ExampleAppWindow *win)
|
||||
view = gtk_bin_get_child (GTK_BIN (tab));
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
count = gtk_text_buffer_get_line_count (buffer);
|
||||
count = 0;
|
||||
|
||||
gtk_text_buffer_get_start_iter (buffer, &iter);
|
||||
while (!gtk_text_iter_is_end (&iter))
|
||||
{
|
||||
count++;
|
||||
if (!gtk_text_iter_forward_line (&iter))
|
||||
break;
|
||||
}
|
||||
|
||||
lines = g_strdup_printf ("%d", count);
|
||||
gtk_label_set_text (GTK_LABEL (win->lines), lines);
|
||||
gtk_label_set_text (GTK_LABEL (priv->lines), lines);
|
||||
g_free (lines);
|
||||
}
|
||||
|
||||
static void
|
||||
visible_child_changed (GObject *stack,
|
||||
GParamSpec *pspec,
|
||||
ExampleAppWindow *win)
|
||||
visible_child_changed (GObject *stack,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ExampleAppWindow *win;
|
||||
ExampleAppWindowPrivate *priv;
|
||||
|
||||
if (gtk_widget_in_destruction (GTK_WIDGET (stack)))
|
||||
return;
|
||||
|
||||
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (win->searchbar), FALSE);
|
||||
win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (stack)));
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (priv->searchbar), FALSE);
|
||||
update_words (win);
|
||||
update_lines (win);
|
||||
}
|
||||
@@ -163,43 +196,45 @@ words_changed (GObject *sidebar,
|
||||
static void
|
||||
example_app_window_init (ExampleAppWindow *win)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
GtkBuilder *builder;
|
||||
GMenuModel *menu;
|
||||
GAction *action;
|
||||
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
gtk_widget_init_template (GTK_WIDGET (win));
|
||||
win->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
priv->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
|
||||
g_settings_bind (win->settings, "transition",
|
||||
win->stack, "transition-type",
|
||||
g_settings_bind (priv->settings, "transition",
|
||||
priv->stack, "transition-type",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
g_settings_bind (win->settings, "show-words",
|
||||
win->sidebar, "reveal-child",
|
||||
g_settings_bind (priv->settings, "show-words",
|
||||
priv->sidebar, "reveal-child",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
g_object_bind_property (win->search, "active",
|
||||
win->searchbar, "search-mode-enabled",
|
||||
g_object_bind_property (priv->search, "active",
|
||||
priv->searchbar, "search-mode-enabled",
|
||||
G_BINDING_BIDIRECTIONAL);
|
||||
|
||||
g_signal_connect (win->sidebar, "notify::reveal-child",
|
||||
g_signal_connect (priv->sidebar, "notify::reveal-child",
|
||||
G_CALLBACK (words_changed), win);
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/gears-menu.ui");
|
||||
menu = G_MENU_MODEL (gtk_builder_get_object (builder, "menu"));
|
||||
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (win->gears), menu);
|
||||
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (priv->gears), menu);
|
||||
g_object_unref (builder);
|
||||
|
||||
action = g_settings_create_action (win->settings, "show-words");
|
||||
action = g_settings_create_action (priv->settings, "show-words");
|
||||
g_action_map_add_action (G_ACTION_MAP (win), action);
|
||||
g_object_unref (action);
|
||||
|
||||
action = (GAction*) g_property_action_new ("show-lines", win->lines, "visible");
|
||||
action = (GAction*) g_property_action_new ("show-lines", priv->lines, "visible");
|
||||
g_action_map_add_action (G_ACTION_MAP (win), action);
|
||||
g_object_unref (action);
|
||||
|
||||
g_object_bind_property (win->lines, "visible",
|
||||
win->lines_label, "visible",
|
||||
g_object_bind_property (priv->lines, "visible",
|
||||
priv->lines_label, "visible",
|
||||
G_BINDING_DEFAULT);
|
||||
|
||||
g_object_set (gtk_settings_get_default (), "gtk-shell-shows-app-menu", FALSE, NULL);
|
||||
@@ -210,10 +245,12 @@ static void
|
||||
example_app_window_dispose (GObject *object)
|
||||
{
|
||||
ExampleAppWindow *win;
|
||||
ExampleAppWindowPrivate *priv;
|
||||
|
||||
win = EXAMPLE_APP_WINDOW (object);
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
|
||||
g_clear_object (&win->settings);
|
||||
g_clear_object (&priv->settings);
|
||||
|
||||
G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
|
||||
}
|
||||
@@ -226,15 +263,15 @@ example_app_window_class_init (ExampleAppWindowClass *class)
|
||||
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
|
||||
"/org/gtk/exampleapp/window.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchentry);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, gears);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, words);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, sidebar);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, lines);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, lines_label);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchentry);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, gears);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, words);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, sidebar);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, lines);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, lines_label);
|
||||
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), search_text_changed);
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), visible_child_changed);
|
||||
@@ -250,6 +287,7 @@ void
|
||||
example_app_window_open (ExampleAppWindow *win,
|
||||
GFile *file)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
gchar *basename;
|
||||
GtkWidget *scrolled, *view;
|
||||
gchar *contents;
|
||||
@@ -258,16 +296,19 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
GtkTextTag *tag;
|
||||
GtkTextIter start_iter, end_iter;
|
||||
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
basename = g_file_get_basename (file);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_show (scrolled);
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_widget_show (view);
|
||||
gtk_container_add (GTK_CONTAINER (scrolled), view);
|
||||
gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
|
||||
gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
@@ -278,7 +319,7 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
}
|
||||
|
||||
tag = gtk_text_buffer_create_tag (buffer, NULL, NULL);
|
||||
g_settings_bind (win->settings, "font",
|
||||
g_settings_bind (priv->settings, "font",
|
||||
tag, "font",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
@@ -288,7 +329,7 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
|
||||
g_free (basename);
|
||||
|
||||
gtk_widget_set_sensitive (win->search, TRUE);
|
||||
gtk_widget_set_sensitive (priv->search, TRUE);
|
||||
|
||||
update_words (win);
|
||||
update_lines (win);
|
||||
|
@@ -27,7 +27,14 @@
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="search">
|
||||
<property name="sensitive">0</property>
|
||||
<property name="icon-name">edit-find-symbolic</property>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkImage" id="search-icon">
|
||||
<property name="icon-name">edit-find-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">end</property>
|
||||
|
@@ -6,11 +6,16 @@
|
||||
struct _ExampleAppWindow
|
||||
{
|
||||
GtkApplicationWindow parent;
|
||||
};
|
||||
|
||||
typedef struct _ExampleAppWindowPrivate ExampleAppWindowPrivate;
|
||||
|
||||
struct _ExampleAppWindowPrivate
|
||||
{
|
||||
GtkWidget *stack;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
|
||||
|
||||
static void
|
||||
example_app_window_init (ExampleAppWindow *win)
|
||||
@@ -23,7 +28,7 @@ example_app_window_class_init (ExampleAppWindowClass *class)
|
||||
{
|
||||
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
|
||||
"/org/gtk/exampleapp/window.ui");
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
}
|
||||
|
||||
ExampleAppWindow *
|
||||
@@ -36,21 +41,25 @@ void
|
||||
example_app_window_open (ExampleAppWindow *win,
|
||||
GFile *file)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
gchar *basename;
|
||||
GtkWidget *scrolled, *view;
|
||||
gchar *contents;
|
||||
gsize length;
|
||||
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
basename = g_file_get_basename (file);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_show (scrolled);
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_widget_show (view);
|
||||
gtk_container_add (GTK_CONTAINER (scrolled), view);
|
||||
gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
|
||||
gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
|
||||
|
||||
if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL))
|
||||
{
|
||||
|
@@ -6,11 +6,16 @@
|
||||
struct _ExampleAppWindow
|
||||
{
|
||||
GtkApplicationWindow parent;
|
||||
};
|
||||
|
||||
typedef struct _ExampleAppWindowPrivate ExampleAppWindowPrivate;
|
||||
|
||||
struct _ExampleAppWindowPrivate
|
||||
{
|
||||
GtkWidget *stack;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
|
||||
|
||||
static void
|
||||
example_app_window_init (ExampleAppWindow *win)
|
||||
@@ -23,7 +28,7 @@ example_app_window_class_init (ExampleAppWindowClass *class)
|
||||
{
|
||||
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
|
||||
"/org/gtk/exampleapp/window.ui");
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
}
|
||||
|
||||
ExampleAppWindow *
|
||||
@@ -36,21 +41,25 @@ void
|
||||
example_app_window_open (ExampleAppWindow *win,
|
||||
GFile *file)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
gchar *basename;
|
||||
GtkWidget *scrolled, *view;
|
||||
gchar *contents;
|
||||
gsize length;
|
||||
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
basename = g_file_get_basename (file);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_show (scrolled);
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_widget_show (view);
|
||||
gtk_container_add (GTK_CONTAINER (scrolled), view);
|
||||
gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
|
||||
gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
|
||||
|
||||
if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL))
|
||||
{
|
||||
|
@@ -6,21 +6,29 @@
|
||||
struct _ExampleAppWindow
|
||||
{
|
||||
GtkApplicationWindow parent;
|
||||
};
|
||||
|
||||
typedef struct _ExampleAppWindowPrivate ExampleAppWindowPrivate;
|
||||
|
||||
struct _ExampleAppWindowPrivate
|
||||
{
|
||||
GSettings *settings;
|
||||
GtkWidget *stack;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
|
||||
|
||||
static void
|
||||
example_app_window_init (ExampleAppWindow *win)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (win));
|
||||
win->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
ExampleAppWindowPrivate *priv;
|
||||
|
||||
g_settings_bind (win->settings, "transition",
|
||||
win->stack, "transition-type",
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
gtk_widget_init_template (GTK_WIDGET (win));
|
||||
priv->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
|
||||
g_settings_bind (priv->settings, "transition",
|
||||
priv->stack, "transition-type",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
}
|
||||
|
||||
@@ -28,10 +36,12 @@ static void
|
||||
example_app_window_dispose (GObject *object)
|
||||
{
|
||||
ExampleAppWindow *win;
|
||||
ExampleAppWindowPrivate *priv;
|
||||
|
||||
win = EXAMPLE_APP_WINDOW (object);
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
|
||||
g_clear_object (&win->settings);
|
||||
g_clear_object (&priv->settings);
|
||||
|
||||
G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
|
||||
}
|
||||
@@ -43,7 +53,7 @@ example_app_window_class_init (ExampleAppWindowClass *class)
|
||||
|
||||
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
|
||||
"/org/gtk/exampleapp/window.ui");
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
}
|
||||
|
||||
ExampleAppWindow *
|
||||
@@ -56,6 +66,7 @@ void
|
||||
example_app_window_open (ExampleAppWindow *win,
|
||||
GFile *file)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
gchar *basename;
|
||||
GtkWidget *scrolled, *view;
|
||||
gchar *contents;
|
||||
@@ -64,16 +75,19 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
GtkTextTag *tag;
|
||||
GtkTextIter start_iter, end_iter;
|
||||
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
basename = g_file_get_basename (file);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_show (scrolled);
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_widget_show (view);
|
||||
gtk_container_add (GTK_CONTAINER (scrolled), view);
|
||||
gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
|
||||
gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
@@ -84,7 +98,7 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
}
|
||||
|
||||
tag = gtk_text_buffer_create_tag (buffer, NULL, NULL);
|
||||
g_settings_bind (win->settings, "font", tag, "font", G_SETTINGS_BIND_DEFAULT);
|
||||
g_settings_bind (priv->settings, "font", tag, "font", G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
gtk_text_buffer_get_start_iter (buffer, &start_iter);
|
||||
gtk_text_buffer_get_end_iter (buffer, &end_iter);
|
||||
|
@@ -7,36 +7,43 @@
|
||||
struct _ExampleAppPrefs
|
||||
{
|
||||
GtkDialog parent;
|
||||
};
|
||||
|
||||
typedef struct _ExampleAppPrefsPrivate ExampleAppPrefsPrivate;
|
||||
|
||||
struct _ExampleAppPrefsPrivate
|
||||
{
|
||||
GSettings *settings;
|
||||
GtkWidget *font;
|
||||
GtkWidget *transition;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
|
||||
|
||||
static void
|
||||
example_app_prefs_init (ExampleAppPrefs *prefs)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (prefs));
|
||||
prefs->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
ExampleAppPrefsPrivate *priv;
|
||||
|
||||
g_settings_bind (prefs->settings, "font",
|
||||
prefs->font, "font",
|
||||
priv = example_app_prefs_get_instance_private (prefs);
|
||||
gtk_widget_init_template (GTK_WIDGET (prefs));
|
||||
priv->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
|
||||
g_settings_bind (priv->settings, "font",
|
||||
priv->font, "font",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
g_settings_bind (prefs->settings, "transition",
|
||||
prefs->transition, "active-id",
|
||||
g_settings_bind (priv->settings, "transition",
|
||||
priv->transition, "active-id",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
}
|
||||
|
||||
static void
|
||||
example_app_prefs_dispose (GObject *object)
|
||||
{
|
||||
ExampleAppPrefs *prefs;
|
||||
ExampleAppPrefsPrivate *priv;
|
||||
|
||||
prefs = EXAMPLE_APP_PREFS (object);
|
||||
|
||||
g_clear_object (&prefs->settings);
|
||||
priv = example_app_prefs_get_instance_private (EXAMPLE_APP_PREFS (object));
|
||||
g_clear_object (&priv->settings);
|
||||
|
||||
G_OBJECT_CLASS (example_app_prefs_parent_class)->dispose (object);
|
||||
}
|
||||
@@ -48,8 +55,8 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
|
||||
|
||||
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
|
||||
"/org/gtk/exampleapp/prefs.ui");
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
|
||||
}
|
||||
|
||||
ExampleAppPrefs *
|
||||
|
@@ -6,21 +6,29 @@
|
||||
struct _ExampleAppWindow
|
||||
{
|
||||
GtkApplicationWindow parent;
|
||||
};
|
||||
|
||||
typedef struct ExampleAppWindowPrivate ExampleAppWindowPrivate;
|
||||
|
||||
struct ExampleAppWindowPrivate
|
||||
{
|
||||
GSettings *settings;
|
||||
GtkWidget *stack;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
|
||||
|
||||
static void
|
||||
example_app_window_init (ExampleAppWindow *win)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (win));
|
||||
win->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
ExampleAppWindowPrivate *priv;
|
||||
|
||||
g_settings_bind (win->settings, "transition",
|
||||
win->stack, "transition-type",
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
gtk_widget_init_template (GTK_WIDGET (win));
|
||||
priv->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
|
||||
g_settings_bind (priv->settings, "transition",
|
||||
priv->stack, "transition-type",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
}
|
||||
|
||||
@@ -28,10 +36,12 @@ static void
|
||||
example_app_window_dispose (GObject *object)
|
||||
{
|
||||
ExampleAppWindow *win;
|
||||
ExampleAppWindowPrivate *priv;
|
||||
|
||||
win = EXAMPLE_APP_WINDOW (object);
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
|
||||
g_clear_object (&win->settings);
|
||||
g_clear_object (&priv->settings);
|
||||
|
||||
G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
|
||||
}
|
||||
@@ -43,7 +53,7 @@ example_app_window_class_init (ExampleAppWindowClass *class)
|
||||
|
||||
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
|
||||
"/org/gtk/exampleapp/window.ui");
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
}
|
||||
|
||||
ExampleAppWindow *
|
||||
@@ -56,6 +66,7 @@ void
|
||||
example_app_window_open (ExampleAppWindow *win,
|
||||
GFile *file)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
gchar *basename;
|
||||
GtkWidget *scrolled, *view;
|
||||
gchar *contents;
|
||||
@@ -64,16 +75,19 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
GtkTextTag *tag;
|
||||
GtkTextIter start_iter, end_iter;
|
||||
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
basename = g_file_get_basename (file);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_show (scrolled);
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_widget_show (view);
|
||||
gtk_container_add (GTK_CONTAINER (scrolled), view);
|
||||
gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
|
||||
gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
@@ -84,7 +98,7 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
}
|
||||
|
||||
tag = gtk_text_buffer_create_tag (buffer, NULL, NULL);
|
||||
g_settings_bind (win->settings, "font", tag, "font", G_SETTINGS_BIND_DEFAULT);
|
||||
g_settings_bind (priv->settings, "font", tag, "font", G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
gtk_text_buffer_get_start_iter (buffer, &start_iter);
|
||||
gtk_text_buffer_get_end_iter (buffer, &end_iter);
|
||||
|
@@ -7,36 +7,43 @@
|
||||
struct _ExampleAppPrefs
|
||||
{
|
||||
GtkDialog parent;
|
||||
};
|
||||
|
||||
typedef struct _ExampleAppPrefsPrivate ExampleAppPrefsPrivate;
|
||||
|
||||
struct _ExampleAppPrefsPrivate
|
||||
{
|
||||
GSettings *settings;
|
||||
GtkWidget *font;
|
||||
GtkWidget *transition;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
|
||||
|
||||
static void
|
||||
example_app_prefs_init (ExampleAppPrefs *prefs)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (prefs));
|
||||
prefs->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
ExampleAppPrefsPrivate *priv;
|
||||
|
||||
g_settings_bind (prefs->settings, "font",
|
||||
prefs->font, "font",
|
||||
priv = example_app_prefs_get_instance_private (prefs);
|
||||
gtk_widget_init_template (GTK_WIDGET (prefs));
|
||||
priv->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
|
||||
g_settings_bind (priv->settings, "font",
|
||||
priv->font, "font",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
g_settings_bind (prefs->settings, "transition",
|
||||
prefs->transition, "active-id",
|
||||
g_settings_bind (priv->settings, "transition",
|
||||
priv->transition, "active-id",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
}
|
||||
|
||||
static void
|
||||
example_app_prefs_dispose (GObject *object)
|
||||
{
|
||||
ExampleAppPrefs *prefs;
|
||||
ExampleAppPrefsPrivate *priv;
|
||||
|
||||
prefs = EXAMPLE_APP_PREFS (object);
|
||||
|
||||
g_clear_object (&prefs->settings);
|
||||
priv = example_app_prefs_get_instance_private (EXAMPLE_APP_PREFS (object));
|
||||
g_clear_object (&priv->settings);
|
||||
|
||||
G_OBJECT_CLASS (example_app_prefs_parent_class)->dispose (object);
|
||||
}
|
||||
@@ -48,8 +55,8 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
|
||||
|
||||
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
|
||||
"/org/gtk/exampleapp/prefs.ui");
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
|
||||
}
|
||||
|
||||
ExampleAppPrefs *
|
||||
|
@@ -6,19 +6,25 @@
|
||||
struct _ExampleAppWindow
|
||||
{
|
||||
GtkApplicationWindow parent;
|
||||
};
|
||||
|
||||
typedef struct _ExampleAppWindowPrivate ExampleAppWindowPrivate;
|
||||
|
||||
struct _ExampleAppWindowPrivate
|
||||
{
|
||||
GSettings *settings;
|
||||
GtkWidget *stack;
|
||||
GtkWidget *search;
|
||||
GtkWidget *searchbar;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
|
||||
|
||||
static void
|
||||
search_text_changed (GtkEntry *entry,
|
||||
ExampleAppWindow *win)
|
||||
search_text_changed (GtkEntry *entry)
|
||||
{
|
||||
ExampleAppWindow *win;
|
||||
ExampleAppWindowPrivate *priv;
|
||||
const gchar *text;
|
||||
GtkWidget *tab;
|
||||
GtkWidget *view;
|
||||
@@ -30,7 +36,10 @@ search_text_changed (GtkEntry *entry,
|
||||
if (text[0] == '\0')
|
||||
return;
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
|
||||
win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (entry)));
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
|
||||
view = gtk_bin_get_child (GTK_BIN (tab));
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
@@ -46,28 +55,36 @@ search_text_changed (GtkEntry *entry,
|
||||
}
|
||||
|
||||
static void
|
||||
visible_child_changed (GObject *stack,
|
||||
GParamSpec *pspec,
|
||||
ExampleAppWindow *win)
|
||||
visible_child_changed (GObject *stack,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ExampleAppWindow *win;
|
||||
ExampleAppWindowPrivate *priv;
|
||||
|
||||
if (gtk_widget_in_destruction (GTK_WIDGET (stack)))
|
||||
return;
|
||||
|
||||
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (win->searchbar), FALSE);
|
||||
win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (stack)));
|
||||
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (priv->searchbar), FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
example_app_window_init (ExampleAppWindow *win)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (win));
|
||||
win->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
ExampleAppWindowPrivate *priv;
|
||||
|
||||
g_settings_bind (win->settings, "transition",
|
||||
win->stack, "transition-type",
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
gtk_widget_init_template (GTK_WIDGET (win));
|
||||
priv->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
|
||||
g_settings_bind (priv->settings, "transition",
|
||||
priv->stack, "transition-type",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
g_object_bind_property (win->search, "active",
|
||||
win->searchbar, "search-mode-enabled",
|
||||
g_object_bind_property (priv->search, "active",
|
||||
priv->searchbar, "search-mode-enabled",
|
||||
G_BINDING_BIDIRECTIONAL);
|
||||
}
|
||||
|
||||
@@ -75,10 +92,12 @@ static void
|
||||
example_app_window_dispose (GObject *object)
|
||||
{
|
||||
ExampleAppWindow *win;
|
||||
ExampleAppWindowPrivate *priv;
|
||||
|
||||
win = EXAMPLE_APP_WINDOW (object);
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
|
||||
g_clear_object (&win->settings);
|
||||
g_clear_object (&priv->settings);
|
||||
|
||||
G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
|
||||
}
|
||||
@@ -91,9 +110,9 @@ example_app_window_class_init (ExampleAppWindowClass *class)
|
||||
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
|
||||
"/org/gtk/exampleapp/window.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
|
||||
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), search_text_changed);
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), visible_child_changed);
|
||||
@@ -109,6 +128,7 @@ void
|
||||
example_app_window_open (ExampleAppWindow *win,
|
||||
GFile *file)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
gchar *basename;
|
||||
GtkWidget *scrolled, *view;
|
||||
gchar *contents;
|
||||
@@ -117,16 +137,19 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
GtkTextTag *tag;
|
||||
GtkTextIter start_iter, end_iter;
|
||||
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
basename = g_file_get_basename (file);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_show (scrolled);
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_widget_show (view);
|
||||
gtk_container_add (GTK_CONTAINER (scrolled), view);
|
||||
gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
|
||||
gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
@@ -137,7 +160,7 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
}
|
||||
|
||||
tag = gtk_text_buffer_create_tag (buffer, NULL, NULL);
|
||||
g_settings_bind (win->settings, "font",
|
||||
g_settings_bind (priv->settings, "font",
|
||||
tag, "font",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
@@ -147,5 +170,5 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
|
||||
g_free (basename);
|
||||
|
||||
gtk_widget_set_sensitive (win->search, TRUE);
|
||||
gtk_widget_set_sensitive (priv->search, TRUE);
|
||||
}
|
||||
|
@@ -18,7 +18,14 @@
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="search">
|
||||
<property name="sensitive">0</property>
|
||||
<property name="icon-name">edit-find-symbolic</property>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkImage" id="search-icon">
|
||||
<property name="icon-name">edit-find-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">end</property>
|
||||
|
@@ -7,36 +7,43 @@
|
||||
struct _ExampleAppPrefs
|
||||
{
|
||||
GtkDialog parent;
|
||||
};
|
||||
|
||||
typedef struct _ExampleAppPrefsPrivate ExampleAppPrefsPrivate;
|
||||
|
||||
struct _ExampleAppPrefsPrivate
|
||||
{
|
||||
GSettings *settings;
|
||||
GtkWidget *font;
|
||||
GtkWidget *transition;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
|
||||
|
||||
static void
|
||||
example_app_prefs_init (ExampleAppPrefs *prefs)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (prefs));
|
||||
prefs->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
ExampleAppPrefsPrivate *priv;
|
||||
|
||||
g_settings_bind (prefs->settings, "font",
|
||||
prefs->font, "font",
|
||||
priv = example_app_prefs_get_instance_private (prefs);
|
||||
gtk_widget_init_template (GTK_WIDGET (prefs));
|
||||
priv->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
|
||||
g_settings_bind (priv->settings, "font",
|
||||
priv->font, "font",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
g_settings_bind (prefs->settings, "transition",
|
||||
prefs->transition, "active-id",
|
||||
g_settings_bind (priv->settings, "transition",
|
||||
priv->transition, "active-id",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
}
|
||||
|
||||
static void
|
||||
example_app_prefs_dispose (GObject *object)
|
||||
{
|
||||
ExampleAppPrefs *prefs;
|
||||
ExampleAppPrefsPrivate *priv;
|
||||
|
||||
prefs = EXAMPLE_APP_PREFS (object);
|
||||
|
||||
g_clear_object (&prefs->settings);
|
||||
priv = example_app_prefs_get_instance_private (EXAMPLE_APP_PREFS (object));
|
||||
g_clear_object (&priv->settings);
|
||||
|
||||
G_OBJECT_CLASS (example_app_prefs_parent_class)->dispose (object);
|
||||
}
|
||||
@@ -48,8 +55,8 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
|
||||
|
||||
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
|
||||
"/org/gtk/exampleapp/prefs.ui");
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
|
||||
}
|
||||
|
||||
ExampleAppPrefs *
|
||||
|
@@ -6,7 +6,12 @@
|
||||
struct _ExampleAppWindow
|
||||
{
|
||||
GtkApplicationWindow parent;
|
||||
};
|
||||
|
||||
typedef struct _ExampleAppWindowPrivate ExampleAppWindowPrivate;
|
||||
|
||||
struct _ExampleAppWindowPrivate
|
||||
{
|
||||
GSettings *settings;
|
||||
GtkWidget *stack;
|
||||
GtkWidget *search;
|
||||
@@ -17,12 +22,13 @@ struct _ExampleAppWindow
|
||||
GtkWidget *words;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
|
||||
|
||||
static void
|
||||
search_text_changed (GtkEntry *entry,
|
||||
ExampleAppWindow *win)
|
||||
search_text_changed (GtkEntry *entry)
|
||||
{
|
||||
ExampleAppWindow *win;
|
||||
ExampleAppWindowPrivate *priv;
|
||||
const gchar *text;
|
||||
GtkWidget *tab;
|
||||
GtkWidget *view;
|
||||
@@ -34,7 +40,10 @@ search_text_changed (GtkEntry *entry,
|
||||
if (text[0] == '\0')
|
||||
return;
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
|
||||
win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (entry)));
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
|
||||
view = gtk_bin_get_child (GTK_BIN (tab));
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
@@ -53,15 +62,19 @@ static void
|
||||
find_word (GtkButton *button,
|
||||
ExampleAppWindow *win)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
const gchar *word;
|
||||
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
|
||||
word = gtk_button_get_label (button);
|
||||
gtk_entry_set_text (GTK_ENTRY (win->searchentry), word);
|
||||
gtk_entry_set_text (GTK_ENTRY (priv->searchentry), word);
|
||||
}
|
||||
|
||||
static void
|
||||
update_words (ExampleAppWindow *win)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
GHashTable *strings;
|
||||
GHashTableIter iter;
|
||||
GtkWidget *tab, *view, *row;
|
||||
@@ -70,7 +83,9 @@ update_words (ExampleAppWindow *win)
|
||||
GList *children, *l;
|
||||
gchar *word, *key;
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
|
||||
|
||||
if (tab == NULL)
|
||||
return;
|
||||
@@ -98,9 +113,9 @@ update_words (ExampleAppWindow *win)
|
||||
}
|
||||
|
||||
done:
|
||||
children = gtk_container_get_children (GTK_CONTAINER (win->words));
|
||||
children = gtk_container_get_children (GTK_CONTAINER (priv->words));
|
||||
for (l = children; l; l = l->next)
|
||||
gtk_container_remove (GTK_CONTAINER (win->words), GTK_WIDGET (l->data));
|
||||
gtk_container_remove (GTK_CONTAINER (priv->words), GTK_WIDGET (l->data));
|
||||
g_list_free (children);
|
||||
|
||||
g_hash_table_iter_init (&iter, strings);
|
||||
@@ -109,21 +124,27 @@ done:
|
||||
row = gtk_button_new_with_label (key);
|
||||
g_signal_connect (row, "clicked",
|
||||
G_CALLBACK (find_word), win);
|
||||
gtk_container_add (GTK_CONTAINER (win->words), row);
|
||||
gtk_widget_show (row);
|
||||
gtk_container_add (GTK_CONTAINER (priv->words), row);
|
||||
}
|
||||
|
||||
g_hash_table_unref (strings);
|
||||
}
|
||||
|
||||
static void
|
||||
visible_child_changed (GObject *stack,
|
||||
GParamSpec *pspec,
|
||||
ExampleAppWindow *win)
|
||||
visible_child_changed (GObject *stack,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ExampleAppWindow *win;
|
||||
ExampleAppWindowPrivate *priv;
|
||||
|
||||
if (gtk_widget_in_destruction (GTK_WIDGET (stack)))
|
||||
return;
|
||||
|
||||
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (win->searchbar), FALSE);
|
||||
win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (stack)));
|
||||
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (priv->searchbar), FALSE);
|
||||
update_words (win);
|
||||
}
|
||||
|
||||
@@ -138,34 +159,36 @@ words_changed (GObject *sidebar,
|
||||
static void
|
||||
example_app_window_init (ExampleAppWindow *win)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
GtkBuilder *builder;
|
||||
GMenuModel *menu;
|
||||
GAction *action;
|
||||
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
gtk_widget_init_template (GTK_WIDGET (win));
|
||||
win->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
priv->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
|
||||
g_settings_bind (win->settings, "transition",
|
||||
win->stack, "transition-type",
|
||||
g_settings_bind (priv->settings, "transition",
|
||||
priv->stack, "transition-type",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
g_settings_bind (win->settings, "show-words",
|
||||
win->sidebar, "reveal-child",
|
||||
g_settings_bind (priv->settings, "show-words",
|
||||
priv->sidebar, "reveal-child",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
g_object_bind_property (win->search, "active",
|
||||
win->searchbar, "search-mode-enabled",
|
||||
g_object_bind_property (priv->search, "active",
|
||||
priv->searchbar, "search-mode-enabled",
|
||||
G_BINDING_BIDIRECTIONAL);
|
||||
|
||||
g_signal_connect (win->sidebar, "notify::reveal-child",
|
||||
g_signal_connect (priv->sidebar, "notify::reveal-child",
|
||||
G_CALLBACK (words_changed), win);
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/gears-menu.ui");
|
||||
menu = G_MENU_MODEL (gtk_builder_get_object (builder, "menu"));
|
||||
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (win->gears), menu);
|
||||
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (priv->gears), menu);
|
||||
g_object_unref (builder);
|
||||
|
||||
action = g_settings_create_action (win->settings, "show-words");
|
||||
action = g_settings_create_action (priv->settings, "show-words");
|
||||
g_action_map_add_action (G_ACTION_MAP (win), action);
|
||||
g_object_unref (action);
|
||||
}
|
||||
@@ -174,10 +197,12 @@ static void
|
||||
example_app_window_dispose (GObject *object)
|
||||
{
|
||||
ExampleAppWindow *win;
|
||||
ExampleAppWindowPrivate *priv;
|
||||
|
||||
win = EXAMPLE_APP_WINDOW (object);
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
|
||||
g_clear_object (&win->settings);
|
||||
g_clear_object (&priv->settings);
|
||||
|
||||
G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
|
||||
}
|
||||
@@ -190,13 +215,13 @@ example_app_window_class_init (ExampleAppWindowClass *class)
|
||||
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
|
||||
"/org/gtk/exampleapp/window.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchentry);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, gears);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, words);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, sidebar);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchentry);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, gears);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, words);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, sidebar);
|
||||
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), search_text_changed);
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), visible_child_changed);
|
||||
@@ -213,6 +238,7 @@ void
|
||||
example_app_window_open (ExampleAppWindow *win,
|
||||
GFile *file)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
gchar *basename;
|
||||
GtkWidget *scrolled, *view;
|
||||
gchar *contents;
|
||||
@@ -221,16 +247,19 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
GtkTextTag *tag;
|
||||
GtkTextIter start_iter, end_iter;
|
||||
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
basename = g_file_get_basename (file);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_show (scrolled);
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_widget_show (view);
|
||||
gtk_container_add (GTK_CONTAINER (scrolled), view);
|
||||
gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
|
||||
gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
@@ -241,7 +270,7 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
}
|
||||
|
||||
tag = gtk_text_buffer_create_tag (buffer, NULL, NULL);
|
||||
g_settings_bind (win->settings, "font",
|
||||
g_settings_bind (priv->settings, "font",
|
||||
tag, "font",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
@@ -251,7 +280,7 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
|
||||
g_free (basename);
|
||||
|
||||
gtk_widget_set_sensitive (win->search, TRUE);
|
||||
gtk_widget_set_sensitive (priv->search, TRUE);
|
||||
|
||||
update_words (win);
|
||||
}
|
||||
|
@@ -18,7 +18,14 @@
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="search">
|
||||
<property name="sensitive">0</property>
|
||||
<property name="icon-name">edit-find-symbolic</property>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkImage" id="search-icon">
|
||||
<property name="icon-name">edit-find-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">end</property>
|
||||
|
@@ -7,36 +7,43 @@
|
||||
struct _ExampleAppPrefs
|
||||
{
|
||||
GtkDialog parent;
|
||||
};
|
||||
|
||||
typedef struct _ExampleAppPrefsPrivate ExampleAppPrefsPrivate;
|
||||
|
||||
struct _ExampleAppPrefsPrivate
|
||||
{
|
||||
GSettings *settings;
|
||||
GtkWidget *font;
|
||||
GtkWidget *transition;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
|
||||
|
||||
static void
|
||||
example_app_prefs_init (ExampleAppPrefs *prefs)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (prefs));
|
||||
prefs->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
ExampleAppPrefsPrivate *priv;
|
||||
|
||||
g_settings_bind (prefs->settings, "font",
|
||||
prefs->font, "font",
|
||||
priv = example_app_prefs_get_instance_private (prefs);
|
||||
gtk_widget_init_template (GTK_WIDGET (prefs));
|
||||
priv->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
|
||||
g_settings_bind (priv->settings, "font",
|
||||
priv->font, "font",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
g_settings_bind (prefs->settings, "transition",
|
||||
prefs->transition, "active-id",
|
||||
g_settings_bind (priv->settings, "transition",
|
||||
priv->transition, "active-id",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
}
|
||||
|
||||
static void
|
||||
example_app_prefs_dispose (GObject *object)
|
||||
{
|
||||
ExampleAppPrefs *prefs;
|
||||
ExampleAppPrefsPrivate *priv;
|
||||
|
||||
prefs = EXAMPLE_APP_PREFS (object);
|
||||
|
||||
g_clear_object (&prefs->settings);
|
||||
priv = example_app_prefs_get_instance_private (EXAMPLE_APP_PREFS (object));
|
||||
g_clear_object (&priv->settings);
|
||||
|
||||
G_OBJECT_CLASS (example_app_prefs_parent_class)->dispose (object);
|
||||
}
|
||||
@@ -48,8 +55,8 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
|
||||
|
||||
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
|
||||
"/org/gtk/exampleapp/prefs.ui");
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
|
||||
}
|
||||
|
||||
ExampleAppPrefs *
|
||||
|
@@ -6,7 +6,12 @@
|
||||
struct _ExampleAppWindow
|
||||
{
|
||||
GtkApplicationWindow parent;
|
||||
};
|
||||
|
||||
typedef struct _ExampleAppWindowPrivate ExampleAppWindowPrivate;
|
||||
|
||||
struct _ExampleAppWindowPrivate
|
||||
{
|
||||
GSettings *settings;
|
||||
GtkWidget *stack;
|
||||
GtkWidget *search;
|
||||
@@ -19,12 +24,13 @@ struct _ExampleAppWindow
|
||||
GtkWidget *lines_label;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
|
||||
|
||||
static void
|
||||
search_text_changed (GtkEntry *entry,
|
||||
ExampleAppWindow *win)
|
||||
search_text_changed (GtkEntry *entry)
|
||||
{
|
||||
ExampleAppWindow *win;
|
||||
ExampleAppWindowPrivate *priv;
|
||||
const gchar *text;
|
||||
GtkWidget *tab;
|
||||
GtkWidget *view;
|
||||
@@ -36,7 +42,10 @@ search_text_changed (GtkEntry *entry,
|
||||
if (text[0] == '\0')
|
||||
return;
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
|
||||
win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (entry)));
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
|
||||
view = gtk_bin_get_child (GTK_BIN (tab));
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
@@ -55,15 +64,19 @@ static void
|
||||
find_word (GtkButton *button,
|
||||
ExampleAppWindow *win)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
const gchar *word;
|
||||
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
|
||||
word = gtk_button_get_label (button);
|
||||
gtk_entry_set_text (GTK_ENTRY (win->searchentry), word);
|
||||
gtk_entry_set_text (GTK_ENTRY (priv->searchentry), word);
|
||||
}
|
||||
|
||||
static void
|
||||
update_words (ExampleAppWindow *win)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
GHashTable *strings;
|
||||
GHashTableIter iter;
|
||||
GtkWidget *tab, *view, *row;
|
||||
@@ -72,7 +85,9 @@ update_words (ExampleAppWindow *win)
|
||||
GList *children, *l;
|
||||
gchar *word, *key;
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
|
||||
|
||||
if (tab == NULL)
|
||||
return;
|
||||
@@ -100,9 +115,9 @@ update_words (ExampleAppWindow *win)
|
||||
}
|
||||
|
||||
done:
|
||||
children = gtk_container_get_children (GTK_CONTAINER (win->words));
|
||||
children = gtk_container_get_children (GTK_CONTAINER (priv->words));
|
||||
for (l = children; l; l = l->next)
|
||||
gtk_container_remove (GTK_CONTAINER (win->words), GTK_WIDGET (l->data));
|
||||
gtk_container_remove (GTK_CONTAINER (priv->words), GTK_WIDGET (l->data));
|
||||
g_list_free (children);
|
||||
|
||||
g_hash_table_iter_init (&iter, strings);
|
||||
@@ -111,7 +126,8 @@ done:
|
||||
row = gtk_button_new_with_label (key);
|
||||
g_signal_connect (row, "clicked",
|
||||
G_CALLBACK (find_word), win);
|
||||
gtk_container_add (GTK_CONTAINER (win->words), row);
|
||||
gtk_widget_show (row);
|
||||
gtk_container_add (GTK_CONTAINER (priv->words), row);
|
||||
}
|
||||
|
||||
g_hash_table_unref (strings);
|
||||
@@ -120,12 +136,16 @@ done:
|
||||
static void
|
||||
update_lines (ExampleAppWindow *win)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
GtkWidget *tab, *view;
|
||||
GtkTextBuffer *buffer;
|
||||
GtkTextIter iter;
|
||||
int count;
|
||||
gchar *lines;
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
|
||||
|
||||
if (tab == NULL)
|
||||
return;
|
||||
@@ -133,21 +153,34 @@ update_lines (ExampleAppWindow *win)
|
||||
view = gtk_bin_get_child (GTK_BIN (tab));
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
count = gtk_text_buffer_get_line_count (buffer);
|
||||
count = 0;
|
||||
|
||||
gtk_text_buffer_get_start_iter (buffer, &iter);
|
||||
while (!gtk_text_iter_is_end (&iter))
|
||||
{
|
||||
count++;
|
||||
if (!gtk_text_iter_forward_line (&iter))
|
||||
break;
|
||||
}
|
||||
|
||||
lines = g_strdup_printf ("%d", count);
|
||||
gtk_label_set_text (GTK_LABEL (win->lines), lines);
|
||||
gtk_label_set_text (GTK_LABEL (priv->lines), lines);
|
||||
g_free (lines);
|
||||
}
|
||||
|
||||
static void
|
||||
visible_child_changed (GObject *stack,
|
||||
GParamSpec *pspec,
|
||||
ExampleAppWindow *win)
|
||||
visible_child_changed (GObject *stack,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ExampleAppWindow *win;
|
||||
ExampleAppWindowPrivate *priv;
|
||||
|
||||
if (gtk_widget_in_destruction (GTK_WIDGET (stack)))
|
||||
return;
|
||||
|
||||
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (win->searchbar), FALSE);
|
||||
win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (stack)));
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (priv->searchbar), FALSE);
|
||||
update_words (win);
|
||||
update_lines (win);
|
||||
}
|
||||
@@ -163,43 +196,45 @@ words_changed (GObject *sidebar,
|
||||
static void
|
||||
example_app_window_init (ExampleAppWindow *win)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
GtkBuilder *builder;
|
||||
GMenuModel *menu;
|
||||
GAction *action;
|
||||
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
gtk_widget_init_template (GTK_WIDGET (win));
|
||||
win->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
priv->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
|
||||
g_settings_bind (win->settings, "transition",
|
||||
win->stack, "transition-type",
|
||||
g_settings_bind (priv->settings, "transition",
|
||||
priv->stack, "transition-type",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
g_settings_bind (win->settings, "show-words",
|
||||
win->sidebar, "reveal-child",
|
||||
g_settings_bind (priv->settings, "show-words",
|
||||
priv->sidebar, "reveal-child",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
g_object_bind_property (win->search, "active",
|
||||
win->searchbar, "search-mode-enabled",
|
||||
g_object_bind_property (priv->search, "active",
|
||||
priv->searchbar, "search-mode-enabled",
|
||||
G_BINDING_BIDIRECTIONAL);
|
||||
|
||||
g_signal_connect (win->sidebar, "notify::reveal-child",
|
||||
g_signal_connect (priv->sidebar, "notify::reveal-child",
|
||||
G_CALLBACK (words_changed), win);
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/gears-menu.ui");
|
||||
menu = G_MENU_MODEL (gtk_builder_get_object (builder, "menu"));
|
||||
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (win->gears), menu);
|
||||
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (priv->gears), menu);
|
||||
g_object_unref (builder);
|
||||
|
||||
action = g_settings_create_action (win->settings, "show-words");
|
||||
action = g_settings_create_action (priv->settings, "show-words");
|
||||
g_action_map_add_action (G_ACTION_MAP (win), action);
|
||||
g_object_unref (action);
|
||||
|
||||
action = (GAction*) g_property_action_new ("show-lines", win->lines, "visible");
|
||||
action = (GAction*) g_property_action_new ("show-lines", priv->lines, "visible");
|
||||
g_action_map_add_action (G_ACTION_MAP (win), action);
|
||||
g_object_unref (action);
|
||||
|
||||
g_object_bind_property (win->lines, "visible",
|
||||
win->lines_label, "visible",
|
||||
g_object_bind_property (priv->lines, "visible",
|
||||
priv->lines_label, "visible",
|
||||
G_BINDING_DEFAULT);
|
||||
}
|
||||
|
||||
@@ -207,10 +242,12 @@ static void
|
||||
example_app_window_dispose (GObject *object)
|
||||
{
|
||||
ExampleAppWindow *win;
|
||||
ExampleAppWindowPrivate *priv;
|
||||
|
||||
win = EXAMPLE_APP_WINDOW (object);
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
|
||||
g_clear_object (&win->settings);
|
||||
g_clear_object (&priv->settings);
|
||||
|
||||
G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
|
||||
}
|
||||
@@ -223,15 +260,15 @@ example_app_window_class_init (ExampleAppWindowClass *class)
|
||||
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
|
||||
"/org/gtk/exampleapp/window.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchentry);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, gears);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, words);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, sidebar);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, lines);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, lines_label);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchentry);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, gears);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, words);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, sidebar);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, lines);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, lines_label);
|
||||
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), search_text_changed);
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), visible_child_changed);
|
||||
@@ -247,6 +284,7 @@ void
|
||||
example_app_window_open (ExampleAppWindow *win,
|
||||
GFile *file)
|
||||
{
|
||||
ExampleAppWindowPrivate *priv;
|
||||
gchar *basename;
|
||||
GtkWidget *scrolled, *view;
|
||||
gchar *contents;
|
||||
@@ -255,16 +293,19 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
GtkTextTag *tag;
|
||||
GtkTextIter start_iter, end_iter;
|
||||
|
||||
priv = example_app_window_get_instance_private (win);
|
||||
basename = g_file_get_basename (file);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_show (scrolled);
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_widget_show (view);
|
||||
gtk_container_add (GTK_CONTAINER (scrolled), view);
|
||||
gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
|
||||
gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
@@ -275,7 +316,7 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
}
|
||||
|
||||
tag = gtk_text_buffer_create_tag (buffer, NULL, NULL);
|
||||
g_settings_bind (win->settings, "font",
|
||||
g_settings_bind (priv->settings, "font",
|
||||
tag, "font",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
@@ -285,7 +326,7 @@ example_app_window_open (ExampleAppWindow *win,
|
||||
|
||||
g_free (basename);
|
||||
|
||||
gtk_widget_set_sensitive (win->search, TRUE);
|
||||
gtk_widget_set_sensitive (priv->search, TRUE);
|
||||
|
||||
update_words (win);
|
||||
update_lines (win);
|
||||
|
@@ -29,7 +29,14 @@
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="search">
|
||||
<property name="sensitive">0</property>
|
||||
<property name="icon-name">edit-find-symbolic</property>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkImage" id="search-icon">
|
||||
<property name="icon-name">edit-find-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">end</property>
|
||||
|
@@ -1,5 +1,16 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static gboolean
|
||||
window_key_pressed (GtkEventController *controller,
|
||||
guint keyval,
|
||||
guint keycode,
|
||||
GdkModifierType state,
|
||||
GtkSearchBar *search_bar)
|
||||
{
|
||||
return gtk_search_bar_handle_event (search_bar,
|
||||
gtk_get_current_event ());
|
||||
}
|
||||
|
||||
static void
|
||||
activate_cb (GtkApplication *app,
|
||||
gpointer user_data)
|
||||
@@ -9,12 +20,12 @@ activate_cb (GtkApplication *app,
|
||||
GtkWidget *box;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *menu_button;
|
||||
GtkEventController *controller;
|
||||
|
||||
window = gtk_application_window_new (app);
|
||||
gtk_widget_show (window);
|
||||
|
||||
search_bar = gtk_search_bar_new ();
|
||||
gtk_widget_set_valign (search_bar, GTK_ALIGN_START);
|
||||
gtk_container_add (GTK_CONTAINER (window), search_bar);
|
||||
gtk_widget_show (search_bar);
|
||||
|
||||
@@ -29,7 +40,12 @@ activate_cb (GtkApplication *app,
|
||||
gtk_box_pack_start (GTK_BOX (box), menu_button);
|
||||
|
||||
gtk_search_bar_connect_entry (GTK_SEARCH_BAR (search_bar), GTK_ENTRY (entry));
|
||||
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (search_bar), window);
|
||||
|
||||
controller = gtk_event_controller_key_new ();
|
||||
g_object_set_data_full (G_OBJECT (window), "controller", controller, g_object_unref);
|
||||
g_signal_connect (controller, "key-pressed",
|
||||
G_CALLBACK (window_key_pressed), search_bar);
|
||||
gtk_widget_add_controller (window, controller);
|
||||
}
|
||||
|
||||
gint
|
||||
|
@@ -61,6 +61,9 @@ static GdkSurface * gdk_broadway_device_surface_at_position (GdkDevice *de
|
||||
gdouble *win_y,
|
||||
GdkModifierType *mask,
|
||||
gboolean get_toplevel);
|
||||
static void gdk_broadway_device_select_surface_events (GdkDevice *device,
|
||||
GdkSurface *surface,
|
||||
GdkEventMask event_mask);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GdkBroadwayDevice, gdk_broadway_device, GDK_TYPE_DEVICE)
|
||||
@@ -78,6 +81,7 @@ gdk_broadway_device_class_init (GdkBroadwayDeviceClass *klass)
|
||||
device_class->grab = gdk_broadway_device_grab;
|
||||
device_class->ungrab = gdk_broadway_device_ungrab;
|
||||
device_class->surface_at_position = gdk_broadway_device_surface_at_position;
|
||||
device_class->select_surface_events = gdk_broadway_device_select_surface_events;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -321,3 +325,9 @@ gdk_broadway_device_surface_at_position (GdkDevice *device,
|
||||
return surface;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_device_select_surface_events (GdkDevice *device,
|
||||
GdkSurface *surface,
|
||||
GdkEventMask event_mask)
|
||||
{
|
||||
}
|
||||
|
@@ -49,6 +49,9 @@ struct _GdkBroadwayDisplay
|
||||
/* Keyboard related information */
|
||||
GdkKeymap *keymap;
|
||||
|
||||
/* drag and drop information */
|
||||
GdkDragContext *current_dest_drag;
|
||||
|
||||
GdkBroadwayServer *server;
|
||||
|
||||
gpointer move_resize_data;
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkdragprivate.h"
|
||||
#include "gdkdndprivate.h"
|
||||
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkproperty.h"
|
||||
@@ -34,56 +34,56 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define GDK_TYPE_BROADWAY_DRAG (gdk_broadway_drag_get_type ())
|
||||
#define GDK_BROADWAY_DRAG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_BROADWAY_DRAG, GdkBroadwayDrag))
|
||||
#define GDK_BROADWAY_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_BROADWAY_DRAG, GdkBroadwayDragClass))
|
||||
#define GDK_IS_BROADWAY_DRAG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_BROADWAY_DRAG))
|
||||
#define GDK_IS_BROADWAY_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_BROADWAY_DRAG))
|
||||
#define GDK_BROADWAY_DRAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_BROADWAY_DRAG, GdkBroadwayDragClass))
|
||||
#define GDK_TYPE_BROADWAY_DRAG_CONTEXT (gdk_broadway_drag_context_get_type ())
|
||||
#define GDK_BROADWAY_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_BROADWAY_DRAG_CONTEXT, GdkBroadwayDragContext))
|
||||
#define GDK_BROADWAY_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_BROADWAY_DRAG_CONTEXT, GdkBroadwayDragContextClass))
|
||||
#define GDK_IS_BROADWAY_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_BROADWAY_DRAG_CONTEXT))
|
||||
#define GDK_IS_BROADWAY_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_BROADWAY_DRAG_CONTEXT))
|
||||
#define GDK_BROADWAY_DRAG_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_BROADWAY_DRAG_CONTEXT, GdkBroadwayDragContextClass))
|
||||
|
||||
#ifdef GDK_COMPILATION
|
||||
typedef struct _GdkBroadwayDrag GdkBroadwayDrag;
|
||||
typedef struct _GdkBroadwayDragContext GdkBroadwayDragContext;
|
||||
#else
|
||||
typedef GdkDrag GdkBroadwayDrag;
|
||||
typedef GdkDragContext GdkBroadwayDragContext;
|
||||
#endif
|
||||
typedef struct _GdkBroadwayDragClass GdkBroadwayDragClass;
|
||||
typedef struct _GdkBroadwayDragContextClass GdkBroadwayDragContextClass;
|
||||
|
||||
GType gdk_broadway_drag_get_type (void);
|
||||
GType gdk_broadway_drag_context_get_type (void);
|
||||
|
||||
struct _GdkBroadwayDrag {
|
||||
GdkDrag context;
|
||||
struct _GdkBroadwayDragContext {
|
||||
GdkDragContext context;
|
||||
};
|
||||
|
||||
struct _GdkBroadwayDragClass
|
||||
struct _GdkBroadwayDragContextClass
|
||||
{
|
||||
GdkDragClass parent_class;
|
||||
GdkDragContextClass parent_class;
|
||||
};
|
||||
|
||||
static void gdk_broadway_drag_finalize (GObject *object);
|
||||
static void gdk_broadway_drag_context_finalize (GObject *object);
|
||||
|
||||
static GList *contexts;
|
||||
|
||||
G_DEFINE_TYPE (GdkBroadwayDrag, gdk_broadway_drag, GDK_TYPE_DRAG)
|
||||
G_DEFINE_TYPE (GdkBroadwayDragContext, gdk_broadway_drag_context, GDK_TYPE_DRAG_CONTEXT)
|
||||
|
||||
static void
|
||||
gdk_broadway_drag_init (GdkBroadwayDrag *dragcontext)
|
||||
gdk_broadway_drag_context_init (GdkBroadwayDragContext *dragcontext)
|
||||
{
|
||||
contexts = g_list_prepend (contexts, dragcontext);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_drag_finalize (GObject *object)
|
||||
gdk_broadway_drag_context_finalize (GObject *object)
|
||||
{
|
||||
GdkDrag *context = GDK_DRAG (object);
|
||||
GdkDragContext *context = GDK_DRAG_CONTEXT (object);
|
||||
|
||||
contexts = g_list_remove (contexts, context);
|
||||
|
||||
G_OBJECT_CLASS (gdk_broadway_drag_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (gdk_broadway_drag_context_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
/* Drag Contexts */
|
||||
|
||||
GdkDrag *
|
||||
GdkDragContext *
|
||||
_gdk_broadway_surface_drag_begin (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkContentProvider *content,
|
||||
@@ -91,12 +91,12 @@ _gdk_broadway_surface_drag_begin (GdkSurface *surface,
|
||||
gint dx,
|
||||
gint dy)
|
||||
{
|
||||
GdkDrag *new_context;
|
||||
GdkDragContext *new_context;
|
||||
|
||||
g_return_val_if_fail (surface != NULL, NULL);
|
||||
g_return_val_if_fail (GDK_SURFACE_IS_BROADWAY (surface), NULL);
|
||||
|
||||
new_context = g_object_new (GDK_TYPE_BROADWAY_DRAG,
|
||||
new_context = g_object_new (GDK_TYPE_BROADWAY_DRAG_CONTEXT,
|
||||
"device", device,
|
||||
"content", content,
|
||||
NULL);
|
||||
@@ -104,6 +104,38 @@ _gdk_broadway_surface_drag_begin (GdkSurface *surface,
|
||||
return new_context;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_drag_context_drag_drop (GdkDragContext *context,
|
||||
guint32 time)
|
||||
{
|
||||
g_return_if_fail (context != NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_drag_context_drag_abort (GdkDragContext *context,
|
||||
guint32 time)
|
||||
{
|
||||
g_return_if_fail (context != NULL);
|
||||
}
|
||||
|
||||
/* Destination side */
|
||||
|
||||
static void
|
||||
gdk_broadway_drag_context_drag_status (GdkDragContext *context,
|
||||
GdkDragAction action,
|
||||
guint32 time)
|
||||
{
|
||||
g_return_if_fail (context != NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_drag_context_drop_finish (GdkDragContext *context,
|
||||
gboolean success,
|
||||
guint32 time)
|
||||
{
|
||||
g_return_if_fail (context != NULL);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_broadway_surface_register_dnd (GdkSurface *surface)
|
||||
{
|
||||
@@ -115,9 +147,15 @@ _gdk_broadway_display_init_dnd (GdkDisplay *display)
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_drag_class_init (GdkBroadwayDragClass *klass)
|
||||
gdk_broadway_drag_context_class_init (GdkBroadwayDragContextClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GdkDragContextClass *context_class = GDK_DRAG_CONTEXT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gdk_broadway_drag_finalize;
|
||||
object_class->finalize = gdk_broadway_drag_context_finalize;
|
||||
|
||||
context_class->drag_status = gdk_broadway_drag_context_drag_status;
|
||||
context_class->drag_abort = gdk_broadway_drag_context_drag_abort;
|
||||
context_class->drag_drop = gdk_broadway_drag_context_drag_drop;
|
||||
context_class->drop_finish = gdk_broadway_drag_context_drop_finish;
|
||||
}
|
||||
|
@@ -285,6 +285,7 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message)
|
||||
event->key.state = message->key.state;
|
||||
event->key.hardware_keycode = message->key.key;
|
||||
gdk_event_set_scancode (event, message->key.key);
|
||||
event->key.length = 0;
|
||||
gdk_event_set_device (event, gdk_seat_get_keyboard (seat));
|
||||
|
||||
node = _gdk_event_queue_append (display, event);
|
||||
@@ -382,7 +383,7 @@ gdk_event_source_dispatch (GSource *source,
|
||||
{
|
||||
_gdk_event_emit (event);
|
||||
|
||||
g_object_unref (event);
|
||||
gdk_event_free (event);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@@ -46,7 +46,7 @@ void gdk_broadway_surface_set_nodes (GdkSurface *surface,
|
||||
GPtrArray *node_textures);
|
||||
|
||||
void _gdk_broadway_surface_register_dnd (GdkSurface *surface);
|
||||
GdkDrag * _gdk_broadway_surface_drag_begin (GdkSurface *surface,
|
||||
GdkDragContext * _gdk_broadway_surface_drag_begin (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkContentProvider *content,
|
||||
GdkDragAction actions,
|
||||
@@ -101,6 +101,7 @@ void _gdk_broadway_display_get_maximal_cursor_size (GdkDisplay *display,
|
||||
void _gdk_broadway_display_create_surface_impl (GdkDisplay *display,
|
||||
GdkSurface *surface,
|
||||
GdkSurface *real_parent,
|
||||
GdkEventMask event_mask,
|
||||
GdkSurfaceAttr *attributes);
|
||||
gint _gdk_broadway_display_text_property_to_utf8_list (GdkDisplay *display,
|
||||
GdkAtom encoding,
|
||||
|
@@ -207,6 +207,7 @@ void
|
||||
_gdk_broadway_display_create_surface_impl (GdkDisplay *display,
|
||||
GdkSurface *surface,
|
||||
GdkSurface *real_parent,
|
||||
GdkEventMask event_mask,
|
||||
GdkSurfaceAttr *attributes)
|
||||
{
|
||||
GdkSurfaceImplBroadway *impl;
|
||||
@@ -322,7 +323,11 @@ gdk_surface_broadway_show (GdkSurface *surface,
|
||||
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
||||
impl->visible = TRUE;
|
||||
|
||||
/* FIXME: update state ? */
|
||||
if (surface->event_mask & GDK_STRUCTURE_MASK)
|
||||
_gdk_make_event (GDK_SURFACE (surface), GDK_MAP, NULL, FALSE);
|
||||
|
||||
if (surface->parent && surface->parent->event_mask & GDK_SUBSTRUCTURE_MASK)
|
||||
_gdk_make_event (GDK_SURFACE (surface), GDK_MAP, NULL, FALSE);
|
||||
|
||||
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
|
||||
if (_gdk_broadway_server_surface_show (broadway_display->server, impl->id))
|
||||
@@ -339,7 +344,11 @@ gdk_surface_broadway_hide (GdkSurface *surface)
|
||||
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
||||
impl->visible = FALSE;
|
||||
|
||||
/* FIXME: update state ? */
|
||||
if (surface->event_mask & GDK_STRUCTURE_MASK)
|
||||
_gdk_make_event (GDK_SURFACE (surface), GDK_UNMAP, NULL, FALSE);
|
||||
|
||||
if (surface->parent && surface->parent->event_mask & GDK_SUBSTRUCTURE_MASK)
|
||||
_gdk_make_event (GDK_SURFACE (surface), GDK_UNMAP, NULL, FALSE);
|
||||
|
||||
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
|
||||
|
||||
@@ -611,6 +620,24 @@ gdk_surface_broadway_get_device_state (GdkSurface *surface,
|
||||
return child != NULL;
|
||||
}
|
||||
|
||||
static GdkEventMask
|
||||
gdk_surface_broadway_get_events (GdkSurface *surface)
|
||||
{
|
||||
if (GDK_SURFACE_DESTROYED (surface))
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_surface_broadway_set_events (GdkSurface *surface,
|
||||
GdkEventMask event_mask)
|
||||
{
|
||||
if (!GDK_SURFACE_DESTROYED (surface))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_surface_broadway_input_shape_combine_region (GdkSurface *surface,
|
||||
const cairo_region_t *shape_region,
|
||||
@@ -1332,6 +1359,8 @@ gdk_surface_impl_broadway_class_init (GdkSurfaceImplBroadwayClass *klass)
|
||||
impl_class->show = gdk_surface_broadway_show;
|
||||
impl_class->hide = gdk_surface_broadway_hide;
|
||||
impl_class->withdraw = gdk_surface_broadway_withdraw;
|
||||
impl_class->set_events = gdk_surface_broadway_set_events;
|
||||
impl_class->get_events = gdk_surface_broadway_get_events;
|
||||
impl_class->raise = gdk_surface_broadway_raise;
|
||||
impl_class->lower = gdk_surface_broadway_lower;
|
||||
impl_class->restack_toplevel = gdk_surface_broadway_restack_toplevel;
|
||||
|
@@ -43,19 +43,8 @@ clienthtml_h = custom_target('clienthtml.h',
|
||||
],
|
||||
)
|
||||
|
||||
broadwayjs_h = custom_target('broadwayjs.h',
|
||||
input : ['broadway.js'],
|
||||
output : 'broadwayjs.h',
|
||||
command : [
|
||||
gen_c_array,
|
||||
'--array-name=broadway_js',
|
||||
'--output=@OUTPUT@',
|
||||
'@INPUT0@',
|
||||
],
|
||||
)
|
||||
|
||||
libgdk_broadway = static_library('gdk-broadway',
|
||||
clienthtml_h, broadwayjs_h,
|
||||
clienthtml_h,
|
||||
gdk_broadway_sources, gdkconfig, gdkenum_h,
|
||||
include_directories: [confinc, gdkinc],
|
||||
c_args: [
|
||||
@@ -69,6 +58,17 @@ libgdk_broadway = static_library('gdk-broadway',
|
||||
|
||||
broadwayd_syslib = os_win32 ? find_library('ws2_32') : shmlib
|
||||
|
||||
broadwayjs_h = custom_target('broadwayjs.h',
|
||||
input : ['broadway.js'],
|
||||
output : 'broadwayjs.h',
|
||||
command : [
|
||||
gen_c_array,
|
||||
'--array-name=broadway_js',
|
||||
'--output=@OUTPUT@',
|
||||
'@INPUT0@',
|
||||
],
|
||||
)
|
||||
|
||||
executable('gtk4-broadwayd',
|
||||
clienthtml_h, broadwayjs_h,
|
||||
'broadwayd.c', 'broadway-server.c', 'broadway-output.c',
|
||||
|
@@ -23,12 +23,12 @@
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkAppLaunchContext, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkClipboard, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkContentProvider, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkCursor, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDevice, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDisplay, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDisplayManager, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDrag, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDragContext, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDrawingContext, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDrawContext, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkFrameClock, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkGLContext, g_object_unref)
|
||||
@@ -39,7 +39,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkVulkanContext, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkSurface, g_object_unref)
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkContentFormats, gdk_content_formats_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkEvent, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkEvent, gdk_event_free)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkFrameTimings, gdk_frame_timings_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkRGBA, gdk_rgba_free)
|
||||
|
||||
|
@@ -20,6 +20,14 @@ void gdk_surface_thaw_toplevel_updates (GdkSurface *surface);
|
||||
|
||||
gboolean gdk_surface_supports_edge_constraints (GdkSurface *surface);
|
||||
|
||||
void gdk_surface_move_to_rect (GdkSurface *surface,
|
||||
const GdkRectangle *rect,
|
||||
GdkGravity rect_anchor,
|
||||
GdkGravity surface_anchor,
|
||||
GdkAnchorHints anchor_hints,
|
||||
gint rect_anchor_dx,
|
||||
gint rect_anchor_dy);
|
||||
|
||||
GObject * gdk_event_get_user_data (const GdkEvent *event);
|
||||
|
||||
guint32 gdk_display_get_last_seen_time (GdkDisplay *display);
|
||||
@@ -31,9 +39,5 @@ void gdk_display_set_double_click_distance (GdkDisplay *display,
|
||||
void gdk_display_set_cursor_theme (GdkDisplay *display,
|
||||
const char *theme,
|
||||
int size);
|
||||
gboolean gdk_running_in_sandbox (void);
|
||||
gboolean gdk_should_use_portal (void);
|
||||
|
||||
const gchar * gdk_get_startup_notification_id (void);
|
||||
|
||||
#endif /* __GDK__PRIVATE_H__ */
|
||||
|
77
gdk/gdk.c
77
gdk/gdk.c
@@ -154,36 +154,6 @@ static const GDebugKey gdk_debug_keys[] = {
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef G_HAS_CONSTRUCTORS
|
||||
#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
|
||||
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(stash_desktop_startup_notification_id)
|
||||
#endif
|
||||
G_DEFINE_CONSTRUCTOR(stash_desktop_startup_notification_id)
|
||||
#endif
|
||||
|
||||
static gchar *startup_notification_id = NULL;
|
||||
|
||||
static void
|
||||
stash_desktop_startup_notification_id (void)
|
||||
{
|
||||
const char *desktop_startup_id;
|
||||
|
||||
desktop_startup_id = g_getenv ("DESKTOP_STARTUP_ID");
|
||||
if (desktop_startup_id && *desktop_startup_id != '\0')
|
||||
{
|
||||
if (!g_utf8_validate (desktop_startup_id, -1, NULL))
|
||||
g_warning ("DESKTOP_STARTUP_ID contains invalid UTF-8");
|
||||
else
|
||||
startup_notification_id = g_strdup (desktop_startup_id ? desktop_startup_id : "");
|
||||
}
|
||||
|
||||
/* Clear the environment variable so it won't be inherited by
|
||||
* child processes and confuse things.
|
||||
*/
|
||||
g_unsetenv ("DESKTOP_STARTUP_ID");
|
||||
}
|
||||
|
||||
static gpointer
|
||||
register_resources (gpointer dummy G_GNUC_UNUSED)
|
||||
{
|
||||
@@ -216,10 +186,6 @@ gdk_pre_parse (void)
|
||||
G_N_ELEMENTS (gdk_debug_keys));
|
||||
}
|
||||
#endif /* G_ENABLE_DEBUG */
|
||||
|
||||
#ifndef G_HAS_CONSTRUCTORS
|
||||
stash_desktop_startup_notification_id ();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*< private >
|
||||
@@ -250,48 +216,6 @@ gdk_display_open_default (void)
|
||||
return display;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
*
|
||||
* gdk_get_startup_notification_id
|
||||
*
|
||||
* Returns the original value of the DESKTOP_STARTUP_ID environment
|
||||
* variable if it was defined and valid, or %NULL otherwise.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the original value of the
|
||||
* DESKTOP_STARTUP_ID environment variable, or %NULL.
|
||||
*/
|
||||
const gchar *
|
||||
gdk_get_startup_notification_id (void)
|
||||
{
|
||||
return startup_notification_id;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_running_in_sandbox (void)
|
||||
{
|
||||
return g_file_test ("/.flatpak-info", G_FILE_TEST_EXISTS);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_should_use_portal (void)
|
||||
{
|
||||
static const char *use_portal = NULL;
|
||||
|
||||
if (G_UNLIKELY (use_portal == NULL))
|
||||
{
|
||||
if (gdk_running_in_sandbox ())
|
||||
use_portal = "1";
|
||||
else
|
||||
{
|
||||
use_portal = g_getenv ("GTK_USE_PORTAL");
|
||||
if (!use_portal)
|
||||
use_portal = "";
|
||||
}
|
||||
}
|
||||
|
||||
return use_portal[0] == '1';
|
||||
}
|
||||
|
||||
/**
|
||||
* SECTION:threads
|
||||
* @Short_description: Functions for using GDK in multi-threaded programs
|
||||
@@ -342,4 +266,3 @@ gdk_should_use_portal (void)
|
||||
* expensive tasks from worker threads, and will handle thread
|
||||
* management for you.
|
||||
*/
|
||||
|
||||
|
@@ -44,9 +44,8 @@
|
||||
#include <gdk/gdkdevicetool.h>
|
||||
#include <gdk/gdkdisplay.h>
|
||||
#include <gdk/gdkdisplaymanager.h>
|
||||
#include <gdk/gdkdrag.h>
|
||||
#include <gdk/gdkdnd.h>
|
||||
#include <gdk/gdkdrawcontext.h>
|
||||
#include <gdk/gdkdrop.h>
|
||||
#include <gdk/gdkenumtypes.h>
|
||||
#include <gdk/gdkevents.h>
|
||||
#include <gdk/gdkframeclock.h>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user