mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-12 20:00:09 +00:00
Merge branch 'wip/otte/for-master' into 'master'
fontbutton: Make sure the window is on the same display See merge request GNOME/gtk!3901
This commit is contained in:
commit
32899a1edd
@ -60,7 +60,7 @@ struct _NodeEditorWindow
|
||||
|
||||
GtkWidget *renderer_listbox;
|
||||
GListStore *renderers;
|
||||
GdkPaintable *paintable;
|
||||
GskRenderNode *node;
|
||||
|
||||
GFileMonitor *file_monitor;
|
||||
|
||||
@ -167,7 +167,6 @@ static void
|
||||
text_changed (GtkTextBuffer *buffer,
|
||||
NodeEditorWindow *self)
|
||||
{
|
||||
GskRenderNode *node;
|
||||
char *text;
|
||||
GBytes *bytes;
|
||||
GtkTextIter iter;
|
||||
@ -178,10 +177,12 @@ text_changed (GtkTextBuffer *buffer,
|
||||
text_buffer_remove_all_tags (self->text_buffer);
|
||||
bytes = g_bytes_new_take (text, strlen (text));
|
||||
|
||||
g_clear_pointer (&self->node, gsk_render_node_unref);
|
||||
|
||||
/* If this is too slow, go fix the parser performance */
|
||||
node = gsk_render_node_deserialize (bytes, deserialize_error_func, self);
|
||||
self->node = gsk_render_node_deserialize (bytes, deserialize_error_func, self);
|
||||
g_bytes_unref (bytes);
|
||||
if (node)
|
||||
if (self->node)
|
||||
{
|
||||
/* XXX: Is this code necessary or can we have API to turn nodes into paintables? */
|
||||
GtkSnapshot *snapshot;
|
||||
@ -190,10 +191,9 @@ text_changed (GtkTextBuffer *buffer,
|
||||
guint i;
|
||||
|
||||
snapshot = gtk_snapshot_new ();
|
||||
gsk_render_node_get_bounds (node, &bounds);
|
||||
gsk_render_node_get_bounds (self->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);
|
||||
gtk_snapshot_append_node (snapshot, self->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++)
|
||||
@ -337,15 +337,9 @@ text_view_query_tooltip_cb (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
load_file_contents (NodeEditorWindow *self,
|
||||
GFile *file)
|
||||
load_bytes (NodeEditorWindow *self,
|
||||
GBytes *bytes)
|
||||
{
|
||||
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);
|
||||
@ -361,6 +355,105 @@ load_file_contents (NodeEditorWindow *self,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
load_file_contents (NodeEditorWindow *self,
|
||||
GFile *file)
|
||||
{
|
||||
GBytes *bytes;
|
||||
|
||||
bytes = g_file_load_bytes (file, NULL, NULL, NULL);
|
||||
if (bytes == NULL)
|
||||
return FALSE;
|
||||
|
||||
return load_bytes (self, bytes);
|
||||
}
|
||||
|
||||
static GdkContentProvider *
|
||||
on_picture_drag_prepare_cb (GtkDragSource *source,
|
||||
double x,
|
||||
double y,
|
||||
NodeEditorWindow *self)
|
||||
{
|
||||
if (self->node == NULL)
|
||||
return NULL;
|
||||
|
||||
return gdk_content_provider_new_typed (GSK_TYPE_RENDER_NODE, self->node);
|
||||
}
|
||||
|
||||
static void
|
||||
on_picture_drop_read_done_cb (GObject *source,
|
||||
GAsyncResult *res,
|
||||
gpointer data)
|
||||
{
|
||||
NodeEditorWindow *self = data;
|
||||
GOutputStream *stream = G_OUTPUT_STREAM (source);
|
||||
GdkDrop *drop = g_object_get_data (source, "drop");
|
||||
GdkDragAction action = 0;
|
||||
GBytes *bytes;
|
||||
|
||||
if (g_output_stream_splice_finish (stream, res, NULL) >= 0)
|
||||
{
|
||||
bytes = g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (stream));
|
||||
if (load_bytes (self, bytes))
|
||||
action = GDK_ACTION_COPY;
|
||||
}
|
||||
|
||||
g_object_unref (self);
|
||||
gdk_drop_finish (drop, action);
|
||||
g_object_unref (drop);
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
on_picture_drop_read_cb (GObject *source,
|
||||
GAsyncResult *res,
|
||||
gpointer data)
|
||||
{
|
||||
NodeEditorWindow *self = data;
|
||||
GdkDrop *drop = GDK_DROP (source);
|
||||
GInputStream *input;
|
||||
GOutputStream *output;
|
||||
|
||||
input = gdk_drop_read_finish (drop, res, NULL, NULL);
|
||||
if (input == NULL)
|
||||
{
|
||||
g_object_unref (self);
|
||||
gdk_drop_finish (drop, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
output = g_memory_output_stream_new_resizable ();
|
||||
g_object_set_data (G_OBJECT (output), "drop", drop);
|
||||
g_object_ref (drop);
|
||||
|
||||
g_output_stream_splice_async (output,
|
||||
input,
|
||||
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
|
||||
G_PRIORITY_DEFAULT,
|
||||
NULL,
|
||||
on_picture_drop_read_done_cb,
|
||||
self);
|
||||
g_object_unref (output);
|
||||
g_object_unref (input);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
on_picture_drop_cb (GtkDropTargetAsync *dest,
|
||||
GdkDrop *drop,
|
||||
double x,
|
||||
double y,
|
||||
NodeEditorWindow *self)
|
||||
{
|
||||
gdk_drop_read_async (drop,
|
||||
(const char *[2]) { "application/x-gtk-render-node", NULL },
|
||||
G_PRIORITY_DEFAULT,
|
||||
NULL,
|
||||
on_picture_drop_read_cb,
|
||||
g_object_ref (self));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
file_changed_cb (GFileMonitor *monitor,
|
||||
GFile *file,
|
||||
@ -735,6 +828,7 @@ node_editor_window_finalize (GObject *object)
|
||||
|
||||
g_array_free (self->errors, TRUE);
|
||||
|
||||
g_clear_pointer (&self->node, gsk_render_node_unref);
|
||||
g_clear_object (&self->renderers);
|
||||
|
||||
G_OBJECT_CLASS (node_editor_window_parent_class)->finalize (object);
|
||||
@ -844,6 +938,8 @@ node_editor_window_class_init (NodeEditorWindowClass *class)
|
||||
gtk_widget_class_bind_template_callback (widget_class, testcase_save_clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, testcase_name_entry_changed_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, dark_mode_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_picture_drag_prepare_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_picture_drop_cb);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
|
@ -200,6 +200,19 @@
|
||||
<property name="can-shrink">0</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<child>
|
||||
<object class="GtkDragSource">
|
||||
<property name="actions">copy</property>
|
||||
<signal name="prepare" handler="on_picture_drag_prepare_cb" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkDropTargetAsync">
|
||||
<property name="actions">copy</property>
|
||||
<property name="formats">application/x-gtk-render-node</property>
|
||||
<signal name="drop" handler="on_picture_drop_cb" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@ -553,6 +553,8 @@ gdk_content_deserialize_async (GInputStream *stream,
|
||||
Deserializer *deserializer;
|
||||
|
||||
g_return_if_fail (G_IS_INPUT_STREAM (stream));
|
||||
g_return_if_fail (mime_type != NULL);
|
||||
g_return_if_fail (G_TYPE_IS_VALUE_TYPE (type));
|
||||
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
|
||||
g_return_if_fail (callback != NULL);
|
||||
|
||||
@ -591,7 +593,10 @@ gdk_content_deserialize_finish (GAsyncResult *result,
|
||||
g_return_val_if_fail (GDK_IS_CONTENT_DESERIALIZER (result), FALSE);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
deserializer = GDK_CONTENT_DESERIALIZER (result);
|
||||
g_return_val_if_fail (G_VALUE_HOLDS (value, G_VALUE_TYPE (&deserializer->value)), FALSE);
|
||||
if (G_VALUE_TYPE (value) == 0)
|
||||
g_value_init (value, G_VALUE_TYPE (&deserializer->value));
|
||||
else
|
||||
g_return_val_if_fail (G_VALUE_HOLDS (value, G_VALUE_TYPE (&deserializer->value)), FALSE);
|
||||
|
||||
if (deserializer->error)
|
||||
{
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* GskRenderNode: (ref-func gsk_render_node_ref) (unref-func gsk_render_node_unref)
|
||||
* GskRenderNode: (ref-func gsk_render_node_ref) (unref-func gsk_render_node_unref) (set-value-func gsk_value_set_render_node) (get-value-func gsk_value_get_render_node)
|
||||
*
|
||||
* `GskRenderNode` is the basic block in a scene graph to be
|
||||
* rendered using `GskRenderer`.
|
||||
@ -620,3 +620,108 @@ gsk_render_node_deserialize (GBytes *bytes,
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_value_set_render_node:
|
||||
* @value: a `GValue` initialized with type `GSK_TYPE_RENDER_NODE`
|
||||
* @node: a `GskRenderNode`
|
||||
*
|
||||
* Stores the given `GskRenderNode` inside `value`.
|
||||
*
|
||||
* The `GValue` will acquire a reference to the `node`.
|
||||
*/
|
||||
void
|
||||
gsk_value_set_render_node (GValue *value,
|
||||
GskRenderNode *node)
|
||||
{
|
||||
GskRenderNode *old_node;
|
||||
|
||||
g_return_if_fail (G_VALUE_HOLDS (value, GSK_TYPE_RENDER_NODE));
|
||||
|
||||
old_node = value->data[0].v_pointer;
|
||||
|
||||
if (node != NULL)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_RENDER_NODE (node));
|
||||
|
||||
value->data[0].v_pointer = gsk_render_node_ref (node);
|
||||
}
|
||||
else
|
||||
{
|
||||
value->data[0].v_pointer = NULL;
|
||||
}
|
||||
|
||||
if (old_node != NULL)
|
||||
gsk_render_node_unref (old_node);
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_value_take_render_node:
|
||||
* @value: a `GValue` initialized with type `GSK_TYPE_RENDER_NODE`
|
||||
* @node: (transfer full) (nullable): a `GskRenderNode`
|
||||
*
|
||||
* Stores the given `GskRenderNode` inside `value`.
|
||||
*
|
||||
* This function transfers the ownership of the `node` to the `GValue`.
|
||||
*/
|
||||
void
|
||||
gsk_value_take_render_node (GValue *value,
|
||||
GskRenderNode *node)
|
||||
{
|
||||
GskRenderNode *old_node;
|
||||
|
||||
g_return_if_fail (G_VALUE_HOLDS (value, GSK_TYPE_RENDER_NODE));
|
||||
|
||||
old_node = value->data[0].v_pointer;
|
||||
|
||||
if (node != NULL)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_RENDER_NODE (node));
|
||||
|
||||
value->data[0].v_pointer = node;
|
||||
}
|
||||
else
|
||||
{
|
||||
value->data[0].v_pointer = NULL;
|
||||
}
|
||||
|
||||
if (old_node != NULL)
|
||||
gsk_render_node_unref (old_node);
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_value_get_render_node:
|
||||
* @value: a `GValue` initialized with type `GSK_TYPE_RENDER_NODE`
|
||||
*
|
||||
* Retrieves the `GskRenderNode` stored inside the given `value`.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): a `GskRenderNode`
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_value_get_render_node (const GValue *value)
|
||||
{
|
||||
g_return_val_if_fail (G_VALUE_HOLDS (value, GSK_TYPE_RENDER_NODE), NULL);
|
||||
|
||||
return value->data[0].v_pointer;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_value_dup_render_node:
|
||||
* @value: a `GValue` initialized with type `GSK_TYPE_RENDER_NODE`
|
||||
*
|
||||
* Retrieves the `GskRenderNode` stored inside the given `value`, and acquires
|
||||
* a reference to it.
|
||||
*
|
||||
* Returns: (transfer full) (nullable): a `GskRenderNode`
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_value_dup_render_node (const GValue *value)
|
||||
{
|
||||
g_return_val_if_fail (G_VALUE_HOLDS (value, GSK_TYPE_RENDER_NODE), NULL);
|
||||
|
||||
if (value->data[0].v_pointer == NULL)
|
||||
return NULL;
|
||||
|
||||
return gsk_render_node_ref (value->data[0].v_pointer);
|
||||
}
|
||||
|
||||
|
@ -534,6 +534,26 @@ GBytes * gsk_gl_shader_node_get_args (const GskRender
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskGLShader * gsk_gl_shader_node_get_shader (const GskRenderNode *node) G_GNUC_PURE;
|
||||
|
||||
/**
|
||||
* GSK_VALUE_HOLDS_RENDER_NODE:
|
||||
* @value: a `GValue`
|
||||
*
|
||||
* Evaluates to %TRUE if @value was initialized with %GSK_TYPE_RENDER_NODE.
|
||||
*/
|
||||
#define GSK_VALUE_HOLDS_RENDER_NODE(value) (G_VALUE_HOLDS ((value), GSK_TYPE_RENDER_NODE))
|
||||
|
||||
GDK_AVAILABLE_IN_4_4
|
||||
void gsk_value_set_render_node (GValue *value,
|
||||
GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_4_4
|
||||
void gsk_value_take_render_node (GValue *value,
|
||||
GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_4_4
|
||||
GskRenderNode * gsk_value_get_render_node (const GValue *value);
|
||||
GDK_AVAILABLE_IN_4_4
|
||||
GskRenderNode * gsk_value_dup_render_node (const GValue *value);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_RENDER_NODE_H__ */
|
||||
|
@ -5721,6 +5721,116 @@ gsk_render_node_init_types_once (void)
|
||||
gsk_render_node_types[GSK_DEBUG_NODE] = node_type;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_render_node_content_serializer_finish (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer serializer)
|
||||
{
|
||||
GOutputStream *stream = G_OUTPUT_STREAM (source);
|
||||
GError *error = NULL;
|
||||
|
||||
if (!g_output_stream_write_bytes_finish (stream, result, &error))
|
||||
gdk_content_serializer_return_error (serializer, error);
|
||||
else
|
||||
gdk_content_serializer_return_success (serializer);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_render_node_content_serializer (GdkContentSerializer *serializer)
|
||||
{
|
||||
const GValue *value;
|
||||
GskRenderNode *node;
|
||||
GBytes *bytes;
|
||||
|
||||
value = gdk_content_serializer_get_value (serializer);
|
||||
node = gsk_value_get_render_node (value);
|
||||
bytes = gsk_render_node_serialize (node);
|
||||
|
||||
g_output_stream_write_bytes_async (gdk_content_serializer_get_output_stream (serializer),
|
||||
bytes,
|
||||
gdk_content_serializer_get_priority (serializer),
|
||||
gdk_content_serializer_get_cancellable (serializer),
|
||||
gsk_render_node_content_serializer_finish,
|
||||
serializer);
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_render_node_content_deserializer_finish (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer deserializer)
|
||||
{
|
||||
GOutputStream *stream = G_OUTPUT_STREAM (source);
|
||||
GError *error = NULL;
|
||||
gssize written;
|
||||
GValue *value;
|
||||
GskRenderNode *node;
|
||||
GBytes *bytes;
|
||||
|
||||
written = g_output_stream_splice_finish (stream, result, &error);
|
||||
if (written < 0)
|
||||
{
|
||||
gdk_content_deserializer_return_error (deserializer, error);
|
||||
return;
|
||||
}
|
||||
|
||||
bytes = g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (stream));
|
||||
|
||||
/* For now, we ignore any parsing errors. We might want to revisit that if it turns
|
||||
* out copy/paste leads to too many errors */
|
||||
node = gsk_render_node_deserialize (bytes, NULL, NULL);
|
||||
|
||||
value = gdk_content_deserializer_get_value (deserializer);
|
||||
gsk_value_take_render_node (value, node);
|
||||
|
||||
gdk_content_deserializer_return_success (deserializer);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_render_node_content_deserializer (GdkContentDeserializer *deserializer)
|
||||
{
|
||||
GOutputStream *output;
|
||||
|
||||
output = g_memory_output_stream_new_resizable ();
|
||||
|
||||
g_output_stream_splice_async (output,
|
||||
gdk_content_deserializer_get_input_stream (deserializer),
|
||||
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
|
||||
gdk_content_deserializer_get_priority (deserializer),
|
||||
gdk_content_deserializer_get_cancellable (deserializer),
|
||||
gsk_render_node_content_deserializer_finish,
|
||||
deserializer);
|
||||
g_object_unref (output);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_render_node_init_content_serializers (void)
|
||||
{
|
||||
gdk_content_register_serializer (GSK_TYPE_RENDER_NODE,
|
||||
"application/x-gtk-render-node",
|
||||
gsk_render_node_content_serializer,
|
||||
NULL,
|
||||
NULL);
|
||||
gdk_content_register_serializer (GSK_TYPE_RENDER_NODE,
|
||||
"text/plain;charset=utf-8",
|
||||
gsk_render_node_content_serializer,
|
||||
NULL,
|
||||
NULL);
|
||||
/* The serialization format only outputs ASCII, so we can do this */
|
||||
gdk_content_register_serializer (GSK_TYPE_RENDER_NODE,
|
||||
"text/plain",
|
||||
gsk_render_node_content_serializer,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
gdk_content_register_deserializer ("application/x-gtk-render-node",
|
||||
GSK_TYPE_RENDER_NODE,
|
||||
gsk_render_node_content_deserializer,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gsk_render_node_init_types:
|
||||
*
|
||||
@ -5735,6 +5845,7 @@ gsk_render_node_init_types (void)
|
||||
{
|
||||
gboolean initialized = TRUE;
|
||||
gsk_render_node_init_types_once ();
|
||||
gsk_render_node_init_content_serializers ();
|
||||
g_once_init_leave (®ister_types__volatile, initialized);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,9 @@
|
||||
|
||||
/* for the drag icons */
|
||||
#include "gtkcolorswatchprivate.h"
|
||||
#include "gtkimage.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtkrendernodepaintableprivate.h"
|
||||
#include "gtktextutil.h"
|
||||
|
||||
|
||||
@ -555,6 +557,25 @@ gtk_drag_icon_create_widget_for_value (const GValue *value)
|
||||
|
||||
return picture;
|
||||
}
|
||||
else if (G_VALUE_HOLDS (value, GSK_TYPE_RENDER_NODE))
|
||||
{
|
||||
GskRenderNode *node;
|
||||
GdkPaintable *paintable;
|
||||
graphene_rect_t bounds;
|
||||
GtkWidget *image;
|
||||
|
||||
node = gsk_value_get_render_node (value);
|
||||
if (node == NULL)
|
||||
return NULL;
|
||||
|
||||
gsk_render_node_get_bounds (node, &bounds);
|
||||
paintable = gtk_render_node_paintable_new (node, &bounds);
|
||||
image = gtk_image_new_from_paintable (paintable);
|
||||
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
|
||||
g_object_unref (paintable);
|
||||
|
||||
return image;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
|
@ -461,6 +461,16 @@ gtk_font_button_activate (GtkFontButton *self)
|
||||
gtk_widget_activate (self->button);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_font_button_unrealize (GtkWidget *widget)
|
||||
{
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON (widget);
|
||||
|
||||
g_clear_pointer ((GtkWindow **) &font_button->font_dialog, gtk_window_destroy);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_font_button_parent_class)->unrealize (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_font_button_class_init (GtkFontButtonClass *klass)
|
||||
{
|
||||
@ -476,6 +486,7 @@ gtk_font_button_class_init (GtkFontButtonClass *klass)
|
||||
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_child;
|
||||
widget_class->focus = gtk_widget_focus_child;
|
||||
widget_class->unrealize = gtk_font_button_unrealize;
|
||||
|
||||
klass->font_set = NULL;
|
||||
klass->activate = gtk_font_button_activate;
|
||||
@ -628,9 +639,6 @@ gtk_font_button_finalize (GObject *object)
|
||||
{
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON (object);
|
||||
|
||||
if (font_button->font_dialog != NULL)
|
||||
gtk_window_destroy (GTK_WINDOW (font_button->font_dialog));
|
||||
|
||||
g_free (font_button->title);
|
||||
|
||||
clear_font_data (font_button);
|
||||
@ -968,6 +976,7 @@ gtk_font_button_clicked (GtkButton *button,
|
||||
font_button->font_dialog = gtk_font_chooser_dialog_new (font_button->title, NULL);
|
||||
gtk_window_set_hide_on_close (GTK_WINDOW (font_button->font_dialog), TRUE);
|
||||
gtk_window_set_modal (GTK_WINDOW (font_button->font_dialog), font_button->modal);
|
||||
gtk_window_set_display (GTK_WINDOW (font_button->font_dialog), gtk_widget_get_display (GTK_WIDGET (button)));
|
||||
|
||||
font_dialog = GTK_FONT_CHOOSER (font_button->font_dialog);
|
||||
|
||||
|
@ -20,31 +20,16 @@
|
||||
#include "gtkstylecontextprivate.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <gobject/gvaluecollector.h>
|
||||
|
||||
#include "gtkcsscolorvalueprivate.h"
|
||||
#include "gtkcssenumvalueprivate.h"
|
||||
#include "gtkcssimagevalueprivate.h"
|
||||
#include "gtkcssnodedeclarationprivate.h"
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtkcsscolorvalueprivate.h"
|
||||
#include "gtkcsscolorvalueprivate.h"
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtkcsstransientnodeprivate.h"
|
||||
#include "gtkcsswidgetnodeprivate.h"
|
||||
#include "gtkdebug.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkrenderbackgroundprivate.h"
|
||||
#include "gtkrendericonprivate.h"
|
||||
#include "gtksettings.h"
|
||||
#include "gtksettingsprivate.h"
|
||||
#include "gtkstylecascadeprivate.h"
|
||||
#include "gtkstyleproviderprivate.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtksnapshot.h"
|
||||
|
||||
|
||||
/**
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include <gtk/gtkbinlayout.h>
|
||||
#include <gtk/gtkbox.h>
|
||||
#include <gtk/gtkdragsource.h>
|
||||
#include <gtk/gtkeventcontroller.h>
|
||||
#include <gtk/gtkfilechooserdialog.h>
|
||||
#include <gtk/gtksignallistitemfactory.h>
|
||||
#include <gtk/gtklabel.h>
|
||||
@ -344,15 +346,39 @@ node_name (GskRenderNode *node)
|
||||
}
|
||||
}
|
||||
|
||||
static GdkContentProvider *
|
||||
prepare_render_node_drag (GtkDragSource *source,
|
||||
double x,
|
||||
double y,
|
||||
GtkListItem *list_item)
|
||||
{
|
||||
GtkTreeListRow *row_item;
|
||||
GdkPaintable *paintable;
|
||||
GskRenderNode *node;
|
||||
|
||||
row_item = gtk_list_item_get_item (list_item);
|
||||
if (row_item == NULL)
|
||||
return NULL;
|
||||
|
||||
paintable = gtk_tree_list_row_get_item (row_item);
|
||||
node = gtk_render_node_paintable_get_render_node (GTK_RENDER_NODE_PAINTABLE (paintable));
|
||||
|
||||
return gdk_content_provider_new_typed (GSK_TYPE_RENDER_NODE, node);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_widget_for_render_node (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *list_item)
|
||||
{
|
||||
GtkWidget *expander, *box, *child;
|
||||
GtkDragSource *source;
|
||||
|
||||
/* expander */
|
||||
expander = gtk_tree_expander_new ();
|
||||
gtk_list_item_set_child (list_item, expander);
|
||||
source = gtk_drag_source_new ();
|
||||
g_signal_connect (source, "prepare", G_CALLBACK (prepare_render_node_drag), list_item);
|
||||
gtk_widget_add_controller (expander, GTK_EVENT_CONTROLLER (source));
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
|
||||
gtk_tree_expander_set_child (GTK_TREE_EXPANDER (expander), box);
|
||||
|
Loading…
Reference in New Issue
Block a user