Compare commits

..

2 Commits

Author SHA1 Message Date
Matthias Clasen eccbd4fe5f gizmo: Set the name
This helps with debugging.
2019-05-04 18:20:27 +00:00
Matthias Clasen 3b967f1242 widget: Improve warning messages
When we print warnings about a widget, using
gtk_widget_get_name() is slightly better than
G_OBJECT_TYPE_NAME(), since it will give us
the widgets unique name when available.
2019-05-04 18:20:20 +00:00
309 changed files with 6182 additions and 15132 deletions
+2 -2
View File
@@ -13,7 +13,7 @@ stages:
- subprojects/pango/
fedora-x86_64:
image: registry.gitlab.gnome.org/gnome/gtk/master:v6
image: registry.gitlab.gnome.org/gnome/gtk/master:v5
stage: build
script:
- bash -x ./.gitlab-ci/test-docker.sh
@@ -101,7 +101,7 @@ flatpak-master:icon-browser:
<<: *flatpak-master
pages:
image: registry.gitlab.gnome.org/gnome/gtk/master:v6
image: registry.gitlab.gnome.org/gnome/gtk/master:v4
stage: deploy
script:
- meson -Ddocumentation=true _build .
+4 -4
View File
@@ -1,4 +1,4 @@
FROM fedora:30
FROM fedora:29
RUN dnf -y install \
hicolor-icon-theme \
@@ -11,7 +11,6 @@ RUN dnf -y install \
ccache \
colord-devel \
cups-devel \
dbus-daemon \
dejavu-sans-mono-fonts \
desktop-file-utils \
elfutils-libelf-devel \
@@ -60,7 +59,6 @@ RUN dnf -y install \
pango-devel \
pcre-devel \
python3 \
python3-jinja2 \
python3-pip \
python3-wheel \
redhat-rpm-config \
@@ -73,7 +71,9 @@ RUN dnf -y install \
xorg-x11-server-Xvfb \
&& dnf clean all
RUN pip3 install meson==0.50.1
RUN pip3 install meson==0.50.0
RUN pip3 install jinja2
ARG HOST_USER_ID=5555
ENV HOST_USER_ID ${HOST_USER_ID}
+1 -1
View File
@@ -2,7 +2,7 @@
set -e
TAG="registry.gitlab.gnome.org/gnome/gtk/master:v6"
TAG="registry.gitlab.gnome.org/gnome/gtk/master:v4"
sudo docker build --build-arg HOST_USER_ID="$UID" --tag "${TAG}" \
--file "Dockerfile" .
+1
View File
@@ -32,6 +32,7 @@ xvfb-run -a -s "-screen 0 1024x768x24" \
--timeout-multiplier 2 \
--print-errorlogs \
--suite=gtk \
--no-suite=gtk:gsk \
--no-suite=gtk:a11y
# Save the exit code
+3
View File
@@ -24,6 +24,9 @@
/* Define to 1 if you have the <crt_externs.h> header file. */
#mesondefine HAVE_CRT_EXTERNS_H
/* Define to 1 if CUPS 1.6 API is available */
#mesondefine HAVE_CUPS_API_1_6
/* Define to 1 if you have the `dcgettext' function. */
#mesondefine HAVE_DCGETTEXT
-1
View File
@@ -1,4 +1,3 @@
subdir('gtk-demo')
subdir('icon-browser')
subdir('node-editor')
subdir('widget-factory')
-323
View File
@@ -1,323 +0,0 @@
/*
* Copyright © 2019 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#include "config.h"
#include "gtkrendererpaintableprivate.h"
#include <gtk/gtk.h>
struct _GtkRendererPaintable
{
GObject parent_instance;
GskRenderer *renderer;
GdkPaintable *paintable;
};
struct _GtkRendererPaintableClass
{
GObjectClass parent_class;
};
enum {
PROP_0,
PROP_PAINTABLE,
PROP_RENDERER,
N_PROPS
};
static GParamSpec *properties[N_PROPS] = { NULL, };
static void
gtk_renderer_paintable_paintable_snapshot (GdkPaintable *paintable,
GdkSnapshot *snapshot,
double width,
double height)
{
GtkRendererPaintable *self = GTK_RENDERER_PAINTABLE (paintable);
GtkSnapshot *node_snapshot;
GskRenderNode *node;
GdkTexture *texture;
if (self->paintable == NULL)
return;
if (self->renderer == NULL ||
!gsk_renderer_is_realized (self->renderer))
{
gdk_paintable_snapshot (self->paintable, snapshot, width, height);
return;
}
node_snapshot = gtk_snapshot_new ();
gdk_paintable_snapshot (self->paintable, node_snapshot, width, height);
node = gtk_snapshot_free_to_node (node_snapshot);
if (node == NULL)
return;
texture = gsk_renderer_render_texture (self->renderer,
node,
&GRAPHENE_RECT_INIT (0, 0, width, height));
gdk_paintable_snapshot (GDK_PAINTABLE (texture), snapshot, width, height);
g_object_unref (texture);
}
static int
gtk_renderer_paintable_paintable_get_intrinsic_width (GdkPaintable *paintable)
{
GtkRendererPaintable *self = GTK_RENDERER_PAINTABLE (paintable);
if (self->paintable == NULL)
return 0;
return gdk_paintable_get_intrinsic_width (self->paintable);
}
static int
gtk_renderer_paintable_paintable_get_intrinsic_height (GdkPaintable *paintable)
{
GtkRendererPaintable *self = GTK_RENDERER_PAINTABLE (paintable);
if (self->paintable == NULL)
return 0;
return gdk_paintable_get_intrinsic_height (self->paintable);
}
static double
gtk_renderer_paintable_paintable_get_intrinsic_aspect_ratio (GdkPaintable *paintable)
{
GtkRendererPaintable *self = GTK_RENDERER_PAINTABLE (paintable);
if (self->paintable == NULL)
return 0.0;
return gdk_paintable_get_intrinsic_aspect_ratio (self->paintable);
}
static void
gtk_renderer_paintable_paintable_init (GdkPaintableInterface *iface)
{
iface->snapshot = gtk_renderer_paintable_paintable_snapshot;
iface->get_intrinsic_width = gtk_renderer_paintable_paintable_get_intrinsic_width;
iface->get_intrinsic_height = gtk_renderer_paintable_paintable_get_intrinsic_height;
iface->get_intrinsic_aspect_ratio = gtk_renderer_paintable_paintable_get_intrinsic_aspect_ratio;
}
G_DEFINE_TYPE_EXTENDED (GtkRendererPaintable, gtk_renderer_paintable, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
gtk_renderer_paintable_paintable_init))
static void
gtk_renderer_paintable_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkRendererPaintable *self = GTK_RENDERER_PAINTABLE (object);
switch (prop_id)
{
case PROP_PAINTABLE:
gtk_renderer_paintable_set_paintable (self, g_value_get_object (value));
break;
case PROP_RENDERER:
gtk_renderer_paintable_set_renderer (self, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_renderer_paintable_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkRendererPaintable *self = GTK_RENDERER_PAINTABLE (object);
switch (prop_id)
{
case PROP_PAINTABLE:
g_value_set_object (value, self->paintable);
break;
case PROP_RENDERER:
g_value_set_object (value, self->renderer);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_renderer_paintable_unset_paintable (GtkRendererPaintable *self)
{
guint flags;
if (self->paintable == NULL)
return;
flags = gdk_paintable_get_flags (self->paintable);
if ((flags & GDK_PAINTABLE_STATIC_CONTENTS) == 0)
g_signal_handlers_disconnect_by_func (self->paintable,
gdk_paintable_invalidate_contents,
self);
if ((flags & GDK_PAINTABLE_STATIC_SIZE) == 0)
g_signal_handlers_disconnect_by_func (self->paintable,
gdk_paintable_invalidate_size,
self);
g_clear_object (&self->paintable);
}
static void
gtk_renderer_paintable_dispose (GObject *object)
{
GtkRendererPaintable *self = GTK_RENDERER_PAINTABLE (object);
g_clear_object (&self->renderer);
gtk_renderer_paintable_unset_paintable (self);
G_OBJECT_CLASS (gtk_renderer_paintable_parent_class)->dispose (object);
}
static void
gtk_renderer_paintable_class_init (GtkRendererPaintableClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->get_property = gtk_renderer_paintable_get_property;
gobject_class->set_property = gtk_renderer_paintable_set_property;
gobject_class->dispose = gtk_renderer_paintable_dispose;
properties[PROP_PAINTABLE] =
g_param_spec_object ("paintable",
"Paintable",
"The paintable to be shown",
GDK_TYPE_PAINTABLE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
properties[PROP_RENDERER] =
g_param_spec_object ("renderer",
"Renderer",
"Renderer used to render the paintable",
GSK_TYPE_RENDERER,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (gobject_class, N_PROPS, properties);
}
static void
gtk_renderer_paintable_init (GtkRendererPaintable *self)
{
}
GdkPaintable *
gtk_renderer_paintable_new (GskRenderer *renderer,
GdkPaintable *paintable)
{
g_return_val_if_fail (renderer == NULL || GSK_IS_RENDERER (renderer), NULL);
g_return_val_if_fail (paintable == NULL || GDK_IS_PAINTABLE (paintable), NULL);
return g_object_new (GTK_TYPE_RENDERER_PAINTABLE,
"renderer", renderer,
"paintable", paintable,
NULL);
}
void
gtk_renderer_paintable_set_renderer (GtkRendererPaintable *self,
GskRenderer *renderer)
{
g_return_if_fail (GTK_IS_RENDERER_PAINTABLE (self));
g_return_if_fail (renderer == NULL || GSK_IS_RENDERER (renderer));
if (!g_set_object (&self->renderer, renderer))
return;
if (self->paintable)
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_RENDERER]);
}
GskRenderer *
gtk_renderer_paintable_get_renderer (GtkRendererPaintable *self)
{
g_return_val_if_fail (GTK_IS_RENDERER_PAINTABLE (self), NULL);
return self->renderer;
}
void
gtk_renderer_paintable_set_paintable (GtkRendererPaintable *self,
GdkPaintable *paintable)
{
g_return_if_fail (GTK_IS_RENDERER_PAINTABLE (self));
g_return_if_fail (paintable == NULL || GDK_IS_PAINTABLE (paintable));
if (self->paintable == paintable)
return;
gtk_renderer_paintable_unset_paintable (self);
if (paintable)
{
const guint flags = gdk_paintable_get_flags (paintable);
self->paintable = g_object_ref (paintable);
if ((flags & GDK_PAINTABLE_STATIC_CONTENTS) == 0)
g_signal_connect_swapped (paintable,
"invalidate-contents",
G_CALLBACK (gdk_paintable_invalidate_contents),
self);
if ((flags & GDK_PAINTABLE_STATIC_SIZE) == 0)
g_signal_connect_swapped (paintable,
"invalidate-size",
G_CALLBACK (gdk_paintable_invalidate_size),
self);
}
gdk_paintable_invalidate_size (GDK_PAINTABLE (self));
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PAINTABLE]);
}
GdkPaintable *
gtk_renderer_paintable_get_paintable (GtkRendererPaintable *self)
{
g_return_val_if_fail (GTK_IS_RENDERER_PAINTABLE (self), NULL);
return self->paintable;
}
@@ -1,43 +0,0 @@
/*
* Copyright © 2019 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#ifndef __GTK_RENDERER_PAINTABLE_H__
#define __GTK_RENDERER_PAINTABLE_H__
#include <gsk/gsk.h>
G_BEGIN_DECLS
#define GTK_TYPE_RENDERER_PAINTABLE (gtk_renderer_paintable_get_type ())
G_DECLARE_FINAL_TYPE (GtkRendererPaintable, gtk_renderer_paintable, GTK, RENDERER_PAINTABLE, GObject)
GdkPaintable * gtk_renderer_paintable_new (GskRenderer *renderer,
GdkPaintable *paintable);
void gtk_renderer_paintable_set_renderer (GtkRendererPaintable *self,
GskRenderer *renderer);
GskRenderer * gtk_renderer_paintable_get_renderer (GtkRendererPaintable *self) G_GNUC_PURE;
void gtk_renderer_paintable_set_paintable (GtkRendererPaintable *self,
GdkPaintable *paintable);
GdkPaintable * gtk_renderer_paintable_get_paintable (GtkRendererPaintable *self) G_GNUC_PURE;
G_END_DECLS
#endif /* __GTK_RENDERER_PAINTABLE_H__ */
-28
View File
@@ -1,28 +0,0 @@
/*
* Copyright © 2019 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#include "config.h"
#include <node-editor-application.h>
int
main (int argc, char *argv[])
{
return g_application_run (G_APPLICATION (node_editor_application_new ()), argc, argv);
}
-18
View File
@@ -1,18 +0,0 @@
node_editor_sources = [
'gtkrendererpaintable.c',
'main.c',
'node-editor-application.c',
'node-editor-window.c',
]
node_editor_resources = gnome.compile_resources('node_editor_resources',
'node-editor.gresource.xml',
source_dir: '.')
executable('gtk4-node-editor',
node_editor_sources, node_editor_resources,
dependencies: libgtk_dep,
include_directories: confinc,
gui_app: true,
link_args: extra_demo_ldflags,
install: false)
-132
View File
@@ -1,132 +0,0 @@
/*
* Copyright © 2019 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#include "config.h"
#include "node-editor-application.h"
#include "node-editor-window.h"
static const char *css =
"textview.editor {"
" color: rgb(192, 197, 206);"
" caret-color: white;"
"}"
"textview.editor text {"
" background-color: rgb(43, 48, 59);"
"}"
;
struct _NodeEditorApplication
{
GtkApplication parent;
};
struct _NodeEditorApplicationClass
{
GtkApplicationClass parent_class;
};
G_DEFINE_TYPE(NodeEditorApplication, node_editor_application, GTK_TYPE_APPLICATION);
static void
node_editor_application_init (NodeEditorApplication *app)
{
}
static void
quit_activated (GSimpleAction *action,
GVariant *parameter,
gpointer data)
{
g_application_quit (G_APPLICATION (data));
}
static GActionEntry app_entries[] =
{
{ "quit", quit_activated, NULL, NULL, NULL }
};
static void
node_editor_application_startup (GApplication *app)
{
const char *quit_accels[2] = { "<Ctrl>Q", NULL };
const char *open_accels[2] = { "<Ctrl>O", NULL };
GtkCssProvider *provider;
G_APPLICATION_CLASS (node_editor_application_parent_class)->startup (app);
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.quit", quit_accels);
gtk_application_set_accels_for_action (GTK_APPLICATION (app), "win.open", open_accels);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, css, -1);
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
static void
node_editor_application_activate (GApplication *app)
{
NodeEditorWindow *win;
win = node_editor_window_new (NODE_EDITOR_APPLICATION (app));
gtk_window_present (GTK_WINDOW (win));
}
static void
node_editor_application_open (GApplication *app,
GFile **files,
gint n_files,
const gchar *hint)
{
NodeEditorWindow *win;
gint i;
for (i = 0; i < n_files; i++)
{
win = node_editor_window_new (NODE_EDITOR_APPLICATION (app));
node_editor_window_load (win, files[i]);
gtk_window_present (GTK_WINDOW (win));
}
}
static void
node_editor_application_class_init (NodeEditorApplicationClass *class)
{
GApplicationClass *application_class = G_APPLICATION_CLASS (class);
application_class->startup = node_editor_application_startup;
application_class->activate = node_editor_application_activate;
application_class->open = node_editor_application_open;
}
NodeEditorApplication *
node_editor_application_new (void)
{
return g_object_new (NODE_EDITOR_APPLICATION_TYPE,
"application-id", "org.gtk.gtk4.NodeEditor",
"flags", G_APPLICATION_HANDLES_OPEN,
NULL);
}
@@ -1,38 +0,0 @@
/*
* Copyright © 2019 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#ifndef __NODE_EDITOR_APPLICATION_H__
#define __NODE_EDITOR_APPLICATION_H__
#include <gtk/gtk.h>
#define NODE_EDITOR_APPLICATION_TYPE (node_editor_application_get_type ())
#define NODE_EDITOR_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NODE_EDITOR_APPLICATION_TYPE, NodeEditorApplication))
typedef struct _NodeEditorApplication NodeEditorApplication;
typedef struct _NodeEditorApplicationClass NodeEditorApplicationClass;
GType node_editor_application_get_type (void);
NodeEditorApplication *node_editor_application_new (void);
#endif /* __NODE_EDITOR_APPLICATION_H__ */
-728
View File
@@ -1,728 +0,0 @@
/*
* Copyright © 2019 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#include "config.h"
#include "node-editor-window.h"
#include "gtkrendererpaintableprivate.h"
#include "gsk/gskrendernodeparserprivate.h"
typedef struct
{
gsize start_chars;
gsize end_chars;
char *message;
} TextViewError;
struct _NodeEditorWindow
{
GtkApplicationWindow parent;
GtkWidget *picture;
GtkWidget *text_view;
GtkTextBuffer *text_buffer;
GtkTextTagTable *tag_table;
GtkWidget *renderer_listbox;
GListStore *renderers;
GdkPaintable *paintable;
GArray *errors;
};
struct _NodeEditorWindowClass
{
GtkApplicationWindowClass parent_class;
};
G_DEFINE_TYPE(NodeEditorWindow, node_editor_window, GTK_TYPE_APPLICATION_WINDOW);
static void
text_view_error_free (TextViewError *e)
{
g_free (e->message);
}
static gchar *
get_current_text (GtkTextBuffer *buffer)
{
GtkTextIter start, end;
gtk_text_buffer_get_start_iter (buffer, &start);
gtk_text_buffer_get_end_iter (buffer, &end);
return gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
}
static void
text_buffer_remove_all_tags (GtkTextBuffer *buffer)
{
GtkTextIter start, end;
gtk_text_buffer_get_start_iter (buffer, &start);
gtk_text_buffer_get_end_iter (buffer, &end);
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
}
static void
deserialize_error_func (const GtkCssSection *section,
const GError *error,
gpointer user_data)
{
const GtkCssLocation *start_location = gtk_css_section_get_start_location (section);
const GtkCssLocation *end_location = gtk_css_section_get_end_location (section);
NodeEditorWindow *self = user_data;
GtkTextIter start_iter, end_iter;
TextViewError text_view_error;
gtk_text_buffer_get_iter_at_line_offset (self->text_buffer, &start_iter,
start_location->lines,
start_location->line_chars);
gtk_text_buffer_get_iter_at_line_offset (self->text_buffer, &end_iter,
end_location->lines,
end_location->line_chars);
gtk_text_buffer_apply_tag_by_name (self->text_buffer, "error",
&start_iter, &end_iter);
text_view_error.start_chars = start_location->chars;
text_view_error.end_chars = end_location->chars;
text_view_error.message = g_strdup (error->message);
g_array_append_val (self->errors, text_view_error);
}
static void
text_iter_skip_alpha_backward (GtkTextIter *iter)
{
/* Just skip to the previous non-whitespace char */
while (!gtk_text_iter_is_start (iter))
{
gunichar c = gtk_text_iter_get_char (iter);
if (g_unichar_isspace (c))
{
gtk_text_iter_forward_char (iter);
break;
}
gtk_text_iter_backward_char (iter);
}
}
static void
text_iter_skip_whitespace_backward (GtkTextIter *iter)
{
while (!gtk_text_iter_is_start (iter))
{
gunichar c = gtk_text_iter_get_char (iter);
if (g_unichar_isalpha (c))
{
gtk_text_iter_forward_char (iter);
break;
}
gtk_text_iter_backward_char (iter);
}
}
static void
text_changed (GtkTextBuffer *buffer,
NodeEditorWindow *self)
{
GskRenderNode *node;
char *text;
GBytes *bytes;
g_array_remove_range (self->errors, 0, self->errors->len);
text = get_current_text (self->text_buffer);
text_buffer_remove_all_tags (self->text_buffer);
bytes = g_bytes_new_take (text, strlen (text));
/* If this is too slow, go fix the parser performance */
node = gsk_render_node_deserialize (bytes, deserialize_error_func, self);
g_bytes_unref (bytes);
if (node)
{
/* XXX: Is this code necessary or can we have API to turn nodes into paintables? */
GtkSnapshot *snapshot;
GdkPaintable *paintable;
graphene_rect_t bounds;
guint i;
snapshot = gtk_snapshot_new ();
gsk_render_node_get_bounds (node, &bounds);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (- bounds.origin.x, - bounds.origin.y));
gtk_snapshot_append_node (snapshot, node);
gsk_render_node_unref (node);
paintable = gtk_snapshot_free_to_paintable (snapshot, &bounds.size);
gtk_picture_set_paintable (GTK_PICTURE (self->picture), paintable);
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (self->renderers)); i++)
{
gpointer item = g_list_model_get_item (G_LIST_MODEL (self->renderers), i);
gtk_renderer_paintable_set_paintable (item, paintable);
g_object_unref (item);
}
g_clear_object (&paintable);
}
else
{
gtk_picture_set_paintable (GTK_PICTURE (self->picture), NULL);
}
GtkTextIter iter;
gtk_text_buffer_get_start_iter (self->text_buffer, &iter);
while (!gtk_text_iter_is_end (&iter))
{
gunichar c = gtk_text_iter_get_char (&iter);
if (c == '{')
{
GtkTextIter word_end = iter;
GtkTextIter word_start;
gtk_text_iter_backward_char (&word_end);
text_iter_skip_whitespace_backward (&word_end);
word_start = word_end;
gtk_text_iter_backward_word_start (&word_start);
text_iter_skip_alpha_backward (&word_start);
gtk_text_buffer_apply_tag_by_name (self->text_buffer, "nodename",
&word_start, &word_end);
}
else if (c == ':')
{
GtkTextIter word_end = iter;
GtkTextIter word_start;
gtk_text_iter_backward_char (&word_end);
text_iter_skip_whitespace_backward (&word_end);
word_start = word_end;
gtk_text_iter_backward_word_start (&word_start);
text_iter_skip_alpha_backward (&word_start);
gtk_text_buffer_apply_tag_by_name (self->text_buffer, "propname",
&word_start, &word_end);
}
else if (c == '"')
{
GtkTextIter string_start = iter;
GtkTextIter string_end = iter;
gtk_text_iter_forward_char (&iter);
while (!gtk_text_iter_is_end (&iter))
{
c = gtk_text_iter_get_char (&iter);
if (c == '"')
{
gtk_text_iter_forward_char (&iter);
string_end = iter;
break;
}
gtk_text_iter_forward_char (&iter);
}
gtk_text_buffer_apply_tag_by_name (self->text_buffer, "string",
&string_start, &string_end);
}
gtk_text_iter_forward_char (&iter);
}
}
static gboolean
text_view_query_tooltip_cb (GtkWidget *widget,
int x,
int y,
gboolean keyboard_tip,
GtkTooltip *tooltip,
NodeEditorWindow *self)
{
GtkTextIter iter;
guint i;
GString *text;
if (keyboard_tip)
{
gint offset;
g_object_get (self->text_buffer, "cursor-position", &offset, NULL);
gtk_text_buffer_get_iter_at_offset (self->text_buffer, &iter, offset);
}
else
{
gint bx, by, trailing;
gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (self->text_view), GTK_TEXT_WINDOW_TEXT,
x, y, &bx, &by);
gtk_text_view_get_iter_at_position (GTK_TEXT_VIEW (self->text_view), &iter, &trailing, bx, by);
}
text = g_string_new ("");
for (i = 0; i < self->errors->len; i ++)
{
const TextViewError *e = &g_array_index (self->errors, TextViewError, i);
GtkTextIter start_iter, end_iter;
gtk_text_buffer_get_iter_at_offset (self->text_buffer, &start_iter, e->start_chars);
gtk_text_buffer_get_iter_at_offset (self->text_buffer, &end_iter, e->end_chars);
if (gtk_text_iter_in_range (&iter, &start_iter, &end_iter))
{
if (text->len > 0)
g_string_append (text, "\n");
g_string_append (text, e->message);
}
}
if (text->len > 0)
{
gtk_tooltip_set_text (tooltip, text->str);
g_string_free (text, TRUE);
return TRUE;
}
else
{
g_string_free (text, TRUE);
return FALSE;
}
}
gboolean
node_editor_window_load (NodeEditorWindow *self,
GFile *file)
{
GtkTextIter end;
GBytes *bytes;
bytes = g_file_load_bytes (file, NULL, NULL, NULL);
if (bytes == NULL)
return FALSE;
if (!g_utf8_validate (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), NULL))
{
g_bytes_unref (bytes);
return FALSE;
}
gtk_text_buffer_get_end_iter (self->text_buffer, &end);
gtk_text_buffer_insert (self->text_buffer,
&end,
g_bytes_get_data (bytes, NULL),
g_bytes_get_size (bytes));
g_bytes_unref (bytes);
return TRUE;
}
static void
open_response_cb (GtkWidget *dialog,
gint response,
NodeEditorWindow *self)
{
gtk_widget_hide (dialog);
if (response == GTK_RESPONSE_ACCEPT)
{
GFile *file;
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
node_editor_window_load (self, file);
g_object_unref (file);
}
gtk_widget_destroy (dialog);
}
static void
show_open_filechooser (NodeEditorWindow *self)
{
GtkWidget *dialog;
dialog = gtk_file_chooser_dialog_new ("Open node file",
GTK_WINDOW (self),
GTK_FILE_CHOOSER_ACTION_OPEN,
"_Cancel", GTK_RESPONSE_CANCEL,
"_Load", GTK_RESPONSE_ACCEPT,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), ".");
g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), self);
gtk_widget_show (dialog);
}
static void
open_cb (GtkWidget *button,
NodeEditorWindow *self)
{
show_open_filechooser (self);
}
static void
save_response_cb (GtkWidget *dialog,
gint response,
NodeEditorWindow *self)
{
gtk_widget_hide (dialog);
if (response == GTK_RESPONSE_ACCEPT)
{
char *text, *filename;
GError *error = NULL;
text = get_current_text (self->text_buffer);
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
if (!g_file_set_contents (filename, text, -1, &error))
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))),
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
"Saving failed");
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
"%s", error->message);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show (dialog);
g_error_free (error);
}
g_free (filename);
}
gtk_widget_destroy (dialog);
}
static void
save_cb (GtkWidget *button,
NodeEditorWindow *self)
{
GtkWidget *dialog;
dialog = gtk_file_chooser_dialog_new ("Save node",
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (button))),
GTK_FILE_CHOOSER_ACTION_SAVE,
"_Cancel", GTK_RESPONSE_CANCEL,
"_Save", GTK_RESPONSE_ACCEPT,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), ".");
g_signal_connect (dialog, "response", G_CALLBACK (save_response_cb), self);
gtk_widget_show (dialog);
}
static GdkTexture *
create_texture (NodeEditorWindow *self)
{
GdkPaintable *paintable;
GtkSnapshot *snapshot;
GskRenderer *renderer;
GskRenderNode *node;
GdkTexture *texture;
paintable = gtk_picture_get_paintable (GTK_PICTURE (self->picture));
if (paintable == NULL ||
gdk_paintable_get_intrinsic_width (paintable) <= 0 ||
gdk_paintable_get_intrinsic_height (paintable) <= 0)
return NULL;
snapshot = gtk_snapshot_new ();
gdk_paintable_snapshot (paintable, snapshot, gdk_paintable_get_intrinsic_width (paintable), gdk_paintable_get_intrinsic_height (paintable));
node = gtk_snapshot_free_to_node (snapshot);
if (node == NULL)
return NULL;
/* ahem */
renderer = GTK_ROOT_GET_IFACE (gtk_widget_get_root (GTK_WIDGET (self)))->get_renderer (gtk_widget_get_root (GTK_WIDGET (self)));
texture = gsk_renderer_render_texture (renderer, node, NULL);
gsk_render_node_unref (node);
return texture;
}
static void
export_image_response_cb (GtkWidget *dialog,
gint response,
GdkTexture *texture)
{
gtk_widget_hide (dialog);
if (response == GTK_RESPONSE_ACCEPT)
{
char *filename;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
if (!gdk_texture_save_to_png (texture, filename))
{
GtkWidget *message_dialog;
message_dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_window_get_transient_for (GTK_WINDOW (dialog))),
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
"Exporting to image failed");
g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show (message_dialog);
}
g_free (filename);
}
gtk_widget_destroy (dialog);
g_object_unref (texture);
}
static void
export_image_cb (GtkWidget *button,
NodeEditorWindow *self)
{
GdkTexture *texture;
GtkWidget *dialog;
texture = create_texture (self);
if (texture == NULL)
return;
dialog = gtk_file_chooser_dialog_new ("",
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (button))),
GTK_FILE_CHOOSER_ACTION_SAVE,
"_Cancel", GTK_RESPONSE_CANCEL,
"_Save", GTK_RESPONSE_ACCEPT,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
g_signal_connect (dialog, "response", G_CALLBACK (export_image_response_cb), texture);
gtk_widget_show (dialog);
}
static void
node_editor_window_finalize (GObject *object)
{
NodeEditorWindow *self = (NodeEditorWindow *)object;
g_array_free (self->errors, TRUE);
g_clear_object (&self->renderers);
G_OBJECT_CLASS (node_editor_window_parent_class)->finalize (object);
}
static void
node_editor_window_add_renderer (NodeEditorWindow *self,
GskRenderer *renderer,
const char *description)
{
GdkSurface *surface;
GdkPaintable *paintable;
surface = gtk_widget_get_surface (GTK_WIDGET (self));
g_assert (surface != NULL);
if (renderer != NULL && !gsk_renderer_realize (renderer, surface, NULL))
{
g_object_unref (renderer);
return;
}
paintable = gtk_renderer_paintable_new (renderer, gtk_picture_get_paintable (GTK_PICTURE (self->picture)));
g_object_set_data_full (G_OBJECT (paintable), "description", g_strdup (description), g_free);
g_clear_object (&renderer);
g_list_store_append (self->renderers, paintable);
g_object_unref (paintable);
}
static void
node_editor_window_realize (GtkWidget *widget)
{
NodeEditorWindow *self = NODE_EDITOR_WINDOW (widget);
GTK_WIDGET_CLASS (node_editor_window_parent_class)->realize (widget);
#if 0
node_editor_window_add_renderer (self,
NULL,
"Default");
#endif
node_editor_window_add_renderer (self,
gsk_gl_renderer_new (),
"OpenGL");
#ifdef GDK_RENDERING_VULKAN
node_editor_window_add_renderer (self,
gsk_vulkan_renderer_new (),
"Vulkan");
#endif
#ifdef GDK_WINDOWING_BROADWAY
node_editor_window_add_renderer (self,
gsk_broadway_renderer_new (),
"Broadway");
#endif
node_editor_window_add_renderer (self,
gsk_cairo_renderer_new (),
"Cairo");
}
static void
node_editor_window_unrealize (GtkWidget *widget)
{
NodeEditorWindow *self = NODE_EDITOR_WINDOW (widget);
g_list_store_remove_all (self->renderers);
GTK_WIDGET_CLASS (node_editor_window_parent_class)->unrealize (widget);
}
static void
node_editor_window_class_init (NodeEditorWindowClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
object_class->finalize = node_editor_window_finalize;
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gtk/gtk4/node-editor/node-editor-window.ui");
widget_class->realize = node_editor_window_realize;
widget_class->unrealize = node_editor_window_unrealize;
gtk_widget_class_bind_template_child (widget_class, NodeEditorWindow, text_view);
gtk_widget_class_bind_template_child (widget_class, NodeEditorWindow, picture);
gtk_widget_class_bind_template_child (widget_class, NodeEditorWindow, renderer_listbox);
gtk_widget_class_bind_template_callback (widget_class, text_view_query_tooltip_cb);
gtk_widget_class_bind_template_callback (widget_class, open_cb);
gtk_widget_class_bind_template_callback (widget_class, save_cb);
gtk_widget_class_bind_template_callback (widget_class, export_image_cb);
}
static GtkWidget *
node_editor_window_create_renderer_widget (gpointer item,
gpointer user_data)
{
GdkPaintable *paintable = item;
GtkWidget *box, *label, *picture;
GtkWidget *row;
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_size_request (box, 120, 90);
label = gtk_label_new (g_object_get_data (G_OBJECT (paintable), "description"));
gtk_container_add (GTK_CONTAINER (box), label);
picture = gtk_picture_new_for_paintable (paintable);
/* don't ever scale up, we want to be as accurate as possible */
gtk_widget_set_halign (picture, GTK_ALIGN_CENTER);
gtk_widget_set_valign (picture, GTK_ALIGN_CENTER);
gtk_container_add (GTK_CONTAINER (box), picture);
row = gtk_list_box_row_new ();
gtk_container_add (GTK_CONTAINER (row), box);
gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), FALSE);
return row;
}
static void
window_open (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
NodeEditorWindow *self = user_data;
show_open_filechooser (self);
}
static GActionEntry win_entries[] = {
{ "open", window_open, NULL, NULL, NULL },
};
static void
node_editor_window_init (NodeEditorWindow *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
self->renderers = g_list_store_new (GDK_TYPE_PAINTABLE);
gtk_list_box_bind_model (GTK_LIST_BOX (self->renderer_listbox),
G_LIST_MODEL (self->renderers),
node_editor_window_create_renderer_widget,
self,
NULL);
self->errors = g_array_new (FALSE, TRUE, sizeof (TextViewError));
g_array_set_clear_func (self->errors, (GDestroyNotify)text_view_error_free);
g_action_map_add_action_entries (G_ACTION_MAP (self), win_entries, G_N_ELEMENTS (win_entries), self);
self->tag_table = gtk_text_tag_table_new ();
gtk_text_tag_table_add (self->tag_table,
g_object_new (GTK_TYPE_TEXT_TAG,
"name", "error",
"underline", PANGO_UNDERLINE_ERROR,
NULL));
gtk_text_tag_table_add (self->tag_table,
g_object_new (GTK_TYPE_TEXT_TAG,
"name", "nodename",
"foreground-rgba", &(GdkRGBA) { 0.9, 0.78, 0.53, 1},
NULL));
gtk_text_tag_table_add (self->tag_table,
g_object_new (GTK_TYPE_TEXT_TAG,
"name", "propname",
"foreground-rgba", &(GdkRGBA) { 0.7, 0.55, 0.67, 1},
NULL));
gtk_text_tag_table_add (self->tag_table,
g_object_new (GTK_TYPE_TEXT_TAG,
"name", "string",
"foreground-rgba", &(GdkRGBA) { 0.63, 0.73, 0.54, 1},
NULL));
gtk_text_tag_table_add (self->tag_table,
g_object_new (GTK_TYPE_TEXT_TAG,
"name", "number",
"foreground-rgba", &(GdkRGBA) { 0.8, 0.52, 0.43, 1},
NULL));
self->text_buffer = gtk_text_buffer_new (self->tag_table);
g_signal_connect (self->text_buffer, "changed", G_CALLBACK (text_changed), self);
gtk_text_view_set_buffer (GTK_TEXT_VIEW (self->text_view), self->text_buffer);
}
NodeEditorWindow *
node_editor_window_new (NodeEditorApplication *application)
{
return g_object_new (NODE_EDITOR_WINDOW_TYPE,
"application", application,
NULL);
}
-42
View File
@@ -1,42 +0,0 @@
/*
* Copyright © 2019 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#ifndef __NODE_EDITOR_WINDOW_H__
#define __NODE_EDITOR_WINDOW_H__
#include <gtk/gtk.h>
#include "node-editor-application.h"
#define NODE_EDITOR_WINDOW_TYPE (node_editor_window_get_type ())
#define NODE_EDITOR_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NODE_EDITOR_WINDOW_TYPE, NodeEditorWindow))
typedef struct _NodeEditorWindow NodeEditorWindow;
typedef struct _NodeEditorWindowClass NodeEditorWindowClass;
GType node_editor_window_get_type (void);
NodeEditorWindow * node_editor_window_new (NodeEditorApplication *application);
gboolean node_editor_window_load (NodeEditorWindow *self,
GFile *file);
#endif /* __NODE_EDITOR_WINDOW_H__ */
-103
View File
@@ -1,103 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="NodeEditorWindow" parent="GtkApplicationWindow">
<style>
<class name="devel"/>
</style>
<property name="title" translatable="yes">GTK Node Editor</property>
<property name="default-width">1024</property>
<property name="default-height">768</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
<property name="title" translatable="yes">GTK Node Editor</property>
<property name="show-title-buttons">1</property>
<child type="start">
<object class="GtkButton">
<property name="icon-name">document-open-symbolic</property>
<property name="tooltip-text">Open node file</property>
<signal name="clicked" handler="open_cb"/>
</object>
</child>
<child type="start">
<object class="GtkButton">
<property name="icon-name">document-save-symbolic</property>
<property name="tooltip-text">Save to node file</property>
<signal name="clicked" handler="save_cb"/>
</object>
</child>
<child type="start">
<object class="GtkButton">
<property name="icon-name">insert-image-symbolic</property>
<property name="tooltip-text">Export to image</property>
<signal name="clicked" handler="export_image_cb"/>
</object>
</child>
<child type="title">
<object class="GtkLabel">
<property name="label" translatable="yes">GTK Node Editor</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkPaned">
<property name="shrink-child2">false</property>
<property name="position">400</property>
<child>
<object class="GtkScrolledWindow">
<property name="hscrollbar-policy">never</property>
<property name="expand">1</property>
<child>
<object class="GtkTextView" id="text_view">
<property name="wrap-mode">word</property>
<property name="monospace">1</property>
<property name="has-focus">1</property>
<property name="top-margin">6</property>
<property name="left-margin">6</property>
<property name="right-margin">6</property>
<property name="bottom-margin">6</property>
<property name="has-tooltip">1</property>
<signal name="query-tooltip" handler="text_view_query_tooltip_cb"/>
<style>
<class name="editor" />
</style>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<child>
<object class="GtkScrolledWindow">
<property name="expand">1</property>
<property name="min-content-height">100</property>
<property name="min-content-width">100</property>
<child>
<object class="GtkViewport">
<child>
<object class="GtkPicture" id="picture">
<property name="can-shrink">0</property>
<property name="halign">center</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="hscrollbar-policy">never</property>
<child>
<object class="GtkListBox" id="renderer_listbox">
<property name="selection-mode">none</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gtk/gtk4/node-editor">
<file preprocess="xml-stripblanks">node-editor-window.ui</file>
</gresource>
</gresources>
+1 -6
View File
@@ -1,17 +1,12 @@
<SECTION>
<FILE>GskRenderer</FILE>
gsk_renderer_new_for_surface
gsk_renderer_get_surface
gsk_renderer_realize
gsk_renderer_unrealize
gsk_renderer_is_realized
gsk_renderer_render
gsk_renderer_render_texture
<SUBSECTION>
gsk_renderer_new_for_surface
gsk_gl_renderer_new
gsk_cairo_renderer_new
gsk_vulkan_renderer_new
gsk_broadway_renderer_new
<SUBSECTION Standard>
GSK_IS_RENDERER
GSK_RENDERER
-26
View File
@@ -574,32 +574,6 @@ nevertheless.
</refsect2>
<refsect2 id="profiling">
<title>Profiling</title>
<para>
GTK supports profiling with sysprof. It exports timing information
about frameclock phases and various characteristics of GskRenders
in a format that can be displayed by sysprof or GNOME Builder.
</para>
<para>
A simple way to capture data is to set the <envar>GTK_TRACE</envar>
environment variable. When it is set, GTK will write profiling
data to a file called
<filename>gtk.<replaceable>PID</replaceable>.syscap</filename>.
</para>
<para>
When launching the application from sysprof, it will set the
<envar>SYSPROF_TRACE_FD</envar> environment variable to point
GTK at a file descriptor to write profiling data to.
</para>
<para>
When GtkApplication registers with D-Bus, it exports the
<literal>org.gnome.Sysprof2.Profiler</literal> interface
that lets sysprof request profiling data at runtime.
</para>
</refsect2>
</refsect1>
</refentry>
+3 -1
View File
@@ -24,7 +24,9 @@ gdk_broadway_public_headers = [
'gdkbroadwaymonitor.h',
]
install_headers(gdk_broadway_public_headers, 'gdkbroadway.h', subdir: 'gtk-4.0/gdk/broadway/')
# Broadway backend headers aren't installed it seems
#install_headers(gdk_broadway_public_headers, subdir: 'gtk-4.0/gdk/broadway/')
#install_headers('gdkbroadway.h', subdir: 'gtk-4.0/gdk/')
gdk_broadway_deps = [shmlib]
-224
View File
@@ -1,224 +0,0 @@
/* sp-capture-types.h
*
* Copyright © 2016 Christian Hergert <chergert@redhat.com>
*
* This file is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SP_CAPTURE_FORMAT_H
#define SP_CAPTURE_FORMAT_H
#include <glib.h>
#ifndef SP_DISABLE_GOBJECT
# include <glib-object.h>
#endif
#include "sp-clock.h"
G_BEGIN_DECLS
#define SP_CAPTURE_MAGIC (GUINT32_TO_LE(0xFDCA975E))
#define SP_CAPTURE_ALIGN (sizeof(SpCaptureAddress))
#if __WORDSIZE == 64
# define SP_CAPTURE_JITMAP_MARK G_GUINT64_CONSTANT(0xE000000000000000)
# define SP_CAPTURE_ADDRESS_FORMAT "0x%016lx"
#else
# define SP_CAPTURE_JITMAP_MARK G_GUINT64_CONSTANT(0xE0000000)
# define SP_CAPTURE_ADDRESS_FORMAT "0x%016llx"
#endif
#define SP_CAPTURE_CURRENT_TIME (sp_clock_get_current_time())
#define SP_CAPTURE_COUNTER_INT64 0
#define SP_CAPTURE_COUNTER_DOUBLE 1
typedef struct _SpCaptureReader SpCaptureReader;
typedef struct _SpCaptureWriter SpCaptureWriter;
typedef struct _SpCaptureCursor SpCaptureCursor;
typedef struct _SpCaptureCondition SpCaptureCondition;
typedef guint64 SpCaptureAddress;
typedef union
{
gint64 v64;
gdouble vdbl;
} SpCaptureCounterValue;
typedef enum
{
SP_CAPTURE_FRAME_TIMESTAMP = 1,
SP_CAPTURE_FRAME_SAMPLE = 2,
SP_CAPTURE_FRAME_MAP = 3,
SP_CAPTURE_FRAME_PROCESS = 4,
SP_CAPTURE_FRAME_FORK = 5,
SP_CAPTURE_FRAME_EXIT = 6,
SP_CAPTURE_FRAME_JITMAP = 7,
SP_CAPTURE_FRAME_CTRDEF = 8,
SP_CAPTURE_FRAME_CTRSET = 9,
SP_CAPTURE_FRAME_MARK = 10,
} SpCaptureFrameType;
#pragma pack(push, 1)
typedef struct
{
guint32 magic;
guint8 version;
guint32 little_endian : 1;
guint32 padding : 23;
gchar capture_time[64];
gint64 time;
gint64 end_time;
gchar suffix[168];
} SpCaptureFileHeader;
typedef struct
{
guint16 len;
gint16 cpu;
gint32 pid;
gint64 time;
guint8 type;
guint64 padding : 56;
guint8 data[0];
} SpCaptureFrame;
typedef struct
{
SpCaptureFrame frame;
guint64 start;
guint64 end;
guint64 offset;
guint64 inode;
gchar filename[0];
} SpCaptureMap;
typedef struct
{
SpCaptureFrame frame;
guint32 n_jitmaps;
guint8 data[0];
} SpCaptureJitmap;
typedef struct
{
SpCaptureFrame frame;
gchar cmdline[0];
} SpCaptureProcess;
typedef struct
{
SpCaptureFrame frame;
guint16 n_addrs;
guint64 padding : 48;
SpCaptureAddress addrs[0];
} SpCaptureSample;
typedef struct
{
SpCaptureFrame frame;
GPid child_pid;
} SpCaptureFork;
typedef struct
{
SpCaptureFrame frame;
} SpCaptureExit;
typedef struct
{
SpCaptureFrame frame;
} SpCaptureTimestamp;
typedef struct
{
gchar category[32];
gchar name[32];
gchar description[52];
guint32 id : 24;
guint8 type;
SpCaptureCounterValue value;
} SpCaptureCounter;
typedef struct
{
SpCaptureFrame frame;
guint16 n_counters;
guint64 padding : 48;
SpCaptureCounter counters[0];
} SpCaptureFrameCounterDefine;
typedef struct
{
/*
* 96 bytes might seem a bit odd, but the counter frame header is 32
* bytes. So this makes a nice 2-cacheline aligned size which is
* useful when the number of counters is rather small.
*/
guint32 ids[8];
SpCaptureCounterValue values[8];
} SpCaptureCounterValues;
typedef struct
{
SpCaptureFrame frame;
guint16 n_values;
guint64 padding : 48;
SpCaptureCounterValues values[0];
} SpCaptureFrameCounterSet;
typedef struct
{
SpCaptureFrame frame;
gint64 duration;
gchar group[24];
gchar name[40];
gchar message[0];
} SpCaptureMark;
#pragma pack(pop)
G_STATIC_ASSERT (sizeof (SpCaptureFileHeader) == 256);
G_STATIC_ASSERT (sizeof (SpCaptureFrame) == 24);
G_STATIC_ASSERT (sizeof (SpCaptureMap) == 56);
G_STATIC_ASSERT (sizeof (SpCaptureJitmap) == 28);
G_STATIC_ASSERT (sizeof (SpCaptureProcess) == 24);
G_STATIC_ASSERT (sizeof (SpCaptureSample) == 32);
G_STATIC_ASSERT (sizeof (SpCaptureFork) == 28);
G_STATIC_ASSERT (sizeof (SpCaptureExit) == 24);
G_STATIC_ASSERT (sizeof (SpCaptureTimestamp) == 24);
G_STATIC_ASSERT (sizeof (SpCaptureCounter) == 128);
G_STATIC_ASSERT (sizeof (SpCaptureCounterValues) == 96);
G_STATIC_ASSERT (sizeof (SpCaptureFrameCounterDefine) == 32);
G_STATIC_ASSERT (sizeof (SpCaptureFrameCounterSet) == 32);
G_STATIC_ASSERT (sizeof (SpCaptureMark) == 96);
static inline gint
sp_capture_address_compare (SpCaptureAddress a,
SpCaptureAddress b)
{
if (a < b)
return -1;
if (a > b)
return 1;
else
return 0;
}
G_END_DECLS
#endif /* SP_CAPTURE_FORMAT_H */
File diff suppressed because it is too large Load Diff
-132
View File
@@ -1,132 +0,0 @@
/* sp-capture-writer.h
*
* Copyright © 2016 Christian Hergert <chergert@redhat.com>
*
* This file is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SP_CAPTURE_WRITER_H
#define SP_CAPTURE_WRITER_H
#include "capture/sp-capture-types.h"
G_BEGIN_DECLS
typedef struct _SpCaptureWriter SpCaptureWriter;
typedef struct
{
/*
* The number of frames indexed by SpCaptureFrameType
*/
gsize frame_count[16];
/*
* Padding for future expansion.
*/
gsize padding[48];
} SpCaptureStat;
SpCaptureWriter *sp_capture_writer_new (const gchar *filename,
gsize buffer_size);
SpCaptureWriter *sp_capture_writer_new_from_fd (int fd,
gsize buffer_size);
SpCaptureWriter *sp_capture_writer_ref (SpCaptureWriter *self);
void sp_capture_writer_unref (SpCaptureWriter *self);
void sp_capture_writer_stat (SpCaptureWriter *self,
SpCaptureStat *stat);
gboolean sp_capture_writer_add_map (SpCaptureWriter *self,
gint64 time,
gint cpu,
GPid pid,
guint64 start,
guint64 end,
guint64 offset,
guint64 inode,
const gchar *filename);
gboolean sp_capture_writer_add_mark (SpCaptureWriter *self,
gint64 time,
gint cpu,
GPid pid,
guint64 duration,
const gchar *group,
const gchar *name,
const gchar *message);
guint64 sp_capture_writer_add_jitmap (SpCaptureWriter *self,
const gchar *name);
gboolean sp_capture_writer_add_process (SpCaptureWriter *self,
gint64 time,
gint cpu,
GPid pid,
const gchar *cmdline);
gboolean sp_capture_writer_add_sample (SpCaptureWriter *self,
gint64 time,
gint cpu,
GPid pid,
const SpCaptureAddress *addrs,
guint n_addrs);
gboolean sp_capture_writer_add_fork (SpCaptureWriter *self,
gint64 time,
gint cpu,
GPid pid,
GPid child_pid);
gboolean sp_capture_writer_add_exit (SpCaptureWriter *self,
gint64 time,
gint cpu,
GPid pid);
gboolean sp_capture_writer_add_timestamp (SpCaptureWriter *self,
gint64 time,
gint cpu,
GPid pid);
gboolean sp_capture_writer_define_counters (SpCaptureWriter *self,
gint64 time,
gint cpu,
GPid pid,
const SpCaptureCounter *counters,
guint n_counters);
gboolean sp_capture_writer_set_counters (SpCaptureWriter *self,
gint64 time,
gint cpu,
GPid pid,
const guint *counters_ids,
const SpCaptureCounterValue *values,
guint n_counters);
gboolean sp_capture_writer_flush (SpCaptureWriter *self);
gboolean sp_capture_writer_save_as (SpCaptureWriter *self,
const gchar *filename,
GError **error);
gint sp_capture_writer_request_counter (SpCaptureWriter *self,
guint n_counters);
SpCaptureReader *sp_capture_writer_create_reader (SpCaptureWriter *self,
GError **error);
gboolean sp_capture_writer_splice (SpCaptureWriter *self,
SpCaptureWriter *dest,
GError **error);
gboolean _sp_capture_writer_splice_from_fd (SpCaptureWriter *self,
int fd,
GError **error) G_GNUC_INTERNAL;
#ifndef SP_DISABLE_GOBJECT
# define SP_TYPE_CAPTURE_WRITER (sp_capture_writer_get_type())
GType sp_capture_writer_get_type (void);
#endif
#if GLIB_CHECK_VERSION(2, 44, 0)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SpCaptureWriter, sp_capture_writer_unref)
#endif
G_END_DECLS
#endif /* SP_CAPTURE_WRITER_H */
-52
View File
@@ -1,52 +0,0 @@
/* sp-clock.c
*
* Copyright © 2016 Christian Hergert <chergert@redhat.com>
*
* This file is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "sp-clock.h"
gint sp_clock = -1;
void
sp_clock_init (void)
{
static const gint clock_ids[] = {
CLOCK_MONOTONIC_RAW,
CLOCK_MONOTONIC_COARSE,
CLOCK_MONOTONIC,
CLOCK_REALTIME_COARSE,
CLOCK_REALTIME,
};
guint i;
if (sp_clock != -1)
return;
for (i = 0; i < G_N_ELEMENTS (clock_ids); i++)
{
struct timespec ts;
int clock_id = clock_ids [i];
if (0 == clock_gettime (clock_id, &ts))
{
sp_clock = clock_id;
return;
}
}
g_assert_not_reached ();
}
-55
View File
@@ -1,55 +0,0 @@
/* sp-clock.h
*
* Copyright © 2016 Christian Hergert <chergert@redhat.com>
*
* This file is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SP_CLOCK_H
#define SP_CLOCK_H
#include <glib.h>
#include <time.h>
G_BEGIN_DECLS
typedef gint SpClock;
typedef gint64 SpTimeStamp;
typedef gint32 SpTimeSpan;
extern SpClock sp_clock;
static inline SpTimeStamp
sp_clock_get_current_time (void)
{
struct timespec ts;
clock_gettime (sp_clock, &ts);
return (ts.tv_sec * G_GINT64_CONSTANT (1000000000)) + ts.tv_nsec;
}
static inline SpTimeSpan
sp_clock_get_relative_time (SpTimeStamp epoch)
{
return sp_clock_get_current_time () - epoch;
}
void sp_clock_init (void);
G_END_DECLS
#endif /* SP_CLOCK_H */
-6
View File
@@ -26,7 +26,6 @@
#include "gdkversionmacros.h"
#include "gdkprofilerprivate.h"
#include "gdkinternals.h"
#include "gdkintl.h"
@@ -212,11 +211,6 @@ gdk_pre_parse (void)
_gdk_debug_flags = g_parse_debug_string (debug_string,
(GDebugKey *) gdk_debug_keys,
G_N_ELEMENTS (gdk_debug_keys));
if (g_getenv ("SYSPROF_TRACE_FD"))
gdk_profiler_start (atoi (g_getenv ("SYSPROF_TRACE_FD")));
else if (g_getenv ("GTK_TRACE"))
gdk_profiler_start (-1);
}
#endif /* G_ENABLE_DEBUG */
+3 -105
View File
@@ -29,7 +29,6 @@
#include "gdkinternals.h"
#include "gdkframeclockprivate.h"
#include "gdk.h"
#include "gdkprofilerprivate.h"
#ifdef G_OS_WIN32
#include <windows.h>
@@ -114,96 +113,6 @@ get_sleep_serial (void)
return sleep_serial;
}
static guint fps_counter = 0;
static void
add_timings_to_profiler (GdkFrameTimings *timings)
{
gdk_profiler_add_mark (timings->frame_time * 1000,
(timings->frame_end_time - timings->frame_time) * 1000,
"frame", "");
if (timings->layout_start_time != 0)
gdk_profiler_add_mark (timings->layout_start_time * 1000,
(timings->paint_start_time - timings->layout_start_time) * 1000,
"layout", "");
if (timings->paint_start_time != 0)
gdk_profiler_add_mark (timings->paint_start_time * 1000,
(timings->frame_end_time - timings->paint_start_time) * 1000,
"paint", "");
}
static gint64
guess_refresh_interval (GdkFrameClock *frame_clock)
{
gint64 interval;
gint64 i;
interval = G_MAXINT64;
for (i = gdk_frame_clock_get_history_start (frame_clock);
i < gdk_frame_clock_get_frame_counter (frame_clock);
i++)
{
GdkFrameTimings *t, *before;
gint64 ts, before_ts;
t = gdk_frame_clock_get_timings (frame_clock, i);
before = gdk_frame_clock_get_timings (frame_clock, i - 1);
if (t == NULL || before == NULL)
continue;
ts = gdk_frame_timings_get_frame_time (t);
before_ts = gdk_frame_timings_get_frame_time (before);
if (ts == 0 || before_ts == 0)
continue;
interval = MIN (interval, ts - before_ts);
}
if (interval == G_MAXINT64)
return 0;
return interval;
}
static double
frame_clock_get_fps (GdkFrameClock *frame_clock)
{
GdkFrameTimings *start, *end;
gint64 start_counter, end_counter;
gint64 start_timestamp, end_timestamp;
gint64 interval;
start_counter = gdk_frame_clock_get_history_start (frame_clock);
end_counter = gdk_frame_clock_get_frame_counter (frame_clock);
start = gdk_frame_clock_get_timings (frame_clock, start_counter);
for (end = gdk_frame_clock_get_timings (frame_clock, end_counter);
end_counter > start_counter && end != NULL && !gdk_frame_timings_get_complete (end);
end = gdk_frame_clock_get_timings (frame_clock, end_counter))
end_counter--;
if (end_counter - start_counter < 4)
return 0.0;
start_timestamp = gdk_frame_timings_get_presentation_time (start);
end_timestamp = gdk_frame_timings_get_presentation_time (end);
if (start_timestamp == 0 || end_timestamp == 0)
{
start_timestamp = gdk_frame_timings_get_frame_time (start);
end_timestamp = gdk_frame_timings_get_frame_time (end);
}
interval = gdk_frame_timings_get_refresh_interval (end);
if (interval == 0)
{
interval = guess_refresh_interval (frame_clock);
if (interval == 0)
return 0.0;
}
return ((double) end_counter - start_counter) * G_USEC_PER_SEC / (end_timestamp - start_timestamp);
}
static void
gdk_frame_clock_idle_init (GdkFrameClockIdle *frame_clock_idle)
{
@@ -214,11 +123,6 @@ gdk_frame_clock_idle_init (GdkFrameClockIdle *frame_clock_idle)
priv->frame_time = g_get_monotonic_time (); /* more sane than zero */
priv->freeze_count = 0;
#ifdef G_ENABLE_DEBUG
if (fps_counter == 0)
fps_counter = gdk_profiler_define_counter ("fps", "Frames per Second");
#endif
}
static void
@@ -501,7 +405,7 @@ gdk_frame_clock_paint_idle (void *data)
{
int iter;
#ifdef G_ENABLE_DEBUG
if (GDK_DEBUG_CHECK (FRAMES) || gdk_profiler_is_running ())
if (GDK_DEBUG_CHECK (FRAMES))
{
if (priv->phase != GDK_FRAME_CLOCK_PHASE_LAYOUT &&
(priv->requested & GDK_FRAME_CLOCK_PHASE_LAYOUT))
@@ -531,7 +435,7 @@ gdk_frame_clock_paint_idle (void *data)
if (priv->freeze_count == 0)
{
#ifdef G_ENABLE_DEBUG
if (GDK_DEBUG_CHECK (FRAMES) || gdk_profiler_is_running ())
if (GDK_DEBUG_CHECK (FRAMES))
{
if (priv->phase != GDK_FRAME_CLOCK_PHASE_PAINT &&
(priv->requested & GDK_FRAME_CLOCK_PHASE_PAINT))
@@ -558,7 +462,7 @@ gdk_frame_clock_paint_idle (void *data)
priv->phase = GDK_FRAME_CLOCK_PHASE_NONE;
#ifdef G_ENABLE_DEBUG
if (GDK_DEBUG_CHECK (FRAMES) || gdk_profiler_is_running ())
if (GDK_DEBUG_CHECK (FRAMES))
timings->frame_end_time = g_get_monotonic_time ();
#endif /* G_ENABLE_DEBUG */
}
@@ -571,12 +475,6 @@ gdk_frame_clock_paint_idle (void *data)
}
#ifdef G_ENABLE_DEBUG
if (gdk_profiler_is_running ())
{
add_timings_to_profiler (timings);
gdk_profiler_set_counter (fps_counter, timings->frame_end_time * 1000, frame_clock_get_fps (clock));
}
if (GDK_DEBUG_CHECK (FRAMES))
{
if (timings && timings->complete)
-230
View File
@@ -1,230 +0,0 @@
/* GDK - The GIMP Drawing Kit
*
* gdkprofiler.c: A simple profiler
*
* Copyright © 2018 Matthias Clasen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "gdkversionmacros.h"
#include "gdkprofilerprivate.h"
#include "gdkframeclockprivate.h"
#ifndef G_OS_WIN32
#include "capture/sp-capture-writer.h"
static SpCaptureWriter *writer = NULL;
static gboolean running = FALSE;
static void
profiler_stop (void)
{
if (writer)
sp_capture_writer_unref (writer);
}
void
gdk_profiler_start (int fd)
{
if (writer)
return;
sp_clock_init ();
if (fd == -1)
{
gchar *filename;
filename = g_strdup_printf ("gtk.%d.syscap", getpid ());
g_print ("Writing profiling data to %s\n", filename);
writer = sp_capture_writer_new (filename, 16*1024);
g_free (filename);
}
else if (fd > 2)
writer = sp_capture_writer_new_from_fd (fd, 16*1024);
if (writer)
running = TRUE;
atexit (profiler_stop);
}
void
gdk_profiler_stop (void)
{
running = FALSE;
}
gboolean
gdk_profiler_is_running (void)
{
return running;
}
void
gdk_profiler_add_mark (gint64 start,
guint64 duration,
const char *name,
const char *message)
{
if (!running)
return;
sp_capture_writer_add_mark (writer,
start,
-1, getpid (),
duration,
"gtk", name, message);
}
static guint
define_counter (const char *name,
const char *description,
int type)
{
SpCaptureCounter counter;
if (!writer)
return 0;
counter.id = (guint) sp_capture_writer_request_counter (writer, 1);
counter.type = type;
counter.value.vdbl = 0;
g_strlcpy (counter.category, "gtk", sizeof counter.category);
g_strlcpy (counter.name, name, sizeof counter.name);
g_strlcpy (counter.description, description, sizeof counter.name);
sp_capture_writer_define_counters (writer,
SP_CAPTURE_CURRENT_TIME,
-1,
getpid (),
&counter,
1);
return counter.id;
}
guint
gdk_profiler_define_counter (const char *name,
const char *description)
{
return define_counter (name, description, SP_CAPTURE_COUNTER_DOUBLE);
}
guint
gdk_profiler_define_int_counter (const char *name,
const char *description)
{
return define_counter (name, description, SP_CAPTURE_COUNTER_INT64);
}
void
gdk_profiler_set_counter (guint id,
gint64 time,
double val)
{
SpCaptureCounterValue value;
if (!running)
return;
value.vdbl = val;
sp_capture_writer_set_counters (writer,
time,
-1, getpid (),
&id, &value, 1);
}
void
gdk_profiler_set_int_counter (guint id,
gint64 time,
gint64 val)
{
SpCaptureCounterValue value;
if (!running)
return;
value.v64 = val;
sp_capture_writer_set_counters (writer,
time,
-1, getpid (),
&id, &value, 1);
}
#else
void
gdk_profiler_start (int fd)
{
}
void
gdk_profiler_stop (void)
{
}
gboolean
gdk_profiler_is_running (void)
{
return FALSE;
}
void
gdk_profiler_add_mark (gint64 start,
guint64 duration,
const char *name,
const char *message)
{
}
guint
gdk_profiler_define_counter (const char *name,
const char *description)
{
return 0;
}
void
gdk_profiler_set_counter (guint id,
gint64 time,
double value)
{
}
guint
gdk_profiler_define_int_counter (const char *name,
const char *description)
{
return 0;
}
void
gdk_profiler_set_int_counter (guint id,
gint64 time,
gint64 value)
{
}
#endif /* G_OS_WIN32 */
-46
View File
@@ -1,46 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2018 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GDK_PROFILER_PRIVATE_H__
#define __GDK_PROFILER_PRIVATE_H__
#include "gdk/gdkframeclock.h"
#include "gdk/gdkdisplay.h"
G_BEGIN_DECLS
void gdk_profiler_start (int fd);
void gdk_profiler_stop (void);
gboolean gdk_profiler_is_running (void);
void gdk_profiler_add_mark (gint64 start,
guint64 duration,
const char *name,
const char *message);
guint gdk_profiler_define_counter (const char *name,
const char *description);
void gdk_profiler_set_counter (guint id,
gint64 time,
double value);
guint gdk_profiler_define_int_counter (const char *name,
const char *description);
void gdk_profiler_set_int_counter (guint id,
gint64 time,
gint64 value);
G_END_DECLS
#endif /* __GDK_PROFILER_PRIVATE_H__ */
+1 -4
View File
@@ -4202,10 +4202,7 @@ void
gdk_surface_set_startup_id (GdkSurface *surface,
const gchar *startup_id)
{
GdkSurfaceImplClass *klass = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
if (klass->set_startup_id)
klass->set_startup_id (surface, startup_id);
GDK_SURFACE_IMPL_GET_CLASS (surface->impl)->set_startup_id (surface, startup_id);
}
/**
-8
View File
@@ -45,16 +45,8 @@ gdk_public_sources = files([
'gdkvulkancontext.c',
'gdksurface.c',
'gdksurfaceimpl.c',
'gdkprofiler.c'
])
if not win32_enabled
gdk_public_sources += files([
'capture/sp-capture-writer.c',
'capture/sp-clock.c'
])
endif
gdk_public_headers = files([
'gdk-autocleanup.h',
'gdk.h',
+2 -1
View File
@@ -33,7 +33,8 @@ gdk_quartz_public_headers = files([
'gdkquartzsurface.h',
])
install_headers(gdk_quartz_public_headers, 'gdkquartz.h', subdir: 'gtk-4.0/gdk/quartz/')
install_headers(gdk_quartz_public_headers, subdir: 'gtk-4.0/gdk/quartz/')
install_headers('gdkquartz.h', subdir: 'gtk-4.0/gdk/')
gdk_quartz_deps = [ # FIXME
]
+2 -1
View File
@@ -26,7 +26,8 @@ gdk_wayland_public_headers = files([
'gdkwaylandsurface.h'
])
install_headers(gdk_wayland_public_headers, 'gdkwayland.h', subdir: 'gtk-4.0/gdk/wayland/')
install_headers(gdk_wayland_public_headers, subdir: 'gtk-4.0/gdk/wayland/')
install_headers('gdkwayland.h', subdir: 'gtk-4.0/gdk/')
gdk_wayland_deps = [
shmlib,
+2 -1
View File
@@ -42,7 +42,8 @@ gdk_win32_public_headers = files([
'gdkwin32surface.h',
])
install_headers(gdk_win32_public_headers, 'gdkwin32.h', subdir: 'gtk-4.0/gdk/win32/')
install_headers(gdk_win32_public_headers, subdir: 'gtk-4.0/gdk/win32/')
install_headers('gdkwin32.h', subdir: 'gtk-4.0/gdk/')
gdk_win32_deps = [ # FIXME
pangowin32_dep
+2 -1
View File
@@ -54,7 +54,8 @@ gdk_x11_public_headers = files([
'gdkx11surface.h',
])
install_headers(gdk_x11_public_headers, 'gdkx.h', subdir: 'gtk-4.0/gdk/x11/')
install_headers(gdk_x11_public_headers, subdir: 'gtk-4.0/gdk/x11/')
install_headers('gdkx.h', subdir: 'gtk-4.0/gdk/')
gdk_x11_deps = [
xrender_dep,
+1 -22
View File
@@ -1,7 +1,6 @@
#include "config.h"
#include "gskbroadwayrenderer.h"
#include "gskbroadwayrendererprivate.h"
#include "broadway/gdkprivate-broadway.h"
#include "gskdebugprivate.h"
@@ -828,23 +827,3 @@ static void
gsk_broadway_renderer_init (GskBroadwayRenderer *self)
{
}
/**
* gsk_broadway_renderer_new:
*
* Creates a new Broadway renderer.
*
* The Broadway renderer is the default renderer for the broadway backend.
* It will only work with broadway surfaces, otherwise it will fail the
* call to gdk_renderer_realize().
*
* This function is only available when GTK was compiled with Broadway
* support.
*
* Returns: a new Broadway renderer.
**/
GskRenderer *
gsk_broadway_renderer_new (void)
{
return g_object_new (GSK_TYPE_BROADWAY_RENDERER, NULL);
}
-52
View File
@@ -1,52 +0,0 @@
/*
* Copyright © 2019 Alexander Larsson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GSK_BROADWAY_RENDERER_H__
#define __GSK_BROADWAY_RENDERER_H__
#include <gdk/gdk.h>
#include <gsk/gskrenderer.h>
#ifdef GDK_WINDOWING_BROADWAY
#include <gdk/broadway/gdkbroadway.h>
G_BEGIN_DECLS
#define GSK_TYPE_BROADWAY_RENDERER (gsk_broadway_renderer_get_type ())
#define GSK_BROADWAY_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSK_TYPE_BROADWAY_RENDERER, GskBroadwayRenderer))
#define GSK_IS_BROADWAY_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSK_TYPE_BROADWAY_RENDERER))
#define GSK_BROADWAY_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSK_TYPE_BROADWAY_RENDERER, GskBroadwayRendererClass))
#define GSK_IS_BROADWAY_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSK_TYPE_BROADWAY_RENDERER))
#define GSK_BROADWAY_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSK_TYPE_BROADWAY_RENDERER, GskBroadwayRendererClass))
typedef struct _GskBroadwayRenderer GskBroadwayRenderer;
typedef struct _GskBroadwayRendererClass GskBroadwayRendererClass;
GDK_AVAILABLE_IN_ALL
GType gsk_broadway_renderer_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GskRenderer * gsk_broadway_renderer_new (void);
G_END_DECLS
#endif /* GDK_WINDOWING_BROADWAY */
#endif /* __GSK_BROADWAY_RENDERER_H__ */
+24
View File
@@ -0,0 +1,24 @@
#ifndef __GSK_BROADWAY_RENDERER_PRIVATE_H__
#define __GSK_BROADWAY_RENDERER_PRIVATE_H__
#include "broadway/gdkbroadway.h"
#include <gsk/gskrenderer.h>
G_BEGIN_DECLS
#define GSK_TYPE_BROADWAY_RENDERER (gsk_broadway_renderer_get_type ())
#define GSK_BROADWAY_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSK_TYPE_BROADWAY_RENDERER, GskBroadwayRenderer))
#define GSK_IS_BROADWAY_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSK_TYPE_BROADWAY_RENDERER))
#define GSK_BROADWAY_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSK_TYPE_BROADWAY_RENDERER, GskBroadwayRendererClass))
#define GSK_IS_BROADWAY_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSK_TYPE_BROADWAY_RENDERER))
#define GSK_BROADWAY_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSK_TYPE_BROADWAY_RENDERER, GskBroadwayRendererClass))
typedef struct _GskBroadwayRenderer GskBroadwayRenderer;
typedef struct _GskBroadwayRendererClass GskBroadwayRendererClass;
GType gsk_broadway_renderer_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GSK_BROADWAY_RENDERER_PRIVATE_H__ */
+5 -33
View File
@@ -1,6 +1,6 @@
#include "config.h"
#include "gskglrenderer.h"
#include "gskglrendererprivate.h"
#include "gskdebugprivate.h"
#include "gskenums.h"
@@ -21,7 +21,6 @@
#include "gdk/gdkgltextureprivate.h"
#include "gdk/gdkglcontextprivate.h"
#include "gdk/gdkprofilerprivate.h"
#include <epoxy/gl.h>
#include <cairo-ft.h>
@@ -1269,17 +1268,10 @@ render_blur_node (GskGLRenderer *self,
const float min_y = builder->dy + node->bounds.origin.y;
const float max_x = min_x + node->bounds.size.width;
const float max_y = min_y + node->bounds.size.height;
const float blur_radius = gsk_blur_node_get_radius (node);
int texture_id;
gboolean is_offscreen;
RenderOp op;
if (blur_radius <= 0)
{
gsk_gl_renderer_add_render_ops (self, gsk_blur_node_get_child (node), builder);
return;
}
/* TODO(perf): We're forcing the child offscreen even if it's a texture
* so the resulting offscreen texture is bigger by the gaussian blur factor
* (see gsk_blur_node_new), but we didn't have to do that if the blur
@@ -1891,13 +1883,13 @@ render_cross_fade_node (GskGLRenderer *self,
&node->bounds,
start_node,
&start_texture_id, &is_offscreen1,
FORCE_OFFSCREEN | RESET_CLIP | RESET_OPACITY);
FORCE_OFFSCREEN | RESET_CLIP);
add_offscreen_ops (self, builder,
&node->bounds,
end_node,
&end_texture_id, &is_offscreen2,
FORCE_OFFSCREEN | RESET_CLIP | RESET_OPACITY);
FORCE_OFFSCREEN | RESET_CLIP);
ops_set_program (builder, &self->cross_fade_program);
op.op = OP_CHANGE_CROSS_FADE;
@@ -3009,7 +3001,7 @@ gsk_gl_renderer_do_render (GskRenderer *renderer,
gsize buffer_size;
#ifdef G_ENABLE_DEBUG
GskProfiler *profiler;
gint64 gpu_time, cpu_time, start_time;
gint64 gpu_time, cpu_time;
#endif
#ifdef G_ENABLE_DEBUG
@@ -3117,7 +3109,6 @@ gsk_gl_renderer_do_render (GskRenderer *renderer,
#ifdef G_ENABLE_DEBUG
gsk_profiler_counter_inc (profiler, self->profile_counters.frames);
start_time = gsk_profiler_timer_get_start (profiler, self->profile_timers.cpu_time);
cpu_time = gsk_profiler_timer_end (profiler, self->profile_timers.cpu_time);
gsk_profiler_timer_set (profiler, self->profile_timers.cpu_time, cpu_time);
@@ -3125,10 +3116,6 @@ gsk_gl_renderer_do_render (GskRenderer *renderer,
gsk_profiler_timer_set (profiler, self->profile_timers.gpu_time, gpu_time);
gsk_profiler_push_samples (profiler);
if (gdk_profiler_is_running ())
gdk_profiler_add_mark (start_time, cpu_time, "render", "");
#endif
}
@@ -3145,7 +3132,6 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer,
g_return_val_if_fail (self->gl_context != NULL, NULL);
gdk_gl_context_make_current (self->gl_context);
gdk_gl_context_push_debug_group_printf (self->gl_context,
"Render %s<%p> to texture", root->node_class->type_name, root);
@@ -3153,6 +3139,7 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer,
height = ceilf (viewport->size.height);
self->scale_factor = gdk_surface_get_scale_factor (gsk_renderer_get_surface (renderer));
gdk_gl_context_make_current (self->gl_context);
/* Prepare our framebuffer */
gsk_gl_driver_begin_frame (self->gl_driver);
@@ -3204,7 +3191,6 @@ gsk_gl_renderer_render (GskRenderer *renderer,
if (self->gl_context == NULL)
return;
gdk_gl_context_make_current (self->gl_context);
gdk_gl_context_push_debug_group_printf (self->gl_context,
"Render root node %p", root);
@@ -3295,17 +3281,3 @@ gsk_gl_renderer_init (GskGLRenderer *self)
}
#endif
}
/**
* gsk_gl_renderer_new:
*
* Creates a new #GskRenderer using OpenGL. This is the default renderer
* used by GTK.
*
* Returns: a new GL renderer
**/
GskRenderer *
gsk_gl_renderer_new (void)
{
return g_object_new (GSK_TYPE_GL_RENDERER, NULL);
}
-47
View File
@@ -1,47 +0,0 @@
/*
* Copyright © 2016 Endless
* 2018 Timm Bäder <mail@baedert.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Timm Bäder <mail@baedert.org>
*/
#ifndef __GSK_GL_RENDERER_H__
#define __GSK_GL_RENDERER_H__
#include <gsk/gskrenderer.h>
G_BEGIN_DECLS
#define GSK_TYPE_GL_RENDERER (gsk_gl_renderer_get_type ())
#define GSK_GL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSK_TYPE_GL_RENDERER, GskGLRenderer))
#define GSK_IS_GL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSK_TYPE_GL_RENDERER))
#define GSK_GL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSK_TYPE_GL_RENDERER, GskGLRendererClass))
#define GSK_IS_GL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSK_TYPE_GL_RENDERER))
#define GSK_GL_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSK_TYPE_GL_RENDERER, GskGLRendererClass))
typedef struct _GskGLRenderer GskGLRenderer;
typedef struct _GskGLRendererClass GskGLRendererClass;
GDK_AVAILABLE_IN_ALL
GType gsk_gl_renderer_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GskRenderer * gsk_gl_renderer_new (void);
G_END_DECLS
#endif /* __GSK_GL_RENDERER_H__ */
+23
View File
@@ -0,0 +1,23 @@
#ifndef __GSK_GL_RENDERER_PRIVATE_H__
#define __GSK_GL_RENDERER_PRIVATE_H__
#include <gsk/gskrenderer.h>
G_BEGIN_DECLS
#define GSK_TYPE_GL_RENDERER (gsk_gl_renderer_get_type ())
#define GSK_GL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSK_TYPE_GL_RENDERER, GskGLRenderer))
#define GSK_IS_GL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSK_TYPE_GL_RENDERER))
#define GSK_GL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSK_TYPE_GL_RENDERER, GskGLRendererClass))
#define GSK_IS_GL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSK_TYPE_GL_RENDERER))
#define GSK_GL_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSK_TYPE_GL_RENDERER, GskGLRendererClass))
typedef struct _GskGLRenderer GskGLRenderer;
typedef struct _GskGLRendererClass GskGLRendererClass;
GType gsk_gl_renderer_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GSK_GL_RENDERER_PRIVATE_H__ */
+1 -1
View File
@@ -7,7 +7,7 @@
#include "gskgldriverprivate.h"
#include "gskroundedrectprivate.h"
#include "gskglrenderer.h"
#include "gskglrendererprivate.h"
#include "gskrendernodeprivate.h"
#define GL_N_VERTICES 6
-5
View File
@@ -26,11 +26,6 @@
#include <gsk/gskroundedrect.h>
#include <gsk/gsktransform.h>
#include <gsk/gskcairorenderer.h>
#include <gsk/gl/gskglrenderer.h>
#include <gsk/broadway/gskbroadwayrenderer.h>
#include <gsk/vulkan/gskvulkanrenderer.h>
#include <gsk/gsktypes.h>
#include <gsk/gskenumtypes.h>
+1 -41
View File
@@ -1,26 +1,6 @@
/*
* Copyright © 2016 Endless
* 2018 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#include "config.h"
#include "gskcairorenderer.h"
#include "gskcairorendererprivate.h"
#include "gskdebugprivate.h"
#include "gskrendererprivate.h"
@@ -179,23 +159,3 @@ gsk_cairo_renderer_init (GskCairoRenderer *self)
self->profile_timers.cpu_time = gsk_profiler_add_timer (profiler, "cpu-time", "CPU time", FALSE, TRUE);
#endif
}
/**
* gsk_cairo_renderer_new:
*
* Creates a new Cairo renderer.
*
* The Cairo renderer is the fallback renderer drawing in ways similar
* to how GTK 3 drew its content. Its primary use is as comparison tool.
*
* The Cairo renderer is incomplete. It cannot render 3D transformed
* content and will instead render an error marker. Its usage should be
* avoided.
*
* Returns: a new Cairo renderer.
**/
GskRenderer *
gsk_cairo_renderer_new (void)
{
return g_object_new (GSK_TYPE_CAIRO_RENDERER, NULL);
}
-48
View File
@@ -1,48 +0,0 @@
/*
* Copyright © 2016 Endless
* 2018 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#ifndef __GSK_CAIRO_RENDERER_H__
#define __GSK_CAIRO_RENDERER_H__
#include <cairo.h>
#include <gsk/gskrenderer.h>
G_BEGIN_DECLS
#define GSK_TYPE_CAIRO_RENDERER (gsk_cairo_renderer_get_type ())
#define GSK_CAIRO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSK_TYPE_CAIRO_RENDERER, GskCairoRenderer))
#define GSK_IS_CAIRO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSK_TYPE_CAIRO_RENDERER))
#define GSK_CAIRO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSK_TYPE_CAIRO_RENDERER, GskCairoRendererClass))
#define GSK_IS_CAIRO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSK_TYPE_CAIRO_RENDERER))
#define GSK_CAIRO_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSK_TYPE_CAIRO_RENDERER, GskCairoRendererClass))
typedef struct _GskCairoRenderer GskCairoRenderer;
typedef struct _GskCairoRendererClass GskCairoRendererClass;
GDK_AVAILABLE_IN_ALL
GType gsk_cairo_renderer_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GskRenderer * gsk_cairo_renderer_new (void);
G_END_DECLS
#endif /* __GSK_CAIRO_RENDERER_H__ */
+24
View File
@@ -0,0 +1,24 @@
#ifndef __GSK_CAIRO_RENDERER_PRIVATE_H__
#define __GSK_CAIRO_RENDERER_PRIVATE_H__
#include <cairo.h>
#include <gsk/gskrenderer.h>
G_BEGIN_DECLS
#define GSK_TYPE_CAIRO_RENDERER (gsk_cairo_renderer_get_type ())
#define GSK_CAIRO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSK_TYPE_CAIRO_RENDERER, GskCairoRenderer))
#define GSK_IS_CAIRO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSK_TYPE_CAIRO_RENDERER))
#define GSK_CAIRO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSK_TYPE_CAIRO_RENDERER, GskCairoRendererClass))
#define GSK_IS_CAIRO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSK_TYPE_CAIRO_RENDERER))
#define GSK_CAIRO_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSK_TYPE_CAIRO_RENDERER, GskCairoRendererClass))
typedef struct _GskCairoRenderer GskCairoRenderer;
typedef struct _GskCairoRendererClass GskCairoRendererClass;
GType gsk_cairo_renderer_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GSK_CAIRO_RENDERER_PRIVATE_H__ */
-13
View File
@@ -365,19 +365,6 @@ gsk_profiler_timer_get (GskProfiler *profiler,
return timer->value;
}
gint64
gsk_profiler_timer_get_start (GskProfiler *profiler,
GQuark timer_id)
{
NamedTimer *timer;
timer = gsk_profiler_get_timer (profiler, timer_id);
if (timer == NULL)
return 0;
return timer->start_time;
}
void
gsk_profiler_reset (GskProfiler *profiler)
{
-2
View File
@@ -40,8 +40,6 @@ gint64 gsk_profiler_counter_get (GskProfiler *profiler,
GQuark counter_id);
gint64 gsk_profiler_timer_get (GskProfiler *profiler,
GQuark timer_id);
gint64 gsk_profiler_timer_get_start (GskProfiler *profiler,
GQuark timer_id);
void gsk_profiler_reset (GskProfiler *profiler);
+4 -4
View File
@@ -36,9 +36,9 @@
#include "gskrendererprivate.h"
#include "gskcairorenderer.h"
#include "gskcairorendererprivate.h"
#include "gskdebugprivate.h"
#include "gl/gskglrenderer.h"
#include "gl/gskglrendererprivate.h"
#include "gskprofilerprivate.h"
#include "gskrendernodeprivate.h"
@@ -55,10 +55,10 @@
#include <gdk/wayland/gdkwayland.h>
#endif
#ifdef GDK_WINDOWING_BROADWAY
#include "broadway/gskbroadwayrenderer.h"
#include "broadway/gskbroadwayrendererprivate.h"
#endif
#ifdef GDK_RENDERING_VULKAN
#include "vulkan/gskvulkanrenderer.h"
#include "vulkan/gskvulkanrendererprivate.h"
#endif
typedef struct
+41 -8
View File
@@ -42,7 +42,6 @@
#include "gskdebugprivate.h"
#include "gskrendererprivate.h"
#include "gskrendernodeparserprivate.h"
#include <graphene-gobject.h>
@@ -329,11 +328,19 @@ gsk_render_node_diff (GskRenderNode *node1,
GBytes *
gsk_render_node_serialize (GskRenderNode *node)
{
GVariant *node_variant, *variant;
GBytes *result;
char *str;
str = gsk_render_node_serialize_to_string (node);
result = g_bytes_new_take (str, strlen (str));
node_variant = gsk_render_node_serialize_node (node);
variant = g_variant_new ("(suuv)",
GSK_RENDER_NODE_SERIALIZATION_ID,
(guint32) GSK_RENDER_NODE_SERIALIZATION_VERSION,
(guint32) gsk_render_node_get_node_type (node),
node_variant);
result = g_variant_get_data_as_bytes (variant);
g_variant_unref (variant);
return result;
}
@@ -387,13 +394,39 @@ gsk_render_node_write_to_file (GskRenderNode *node,
* error.
**/
GskRenderNode *
gsk_render_node_deserialize (GBytes *bytes,
GskParseErrorFunc error_func,
gpointer user_data)
gsk_render_node_deserialize (GBytes *bytes,
GError **error)
{
char *id_string;
guint32 version, node_type;
GVariant *variant, *node_variant;
GskRenderNode *node = NULL;
node = gsk_render_node_deserialize_from_bytes (bytes, error_func, user_data);
variant = g_variant_new_from_bytes (G_VARIANT_TYPE ("(suuv)"), bytes, FALSE);
g_variant_get (variant, "(suuv)", &id_string, &version, &node_type, &node_variant);
if (!g_str_equal (id_string, GSK_RENDER_NODE_SERIALIZATION_ID))
{
g_set_error (error, GSK_SERIALIZATION_ERROR, GSK_SERIALIZATION_UNSUPPORTED_FORMAT,
"Data not in GskRenderNode serialization format.");
goto out;
}
if (version != GSK_RENDER_NODE_SERIALIZATION_VERSION)
{
g_set_error (error, GSK_SERIALIZATION_ERROR, GSK_SERIALIZATION_UNSUPPORTED_VERSION,
"Format version %u not supported.", version);
goto out;
}
node = gsk_render_node_deserialize_node (node_type, node_variant, error);
out:
g_free (id_string);
g_variant_unref (node_variant);
g_variant_unref (variant);
return node;
}
+2 -8
View File
@@ -25,7 +25,6 @@
#include <gsk/gskroundedrect.h>
#include <gsk/gsktypes.h>
#include <gtk/css/gtkcss.h>
G_BEGIN_DECLS
@@ -53,10 +52,6 @@ struct _GskShadow
float radius;
};
typedef void (* GskParseErrorFunc) (const GtkCssSection *section,
const GError *error,
gpointer user_data);
GDK_AVAILABLE_IN_ALL
GType gsk_render_node_get_type (void) G_GNUC_CONST;
@@ -86,9 +81,8 @@ gboolean gsk_render_node_write_to_file (GskRenderNode *
const char *filename,
GError **error);
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_render_node_deserialize (GBytes *bytes,
GskParseErrorFunc error_func,
gpointer user_data);
GskRenderNode * gsk_render_node_deserialize (GBytes *bytes,
GError **error);
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_debug_node_new (GskRenderNode *child,
+1319 -5
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-12
View File
@@ -1,12 +0,0 @@
#ifndef __GSK_RENDER_NODE_PARSER_PRIVATE_H__
#define __GSK_RENDER_NODE_PARSER_PRIVATE_H__
#include "gskrendernode.h"
GskRenderNode * gsk_render_node_deserialize_from_bytes (GBytes *bytes,
GskParseErrorFunc error_func,
gpointer user_data);
char * gsk_render_node_serialize_to_string (GskRenderNode *root);
#endif
+8
View File
@@ -33,6 +33,9 @@ struct _GskRenderNodeClass
void (* diff) (GskRenderNode *node1,
GskRenderNode *node2,
cairo_region_t *region);
GVariant * (* serialize) (GskRenderNode *node);
GskRenderNode * (* deserialize) (GVariant *variant,
GError **error);
};
GskRenderNode * gsk_render_node_new (const GskRenderNodeClass *node_class,
@@ -47,6 +50,11 @@ void gsk_render_node_diff_impossible (GskRenderNode *nod
GskRenderNode *node2,
cairo_region_t *region);
GVariant * gsk_render_node_serialize_node (GskRenderNode *node);
GskRenderNode * gsk_render_node_deserialize_node (GskRenderNodeType type,
GVariant *variant,
GError **error);
GskRenderNode * gsk_cairo_node_new_for_surface (const graphene_rect_t *bounds,
cairo_surface_t *surface);
+5 -24
View File
@@ -22,23 +22,22 @@ gsk_private_gl_shaders = [
gsk_public_sources = files([
'gskdiff.c',
'gskcairorenderer.c',
'gskrenderer.c',
'gskrendernode.c',
'gskrendernodeimpl.c',
'gskroundedrect.c',
'gsktransform.c',
'gl/gskglrenderer.c',
])
gsk_private_sources = files([
'gskcairoblur.c',
'gskcairorenderer.c',
'gskdebug.c',
'gskprivate.c',
'gskprofiler.c',
'gskrendernodeparser.c',
'gl/gskshaderbuilder.c',
'gl/gskglprofiler.c',
'gl/gskglrenderer.c',
'gl/gskglglyphcache.c',
'gl/gskglimage.c',
'gl/gskgldriver.c',
@@ -48,35 +47,17 @@ gsk_private_sources = files([
])
gsk_public_headers = files([
'gskcairorenderer.h',
'gskenums.h',
'gskrenderer.h',
'gskrendernode.h',
'gskroundedrect.h',
'gsktransform.h',
'gsktypes.h',
'gsk-autocleanup.h',
'gsk-autocleanup.h'
])
install_headers(gsk_public_headers, 'gsk.h', subdir: 'gtk-4.0/gsk')
gsk_public_gl_headers = files([
'gl/gskglrenderer.h'
])
install_headers(gsk_public_gl_headers, subdir: 'gtk-4.0/gsk/gl')
gsk_public_headers += gsk_public_gl_headers
gsk_public_broadway_headers = files([
'broadway/gskbroadwayrenderer.h'
])
install_headers(gsk_public_broadway_headers, subdir: 'gtk-4.0/gsk/broadway')
gsk_public_headers += gsk_public_broadway_headers
gsk_public_vulkan_headers = files([
'vulkan/gskvulkanrenderer.h'
])
install_headers(gsk_public_vulkan_headers, subdir: 'gtk-4.0/gsk/vulkan')
gsk_public_headers += gsk_public_vulkan_headers
gsk_private_vulkan_shaders = []
# This is an odd split because we use configure_file() below to workaround
# a limitation in meson preventing using custom_target() with gnome.compile_resources()
@@ -116,7 +97,7 @@ if have_vulkan
endif # have_vulkan
if get_variable('broadway_enabled')
gsk_public_sources += files([
gsk_private_sources += files([
'broadway/gskbroadwayrenderer.c',
])
endif
+16 -16
View File
@@ -264,22 +264,22 @@ void main() {
vec4 result;
switch(u_mode) {
case 0: result = normal(top_color, bottom_color); break;
case 1: result = multiply(top_color, bottom_color); break;
case 2: result = screen(top_color, bottom_color); break;
case 3: result = overlay(top_color, bottom_color); break;
case 4: result = darken(top_color, bottom_color); break;
case 5: result = lighten(top_color, bottom_color); break;
case 6: result = color_dodge(top_color, bottom_color); break;
case 7: result = color_burn(top_color, bottom_color); break;
case 8: result = hard_light(top_color, bottom_color); break;
case 9: result = soft_light(top_color, bottom_color); break;
case 10: result = difference(top_color, bottom_color); break;
case 11: result = exclusion(top_color, bottom_color); break;
case 12: result = color(top_color, bottom_color); break;
case 13: result = hue(top_color, bottom_color); break;
case 14: result = saturation(top_color, bottom_color); break;
case 15: result = luminosity(top_color, bottom_color); break;
case 0: result = normal(bottom_color, top_color); break;
case 1: result = multiply(bottom_color, top_color); break;
case 2: result = screen(bottom_color, top_color); break;
case 3: result = overlay(bottom_color, top_color); break;
case 4: result = darken(bottom_color, top_color); break;
case 5: result = lighten(bottom_color, top_color); break;
case 6: result = color_dodge(bottom_color, top_color); break;
case 7: result = color_burn(bottom_color, top_color); break;
case 8: result = hard_light(bottom_color, top_color); break;
case 9: result = soft_light(bottom_color, top_color); break;
case 10: result = difference(bottom_color, top_color); break;
case 11: result = exclusion(bottom_color, top_color); break;
case 12: result = color(bottom_color, top_color); break;
case 13: result = hue(bottom_color, top_color); break;
case 14: result = saturation(bottom_color, top_color); break;
case 15: result = luminosity(bottom_color, top_color); break;
default: discard;
}
+1 -2
View File
@@ -8,8 +8,7 @@ void main() {
color.rgb *= color.a;
// u_source is drawn using cairo, so already pre-multiplied.
color = vec4(color.rgb * diffuse.a * u_alpha,
color.a * diffuse.a * u_alpha);
color = vec4(u_color.rgb * diffuse.a * u_alpha, diffuse.a * color.a * u_alpha);
setOutputColor(color);
}
+1 -43
View File
@@ -13,7 +13,6 @@
#include "gskvulkanglyphcacheprivate.h"
#include "gdk/gdktextureprivate.h"
#include "gdk/gdkprofilerprivate.h"
#include <graphene.h>
@@ -39,9 +38,6 @@ typedef struct {
} ProfileTimers;
#endif
static guint texture_pixels_counter;
static guint fallback_pixels_counter;
struct _GskVulkanRenderer
{
GskRenderer parent_instance;
@@ -174,7 +170,7 @@ gsk_vulkan_renderer_render_texture (GskRenderer *renderer,
GdkTexture *texture;
#ifdef G_ENABLE_DEBUG
GskProfiler *profiler;
gint64 cpu_time, start_time;
gint64 cpu_time;
#endif
#ifdef G_ENABLE_DEBUG
@@ -205,22 +201,10 @@ gsk_vulkan_renderer_render_texture (GskRenderer *renderer,
gsk_vulkan_render_free (render);
#ifdef G_ENABLE_DEBUG
start_time = gsk_profiler_timer_get_start (profiler, self->profile_timers.cpu_time);
cpu_time = gsk_profiler_timer_end (profiler, self->profile_timers.cpu_time);
gsk_profiler_timer_set (profiler, self->profile_timers.cpu_time, cpu_time);
gsk_profiler_push_samples (profiler);
if (gdk_profiler_is_running ())
{
gdk_profiler_add_mark (start_time, cpu_time, "render", "");
gdk_profiler_set_int_counter (texture_pixels_counter,
start_time + cpu_time,
gsk_profiler_counter_get (profiler, self->profile_counters.texture_pixels));
gdk_profiler_set_int_counter (fallback_pixels_counter,
start_time + cpu_time,
gsk_profiler_counter_get (profiler, self->profile_counters.fallback_pixels));
}
#endif
return texture;
@@ -300,13 +284,6 @@ gsk_vulkan_renderer_init (GskVulkanRenderer *self)
self->profile_timers.cpu_time = gsk_profiler_add_timer (profiler, "cpu-time", "CPU time", FALSE, TRUE);
if (GSK_RENDERER_DEBUG_CHECK (GSK_RENDERER (self), SYNC))
self->profile_timers.gpu_time = gsk_profiler_add_timer (profiler, "gpu-time", "GPU time", FALSE, TRUE);
if (texture_pixels_counter == 0)
{
texture_pixels_counter = gdk_profiler_define_int_counter ("texture-pixels", "Texture Pixels");
fallback_pixels_counter = gdk_profiler_define_int_counter ("fallback-pixels", "Fallback Pixels");
}
#endif
}
@@ -387,22 +364,3 @@ gsk_vulkan_renderer_get_cached_glyph (GskVulkanRenderer *self,
{
return gsk_vulkan_glyph_cache_lookup (self->glyph_cache, FALSE, font, glyph, scale);
}
/**
* gsk_vulkan_renderer_new:
*
* Creates a new Vulkan renderer.
*
* The Vulkan renderer is a renderer that uses the Vulkan library for
* rendering.
*
* This function is only available when GTK was compiled with Vulkan
* support.
*
* Returns: a new Vulkan renderer
**/
GskRenderer *
gsk_vulkan_renderer_new (void)
{
return g_object_new (GSK_TYPE_VULKAN_RENDERER, NULL);
}
-51
View File
@@ -1,51 +0,0 @@
/*
* Copyright © 2016 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GSK_VULKAN_RENDERER_H__
#define __GSK_VULKAN_RENDERER_H__
#include <gdk/gdk.h>
#include <gsk/gskrenderer.h>
#ifdef GDK_RENDERING_VULKAN
#include <vulkan/vulkan.h>
G_BEGIN_DECLS
#define GSK_TYPE_VULKAN_RENDERER (gsk_vulkan_renderer_get_type ())
#define GSK_VULKAN_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSK_TYPE_VULKAN_RENDERER, GskVulkanRenderer))
#define GSK_IS_VULKAN_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSK_TYPE_VULKAN_RENDERER))
#define GSK_VULKAN_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSK_TYPE_VULKAN_RENDERER, GskVulkanRendererClass))
#define GSK_IS_VULKAN_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSK_TYPE_VULKAN_RENDERER))
#define GSK_VULKAN_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSK_TYPE_VULKAN_RENDERER, GskVulkanRendererClass))
typedef struct _GskVulkanRenderer GskVulkanRenderer;
typedef struct _GskVulkanRendererClass GskVulkanRendererClass;
GDK_AVAILABLE_IN_ALL
GType gsk_vulkan_renderer_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GskRenderer * gsk_vulkan_renderer_new (void);
G_END_DECLS
#endif /* GDK_WINDOWING_VULKAN */
#endif /* __GSK_VULKAN_RENDERER_H__ */
+16 -1
View File
@@ -1,11 +1,26 @@
#ifndef __GSK_VULKAN_RENDERER_PRIVATE_H__
#define __GSK_VULKAN_RENDERER_PRIVATE_H__
#include "gskvulkanrenderer.h"
#include <vulkan/vulkan.h>
#include <gsk/gskrenderer.h>
#include "gskvulkanimageprivate.h"
G_BEGIN_DECLS
#define GSK_TYPE_VULKAN_RENDERER (gsk_vulkan_renderer_get_type ())
#define GSK_VULKAN_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSK_TYPE_VULKAN_RENDERER, GskVulkanRenderer))
#define GSK_IS_VULKAN_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSK_TYPE_VULKAN_RENDERER))
#define GSK_VULKAN_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSK_TYPE_VULKAN_RENDERER, GskVulkanRendererClass))
#define GSK_IS_VULKAN_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSK_TYPE_VULKAN_RENDERER))
#define GSK_VULKAN_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSK_TYPE_VULKAN_RENDERER, GskVulkanRendererClass))
typedef struct _GskVulkanRenderer GskVulkanRenderer;
typedef struct _GskVulkanRendererClass GskVulkanRendererClass;
GType gsk_vulkan_renderer_get_type (void) G_GNUC_CONST;
GskVulkanImage * gsk_vulkan_renderer_ref_texture_image (GskVulkanRenderer *self,
GdkTexture *texture,
GskVulkanUploader *uploader);
+2 -4
View File
@@ -243,7 +243,6 @@ gtk_notebook_page_accessible_new (GtkNotebookAccessible *notebook,
GObject *object;
AtkObject *atk_object;
GtkNotebookPageAccessible *page;
GtkNotebook *nb;
g_return_val_if_fail (GTK_IS_NOTEBOOK_ACCESSIBLE (notebook), NULL);
g_return_val_if_fail (GTK_WIDGET (child), NULL);
@@ -259,10 +258,9 @@ gtk_notebook_page_accessible_new (GtkNotebookAccessible *notebook,
atk_object->layer = ATK_LAYER_WIDGET;
atk_object_set_parent (gtk_widget_get_accessible (child), atk_object);
nb = GTK_NOTEBOOK (gtk_accessible_get_widget (page->priv->notebook));
g_signal_connect (gtk_notebook_get_page (nb, child),
"notify::tab-label",
g_signal_connect (gtk_accessible_get_widget (page->priv->notebook),
"child-notify::tab-label",
G_CALLBACK (notify_tab_label), page);
return atk_object;
-175
View File
@@ -1,175 +0,0 @@
/* GStreamer data:// uri source element
* Copyright (C) 2009 Igalia S.L
* Copyright (C) 2009 Sebastian Dröge <sebastian.droege@collabora.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*<private>
* SECTION:data-url
* @title: data: URLs
*
* These function allow encoding and decoding of data: URLs, see
* [RFC 2397](http://tools.ietf.org/html/rfc2397) for more information.
*/
#include "config.h"
#include "gtkcssdataurlprivate.h"
#include "../gtkintl.h"
#include <string.h>
/*<private>
* gtk_css_data_url_parse:
* @url: the URL to parse
* @out_mimetype: (out nullable optional): Return location to set the contained
* mime type to. If no mime type was specified, this value is set to %NULL.
* @error: error location or %NULL for none
*
* Decodes a data URL according to RFC2397 and returns the decoded data.
*
* Returns: a new #GBytes with the decoded data or %NULL on error
**/
GBytes *
gtk_css_data_url_parse (const char *url,
char **out_mimetype,
GError **error)
{
char *mimetype = NULL;
const char *parameters_start;
const char *data_start;
GBytes *bytes;
gboolean base64 = FALSE;
char *charset = NULL;
gpointer bdata;
gsize bsize;
/* url must be an URI as defined in RFC 2397
* data:[<mediatype>][;base64],<data>
*/
if (g_ascii_strncasecmp ("data:", url, 5) != 0)
{
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_FILENAME,
_("Not a data: URL"));
return NULL;
}
url += 5;
parameters_start = strchr (url, ';');
data_start = strchr (url, ',');
if (data_start == NULL)
{
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_FILENAME,
_("Malformed data: URL"));
return NULL;
}
if (parameters_start > data_start)
parameters_start = NULL;
if (data_start != url && parameters_start != url)
{
mimetype = g_strndup (url,
(parameters_start ? parameters_start
: data_start) - url);
}
else
{
mimetype = NULL;
}
if (parameters_start != NULL)
{
char *parameters_str;
char **parameters;
guint i;
parameters_str = g_strndup (parameters_start + 1, data_start - parameters_start - 1);
parameters = g_strsplit (parameters_str, ";", -1);
for (i = 0; parameters[i] != NULL; i++)
{
if (g_ascii_strcasecmp ("base64", parameters[i]) == 0)
{
base64 = TRUE;
}
else if (g_ascii_strncasecmp ("charset=", parameters[i], 8) == 0)
{
g_free (charset);
charset = g_strdup (parameters[i] + 8);
}
}
g_free (parameters_str);
g_strfreev (parameters);
}
/* Skip comma */
data_start += 1;
if (base64)
{
bdata = g_base64_decode (data_start, &bsize);
}
else
{
/* URI encoded, i.e. "percent" encoding */
/* XXX: This doesn't allow nul bytes */
bdata = g_uri_unescape_string (data_start, NULL);
if (bdata == NULL)
{
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_FILENAME,
_("Could not unescape string"));
g_free (mimetype);
return NULL;
}
bsize = strlen (bdata);
}
/* Convert to UTF8 */
if ((mimetype == NULL || g_ascii_strcasecmp ("text/plain", mimetype) == 0) &&
charset && g_ascii_strcasecmp ("US-ASCII", charset) != 0
&& g_ascii_strcasecmp ("UTF-8", charset) != 0)
{
gsize read;
gsize written;
gpointer data;
data = g_convert_with_fallback (bdata, bsize,
"UTF-8", charset,
(char *) "*",
&read, &written, NULL);
g_free (bdata);
bdata = data;
bsize = written;
}
bytes = g_bytes_new_take (bdata, bsize);
g_free (charset);
if (out_mimetype)
*out_mimetype = mimetype;
else
g_free (mimetype);
return bytes;
}
-35
View File
@@ -1,35 +0,0 @@
/*
* Copyright © 2019 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#ifndef __GTK_CSS_DATA_URL_PRIVATE_H__
#define __GTK_CSS_DATA_URL_PRIVATE_H__
#include <gio/gio.h>
G_BEGIN_DECLS
GBytes * gtk_css_data_url_parse (const char *url,
char **out_mimetype,
GError **error);
G_END_DECLS
#endif /* __GTK_CSS_DATA_URL_PRIVATE_H__ */
+13 -22
View File
@@ -335,9 +335,7 @@ gtk_css_parser_consume_token (GtkCssParser *self)
/* unpreserved tokens MUST be consumed via start_block() */
g_assert (gtk_css_token_is_preserved (&self->token, NULL));
/* Don't consume any tokens at the end of a block */
if (!gtk_css_token_is (gtk_css_parser_peek_token (self), GTK_CSS_TOKEN_EOF))
gtk_css_token_clear (&self->token);
gtk_css_token_clear (&self->token);
}
void
@@ -437,15 +435,7 @@ gtk_css_parser_end_block (GtkCssParser *self)
else
{
g_array_set_size (self->blocks, self->blocks->len - 1);
if (gtk_css_token_is_preserved (&self->token, NULL))
{
gtk_css_token_clear (&self->token);
}
else
{
gtk_css_parser_start_block (self);
gtk_css_parser_end_block (self);
}
gtk_css_parser_skip (self);
}
}
@@ -973,10 +963,11 @@ gtk_css_parser_parse_url_arg (GtkCssParser *parser,
*
* Returns: (nullable) (transfer full): the resulting URL or %NULL on error
**/
char *
GFile *
gtk_css_parser_consume_url (GtkCssParser *self)
{
const GtkCssToken *token;
GFile *result;
char *url;
token = gtk_css_parser_get_token (self);
@@ -997,16 +988,16 @@ gtk_css_parser_consume_url (GtkCssParser *self)
return NULL;
}
return url;
}
result = gtk_css_parser_resolve_url (self, url);
if (result == NULL)
{
gtk_css_parser_error_import (self, "Could not resolve \"%s\" to a valid URL", url);
g_free (url);
return NULL;
}
g_free (url);
gboolean
gtk_css_parser_has_number (GtkCssParser *self)
{
return gtk_css_parser_has_token (self, GTK_CSS_TOKEN_SIGNED_NUMBER)
|| gtk_css_parser_has_token (self, GTK_CSS_TOKEN_SIGNLESS_NUMBER)
|| gtk_css_parser_has_token (self, GTK_CSS_TOKEN_SIGNED_INTEGER)
|| gtk_css_parser_has_token (self, GTK_CSS_TOKEN_SIGNLESS_INTEGER);
return result;
}
gboolean
+1 -2
View File
@@ -118,7 +118,6 @@ gboolean gtk_css_parser_has_token (GtkCssParser
GtkCssTokenType token_type);
gboolean gtk_css_parser_has_ident (GtkCssParser *self,
const char *ident);
gboolean gtk_css_parser_has_number (GtkCssParser *self);
gboolean gtk_css_parser_has_integer (GtkCssParser *self);
gboolean gtk_css_parser_has_function (GtkCssParser *self,
const char *name);
@@ -134,7 +133,7 @@ gboolean gtk_css_parser_try_token (GtkCssParser
char * gtk_css_parser_consume_ident (GtkCssParser *self) G_GNUC_WARN_UNUSED_RESULT;
char * gtk_css_parser_consume_string (GtkCssParser *self) G_GNUC_WARN_UNUSED_RESULT;
char * gtk_css_parser_consume_url (GtkCssParser *self) G_GNUC_WARN_UNUSED_RESULT;
GFile * gtk_css_parser_consume_url (GtkCssParser *self) G_GNUC_WARN_UNUSED_RESULT;
gboolean gtk_css_parser_consume_number (GtkCssParser *self,
double *number);
gboolean gtk_css_parser_consume_integer (GtkCssParser *self,
+17 -26
View File
@@ -633,6 +633,13 @@ is_name (char c)
|| c == '-';
}
static gboolean
is_valid_escape (char c1, char c2)
{
return c1 == '\\'
&& !is_newline (c2);
}
static gboolean
is_non_printable (char c)
{
@@ -643,25 +650,6 @@ is_non_printable (char c)
|| c == 0x7F;
}
static gboolean
is_valid_escape (const char *data,
const char *end)
{
switch (end - data)
{
default:
if (is_newline (data[1]))
return FALSE;
G_GNUC_FALLTHROUGH;
case 1:
return data[0] == '\\';
case 0:
return FALSE;
}
}
static inline gsize
gtk_css_tokenizer_remaining (GtkCssTokenizer *tokenizer)
{
@@ -671,7 +659,15 @@ gtk_css_tokenizer_remaining (GtkCssTokenizer *tokenizer)
static gboolean
gtk_css_tokenizer_has_valid_escape (GtkCssTokenizer *tokenizer)
{
return is_valid_escape (tokenizer->data, tokenizer->end);
switch (gtk_css_tokenizer_remaining (tokenizer))
{
case 0:
return FALSE;
case 1:
return *tokenizer->data == '\\';
default:
return is_valid_escape (tokenizer->data[0], tokenizer->data[1]);
}
}
static gboolean
@@ -818,11 +814,7 @@ gtk_css_tokenizer_read_escape (GtkCssTokenizer *tokenizer)
if (i == 0)
{
gsize remaining = gtk_css_tokenizer_remaining (tokenizer);
if (remaining == 0)
return 0xFFFD;
value = g_utf8_get_char_validated (tokenizer->data, remaining);
value = g_utf8_get_char_validated (tokenizer->data, gtk_css_tokenizer_remaining (tokenizer));
if (value == (gunichar) -1 || value == (gunichar) -2)
value = 0;
@@ -1384,7 +1376,6 @@ gtk_css_tokenizer_read_token (GtkCssTokenizer *tokenizer,
else
{
gtk_css_token_init (token, GTK_CSS_TOKEN_DELIM, '\\');
gtk_css_tokenizer_consume_ascii (tokenizer);
gtk_css_tokenizer_parse_error (error, "Newline may not follow '\' escape character");
return FALSE;
}
-1
View File
@@ -5,7 +5,6 @@ gtk_css_public_sources = files([
])
gtk_css_private_sources = files([
'gtkcssdataurl.c',
'gtkcssparser.c',
'gtkcsstokenizer.c',
])
-1
View File
@@ -70,7 +70,6 @@ for f in get_files('inspector', '.ui'):
xml += '''
<file>inspector/logo.png</file>
<file>inspector/inspector.css</file>
<file>emoji/emoji.data</file>
</gresource>
</gresources>'''
+2 -1
View File
@@ -684,7 +684,7 @@ update_credits_button_visibility (GtkAboutDialog *about)
gboolean show;
GtkStackPage *page;
page = gtk_stack_get_page (GTK_STACK (priv->stack), priv->credits_page);
page = gtk_stack_get_page (GTK_STACK (priv->stack), priv->system_page);
show = (priv->authors != NULL ||
priv->documenters != NULL ||
@@ -2155,6 +2155,7 @@ add_credits_section (GtkAboutDialog *about,
gtk_widget_set_halign (label, GTK_ALIGN_END);
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
gtk_grid_attach (grid, label, 0, *row, 1, 1);
gtk_widget_show (label);
for (p = people; *p; p++)
{
-149
View File
@@ -21,11 +21,6 @@
#include "config.h"
#include "gtkapplication.h"
#include "gdkprofilerprivate.h"
#ifdef G_OS_UNIX
#include <gio/gunixfdlist.h>
#endif
#include <stdlib.h>
@@ -608,148 +603,6 @@ gtk_application_finalize (GObject *object)
G_OBJECT_CLASS (gtk_application_parent_class)->finalize (object);
}
#ifdef G_OS_UNIX
static const gchar org_gnome_Sysprof3_Profiler_xml[] =
"<node>"
"<interface name='org.gnome.Sysprof3.Profiler'>"
"<method name='Start'>"
"<arg type='h' name='fd' direction='in'/>"
"</method>"
"<method name='Stop'>"
"</method>"
"</interface>"
"</node>";
static GDBusInterfaceInfo *org_gnome_Sysprof3_Profiler;
static void
sysprof_profiler_method_call (GDBusConnection *connection,
const gchar *sender,
const gchar *object_path,
const gchar *interface_name,
const gchar *method_name,
GVariant *parameters,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
if (strcmp (method_name, "Start") == 0)
{
GDBusMessage *message;
GUnixFDList *fd_list;
int fd = -1;
int idx;
if (gdk_profiler_is_running ())
{
g_dbus_method_invocation_return_error (invocation,
G_DBUS_ERROR,
G_DBUS_ERROR_FAILED,
"Profiler already running");
return;
}
g_variant_get (parameters, "(h)", &idx);
message = g_dbus_method_invocation_get_message (invocation);
fd_list = g_dbus_message_get_unix_fd_list (message);
if (fd_list)
fd = g_unix_fd_list_get (fd_list, idx, NULL);
gdk_profiler_start (fd);
}
else if (strcmp (method_name, "Stop") == 0)
{
if (!gdk_profiler_is_running ())
{
g_dbus_method_invocation_return_error (invocation,
G_DBUS_ERROR,
G_DBUS_ERROR_FAILED,
"Profiler not running");
return;
}
gdk_profiler_stop ();
}
else
{
g_dbus_method_invocation_return_error (invocation,
G_DBUS_ERROR,
G_DBUS_ERROR_UNKNOWN_METHOD,
"Unknown method");
return;
}
g_dbus_method_invocation_return_value (invocation, NULL);
}
static gboolean
gtk_application_dbus_register (GApplication *application,
GDBusConnection *connection,
const char *obect_path,
GError **error)
{
GtkApplicationImplDBus *dbus = (GtkApplicationImplDBus *) application;
GDBusInterfaceVTable vtable = {
sysprof_profiler_method_call,
NULL,
NULL
};
if (org_gnome_Sysprof3_Profiler == NULL)
{
GDBusNodeInfo *info;
info = g_dbus_node_info_new_for_xml (org_gnome_Sysprof3_Profiler_xml, error);
if (info == NULL)
return FALSE;
org_gnome_Sysprof3_Profiler = g_dbus_node_info_lookup_interface (info, "org.gnome.Sysprof3.Profiler");
g_dbus_interface_info_ref (org_gnome_Sysprof3_Profiler);
g_dbus_node_info_unref (info);
}
dbus->profiler_id = g_dbus_connection_register_object (connection,
"/org/gtk/Profiler",
org_gnome_Sysprof3_Profiler,
&vtable,
NULL,
NULL,
error);
return TRUE;
}
static void
gtk_application_dbus_unregister (GApplication *application,
GDBusConnection *connection,
const char *obect_path)
{
GtkApplicationImplDBus *dbus = (GtkApplicationImplDBus *) application;
g_dbus_connection_unregister_object (connection, dbus->profiler_id);
}
#else
static gboolean
gtk_application_dbus_register (GApplication *application,
GDBusConnection *connection,
const char *obect_path,
GError **error)
{
return TRUE;
}
static void
gtk_application_dbus_unregister (GApplication *application,
GDBusConnection *connection,
const char *obect_path)
{
}
#endif
static void
gtk_application_class_init (GtkApplicationClass *class)
{
@@ -766,8 +619,6 @@ gtk_application_class_init (GtkApplicationClass *class)
application_class->after_emit = gtk_application_after_emit;
application_class->startup = gtk_application_startup;
application_class->shutdown = gtk_application_shutdown;
application_class->dbus_register = gtk_application_dbus_register;
application_class->dbus_unregister = gtk_application_dbus_unregister;
class->window_added = gtk_application_window_added;
class->window_removed = gtk_application_window_removed;
-1
View File
@@ -127,7 +127,6 @@ typedef struct
gchar *menubar_path;
guint menubar_id;
guint profiler_id;
/* Session management... */
GDBusProxy *sm_proxy;
+3 -1
View File
@@ -161,7 +161,6 @@ gtk_box_class_init (GtkBoxClass *class)
g_object_class_install_properties (object_class, LAST_PROP, props);
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT);
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_FILLER);
gtk_widget_class_set_css_name (widget_class, I_("box"));
}
@@ -345,9 +344,12 @@ static void
gtk_box_init (GtkBox *box)
{
GtkBoxPrivate *priv = gtk_box_get_instance_private (box);
GtkLayoutManager *box_layout = gtk_box_layout_new (GTK_ORIENTATION_HORIZONTAL);
gtk_widget_set_has_surface (GTK_WIDGET (box), FALSE);
gtk_widget_set_layout_manager (GTK_WIDGET (box), box_layout);
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (box));
}
+4 -10
View File
@@ -245,16 +245,10 @@ gtk_css_image_recolor_parse_arg (GtkCssParser *parser,
switch (arg)
{
case 0:
{
char *url = gtk_css_parser_consume_url (parser);
if (url == NULL)
return 0;
self->file = gtk_css_parser_resolve_url (parser, url);
g_free (url);
if (self->file == NULL)
return 0;
return 1;
}
self->file = gtk_css_parser_consume_url (parser);
if (self->file == NULL)
return 0;
return 1;
case 1:
self->palette = gtk_css_palette_value_parse (parser);
+3 -45
View File
@@ -27,8 +27,6 @@
#include "gtkcssimagepaintableprivate.h"
#include "gtkstyleproviderprivate.h"
#include "gtk/css/gtkcssdataurlprivate.h"
G_DEFINE_TYPE (GtkCssImageUrl, _gtk_css_image_url, GTK_TYPE_CSS_IMAGE)
static GtkCssImage *
@@ -165,52 +163,12 @@ static gboolean
gtk_css_image_url_parse (GtkCssImage *image,
GtkCssParser *parser)
{
GtkCssImageUrl *self = GTK_CSS_IMAGE_URL (image);
char *url, *scheme;
GtkCssImageUrl *url = GTK_CSS_IMAGE_URL (image);
url = gtk_css_parser_consume_url (parser);
if (url == NULL)
url->file = gtk_css_parser_consume_url (parser);
if (url->file == NULL)
return FALSE;
scheme = g_uri_parse_scheme (url);
if (scheme && g_ascii_strcasecmp (scheme, "data") == 0)
{
GInputStream *stream;
GdkPixbuf *pixbuf;
GBytes *bytes;
GError *error = NULL;
bytes = gtk_css_data_url_parse (url, NULL, &error);
if (bytes)
{
stream = g_memory_input_stream_new_from_bytes (bytes);
pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, &error);
g_object_unref (stream);
if (pixbuf == NULL)
{
gtk_css_parser_emit_error (parser,
gtk_css_parser_get_start_location (parser),
gtk_css_parser_get_end_location (parser),
error);
g_clear_error (&error);
}
else
{
GdkTexture *texture = gdk_texture_new_for_pixbuf (pixbuf);
self->loaded_image = gtk_css_image_paintable_new (GDK_PAINTABLE (texture), GDK_PAINTABLE (texture));
g_object_unref (texture);
g_object_unref (pixbuf);
}
}
}
else
{
self->file = gtk_css_parser_resolve_url (parser, url);
}
g_free (url);
g_free (scheme);
return TRUE;
}
+12 -14
View File
@@ -61,16 +61,18 @@
* In addition, certain files will be read when GTK+ is initialized. First, the
* file `$XDG_CONFIG_HOME/gtk-4.0/gtk.css` is loaded if it exists. Then, GTK+
* loads the first existing file among
* `XDG_DATA_HOME/themes/THEME/gtk-VERSION/gtk-VARIANT.css`,
* `$HOME/.themes/THEME/gtk-VERSION/gtk-VARIANT.css`,
* `$XDG_DATA_DIRS/themes/THEME/gtk-VERSION/gtk-VARIANT.css` and
* `DATADIR/share/themes/THEME/gtk-VERSION/gtk-VARIANT.css`, where `THEME` is the name of
* the current theme (see the #GtkSettings:gtk-theme-name setting),
* VARIANT is the variant to load (see the #GtkSettings:gtk-application-prefer-dark-theme setting), `DATADIR`
* `XDG_DATA_HOME/themes/THEME/gtk-VERSION/gtk.css`,
* `$HOME/.themes/THEME/gtk-VERSION/gtk.css`,
* `$XDG_DATA_DIRS/themes/THEME/gtk-VERSION/gtk.css` and
* `DATADIR/share/themes/THEME/gtk-VERSION/gtk.css`, where `THEME` is the name of
* the current theme (see the #GtkSettings:gtk-theme-name setting), `DATADIR`
* is the prefix configured when GTK+ was compiled (unless overridden by the
* `GTK_DATA_PREFIX` environment variable), and `VERSION` is the GTK+ version number.
* If no file is found for the current version, GTK+ tries older versions all the
* way back to 4.0.
*
* In the same way, GTK+ tries to load a gtk-keys.css file for the current
* key theme, as defined by #GtkSettings:gtk-key-theme-name.
*/
@@ -695,14 +697,7 @@ parse_import (GtkCssScanner *scanner)
}
else
{
char *url = gtk_css_parser_consume_url (scanner->parser);
if (url)
{
file = gtk_css_parser_resolve_url (scanner->parser, url);
g_free (url);
}
else
file = NULL;
file = gtk_css_parser_consume_url (scanner->parser);
}
if (file == NULL)
@@ -1288,6 +1283,9 @@ _gtk_css_find_theme_dir (const gchar *dir,
for (i = MINOR; i >= 0; i = i - 2)
{
if (i < 14)
i = 0;
subsubdir = g_strdup_printf ("gtk-4.%d", i);
path = g_build_filename (base, subsubdir, file, NULL);
g_free (subsubdir);
+9 -17
View File
@@ -153,9 +153,11 @@ populate_recent_section (GtkEmojiChooser *chooser)
empty = FALSE;
}
gtk_widget_set_visible (chooser->recent.box, !empty);
gtk_widget_set_sensitive (chooser->recent.button, !empty);
if (!empty)
{
gtk_widget_show (chooser->recent.box);
gtk_widget_set_sensitive (chooser->recent.button, TRUE);
}
g_variant_unref (variant);
}
@@ -456,12 +458,15 @@ populate_emoji_chooser (gpointer data)
return G_SOURCE_CONTINUE;
}
/* We scroll to the top on show, so check the right button for the 1st time */
gtk_widget_set_state_flags (chooser->recent.button, GTK_STATE_FLAG_CHECKED, FALSE);
g_variant_iter_free (chooser->iter);
chooser->iter = NULL;
chooser->box = NULL;
chooser->populate_idle = 0;
return G_SOURCE_REMOVE;
return G_SOURCE_REMOVE;
}
static void
@@ -491,9 +496,6 @@ adj_value_changed (GtkAdjustment *adj,
EmojiSection const *section = sections[i];
GtkAllocation alloc;
if (!gtk_widget_get_visible (section->box))
continue;
if (section->heading)
gtk_widget_get_allocation (section->heading, &alloc);
else
@@ -609,13 +611,6 @@ search_changed (GtkEntry *entry,
update_headings (chooser);
}
static void
stop_search (GtkEntry *entry,
gpointer data)
{
gtk_popover_popdown (GTK_POPOVER (data));
}
static void
setup_section (GtkEmojiChooser *chooser,
EmojiSection *section,
@@ -686,7 +681,6 @@ gtk_emoji_chooser_init (GtkEmojiChooser *chooser)
populate_recent_section (chooser);
chooser->populate_idle = g_idle_add (populate_emoji_chooser, chooser);
g_source_set_name_by_id (chooser->populate_idle, "[gtk] populate_emoji_chooser");
}
static void
@@ -699,7 +693,6 @@ gtk_emoji_chooser_show (GtkWidget *widget)
adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (chooser->scrolled_window));
gtk_adjustment_set_value (adj, 0);
adj_value_changed (adj, chooser);
gtk_editable_set_text (GTK_EDITABLE (chooser->search_entry), "");
}
@@ -768,7 +761,6 @@ gtk_emoji_chooser_class_init (GtkEmojiChooserClass *klass)
gtk_widget_class_bind_template_callback (widget_class, emoji_activated);
gtk_widget_class_bind_template_callback (widget_class, search_changed);
gtk_widget_class_bind_template_callback (widget_class, stop_search);
gtk_widget_class_bind_template_callback (widget_class, pressed_cb);
gtk_widget_class_bind_template_callback (widget_class, long_pressed_cb);
}
+29 -6
View File
@@ -3447,19 +3447,42 @@ gtk_entry_enter_text (GtkEntry *entry,
gtk_text_enter_text (GTK_TEXT (priv->text), text);
}
static void
gtk_entry_insert_emoji (GtkEntry *entry)
{
GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
GtkWidget *chooser;
GdkRectangle rect;
if (gtk_widget_get_ancestor (GTK_WIDGET (entry), GTK_TYPE_EMOJI_CHOOSER) != NULL)
return;
chooser = GTK_WIDGET (g_object_get_data (G_OBJECT (entry), "gtk-emoji-chooser"));
if (!chooser)
{
chooser = gtk_emoji_chooser_new ();
g_object_set_data (G_OBJECT (entry), "gtk-emoji-chooser", chooser);
gtk_popover_set_relative_to (GTK_POPOVER (chooser), GTK_WIDGET (entry));
if (priv->show_emoji_icon)
{
gtk_entry_get_icon_area (entry, GTK_ENTRY_ICON_SECONDARY, &rect);
gtk_popover_set_pointing_to (GTK_POPOVER (chooser), &rect);
}
g_signal_connect_swapped (chooser, "emoji-picked", G_CALLBACK (gtk_entry_enter_text), entry);
}
gtk_popover_popup (GTK_POPOVER (chooser));
}
static void
pick_emoji (GtkEntry *entry,
int icon,
GdkEvent *event,
gpointer data)
{
GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
if (gtk_widget_get_ancestor (GTK_WIDGET (entry), GTK_TYPE_EMOJI_CHOOSER) != NULL)
return;
if (icon == GTK_ENTRY_ICON_SECONDARY)
g_signal_emit_by_name (priv->text, "insert-emoji");
gtk_entry_insert_emoji (entry);
}
static void
+2 -2
View File
@@ -422,8 +422,6 @@ gtk_file_chooser_button_class_init (GtkFileChooserButtonClass * class)
_gtk_file_chooser_install_properties (gobject_class);
gtk_widget_class_set_css_name (widget_class, I_("filechooserbutton"));
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
}
static void
@@ -499,6 +497,8 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button)
target_list,
GDK_ACTION_COPY);
gdk_content_formats_unref (target_list);
gtk_widget_set_layout_manager (GTK_WIDGET (button), gtk_bin_layout_new ());
}
+2 -2
View File
@@ -8326,8 +8326,6 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
gtk_widget_class_bind_template_callback (widget_class, widget_key_press_cb);
gtk_widget_class_set_css_name (widget_class, I_("filechooser"));
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
}
static void
@@ -8469,6 +8467,8 @@ gtk_file_chooser_widget_init (GtkFileChooserWidget *impl)
*/
post_process_ui (impl);
gtk_widget_set_layout_manager (GTK_WIDGET (impl), gtk_bin_layout_new ());
profile_end ("end", NULL);
}
+2 -4
View File
@@ -96,14 +96,11 @@ static void
gtk_fixed_class_init (GtkFixedClass *klass)
{
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
container_class->add = gtk_fixed_add;
container_class->remove = gtk_fixed_remove;
container_class->forall = gtk_fixed_forall;
container_class->child_type = gtk_fixed_child_type;
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_FIXED_LAYOUT);
}
static GType
@@ -120,7 +117,8 @@ gtk_fixed_init (GtkFixed *self)
gtk_widget_set_has_surface (GTK_WIDGET (self), FALSE);
gtk_widget_set_overflow (GTK_WIDGET (self), GTK_OVERFLOW_HIDDEN);
priv->layout = gtk_widget_get_layout_manager (GTK_WIDGET (self));
priv->layout = gtk_fixed_layout_new ();
gtk_widget_set_layout_manager (GTK_WIDGET (self), priv->layout);
}
/**
+1
View File
@@ -107,6 +107,7 @@ gtk_gizmo_new (const char *css_name,
{
GtkGizmo *gizmo = GTK_GIZMO (g_object_new (GTK_TYPE_GIZMO,
"css-name", css_name,
"name", css_name,
NULL));
gizmo->measure_func = measure_func;
+2 -3
View File
@@ -380,8 +380,6 @@ gtk_grid_class_init (GtkGridClass *class)
g_object_class_install_properties (object_class, N_PROPERTIES, obj_properties);
gtk_widget_class_set_css_name (widget_class, I_("grid"));
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_GRID_LAYOUT);
}
static void
@@ -391,7 +389,8 @@ gtk_grid_init (GtkGrid *grid)
gtk_widget_set_has_surface (GTK_WIDGET (grid), FALSE);
priv->layout_manager = gtk_widget_get_layout_manager (GTK_WIDGET (grid));
priv->layout_manager = gtk_grid_layout_new ();
gtk_widget_set_layout_manager (GTK_WIDGET (grid), priv->layout_manager);
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (grid));
-1
View File
@@ -2045,7 +2045,6 @@ gtk_header_bar_set_decoration_layout (GtkHeaderBar *bar,
priv = gtk_header_bar_get_instance_private (bar);
g_free (priv->decoration_layout);
priv->decoration_layout = g_strdup (layout);
priv->decoration_layout_set = (layout != NULL);
+2 -3
View File
@@ -302,8 +302,6 @@ gtk_overlay_class_init (GtkOverlayClass *klass)
GDK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE);
gtk_widget_class_set_css_name (widget_class, I_("overlay"));
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_OVERLAY_LAYOUT);
}
static void
@@ -313,7 +311,8 @@ gtk_overlay_init (GtkOverlay *overlay)
gtk_widget_set_has_surface (GTK_WIDGET (overlay), FALSE);
priv->layout = gtk_widget_get_layout_manager (GTK_WIDGET (overlay));
priv->layout = gtk_overlay_layout_new ();
gtk_widget_set_layout_manager (GTK_WIDGET (overlay), priv->layout);
}
static GtkBuildableIface *parent_buildable_iface;
+12 -1
View File
@@ -87,7 +87,18 @@
* Applications can override system-wide settings by setting the property
* of the GtkSettings object with g_object_set(). This should be restricted
* to special cases though; GtkSettings are not meant as an application
* configuration facility.
* configuration facility. When doing so, you need to be aware that settings
* that are specific to individual widgets may not be available before the
* widget type has been realized at least once. The following example
* demonstrates a way to do this:
* |[<!-- language="C" -->
* gtk_init ();
*
* // make sure the type is realized
* g_type_class_unref (g_type_class_ref (GTK_TYPE_BUTTON));
*
* g_object_set (gtk_settings_get_default (), "gtk-enable-animations", FALSE, NULL);
* ]|
*
* There is one GtkSettings instance per display. It can be obtained with
* gtk_settings_get_for_display(), but in many cases, it is more convenient
+1
View File
@@ -78,6 +78,7 @@ gtk_test_init (int *argcp,
g_test_init (argcp, argvp, NULL);
gtk_disable_setlocale();
setlocale (LC_ALL, "en_US.UTF-8");
g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id=%s");
/* XSendEvent() doesn't work yet on XI2 events.
* So at the moment gdk_test_simulate_* can only
+21 -68
View File
@@ -47,7 +47,6 @@
#include "gtkgestureprivate.h"
#include "gtkgesturesingle.h"
#include "gtkgestureswipe.h"
#include "gtkeventcontrollerkey.h"
#include "gtkintl.h"
#include "gtklayoutmanagerprivate.h"
#include "gtkmain.h"
@@ -498,7 +497,6 @@ struct _GtkWidgetClassPrivate
GType accessible_type;
AtkRole accessible_role;
const char *css_name;
GType layout_manager_type;
};
enum {
@@ -2742,7 +2740,6 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
{
GtkWidget *widget = GTK_WIDGET (instance);
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GType layout_manager_type;
widget->priv = priv;
@@ -2811,10 +2808,6 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
if (g_type_is_a (G_TYPE_FROM_CLASS (g_class), GTK_TYPE_ROOT))
priv->root = (GtkRoot *) widget;
layout_manager_type = gtk_widget_class_get_layout_manager_type (g_class);
if (layout_manager_type != G_TYPE_INVALID)
gtk_widget_set_layout_manager (widget, g_object_new (layout_manager_type, NULL));
}
/**
@@ -5226,9 +5219,7 @@ gtk_widget_run_controllers (GtkWidget *widget,
* to collaborate with anything else. Break early if any such event
* controller handled the event.
*/
if (handled &&
!GTK_IS_GESTURE (controller) &&
!GTK_IS_EVENT_CONTROLLER_KEY (controller))
if (handled && !GTK_IS_GESTURE (controller))
break;
}
@@ -5258,7 +5249,11 @@ _gtk_widget_captured_event (GtkWidget *widget,
return TRUE;
event_copy = gdk_event_copy (event);
translate_event_coordinates (event_copy, widget);
if (!translate_event_coordinates (event_copy, widget))
{
g_object_unref (event_copy);
return FALSE;
}
return_val = gtk_widget_run_controllers (widget, event_copy, GTK_PHASE_CAPTURE);
@@ -5360,7 +5355,11 @@ gtk_widget_event_internal (GtkWidget *widget,
event_copy = gdk_event_copy (event);
translate_event_coordinates (event_copy, widget);
if (!translate_event_coordinates (event_copy, widget))
{
g_object_unref (event_copy);
return FALSE;
}
if (widget == gtk_get_event_target (event_copy))
return_val |= gtk_widget_run_controllers (widget, event_copy, GTK_PHASE_TARGET);
@@ -6740,17 +6739,17 @@ gtk_widget_verify_invariants (GtkWidget *widget)
if (!priv->realized)
g_warning ("%s %p is mapped but not realized",
G_OBJECT_TYPE_NAME (widget), widget);
gtk_widget_get_name (widget), widget);
if (!priv->visible)
g_warning ("%s %p is mapped but not visible",
G_OBJECT_TYPE_NAME (widget), widget);
gtk_widget_get_name (widget), widget);
if (!GTK_IS_ROOT (widget))
{
if (!priv->child_visible)
g_warning ("%s %p is mapped but not child_visible",
G_OBJECT_TYPE_NAME (widget), widget);
gtk_widget_get_name (widget), widget);
}
}
else
@@ -6800,8 +6799,8 @@ gtk_widget_verify_invariants (GtkWidget *widget)
if (priv->realized)
g_warning ("%s %p is not realized but child %s %p is realized",
parent ? G_OBJECT_TYPE_NAME (parent) : "no parent", parent,
G_OBJECT_TYPE_NAME (widget), widget);
parent ? gtk_widget_get_name (parent) : "no parent", parent,
gtk_widget_get_name (widget), widget);
}
if (parent &&
@@ -6813,8 +6812,8 @@ gtk_widget_verify_invariants (GtkWidget *widget)
if (!priv->mapped)
g_warning ("%s %p is mapped but visible child %s %p is not mapped",
G_OBJECT_TYPE_NAME (parent), parent,
G_OBJECT_TYPE_NAME (widget), widget);
gtk_widget_get_name (parent), parent,
gtk_widget_get_name (widget), widget);
}
else if (!GTK_IS_ROOT (widget))
{
@@ -6822,10 +6821,10 @@ gtk_widget_verify_invariants (GtkWidget *widget)
if (priv->mapped)
g_warning ("%s %p is mapped but visible=%d child_visible=%d parent %s %p mapped=%d",
G_OBJECT_TYPE_NAME (widget), widget,
gtk_widget_get_name (widget), widget,
priv->visible,
priv->child_visible,
parent ? G_OBJECT_TYPE_NAME (parent) : "no parent", parent,
parent ? gtk_widget_get_name (parent) : "no parent", parent,
parent ? parent->priv->mapped : FALSE);
}
}
@@ -12987,7 +12986,7 @@ gtk_widget_snapshot (GtkWidget *widget,
if (_gtk_widget_get_alloc_needed (widget))
{
g_warning ("Trying to snapshot %s %p without a current allocation", G_OBJECT_TYPE_NAME (widget), widget);
g_warning ("Trying to snapshot %s %p without a current allocation", gtk_widget_get_name (widget), widget);
return;
}
@@ -13576,52 +13575,6 @@ gtk_widget_get_height (GtkWidget *widget)
return priv->height;
}
/**
* gtk_widget_class_set_layout_manager_type:
* @widget_class: class to set the layout manager type for
* @type: The object type that implements the #GtkLayoutManager for @widget_class
*
* Sets the type to be used for creating layout managers for widgets of
* @widget_class. The given @type must be a subtype of #GtkLayoutManager.
*
* This function should only be called from class init functions of widgets.
**/
void
gtk_widget_class_set_layout_manager_type (GtkWidgetClass *widget_class,
GType type)
{
GtkWidgetClassPrivate *priv;
g_return_if_fail (GTK_IS_WIDGET_CLASS (widget_class));
g_return_if_fail (g_type_is_a (type, GTK_TYPE_LAYOUT_MANAGER));
priv = widget_class->priv;
priv->layout_manager_type = type;
}
/**
* gtk_widget_class_get_layout_manager_type:
* @widget_class: a #GtkWidgetClass
*
* Retrieves the type of the #GtkLayoutManager used by the #GtkWidget class.
*
* See also: gtk_widget_class_set_layout_manager_type()
*
* Returns: a #GtkLayoutManager subclass, or %G_TYPE_INVALID
*/
GType
gtk_widget_class_get_layout_manager_type (GtkWidgetClass *widget_class)
{
GtkWidgetClassPrivate *priv;
g_return_val_if_fail (GTK_IS_WIDGET_CLASS (widget_class), G_TYPE_INVALID);
priv = widget_class->priv;
return priv->layout_manager_type;
}
/**
* gtk_widget_set_layout_manager:
* @widget: a #GtkWidget
-6
View File
@@ -414,12 +414,6 @@ void gtk_widget_set_layout_manager (GtkWidget *widge
GDK_AVAILABLE_IN_ALL
GtkLayoutManager * gtk_widget_get_layout_manager (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_widget_class_set_layout_manager_type (GtkWidgetClass *widget_class,
GType type);
GDK_AVAILABLE_IN_ALL
GType gtk_widget_class_get_layout_manager_type (GtkWidgetClass *widget_class);
GDK_AVAILABLE_IN_ALL
void gtk_widget_add_accelerator (GtkWidget *widget,
const gchar *accel_signal,
+64 -15
View File
@@ -431,7 +431,6 @@ static void gtk_window_move_focus (GtkWidget *widget,
GtkDirectionType dir);
static void gtk_window_real_activate_default (GtkWindow *window);
static void gtk_window_real_activate_focus (GtkWindow *window);
static void gtk_window_keys_changed (GtkWindow *window);
static gboolean gtk_window_enable_debugging (GtkWindow *window,
gboolean toggle);
@@ -504,8 +503,6 @@ static void gtk_window_do_popup (GtkWindow *window,
static void gtk_window_style_updated (GtkWidget *widget);
static void gtk_window_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state);
static void _gtk_window_set_is_active (GtkWindow *window,
gboolean is_active);
static GListStore *toplevel_list = NULL;
static guint window_signals[LAST_SIGNAL] = { 0 };
@@ -805,7 +802,6 @@ gtk_window_class_init (GtkWindowClass *klass)
container_class->forall = gtk_window_forall;
klass->activate_default = gtk_window_real_activate_default;
klass->activate_focus = gtk_window_real_activate_focus;
klass->keys_changed = gtk_window_keys_changed;
klass->enable_debugging = gtk_window_enable_debugging;
klass->close_request = gtk_window_close_request;
@@ -6235,12 +6231,44 @@ get_active_region_type (GtkWindow *window, gint x, gint y)
}
static void
gtk_window_real_activate_focus (GtkWindow *window)
do_focus_change (GtkWidget *widget,
gboolean in)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GdkSeat *seat;
GdkDevice *device;
GdkEvent *event;
GtkRoot *root;
GtkStateFlags flags;
if (priv->focus_widget && gtk_widget_is_sensitive (priv->focus_widget))
gtk_widget_activate (priv->focus_widget);
seat = gdk_display_get_default_seat (gtk_widget_get_display (widget));
device = gdk_seat_get_keyboard (seat);
event = gdk_event_new (GDK_FOCUS_CHANGE);
gdk_event_set_display (event, gtk_widget_get_display (widget));
gdk_event_set_device (event, device);
event->any.type = GDK_FOCUS_CHANGE;
event->any.surface = _gtk_widget_get_surface (widget);
if (event->any.surface)
g_object_ref (event->any.surface);
event->focus_change.in = in;
event->focus_change.mode = GDK_CROSSING_STATE_CHANGED;
event->focus_change.detail = GDK_NOTIFY_ANCESTOR;
flags = GTK_STATE_FLAG_FOCUSED;
root = gtk_widget_get_root (widget);
if (!GTK_IS_WINDOW (root) || gtk_window_get_focus_visible (GTK_WINDOW (root)))
flags |= GTK_STATE_FLAG_FOCUS_VISIBLE;
if (in)
gtk_widget_set_state_flags (widget, flags, FALSE);
else
gtk_widget_unset_state_flags (widget, flags);
gtk_widget_set_has_focus (widget, in);
gtk_widget_event (widget, event);
g_object_unref (event);
}
static gboolean
@@ -8918,7 +8946,7 @@ gtk_window_activate_key (GtkWindow *window,
return gtk_window_activate_menubar (window, event);
}
/*
/**
* _gtk_window_set_is_active:
* @window: a #GtkWindow
* @is_active: %TRUE if the window is in the currently active toplevel
@@ -8927,19 +8955,40 @@ gtk_window_activate_key (GtkWindow *window,
* of the currently active toplevel window (taking into account inter-process
* embedding.)
**/
static void
void
_gtk_window_set_is_active (GtkWindow *window,
gboolean is_active)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
if (priv->is_active == is_active)
return;
g_return_if_fail (GTK_IS_WINDOW (window));
priv->is_active = is_active;
is_active = is_active != FALSE;
g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_IS_ACTIVE]);
_gtk_window_accessible_set_is_active (window, is_active);
if (is_active != priv->is_active)
{
GtkWidget *widget = GTK_WIDGET (window);
priv->is_active = is_active;
if (is_active)
{
if (priv->focus_widget &&
priv->focus_widget != widget &&
!gtk_widget_has_focus (priv->focus_widget))
do_focus_change (priv->focus_widget, TRUE);
}
else
{
if (priv->focus_widget &&
priv->focus_widget != widget &&
gtk_widget_has_focus (priv->focus_widget))
do_focus_change (priv->focus_widget, FALSE);
}
g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_IS_ACTIVE]);
_gtk_window_accessible_set_is_active (window, is_active);
}
}
/**
+3
View File
@@ -47,6 +47,9 @@ gboolean _gtk_window_group_widget_is_blocked_for_device (GtkWindowGroup *
void _gtk_window_unset_focus_and_default (GtkWindow *window,
GtkWidget *widget);
void _gtk_window_set_is_active (GtkWindow *window,
gboolean is_active);
void _gtk_window_set_allocation (GtkWindow *window,
int width,
int height,
+15 -30
View File
@@ -45,8 +45,7 @@ enum
PROP_0,
PROP_GROUP,
PROP_PREFIX,
PROP_NAME,
PROP_SIZEGROUP
PROP_NAME
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorActionEditor, gtk_inspector_action_editor, GTK_TYPE_BOX)
@@ -56,8 +55,9 @@ gtk_inspector_action_editor_init (GtkInspectorActionEditor *editor)
{
editor->priv = gtk_inspector_action_editor_get_instance_private (editor);
g_object_set (editor,
"orientation", GTK_ORIENTATION_HORIZONTAL,
"orientation", GTK_ORIENTATION_VERTICAL,
"spacing", 10,
"margin", 10,
NULL);
}
@@ -238,9 +238,6 @@ action_enabled_changed_cb (GActionGroup *group,
gboolean enabled,
GtkInspectorActionEditor *r)
{
if (!g_str_equal (action_name, r->priv->name))
return;
r->priv->enabled = enabled;
if (r->priv->parameter_entry)
{
@@ -255,9 +252,6 @@ action_state_changed_cb (GActionGroup *group,
GVariant *state,
GtkInspectorActionEditor *r)
{
if (!g_str_equal (action_name, r->priv->name))
return;
if (r->priv->state_entry)
variant_editor_set_value (r->priv->state_entry, state);
}
@@ -267,30 +261,34 @@ constructed (GObject *object)
{
GtkInspectorActionEditor *r = GTK_INSPECTOR_ACTION_EDITOR (object);
GVariant *state;
gchar *fullname;
GtkWidget *row;
GtkWidget *activate;
GtkWidget *label;
r->priv->enabled = g_action_group_get_action_enabled (r->priv->group, r->priv->name);
state = g_action_group_get_action_state (r->priv->group, r->priv->name);
fullname = g_strdup_printf ("%s.%s", r->priv->prefix, r->priv->name);
gtk_container_add (GTK_CONTAINER (r), gtk_label_new (fullname));
g_free (fullname);
r->priv->sg = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
activate = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
gtk_container_add (GTK_CONTAINER (row), activate);
gtk_size_group_add_widget (r->priv->sg, activate);
r->priv->activate_button = gtk_button_new_with_label (_("Activate"));
g_signal_connect (r->priv->activate_button, "clicked", G_CALLBACK (activate_action), r);
gtk_size_group_add_widget (r->priv->sg, r->priv->activate_button);
gtk_widget_set_sensitive (r->priv->activate_button, r->priv->enabled);
gtk_container_add (GTK_CONTAINER (activate), r->priv->activate_button);
gtk_container_add (GTK_CONTAINER (row), r->priv->activate_button);
r->priv->parameter_type = g_action_group_get_action_parameter_type (r->priv->group, r->priv->name);
if (r->priv->parameter_type)
{
r->priv->parameter_entry = variant_editor_new (r->priv->parameter_type, parameter_changed, r);
gtk_widget_set_sensitive (r->priv->parameter_entry, r->priv->enabled);
gtk_container_add (GTK_CONTAINER (activate), r->priv->parameter_entry);
gtk_container_add (GTK_CONTAINER (row), r->priv->parameter_entry);
}
gtk_container_add (GTK_CONTAINER (r), row);
@@ -299,7 +297,7 @@ constructed (GObject *object)
{
r->priv->state_type = g_variant_type_copy (g_variant_get_type (state));
row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
label = gtk_label_new (_("Set State"));
label = gtk_label_new (_("State"));
gtk_size_group_add_widget (r->priv->sg, label);
gtk_container_add (GTK_CONTAINER (row), label);
r->priv->state_entry = variant_editor_new (r->priv->state_type, state_changed, r);
@@ -352,10 +350,6 @@ get_property (GObject *object,
g_value_set_string (value, r->priv->name);
break;
case PROP_SIZEGROUP:
g_value_set_object (value, r->priv->sg);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -386,10 +380,6 @@ set_property (GObject *object,
r->priv->name = g_value_dup_string (value);
break;
case PROP_SIZEGROUP:
r->priv->sg = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
break;
@@ -417,21 +407,16 @@ gtk_inspector_action_editor_class_init (GtkInspectorActionEditorClass *klass)
g_object_class_install_property (object_class, PROP_NAME,
g_param_spec_string ("name", "Name", "The action name",
NULL, G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_SIZEGROUP,
g_param_spec_object ("sizegroup", "Size Group", "The Size Group for activate",
GTK_TYPE_SIZE_GROUP, G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
}
GtkWidget *
gtk_inspector_action_editor_new (GActionGroup *group,
const gchar *prefix,
const gchar *name,
GtkSizeGroup *activate)
const gchar *name)
{
return g_object_new (GTK_TYPE_INSPECTOR_ACTION_EDITOR,
"group", group,
"prefix", prefix,
"name", name,
"sizegroup", activate,
NULL);
}
+1 -3
View File
@@ -20,7 +20,6 @@
#include <gtk/gtkbox.h>
#include <gtk/gtksizegroup.h>
#define GTK_TYPE_INSPECTOR_ACTION_EDITOR (gtk_inspector_action_editor_get_type())
@@ -50,8 +49,7 @@ G_BEGIN_DECLS
GType gtk_inspector_action_editor_get_type (void);
GtkWidget *gtk_inspector_action_editor_new (GActionGroup *group,
const gchar *prefix,
const gchar *name,
GtkSizeGroup *activate);
const gchar *name);
G_END_DECLS
+85 -114
View File
@@ -29,9 +29,6 @@
#include "gtkpopover.h"
#include "gtklabel.h"
#include "gtkstack.h"
#include "gtklistbox.h"
#include "gtkstylecontext.h"
#include "gtksizegroup.h"
enum
{
@@ -45,14 +42,9 @@ enum
struct _GtkInspectorActionsPrivate
{
GtkWidget *list;
GtkSizeGroup *prefix;
GtkSizeGroup *name;
GtkSizeGroup *enabled;
GtkSizeGroup *parameter;
GtkSizeGroup *state;
GtkSizeGroup *activate;
GtkListStore *model;
GHashTable *groups;
GHashTable *iters;
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorActions, gtk_inspector_actions, GTK_TYPE_BOX)
@@ -61,6 +53,10 @@ static void
gtk_inspector_actions_init (GtkInspectorActions *sl)
{
sl->priv = gtk_inspector_actions_get_instance_private (sl);
sl->priv->iters = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
(GDestroyNotify) gtk_tree_iter_free);
sl->priv->groups = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
NULL,
@@ -74,15 +70,11 @@ add_action (GtkInspectorActions *sl,
const gchar *prefix,
const gchar *name)
{
GtkTreeIter iter;
gboolean enabled;
const gchar *parameter;
GVariant *state;
gchar *state_string;
GtkWidget *row;
GtkWidget *label;
GtkWidget *box;
char *key = g_strconcat (prefix, ".", name, NULL);
GtkWidget *editor;
enabled = g_action_group_get_action_enabled (group, name);
parameter = (const gchar *)g_action_group_get_action_parameter_type (group, name);
@@ -91,82 +83,21 @@ add_action (GtkInspectorActions *sl,
state_string = g_variant_print (state, FALSE);
else
state_string = g_strdup ("");
row = gtk_list_box_row_new ();
g_object_set_data_full (G_OBJECT (row), "key", key, g_free);
gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), FALSE);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_add (GTK_CONTAINER (row), box);
label = gtk_label_new (prefix);
gtk_style_context_add_class (gtk_widget_get_style_context (label), "cell");
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_size_group_add_widget (sl->priv->prefix, label);
gtk_container_add (GTK_CONTAINER (box), label);
label = gtk_label_new (name);
gtk_style_context_add_class (gtk_widget_get_style_context (label), "cell");
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_size_group_add_widget (sl->priv->name, label);
gtk_container_add (GTK_CONTAINER (box), label);
label = gtk_label_new (enabled ? "+" : "-");
gtk_style_context_add_class (gtk_widget_get_style_context (label), "cell");
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_size_group_add_widget (sl->priv->enabled, label);
gtk_container_add (GTK_CONTAINER (box), label);
g_object_set_data (G_OBJECT (row), "enabled", label);
label = gtk_label_new (parameter);
gtk_style_context_add_class (gtk_widget_get_style_context (label), "cell");
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_size_group_add_widget (sl->priv->parameter, label);
gtk_container_add (GTK_CONTAINER (box), label);
label = gtk_label_new (state_string);
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_style_context_add_class (gtk_widget_get_style_context (label), "cell");
gtk_size_group_add_widget (sl->priv->state, label);
gtk_container_add (GTK_CONTAINER (box), label);
g_object_set_data (G_OBJECT (row), "state", label);
editor = gtk_inspector_action_editor_new (group, prefix, name, sl->priv->activate);
gtk_style_context_add_class (gtk_widget_get_style_context (editor), "cell");
gtk_container_add (GTK_CONTAINER (box), editor);
gtk_container_add (GTK_CONTAINER (sl->priv->list), row);
gtk_list_store_append (sl->priv->model, &iter);
gtk_list_store_set (sl->priv->model, &iter,
COLUMN_PREFIX, prefix,
COLUMN_NAME, name,
COLUMN_ENABLED, enabled,
COLUMN_PARAMETER, parameter,
COLUMN_STATE, state_string,
COLUMN_GROUP, group,
-1);
g_hash_table_insert (sl->priv->iters,
g_strconcat (prefix, ".", name, NULL),
gtk_tree_iter_copy (&iter));
g_free (state_string);
}
static GtkWidget *
find_row (GtkInspectorActions *sl,
const char *prefix,
const char *action_name)
{
GtkWidget *row = NULL;
GtkWidget *widget;
char *key = g_strconcat (prefix, ".", action_name, NULL);
for (widget = gtk_widget_get_first_child (sl->priv->list);
widget;
widget = gtk_widget_get_next_sibling (widget))
{
const char *rkey = g_object_get_data (G_OBJECT (widget), "key");
if (g_str_equal (key, rkey))
{
row = widget;
break;
}
}
g_free (key);
return row;
}
static void
action_added_cb (GActionGroup *group,
const gchar *action_name,
@@ -183,12 +114,14 @@ action_removed_cb (GActionGroup *group,
GtkInspectorActions *sl)
{
const gchar *prefix;
GtkWidget *row;
gchar *key;
GtkTreeIter *iter;
prefix = g_hash_table_lookup (sl->priv->groups, group);
row = find_row (sl, prefix, action_name);
if (row)
gtk_container_remove (GTK_CONTAINER (sl->priv->list), row);
key = g_strconcat (prefix, ".", action_name, NULL);
iter = g_hash_table_lookup (sl->priv->iters, key);
gtk_list_store_remove (sl->priv->model, iter);
g_hash_table_remove (sl->priv->iters, key);
g_free (key);
}
static void
@@ -198,14 +131,15 @@ action_enabled_changed_cb (GActionGroup *group,
GtkInspectorActions *sl)
{
const gchar *prefix;
GtkWidget *row;
GtkWidget *label;
gchar *key;
GtkTreeIter *iter;
prefix = g_hash_table_lookup (sl->priv->groups, group);
row = find_row (sl, prefix, action_name);
label = GTK_WIDGET (g_object_get_data (G_OBJECT (row), "enabled"));
gtk_label_set_label (GTK_LABEL (label), enabled ? "+" : "-" );
key = g_strconcat (prefix, ".", action_name, NULL);
iter = g_hash_table_lookup (sl->priv->iters, key);
gtk_list_store_set (sl->priv->model, iter,
COLUMN_ENABLED, enabled,
-1);
g_free (key);
}
static void
@@ -215,20 +149,21 @@ action_state_changed_cb (GActionGroup *group,
GtkInspectorActions *sl)
{
const gchar *prefix;
gchar *key;
GtkTreeIter *iter;
gchar *state_string;
GtkWidget *row;
GtkWidget *label;
prefix = g_hash_table_lookup (sl->priv->groups, group);
row = find_row (sl, prefix, action_name);
key = g_strconcat (prefix, ".", action_name, NULL);
iter = g_hash_table_lookup (sl->priv->iters, key);
if (state)
state_string = g_variant_print (state, FALSE);
else
state_string = g_strdup ("");
label = GTK_WIDGET (g_object_get_data (G_OBJECT (row), "state"));
gtk_label_set_label (GTK_LABEL (label), state_string);
gtk_list_store_set (sl->priv->model, iter,
COLUMN_STATE, state_string,
-1);
g_free (state_string);
g_free (key);
}
static void
@@ -279,6 +214,8 @@ gtk_inspector_actions_set_object (GtkInspectorActions *sl,
g_object_set (page, "visible", FALSE, NULL);
g_hash_table_foreach (sl->priv->groups, disconnect_group, sl);
g_hash_table_remove_all (sl->priv->groups);
g_hash_table_remove_all (sl->priv->iters);
gtk_list_store_clear (sl->priv->model);
if (GTK_IS_APPLICATION (object))
add_group (sl, page, G_ACTION_GROUP (object), "app");
@@ -301,19 +238,53 @@ gtk_inspector_actions_set_object (GtkInspectorActions *sl,
}
}
static void
row_activated (GtkTreeView *tv,
GtkTreePath *path,
GtkTreeViewColumn *col,
GtkInspectorActions *sl)
{
GtkTreeIter iter;
GdkRectangle rect;
GtkWidget *popover;
gchar *prefix;
gchar *name;
GActionGroup *group;
GtkWidget *editor;
gtk_tree_model_get_iter (GTK_TREE_MODEL (sl->priv->model), &iter, path);
gtk_tree_model_get (GTK_TREE_MODEL (sl->priv->model),
&iter,
COLUMN_PREFIX, &prefix,
COLUMN_NAME, &name,
COLUMN_GROUP, &group,
-1);
gtk_tree_model_get_iter (GTK_TREE_MODEL (sl->priv->model), &iter, path);
gtk_tree_view_get_cell_area (tv, path, col, &rect);
gtk_tree_view_convert_bin_window_to_widget_coords (tv, rect.x, rect.y, &rect.x, &rect.y);
popover = gtk_popover_new (GTK_WIDGET (tv));
gtk_popover_set_pointing_to (GTK_POPOVER (popover), &rect);
editor = gtk_inspector_action_editor_new (group, prefix, name);
gtk_container_add (GTK_CONTAINER (popover), editor);
gtk_popover_popup (GTK_POPOVER (popover));
g_signal_connect (popover, "hide", G_CALLBACK (gtk_widget_destroy), NULL);
g_free (name);
g_free (prefix);
}
static void
gtk_inspector_actions_class_init (GtkInspectorActionsClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/actions.ui");
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorActions, list);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorActions, prefix);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorActions, name);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorActions, enabled);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorActions, parameter);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorActions, state);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorActions, activate);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorActions, model);
gtk_widget_class_bind_template_callback (widget_class, row_activated);
}
// vim: set et sw=2 ts=2:
+70 -85
View File
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface domain="gtk40">
<object class="GtkListStore" id="model">
<columns>
@@ -12,98 +11,84 @@
</object>
<template class="GtkInspectorActions" parent="GtkBox">
<property name="orientation">vertical</property>
<style>
<class name="view"/>
</style>
<child>
<object class="GtkBox">
<style>
<class name="header"/>
</style>
<child>
<object class="GtkLabel" id="prefix_heading">
<property name="label" translatable="yes">Prefix</property>
<property name="xalign">0</property>
</object>
</child>
<child>
<object class="GtkLabel" id="name_heading">
<property name="label" translatable="yes">Name</property>
<property name="xalign">0</property>
</object>
</child>
<child>
<object class="GtkLabel" id="enabled_heading">
<property name="label" translatable="yes">Enabled</property>
<property name="xalign">0</property>
</object>
</child>
<child>
<object class="GtkLabel" id="parameter_heading">
<property name="label" translatable="yes">Parameter Type</property>
<property name="xalign">0</property>
</object>
</child>
<child>
<object class="GtkLabel" id="state_heading">
<property name="label" translatable="yes">State</property>
<property name="xalign">0</property>
</object>
</child>
<child>
<object class="GtkLabel" id="changes_heading">
<property name="label" translatable="yes"></property>
<property name="xalign">0</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="expand">1</property>
<property name="hscrollbar-policy">never</property>
<child>
<object class="GtkListBox" id="list">
<style>
<class name="list"/>
</style>
<property name="selection-mode">none</property>
<object class="GtkTreeView">
<property name="model">model</property>
<property name="enable-search">0</property>
<property name="activate-on-single-click">1</property>
<signal name="row-activated" handler="row_activated"/>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">Prefix</property>
<child>
<object class="GtkCellRendererText">
<property name="scale">0.8</property>
</object>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">Name</property>
<child>
<object class="GtkCellRendererText">
<property name="scale">0.8</property>
</object>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">Enabled</property>
<child>
<object class="GtkCellRendererText">
<property name="scale">0.8</property>
</object>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">Parameter Type</property>
<child>
<object class="GtkCellRendererText">
<property name="scale">0.8</property>
</object>
<attributes>
<attribute name="text">3</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">State</property>
<child>
<object class="GtkCellRendererText">
<property name="scale">0.8</property>
</object>
<attributes>
<attribute name="text">4</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
<object class="GtkSizeGroup" id="prefix">
<property name="mode">horizontal</property>
<widgets>
<widget name="prefix_heading"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="name">
<property name="mode">horizontal</property>
<widgets>
<widget name="name_heading"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="enabled">
<property name="mode">horizontal</property>
<widgets>
<widget name="enabled_heading"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="parameter">
<property name="mode">horizontal</property>
<widgets>
<widget name="parameter_heading"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="state">
<property name="mode">horizontal</property>
<widgets>
<widget name="state_heading"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="activate">
<property name="mode">horizontal</property>
</object>
</interface>
-35
View File
@@ -1,35 +0,0 @@
/* some style for the inspector */
.header {
background: lightgray;
border: 1px solid gray;
}
.header>* {
padding: 2px;
font-weight: bold;
}
.header sort_indicator {
min-width: 16px;
}
.header>*:not(:last-child) {
border-right: 1px solid gray;
}
.list .cell {
font-size: smaller;
padding: 0 2px;
min-height: 24px;
}
.list .cell entry,
.list .cell spinbutton,
.list .cell button,
.list .cell combobox
{
min-height: 24px;
min-width: 0;
padding: 0 4px;
}
+1 -1
View File
@@ -180,7 +180,7 @@ show_object (GtkInspectorMiscInfo *sl,
const gchar *tab)
{
g_object_set_data_full (G_OBJECT (sl->priv->object_tree), "next-tab", g_strdup (tab), g_free);
gtk_inspector_object_tree_activate_object (sl->priv->object_tree, object);
gtk_inspector_object_tree_select_object (sl->priv->object_tree, object);
}
static void
+6 -7
View File
@@ -43,7 +43,6 @@
#include "gtksizegroup.h"
#include "gtkroot.h"
#include "gtkgesturemultipress.h"
#include "gtkstylecontext.h"
enum
{
@@ -106,13 +105,17 @@ apply_sort (GtkInspectorPropList *pl,
if (column == COLUMN_NAME)
{
gtk_image_clear (GTK_IMAGE (pl->priv->origin_sort_indicator));
gtk_widget_hide (pl->priv->origin_sort_indicator);
gtk_widget_show (pl->priv->name_sort_indicator);
gtk_image_set_from_icon_name (GTK_IMAGE (pl->priv->name_sort_indicator),
icon_name);
}
else
{
gtk_image_clear (GTK_IMAGE (pl->priv->name_sort_indicator));
gtk_widget_show (pl->priv->origin_sort_indicator);
gtk_widget_hide (pl->priv->name_sort_indicator);
gtk_image_set_from_icon_name (GTK_IMAGE (pl->priv->origin_sort_indicator),
icon_name);
}
@@ -537,28 +540,24 @@ gtk_inspector_prop_list_create_row (GtkInspectorPropList *pl,
gtk_container_add (GTK_CONTAINER (row), box);
label = gtk_label_new (prop->name);
gtk_style_context_add_class (gtk_widget_get_style_context (label), "cell");
gtk_widget_set_sensitive (label, writable);
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_size_group_add_widget (pl->priv->names, label);
gtk_container_add (GTK_CONTAINER (box), label);
label = gtk_label_new (type ? type : "");
gtk_style_context_add_class (gtk_widget_get_style_context (label), "cell");
gtk_widget_set_sensitive (label, writable);
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_size_group_add_widget (pl->priv->types, label);
gtk_container_add (GTK_CONTAINER (box), label);
label = gtk_label_new (g_type_name (prop->owner_type));
gtk_style_context_add_class (gtk_widget_get_style_context (label), "cell");
gtk_widget_set_sensitive (label, writable);
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_size_group_add_widget (pl->priv->origins, label);
gtk_container_add (GTK_CONTAINER (box), label);
widget = gtk_inspector_prop_editor_new (pl->priv->object, prop->name, pl->priv->values);
gtk_style_context_add_class (gtk_widget_get_style_context (widget), "cell");
gtk_container_add (GTK_CONTAINER (box), widget);
g_signal_connect (widget, "show-object", G_CALLBACK (show_object), pl);
+3 -16
View File
@@ -15,7 +15,6 @@
</style>
<child>
<object class="GtkBox" id="name_heading">
<property name="hexpand">0</property>
<child>
<object class="GtkGestureMultiPress">
<signal name="pressed" handler="sort_changed" swapped="no"/>
@@ -31,9 +30,6 @@
</child>
<child>
<object class="GtkImage" id="name_sort_indicator">
<style>
<class name="sort_indicator"/>
</style>
</object>
</child>
</object>
@@ -46,7 +42,6 @@
</child>
<child>
<object class="GtkBox" id="origin_heading">
<property name="hexpand">0</property>
<child>
<object class="GtkGestureMultiPress">
<signal name="pressed" handler="sort_changed" swapped="no"/>
@@ -62,9 +57,6 @@
</child>
<child>
<object class="GtkImage" id="origin_sort_indicator">
<style>
<class name="sort_indicator"/>
</style>
</object>
</child>
</object>
@@ -73,7 +65,9 @@
<object class="GtkLabel" id="value_heading">
<property name="label">Value</property>
<property name="xalign">0</property>
<property name="hexpand">0</property>
<property name="hexpand">1</property>
<property name="margin-start">6</property>
<property name="margin-end">6</property>
</object>
</child>
</object>
@@ -84,9 +78,6 @@
<property name="hscrollbar-policy">never</property>
<child>
<object class="GtkListBox" id="list2">
<style>
<class name="list"/>
</style>
<property name="selection-mode">none</property>
</object>
</child>
@@ -96,25 +87,21 @@
</child>
</template>
<object class="GtkSizeGroup" id="names">
<property name="mode">horizontal</property>
<widgets>
<widget name="name_heading"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="types">
<property name="mode">horizontal</property>
<widgets>
<widget name="type_heading"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="origins">
<property name="mode">horizontal</property>
<widgets>
<widget name="origin_heading"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="values">
<property name="mode">horizontal</property>
<widgets>
<widget name="value_heading"/>
</widgets>
-11
View File
@@ -54,9 +54,6 @@
#include "gtkwindowgroup.h"
#include "gtkrevealer.h"
#include "gtklayoutmanager.h"
#include "gtkcssprovider.h"
#include "gtkstylecontext.h"
G_DEFINE_TYPE (GtkInspectorWindow, gtk_inspector_window, GTK_TYPE_WINDOW)
@@ -293,19 +290,11 @@ static void
gtk_inspector_window_realize (GtkWidget *widget)
{
GskRenderer *renderer;
GtkCssProvider *provider;
GTK_WIDGET_CLASS (gtk_inspector_window_parent_class)->realize (widget);
renderer = gtk_root_get_renderer (GTK_ROOT (widget));
gsk_renderer_set_debug_flags (renderer, 0);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/org/gtk/libgtk/inspector/inspector.css");
gtk_style_context_add_provider_for_display (gtk_widget_get_display (widget),
GTK_STYLE_PROVIDER (provider),
800);
g_object_unref (provider);
}
static void
-2
View File
@@ -1083,8 +1083,6 @@ if build_gir
gtk_introspection_sources = [
gtk_public_headers,
gtk_public_sources,
gtk_deprecated_headers,
gtk_deprecated_sources,
a11y_headers,
a11y_sources,
gtktypebuiltins_h,

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