Compare commits
149 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b1038c5d19 | |||
| b16b44f1ae | |||
| 37c151ce0f | |||
| eb7ad4bbad | |||
| cdec487998 | |||
| 80d3c68615 | |||
| ed4b3f8033 | |||
| 451e7a5ad2 | |||
| 89360b26af | |||
| d3d4fe14c2 | |||
| 040175cd92 | |||
| 64b0c63190 | |||
| 8ff540eb4c | |||
| 9194b7388f | |||
| 6831d3e28e | |||
| 800f1c03d5 | |||
| 7a0355fcb1 | |||
| 15d58a868a | |||
| 61f21fc9e9 | |||
| 9e068d3a46 | |||
| 2aa136a19c | |||
| 1dfd514f7f | |||
| 08fbd012ec | |||
| 638508fa20 | |||
| ce6c7bae51 | |||
| 19f7b7ed40 | |||
| e3dba28666 | |||
| 88aa548965 | |||
| 17a9b13af2 | |||
| 1efa781a19 | |||
| 0a19d7ef08 | |||
| 926fb208ba | |||
| e76dee07c5 | |||
| 11a43cf554 | |||
| a7218da202 | |||
| ed362fcc5b | |||
| 17ec74da35 | |||
| 754d6d1a04 | |||
| ff53d5ba11 | |||
| 7233a70d47 | |||
| 12990b3520 | |||
| 95d807ab61 | |||
| 8a1a96a47e | |||
| c31916081f | |||
| 0a1e19f4e3 | |||
| 7d3f3b7ab8 | |||
| 432b741ab7 | |||
| 703f18ce66 | |||
| 4da82bde7b | |||
| feee281cf8 | |||
| 443fd4d63d | |||
| 4b346538e2 | |||
| 0ee58e9ef4 | |||
| bd56bc9055 | |||
| 3e7e862415 | |||
| 4eeb413047 | |||
| 661f3466c2 | |||
| e735554ced | |||
| 520ea7c39d | |||
| ffa345e4ab | |||
| e072d9b28b | |||
| 9f5b04e65c | |||
| d08310096c | |||
| 20d0d6fae2 | |||
| 6b9ac1043b | |||
| c5b4066714 | |||
| b09b2dd2cd | |||
| 72a0828101 | |||
| 7379c34a39 | |||
| 6cd1b9955b | |||
| a6a31827bc | |||
| 84939a612c | |||
| 394ea32e93 | |||
| 2bd36d490b | |||
| ad1bc75dd2 | |||
| 7505c1fd7c | |||
| 8780906b93 | |||
| 0ed2e970be | |||
| 58253d567f | |||
| c09c61769c | |||
| 9b5dc35650 | |||
| 3c9ada14fe | |||
| 6b4d6c3771 | |||
| b15f16e8db | |||
| e3b9dfef1c | |||
| 822c2aba36 | |||
| a11f9fea76 | |||
| f16c829190 | |||
| 16c820c2f0 | |||
| 72ae6daa1e | |||
| 35ba24d2e8 | |||
| 508cb6160c | |||
| b9a76ddd75 | |||
| 038190c5a8 | |||
| 2ae08e632c | |||
| 99eed078bd | |||
| 6720552afd | |||
| 6f01508aa8 | |||
| 632524f679 | |||
| 22e1827f84 | |||
| 3c39613d9c | |||
| 46ff9f891a | |||
| 97ff1b83dc | |||
| 9416856420 | |||
| c1459cc45b | |||
| 4fe8c037c7 | |||
| b1afe5ff23 | |||
| bbd4fb8798 | |||
| b3b29e37fd | |||
| f996ba6585 | |||
| 7ca36cd2d4 | |||
| 2a18f2150d | |||
| a65fd81106 | |||
| ff8217db40 | |||
| a3861bf9a0 | |||
| b86c1446a4 | |||
| 9ce58bdb0c | |||
| 9f252f0ceb | |||
| 7008a531bb | |||
| 458b8a6554 | |||
| 307cc69adb | |||
| ab6b5ae568 | |||
| 0e601c0a70 | |||
| 5425edff82 | |||
| 213c471bb7 | |||
| 9ae0fe7f3a | |||
| abe6876f7c | |||
| 53d74fd2dc | |||
| 3f0a830f3c | |||
| e0323fcdc2 | |||
| cd5cded430 | |||
| 54e4e6cd23 | |||
| 59852d3425 | |||
| d701a89281 | |||
| 5e095cd208 | |||
| d2bdf3d5a1 | |||
| e692385baa | |||
| 1e8df851e9 | |||
| 904db0a8f7 | |||
| 6b7cc8baa6 | |||
| 71fe843d99 | |||
| 552a681816 | |||
| 2f0016eb08 | |||
| f87291cac2 | |||
| 37c3ba2645 | |||
| ba05787a06 | |||
| 12b97ffd24 | |||
| 1ae60cb713 | |||
| 3371e3aa49 |
+5
-5
@@ -27,14 +27,14 @@ variables:
|
||||
|
||||
style-check-diff:
|
||||
extends: .only-default
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v15
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
|
||||
stage: .pre
|
||||
allow_failure: true
|
||||
script:
|
||||
- .gitlab-ci/run-style-check-diff.sh
|
||||
|
||||
fedora-x86_64:
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v15
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
|
||||
stage: build
|
||||
variables:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=debug --default-library=both"
|
||||
@@ -66,7 +66,7 @@ fedora-x86_64:
|
||||
<<: *cache-paths
|
||||
|
||||
release-build:
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v15
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
|
||||
stage: build
|
||||
variables:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=release"
|
||||
@@ -168,7 +168,7 @@ flatpak-master:icon-browser:
|
||||
<<: *flatpak-master
|
||||
|
||||
static-scan:
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v15
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
|
||||
stage: analysis
|
||||
variables:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=debug"
|
||||
@@ -181,7 +181,7 @@ static-scan:
|
||||
allow_failure: true
|
||||
|
||||
reference:
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v15
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
|
||||
stage: docs
|
||||
variables:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=release"
|
||||
|
||||
@@ -82,7 +82,7 @@ RUN dnf -y install \
|
||||
xorg-x11-server-Xvfb \
|
||||
&& dnf clean all
|
||||
|
||||
RUN pip3 install meson==0.52.1
|
||||
RUN pip3 install meson==0.53.1
|
||||
|
||||
ARG HOST_USER_ID=5555
|
||||
ENV HOST_USER_ID ${HOST_USER_ID}
|
||||
|
||||
@@ -174,7 +174,7 @@ ul.images li {
|
||||
<div class="failures">
|
||||
<h4><a name="{{ suite_result.suite_name }}-failed">Failures</a></h4>
|
||||
<ul class="failed">
|
||||
{% for failure in suite_result.failures if failure.result in [ 'FAIL', 'UNEXPECTEDPASS' ] %}
|
||||
{% for failure in suite_result.failures if failure.result in [ 'ERROR', 'FAIL', 'UNEXPECTEDPASS' ] %}
|
||||
<li><a name="{{ failure.name }}">{{ failure.name }}</a> - result: <span class="result fail">{{ failure.result }}</span><br/>
|
||||
{% if failure.stdout %}
|
||||
Output: <pre>{{ failure.stdout }}</pre>
|
||||
@@ -207,24 +207,6 @@ ul.images li {
|
||||
</div>
|
||||
|
||||
<div class="successes">
|
||||
<h4><a name="{{ suite_result.suite_name }}-skipped">Skipped</a></h4>
|
||||
<ul>
|
||||
{% for success in suite_result.successes if success.result == 'SKIP' %}
|
||||
<li>{{ success.name }} - result: <span class="result skip">{{ success.result }}</li>
|
||||
{% else %}
|
||||
<li>None</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h4><a name="{{ suite_result.suite_name }}-passed">Passed</a></h4>
|
||||
<ul class="passed">
|
||||
{% for success in suite_result.successes if success.result == 'OK' %}
|
||||
<li>{{ success.name }} - result: <span class="result pass">{{ success.result }}</li>
|
||||
{% else %}
|
||||
<li>None</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h4><a name="{{ suite_result.suite_name }}-expected-fail">Expected failures</a></h4>
|
||||
<ul>
|
||||
{% for success in suite_result.successes if success.result == 'EXPECTEDFAIL' %}
|
||||
@@ -244,6 +226,24 @@ ul.images li {
|
||||
<li>None</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h4><a name="{{ suite_result.suite_name }}-skipped">Skipped</a></h4>
|
||||
<ul>
|
||||
{% for success in suite_result.successes if success.result == 'SKIP' %}
|
||||
<li>{{ success.name }} - result: <span class="result skip">{{ success.result }}</li>
|
||||
{% else %}
|
||||
<li>None</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h4><a name="{{ suite_result.suite_name }}-passed">Passed</a></h4>
|
||||
<ul class="passed">
|
||||
{% for success in suite_result.successes if success.result == 'OK' %}
|
||||
<li>{{ success.name }} - result: <span class="result pass">{{ success.result }}</li>
|
||||
{% else %}
|
||||
<li>None</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -331,7 +331,7 @@ for name, units in suites.items():
|
||||
print('Processing {} suite {}:'.format(project_name, suite_name))
|
||||
|
||||
def if_failed(unit):
|
||||
if unit['result'] in ['FAIL', 'UNEXPECTEDPASS', 'TIMEOUT']:
|
||||
if unit['result'] in ['FAIL', 'UNEXPECTEDPASS', 'TIMEOUT', 'ERROR',]:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ for name, units in suites.items():
|
||||
print('Processing suite {} (units: {})'.format(name, len(units)))
|
||||
|
||||
def if_failed(unit):
|
||||
if unit['result'] in ['FAIL', 'UNEXPECTEDPASS', 'TIMEOUT']:
|
||||
if unit['result'] in ['ERROR', 'FAIL', 'UNEXPECTEDPASS', 'TIMEOUT']:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ constraint_view_add_child (ConstraintView *view,
|
||||
|
||||
label = gtk_label_new (name);
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (frame), "child");
|
||||
gtk_widget_add_css_class (frame, "child");
|
||||
gtk_widget_set_name (frame, name);
|
||||
gtk_container_add (GTK_CONTAINER (frame), label);
|
||||
gtk_widget_set_parent (frame, GTK_WIDGET (view));
|
||||
@@ -257,7 +257,7 @@ constraint_view_add_guide (ConstraintView *view,
|
||||
G_BINDING_DEFAULT);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (frame), "guide");
|
||||
gtk_widget_add_css_class (frame, "guide");
|
||||
g_object_set_data (G_OBJECT (frame), "internal", (char *)"yes");
|
||||
gtk_container_add (GTK_CONTAINER (frame), label);
|
||||
gtk_widget_insert_after (frame, GTK_WIDGET (view), NULL);
|
||||
|
||||
@@ -131,13 +131,11 @@ blur_overlay_child_update_style_classes (BlurOverlay *overlay,
|
||||
GtkAlign valign, halign;
|
||||
gboolean is_left, is_right, is_top, is_bottom;
|
||||
gboolean has_left, has_right, has_top, has_bottom;
|
||||
GtkStyleContext *context;
|
||||
|
||||
context = gtk_widget_get_style_context (child);
|
||||
has_left = gtk_style_context_has_class (context, GTK_STYLE_CLASS_LEFT);
|
||||
has_right = gtk_style_context_has_class (context, GTK_STYLE_CLASS_RIGHT);
|
||||
has_top = gtk_style_context_has_class (context, GTK_STYLE_CLASS_TOP);
|
||||
has_bottom = gtk_style_context_has_class (context, GTK_STYLE_CLASS_BOTTOM);
|
||||
has_left = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_LEFT);
|
||||
has_right = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_RIGHT);
|
||||
has_top = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_TOP);
|
||||
has_bottom = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_BOTTOM);
|
||||
|
||||
is_left = is_right = is_top = is_bottom = FALSE;
|
||||
|
||||
@@ -160,24 +158,24 @@ blur_overlay_child_update_style_classes (BlurOverlay *overlay,
|
||||
is_bottom = (child_allocation->y + child_allocation->height == height);
|
||||
|
||||
if (has_left && !is_left)
|
||||
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_LEFT);
|
||||
gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_LEFT);
|
||||
else if (!has_left && is_left)
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT);
|
||||
gtk_widget_add_css_class (child, GTK_STYLE_CLASS_LEFT);
|
||||
|
||||
if (has_right && !is_right)
|
||||
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_RIGHT);
|
||||
gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_RIGHT);
|
||||
else if (!has_right && is_right)
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT);
|
||||
gtk_widget_add_css_class (child, GTK_STYLE_CLASS_RIGHT);
|
||||
|
||||
if (has_top && !is_top)
|
||||
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP);
|
||||
gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_TOP);
|
||||
else if (!has_top && is_top)
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
|
||||
gtk_widget_add_css_class (child, GTK_STYLE_CLASS_TOP);
|
||||
|
||||
if (has_bottom && !is_bottom)
|
||||
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM);
|
||||
gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_BOTTOM);
|
||||
else if (!has_bottom && is_bottom)
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
|
||||
gtk_widget_add_css_class (child, GTK_STYLE_CLASS_BOTTOM);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -104,6 +104,10 @@
|
||||
<file>gtkfishbowl.c</file>
|
||||
<file>gtkfishbowl.h</file>
|
||||
</gresource>
|
||||
<gresource prefix="/gears">
|
||||
<file>gtkgears.c</file>
|
||||
<file>gtkgears.h</file>
|
||||
</gresource>
|
||||
<gresource prefix="/iconscroll">
|
||||
<file>iconscroll.ui</file>
|
||||
</gresource>
|
||||
@@ -176,6 +180,7 @@
|
||||
<file>font_features.c</file>
|
||||
<file>fontplane.c</file>
|
||||
<file>fontrendering.c</file>
|
||||
<file>gears.c</file>
|
||||
<file>gestures.c</file>
|
||||
<file>glarea.c</file>
|
||||
<file>headerbar.c</file>
|
||||
|
||||
@@ -81,7 +81,7 @@ deserialize_widget (GtkDemoWidget *demo)
|
||||
else if (demo->type == GTK_TYPE_SPINNER)
|
||||
{
|
||||
widget = g_object_new (demo->type, "spinning", demo->active, NULL);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (widget), "demo");
|
||||
gtk_widget_add_css_class (widget, "demo");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -114,7 +114,7 @@ new_spinner_cb (GtkWidget *button,
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = gtk_spinner_new ();
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (widget), "demo");
|
||||
gtk_widget_add_css_class (widget, "demo");
|
||||
gtk_spinner_start (GTK_SPINNER (widget));
|
||||
gtk_fixed_put (fixed, widget, pos_x, pos_y);
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ create_blurred_button (void)
|
||||
{
|
||||
GtkWidget *w = gtk_button_new ();
|
||||
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (w), "blurred-button");
|
||||
gtk_widget_add_css_class (w, "blurred-button");
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ create_faces (void)
|
||||
/* Add a face */
|
||||
faces[i].face = gtk_frame_new (NULL);
|
||||
gtk_widget_set_size_request (faces[i].face, face_size, face_size);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (faces[i].face), faces[i].css_class);
|
||||
gtk_widget_add_css_class (faces[i].face, faces[i].css_class);
|
||||
gtk_container_add (GTK_CONTAINER (fixed), faces[i].face);
|
||||
|
||||
/* Set up the transformation for each face */
|
||||
|
||||
@@ -189,8 +189,6 @@ gtk_font_plane_init (GtkFontPlane *plane)
|
||||
{
|
||||
GtkGesture *gesture;
|
||||
|
||||
gtk_widget_set_can_focus (GTK_WIDGET (plane), TRUE);
|
||||
|
||||
gesture = gtk_gesture_drag_new ();
|
||||
g_signal_connect (gesture, "drag-begin",
|
||||
G_CALLBACK (plane_drag_gesture_begin), plane);
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/* OpenGL/Gears
|
||||
*
|
||||
* This is a classic OpenGL demo, running in a GtkGLArea.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gtkgears.h"
|
||||
|
||||
/************************************************************************
|
||||
* DEMO CODE *
|
||||
************************************************************************/
|
||||
|
||||
static void
|
||||
on_axis_value_change (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
{
|
||||
GtkGears *gears = GTK_GEARS (data);
|
||||
int axis = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (adjustment), "axis"));
|
||||
|
||||
gtk_gears_set_axis (gears, axis, gtk_adjustment_get_value (adjustment));
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget *
|
||||
create_axis_slider (GtkGears *gears,
|
||||
int axis)
|
||||
{
|
||||
GtkWidget *box, *label, *slider;
|
||||
GtkAdjustment *adj;
|
||||
const char *text;
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE);
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case GTK_GEARS_X_AXIS:
|
||||
text = "X";
|
||||
break;
|
||||
|
||||
case GTK_GEARS_Y_AXIS:
|
||||
text = "Y";
|
||||
break;
|
||||
|
||||
case GTK_GEARS_Z_AXIS:
|
||||
text = "Z";
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
label = gtk_label_new (text);
|
||||
gtk_container_add (GTK_CONTAINER (box), label);
|
||||
gtk_widget_show (label);
|
||||
|
||||
adj = gtk_adjustment_new (gtk_gears_get_axis (gears, axis), 0.0, 360.0, 1.0, 12.0, 0.0);
|
||||
g_object_set_data (G_OBJECT (adj), "axis", GINT_TO_POINTER (axis));
|
||||
g_signal_connect (adj, "value-changed",
|
||||
G_CALLBACK (on_axis_value_change),
|
||||
gears);
|
||||
slider = gtk_scale_new (GTK_ORIENTATION_VERTICAL, adj);
|
||||
gtk_scale_set_draw_value (GTK_SCALE (slider), FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (box), slider);
|
||||
gtk_widget_set_vexpand (slider, TRUE);
|
||||
gtk_widget_show (slider);
|
||||
|
||||
gtk_widget_show (box);
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_gears (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *box, *hbox, *fps_label, *gears, *overlay, *frame;
|
||||
int i;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Gears");
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 640, 640);
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
||||
overlay = gtk_overlay_new ();
|
||||
gtk_widget_set_margin_start (overlay, 12);
|
||||
gtk_widget_set_margin_end (overlay, 12);
|
||||
gtk_widget_set_margin_top (overlay, 12);
|
||||
gtk_widget_set_margin_bottom (overlay, 12);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), overlay);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_widget_set_halign (frame, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (frame, GTK_ALIGN_START);
|
||||
gtk_widget_add_css_class (frame, "app-notification");
|
||||
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), frame);
|
||||
|
||||
fps_label = gtk_label_new ("");
|
||||
gtk_widget_set_halign (fps_label, GTK_ALIGN_START);
|
||||
gtk_container_add (GTK_CONTAINER (frame), fps_label);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE);
|
||||
gtk_box_set_spacing (GTK_BOX (box), 6);
|
||||
gtk_container_add (GTK_CONTAINER (overlay), box);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE);
|
||||
gtk_box_set_spacing (GTK_BOX (box), 6);
|
||||
gtk_container_add (GTK_CONTAINER (box), hbox);
|
||||
|
||||
gears = gtk_gears_new ();
|
||||
gtk_widget_set_hexpand (gears, TRUE);
|
||||
gtk_widget_set_vexpand (gears, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (hbox), gears);
|
||||
|
||||
for (i = 0; i < GTK_GEARS_N_AXIS; i++)
|
||||
gtk_container_add (GTK_CONTAINER (hbox), create_axis_slider (GTK_GEARS (gears), i));
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE);
|
||||
gtk_box_set_spacing (GTK_BOX (hbox), 6);
|
||||
gtk_container_add (GTK_CONTAINER (box), hbox);
|
||||
|
||||
gtk_gears_set_fps_label (GTK_GEARS (gears), GTK_LABEL (fps_label));
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
|
||||
return window;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/* OpenGL Area
|
||||
/* OpenGL/OpenGL Area
|
||||
*
|
||||
* GtkGLArea is a widget that allows custom drawing using OpenGL calls.
|
||||
*/
|
||||
|
||||
@@ -42,7 +42,7 @@ do_headerbar (GtkWidget *do_widget)
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (box), "linked");
|
||||
gtk_widget_add_css_class (box, "linked");
|
||||
button = gtk_button_new ();
|
||||
gtk_container_add (GTK_CONTAINER (button), gtk_image_new_from_icon_name ("pan-start-symbolic"));
|
||||
gtk_container_add (GTK_CONTAINER (box), button);
|
||||
|
||||
@@ -28,6 +28,7 @@ demos = files([
|
||||
'fishbowl.c',
|
||||
'fixed.c',
|
||||
'fontrendering.c',
|
||||
'gears.c',
|
||||
'gestures.c',
|
||||
'glarea.c',
|
||||
'headerbar.c',
|
||||
|
||||
@@ -74,7 +74,7 @@ do_password_entry (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (box), entry2);
|
||||
|
||||
button = gtk_button_new_with_mnemonic ("_Done");
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (button), "suggested-action");
|
||||
gtk_widget_add_css_class (button, "suggested-action");
|
||||
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
|
||||
gtk_widget_set_sensitive (button, FALSE);
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
|
||||
|
||||
@@ -190,8 +190,7 @@ do_rotated_text (GtkWidget *do_widget)
|
||||
/* Add a drawing area */
|
||||
drawing_area = gtk_drawing_area_new ();
|
||||
gtk_container_add (GTK_CONTAINER (box), drawing_area);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (drawing_area),
|
||||
GTK_STYLE_CLASS_VIEW);
|
||||
gtk_widget_add_css_class (drawing_area, GTK_STYLE_CLASS_VIEW);
|
||||
|
||||
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area),
|
||||
rotated_text_draw,
|
||||
|
||||
@@ -63,7 +63,7 @@ do_sidebar (GtkWidget *do_widget)
|
||||
if (i == 0)
|
||||
{
|
||||
widget = gtk_image_new_from_icon_name ("org.gtk.Demo4");
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (widget), "icon-dropshadow");
|
||||
gtk_widget_add_css_class (widget, "icon-dropshadow");
|
||||
gtk_image_set_pixel_size (GTK_IMAGE (widget), 256);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -419,7 +419,7 @@ do_sliding_puzzle (GtkWidget *do_widget)
|
||||
gtk_widget_set_margin_bottom (tweaks, 10);
|
||||
|
||||
choices = gtk_flow_box_new ();
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (choices), GTK_STYLE_CLASS_VIEW);
|
||||
gtk_widget_add_css_class (choices, GTK_STYLE_CLASS_VIEW);
|
||||
add_choice (choices, puzzle);
|
||||
add_choice (choices, gtk_nuclear_animation_new ());
|
||||
media = gtk_media_file_new_for_resource ("/images/gtk-logo.webm");
|
||||
|
||||
@@ -25,7 +25,7 @@ add_tag (GtkButton *button, DemoTaggedEntry *entry)
|
||||
DemoTaggedEntryTag *tag;
|
||||
|
||||
tag = demo_tagged_entry_tag_new ("Blue");
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (tag)), "blue");
|
||||
gtk_widget_add_css_class (GTK_WIDGET (tag), "blue");
|
||||
demo_tagged_entry_tag_set_has_close_button (tag, TRUE);
|
||||
g_signal_connect (tag, "button-clicked", G_CALLBACK (closed_cb), entry);
|
||||
|
||||
@@ -98,7 +98,7 @@ do_tagged_entry (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (box2), button);
|
||||
|
||||
button = gtk_button_new_with_mnemonic ("_Done");
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (button), "suggested-action");
|
||||
gtk_widget_add_css_class (button, "suggested-action");
|
||||
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
|
||||
|
||||
|
||||
@@ -25,23 +25,46 @@
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static char *current_theme;
|
||||
|
||||
static void
|
||||
change_dark_state (GSimpleAction *action,
|
||||
GVariant *state,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkSettings *settings = gtk_settings_get_default ();
|
||||
gboolean prefer_dark = g_variant_get_boolean (state);
|
||||
char *theme;
|
||||
const char *new_theme = NULL;
|
||||
|
||||
g_object_set (G_OBJECT (settings),
|
||||
"gtk-application-prefer-dark-theme",
|
||||
g_variant_get_boolean (state),
|
||||
g_object_get (G_OBJECT (settings),
|
||||
"gtk-theme-name", &theme,
|
||||
NULL);
|
||||
|
||||
g_simple_action_set_state (action, state);
|
||||
}
|
||||
if (prefer_dark)
|
||||
{
|
||||
if (strcmp (theme, "Adwaita") == 0)
|
||||
new_theme = "Adwaita-dark";
|
||||
else if (strcmp (theme, "HighContrastInverse") == 0)
|
||||
new_theme = "HighContrast";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strcmp (theme, "Adwaita-dark") == 0)
|
||||
new_theme = "Adwaita";
|
||||
else if (strcmp (theme, "HighContrast") == 0)
|
||||
new_theme = "HighContrastInverse";
|
||||
}
|
||||
|
||||
static char *current_theme;
|
||||
static gboolean current_dark;
|
||||
if (new_theme)
|
||||
g_object_set (G_OBJECT (settings),
|
||||
"gtk-theme-name", new_theme,
|
||||
NULL);
|
||||
|
||||
g_simple_action_set_state (action, state);
|
||||
|
||||
g_free (theme);
|
||||
}
|
||||
|
||||
static void
|
||||
change_theme_state (GSimpleAction *action,
|
||||
@@ -51,41 +74,34 @@ change_theme_state (GSimpleAction *action,
|
||||
GtkSettings *settings = gtk_settings_get_default ();
|
||||
const char *s;
|
||||
const char *theme;
|
||||
gboolean prefer_dark = FALSE;
|
||||
|
||||
s = g_variant_get_string (state, NULL);
|
||||
|
||||
if (strcmp (s, "adwaita") == 0)
|
||||
{
|
||||
theme = "Adwaita";
|
||||
prefer_dark = FALSE;
|
||||
}
|
||||
else if (strcmp (s, "adwaita-dark") == 0)
|
||||
{
|
||||
theme = "Adwaita";
|
||||
prefer_dark = TRUE;
|
||||
theme = "Adwaita-dark";
|
||||
}
|
||||
else if (strcmp (s, "highcontrast") == 0)
|
||||
{
|
||||
theme = "HighContrast";
|
||||
prefer_dark = FALSE;
|
||||
}
|
||||
else if (strcmp (s, "highcontrast-inverse") == 0)
|
||||
{
|
||||
theme = "HighContrastInverse";
|
||||
prefer_dark = FALSE;
|
||||
}
|
||||
else if (strcmp (s, "current") == 0)
|
||||
{
|
||||
theme = current_theme;
|
||||
prefer_dark = current_dark;
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
g_object_set (G_OBJECT (settings),
|
||||
"gtk-theme-name", theme,
|
||||
"gtk-application-prefer-dark-theme", prefer_dark,
|
||||
NULL);
|
||||
|
||||
g_simple_action_set_state (action, state);
|
||||
@@ -442,24 +458,17 @@ on_entry_icon_release (GtkEntry *entry,
|
||||
|
||||
#define EPSILON (1e-10)
|
||||
|
||||
static gboolean
|
||||
on_scale_button_query_tooltip (GtkWidget *button,
|
||||
gint x,
|
||||
gint y,
|
||||
gboolean keyboard_mode,
|
||||
GtkTooltip *tooltip,
|
||||
gpointer user_data)
|
||||
static void
|
||||
on_scale_button_value_changed (GtkScaleButton *button,
|
||||
gdouble value,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkScaleButton *scale_button = GTK_SCALE_BUTTON (button);
|
||||
GtkAdjustment *adjustment;
|
||||
gdouble val;
|
||||
gchar *str;
|
||||
AtkImage *image;
|
||||
|
||||
image = ATK_IMAGE (gtk_widget_get_accessible (button));
|
||||
|
||||
adjustment = gtk_scale_button_get_adjustment (scale_button);
|
||||
val = gtk_scale_button_get_value (scale_button);
|
||||
adjustment = gtk_scale_button_get_adjustment (button);
|
||||
val = gtk_scale_button_get_value (button);
|
||||
|
||||
if (val < (gtk_adjustment_get_lower (adjustment) + EPSILON))
|
||||
{
|
||||
@@ -478,32 +487,21 @@ on_scale_button_query_tooltip (GtkWidget *button,
|
||||
str = g_strdup_printf (C_("volume percentage", "%d %%"), percent);
|
||||
}
|
||||
|
||||
gtk_tooltip_set_text (tooltip, str);
|
||||
atk_image_set_image_description (image, str);
|
||||
gtk_widget_set_tooltip_text (GTK_WIDGET (button), str);
|
||||
atk_object_set_description (gtk_widget_get_accessible (GTK_WIDGET (button)), str);
|
||||
|
||||
g_free (str);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
on_scale_button_value_changed (GtkScaleButton *button,
|
||||
gdouble value,
|
||||
gpointer user_data)
|
||||
{
|
||||
gtk_widget_trigger_tooltip_query (GTK_WIDGET (button));
|
||||
}
|
||||
|
||||
static void
|
||||
on_record_button_toggled (GtkToggleButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
|
||||
context = gtk_widget_get_style_context (GTK_WIDGET (button));
|
||||
if (gtk_toggle_button_get_active (button))
|
||||
gtk_style_context_remove_class (context, "destructive-action");
|
||||
gtk_widget_remove_css_class (GTK_WIDGET (button), "destructive-action");
|
||||
else
|
||||
gtk_style_context_add_class (context, "destructive-action");
|
||||
gtk_widget_add_css_class (GTK_WIDGET (button), "destructive-action");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1757,7 +1755,6 @@ activate (GApplication *app)
|
||||
|
||||
g_object_get (gtk_settings_get_default (),
|
||||
"gtk-theme-name", ¤t_theme,
|
||||
"gtk-application-prefer-dark-theme", ¤t_dark,
|
||||
NULL);
|
||||
|
||||
g_type_ensure (my_text_view_get_type ());
|
||||
@@ -1774,7 +1771,6 @@ activate (GApplication *app)
|
||||
gtk_builder_cscope_add_callback_symbols (GTK_BUILDER_CSCOPE (scope),
|
||||
"on_entry_icon_release", (GCallback)on_entry_icon_release,
|
||||
"on_scale_button_value_changed", (GCallback)on_scale_button_value_changed,
|
||||
"on_scale_button_query_tooltip", (GCallback)on_scale_button_query_tooltip,
|
||||
"on_record_button_toggled", (GCallback)on_record_button_toggled,
|
||||
"on_page_combo_changed", (GCallback)on_page_combo_changed,
|
||||
"on_range_from_changed", (GCallback)on_range_from_changed,
|
||||
|
||||
@@ -1510,7 +1510,6 @@ microphone-sensitivity-medium-symbolic</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="value">.5</property>
|
||||
<property name="halign">center</property>
|
||||
<signal name="query-tooltip" handler="on_scale_button_query_tooltip" swapped="no"/>
|
||||
<signal name="value-changed" handler="on_scale_button_value_changed" swapped="no"/>
|
||||
<layout>
|
||||
<property name="left-attach">0</property>
|
||||
|
||||
@@ -515,6 +515,9 @@ gdk_key_event_get_consumed_modifiers
|
||||
gdk_key_event_get_layout
|
||||
gdk_key_event_get_level
|
||||
gdk_key_event_is_modifier
|
||||
GdkEventMatch
|
||||
gdk_key_event_matches
|
||||
gdk_key_event_get_match
|
||||
gdk_focus_event_get_in
|
||||
gdk_touch_event_get_emulating_pointer
|
||||
gdk_crossing_event_get_mode
|
||||
@@ -537,11 +540,6 @@ gdk_events_get_angle
|
||||
gdk_events_get_center
|
||||
gdk_events_get_distance
|
||||
|
||||
<SUBSECTION>
|
||||
GdkEventMatch
|
||||
gdk_event_matches
|
||||
gdk_event_get_match
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GDK_TYPE_EVENT
|
||||
GDK_TYPE_EVENT_MASK
|
||||
@@ -657,8 +655,6 @@ gdk_toplevel_set_transient_for
|
||||
gdk_toplevel_set_modal
|
||||
gdk_toplevel_set_icon_list
|
||||
gdk_toplevel_show_window_menu
|
||||
gdk_toplevel_set_accept_focus
|
||||
gdk_toplevel_set_focus_on_map
|
||||
gdk_toplevel_set_decorated
|
||||
gdk_toplevel_set_deletable
|
||||
gdk_toplevel_supports_edge_constraints
|
||||
|
||||
@@ -599,6 +599,8 @@ gtk_color_button_new
|
||||
gtk_color_button_new_with_rgba
|
||||
gtk_color_button_set_title
|
||||
gtk_color_button_get_title
|
||||
gtk_color_button_set_modal
|
||||
gtk_color_button_get_modal
|
||||
<SUBSECTION Standard>
|
||||
GTK_COLOR_BUTTON
|
||||
GTK_IS_COLOR_BUTTON
|
||||
@@ -1155,6 +1157,8 @@ gtk_file_chooser_button_get_title
|
||||
gtk_file_chooser_button_set_title
|
||||
gtk_file_chooser_button_get_width_chars
|
||||
gtk_file_chooser_button_set_width_chars
|
||||
gtk_file_chooser_button_get_modal
|
||||
gtk_file_chooser_button_set_modal
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_FILE_CHOOSER_BUTTON
|
||||
@@ -1269,6 +1273,8 @@ gtk_font_button_set_use_size
|
||||
gtk_font_button_get_use_size
|
||||
gtk_font_button_set_title
|
||||
gtk_font_button_get_title
|
||||
gtk_font_button_set_modal
|
||||
gtk_font_button_get_modal
|
||||
<SUBSECTION Standard>
|
||||
GTK_FONT_BUTTON
|
||||
GTK_IS_FONT_BUTTON
|
||||
@@ -2298,6 +2304,12 @@ GtkSettingsValue
|
||||
gtk_settings_get_default
|
||||
gtk_settings_get_for_display
|
||||
gtk_settings_reset_property
|
||||
|
||||
<SUBSECTION>
|
||||
gtk_theme_get_dark_variant
|
||||
gtk_theme_get_light_variant
|
||||
gtk_theme_get_available_themes
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GtkSettingsClass
|
||||
GTK_IS_SETTINGS
|
||||
@@ -4287,12 +4299,6 @@ gtk_init_check
|
||||
<SUBSECTION>
|
||||
GTK_PRIORITY_RESIZE
|
||||
|
||||
<SUBSECTION>
|
||||
gtk_get_current_event
|
||||
gtk_get_current_event_time
|
||||
gtk_get_current_event_state
|
||||
gtk_get_current_event_device
|
||||
|
||||
<SUBSECTION Private>
|
||||
gtk_init_abi_check
|
||||
gtk_init_check_abi_check
|
||||
@@ -4437,7 +4443,6 @@ gtk_style_context_get_margin
|
||||
gtk_style_context_lookup_color
|
||||
gtk_style_context_remove_provider
|
||||
gtk_style_context_remove_provider_for_display
|
||||
gtk_style_context_reset_widgets
|
||||
gtk_style_context_restore
|
||||
gtk_style_context_save
|
||||
gtk_style_context_add_class
|
||||
@@ -5112,7 +5117,9 @@ gtk_mount_operation_set_parent
|
||||
gtk_mount_operation_get_parent
|
||||
gtk_mount_operation_set_display
|
||||
gtk_mount_operation_get_display
|
||||
gtk_show_uri_on_window
|
||||
gtk_show_uri_full
|
||||
gtk_show_uri_full_finish
|
||||
gtk_show_uri
|
||||
<SUBSECTION Standard>
|
||||
GTK_IS_MOUNT_OPERATION
|
||||
GTK_IS_MOUNT_OPERATION_CLASS
|
||||
@@ -5342,6 +5349,8 @@ gtk_app_chooser_button_get_show_dialog_item
|
||||
gtk_app_chooser_button_set_show_dialog_item
|
||||
gtk_app_chooser_button_get_heading
|
||||
gtk_app_chooser_button_set_heading
|
||||
gtk_app_chooser_button_get_modal
|
||||
gtk_app_chooser_button_set_modal
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_APP_CHOOSER_BUTTON
|
||||
@@ -5816,6 +5825,12 @@ gtk_event_controller_set_propagation_limit
|
||||
gtk_event_controller_get_widget
|
||||
gtk_event_controller_reset
|
||||
|
||||
<SUBSECTION>
|
||||
gtk_event_controller_get_current_event
|
||||
gtk_event_controller_get_current_event_device
|
||||
gtk_event_controller_get_current_event_state
|
||||
gtk_event_controller_get_current_event_time
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_EVENT_CONTROLLER
|
||||
GTK_EVENT_CONTROLLER
|
||||
|
||||
@@ -339,6 +339,15 @@
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Stop using gtk_get_current_... APIs</title>
|
||||
<para>
|
||||
The function gtk_get_current_event() and its variants have been
|
||||
replaced by equivalent event controller APIs:
|
||||
gtk_event_controller_get_current_event(), etc.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Adapt to surface API changes</title>
|
||||
<para>
|
||||
@@ -470,6 +479,22 @@
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Focus handling changes</title>
|
||||
<para>
|
||||
The semantics of the #GtkWidget:can-focus property have changed.
|
||||
In GTK 3, this property only meant that the widget itself would not
|
||||
accept keyboard input, but its children still might (in the case of
|
||||
containers). In GTK 4, if :can-focus is %FALSE, the focus cannot enter
|
||||
the widget or any of its descendents, and the default value has changed
|
||||
from %FALSE to %TRUE.
|
||||
</para>
|
||||
<para>
|
||||
The recommended way to influence focus behavior of custom widgets
|
||||
in GTK 4 is to override the focus() and grab_focus() vfuncs.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Stop using GtkEventBox</title>
|
||||
<para>
|
||||
|
||||
@@ -1226,7 +1226,7 @@ create_sidebar (void)
|
||||
stack = gtk_stack_new ();
|
||||
gtk_widget_set_size_request (stack, 120, 120);
|
||||
view = gtk_label_new ("Sidebar");
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (view), "view");
|
||||
gtk_widget_add_css_class (view, "view");
|
||||
gtk_widget_set_halign (view, GTK_ALIGN_FILL);
|
||||
gtk_widget_set_valign (view, GTK_ALIGN_FILL);
|
||||
gtk_widget_show (view);
|
||||
|
||||
@@ -67,7 +67,7 @@ libgdk_broadway = static_library('gdk-broadway',
|
||||
broadwayd_syslib = os_win32 ? find_library('ws2_32') : shmlib
|
||||
|
||||
executable('gtk4-broadwayd',
|
||||
clienthtml_h, broadwayjs_h,
|
||||
clienthtml_h, broadwayjs_h, gdkconfig, gdkenum_h,
|
||||
'broadwayd.c', 'broadway-server.c', 'broadway-output.c',
|
||||
include_directories: [confinc, gdkinc, include_directories('.')],
|
||||
c_args: ['-DGTK_COMPILATION', '-DG_LOG_DOMAIN="Gdk"', ],
|
||||
|
||||
@@ -557,4 +557,26 @@ struct _GdkKeymapKey
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
/*< private >
|
||||
* GDK_EXTERN_VAR:
|
||||
*
|
||||
* A macro to annotate extern variables so that they show up properly in
|
||||
* Windows DLLs.
|
||||
*/
|
||||
#ifndef GDK_EXTERN_VAR
|
||||
# ifdef G_PLATFORM_WIN32
|
||||
# ifdef GTK_COMPILATION
|
||||
# ifdef DLL_EXPORT
|
||||
# define GDK_EXTERN_VAR __declspec(dllexport)
|
||||
# else /* !DLL_EXPORT */
|
||||
# define GDK_EXTERN_VAR extern
|
||||
# endif /* !DLL_EXPORT */
|
||||
# else /* !GTK_COMPILATION */
|
||||
# define GDK_EXTERN_VAR extern __declspec(dllimport)
|
||||
# endif /* !GTK_COMPILATION */
|
||||
# else /* !G_PLATFORM_WIN32 */
|
||||
# define GDK_EXTERN_VAR _GDK_EXTERN
|
||||
# endif /* !G_PLATFORM_WIN32 */
|
||||
#endif /* GDK_EXTERN_VAR */
|
||||
|
||||
#endif /* __GDK_TYPES_H__ */
|
||||
|
||||
@@ -431,6 +431,7 @@ gdk_registry_handle_global (void *data,
|
||||
else if (strcmp (interface, "xdg_wm_base") == 0)
|
||||
{
|
||||
display_wayland->xdg_wm_base_id = id;
|
||||
display_wayland->xdg_wm_base_version = version;
|
||||
}
|
||||
else if (strcmp (interface, "zxdg_shell_v6") == 0)
|
||||
{
|
||||
@@ -659,7 +660,8 @@ _gdk_wayland_display_open (const gchar *display_name)
|
||||
display_wayland->xdg_wm_base =
|
||||
wl_registry_bind (display_wayland->wl_registry,
|
||||
display_wayland->xdg_wm_base_id,
|
||||
&xdg_wm_base_interface, 1);
|
||||
&xdg_wm_base_interface,
|
||||
MIN (display_wayland->xdg_wm_base_version, 3));
|
||||
xdg_wm_base_add_listener (display_wayland->xdg_wm_base,
|
||||
&xdg_wm_base_listener,
|
||||
display_wayland);
|
||||
|
||||
@@ -86,6 +86,7 @@ struct _GdkWaylandDisplay
|
||||
guint32 serial;
|
||||
|
||||
uint32_t xdg_wm_base_id;
|
||||
int xdg_wm_base_version;
|
||||
uint32_t zxdg_shell_v6_id;
|
||||
GdkWaylandShellVariant shell_variant;
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ static guint signals[LAST_SIGNAL];
|
||||
typedef enum _PopupState
|
||||
{
|
||||
POPUP_STATE_IDLE,
|
||||
POPUP_STATE_WAITING_FOR_REPOSITIONED,
|
||||
POPUP_STATE_WAITING_FOR_CONFIGURE,
|
||||
POPUP_STATE_WAITING_FOR_FRAME,
|
||||
} PopupState;
|
||||
@@ -94,6 +95,9 @@ struct _GdkWaylandSurface
|
||||
EGLSurface egl_surface;
|
||||
EGLSurface dummy_egl_surface;
|
||||
|
||||
uint32_t reposition_token;
|
||||
uint32_t received_reposition_token;
|
||||
|
||||
PopupState popup_state;
|
||||
|
||||
unsigned int initial_configure_received : 1;
|
||||
@@ -103,8 +107,6 @@ struct _GdkWaylandSurface
|
||||
unsigned int awaiting_frame_frozen : 1;
|
||||
unsigned int is_drag_surface : 1;
|
||||
GdkSurfaceTypeHint hint;
|
||||
GdkSurface *transient_for;
|
||||
GdkSurface *popup_parent;
|
||||
|
||||
int pending_buffer_offset_x;
|
||||
int pending_buffer_offset_y;
|
||||
@@ -167,12 +169,18 @@ struct _GdkWaylandSurface
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
uint32_t repositioned_token;
|
||||
gboolean has_repositioned_token;
|
||||
} popup;
|
||||
|
||||
gboolean is_initial_configure;
|
||||
|
||||
uint32_t serial;
|
||||
gboolean is_dirty;
|
||||
} pending;
|
||||
|
||||
uint32_t last_configure_serial;
|
||||
|
||||
int state_freeze_count;
|
||||
|
||||
struct {
|
||||
@@ -190,6 +198,76 @@ struct _GdkWaylandSurfaceClass
|
||||
GdkSurfaceClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GdkWaylandSurface, gdk_wayland_surface, GDK_TYPE_SURFACE)
|
||||
|
||||
typedef struct _GdkWaylandToplevel GdkWaylandToplevel;
|
||||
struct _GdkWaylandToplevel
|
||||
{
|
||||
GdkWaylandSurface parent_instance;
|
||||
|
||||
GdkWaylandToplevel *transient_for;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GdkWaylandSurfaceClass parent_class;
|
||||
} GdkWaylandToplevelClass;
|
||||
|
||||
static void gdk_wayland_toplevel_iface_init (GdkToplevelInterface *iface);
|
||||
|
||||
GType gdk_wayland_toplevel_get_type (void) G_GNUC_CONST;
|
||||
|
||||
#define GDK_IS_WAYLAND_TOPLEVEL(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_TOPLEVEL))
|
||||
#define GDK_WAYLAND_TOPLEVEL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_TOPLEVEL, GdkWaylandToplevel))
|
||||
|
||||
#define GDK_TYPE_WAYLAND_TOPLEVEL (gdk_wayland_toplevel_get_type ())
|
||||
G_DEFINE_TYPE_WITH_CODE (GdkWaylandToplevel, gdk_wayland_toplevel, GDK_TYPE_WAYLAND_SURFACE,
|
||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_TOPLEVEL,
|
||||
gdk_wayland_toplevel_iface_init))
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GdkWaylandSurface parent_instance;
|
||||
} GdkWaylandPopup;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GdkWaylandSurfaceClass parent_class;
|
||||
} GdkWaylandPopupClass;
|
||||
|
||||
static void gdk_wayland_popup_iface_init (GdkPopupInterface *iface);
|
||||
|
||||
GType gdk_wayland_popup_get_type (void) G_GNUC_CONST;
|
||||
|
||||
#define GDK_IS_WAYLAND_POPUP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_POPUP))
|
||||
#define GDK_WAYLAND_POPUP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_POPUP, GdkWaylandPopup))
|
||||
|
||||
#define GDK_TYPE_WAYLAND_POPUP (gdk_wayland_popup_get_type ())
|
||||
G_DEFINE_TYPE_WITH_CODE (GdkWaylandPopup, gdk_wayland_popup, GDK_TYPE_WAYLAND_SURFACE,
|
||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_POPUP,
|
||||
gdk_wayland_popup_iface_init))
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GdkWaylandSurface parent_instance;
|
||||
} GdkWaylandDragSurface;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GdkWaylandSurfaceClass parent_class;
|
||||
} GdkWaylandDragSurfaceClass;
|
||||
|
||||
static void gdk_wayland_drag_surface_iface_init (GdkDragSurfaceInterface *iface);
|
||||
|
||||
GType gdk_wayland_drag_surface_get_type (void) G_GNUC_CONST;
|
||||
|
||||
#define GDK_IS_WAYLAND_DRAG_SURFACE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DRAG_SURFACE))
|
||||
|
||||
#define GDK_TYPE_WAYLAND_DRAG_SURFACE (gdk_wayland_drag_surface_get_type ())
|
||||
G_DEFINE_TYPE_WITH_CODE (GdkWaylandDragSurface, gdk_wayland_drag_surface, GDK_TYPE_WAYLAND_SURFACE,
|
||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_DRAG_SURFACE,
|
||||
gdk_wayland_drag_surface_iface_init))
|
||||
|
||||
static void gdk_wayland_surface_maybe_resize (GdkSurface *surface,
|
||||
int width,
|
||||
int height,
|
||||
@@ -221,16 +299,6 @@ static void update_popup_layout_state (GdkSurface *surface,
|
||||
|
||||
static gboolean gdk_wayland_surface_is_exported (GdkSurface *surface);
|
||||
|
||||
G_DEFINE_TYPE (GdkWaylandSurface, gdk_wayland_surface, GDK_TYPE_SURFACE)
|
||||
|
||||
GType gdk_wayland_toplevel_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_wayland_popup_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_wayland_drag_surface_get_type (void) G_GNUC_CONST;
|
||||
|
||||
#define GDK_TYPE_WAYLAND_TOPLEVEL (gdk_wayland_toplevel_get_type ())
|
||||
#define GDK_TYPE_WAYLAND_POPUP (gdk_wayland_popup_get_type ())
|
||||
#define GDK_TYPE_WAYLAND_DRAG_SURFACE (gdk_wayland_drag_surface_get_type ())
|
||||
|
||||
static void
|
||||
gdk_wayland_surface_init (GdkWaylandSurface *impl)
|
||||
{
|
||||
@@ -438,6 +506,7 @@ frame_callback (void *data,
|
||||
switch (impl->popup_state)
|
||||
{
|
||||
case POPUP_STATE_IDLE:
|
||||
case POPUP_STATE_WAITING_FOR_REPOSITIONED:
|
||||
case POPUP_STATE_WAITING_FOR_CONFIGURE:
|
||||
break;
|
||||
case POPUP_STATE_WAITING_FOR_FRAME:
|
||||
@@ -632,6 +701,9 @@ _gdk_wayland_display_create_surface (GdkDisplay *display,
|
||||
"display", display,
|
||||
"frame-clock", frame_clock,
|
||||
NULL);
|
||||
display_wayland->toplevels = g_list_prepend (display_wayland->toplevels,
|
||||
surface);
|
||||
g_warn_if_fail (!parent);
|
||||
break;
|
||||
case GDK_SURFACE_POPUP:
|
||||
surface = g_object_new (GDK_TYPE_WAYLAND_POPUP,
|
||||
@@ -678,10 +750,6 @@ _gdk_wayland_display_create_surface (GdkDisplay *display,
|
||||
|
||||
gdk_wayland_surface_set_title (surface, get_default_title ());
|
||||
|
||||
if (parent == NULL)
|
||||
display_wayland->toplevels = g_list_prepend (display_wayland->toplevels, surface);
|
||||
|
||||
impl->transient_for = parent;
|
||||
|
||||
gdk_wayland_surface_create_surface (surface);
|
||||
|
||||
@@ -772,8 +840,6 @@ gdk_wayland_surface_dispose (GObject *object)
|
||||
|
||||
impl = GDK_WAYLAND_SURFACE (surface);
|
||||
|
||||
g_clear_object (&impl->popup_parent);
|
||||
|
||||
if (impl->event_queue)
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland =
|
||||
@@ -903,6 +969,7 @@ gdk_wayland_surface_sync_parent (GdkSurface *surface,
|
||||
GdkSurface *parent)
|
||||
{
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
GdkWaylandToplevel *toplevel = GDK_WAYLAND_TOPLEVEL (impl);
|
||||
GdkWaylandDisplay *display_wayland =
|
||||
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
||||
GdkWaylandSurface *impl_parent = NULL;
|
||||
@@ -913,8 +980,8 @@ gdk_wayland_surface_sync_parent (GdkSurface *surface,
|
||||
if (!is_realized_toplevel (surface))
|
||||
return;
|
||||
|
||||
if (impl->transient_for)
|
||||
impl_parent = GDK_WAYLAND_SURFACE (impl->transient_for);
|
||||
if (toplevel->transient_for)
|
||||
impl_parent = GDK_WAYLAND_SURFACE (toplevel->transient_for);
|
||||
else if (parent)
|
||||
impl_parent = GDK_WAYLAND_SURFACE (parent);
|
||||
|
||||
@@ -1282,8 +1349,17 @@ gdk_wayland_surface_configure_popup (GdkSurface *surface)
|
||||
impl->pending.serial);
|
||||
}
|
||||
|
||||
if (impl->pending.popup.has_repositioned_token)
|
||||
impl->received_reposition_token = impl->pending.popup.repositioned_token;
|
||||
|
||||
switch (impl->popup_state)
|
||||
{
|
||||
case POPUP_STATE_WAITING_FOR_REPOSITIONED:
|
||||
if (impl->received_reposition_token != impl->reposition_token)
|
||||
return;
|
||||
else
|
||||
gdk_surface_thaw_updates (surface);
|
||||
G_GNUC_FALLTHROUGH;
|
||||
case POPUP_STATE_WAITING_FOR_CONFIGURE:
|
||||
impl->popup_state = POPUP_STATE_WAITING_FOR_FRAME;
|
||||
break;
|
||||
@@ -1306,6 +1382,10 @@ gdk_wayland_surface_configure_popup (GdkSurface *surface)
|
||||
width, height,
|
||||
impl->popup.layout);
|
||||
|
||||
if (!impl->pending.popup.has_repositioned_token &&
|
||||
!impl->pending.is_initial_configure)
|
||||
g_signal_emit_by_name (surface, "popup-layout-changed");
|
||||
|
||||
gdk_surface_invalidate_rect (surface, NULL);
|
||||
}
|
||||
|
||||
@@ -1318,6 +1398,7 @@ gdk_wayland_surface_configure (GdkSurface *surface)
|
||||
{
|
||||
gdk_surface_thaw_updates (surface);
|
||||
impl->initial_configure_received = TRUE;
|
||||
impl->pending.is_initial_configure = TRUE;
|
||||
}
|
||||
|
||||
if (is_realized_popup (surface))
|
||||
@@ -1327,6 +1408,8 @@ gdk_wayland_surface_configure (GdkSurface *surface)
|
||||
else
|
||||
g_warn_if_reached ();
|
||||
|
||||
impl->last_configure_serial = impl->pending.serial;
|
||||
|
||||
memset (&impl->pending, 0, sizeof (impl->pending));
|
||||
}
|
||||
|
||||
@@ -1663,9 +1746,31 @@ xdg_popup_done (void *data,
|
||||
gdk_surface_hide (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_popup_repositioned (void *data,
|
||||
struct xdg_popup *xdg_popup,
|
||||
uint32_t token)
|
||||
{
|
||||
GdkSurface *surface = GDK_SURFACE (data);
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
|
||||
GDK_DISPLAY_NOTE (gdk_surface_get_display (surface), EVENTS,
|
||||
g_message ("repositioned %p", surface));
|
||||
|
||||
if (impl->popup_state != POPUP_STATE_WAITING_FOR_REPOSITIONED)
|
||||
{
|
||||
g_warning ("Unexpected xdg_popup.repositioned event, probably buggy compositor");
|
||||
return;
|
||||
}
|
||||
|
||||
impl->pending.popup.repositioned_token = token;
|
||||
impl->pending.popup.has_repositioned_token = TRUE;
|
||||
}
|
||||
|
||||
static const struct xdg_popup_listener xdg_popup_listener = {
|
||||
xdg_popup_configure,
|
||||
xdg_popup_done,
|
||||
xdg_popup_repositioned,
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -2052,7 +2157,8 @@ static gpointer
|
||||
create_dynamic_positioner (GdkSurface *surface,
|
||||
int width,
|
||||
int height,
|
||||
GdkPopupLayout *layout)
|
||||
GdkPopupLayout *layout,
|
||||
gboolean ack_parent_configure)
|
||||
{
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
GdkSurface *parent = surface->parent;
|
||||
@@ -2129,6 +2235,30 @@ create_dynamic_positioner (GdkSurface *surface,
|
||||
xdg_positioner_set_constraint_adjustment (positioner,
|
||||
constraint_adjustment);
|
||||
|
||||
if (xdg_positioner_get_version (positioner) >=
|
||||
XDG_POSITIONER_SET_REACTIVE_SINCE_VERSION)
|
||||
xdg_positioner_set_reactive (positioner);
|
||||
|
||||
if (ack_parent_configure &&
|
||||
xdg_positioner_get_version (positioner) >=
|
||||
XDG_POSITIONER_SET_PARENT_CONFIGURE_SINCE_VERSION)
|
||||
{
|
||||
GdkWaylandSurface *parent_impl = GDK_WAYLAND_SURFACE (parent);
|
||||
int parent_width;
|
||||
int parent_height;
|
||||
|
||||
parent_width = parent->width - (parent_impl->margin_left +
|
||||
parent_impl->margin_right);
|
||||
parent_height = parent->height - (parent_impl->margin_top +
|
||||
parent_impl->margin_bottom);
|
||||
|
||||
xdg_positioner_set_parent_size (positioner,
|
||||
parent_width,
|
||||
parent_height);
|
||||
xdg_positioner_set_parent_configure (positioner,
|
||||
parent_impl->last_configure_serial);
|
||||
}
|
||||
|
||||
return positioner;
|
||||
}
|
||||
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
||||
@@ -2233,7 +2363,7 @@ gdk_wayland_surface_create_xdg_popup (GdkSurface *surface,
|
||||
|
||||
gdk_surface_freeze_updates (surface);
|
||||
|
||||
positioner = create_dynamic_positioner (surface, width, height, layout);
|
||||
positioner = create_dynamic_positioner (surface, width, height, layout, FALSE);
|
||||
|
||||
switch (display->shell_variant)
|
||||
{
|
||||
@@ -2307,7 +2437,6 @@ gdk_wayland_surface_create_xdg_popup (GdkSurface *surface,
|
||||
freeze_popup_toplevel_state (surface);
|
||||
}
|
||||
|
||||
g_set_object (&impl->popup_parent, parent);
|
||||
display->current_popups = g_list_append (display->current_popups, surface);
|
||||
if (grab_input_seat)
|
||||
{
|
||||
@@ -2396,9 +2525,8 @@ unmap_popups_for_surface (GdkSurface *surface)
|
||||
for (l = display_wayland->current_popups; l; l = l->next)
|
||||
{
|
||||
GdkSurface *popup = l->data;
|
||||
GdkWaylandSurface *popup_impl = GDK_WAYLAND_SURFACE (popup);
|
||||
|
||||
if (popup_impl->popup_parent == surface)
|
||||
if (popup->parent == surface)
|
||||
{
|
||||
g_warning ("Tried to unmap the parent of a popup");
|
||||
gdk_surface_hide (popup);
|
||||
@@ -2501,6 +2629,9 @@ gdk_wayland_surface_hide_surface (GdkSurface *surface)
|
||||
{
|
||||
switch (impl->popup_state)
|
||||
{
|
||||
case POPUP_STATE_WAITING_FOR_REPOSITIONED:
|
||||
gdk_surface_thaw_updates (surface);
|
||||
G_GNUC_FALLTHROUGH;
|
||||
case POPUP_STATE_WAITING_FOR_CONFIGURE:
|
||||
case POPUP_STATE_WAITING_FOR_FRAME:
|
||||
thaw_popup_toplevel_state (surface);
|
||||
@@ -2602,6 +2733,7 @@ do_queue_relayout (GdkSurface *surface,
|
||||
GdkPopupLayout *layout)
|
||||
{
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
struct xdg_positioner *positioner;
|
||||
|
||||
g_assert (is_realized_popup (surface));
|
||||
g_assert (impl->popup_state == POPUP_STATE_IDLE ||
|
||||
@@ -2612,7 +2744,41 @@ do_queue_relayout (GdkSurface *surface,
|
||||
impl->popup.unconstrained_width = width;
|
||||
impl->popup.unconstrained_height = height;
|
||||
|
||||
queue_relayout_fallback (surface, layout);
|
||||
if (!impl->display_server.xdg_popup ||
|
||||
xdg_popup_get_version (impl->display_server.xdg_popup) <
|
||||
XDG_POPUP_REPOSITION_SINCE_VERSION)
|
||||
{
|
||||
g_warning_once ("Compositor doesn't support moving popups, "
|
||||
"relying on remapping");
|
||||
queue_relayout_fallback (surface, layout);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
positioner = create_dynamic_positioner (surface,
|
||||
width, height, layout,
|
||||
TRUE);
|
||||
xdg_popup_reposition (impl->display_server.xdg_popup,
|
||||
positioner,
|
||||
++impl->reposition_token);
|
||||
xdg_positioner_destroy (positioner);
|
||||
|
||||
gdk_surface_freeze_updates (surface);
|
||||
|
||||
switch (impl->popup_state)
|
||||
{
|
||||
case POPUP_STATE_IDLE:
|
||||
freeze_popup_toplevel_state (surface);
|
||||
break;
|
||||
case POPUP_STATE_WAITING_FOR_FRAME:
|
||||
break;
|
||||
case POPUP_STATE_WAITING_FOR_CONFIGURE:
|
||||
case POPUP_STATE_WAITING_FOR_REPOSITIONED:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
impl->popup_state = POPUP_STATE_WAITING_FOR_REPOSITIONED;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -2623,6 +2789,9 @@ is_relayout_finished (GdkSurface *surface)
|
||||
if (!impl->initial_configure_received)
|
||||
return FALSE;
|
||||
|
||||
if (impl->reposition_token != impl->received_reposition_token)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2707,6 +2876,7 @@ reposition_popup (GdkSurface *surface,
|
||||
case POPUP_STATE_WAITING_FOR_FRAME:
|
||||
do_queue_relayout (surface, width, height, layout);
|
||||
break;
|
||||
case POPUP_STATE_WAITING_FOR_REPOSITIONED:
|
||||
case POPUP_STATE_WAITING_FOR_CONFIGURE:
|
||||
g_warn_if_reached ();
|
||||
break;
|
||||
@@ -3172,44 +3342,46 @@ gdk_wayland_surface_set_startup_id (GdkSurface *surface,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_transient_for_loop (GdkSurface *surface,
|
||||
GdkSurface *parent)
|
||||
check_transient_for_loop (GdkWaylandToplevel *toplevel,
|
||||
GdkWaylandToplevel *parent)
|
||||
{
|
||||
while (parent)
|
||||
{
|
||||
GdkWaylandSurface *impl;
|
||||
|
||||
if (!GDK_IS_WAYLAND_SURFACE (parent))
|
||||
return FALSE;
|
||||
|
||||
impl = GDK_WAYLAND_SURFACE (parent);
|
||||
if (impl->transient_for == surface)
|
||||
if (parent->transient_for == toplevel)
|
||||
return TRUE;
|
||||
parent = impl->transient_for;
|
||||
parent = parent->transient_for;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_surface_set_transient_for (GdkSurface *surface,
|
||||
GdkSurface *parent)
|
||||
gdk_wayland_toplevel_set_transient_for (GdkWaylandToplevel *toplevel,
|
||||
GdkSurface *parent)
|
||||
{
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
g_return_if_fail (!parent || GDK_IS_WAYLAND_TOPLEVEL (parent));
|
||||
g_return_if_fail (!parent ||
|
||||
gdk_surface_get_display (GDK_SURFACE (toplevel)) == gdk_surface_get_display (parent));
|
||||
|
||||
g_assert (parent == NULL ||
|
||||
gdk_surface_get_display (surface) == gdk_surface_get_display (parent));
|
||||
|
||||
if (check_transient_for_loop (surface, parent))
|
||||
if (parent)
|
||||
{
|
||||
g_warning ("Setting %p transient for %p would create a loop", surface, parent);
|
||||
return;
|
||||
GdkWaylandToplevel *parent_toplevel = GDK_WAYLAND_TOPLEVEL (parent);
|
||||
|
||||
if (check_transient_for_loop (toplevel, parent_toplevel))
|
||||
{
|
||||
g_warning ("Setting %p transient for %p would create a loop",
|
||||
toplevel, parent);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
unset_transient_for_exported (surface);
|
||||
unset_transient_for_exported (GDK_SURFACE (toplevel));
|
||||
|
||||
impl->transient_for = parent;
|
||||
if (parent)
|
||||
toplevel->transient_for = GDK_WAYLAND_TOPLEVEL (parent);
|
||||
else
|
||||
toplevel->transient_for = NULL;
|
||||
|
||||
gdk_wayland_surface_sync_parent (surface, NULL);
|
||||
gdk_wayland_surface_sync_parent (GDK_SURFACE (toplevel), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -4097,7 +4269,7 @@ gdk_wayland_surface_set_transient_for_exported (GdkSurface *surface,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gdk_wayland_surface_set_transient_for (surface, NULL);
|
||||
gdk_wayland_toplevel_set_transient_for (GDK_WAYLAND_TOPLEVEL (impl), NULL);
|
||||
|
||||
impl->imported_transient_for =
|
||||
zxdg_importer_v1_import (display_wayland->xdg_importer, parent_handle_str);
|
||||
@@ -4169,22 +4341,6 @@ create_dnd_surface (GdkDisplay *display)
|
||||
|
||||
#define LAST_PROP 1
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GdkWaylandSurface parent_instance;
|
||||
} GdkWaylandPopup;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GdkWaylandSurfaceClass parent_class;
|
||||
} GdkWaylandPopupClass;
|
||||
|
||||
static void gdk_wayland_popup_iface_init (GdkPopupInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GdkWaylandPopup, gdk_wayland_popup, GDK_TYPE_WAYLAND_SURFACE,
|
||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_POPUP,
|
||||
gdk_wayland_popup_iface_init))
|
||||
|
||||
static void
|
||||
gdk_wayland_popup_init (GdkWaylandPopup *popup)
|
||||
{
|
||||
@@ -4294,22 +4450,6 @@ gdk_wayland_popup_iface_init (GdkPopupInterface *iface)
|
||||
iface->get_position_y = gdk_wayland_popup_get_position_y;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GdkWaylandSurface parent_instance;
|
||||
} GdkWaylandToplevel;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GdkWaylandSurfaceClass parent_class;
|
||||
} GdkWaylandToplevelClass;
|
||||
|
||||
static void gdk_wayland_toplevel_iface_init (GdkToplevelInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GdkWaylandToplevel, gdk_wayland_toplevel, GDK_TYPE_WAYLAND_SURFACE,
|
||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_TOPLEVEL,
|
||||
gdk_wayland_toplevel_iface_init))
|
||||
|
||||
static void
|
||||
gdk_wayland_toplevel_init (GdkWaylandToplevel *toplevel)
|
||||
{
|
||||
@@ -4322,6 +4462,7 @@ gdk_wayland_toplevel_set_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GdkSurface *surface = GDK_SURFACE (object);
|
||||
GdkWaylandToplevel *toplevel = GDK_WAYLAND_TOPLEVEL (surface);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@@ -4336,7 +4477,8 @@ gdk_wayland_toplevel_set_property (GObject *object,
|
||||
break;
|
||||
|
||||
case LAST_PROP + GDK_TOPLEVEL_PROP_TRANSIENT_FOR:
|
||||
gdk_wayland_surface_set_transient_for (surface, g_value_get_object (value));
|
||||
gdk_wayland_toplevel_set_transient_for (toplevel,
|
||||
g_value_get_object (value));
|
||||
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
|
||||
break;
|
||||
|
||||
@@ -4376,6 +4518,7 @@ gdk_wayland_toplevel_get_property (GObject *object,
|
||||
{
|
||||
GdkSurface *surface = GDK_SURFACE (object);
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
GdkWaylandToplevel *toplevel = GDK_WAYLAND_TOPLEVEL (surface);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@@ -4392,7 +4535,7 @@ gdk_wayland_toplevel_get_property (GObject *object,
|
||||
break;
|
||||
|
||||
case LAST_PROP + GDK_TOPLEVEL_PROP_TRANSIENT_FOR:
|
||||
g_value_set_object (value, impl->transient_for);
|
||||
g_value_set_object (value, toplevel->transient_for);
|
||||
break;
|
||||
|
||||
case LAST_PROP + GDK_TOPLEVEL_PROP_MODAL:
|
||||
@@ -4617,22 +4760,6 @@ gdk_wayland_toplevel_iface_init (GdkToplevelInterface *iface)
|
||||
iface->restore_system_shortcuts = gdk_wayland_toplevel_restore_system_shortcuts;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GdkWaylandSurface parent_instance;
|
||||
} GdkWaylandDragSurface;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GdkWaylandSurfaceClass parent_class;
|
||||
} GdkWaylandDragSurfaceClass;
|
||||
|
||||
static void gdk_wayland_drag_surface_iface_init (GdkDragSurfaceInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GdkWaylandDragSurface, gdk_wayland_drag_surface, GDK_TYPE_WAYLAND_SURFACE,
|
||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_DRAG_SURFACE,
|
||||
gdk_wayland_drag_surface_iface_init))
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_surface_init (GdkWaylandDragSurface *surface)
|
||||
{
|
||||
|
||||
@@ -37,10 +37,6 @@ gdk_wayland_deps = [
|
||||
wlegldep,
|
||||
]
|
||||
|
||||
# wayland protocols
|
||||
proto_dir = dependency('wayland-protocols').get_pkgconfig_variable('pkgdatadir')
|
||||
assert(proto_dir != '', 'Could not get pkgdatadir from wayland-protocols.pc')
|
||||
|
||||
wayland_scanner = find_program('wayland-scanner')
|
||||
|
||||
# Format:
|
||||
@@ -68,14 +64,14 @@ foreach p: proto_sources
|
||||
|
||||
if proto_stability == 'stable'
|
||||
output_base = proto_name
|
||||
input = join_paths(proto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base))
|
||||
input = files(join_paths(wlproto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base)))
|
||||
elif proto_stability == 'private'
|
||||
output_base = proto_name
|
||||
input = 'protocol/@0@.xml'.format(proto_name)
|
||||
input = files('protocol/@0@.xml'.format(proto_name))
|
||||
else
|
||||
proto_version = p.get(2)
|
||||
output_base = '@0@-@1@-@2@'.format(proto_name, proto_stability, proto_version)
|
||||
input = join_paths(proto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base))
|
||||
input = files(join_paths(wlproto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base)))
|
||||
endif
|
||||
|
||||
gdk_wayland_gen_headers += custom_target('@0@ client header'.format(output_base),
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
|
||||
#include "gdkx11devicemanager-xi2.h"
|
||||
#include "gdkx11device-xi2.h"
|
||||
#include "gdkx11keys.h"
|
||||
|
||||
#include "gdkdeviceprivate.h"
|
||||
#include "gdkdevicetoolprivate.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkeventtranslator.h"
|
||||
#include "gdkkeys-x11.h"
|
||||
#include "gdkprivate-x11.h"
|
||||
#include "gdkdisplay-x11.h"
|
||||
#include "gdkintl.h"
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include "gdkdisplay-x11.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkx11keys.h"
|
||||
|
||||
#include "gdkasync.h"
|
||||
#include "gdkdisplay.h"
|
||||
@@ -39,12 +38,15 @@
|
||||
#include "gdkkeysprivate.h"
|
||||
#include "gdkmarshalers.h"
|
||||
#include "xsettings-client.h"
|
||||
|
||||
#include "gdkcairocontext-x11.h"
|
||||
#include "gdkclipboard-x11.h"
|
||||
#include "gdkglcontext-x11.h"
|
||||
#include "gdkkeys-x11.h"
|
||||
#include "gdkprivate-x11.h"
|
||||
#include "gdkscreen-x11.h"
|
||||
#include "gdkcairocontext-x11.h"
|
||||
#include "gdkglcontext-x11.h"
|
||||
#include "gdkvulkancontext-x11.h"
|
||||
|
||||
#include "gdk-private.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkx11keys.h"
|
||||
#include "gdkkeys-x11.h"
|
||||
|
||||
#include "gdkkeysprivate.h"
|
||||
#include "gdkkeysyms.h"
|
||||
#include "gdkprivate-x11.h"
|
||||
|
||||
@@ -18,10 +18,6 @@
|
||||
#ifndef __GDK_X11_KEYS_H__
|
||||
#define __GDK_X11_KEYS_H__
|
||||
|
||||
#if !defined (__GDKX_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gdk/x11/gdkx.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <gdk/gdkkeysprivate.h>
|
||||
|
||||
@@ -41,7 +37,6 @@ typedef struct _GdkX11KeymapClass GdkX11KeymapClass;
|
||||
#define GDK_IS_X11_KEYMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_X11_KEYMAP))
|
||||
#define GDK_X11_KEYMAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_X11_KEYMAP, GdkX11KeymapClass))
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gdk_x11_keymap_get_type (void);
|
||||
|
||||
gint gdk_x11_keymap_get_group_for_state (GdkKeymap *keymap,
|
||||
+23
-15
@@ -1,36 +1,44 @@
|
||||
# A list of sources that contain public API; these are the sources that
|
||||
# will be introspected for the GdkX11 namespace.
|
||||
#
|
||||
# Note: gdksettings.c gets included from xsettings-client.c, do not add here
|
||||
gdk_x11_sources = files([
|
||||
'gdkapplaunchcontext-x11.c',
|
||||
'gdkasync.c',
|
||||
'gdkcairocontext-x11.c',
|
||||
'gdkclipboard-x11.c',
|
||||
gdk_x11_public_sources = files([
|
||||
'gdkcursor-x11.c',
|
||||
'gdkdevice-xi2.c',
|
||||
'gdkdevicemanager-x11.c',
|
||||
'gdkdevicemanager-xi2.c',
|
||||
'gdkdisplay-x11.c',
|
||||
'gdkdrag-x11.c',
|
||||
'gdkdrop-x11.c',
|
||||
'gdkeventsource.c',
|
||||
'gdkeventtranslator.c',
|
||||
'gdkglcontext-x11.c',
|
||||
'gdkkeys-x11.c',
|
||||
'gdkmain-x11.c',
|
||||
'gdkmonitor-x11.c',
|
||||
'gdkproperty-x11.c',
|
||||
'gdkscreen-x11.c',
|
||||
'gdkselection-x11.c',
|
||||
'gdkselectioninputstream-x11.c',
|
||||
'gdkselectionoutputstream-x11.c',
|
||||
'gdktextlistconverter-x11.c',
|
||||
'gdkvisual-x11.c',
|
||||
'gdkvulkancontext-x11.c',
|
||||
'gdksurface-x11.c',
|
||||
'gdkxftdefaults.c',
|
||||
'gdkxid.c',
|
||||
'xsettings-client.c',
|
||||
])
|
||||
|
||||
# All sources
|
||||
gdk_x11_sources = gdk_x11_public_sources + [
|
||||
'gdkapplaunchcontext-x11.c',
|
||||
'gdkasync.c',
|
||||
'gdkcairocontext-x11.c',
|
||||
'gdkclipboard-x11.c',
|
||||
'gdkdrag-x11.c',
|
||||
'gdkdrop-x11.c',
|
||||
'gdkeventsource.c',
|
||||
'gdkeventtranslator.c',
|
||||
'gdkmain-x11.c',
|
||||
'gdkselectioninputstream-x11.c',
|
||||
'gdkselectionoutputstream-x11.c',
|
||||
'gdktextlistconverter-x11.c',
|
||||
'gdkvulkancontext-x11.c',
|
||||
'gdkxftdefaults.c',
|
||||
]
|
||||
|
||||
# Public headers; will be installed and introspected
|
||||
gdk_x11_public_headers = files([
|
||||
'gdkx-autocleanups.h',
|
||||
'gdkx11applaunchcontext.h',
|
||||
|
||||
@@ -595,7 +595,7 @@ gsk_broadway_renderer_add_node (GskRenderer *renderer,
|
||||
n = gsk_linear_gradient_node_get_n_color_stops (node);
|
||||
add_uint32 (nodes, n);
|
||||
for (i = 0; i < n; i++)
|
||||
add_color_stop (nodes, &gsk_linear_gradient_node_peek_color_stops (node)[i]);
|
||||
add_color_stop (nodes, &gsk_linear_gradient_node_peek_color_stops (node, NULL)[i]);
|
||||
}
|
||||
return;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ node_sample_add (NodeSample *self,
|
||||
g_assert (node_type <= N_NODE_TYPES);
|
||||
|
||||
if (self->nodes[node_type].class_name == NULL)
|
||||
self->nodes[node_type].class_name = node->node_class->type_name;
|
||||
self->nodes[node_type].class_name = g_type_name_from_instance ((GTypeInstance *) node);
|
||||
|
||||
self->nodes[node_type].count ++;
|
||||
self->count ++;
|
||||
|
||||
+31
-16
@@ -150,7 +150,7 @@ print_render_node_tree (GskRenderNode *root, int level)
|
||||
break;
|
||||
|
||||
default:
|
||||
g_print ("%*s %s\n", level * INDENT, " ", root->node_class->type_name);
|
||||
g_print ("%*s %s\n", level * INDENT, " ", g_type_name_from_instance ((GTypeInstance *) root));
|
||||
}
|
||||
|
||||
#undef INDENT
|
||||
@@ -623,7 +623,9 @@ render_fallback_node (GskGLRenderer *self,
|
||||
surface,
|
||||
GL_NEAREST, GL_NEAREST);
|
||||
gdk_gl_context_label_object_printf (self->gl_context, GL_TEXTURE, texture_id,
|
||||
"Fallback %s %d", node->node_class->type_name, texture_id);
|
||||
"Fallback %s %d",
|
||||
g_type_name_from_instance ((GTypeInstance *) node),
|
||||
texture_id);
|
||||
|
||||
cairo_surface_destroy (surface);
|
||||
cairo_surface_destroy (rendered_surface);
|
||||
@@ -643,7 +645,7 @@ render_text_node (GskGLRenderer *self,
|
||||
gboolean force_color)
|
||||
{
|
||||
const PangoFont *font = gsk_text_node_peek_font (node);
|
||||
const PangoGlyphInfo *glyphs = gsk_text_node_peek_glyphs (node);
|
||||
const PangoGlyphInfo *glyphs = gsk_text_node_peek_glyphs (node, NULL);
|
||||
const float text_scale = ops_get_scale (builder);
|
||||
const graphene_point_t *offset = gsk_text_node_get_offset (node);
|
||||
const guint num_glyphs = gsk_text_node_get_num_glyphs (node);
|
||||
@@ -1106,7 +1108,7 @@ render_linear_gradient_node (GskGLRenderer *self,
|
||||
RenderOpBuilder *builder)
|
||||
{
|
||||
const int n_color_stops = MIN (8, gsk_linear_gradient_node_get_n_color_stops (node));
|
||||
const GskColorStop *stops = gsk_linear_gradient_node_peek_color_stops (node);
|
||||
const GskColorStop *stops = gsk_linear_gradient_node_peek_color_stops (node, NULL);
|
||||
const graphene_point_t *start = gsk_linear_gradient_node_peek_start (node);
|
||||
const graphene_point_t *end = gsk_linear_gradient_node_peek_end (node);
|
||||
OpLinearGradient *op;
|
||||
@@ -3159,9 +3161,13 @@ add_offscreen_ops (GskGLRenderer *self,
|
||||
|
||||
gsk_gl_driver_create_render_target (self->gl_driver, width, height, &texture_id, &render_target);
|
||||
gdk_gl_context_label_object_printf (self->gl_context, GL_TEXTURE, texture_id,
|
||||
"Offscreen<%s> %d", child_node->node_class->type_name, texture_id);
|
||||
gdk_gl_context_label_object_printf (self->gl_context, GL_FRAMEBUFFER, render_target,
|
||||
"Offscreen<%s> FB %d", child_node->node_class->type_name, render_target);
|
||||
"Offscreen<%s> %d",
|
||||
g_type_name_from_instance ((GTypeInstance *) child_node),
|
||||
texture_id);
|
||||
gdk_gl_context_label_object_printf (self->gl_context, GL_FRAMEBUFFER, render_target,
|
||||
"Offscreen<%s> FB %d",
|
||||
g_type_name_from_instance ((GTypeInstance *) child_node),
|
||||
render_target);
|
||||
|
||||
graphene_matrix_init_ortho (&item_proj,
|
||||
bounds->origin.x * scale,
|
||||
@@ -3209,10 +3215,11 @@ add_offscreen_ops (GskGLRenderer *self,
|
||||
if (G_UNLIKELY (flags & DUMP_FRAMEBUFFER))
|
||||
{
|
||||
static int k;
|
||||
ops_dump_framebuffer (builder, g_strdup_printf ("%s_%p_%d.png",
|
||||
child_node->node_class->type_name,
|
||||
child_node,
|
||||
k ++),
|
||||
ops_dump_framebuffer (builder,
|
||||
g_strdup_printf ("%s_%p_%d.png",
|
||||
g_type_name_from_instance ((GTypeInstance *) child_node),
|
||||
child_node,
|
||||
k ++),
|
||||
width, height);
|
||||
}
|
||||
#endif
|
||||
@@ -3583,7 +3590,9 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer,
|
||||
|
||||
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);
|
||||
"Render %s<%p> to texture",
|
||||
g_type_name_from_instance ((GTypeInstance *) root),
|
||||
root);
|
||||
|
||||
width = ceilf (viewport->size.width);
|
||||
height = ceilf (viewport->size.height);
|
||||
@@ -3595,8 +3604,11 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer,
|
||||
glGenTextures (1, &texture_id);
|
||||
glBindTexture (GL_TEXTURE_2D, texture_id);
|
||||
|
||||
gdk_gl_context_label_object_printf (self->gl_context, GL_TEXTURE, texture_id,
|
||||
"Texture %s<%p> %d", root->node_class->type_name, root, texture_id);
|
||||
gdk_gl_context_label_object_printf (self->gl_context, GL_TEXTURE, texture_id,
|
||||
"Texture %s<%p> %d",
|
||||
g_type_name_from_instance ((GTypeInstance *) root),
|
||||
root,
|
||||
texture_id);
|
||||
|
||||
if (gdk_gl_context_get_use_es (self->gl_context))
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
@@ -3605,8 +3617,11 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer,
|
||||
|
||||
glGenFramebuffers (1, &fbo_id);
|
||||
glBindFramebuffer (GL_FRAMEBUFFER, fbo_id);
|
||||
gdk_gl_context_label_object_printf (self->gl_context, GL_FRAMEBUFFER, fbo_id,
|
||||
"FB %s<%p> %d", root->node_class->type_name, root, fbo_id);
|
||||
gdk_gl_context_label_object_printf (self->gl_context, GL_FRAMEBUFFER, fbo_id,
|
||||
"FB %s<%p> %d",
|
||||
g_type_name_from_instance ((GTypeInstance *) root),
|
||||
root,
|
||||
fbo_id);
|
||||
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0);
|
||||
g_assert_cmphex (glCheckFramebufferStatus (GL_FRAMEBUFFER), ==, GL_FRAMEBUFFER_COMPLETE);
|
||||
|
||||
|
||||
+2
-2
@@ -46,9 +46,9 @@
|
||||
* @GSK_TEXT_NODE: A node containing a glyph string
|
||||
* @GSK_BLUR_NODE: A node that applies a blur
|
||||
* @GSK_DEBUG_NODE: Debug information that does not affect the rendering
|
||||
*
|
||||
|
||||
* The type of a node determines what the node is rendering.
|
||||
**/
|
||||
*/
|
||||
typedef enum {
|
||||
GSK_NOT_A_RENDER_NODE = 0,
|
||||
GSK_CONTAINER_NODE,
|
||||
|
||||
+281
-29
@@ -50,47 +50,297 @@
|
||||
|
||||
#include <gobject/gvaluecollector.h>
|
||||
|
||||
G_DEFINE_QUARK (gsk-serialization-error-quark, gsk_serialization_error)
|
||||
|
||||
#define GSK_RENDER_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSK_TYPE_RENDER_NODE, GskRenderNodeClass))
|
||||
|
||||
/**
|
||||
* GskRenderNode: (ref-func gsk_render_node_ref) (unref-func gsk_render_node_unref)
|
||||
*
|
||||
* The `GskRenderNode` structure contains only private data.
|
||||
* A node in the render tree.
|
||||
*/
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GskRenderNode, gsk_render_node,
|
||||
gsk_render_node_ref,
|
||||
gsk_render_node_unref)
|
||||
static void
|
||||
value_render_node_init (GValue *value)
|
||||
{
|
||||
value->data[0].v_pointer = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
value_render_node_free_value (GValue *value)
|
||||
{
|
||||
if (value->data[0].v_pointer != NULL)
|
||||
gsk_render_node_unref (value->data[0].v_pointer);
|
||||
}
|
||||
|
||||
static void
|
||||
value_render_node_copy_value (const GValue *src,
|
||||
GValue *dst)
|
||||
{
|
||||
if (src->data[0].v_pointer != NULL)
|
||||
dst->data[0].v_pointer = gsk_render_node_ref (src->data[0].v_pointer);
|
||||
else
|
||||
dst->data[0].v_pointer = NULL;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
value_render_node_peek_pointer (const GValue *value)
|
||||
{
|
||||
return value->data[0].v_pointer;
|
||||
}
|
||||
|
||||
G_DEFINE_QUARK (gsk-serialization-error-quark, gsk_serialization_error)
|
||||
static char *
|
||||
value_render_node_collect_value (GValue *value,
|
||||
guint n_collect_values,
|
||||
GTypeCValue *collect_values,
|
||||
guint collect_flags)
|
||||
{
|
||||
GskRenderNode *node = collect_values[0].v_pointer;
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
value->data[0].v_pointer = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (node->parent_instance.g_class == NULL)
|
||||
return g_strconcat ("invalid unclassed GskRenderNode pointer for "
|
||||
"value type '",
|
||||
G_VALUE_TYPE_NAME (value),
|
||||
"'",
|
||||
NULL);
|
||||
|
||||
value->data[0].v_pointer = gsk_render_node_ref (node);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
value_render_node_lcopy_value (const GValue *value,
|
||||
guint n_collect_values,
|
||||
GTypeCValue *collect_values,
|
||||
guint collect_flags)
|
||||
{
|
||||
GskRenderNode **node_p = collect_values[0].v_pointer;
|
||||
|
||||
if (node_p == NULL)
|
||||
return g_strconcat ("value location for '",
|
||||
G_VALUE_TYPE_NAME (value),
|
||||
"' passed as NULL",
|
||||
NULL);
|
||||
|
||||
if (value->data[0].v_pointer == NULL)
|
||||
*node_p = NULL;
|
||||
else if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
|
||||
*node_p = value->data[0].v_pointer;
|
||||
else
|
||||
*node_p = gsk_render_node_ref (value->data[0].v_pointer);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_render_node_finalize (GskRenderNode *self)
|
||||
{
|
||||
self->node_class->finalize (self);
|
||||
g_type_free_instance ((GTypeInstance *) self);
|
||||
}
|
||||
|
||||
g_free (self);
|
||||
static void
|
||||
gsk_render_node_real_draw (GskRenderNode *node,
|
||||
cairo_t *cr)
|
||||
{
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_render_node_real_can_diff (const GskRenderNode *node1,
|
||||
const GskRenderNode *node2)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_render_node_real_diff (GskRenderNode *node1,
|
||||
GskRenderNode *node2,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_render_node_class_init (GskRenderNodeClass *klass)
|
||||
{
|
||||
klass->node_type = GSK_NOT_A_RENDER_NODE;
|
||||
klass->finalize = gsk_render_node_finalize;
|
||||
klass->draw = gsk_render_node_real_draw;
|
||||
klass->can_diff = gsk_render_node_real_can_diff;
|
||||
klass->diff = gsk_render_node_real_diff;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_render_node_init (GskRenderNode *self)
|
||||
{
|
||||
g_atomic_ref_count_init (&self->ref_count);
|
||||
}
|
||||
|
||||
GType
|
||||
gsk_render_node_get_type (void)
|
||||
{
|
||||
static volatile gsize render_node_type__volatile;
|
||||
|
||||
if (g_once_init_enter (&render_node_type__volatile))
|
||||
{
|
||||
static const GTypeFundamentalInfo finfo = {
|
||||
(G_TYPE_FLAG_CLASSED |
|
||||
G_TYPE_FLAG_INSTANTIATABLE |
|
||||
G_TYPE_FLAG_DERIVABLE |
|
||||
G_TYPE_FLAG_DEEP_DERIVABLE),
|
||||
};
|
||||
|
||||
static const GTypeValueTable value_table = {
|
||||
value_render_node_init,
|
||||
value_render_node_free_value,
|
||||
value_render_node_copy_value,
|
||||
value_render_node_peek_pointer,
|
||||
"p",
|
||||
value_render_node_collect_value,
|
||||
"p",
|
||||
value_render_node_lcopy_value,
|
||||
};
|
||||
|
||||
const GTypeInfo node_info = {
|
||||
/* Class */
|
||||
sizeof (GskRenderNodeClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gsk_render_node_class_init,
|
||||
(GClassFinalizeFunc) NULL,
|
||||
NULL,
|
||||
|
||||
/* Instance */
|
||||
sizeof (GskRenderNode),
|
||||
0,
|
||||
(GInstanceInitFunc) gsk_render_node_init,
|
||||
|
||||
/* GValue */
|
||||
&value_table,
|
||||
};
|
||||
|
||||
GType render_node_type =
|
||||
g_type_register_fundamental (g_type_fundamental_next (),
|
||||
g_intern_static_string ("GskRenderNode"),
|
||||
&node_info, &finfo,
|
||||
G_TYPE_FLAG_ABSTRACT);
|
||||
|
||||
g_once_init_leave (&render_node_type__volatile, render_node_type);
|
||||
}
|
||||
|
||||
return render_node_type__volatile;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GskRenderNodeType node_type;
|
||||
|
||||
void (* finalize) (GskRenderNode *node);
|
||||
void (* draw) (GskRenderNode *node,
|
||||
cairo_t *cr);
|
||||
gboolean (* can_diff) (const GskRenderNode *node1,
|
||||
const GskRenderNode *node2);
|
||||
void (* diff) (GskRenderNode *node1,
|
||||
GskRenderNode *node2,
|
||||
cairo_region_t *region);
|
||||
} RenderNodeClassData;
|
||||
|
||||
static void
|
||||
gsk_render_node_generic_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
{
|
||||
GskRenderNodeClass *node_class = g_class;
|
||||
RenderNodeClassData *node_data = class_data;
|
||||
|
||||
/* Mandatory */
|
||||
node_class->node_type = node_data->node_type;
|
||||
|
||||
/* Optional */
|
||||
if (node_data->finalize != NULL)
|
||||
node_class->finalize = node_data->finalize;
|
||||
if (node_data->can_diff != NULL)
|
||||
node_class->can_diff = node_data->can_diff;
|
||||
|
||||
/* Mandatory */
|
||||
node_class->draw = node_data->draw;
|
||||
node_class->diff = node_data->diff;
|
||||
|
||||
g_free (node_data);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_render_node_can_diff_true (const GskRenderNode *node1,
|
||||
const GskRenderNode *node2)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gsk_render_node_new:
|
||||
* @node_class: class structure for this node
|
||||
* gsk_render_node_type_register_static:
|
||||
* @node_name: the name of the node
|
||||
* @node_info: type information of the node
|
||||
*
|
||||
* Returns: (transfer full): the newly created #GskRenderNode
|
||||
* Registers a new #GskRenderNode type for the given @node_name using
|
||||
* the type information in @node_info.
|
||||
*
|
||||
* Returns: the newly registered GType
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_render_node_new (const GskRenderNodeClass *node_class, gsize extra_size)
|
||||
GType
|
||||
gsk_render_node_type_register_static (const char *node_name,
|
||||
const GskRenderNodeTypeInfo *node_info)
|
||||
{
|
||||
GskRenderNode *self;
|
||||
GTypeInfo info;
|
||||
|
||||
g_return_val_if_fail (node_class != NULL, NULL);
|
||||
g_return_val_if_fail (node_class->node_type != GSK_NOT_A_RENDER_NODE, NULL);
|
||||
info.class_size = sizeof (GskRenderNodeClass);
|
||||
info.base_init = NULL;
|
||||
info.base_finalize = NULL;
|
||||
info.class_init = gsk_render_node_generic_class_init;
|
||||
info.class_finalize = NULL;
|
||||
|
||||
self = g_malloc0 (node_class->struct_size + extra_size);
|
||||
/* Avoid having a class_init() and a class struct for every GskRenderNode,
|
||||
* by passing the various virtual functions and class data when initializing
|
||||
* the base class
|
||||
*/
|
||||
info.class_data = g_new (RenderNodeClassData, 1);
|
||||
((RenderNodeClassData *) info.class_data)->node_type = node_info->node_type;
|
||||
((RenderNodeClassData *) info.class_data)->finalize = node_info->finalize;
|
||||
((RenderNodeClassData *) info.class_data)->draw = node_info->draw;
|
||||
((RenderNodeClassData *) info.class_data)->can_diff = node_info->can_diff != NULL
|
||||
? node_info->can_diff
|
||||
: gsk_render_node_can_diff_true;
|
||||
((RenderNodeClassData *) info.class_data)->diff = node_info->diff != NULL
|
||||
? node_info->diff
|
||||
: gsk_render_node_diff_impossible;
|
||||
|
||||
self->node_class = node_class;
|
||||
info.instance_size = node_info->instance_size;
|
||||
info.n_preallocs = 0;
|
||||
info.instance_init = (GInstanceInitFunc) node_info->instance_init;
|
||||
info.value_table = NULL;
|
||||
|
||||
self->ref_count = 1;
|
||||
return g_type_register_static (GSK_TYPE_RENDER_NODE, node_name, &info, 0);
|
||||
}
|
||||
|
||||
return self;
|
||||
/*< private >
|
||||
* gsk_render_node_alloc:
|
||||
* @node_type: the #GskRenderNodeType to instantiate
|
||||
*
|
||||
* Instantiates a new #GskRenderNode for the given @node_type.
|
||||
*
|
||||
* Returns: (transfer full) (type GskRenderNode): the newly created #GskRenderNode
|
||||
*/
|
||||
gpointer
|
||||
gsk_render_node_alloc (GskRenderNodeType node_type)
|
||||
{
|
||||
g_return_val_if_fail (node_type > GSK_NOT_A_RENDER_NODE, NULL);
|
||||
g_return_val_if_fail (node_type < GSK_RENDER_NODE_TYPE_N_TYPES, NULL);
|
||||
|
||||
g_assert (gsk_render_node_types[node_type] != G_TYPE_INVALID);
|
||||
return g_type_create_instance (gsk_render_node_types[node_type]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +356,7 @@ gsk_render_node_ref (GskRenderNode *node)
|
||||
{
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE (node), NULL);
|
||||
|
||||
g_atomic_int_inc (&node->ref_count);
|
||||
g_atomic_ref_count_inc (&node->ref_count);
|
||||
|
||||
return node;
|
||||
}
|
||||
@@ -125,10 +375,11 @@ gsk_render_node_unref (GskRenderNode *node)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_RENDER_NODE (node));
|
||||
|
||||
if (g_atomic_int_dec_and_test (&node->ref_count))
|
||||
gsk_render_node_finalize (node);
|
||||
if (g_atomic_ref_count_dec (&node->ref_count))
|
||||
GSK_RENDER_NODE_GET_CLASS (node)->finalize (node);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gsk_render_node_get_node_type:
|
||||
* @node: a #GskRenderNode
|
||||
@@ -142,14 +393,14 @@ gsk_render_node_get_node_type (GskRenderNode *node)
|
||||
{
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE (node), GSK_NOT_A_RENDER_NODE);
|
||||
|
||||
return node->node_class->node_type;
|
||||
return GSK_RENDER_NODE_GET_CLASS (node)->node_type;
|
||||
}
|
||||
|
||||
G_GNUC_PURE static inline
|
||||
GskRenderNodeType
|
||||
_gsk_render_node_get_node_type (const GskRenderNode *node)
|
||||
{
|
||||
return node->node_class->node_type;
|
||||
return GSK_RENDER_NODE_GET_CLASS (node)->node_type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,9 +446,10 @@ gsk_render_node_draw (GskRenderNode *node,
|
||||
cairo_save (cr);
|
||||
|
||||
GSK_NOTE (CAIRO, g_message ("Rendering node %s[%p]",
|
||||
node->node_class->type_name, node));
|
||||
g_type_name_from_instance ((GTypeInstance *) node),
|
||||
node));
|
||||
|
||||
node->node_class->draw (node, cr);
|
||||
GSK_RENDER_NODE_GET_CLASS (node)->draw (node, cr);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GSK_DEBUG_CHECK (GEOMETRY))
|
||||
@@ -216,7 +468,7 @@ gsk_render_node_draw (GskRenderNode *node,
|
||||
if (cairo_status (cr))
|
||||
{
|
||||
g_warning ("drawing failure for render node %s: %s",
|
||||
node->node_class->type_name,
|
||||
g_type_name_from_instance ((GTypeInstance *) node),
|
||||
cairo_status_to_string (cairo_status (cr)));
|
||||
}
|
||||
}
|
||||
@@ -245,7 +497,7 @@ gsk_render_node_can_diff (const GskRenderNode *node1,
|
||||
if (_gsk_render_node_get_node_type (node1) != _gsk_render_node_get_node_type (node2))
|
||||
return FALSE;
|
||||
|
||||
return node1->node_class->can_diff (node1, node2);
|
||||
return GSK_RENDER_NODE_GET_CLASS (node1)->can_diff (node1, node2);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -299,7 +551,7 @@ gsk_render_node_diff (GskRenderNode *node1,
|
||||
if (_gsk_render_node_get_node_type (node1) != _gsk_render_node_get_node_type (node2))
|
||||
return gsk_render_node_diff_impossible (node1, node2, region);
|
||||
|
||||
return node1->node_class->diff (node1, node2, region);
|
||||
return GSK_RENDER_NODE_GET_CLASS (node1)->diff (node1, node2, region);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+90
-4
@@ -99,6 +99,52 @@ GskRenderNode * gsk_render_node_deserialize (GBytes
|
||||
GskParseErrorFunc error_func,
|
||||
gpointer user_data);
|
||||
|
||||
#define GSK_TYPE_DEBUG_NODE (gsk_debug_node_get_type())
|
||||
#define GSK_TYPE_COLOR_NODE (gsk_color_node_get_type())
|
||||
#define GSK_TYPE_TEXTURE_NODE (gsk_texture_node_get_type())
|
||||
#define GSK_TYPE_LINEAR_GRADIENT_NODE (gsk_linear_gradient_node_get_type())
|
||||
#define GSK_TYPE_REPEATING_LINEAR_GRADIENT_NODE (gsk_repeating_linear_gradient_node_get_type())
|
||||
#define GSK_TYPE_BORDER_NODE (gsk_border_node_get_type())
|
||||
#define GSK_TYPE_INSET_SHADOW_NODE (gsk_inset_shadow_node_get_type())
|
||||
#define GSK_TYPE_OUTSET_SHADOW_NODE (gsk_outset_shadow_node_get_type())
|
||||
#define GSK_TYPE_CAIRO_NODE (gsk_cairo_node_get_type())
|
||||
#define GSK_TYPE_CONTAINER_NODE (gsk_container_node_get_type())
|
||||
#define GSK_TYPE_TRANSFORM_NODE (gsk_transform_node_get_type())
|
||||
#define GSK_TYPE_OPACITY_NODE (gsk_opacity_node_get_type())
|
||||
#define GSK_TYPE_COLOR_MATRIX_NODE (gsk_color_matrix_node_get_type())
|
||||
#define GSK_TYPE_REPEAT_NODE (gsk_repeat_node_get_type())
|
||||
#define GSK_TYPE_CLIP_NODE (gsk_clip_node_get_type())
|
||||
#define GSK_TYPE_ROUNDED_CLIP_NODE (gsk_rounded_clip_node_get_type())
|
||||
#define GSK_TYPE_SHADOW_NODE (gsk_shadow_node_get_type())
|
||||
#define GSK_TYPE_BLEND_NODE (gsk_blend_node_get_type())
|
||||
#define GSK_TYPE_CROSS_FADE_NODE (gsk_cross_fade_node_get_type())
|
||||
#define GSK_TYPE_TEXT_NODE (gsk_text_node_get_type())
|
||||
#define GSK_TYPE_BLUR_NODE (gsk_blur_node_get_type())
|
||||
|
||||
typedef struct _GskDebugNode GskDebugNode;
|
||||
typedef struct _GskColorNode GskColorNode;
|
||||
typedef struct _GskTextureNode GskTextureNode;
|
||||
typedef struct _GskLinearGradientNode GskLinearGradientNode;
|
||||
typedef struct _GskRepeatingLinearGradientNode GskRepeatingLinearGradientNode;
|
||||
typedef struct _GskBorderNode GskBorderNode;
|
||||
typedef struct _GskInsetShadowNode GskInsetShadowNode;
|
||||
typedef struct _GskOutsetShadowNode GskOutsetShadowNode;
|
||||
typedef struct _GskCairoNode GskCairoNode;
|
||||
typedef struct _GskContainerNode GskContainerNode;
|
||||
typedef struct _GskTransformNode GskTransformNode;
|
||||
typedef struct _GskOpacityNode GskOpacityNode;
|
||||
typedef struct _GskColorMatrixNode GskColorMatrixNode;
|
||||
typedef struct _GskRepeatNode GskRepeatNode;
|
||||
typedef struct _GskClipNode GskClipNode;
|
||||
typedef struct _GskRoundedClipNode GskRoundedClipNode;
|
||||
typedef struct _GskShadowNode GskShadowNode;
|
||||
typedef struct _GskBlendNode GskBlendNode;
|
||||
typedef struct _GskCrossFadeNode GskCrossFadeNode;
|
||||
typedef struct _GskTextNode GskTextNode;
|
||||
typedef struct _GskBlurNode GskBlurNode;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_debug_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_debug_node_new (GskRenderNode *child,
|
||||
char *message);
|
||||
@@ -107,18 +153,24 @@ GskRenderNode * gsk_debug_node_get_child (GskRenderNode
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const char * gsk_debug_node_get_message (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_color_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_color_node_new (const GdkRGBA *rgba,
|
||||
const graphene_rect_t *bounds);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GdkRGBA * gsk_color_node_peek_color (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_texture_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_texture_node_new (GdkTexture *texture,
|
||||
const graphene_rect_t *bounds);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkTexture * gsk_texture_node_get_texture (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_linear_gradient_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_linear_gradient_node_new (const graphene_rect_t *bounds,
|
||||
const graphene_point_t *start,
|
||||
@@ -132,8 +184,11 @@ const graphene_point_t * gsk_linear_gradient_node_peek_end (GskRenderNo
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gsize gsk_linear_gradient_node_get_n_color_stops (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GskColorStop * gsk_linear_gradient_node_peek_color_stops (GskRenderNode *node);
|
||||
const GskColorStop * gsk_linear_gradient_node_peek_color_stops (GskRenderNode *node,
|
||||
gsize *n_stops);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_repeating_linear_gradient_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_repeating_linear_gradient_node_new (const graphene_rect_t *bounds,
|
||||
const graphene_point_t *start,
|
||||
@@ -141,6 +196,8 @@ GskRenderNode * gsk_repeating_linear_gradient_node_new (const graph
|
||||
const GskColorStop *color_stops,
|
||||
gsize n_color_stops);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_border_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_border_node_new (const GskRoundedRect *outline,
|
||||
const float border_width[4],
|
||||
@@ -152,7 +209,8 @@ const float * gsk_border_node_peek_widths (GskRenderNode
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GdkRGBA * gsk_border_node_peek_colors (GskRenderNode *node);
|
||||
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_inset_shadow_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_inset_shadow_node_new (const GskRoundedRect *outline,
|
||||
const GdkRGBA *color,
|
||||
@@ -173,6 +231,8 @@ float gsk_inset_shadow_node_get_spread (GskRenderNode
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_inset_shadow_node_get_blur_radius (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_outset_shadow_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_outset_shadow_node_new (const GskRoundedRect *outline,
|
||||
const GdkRGBA *color,
|
||||
@@ -193,6 +253,8 @@ float gsk_outset_shadow_node_get_spread (GskRenderNode
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_outset_shadow_node_get_blur_radius (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_cairo_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_cairo_node_new (const graphene_rect_t *bounds);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
@@ -200,6 +262,8 @@ cairo_t * gsk_cairo_node_get_draw_context (GskRenderNode
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
cairo_surface_t * gsk_cairo_node_peek_surface (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_container_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_container_node_new (GskRenderNode **children,
|
||||
guint n_children);
|
||||
@@ -209,6 +273,8 @@ GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_container_node_get_child (GskRenderNode *node,
|
||||
guint idx);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_transform_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_transform_node_new (GskRenderNode *child,
|
||||
GskTransform *transform);
|
||||
@@ -217,6 +283,8 @@ GskRenderNode * gsk_transform_node_get_child (GskRenderNode
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskTransform * gsk_transform_node_get_transform (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_opacity_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_opacity_node_new (GskRenderNode *child,
|
||||
float opacity);
|
||||
@@ -225,6 +293,8 @@ GskRenderNode * gsk_opacity_node_get_child (GskRenderNode
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_opacity_node_get_opacity (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_color_matrix_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_color_matrix_node_new (GskRenderNode *child,
|
||||
const graphene_matrix_t *color_matrix,
|
||||
@@ -237,6 +307,8 @@ const graphene_matrix_t *
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const graphene_vec4_t * gsk_color_matrix_node_peek_color_offset (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_repeat_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_repeat_node_new (const graphene_rect_t *bounds,
|
||||
GskRenderNode *child,
|
||||
@@ -246,6 +318,8 @@ GskRenderNode * gsk_repeat_node_get_child (GskRenderNode
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const graphene_rect_t * gsk_repeat_node_peek_child_bounds (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_clip_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_clip_node_new (GskRenderNode *child,
|
||||
const graphene_rect_t *clip);
|
||||
@@ -254,7 +328,8 @@ GskRenderNode * gsk_clip_node_get_child (GskRenderNode
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const graphene_rect_t * gsk_clip_node_peek_clip (GskRenderNode *node);
|
||||
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_rounded_clip_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_rounded_clip_node_new (GskRenderNode *child,
|
||||
const GskRoundedRect *clip);
|
||||
@@ -263,6 +338,8 @@ GskRenderNode * gsk_rounded_clip_node_get_child (GskRenderNode
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GskRoundedRect * gsk_rounded_clip_node_peek_clip (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_shadow_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_shadow_node_new (GskRenderNode *child,
|
||||
const GskShadow *shadows,
|
||||
@@ -275,6 +352,8 @@ const GskShadow * gsk_shadow_node_peek_shadow (GskRenderNode
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gsize gsk_shadow_node_get_n_shadows (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_blend_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_blend_node_new (GskRenderNode *bottom,
|
||||
GskRenderNode *top,
|
||||
@@ -286,6 +365,8 @@ GskRenderNode * gsk_blend_node_get_top_child (GskRenderNode
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskBlendMode gsk_blend_node_get_blend_mode (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_cross_fade_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_cross_fade_node_new (GskRenderNode *start,
|
||||
GskRenderNode *end,
|
||||
@@ -297,6 +378,8 @@ GskRenderNode * gsk_cross_fade_node_get_end_child (GskRenderNode
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_cross_fade_node_get_progress (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_text_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_text_node_new (PangoFont *font,
|
||||
PangoGlyphString *glyphs,
|
||||
@@ -308,12 +391,15 @@ gboolean gsk_text_node_has_color_glyphs (GskRenderNode
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
guint gsk_text_node_get_num_glyphs (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const PangoGlyphInfo *gsk_text_node_peek_glyphs (GskRenderNode *node);
|
||||
const PangoGlyphInfo *gsk_text_node_peek_glyphs (GskRenderNode *node,
|
||||
guint *n_glyphs);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GdkRGBA * gsk_text_node_peek_color (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const graphene_point_t *gsk_text_node_get_offset (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_blur_node_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_blur_node_new (GskRenderNode *child,
|
||||
float radius);
|
||||
|
||||
+1108
-547
File diff suppressed because it is too large
Load Diff
@@ -1973,9 +1973,9 @@ render_node_print (Printer *p,
|
||||
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
|
||||
case GSK_LINEAR_GRADIENT_NODE:
|
||||
{
|
||||
const guint n_stops = gsk_linear_gradient_node_get_n_color_stops (node);
|
||||
const GskColorStop *stops = gsk_linear_gradient_node_peek_color_stops (node);
|
||||
int i;
|
||||
const gsize n_stops = gsk_linear_gradient_node_get_n_color_stops (node);
|
||||
const GskColorStop *stops = gsk_linear_gradient_node_peek_color_stops (node, NULL);
|
||||
gsize i;
|
||||
|
||||
if (gsk_render_node_get_node_type (node) == GSK_REPEATING_LINEAR_GRADIENT_NODE)
|
||||
start_node (p, "repeating-linear-gradient");
|
||||
@@ -2229,7 +2229,7 @@ render_node_print (Printer *p,
|
||||
case GSK_TEXT_NODE:
|
||||
{
|
||||
const guint n_glyphs = gsk_text_node_get_num_glyphs (node);
|
||||
const PangoGlyphInfo *glyphs = gsk_text_node_peek_glyphs (node);
|
||||
const PangoGlyphInfo *glyphs = gsk_text_node_peek_glyphs (node, NULL);
|
||||
const graphene_point_t *offset = gsk_text_node_get_offset (node);
|
||||
const GdkRGBA *color = gsk_text_node_peek_color (node);
|
||||
PangoFont *font = gsk_text_node_peek_font (node);
|
||||
@@ -2449,7 +2449,7 @@ render_node_print (Printer *p,
|
||||
break;
|
||||
|
||||
default:
|
||||
g_error ("Unhandled node: %s", node->node_class->type_name);
|
||||
g_error ("Unhandled node: %s", g_type_name_from_instance ((GTypeInstance *) node));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+61
-15
@@ -8,22 +8,32 @@ G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GskRenderNodeClass GskRenderNodeClass;
|
||||
|
||||
#define GSK_IS_RENDER_NODE_TYPE(node,type) (GSK_IS_RENDER_NODE (node) && (node)->node_class->node_type == (type))
|
||||
/* Keep this in sync with the GskRenderNodeType enumeration.
|
||||
*
|
||||
* We don't add an "n-types" value to avoid having to handle
|
||||
* it in every single switch.
|
||||
*/
|
||||
#define GSK_RENDER_NODE_TYPE_N_TYPES (GSK_DEBUG_NODE + 1)
|
||||
|
||||
extern GType gsk_render_node_types[];
|
||||
|
||||
#define GSK_IS_RENDER_NODE_TYPE(node,type) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((node), GSK_TYPE_RENDER_NODE, GskRenderNodeClass)->node_type == (type))
|
||||
|
||||
struct _GskRenderNode
|
||||
{
|
||||
const GskRenderNodeClass *node_class;
|
||||
GTypeInstance parent_instance;
|
||||
|
||||
volatile int ref_count;
|
||||
gatomicrefcount ref_count;
|
||||
|
||||
graphene_rect_t bounds;
|
||||
};
|
||||
|
||||
struct _GskRenderNodeClass
|
||||
{
|
||||
GTypeClass parent_class;
|
||||
|
||||
GskRenderNodeType node_type;
|
||||
gsize struct_size;
|
||||
const char *type_name;
|
||||
|
||||
void (* finalize) (GskRenderNode *node);
|
||||
void (* draw) (GskRenderNode *node,
|
||||
@@ -35,18 +45,54 @@ struct _GskRenderNodeClass
|
||||
cairo_region_t *region);
|
||||
};
|
||||
|
||||
GskRenderNode * gsk_render_node_new (const GskRenderNodeClass *node_class,
|
||||
gsize extra_size);
|
||||
/*< private >
|
||||
* GskRenderNodeTypeInfo:
|
||||
* @node_type: the render node type in the #GskRenderNodeType enumeration
|
||||
* @instance_size: the size of the render node instance
|
||||
* @instance_init: (nullable): the instance initialization function
|
||||
* @finalize: (nullable): the instance finalization function; must chain up to the
|
||||
* implementation of the parent class
|
||||
* @draw: the function called by gsk_render_node_draw()
|
||||
* @can_diff: (nullable): the function called by gsk_render_node_can_diff(); if
|
||||
* unset, gsk_render_node_can_diff_true() will be used
|
||||
* @diff: (nullable): the function called by gsk_render_node_diff(); if unset,
|
||||
* gsk_render_node_diff_impossible() will be used
|
||||
*
|
||||
* A struction that contains the type information for a #GskRenderNode subclass,
|
||||
* to be used by gsk_render_node_type_register_static().
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
GskRenderNodeType node_type;
|
||||
|
||||
gboolean gsk_render_node_can_diff (const GskRenderNode *node1,
|
||||
const GskRenderNode *node2) G_GNUC_PURE;
|
||||
void gsk_render_node_diff (GskRenderNode *node1,
|
||||
GskRenderNode *node2,
|
||||
cairo_region_t *region);
|
||||
void gsk_render_node_diff_impossible (GskRenderNode *node1,
|
||||
GskRenderNode *node2,
|
||||
cairo_region_t *region);
|
||||
gsize instance_size;
|
||||
|
||||
void (* instance_init) (GskRenderNode *node);
|
||||
void (* finalize) (GskRenderNode *node);
|
||||
void (* draw) (GskRenderNode *node,
|
||||
cairo_t *cr);
|
||||
gboolean (* can_diff) (const GskRenderNode *node1,
|
||||
const GskRenderNode *node2);
|
||||
void (* diff) (GskRenderNode *node1,
|
||||
GskRenderNode *node2,
|
||||
cairo_region_t *region);
|
||||
} GskRenderNodeTypeInfo;
|
||||
|
||||
void gsk_render_node_init_types (void);
|
||||
|
||||
GType gsk_render_node_type_register_static (const char *node_name,
|
||||
const GskRenderNodeTypeInfo *node_info);
|
||||
|
||||
gpointer gsk_render_node_alloc (GskRenderNodeType node_type);
|
||||
|
||||
gboolean gsk_render_node_can_diff (const GskRenderNode *node1,
|
||||
const GskRenderNode *node2) G_GNUC_PURE;
|
||||
void gsk_render_node_diff (GskRenderNode *node1,
|
||||
GskRenderNode *node2,
|
||||
cairo_region_t *region);
|
||||
void gsk_render_node_diff_impossible (GskRenderNode *node1,
|
||||
GskRenderNode *node2,
|
||||
cairo_region_t *region);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -258,7 +258,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
|
||||
return;
|
||||
case GSK_SHADOW_NODE:
|
||||
default:
|
||||
FALLBACK ("Unsupported node '%s'", node->node_class->type_name);
|
||||
FALLBACK ("Unsupported node '%s'", g_type_name_from_instance ((GTypeInstance *) node));
|
||||
|
||||
case GSK_REPEAT_NODE:
|
||||
if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
|
||||
@@ -346,7 +346,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
|
||||
case GSK_TEXT_NODE:
|
||||
{
|
||||
const PangoFont *font = gsk_text_node_peek_font (node);
|
||||
const PangoGlyphInfo *glyphs = gsk_text_node_peek_glyphs (node);
|
||||
const PangoGlyphInfo *glyphs = gsk_text_node_peek_glyphs (node, NULL);
|
||||
guint num_glyphs = gsk_text_node_get_num_glyphs (node);
|
||||
gboolean has_color_glyphs = gsk_text_node_has_color_glyphs (node);
|
||||
int i;
|
||||
@@ -817,7 +817,7 @@ gsk_vulkan_render_pass_upload_fallback (GskVulkanRenderPass *self,
|
||||
g_message ("Upload op=%s, node %s[%p], bounds %gx%g",
|
||||
op->type == GSK_VULKAN_OP_FALLBACK_CLIP ? "fallback-clip" :
|
||||
(op->type == GSK_VULKAN_OP_FALLBACK_ROUNDED_CLIP ? "fallback-rounded-clip" : "fallback"),
|
||||
node->node_class->type_name, node,
|
||||
g_type_name_from_instance ((GTypeInstance *) node), node,
|
||||
ceil (node->bounds.size.width),
|
||||
ceil (node->bounds.size.height)));
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
@@ -1195,7 +1195,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
||||
&op->text.node->bounds,
|
||||
(PangoFont *)gsk_text_node_peek_font (op->text.node),
|
||||
gsk_text_node_get_num_glyphs (op->text.node),
|
||||
gsk_text_node_peek_glyphs (op->text.node),
|
||||
gsk_text_node_peek_glyphs (op->text.node, NULL),
|
||||
gsk_text_node_peek_color (op->text.node),
|
||||
gsk_text_node_get_offset (op->text.node),
|
||||
op->text.start_glyph,
|
||||
@@ -1214,7 +1214,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
||||
&op->text.node->bounds,
|
||||
(PangoFont *)gsk_text_node_peek_font (op->text.node),
|
||||
gsk_text_node_get_num_glyphs (op->text.node),
|
||||
gsk_text_node_peek_glyphs (op->text.node),
|
||||
gsk_text_node_peek_glyphs (op->text.node, NULL),
|
||||
gsk_text_node_get_offset (op->text.node),
|
||||
op->text.start_glyph,
|
||||
op->text.num_glyphs,
|
||||
@@ -1244,7 +1244,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
||||
gsk_linear_gradient_node_peek_end (op->render.node),
|
||||
gsk_render_node_get_node_type (op->render.node) == GSK_REPEATING_LINEAR_GRADIENT_NODE,
|
||||
gsk_linear_gradient_node_get_n_color_stops (op->render.node),
|
||||
gsk_linear_gradient_node_peek_color_stops (op->render.node));
|
||||
gsk_linear_gradient_node_peek_color_stops (op->render.node, NULL));
|
||||
n_bytes += op->render.vertex_count;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
static void atk_action_interface_init (AtkActionIface *iface);
|
||||
static void atk_value_interface_init (AtkValueIface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkScaleButtonAccessible, gtk_scale_button_accessible, GTK_TYPE_BUTTON_ACCESSIBLE,
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkScaleButtonAccessible, gtk_scale_button_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
|
||||
G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init)
|
||||
G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init));
|
||||
|
||||
|
||||
@@ -39,14 +39,14 @@ typedef struct _GtkScaleButtonAccessiblePrivate GtkScaleButtonAccessiblePrivate;
|
||||
|
||||
struct _GtkScaleButtonAccessible
|
||||
{
|
||||
GtkButtonAccessible parent;
|
||||
GtkWidgetAccessible parent;
|
||||
|
||||
GtkScaleButtonAccessiblePrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkScaleButtonAccessibleClass
|
||||
{
|
||||
GtkButtonAccessibleClass parent_class;
|
||||
GtkWidgetAccessibleClass parent_class;
|
||||
};
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#include <gdk/x11/gdkx.h>
|
||||
#endif
|
||||
|
||||
#include "gtktreeprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#include <gdk/x11/gdkx.h>
|
||||
#endif
|
||||
#include "gtkwidgetaccessibleprivate.h"
|
||||
#include "gtknotebookpageaccessible.h"
|
||||
|
||||
@@ -296,6 +293,36 @@ gtk_widget_accessible_ref_relation_set (AtkObject *obj)
|
||||
return relation_set;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
takes_focus (GtkWidget *widget)
|
||||
{
|
||||
if (GTK_IS_NOTEBOOK (widget) ||
|
||||
GTK_IS_BUTTON (widget))
|
||||
return TRUE;
|
||||
|
||||
if (GTK_IS_ACCEL_LABEL (widget) ||
|
||||
GTK_IS_CONTAINER(widget) ||
|
||||
GTK_IS_DRAG_ICON (widget) ||
|
||||
GTK_IS_DRAWING_AREA (widget) ||
|
||||
GTK_IS_GL_AREA (widget) ||
|
||||
GTK_IS_IMAGE (widget) ||
|
||||
GTK_IS_LEVEL_BAR (widget) ||
|
||||
GTK_IS_MEDIA_CONTROLS (widget) ||
|
||||
GTK_IS_PICTURE (widget) ||
|
||||
GTK_IS_PROGRESS_BAR (widget) ||
|
||||
GTK_IS_SCROLLBAR (widget) ||
|
||||
GTK_IS_SEPARATOR (widget) ||
|
||||
GTK_IS_SHORTCUT_LABEL (widget) ||
|
||||
GTK_IS_SHORTCUTS_SHORTCUT (widget) ||
|
||||
GTK_IS_SPINNER (widget) ||
|
||||
GTK_IS_STACK_SIDEBAR (widget) ||
|
||||
GTK_IS_STATUSBAR (widget) ||
|
||||
GTK_IS_VIDEO (widget))
|
||||
return FALSE;
|
||||
|
||||
return gtk_widget_get_can_focus (widget);
|
||||
}
|
||||
|
||||
static AtkStateSet *
|
||||
gtk_widget_accessible_ref_state_set (AtkObject *accessible)
|
||||
{
|
||||
@@ -315,7 +342,7 @@ gtk_widget_accessible_ref_state_set (AtkObject *accessible)
|
||||
atk_state_set_add_state (state_set, ATK_STATE_ENABLED);
|
||||
}
|
||||
|
||||
if (gtk_widget_get_can_focus (widget))
|
||||
if (takes_focus (widget))
|
||||
{
|
||||
atk_state_set_add_state (state_set, ATK_STATE_FOCUSABLE);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ def get_files(subdir,extension):
|
||||
xml += '''
|
||||
<file>theme/Empty/gtk.css</file>
|
||||
<file>theme/Adwaita/gtk.css</file>
|
||||
<file>theme/Adwaita/gtk-dark.css</file>
|
||||
<file alias='theme/Adwaita-dark/gtk.css'>theme/Adwaita/gtk-dark.css</file>
|
||||
<file>theme/Adwaita/Adwaita.css</file>
|
||||
<file>theme/Adwaita/Adwaita-dark.css</file>
|
||||
'''
|
||||
|
||||
+30
-8
@@ -43,28 +43,50 @@ for filename in in_files:
|
||||
for line in f:
|
||||
line = line.rstrip('\n').rstrip('\r')
|
||||
# print line
|
||||
match = re.search(r'\bg[tds]k_[a-zA-Z0-9_]*_get_type\b', line)
|
||||
match = re.search(r'\bg[dst]k_[a-zA-Z0-9_]*_get_type\b', line)
|
||||
if match:
|
||||
func = match.group(0)
|
||||
if not func in funcs:
|
||||
funcs.append(func)
|
||||
if debug: print ('Found ', func)
|
||||
|
||||
file_output = 'G_GNUC_BEGIN_IGNORE_DEPRECATIONS\n'
|
||||
file_output = ['G_GNUC_BEGIN_IGNORE_DEPRECATIONS']
|
||||
|
||||
funcs = sorted(funcs)
|
||||
|
||||
for f in funcs:
|
||||
if f.startswith('gdk_x11') or f.startswith('gtk_socket') or f.startswith('gtk_plug'):
|
||||
file_output += '#ifdef GDK_WINDOWING_X11\n'
|
||||
file_output += '*tp++ = {0}();\n'.format(f)
|
||||
file_output += '#endif\n'
|
||||
if f.startswith('gdk_x11'):
|
||||
file_output += ['#ifdef GDK_WINDOWING_X11']
|
||||
file_output += ['*tp++ = {0}();'.format(f)]
|
||||
file_output += ['#endif']
|
||||
elif f.startswith('gdk_broadway') or f.startswith('gsk_broadway'):
|
||||
file_output += ['#ifdef GDK_WINDOWING_BROADWAY']
|
||||
file_output += ['*tp++ = {0}();'.format(f)]
|
||||
file_output += ['#endif']
|
||||
elif f.startswith('gdk_wayland'):
|
||||
file_output += ['#ifdef GDK_WINDOWING_WAYLAND']
|
||||
file_output += ['*tp++ = {0}();'.format(f)]
|
||||
file_output += ['#endif']
|
||||
elif f.startswith('gdk_win32'):
|
||||
file_output += ['#ifdef GDK_WINDOWING_WIN32']
|
||||
file_output += ['*tp++ = {0}();'.format(f)]
|
||||
file_output += ['#endif']
|
||||
elif f.startswith('gdk_quartz'):
|
||||
file_output += ['#ifdef GDK_WINDOWING_QUARTZ']
|
||||
file_output += ['*tp++ = {0}();'.format(f)]
|
||||
file_output += ['#endif']
|
||||
elif f.startswith('gsk_vulkan'):
|
||||
file_output += ['#ifdef GDK_RENDERING_VULKAN']
|
||||
file_output += ['*tp++ = {0}();'.format(f)]
|
||||
file_output += ['#endif']
|
||||
else:
|
||||
file_output += '*tp++ = {0}();\n'.format(f)
|
||||
file_output += ['*tp++ = {0}();'.format(f)]
|
||||
|
||||
file_output += ['G_GNUC_END_IGNORE_DEPRECATIONS']
|
||||
|
||||
if debug: print (len(funcs), 'functions')
|
||||
|
||||
tmp_file = out_file + '~'
|
||||
with open(tmp_file, 'w') as f:
|
||||
f.write(file_output)
|
||||
f.write('\n'.join(file_output))
|
||||
replace_if_changed(tmp_file, out_file)
|
||||
|
||||
@@ -230,6 +230,7 @@
|
||||
#include <gtk/gtktexttag.h>
|
||||
#include <gtk/gtktexttagtable.h>
|
||||
#include <gtk/gtktextview.h>
|
||||
#include <gtk/gtktheme.h>
|
||||
#include <gtk/gtktogglebutton.h>
|
||||
#include <gtk/gtktooltip.h>
|
||||
#include <gtk/gtktestutils.h>
|
||||
|
||||
+7
-27
@@ -77,7 +77,7 @@
|
||||
* All parts of the dialog are optional.
|
||||
*
|
||||
* About dialogs often contain links and email addresses. GtkAboutDialog
|
||||
* displays these as clickable links. By default, it calls gtk_show_uri_on_window()
|
||||
* displays these as clickable links. By default, it calls gtk_show_uri()
|
||||
* when a user clicks one. The behaviour can be overridden with the
|
||||
* #GtkAboutDialog::activate-link signal.
|
||||
*
|
||||
@@ -130,7 +130,10 @@ static const LicenseInfo gtk_license_info [] = {
|
||||
{ N_("GNU Lesser General Public License, version 2.1 only"), "https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html" },
|
||||
{ N_("GNU Lesser General Public License, version 3 only"), "https://www.gnu.org/licenses/lgpl-3.0.html" },
|
||||
{ N_("GNU Affero General Public License, version 3 or later"), "https://www.gnu.org/licenses/agpl-3.0.html" },
|
||||
{ N_("GNU Affero General Public License, version 3 only"), "https://www.gnu.org/licenses/agpl-3.0.html" }
|
||||
{ N_("GNU Affero General Public License, version 3 only"), "https://www.gnu.org/licenses/agpl-3.0.html" },
|
||||
{ N_("BSD 3-Clause License"), "https://opensource.org/licenses/BSD-3-Clause" },
|
||||
{ N_("Apache License, Version 2.0"), "https://opensource.org/licenses/Apache-2.0" },
|
||||
{ N_("Mozilla Public License 2.0"), "https://opensource.org/licenses/MPL-2.0" }
|
||||
};
|
||||
|
||||
typedef struct
|
||||
@@ -342,7 +345,7 @@ gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
|
||||
*
|
||||
* The signal which gets emitted to activate a URI.
|
||||
* Applications may connect to it to override the default behaviour,
|
||||
* which is to call gtk_show_uri_on_window().
|
||||
* which is to call gtk_show_uri().
|
||||
*
|
||||
* Returns: %TRUE if the link has been activated
|
||||
*/
|
||||
@@ -976,30 +979,7 @@ static gboolean
|
||||
gtk_about_dialog_activate_link (GtkAboutDialog *about,
|
||||
const gchar *uri)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!gtk_show_uri_on_window (GTK_WINDOW (about), uri, gtk_get_current_event_time (), &error))
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (about),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT |
|
||||
GTK_DIALOG_MODAL,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"%s", _("Could not show link"));
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
"%s", error->message);
|
||||
g_error_free (error);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
}
|
||||
|
||||
gtk_show_uri (GTK_WINDOW (about), uri, GDK_CURRENT_TIME);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,11 @@ typedef enum {
|
||||
GTK_LICENSE_LGPL_3_0_ONLY,
|
||||
|
||||
GTK_LICENSE_AGPL_3_0,
|
||||
GTK_LICENSE_AGPL_3_0_ONLY
|
||||
GTK_LICENSE_AGPL_3_0_ONLY,
|
||||
|
||||
GTK_LICENSE_BSD_3,
|
||||
GTK_LICENSE_APACHE_2_0,
|
||||
GTK_LICENSE_MPL_2_0
|
||||
} GtkLicense;
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -592,7 +592,7 @@ gtk_accelerator_name (guint accelerator_key,
|
||||
keyval_name = "";
|
||||
|
||||
saved_mods = accelerator_mods;
|
||||
l = 0;
|
||||
l = strlen (keyval_name);
|
||||
if (accelerator_mods & GDK_SHIFT_MASK)
|
||||
l += sizeof (text_shift) - 1;
|
||||
if (accelerator_mods & GDK_CONTROL_MASK)
|
||||
|
||||
@@ -128,6 +128,9 @@ gtk_accel_label_class_init (GtkAccelLabelClass *class)
|
||||
gobject_class->set_property = gtk_accel_label_set_property;
|
||||
gobject_class->get_property = gtk_accel_label_get_property;
|
||||
|
||||
widget_class->focus = gtk_widget_focus_none;
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_none;
|
||||
|
||||
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_ACCEL_LABEL);
|
||||
|
||||
props[PROP_LABEL] =
|
||||
|
||||
+138
-121
@@ -57,6 +57,7 @@
|
||||
#include "gtkcellrendererpixbuf.h"
|
||||
#include "gtkcellrenderertext.h"
|
||||
#include "gtkcombobox.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkdialog.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkmarshalers.h"
|
||||
@@ -65,6 +66,7 @@ enum {
|
||||
PROP_SHOW_DIALOG_ITEM = 1,
|
||||
PROP_SHOW_DEFAULT_ITEM,
|
||||
PROP_HEADING,
|
||||
PROP_MODAL,
|
||||
NUM_PROPERTIES,
|
||||
|
||||
PROP_CONTENT_TYPE = NUM_PROPERTIES
|
||||
@@ -108,6 +110,18 @@ typedef struct _GtkAppChooserButtonClass GtkAppChooserButtonClass;
|
||||
|
||||
struct _GtkAppChooserButton {
|
||||
GtkWidget parent_instance;
|
||||
|
||||
GtkWidget *combobox;
|
||||
GtkListStore *store;
|
||||
|
||||
gchar *content_type;
|
||||
gchar *heading;
|
||||
gint last_active;
|
||||
gboolean show_dialog_item;
|
||||
gboolean show_default_item;
|
||||
gboolean modal;
|
||||
|
||||
GHashTable *custom_item_names;
|
||||
};
|
||||
|
||||
struct _GtkAppChooserButtonClass {
|
||||
@@ -118,22 +132,7 @@ struct _GtkAppChooserButtonClass {
|
||||
const gchar *item_name);
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget *combobox;
|
||||
GtkListStore *store;
|
||||
|
||||
gchar *content_type;
|
||||
gchar *heading;
|
||||
gint last_active;
|
||||
gboolean show_dialog_item;
|
||||
gboolean show_default_item;
|
||||
|
||||
GHashTable *custom_item_names;
|
||||
} GtkAppChooserButtonPrivate;
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkAppChooserButton, gtk_app_chooser_button, GTK_TYPE_WIDGET,
|
||||
G_ADD_PRIVATE (GtkAppChooserButton)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_APP_CHOOSER,
|
||||
app_chooser_iface_init));
|
||||
|
||||
@@ -192,7 +191,6 @@ select_application_func_cb (GtkTreeModel *model,
|
||||
{
|
||||
SelectAppData *data = user_data;
|
||||
GtkAppChooserButton *self = data->self;
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GAppInfo *app_to_match = data->info;
|
||||
GAppInfo *app = NULL;
|
||||
gboolean custom;
|
||||
@@ -210,7 +208,7 @@ select_application_func_cb (GtkTreeModel *model,
|
||||
result = TRUE;
|
||||
else if (g_app_info_equal (app, app_to_match))
|
||||
{
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->combobox), iter);
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self->combobox), iter);
|
||||
result = TRUE;
|
||||
}
|
||||
else
|
||||
@@ -225,14 +223,13 @@ static void
|
||||
gtk_app_chooser_button_select_application (GtkAppChooserButton *self,
|
||||
GAppInfo *info)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
SelectAppData *data;
|
||||
|
||||
data = g_slice_new0 (SelectAppData);
|
||||
data->self = g_object_ref (self);
|
||||
data->info = g_object_ref (info);
|
||||
|
||||
gtk_tree_model_foreach (GTK_TREE_MODEL (priv->store),
|
||||
gtk_tree_model_foreach (GTK_TREE_MODEL (self->store),
|
||||
select_application_func_cb, data);
|
||||
|
||||
select_app_data_free (data);
|
||||
@@ -244,7 +241,6 @@ other_application_dialog_response_cb (GtkDialog *dialog,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserButton *self = user_data;
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GAppInfo *info;
|
||||
|
||||
if (response_id != GTK_RESPONSE_OK)
|
||||
@@ -252,7 +248,7 @@ other_application_dialog_response_cb (GtkDialog *dialog,
|
||||
/* reset the active item, otherwise we are stuck on
|
||||
* 'Other application…'
|
||||
*/
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (priv->combobox), priv->last_active);
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (self->combobox), self->last_active);
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
return;
|
||||
}
|
||||
@@ -271,16 +267,15 @@ other_application_dialog_response_cb (GtkDialog *dialog,
|
||||
static void
|
||||
other_application_item_activated_cb (GtkAppChooserButton *self)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkWidget *dialog, *widget;
|
||||
GtkRoot *root;
|
||||
|
||||
root = gtk_widget_get_root (GTK_WIDGET (self));
|
||||
dialog = gtk_app_chooser_dialog_new_for_content_type (GTK_WINDOW (root),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
priv->content_type);
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), gtk_window_get_modal (GTK_WINDOW (root)));
|
||||
gtk_app_chooser_dialog_set_heading (GTK_APP_CHOOSER_DIALOG (dialog), priv->heading);
|
||||
self->content_type);
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), self->modal | gtk_window_get_modal (GTK_WINDOW (root)));
|
||||
gtk_app_chooser_dialog_set_heading (GTK_APP_CHOOSER_DIALOG (dialog), self->heading);
|
||||
|
||||
widget = gtk_app_chooser_dialog_get_widget (GTK_APP_CHOOSER_DIALOG (dialog));
|
||||
g_object_set (widget,
|
||||
@@ -297,21 +292,20 @@ static void
|
||||
gtk_app_chooser_button_ensure_dialog_item (GtkAppChooserButton *self,
|
||||
GtkTreeIter *prev_iter)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkTreeIter iter, iter2;
|
||||
|
||||
if (!priv->show_dialog_item || !priv->content_type)
|
||||
if (!self->show_dialog_item || !self->content_type)
|
||||
return;
|
||||
|
||||
if (prev_iter == NULL)
|
||||
gtk_list_store_append (priv->store, &iter);
|
||||
gtk_list_store_append (self->store, &iter);
|
||||
else
|
||||
gtk_list_store_insert_after (priv->store, &iter, prev_iter);
|
||||
gtk_list_store_insert_after (self->store, &iter, prev_iter);
|
||||
|
||||
real_insert_separator (self, FALSE, &iter);
|
||||
iter2 = iter;
|
||||
|
||||
gtk_list_store_insert_after (priv->store, &iter, &iter2);
|
||||
gtk_list_store_insert_after (self->store, &iter, &iter2);
|
||||
real_insert_custom_item (self, CUSTOM_ITEM_OTHER_APP,
|
||||
_("Other application…"), NULL,
|
||||
FALSE, &iter);
|
||||
@@ -322,7 +316,6 @@ insert_one_application (GtkAppChooserButton *self,
|
||||
GAppInfo *app,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GIcon *icon;
|
||||
|
||||
icon = g_app_info_get_icon (app);
|
||||
@@ -332,7 +325,7 @@ insert_one_application (GtkAppChooserButton *self,
|
||||
else
|
||||
g_object_ref (icon);
|
||||
|
||||
gtk_list_store_set (priv->store, iter,
|
||||
gtk_list_store_set (self->store, iter,
|
||||
COLUMN_APP_INFO, app,
|
||||
COLUMN_LABEL, g_app_info_get_name (app),
|
||||
COLUMN_ICON, icon,
|
||||
@@ -345,26 +338,25 @@ insert_one_application (GtkAppChooserButton *self,
|
||||
static void
|
||||
gtk_app_chooser_button_populate (GtkAppChooserButton *self)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GList *recommended_apps = NULL, *l;
|
||||
GAppInfo *app, *default_app = NULL;
|
||||
GtkTreeIter iter, iter2;
|
||||
gboolean cycled_recommended;
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
if (priv->content_type)
|
||||
recommended_apps = g_app_info_get_recommended_for_type (priv->content_type);
|
||||
if (self->content_type)
|
||||
recommended_apps = g_app_info_get_recommended_for_type (self->content_type);
|
||||
#endif
|
||||
cycled_recommended = FALSE;
|
||||
|
||||
if (priv->show_default_item)
|
||||
if (self->show_default_item)
|
||||
{
|
||||
if (priv->content_type)
|
||||
default_app = g_app_info_get_default_for_type (priv->content_type, FALSE);
|
||||
if (self->content_type)
|
||||
default_app = g_app_info_get_default_for_type (self->content_type, FALSE);
|
||||
|
||||
if (default_app != NULL)
|
||||
{
|
||||
get_first_iter (priv->store, &iter);
|
||||
get_first_iter (self->store, &iter);
|
||||
cycled_recommended = TRUE;
|
||||
|
||||
insert_one_application (self, default_app, &iter);
|
||||
@@ -382,12 +374,12 @@ gtk_app_chooser_button_populate (GtkAppChooserButton *self)
|
||||
|
||||
if (cycled_recommended)
|
||||
{
|
||||
gtk_list_store_insert_after (priv->store, &iter2, &iter);
|
||||
gtk_list_store_insert_after (self->store, &iter2, &iter);
|
||||
iter = iter2;
|
||||
}
|
||||
else
|
||||
{
|
||||
get_first_iter (priv->store, &iter);
|
||||
get_first_iter (self->store, &iter);
|
||||
cycled_recommended = TRUE;
|
||||
}
|
||||
|
||||
@@ -402,22 +394,21 @@ gtk_app_chooser_button_populate (GtkAppChooserButton *self)
|
||||
else
|
||||
gtk_app_chooser_button_ensure_dialog_item (self, &iter);
|
||||
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (priv->combobox), 0);
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (self->combobox), 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_app_chooser_button_build_ui (GtkAppChooserButton *self)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkCellRenderer *cell;
|
||||
GtkCellArea *area;
|
||||
|
||||
gtk_combo_box_set_model (GTK_COMBO_BOX (priv->combobox),
|
||||
GTK_TREE_MODEL (priv->store));
|
||||
gtk_combo_box_set_model (GTK_COMBO_BOX (self->combobox),
|
||||
GTK_TREE_MODEL (self->store));
|
||||
|
||||
area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (priv->combobox));
|
||||
area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (self->combobox));
|
||||
|
||||
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (priv->combobox),
|
||||
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (self->combobox),
|
||||
row_separator_func, NULL, NULL);
|
||||
|
||||
cell = gtk_cell_renderer_pixbuf_new ();
|
||||
@@ -426,7 +417,7 @@ gtk_app_chooser_button_build_ui (GtkAppChooserButton *self)
|
||||
"expand", FALSE,
|
||||
"fixed-size", FALSE,
|
||||
NULL);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (priv->combobox), cell,
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (self->combobox), cell,
|
||||
"gicon", COLUMN_ICON,
|
||||
NULL);
|
||||
|
||||
@@ -435,7 +426,7 @@ gtk_app_chooser_button_build_ui (GtkAppChooserButton *self)
|
||||
"align", FALSE,
|
||||
"expand", TRUE,
|
||||
NULL);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (priv->combobox), cell,
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (self->combobox), cell,
|
||||
"text", COLUMN_LABEL,
|
||||
NULL);
|
||||
|
||||
@@ -445,12 +436,11 @@ gtk_app_chooser_button_build_ui (GtkAppChooserButton *self)
|
||||
static void
|
||||
gtk_app_chooser_button_remove_non_custom (GtkAppChooserButton *self)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gboolean custom, res;
|
||||
|
||||
model = GTK_TREE_MODEL (priv->store);
|
||||
model = GTK_TREE_MODEL (self->store);
|
||||
|
||||
if (!gtk_tree_model_get_iter_first (model, &iter))
|
||||
return;
|
||||
@@ -471,7 +461,6 @@ gtk_app_chooser_button_changed (GtkComboBox *object,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserButton *self = user_data;
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkTreeIter iter;
|
||||
gchar *name = NULL;
|
||||
gboolean custom;
|
||||
@@ -480,7 +469,7 @@ gtk_app_chooser_button_changed (GtkComboBox *object,
|
||||
if (!gtk_combo_box_get_active_iter (object, &iter))
|
||||
return;
|
||||
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter,
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (self->store), &iter,
|
||||
COLUMN_NAME, &name,
|
||||
COLUMN_CUSTOM, &custom,
|
||||
-1);
|
||||
@@ -491,7 +480,7 @@ gtk_app_chooser_button_changed (GtkComboBox *object,
|
||||
{
|
||||
name_quark = g_quark_from_string (name);
|
||||
g_signal_emit (self, signals[SIGNAL_CUSTOM_ITEM_ACTIVATED], name_quark, name);
|
||||
priv->last_active = gtk_combo_box_get_active (object);
|
||||
self->last_active = gtk_combo_box_get_active (object);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -502,7 +491,7 @@ gtk_app_chooser_button_changed (GtkComboBox *object,
|
||||
g_free (name);
|
||||
}
|
||||
else
|
||||
priv->last_active = gtk_combo_box_get_active (object);
|
||||
self->last_active = gtk_combo_box_get_active (object);
|
||||
|
||||
g_signal_emit (self, signals[SIGNAL_CHANGED], 0);
|
||||
}
|
||||
@@ -520,14 +509,13 @@ static GAppInfo *
|
||||
gtk_app_chooser_button_get_app_info (GtkAppChooser *object)
|
||||
{
|
||||
GtkAppChooserButton *self = GTK_APP_CHOOSER_BUTTON (object);
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkTreeIter iter;
|
||||
GAppInfo *info;
|
||||
|
||||
if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->combobox), &iter))
|
||||
if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self->combobox), &iter))
|
||||
return NULL;
|
||||
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter,
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (self->store), &iter,
|
||||
COLUMN_APP_INFO, &info,
|
||||
-1);
|
||||
|
||||
@@ -552,12 +540,11 @@ gtk_app_chooser_button_set_property (GObject *obj,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkAppChooserButton *self = GTK_APP_CHOOSER_BUTTON (obj);
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_CONTENT_TYPE:
|
||||
priv->content_type = g_value_dup_string (value);
|
||||
self->content_type = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_SHOW_DIALOG_ITEM:
|
||||
gtk_app_chooser_button_set_show_dialog_item (self, g_value_get_boolean (value));
|
||||
@@ -568,6 +555,9 @@ gtk_app_chooser_button_set_property (GObject *obj,
|
||||
case PROP_HEADING:
|
||||
gtk_app_chooser_button_set_heading (self, g_value_get_string (value));
|
||||
break;
|
||||
case PROP_MODAL:
|
||||
gtk_app_chooser_button_set_modal (self, g_value_get_boolean (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
|
||||
break;
|
||||
@@ -581,21 +571,23 @@ gtk_app_chooser_button_get_property (GObject *obj,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkAppChooserButton *self = GTK_APP_CHOOSER_BUTTON (obj);
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_CONTENT_TYPE:
|
||||
g_value_set_string (value, priv->content_type);
|
||||
g_value_set_string (value, self->content_type);
|
||||
break;
|
||||
case PROP_SHOW_DIALOG_ITEM:
|
||||
g_value_set_boolean (value, priv->show_dialog_item);
|
||||
g_value_set_boolean (value, self->show_dialog_item);
|
||||
break;
|
||||
case PROP_SHOW_DEFAULT_ITEM:
|
||||
g_value_set_boolean (value, priv->show_default_item);
|
||||
g_value_set_boolean (value, self->show_default_item);
|
||||
break;
|
||||
case PROP_HEADING:
|
||||
g_value_set_string (value, priv->heading);
|
||||
g_value_set_string (value, self->heading);
|
||||
break;
|
||||
case PROP_MODAL:
|
||||
g_value_set_boolean (value, self->modal);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
|
||||
@@ -607,13 +599,12 @@ static void
|
||||
gtk_app_chooser_button_finalize (GObject *obj)
|
||||
{
|
||||
GtkAppChooserButton *self = GTK_APP_CHOOSER_BUTTON (obj);
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
g_hash_table_destroy (priv->custom_item_names);
|
||||
g_free (priv->content_type);
|
||||
g_free (priv->heading);
|
||||
g_object_unref (priv->store);
|
||||
gtk_widget_unparent (priv->combobox);
|
||||
g_hash_table_destroy (self->custom_item_names);
|
||||
g_free (self->content_type);
|
||||
g_free (self->heading);
|
||||
g_object_unref (self->store);
|
||||
gtk_widget_unparent (self->combobox);
|
||||
|
||||
G_OBJECT_CLASS (gtk_app_chooser_button_parent_class)->finalize (obj);
|
||||
}
|
||||
@@ -627,10 +618,9 @@ gtk_app_chooser_button_measure (GtkWidget *widget,
|
||||
int *minimum_baseline,
|
||||
int *natural_baseline)
|
||||
{
|
||||
GtkAppChooserButton *button = GTK_APP_CHOOSER_BUTTON (widget);
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (button);
|
||||
GtkAppChooserButton *self = GTK_APP_CHOOSER_BUTTON (widget);
|
||||
|
||||
gtk_widget_measure (priv->combobox, orientation, for_size,
|
||||
gtk_widget_measure (self->combobox, orientation, for_size,
|
||||
minimum, natural,
|
||||
minimum_baseline, natural_baseline);
|
||||
}
|
||||
@@ -641,10 +631,9 @@ gtk_app_chooser_button_size_allocate (GtkWidget *widget,
|
||||
int height,
|
||||
int baseline)
|
||||
{
|
||||
GtkAppChooserButton *button = GTK_APP_CHOOSER_BUTTON (widget);
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (button);
|
||||
GtkAppChooserButton *self = GTK_APP_CHOOSER_BUTTON (widget);
|
||||
|
||||
gtk_widget_size_allocate (priv->combobox, &(GtkAllocation){0, 0, width, height}, baseline);
|
||||
gtk_widget_size_allocate (self->combobox, &(GtkAllocation){0, 0, width, height}, baseline);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -667,6 +656,8 @@ gtk_app_chooser_button_class_init (GtkAppChooserButtonClass *klass)
|
||||
|
||||
widget_class->measure = gtk_app_chooser_button_measure;
|
||||
widget_class->size_allocate = gtk_app_chooser_button_size_allocate;
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_child;
|
||||
widget_class->focus = gtk_widget_focus_child;
|
||||
|
||||
g_object_class_override_property (oclass, PROP_CONTENT_TYPE, "content-type");
|
||||
|
||||
@@ -711,6 +702,12 @@ gtk_app_chooser_button_class_init (GtkAppChooserButtonClass *klass)
|
||||
NULL,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
properties[PROP_MODAL] =
|
||||
g_param_spec_boolean ("modal",
|
||||
P_("Modal"),
|
||||
P_("Whether the dialog should be modal"),
|
||||
TRUE,
|
||||
G_PARAM_READWRITE|G_PARAM_CONSTRUCT|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
|
||||
|
||||
signals[SIGNAL_CHANGED] =
|
||||
@@ -748,20 +745,20 @@ gtk_app_chooser_button_class_init (GtkAppChooserButtonClass *klass)
|
||||
static void
|
||||
gtk_app_chooser_button_init (GtkAppChooserButton *self)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
self->modal = TRUE;
|
||||
|
||||
priv->custom_item_names = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||
priv->store = gtk_list_store_new (NUM_COLUMNS,
|
||||
self->custom_item_names = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||
self->store = gtk_list_store_new (NUM_COLUMNS,
|
||||
G_TYPE_APP_INFO,
|
||||
G_TYPE_STRING, /* name */
|
||||
G_TYPE_STRING, /* label */
|
||||
G_TYPE_ICON,
|
||||
G_TYPE_BOOLEAN, /* separator */
|
||||
G_TYPE_BOOLEAN); /* custom */
|
||||
priv->combobox = gtk_combo_box_new_with_model (GTK_TREE_MODEL (priv->store));
|
||||
gtk_widget_set_parent (priv->combobox, GTK_WIDGET (self));
|
||||
self->combobox = gtk_combo_box_new_with_model (GTK_TREE_MODEL (self->store));
|
||||
gtk_widget_set_parent (self->combobox, GTK_WIDGET (self));
|
||||
|
||||
g_signal_connect (priv->combobox, "changed",
|
||||
g_signal_connect (self->combobox, "changed",
|
||||
G_CALLBACK (gtk_app_chooser_button_changed), self);
|
||||
}
|
||||
|
||||
@@ -770,15 +767,14 @@ app_chooser_button_iter_from_custom_name (GtkAppChooserButton *self,
|
||||
const gchar *name,
|
||||
GtkTreeIter *set_me)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkTreeIter iter;
|
||||
gchar *custom_name = NULL;
|
||||
|
||||
if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store), &iter))
|
||||
if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (self->store), &iter))
|
||||
return FALSE;
|
||||
|
||||
do {
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter,
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (self->store), &iter,
|
||||
COLUMN_NAME, &custom_name,
|
||||
-1);
|
||||
|
||||
@@ -791,7 +787,7 @@ app_chooser_button_iter_from_custom_name (GtkAppChooserButton *self,
|
||||
}
|
||||
|
||||
g_free (custom_name);
|
||||
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->store), &iter));
|
||||
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (self->store), &iter));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -804,21 +800,20 @@ real_insert_custom_item (GtkAppChooserButton *self,
|
||||
gboolean custom,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
if (custom)
|
||||
{
|
||||
if (g_hash_table_lookup (priv->custom_item_names, name) != NULL)
|
||||
if (g_hash_table_lookup (self->custom_item_names, name) != NULL)
|
||||
{
|
||||
g_warning ("Attempting to add custom item %s to GtkAppChooserButton, "
|
||||
"when there's already an item with the same name", name);
|
||||
return;
|
||||
}
|
||||
|
||||
g_hash_table_insert (priv->custom_item_names,
|
||||
g_hash_table_insert (self->custom_item_names,
|
||||
g_strdup (name), GINT_TO_POINTER (1));
|
||||
}
|
||||
|
||||
gtk_list_store_set (priv->store, iter,
|
||||
gtk_list_store_set (self->store, iter,
|
||||
COLUMN_NAME, name,
|
||||
COLUMN_LABEL, label,
|
||||
COLUMN_ICON, icon,
|
||||
@@ -832,9 +827,7 @@ real_insert_separator (GtkAppChooserButton *self,
|
||||
gboolean custom,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
gtk_list_store_set (priv->store, iter,
|
||||
gtk_list_store_set (self->store, iter,
|
||||
COLUMN_CUSTOM, custom,
|
||||
COLUMN_SEPARATOR, TRUE,
|
||||
-1);
|
||||
@@ -869,12 +862,11 @@ gtk_app_chooser_button_new (const gchar *content_type)
|
||||
void
|
||||
gtk_app_chooser_button_append_separator (GtkAppChooserButton *self)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkTreeIter iter;
|
||||
|
||||
g_return_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self));
|
||||
|
||||
gtk_list_store_append (priv->store, &iter);
|
||||
gtk_list_store_append (self->store, &iter);
|
||||
real_insert_separator (self, TRUE, &iter);
|
||||
}
|
||||
|
||||
@@ -898,13 +890,12 @@ gtk_app_chooser_button_append_custom_item (GtkAppChooserButton *self,
|
||||
const gchar *label,
|
||||
GIcon *icon)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkTreeIter iter;
|
||||
|
||||
g_return_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self));
|
||||
g_return_if_fail (name != NULL);
|
||||
|
||||
gtk_list_store_append (priv->store, &iter);
|
||||
gtk_list_store_append (self->store, &iter);
|
||||
real_insert_custom_item (self, name, label, icon, TRUE, &iter);
|
||||
}
|
||||
|
||||
@@ -923,20 +914,19 @@ void
|
||||
gtk_app_chooser_button_set_active_custom_item (GtkAppChooserButton *self,
|
||||
const gchar *name)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkTreeIter iter;
|
||||
|
||||
g_return_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self));
|
||||
g_return_if_fail (name != NULL);
|
||||
|
||||
if (!g_hash_table_contains (priv->custom_item_names, name) ||
|
||||
if (!g_hash_table_contains (self->custom_item_names, name) ||
|
||||
!app_chooser_button_iter_from_custom_name (self, name, &iter))
|
||||
{
|
||||
g_warning ("Can't find the item named %s in the app chooser.", name);
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->combobox), &iter);
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self->combobox), &iter);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -951,11 +941,9 @@ gtk_app_chooser_button_set_active_custom_item (GtkAppChooserButton *self,
|
||||
gboolean
|
||||
gtk_app_chooser_button_get_show_dialog_item (GtkAppChooserButton *self)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self), FALSE);
|
||||
|
||||
return priv->show_dialog_item;
|
||||
return self->show_dialog_item;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -970,10 +958,9 @@ void
|
||||
gtk_app_chooser_button_set_show_dialog_item (GtkAppChooserButton *self,
|
||||
gboolean setting)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
if (priv->show_dialog_item != setting)
|
||||
if (self->show_dialog_item != setting)
|
||||
{
|
||||
priv->show_dialog_item = setting;
|
||||
self->show_dialog_item = setting;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_DIALOG_ITEM]);
|
||||
|
||||
@@ -993,11 +980,9 @@ gtk_app_chooser_button_set_show_dialog_item (GtkAppChooserButton *self,
|
||||
gboolean
|
||||
gtk_app_chooser_button_get_show_default_item (GtkAppChooserButton *self)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self), FALSE);
|
||||
|
||||
return priv->show_default_item;
|
||||
return self->show_default_item;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1012,13 +997,11 @@ void
|
||||
gtk_app_chooser_button_set_show_default_item (GtkAppChooserButton *self,
|
||||
gboolean setting)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
g_return_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self));
|
||||
|
||||
if (priv->show_default_item != setting)
|
||||
if (self->show_default_item != setting)
|
||||
{
|
||||
priv->show_default_item = setting;
|
||||
self->show_default_item = setting;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_DEFAULT_ITEM]);
|
||||
|
||||
@@ -1038,12 +1021,10 @@ void
|
||||
gtk_app_chooser_button_set_heading (GtkAppChooserButton *self,
|
||||
const gchar *heading)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
g_return_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self));
|
||||
|
||||
g_free (priv->heading);
|
||||
priv->heading = g_strdup (heading);
|
||||
g_free (self->heading);
|
||||
self->heading = g_strdup (heading);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_HEADING]);
|
||||
}
|
||||
@@ -1060,9 +1041,45 @@ gtk_app_chooser_button_set_heading (GtkAppChooserButton *self,
|
||||
const gchar *
|
||||
gtk_app_chooser_button_get_heading (GtkAppChooserButton *self)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self), NULL);
|
||||
|
||||
return priv->heading;
|
||||
return self->heading;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_app_chooser_button_set_modal:
|
||||
* @self: a #GtkAppChooserButton
|
||||
* @modal: %TRUE to make the dialog modal
|
||||
*
|
||||
* Sets whether the dialog should be modal.
|
||||
*/
|
||||
void
|
||||
gtk_app_chooser_button_set_modal (GtkAppChooserButton *self,
|
||||
gboolean modal)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self));
|
||||
|
||||
if (self->modal == modal)
|
||||
return;
|
||||
|
||||
self->modal = modal;
|
||||
|
||||
g_object_notify (G_OBJECT (self), "modal");
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_app_chooser_button_get_modal:
|
||||
* @self: a #GtkAppChooserButton
|
||||
*
|
||||
* Gets whether the dialog is modal.
|
||||
*
|
||||
* Returns: %TRUE if the dialog is modal
|
||||
*/
|
||||
gboolean
|
||||
gtk_app_chooser_button_get_modal (GtkAppChooserButton *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self), FALSE);
|
||||
|
||||
return self->modal;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,12 @@ void gtk_app_chooser_button_set_show_default_item (GtkAppChooserButton *self
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_app_chooser_button_get_show_default_item (GtkAppChooserButton *self);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_app_chooser_button_get_modal (GtkAppChooserButton *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_app_chooser_button_set_modal (GtkAppChooserButton *self,
|
||||
gboolean modal);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_APP_CHOOSER_BUTTON_H__ */
|
||||
|
||||
@@ -51,7 +51,6 @@
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkentry.h"
|
||||
#include "gtktogglebutton.h"
|
||||
#include "gtkstylecontext.h"
|
||||
#include "gtkheaderbar.h"
|
||||
#include "gtkdialogprivate.h"
|
||||
#include "gtksearchbar.h"
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "gtkscrolledwindow.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtkgestureclick.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
@@ -913,7 +914,8 @@ gtk_app_chooser_widget_class_init (GtkAppChooserWidgetClass *klass)
|
||||
widget_class->measure = gtk_app_chooser_widget_measure;
|
||||
widget_class->size_allocate = gtk_app_chooser_widget_size_allocate;
|
||||
widget_class->snapshot = gtk_app_chooser_widget_snapshot;
|
||||
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_child;
|
||||
widget_class->focus = gtk_widget_focus_child;
|
||||
|
||||
g_object_class_override_property (gobject_class, PROP_CONTENT_TYPE, "content-type");
|
||||
|
||||
|
||||
+2
-4
@@ -452,7 +452,7 @@ add_action_widgets (GtkAssistant *assistant)
|
||||
if (has_default)
|
||||
{
|
||||
gtk_window_set_default_widget (GTK_WINDOW (assistant), child);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (child), GTK_STYLE_CLASS_SUGGESTED_ACTION);
|
||||
gtk_widget_add_css_class (child, GTK_STYLE_CLASS_SUGGESTED_ACTION);
|
||||
}
|
||||
}
|
||||
g_list_free (children);
|
||||
@@ -1795,7 +1795,6 @@ gtk_assistant_add_page (GtkAssistant *assistant,
|
||||
{
|
||||
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
||||
gint n_pages;
|
||||
GtkStyleContext *context;
|
||||
GtkWidget *sibling;
|
||||
char *name;
|
||||
|
||||
@@ -1808,8 +1807,7 @@ gtk_assistant_add_page (GtkAssistant *assistant,
|
||||
gtk_widget_show (page_info->regular_title);
|
||||
gtk_widget_hide (page_info->current_title);
|
||||
|
||||
context = gtk_widget_get_style_context (page_info->current_title);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_HIGHLIGHT);
|
||||
gtk_widget_add_css_class (page_info->current_title, GTK_STYLE_CLASS_HIGHLIGHT);
|
||||
|
||||
gtk_size_group_add_widget (priv->title_size_group, page_info->regular_title);
|
||||
gtk_size_group_add_widget (priv->title_size_group, page_info->current_title);
|
||||
|
||||
@@ -95,6 +95,8 @@ gtk_builtin_icon_class_init (GtkBuiltinIconClass *klass)
|
||||
wclass->snapshot = gtk_builtin_icon_snapshot;
|
||||
wclass->measure = gtk_builtin_icon_measure;
|
||||
wclass->css_changed = gtk_builtin_icon_css_changed;
|
||||
wclass->grab_focus = gtk_widget_grab_focus_none;
|
||||
wclass->focus = gtk_widget_focus_none;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+13
-15
@@ -68,6 +68,7 @@
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkstylecontext.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
#include "a11y/gtkbuttonaccessible.h"
|
||||
|
||||
@@ -204,6 +205,8 @@ gtk_button_class_init (GtkButtonClass *klass)
|
||||
widget_class->state_flags_changed = gtk_button_state_flags_changed;
|
||||
widget_class->grab_notify = gtk_button_grab_notify;
|
||||
widget_class->unmap = gtk_button_unmap;
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_self;
|
||||
widget_class->focus = gtk_widget_focus_self;
|
||||
|
||||
container_class->add = gtk_button_add;
|
||||
container_class->remove = gtk_button_remove;
|
||||
@@ -306,29 +309,25 @@ click_pressed_cb (GtkGestureClick *gesture,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
touch_release_in_button (GtkButton *button,
|
||||
double x,
|
||||
double y)
|
||||
touch_release_in_button (GtkGestureClick *gesture,
|
||||
GtkWidget *widget,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GdkEvent *event;
|
||||
|
||||
event = gtk_get_current_event ();
|
||||
event = gtk_event_controller_get_current_event (GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
if (!event)
|
||||
return FALSE;
|
||||
|
||||
if (gdk_event_get_event_type (event) != GDK_TOUCH_END)
|
||||
{
|
||||
gdk_event_unref (event);
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
gdk_event_unref (event);
|
||||
if (!gtk_widget_contains (widget, x, y))
|
||||
return FALSE;
|
||||
|
||||
if (gtk_widget_contains (GTK_WIDGET (button), x, y))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -345,7 +344,7 @@ click_released_cb (GtkGestureClick *gesture,
|
||||
gtk_button_do_release (button,
|
||||
gtk_widget_is_sensitive (GTK_WIDGET (button)) &&
|
||||
(priv->in_button ||
|
||||
touch_release_in_button (button, x, y)));
|
||||
touch_release_in_button (gesture, widget, x, y)));
|
||||
|
||||
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
||||
|
||||
@@ -408,7 +407,6 @@ gtk_button_init (GtkButton *button)
|
||||
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
||||
GtkEventController *key_controller;
|
||||
|
||||
gtk_widget_set_can_focus (GTK_WIDGET (button), TRUE);
|
||||
gtk_widget_set_receives_default (GTK_WIDGET (button), TRUE);
|
||||
|
||||
priv->in_button = FALSE;
|
||||
|
||||
@@ -365,6 +365,9 @@ gtk_calendar_class_init (GtkCalendarClass *class)
|
||||
gobject_class->set_property = gtk_calendar_set_property;
|
||||
gobject_class->get_property = gtk_calendar_get_property;
|
||||
|
||||
widget_class->focus = gtk_widget_focus_all;
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_self;
|
||||
|
||||
/**
|
||||
* GtkCalendar:year:
|
||||
*
|
||||
|
||||
@@ -845,8 +845,7 @@ gtk_cell_renderer_start_editing (GtkCellRenderer *cell,
|
||||
if (editable == NULL)
|
||||
return NULL;
|
||||
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (editable)),
|
||||
GTK_STYLE_CLASS_CELL);
|
||||
gtk_widget_add_css_class (GTK_WIDGET (editable), GTK_STYLE_CLASS_CELL);
|
||||
|
||||
g_signal_emit (cell,
|
||||
cell_renderer_signals[EDITING_STARTED], 0,
|
||||
|
||||
@@ -539,8 +539,10 @@ key_controller_key_pressed (GtkEventControllerKey *key,
|
||||
gboolean cleared = FALSE;
|
||||
GdkModifierType accel_mods = 0;
|
||||
guint accel_key;
|
||||
GdkEvent *event;
|
||||
|
||||
if (!gdk_key_event_get_match (gtk_get_current_event (), &accel_key, &accel_mods))
|
||||
event = gtk_event_controller_get_current_event (GTK_EVENT_CONTROLLER (key));
|
||||
if (!gdk_key_event_get_match (event, &accel_key, &accel_mods))
|
||||
return FALSE;
|
||||
|
||||
if (accel_mods == 0)
|
||||
|
||||
@@ -199,6 +199,9 @@ gtk_center_box_class_init (GtkCenterBoxClass *klass)
|
||||
object_class->get_property = gtk_center_box_get_property;
|
||||
object_class->dispose = gtk_center_box_dispose;
|
||||
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_child;
|
||||
widget_class->focus = gtk_widget_focus_child;
|
||||
|
||||
g_object_class_override_property (object_class, PROP_ORIENTATION, "orientation");
|
||||
|
||||
g_object_class_install_property (object_class, PROP_BASELINE_POSITION,
|
||||
|
||||
+121
-80
@@ -43,7 +43,7 @@
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtkstylecontext.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
|
||||
/**
|
||||
@@ -66,16 +66,7 @@ typedef struct _GtkColorButtonClass GtkColorButtonClass;
|
||||
|
||||
struct _GtkColorButton {
|
||||
GtkWidget parent_instance;
|
||||
};
|
||||
|
||||
struct _GtkColorButtonClass {
|
||||
GtkWidgetClass parent_class;
|
||||
|
||||
void (* color_set) (GtkColorButton *cp);
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget *button;
|
||||
|
||||
GtkWidget *swatch; /* Widget where we draw the color sample */
|
||||
@@ -84,9 +75,16 @@ typedef struct
|
||||
gchar *title; /* Title for the color selection window */
|
||||
GdkRGBA rgba;
|
||||
|
||||
guint use_alpha : 1; /* Use alpha or not */
|
||||
guint use_alpha : 1; /* Use alpha or not */
|
||||
guint show_editor : 1;
|
||||
} GtkColorButtonPrivate;
|
||||
guint modal : 1;
|
||||
};
|
||||
|
||||
struct _GtkColorButtonClass {
|
||||
GtkWidgetClass parent_class;
|
||||
|
||||
void (* color_set) (GtkColorButton *cp);
|
||||
};
|
||||
|
||||
/* Properties */
|
||||
enum
|
||||
@@ -95,7 +93,8 @@ enum
|
||||
PROP_USE_ALPHA,
|
||||
PROP_TITLE,
|
||||
PROP_RGBA,
|
||||
PROP_SHOW_EDITOR
|
||||
PROP_SHOW_EDITOR,
|
||||
PROP_MODAL
|
||||
};
|
||||
|
||||
/* Signals */
|
||||
@@ -126,7 +125,6 @@ static guint color_button_signals[LAST_SIGNAL] = { 0 };
|
||||
static void gtk_color_button_iface_init (GtkColorChooserInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkColorButton, gtk_color_button, GTK_TYPE_WIDGET,
|
||||
G_ADD_PRIVATE (GtkColorButton)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_COLOR_CHOOSER,
|
||||
gtk_color_button_iface_init))
|
||||
|
||||
@@ -143,6 +141,9 @@ gtk_color_button_class_init (GtkColorButtonClass *klass)
|
||||
gobject_class->set_property = gtk_color_button_set_property;
|
||||
gobject_class->finalize = gtk_color_button_finalize;
|
||||
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_child;
|
||||
widget_class->focus = gtk_widget_focus_child;
|
||||
|
||||
klass->color_set = NULL;
|
||||
|
||||
/**
|
||||
@@ -223,6 +224,14 @@ gtk_color_button_class_init (GtkColorButtonClass *klass)
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_MODAL,
|
||||
g_param_spec_boolean ("modal", P_("Modal"),
|
||||
P_("Whether the dialog is modal"),
|
||||
TRUE,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
||||
|
||||
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||
gtk_widget_class_set_css_name (widget_class, "colorbutton");
|
||||
}
|
||||
@@ -246,43 +255,41 @@ gtk_color_button_drag_prepare (GtkDragSource *source,
|
||||
double y,
|
||||
GtkColorButton *button)
|
||||
{
|
||||
GtkColorButtonPrivate *priv = gtk_color_button_get_instance_private (button);
|
||||
|
||||
return gdk_content_provider_new_typed (GDK_TYPE_RGBA, &priv->rgba);
|
||||
return gdk_content_provider_new_typed (GDK_TYPE_RGBA, &button->rgba);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_button_init (GtkColorButton *button)
|
||||
{
|
||||
GtkColorButtonPrivate *priv = gtk_color_button_get_instance_private (button);
|
||||
PangoLayout *layout;
|
||||
PangoRectangle rect;
|
||||
GtkDragSource *source;
|
||||
GtkDropTarget *dest;
|
||||
|
||||
priv->button = gtk_button_new ();
|
||||
g_signal_connect (priv->button, "clicked", G_CALLBACK (gtk_color_button_clicked), button);
|
||||
gtk_widget_set_parent (priv->button, GTK_WIDGET (button));
|
||||
button->button = gtk_button_new ();
|
||||
g_signal_connect (button->button, "clicked", G_CALLBACK (gtk_color_button_clicked), button);
|
||||
gtk_widget_set_parent (button->button, GTK_WIDGET (button));
|
||||
|
||||
priv->swatch = gtk_color_swatch_new ();
|
||||
gtk_widget_set_can_focus (priv->swatch, FALSE);
|
||||
g_object_set (priv->swatch, "has-menu", FALSE, NULL);
|
||||
button->swatch = gtk_color_swatch_new ();
|
||||
gtk_widget_set_can_focus (button->swatch, FALSE);
|
||||
g_object_set (button->swatch, "has-menu", FALSE, NULL);
|
||||
layout = gtk_widget_create_pango_layout (GTK_WIDGET (button), "Black");
|
||||
pango_layout_get_pixel_extents (layout, NULL, &rect);
|
||||
g_object_unref (layout);
|
||||
|
||||
gtk_widget_set_size_request (priv->swatch, rect.width, rect.height);
|
||||
gtk_widget_set_size_request (button->swatch, rect.width, rect.height);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (priv->button), priv->swatch);
|
||||
gtk_container_add (GTK_CONTAINER (button->button), button->swatch);
|
||||
|
||||
priv->title = g_strdup (_("Pick a Color")); /* default title */
|
||||
button->title = g_strdup (_("Pick a Color")); /* default title */
|
||||
|
||||
/* Start with opaque black, alpha disabled */
|
||||
priv->rgba.red = 0;
|
||||
priv->rgba.green = 0;
|
||||
priv->rgba.blue = 0;
|
||||
priv->rgba.alpha = 1;
|
||||
priv->use_alpha = FALSE;
|
||||
button->rgba.red = 0;
|
||||
button->rgba.green = 0;
|
||||
button->rgba.blue = 0;
|
||||
button->rgba.alpha = 1;
|
||||
button->use_alpha = FALSE;
|
||||
button->modal = TRUE;
|
||||
|
||||
dest = gtk_drop_target_new (GDK_TYPE_RGBA, GDK_ACTION_COPY);
|
||||
g_signal_connect (dest, "drop", G_CALLBACK (gtk_color_button_drop), button);
|
||||
@@ -291,22 +298,21 @@ gtk_color_button_init (GtkColorButton *button)
|
||||
source = gtk_drag_source_new ();
|
||||
g_signal_connect (source, "prepare", G_CALLBACK (gtk_color_button_drag_prepare), button);
|
||||
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (source), GTK_PHASE_CAPTURE);
|
||||
gtk_widget_add_controller (priv->button, GTK_EVENT_CONTROLLER (source));
|
||||
gtk_widget_add_controller (button->button, GTK_EVENT_CONTROLLER (source));
|
||||
|
||||
gtk_widget_add_css_class (priv->button, "color");
|
||||
gtk_widget_add_css_class (button->button, "color");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_button_finalize (GObject *object)
|
||||
{
|
||||
GtkColorButton *button = GTK_COLOR_BUTTON (object);
|
||||
GtkColorButtonPrivate *priv = gtk_color_button_get_instance_private (button);
|
||||
|
||||
if (priv->cs_dialog != NULL)
|
||||
gtk_widget_destroy (priv->cs_dialog);
|
||||
if (button->cs_dialog != NULL)
|
||||
gtk_widget_destroy (button->cs_dialog);
|
||||
|
||||
g_free (priv->title);
|
||||
gtk_widget_unparent (priv->button);
|
||||
g_free (button->title);
|
||||
gtk_widget_unparent (button->button);
|
||||
|
||||
G_OBJECT_CLASS (gtk_color_button_parent_class)->finalize (object);
|
||||
}
|
||||
@@ -350,9 +356,8 @@ dialog_destroy (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GtkColorButton *button = GTK_COLOR_BUTTON (data);
|
||||
GtkColorButtonPrivate *priv = gtk_color_button_get_instance_private (button);
|
||||
|
||||
priv->cs_dialog = NULL;
|
||||
button->cs_dialog = NULL;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -367,10 +372,9 @@ dialog_response (GtkDialog *dialog,
|
||||
else if (response == GTK_RESPONSE_OK)
|
||||
{
|
||||
GtkColorButton *button = GTK_COLOR_BUTTON (data);
|
||||
GtkColorButtonPrivate *priv = gtk_color_button_get_instance_private (button);
|
||||
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog), &priv->rgba);
|
||||
gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (priv->swatch), &priv->rgba);
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog), &button->rgba);
|
||||
gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (button->swatch), &button->rgba);
|
||||
|
||||
gtk_widget_hide (GTK_WIDGET (dialog));
|
||||
|
||||
@@ -388,24 +392,24 @@ dialog_response (GtkDialog *dialog,
|
||||
static void
|
||||
ensure_dialog (GtkColorButton *button)
|
||||
{
|
||||
GtkColorButtonPrivate *priv = gtk_color_button_get_instance_private (button);
|
||||
GtkWidget *parent, *dialog;
|
||||
|
||||
if (priv->cs_dialog != NULL)
|
||||
if (button->cs_dialog != NULL)
|
||||
return;
|
||||
|
||||
parent = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (button)));
|
||||
|
||||
priv->cs_dialog = dialog = gtk_color_chooser_dialog_new (priv->title, NULL);
|
||||
button->cs_dialog = dialog = gtk_color_chooser_dialog_new (button->title, NULL);
|
||||
gtk_window_set_hide_on_close (GTK_WINDOW (dialog), TRUE);
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), button->modal);
|
||||
|
||||
if (GTK_IS_WINDOW (parent))
|
||||
{
|
||||
if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (dialog)))
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
|
||||
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog),
|
||||
gtk_window_get_modal (GTK_WINDOW (parent)));
|
||||
if (gtk_window_get_modal (GTK_WINDOW (parent)))
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
}
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
@@ -420,19 +424,18 @@ gtk_color_button_clicked (GtkButton *b,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkColorButton *button = user_data;
|
||||
GtkColorButtonPrivate *priv = gtk_color_button_get_instance_private (button);
|
||||
|
||||
/* if dialog already exists, make sure it's shown and raised */
|
||||
ensure_dialog (button);
|
||||
|
||||
g_object_set (priv->cs_dialog, "show-editor", priv->show_editor, NULL);
|
||||
g_object_set (button->cs_dialog, "show-editor", button->show_editor, NULL);
|
||||
|
||||
gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (priv->cs_dialog), priv->use_alpha);
|
||||
gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (button->cs_dialog), button->use_alpha);
|
||||
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (priv->cs_dialog), &priv->rgba);
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button->cs_dialog), &button->rgba);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
gtk_window_present (GTK_WINDOW (priv->cs_dialog));
|
||||
gtk_window_present (GTK_WINDOW (button->cs_dialog));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
}
|
||||
|
||||
@@ -440,13 +443,13 @@ static void
|
||||
gtk_color_button_set_rgba (GtkColorChooser *chooser,
|
||||
const GdkRGBA *rgba)
|
||||
{
|
||||
GtkColorButtonPrivate *priv = gtk_color_button_get_instance_private (GTK_COLOR_BUTTON (chooser));
|
||||
GtkColorButton *button = GTK_COLOR_BUTTON (chooser);
|
||||
|
||||
g_return_if_fail (GTK_IS_COLOR_BUTTON (chooser));
|
||||
g_return_if_fail (rgba != NULL);
|
||||
|
||||
priv->rgba = *rgba;
|
||||
gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (priv->swatch), &priv->rgba);
|
||||
button->rgba = *rgba;
|
||||
gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (button->swatch), &button->rgba);
|
||||
|
||||
g_object_notify (G_OBJECT (chooser), "rgba");
|
||||
}
|
||||
@@ -455,27 +458,25 @@ static void
|
||||
gtk_color_button_get_rgba (GtkColorChooser *chooser,
|
||||
GdkRGBA *rgba)
|
||||
{
|
||||
GtkColorButtonPrivate *priv = gtk_color_button_get_instance_private (GTK_COLOR_BUTTON (chooser));
|
||||
GtkColorButton *button = GTK_COLOR_BUTTON (chooser);
|
||||
|
||||
g_return_if_fail (GTK_IS_COLOR_BUTTON (chooser));
|
||||
g_return_if_fail (rgba != NULL);
|
||||
|
||||
*rgba = priv->rgba;
|
||||
*rgba = button->rgba;
|
||||
}
|
||||
|
||||
static void
|
||||
set_use_alpha (GtkColorButton *button,
|
||||
gboolean use_alpha)
|
||||
{
|
||||
GtkColorButtonPrivate *priv = gtk_color_button_get_instance_private (button);
|
||||
|
||||
use_alpha = (use_alpha != FALSE);
|
||||
|
||||
if (priv->use_alpha != use_alpha)
|
||||
if (button->use_alpha != use_alpha)
|
||||
{
|
||||
priv->use_alpha = use_alpha;
|
||||
button->use_alpha = use_alpha;
|
||||
|
||||
gtk_color_swatch_set_use_alpha (GTK_COLOR_SWATCH (priv->swatch), use_alpha);
|
||||
gtk_color_swatch_set_use_alpha (GTK_COLOR_SWATCH (button->swatch), use_alpha);
|
||||
|
||||
g_object_notify (G_OBJECT (button), "use-alpha");
|
||||
}
|
||||
@@ -492,17 +493,16 @@ void
|
||||
gtk_color_button_set_title (GtkColorButton *button,
|
||||
const gchar *title)
|
||||
{
|
||||
GtkColorButtonPrivate *priv = gtk_color_button_get_instance_private (button);
|
||||
gchar *old_title;
|
||||
|
||||
g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
|
||||
|
||||
old_title = priv->title;
|
||||
priv->title = g_strdup (title);
|
||||
old_title = button->title;
|
||||
button->title = g_strdup (title);
|
||||
g_free (old_title);
|
||||
|
||||
if (priv->cs_dialog)
|
||||
gtk_window_set_title (GTK_WINDOW (priv->cs_dialog), priv->title);
|
||||
if (button->cs_dialog)
|
||||
gtk_window_set_title (GTK_WINDOW (button->cs_dialog), button->title);
|
||||
|
||||
g_object_notify (G_OBJECT (button), "title");
|
||||
}
|
||||
@@ -518,11 +518,49 @@ gtk_color_button_set_title (GtkColorButton *button,
|
||||
const gchar *
|
||||
gtk_color_button_get_title (GtkColorButton *button)
|
||||
{
|
||||
GtkColorButtonPrivate *priv = gtk_color_button_get_instance_private (button);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), NULL);
|
||||
|
||||
return priv->title;
|
||||
return button->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_color_button_set_modal:
|
||||
* @button: a #GtkColorButton
|
||||
* @modal: %TRUE to make the dialog modal
|
||||
*
|
||||
* Sets whether the dialog should be modal.
|
||||
*/
|
||||
void
|
||||
gtk_color_button_set_modal (GtkColorButton *button,
|
||||
gboolean modal)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
|
||||
|
||||
if (button->modal == modal)
|
||||
return;
|
||||
|
||||
button->modal = modal;
|
||||
|
||||
if (button->cs_dialog)
|
||||
gtk_window_set_modal (GTK_WINDOW (button->cs_dialog), button->modal);
|
||||
|
||||
g_object_notify (G_OBJECT (button), "modal");
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_color_button_get_modal:
|
||||
* @button: a #GtkColorButton
|
||||
*
|
||||
* Gets whether the dialog is modal.
|
||||
*
|
||||
* Returns: %TRUE if the dialog is modal
|
||||
*/
|
||||
gboolean
|
||||
gtk_color_button_get_modal (GtkColorButton *button)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), FALSE);
|
||||
|
||||
return button->modal;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -532,7 +570,6 @@ gtk_color_button_set_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkColorButton *button = GTK_COLOR_BUTTON (object);
|
||||
GtkColorButtonPrivate *priv = gtk_color_button_get_instance_private (button);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
@@ -548,13 +585,16 @@ gtk_color_button_set_property (GObject *object,
|
||||
case PROP_SHOW_EDITOR:
|
||||
{
|
||||
gboolean show_editor = g_value_get_boolean (value);
|
||||
if (priv->show_editor != show_editor)
|
||||
if (button->show_editor != show_editor)
|
||||
{
|
||||
priv->show_editor = show_editor;
|
||||
button->show_editor = show_editor;
|
||||
g_object_notify (object, "show-editor");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PROP_MODAL:
|
||||
gtk_color_button_set_modal (button, g_value_get_boolean (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
@@ -568,12 +608,11 @@ gtk_color_button_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkColorButton *button = GTK_COLOR_BUTTON (object);
|
||||
GtkColorButtonPrivate *priv = gtk_color_button_get_instance_private (button);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_USE_ALPHA:
|
||||
g_value_set_boolean (value, priv->use_alpha);
|
||||
g_value_set_boolean (value, button->use_alpha);
|
||||
break;
|
||||
case PROP_TITLE:
|
||||
g_value_set_string (value, gtk_color_button_get_title (button));
|
||||
@@ -587,7 +626,10 @@ gtk_color_button_get_property (GObject *object,
|
||||
}
|
||||
break;
|
||||
case PROP_SHOW_EDITOR:
|
||||
g_value_set_boolean (value, priv->show_editor);
|
||||
g_value_set_boolean (value, button->show_editor);
|
||||
break;
|
||||
case PROP_MODAL:
|
||||
g_value_set_boolean (value, button->modal);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
@@ -603,11 +645,10 @@ gtk_color_button_add_palette (GtkColorChooser *chooser,
|
||||
GdkRGBA *colors)
|
||||
{
|
||||
GtkColorButton *button = GTK_COLOR_BUTTON (chooser);
|
||||
GtkColorButtonPrivate *priv = gtk_color_button_get_instance_private (button);
|
||||
|
||||
ensure_dialog (button);
|
||||
|
||||
gtk_color_chooser_add_palette (GTK_COLOR_CHOOSER (priv->cs_dialog),
|
||||
gtk_color_chooser_add_palette (GTK_COLOR_CHOOSER (button->cs_dialog),
|
||||
orientation, colors_per_line, n_colors, colors);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,12 @@ void gtk_color_button_set_title (GtkColorButton *button,
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const gchar *gtk_color_button_get_title (GtkColorButton *button);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_color_button_get_modal (GtkColorButton *button);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_color_button_set_modal (GtkColorButton *button,
|
||||
gboolean modal);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_COLOR_BUTTON_H__ */
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "gtksizegroup.h"
|
||||
#include "gtkstylecontext.h"
|
||||
#include "gtkboxlayout.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
#include "a11y/gtkcompositeaccessible.h"
|
||||
|
||||
@@ -709,6 +710,9 @@ gtk_color_chooser_widget_class_init (GtkColorChooserWidgetClass *class)
|
||||
object_class->set_property = gtk_color_chooser_widget_set_property;
|
||||
object_class->finalize = gtk_color_chooser_widget_finalize;
|
||||
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_child;
|
||||
widget_class->focus = gtk_widget_focus_child;
|
||||
|
||||
g_object_class_override_property (object_class, PROP_RGBA, "rgba");
|
||||
g_object_class_override_property (object_class, PROP_USE_ALPHA, "use-alpha");
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include "gtkadjustment.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtkspinbutton.h"
|
||||
#include "gtkstylecontext.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
#include "gtkroot.h"
|
||||
|
||||
@@ -562,10 +561,13 @@ gtk_color_editor_class_init (GtkColorEditorClass *class)
|
||||
gtk_widget_class_bind_template_callback (widget_class, entry_focus_changed);
|
||||
gtk_widget_class_bind_template_callback (widget_class, pick_color);
|
||||
|
||||
/**
|
||||
* GtkColorEditor|color.edit:
|
||||
* @component: the component to edit, "h", "sv" or "a"
|
||||
*
|
||||
* Opens the edit popup for one of the color components.
|
||||
*/
|
||||
gtk_widget_class_install_action (widget_class, "color.edit", "s", popup_edit);
|
||||
gtk_widget_class_install_action (widget_class, "color.edit", "s", popup_edit);
|
||||
gtk_widget_class_install_action (widget_class, "color.edit", "s", popup_edit);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+2
-2
@@ -407,8 +407,6 @@ gtk_color_plane_init (GtkColorPlane *plane)
|
||||
|
||||
plane->priv = gtk_color_plane_get_instance_private (plane);
|
||||
|
||||
gtk_widget_set_can_focus (GTK_WIDGET (plane), TRUE);
|
||||
|
||||
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (plane));
|
||||
if (GTK_IS_ACCESSIBLE (atk_obj))
|
||||
{
|
||||
@@ -545,6 +543,8 @@ gtk_color_plane_class_init (GtkColorPlaneClass *class)
|
||||
GTK_TYPE_ADJUSTMENT,
|
||||
GTK_PARAM_WRITABLE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, "plane");
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "gtkcolorutils.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkrangeprivate.h"
|
||||
#include "gtkstylecontext.h"
|
||||
#include "gtkaccessible.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
@@ -481,6 +481,8 @@ gtk_color_swatch_class_init (GtkColorSwatchClass *class)
|
||||
widget_class->snapshot = swatch_snapshot;
|
||||
widget_class->size_allocate = swatch_size_allocate;
|
||||
widget_class->state_flags_changed = swatch_state_flags_changed;
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_self;
|
||||
widget_class->focus = gtk_widget_focus_self;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_RGBA,
|
||||
g_param_spec_boxed ("rgba", P_("RGBA Color"), P_("Color as RGBA"),
|
||||
@@ -495,6 +497,11 @@ gtk_color_swatch_class_init (GtkColorSwatchClass *class)
|
||||
g_param_spec_boolean ("can-drop", P_("Can Drop"), P_("Whether the swatch should accept drops"),
|
||||
FALSE, GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkColorSwatch|menu.popup:
|
||||
*
|
||||
* Opens the context menu.
|
||||
*/
|
||||
gtk_widget_class_install_action (widget_class, "menu.popup", NULL, swatch_popup_menu);
|
||||
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
|
||||
@@ -420,6 +420,7 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
|
||||
widget_class->size_allocate = gtk_combo_box_size_allocate;
|
||||
widget_class->mnemonic_activate = gtk_combo_box_mnemonic_activate;
|
||||
widget_class->grab_focus = gtk_combo_box_grab_focus;
|
||||
widget_class->focus = gtk_widget_focus_child;
|
||||
widget_class->measure = gtk_combo_box_measure;
|
||||
widget_class->unmap = gtk_combo_box_unmap;
|
||||
widget_class->destroy = gtk_combo_box_destroy;
|
||||
|
||||
@@ -140,6 +140,8 @@ gtk_container_class_init (GtkContainerClass *class)
|
||||
widget_class->destroy = gtk_container_destroy;
|
||||
widget_class->compute_expand = gtk_container_compute_expand;
|
||||
widget_class->get_request_mode = gtk_container_get_request_mode;
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_none;
|
||||
widget_class->focus = gtk_widget_focus_child;
|
||||
|
||||
class->add = gtk_container_add_unimplemented;
|
||||
class->remove = gtk_container_remove_unimplemented;
|
||||
|
||||
+16
-36
@@ -1221,17 +1221,16 @@ _gtk_css_provider_get_theme_dir (GtkCssProvider *provider)
|
||||
|
||||
/*
|
||||
* Look for
|
||||
* $dir/$subdir/gtk-4.16/gtk-$variant.css
|
||||
* $dir/$subdir/gtk-4.14/gtk-$variant.css
|
||||
* $dir/$subdir/gtk-4.16/gtk.css
|
||||
* $dir/$subdir/gtk-4.14/gtk.css
|
||||
* ...
|
||||
* $dir/$subdir/gtk-4.0/gtk-$variant.css
|
||||
* $dir/$subdir/gtk-4.0/gtk.css
|
||||
* and return the first found file.
|
||||
*/
|
||||
static gchar *
|
||||
_gtk_css_find_theme_dir (const gchar *dir,
|
||||
const gchar *subdir,
|
||||
const gchar *name,
|
||||
const gchar *variant)
|
||||
const gchar *name)
|
||||
{
|
||||
gchar *file;
|
||||
gchar *base;
|
||||
@@ -1239,10 +1238,7 @@ _gtk_css_find_theme_dir (const gchar *dir,
|
||||
gint i;
|
||||
gchar *path;
|
||||
|
||||
if (variant)
|
||||
file = g_strconcat ("gtk-", variant, ".css", NULL);
|
||||
else
|
||||
file = g_strdup ("gtk.css");
|
||||
file = g_strdup ("gtk.css");
|
||||
|
||||
if (subdir)
|
||||
base = g_build_filename (dir, subdir, name, NULL);
|
||||
@@ -1270,9 +1266,8 @@ _gtk_css_find_theme_dir (const gchar *dir,
|
||||
|
||||
#undef MINOR
|
||||
|
||||
static gchar *
|
||||
_gtk_css_find_theme (const gchar *name,
|
||||
const gchar *variant)
|
||||
char *
|
||||
_gtk_css_find_theme (const char *name)
|
||||
{
|
||||
gchar *path;
|
||||
const char *const *dirs;
|
||||
@@ -1280,12 +1275,12 @@ _gtk_css_find_theme (const gchar *name,
|
||||
char *dir;
|
||||
|
||||
/* First look in the user's data directory */
|
||||
path = _gtk_css_find_theme_dir (g_get_user_data_dir (), "themes", name, variant);
|
||||
path = _gtk_css_find_theme_dir (g_get_user_data_dir (), "themes", name);
|
||||
if (path)
|
||||
return path;
|
||||
|
||||
/* Next look in the user's home directory */
|
||||
path = _gtk_css_find_theme_dir (g_get_home_dir (), ".themes", name, variant);
|
||||
path = _gtk_css_find_theme_dir (g_get_home_dir (), ".themes", name);
|
||||
if (path)
|
||||
return path;
|
||||
|
||||
@@ -1293,14 +1288,14 @@ _gtk_css_find_theme (const gchar *name,
|
||||
dirs = g_get_system_data_dirs ();
|
||||
for (i = 0; dirs[i]; i++)
|
||||
{
|
||||
path = _gtk_css_find_theme_dir (dirs[i], "themes", name, variant);
|
||||
path = _gtk_css_find_theme_dir (dirs[i], "themes", name);
|
||||
if (path)
|
||||
return path;
|
||||
}
|
||||
|
||||
/* Finally, try in the default theme directory */
|
||||
dir = _gtk_get_theme_dir ();
|
||||
path = _gtk_css_find_theme_dir (dir, NULL, name, variant);
|
||||
path = _gtk_css_find_theme_dir (dir, NULL, name);
|
||||
g_free (dir);
|
||||
|
||||
return path;
|
||||
@@ -1310,8 +1305,6 @@ _gtk_css_find_theme (const gchar *name,
|
||||
* gtk_css_provider_load_named:
|
||||
* @provider: a #GtkCssProvider
|
||||
* @name: A theme name
|
||||
* @variant: (allow-none): variant to load, for example, "dark", or
|
||||
* %NULL for the default
|
||||
*
|
||||
* Loads a theme from the usual theme paths. The actual process of
|
||||
* finding the theme might change between releases, but it is
|
||||
@@ -1320,8 +1313,7 @@ _gtk_css_find_theme (const gchar *name,
|
||||
**/
|
||||
void
|
||||
gtk_css_provider_load_named (GtkCssProvider *provider,
|
||||
const gchar *name,
|
||||
const gchar *variant)
|
||||
const gchar *name)
|
||||
{
|
||||
gchar *path;
|
||||
gchar *resource_path;
|
||||
@@ -1334,10 +1326,7 @@ gtk_css_provider_load_named (GtkCssProvider *provider,
|
||||
/* try loading the resource for the theme. This is mostly meant for built-in
|
||||
* themes.
|
||||
*/
|
||||
if (variant)
|
||||
resource_path = g_strdup_printf ("/org/gtk/libgtk/theme/%s/gtk-%s.css", name, variant);
|
||||
else
|
||||
resource_path = g_strdup_printf ("/org/gtk/libgtk/theme/%s/gtk.css", name);
|
||||
resource_path = g_strdup_printf ("/org/gtk/libgtk/theme/%s/gtk.css", name);
|
||||
|
||||
if (g_resources_get_info (resource_path, 0, NULL, NULL, NULL))
|
||||
{
|
||||
@@ -1348,7 +1337,7 @@ gtk_css_provider_load_named (GtkCssProvider *provider,
|
||||
g_free (resource_path);
|
||||
|
||||
/* Next try looking for files in the various theme directories. */
|
||||
path = _gtk_css_find_theme (name, variant);
|
||||
path = _gtk_css_find_theme (name);
|
||||
if (path)
|
||||
{
|
||||
GtkCssProviderPrivate *priv = gtk_css_provider_get_instance_private (provider);
|
||||
@@ -1375,17 +1364,8 @@ gtk_css_provider_load_named (GtkCssProvider *provider,
|
||||
{
|
||||
/* Things failed! Fall back! Fall back! */
|
||||
|
||||
if (variant)
|
||||
{
|
||||
/* If there was a variant, try without */
|
||||
gtk_css_provider_load_named (provider, name, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Worst case, fall back to the default */
|
||||
g_return_if_fail (!g_str_equal (name, DEFAULT_THEME_NAME)); /* infloop protection */
|
||||
gtk_css_provider_load_named (provider, DEFAULT_THEME_NAME, NULL);
|
||||
}
|
||||
g_return_if_fail (!g_str_equal (name, DEFAULT_THEME_NAME)); /* infloop protection */
|
||||
gtk_css_provider_load_named (provider, DEFAULT_THEME_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,8 +63,7 @@ void gtk_css_provider_load_from_resource (GtkCssProvider *css_provid
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_css_provider_load_named (GtkCssProvider *provider,
|
||||
const char *name,
|
||||
const char *variant);
|
||||
const char *name);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ gchar *_gtk_get_theme_dir (void);
|
||||
|
||||
const gchar *_gtk_css_provider_get_theme_dir (GtkCssProvider *provider);
|
||||
|
||||
char *_gtk_css_find_theme (const char *theme);
|
||||
|
||||
void gtk_css_provider_set_keep_css_sections (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@@ -1003,7 +1003,6 @@ populate_dialog (GtkCustomPaperUnixDialog *dialog)
|
||||
GtkTreeIter iter;
|
||||
GtkTreeSelection *selection;
|
||||
GtkUnit user_units;
|
||||
GtkStyleContext *context;
|
||||
|
||||
content_area = gtk_dialog_get_content_area (cpu_dialog);
|
||||
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
|
||||
@@ -1052,8 +1051,7 @@ populate_dialog (GtkCustomPaperUnixDialog *dialog)
|
||||
|
||||
toolbar = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
|
||||
context = gtk_widget_get_style_context (toolbar);
|
||||
gtk_style_context_add_class (context, "linked");
|
||||
gtk_widget_add_css_class (toolbar, "linked");
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (vbox), toolbar);
|
||||
|
||||
|
||||
+2
-8
@@ -317,10 +317,6 @@ gtk_drag_icon_get_property (GObject *object,
|
||||
g_value_set_object (value, self->child);
|
||||
break;
|
||||
|
||||
case LAST_ARG + GTK_ROOT_PROP_FOCUS_WIDGET:
|
||||
g_value_set_object (value, NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@@ -341,9 +337,6 @@ gtk_drag_icon_set_property (GObject *object,
|
||||
gtk_drag_icon_set_child (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case LAST_ARG + GTK_ROOT_PROP_FOCUS_WIDGET:
|
||||
// do nothing
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@@ -368,6 +361,8 @@ gtk_drag_icon_class_init (GtkDragIconClass *klass)
|
||||
widget_class->size_allocate = gtk_drag_icon_size_allocate;
|
||||
widget_class->show = gtk_drag_icon_show;
|
||||
widget_class->hide = gtk_drag_icon_hide;
|
||||
widget_class->focus = gtk_widget_focus_none;
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_none;
|
||||
|
||||
/**
|
||||
* GtkDragIcon:child:
|
||||
@@ -382,7 +377,6 @@ gtk_drag_icon_class_init (GtkDragIconClass *klass)
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, LAST_ARG, properties);
|
||||
gtk_root_install_properties (object_class, LAST_ARG);
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, "dnd");
|
||||
}
|
||||
|
||||
@@ -262,6 +262,8 @@ gtk_drawing_area_class_init (GtkDrawingAreaClass *class)
|
||||
|
||||
widget_class->measure = gtk_drawing_area_measure;
|
||||
widget_class->snapshot = gtk_drawing_area_snapshot;
|
||||
widget_class->focus = gtk_widget_focus_none;
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_none;
|
||||
|
||||
/**
|
||||
* GtkDrawingArea:content-width
|
||||
|
||||
@@ -499,7 +499,7 @@ add_emoji (GtkWidget *list,
|
||||
pango_attr_list_insert (attrs, pango_attr_scale_new (PANGO_SCALE_X_LARGE));
|
||||
gtk_label_set_attributes (GTK_LABEL (label), attrs);
|
||||
pango_attr_list_unref (attrs);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (label), "emoji");
|
||||
gtk_widget_add_css_class (label, "emoji");
|
||||
|
||||
child = g_object_new (GTK_TYPE_LIST_BOX_ROW, "css-name", "emoji-completion-row", NULL);
|
||||
gtk_widget_set_focus_on_click (child, FALSE);
|
||||
|
||||
@@ -138,6 +138,30 @@
|
||||
*
|
||||
* For all the subnodes added to the text node in various situations,
|
||||
* see #GtkText.
|
||||
*
|
||||
* # GtkEntry as GtkBuildable
|
||||
*
|
||||
* The GtkEntry implementation of the GtkBuildable interface supports a
|
||||
* custom <attributes> element, which supports any number of <attribute>
|
||||
* elements. The <attribute> element has attributes named “name“, “value“,
|
||||
* “start“ and “end“ and allows you to specify #PangoAttribute values for
|
||||
* this label.
|
||||
*
|
||||
* An example of a UI definition fragment specifying Pango attributes:
|
||||
* |[
|
||||
* <object class="GtkEnry">
|
||||
* <attributes>
|
||||
* <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
|
||||
* <attribute name="background" value="red" start="5" end="10"/>
|
||||
* </attributes>
|
||||
* </object>
|
||||
* ]|
|
||||
*
|
||||
* The start and end attributes specify the range of characters to which the
|
||||
* Pango attribute applies. If start and end are not specified, the attribute is
|
||||
* applied to the whole text. Note that specifying ranges does not make much
|
||||
* sense with translatable attributes. Use markup embedded in the translatable
|
||||
* content instead.
|
||||
*/
|
||||
|
||||
#define MAX_ICONS 2
|
||||
@@ -413,6 +437,7 @@ gtk_entry_class_init (GtkEntryClass *class)
|
||||
widget_class->query_tooltip = gtk_entry_query_tooltip;
|
||||
widget_class->direction_changed = gtk_entry_direction_changed;
|
||||
widget_class->grab_focus = gtk_entry_grab_focus;
|
||||
widget_class->focus = gtk_widget_focus_child;
|
||||
widget_class->mnemonic_activate = gtk_entry_mnemonic_activate;
|
||||
|
||||
quark_entry_completion = g_quark_from_static_string ("gtk-entry-completion-key");
|
||||
|
||||
@@ -2233,7 +2233,6 @@ gtk_entry_completion_changed (GtkWidget *widget,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (user_data);
|
||||
GdkDevice *device;
|
||||
|
||||
if (!completion->priv->popup_completion)
|
||||
return;
|
||||
@@ -2257,14 +2256,6 @@ gtk_entry_completion_changed (GtkWidget *widget,
|
||||
return;
|
||||
}
|
||||
|
||||
device = gtk_get_current_event_device ();
|
||||
|
||||
if (device && gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
|
||||
device = gdk_device_get_associated_device (device);
|
||||
|
||||
if (device)
|
||||
completion->priv->device = device;
|
||||
|
||||
completion->priv->completion_timeout =
|
||||
g_timeout_add (COMPLETION_TIMEOUT,
|
||||
gtk_entry_completion_timeout,
|
||||
|
||||
@@ -104,8 +104,6 @@ struct _GtkEntryCompletionPrivate
|
||||
gchar *completion_prefix;
|
||||
|
||||
GSource *check_completion_idle;
|
||||
|
||||
GdkDevice *device;
|
||||
};
|
||||
|
||||
void _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion);
|
||||
|
||||
@@ -59,6 +59,7 @@ struct _GtkEventControllerPrivate
|
||||
GtkPropagationLimit limit;
|
||||
char *name;
|
||||
GtkWidget *target;
|
||||
GdkEvent *event;
|
||||
};
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GtkEventController, gtk_event_controller, G_TYPE_OBJECT)
|
||||
@@ -337,13 +338,15 @@ gtk_event_controller_handle_event (GtkEventController *controller,
|
||||
|
||||
controller_class = GTK_EVENT_CONTROLLER_GET_CLASS (controller);
|
||||
|
||||
priv->target = target;
|
||||
priv->target = g_object_ref (target);
|
||||
priv->event = gdk_event_ref (event);
|
||||
|
||||
g_object_ref (controller);
|
||||
retval = controller_class->handle_event (controller, event, x, y);
|
||||
g_object_unref (controller);
|
||||
|
||||
priv->target = NULL;
|
||||
g_clear_object (&priv->target);
|
||||
g_clear_pointer (&priv->event, gdk_event_unref);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -532,6 +535,83 @@ gtk_event_controller_get_target (GtkEventController *controller)
|
||||
return priv->target;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_get_current_event:
|
||||
* @controller: a #GtkEventController
|
||||
*
|
||||
* Returns the event that is currently being handled by the
|
||||
* controller, and %NULL at other times.
|
||||
*
|
||||
* Returns: (nullable) the event is current handled by @controller
|
||||
*/
|
||||
GdkEvent *
|
||||
gtk_event_controller_get_current_event (GtkEventController *controller)
|
||||
{
|
||||
GtkEventControllerPrivate *priv = gtk_event_controller_get_instance_private (controller);
|
||||
|
||||
return priv->event;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_get_current_event_time:
|
||||
* @controller: a #GtkEventController
|
||||
*
|
||||
* Returns the timestamp of the event that is currently being
|
||||
* handled by the controller, and 0 otherwise.
|
||||
*
|
||||
* Returns: timestamp of the event is current handled by @controller
|
||||
*/
|
||||
guint32
|
||||
gtk_event_controller_get_current_event_time (GtkEventController *controller)
|
||||
{
|
||||
GtkEventControllerPrivate *priv = gtk_event_controller_get_instance_private (controller);
|
||||
|
||||
if (priv->event)
|
||||
return gdk_event_get_time (priv->event);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_get_current_event_device:
|
||||
* @controller: a #GtkEventController
|
||||
*
|
||||
* Returns the device of the event that is currently being
|
||||
* handled by the controller, and %NULL otherwise.
|
||||
*
|
||||
* Returns: (nullable): device of the event is current handled by @controller
|
||||
*/
|
||||
GdkDevice *
|
||||
gtk_event_controller_get_current_event_device (GtkEventController *controller)
|
||||
{
|
||||
GtkEventControllerPrivate *priv = gtk_event_controller_get_instance_private (controller);
|
||||
|
||||
if (priv->event)
|
||||
return gdk_event_get_device (priv->event);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_get_current_event_device:
|
||||
* @controller: a #GtkEventController
|
||||
*
|
||||
* Returns the modifier state of the event that is currently being
|
||||
* handled by the controller, and 0 otherwise.
|
||||
*
|
||||
* Returns: (nullable): modifier state of the event is current handled by @controller
|
||||
*/
|
||||
GdkModifierType
|
||||
gtk_event_controller_get_current_event_state (GtkEventController *controller)
|
||||
{
|
||||
GtkEventControllerPrivate *priv = gtk_event_controller_get_instance_private (controller);
|
||||
|
||||
if (priv->event)
|
||||
return gdk_event_get_modifier_state (priv->event);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static GtkCrossingData *
|
||||
gtk_crossing_data_copy (GtkCrossingData *crossing)
|
||||
{
|
||||
|
||||
@@ -72,6 +72,15 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gtk_event_controller_set_name (GtkEventController *controller,
|
||||
const char *name);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkEvent * gtk_event_controller_get_current_event (GtkEventController *controller);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
guint32 gtk_event_controller_get_current_event_time (GtkEventController *controller);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDevice * gtk_event_controller_get_current_event_device (GtkEventController *controller);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkModifierType gtk_event_controller_get_current_event_state (GtkEventController *controller);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_EVENT_CONTROLLER_H__ */
|
||||
|
||||
@@ -100,7 +100,8 @@ struct _GtkEventControllerClass
|
||||
gpointer padding[10];
|
||||
};
|
||||
|
||||
GtkWidget *gtk_event_controller_get_target (GtkEventController *controller);
|
||||
GtkWidget * gtk_event_controller_get_target (GtkEventController *controller);
|
||||
|
||||
|
||||
gboolean gtk_event_controller_handle_event (GtkEventController *controller,
|
||||
GdkEvent *event,
|
||||
|
||||
+6
-7
@@ -300,12 +300,13 @@ gtk_expander_class_init (GtkExpanderClass *klass)
|
||||
gobject_class->set_property = gtk_expander_set_property;
|
||||
gobject_class->get_property = gtk_expander_get_property;
|
||||
|
||||
widget_class->destroy = gtk_expander_destroy;
|
||||
widget_class->size_allocate = gtk_expander_size_allocate;
|
||||
widget_class->focus = gtk_expander_focus;
|
||||
widget_class->measure = gtk_expander_measure;
|
||||
widget_class->destroy = gtk_expander_destroy;
|
||||
widget_class->size_allocate = gtk_expander_size_allocate;
|
||||
widget_class->focus = gtk_expander_focus;
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_self;
|
||||
widget_class->measure = gtk_expander_measure;
|
||||
|
||||
container_class->add = gtk_expander_add;
|
||||
container_class->add = gtk_expander_add;
|
||||
container_class->remove = gtk_expander_remove;
|
||||
container_class->forall = gtk_expander_forall;
|
||||
|
||||
@@ -385,8 +386,6 @@ gtk_expander_init (GtkExpander *expander)
|
||||
GtkGesture *gesture;
|
||||
GtkEventController *controller;
|
||||
|
||||
gtk_widget_set_can_focus (GTK_WIDGET (expander), TRUE);
|
||||
|
||||
priv->label_widget = NULL;
|
||||
priv->child = NULL;
|
||||
|
||||
|
||||
+367
-379
File diff suppressed because it is too large
Load Diff
@@ -51,6 +51,11 @@ gint gtk_file_chooser_button_get_width_chars (GtkFileChooserBu
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_file_chooser_button_set_width_chars (GtkFileChooserButton *button,
|
||||
gint n_chars);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_file_chooser_button_get_modal (GtkFileChooserButton *button);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_file_chooser_button_set_modal (GtkFileChooserButton *button,
|
||||
gboolean modal);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -1502,7 +1502,7 @@ open_folder_cb (GSimpleAction *action,
|
||||
gchar *uri;
|
||||
|
||||
uri = g_file_get_uri (file);
|
||||
gtk_show_uri_on_window (GTK_WINDOW (toplevel), uri, gtk_get_current_event_time (), NULL);
|
||||
gtk_show_uri (GTK_WINDOW (toplevel), uri, GDK_CURRENT_TIME);
|
||||
g_free (uri);
|
||||
}
|
||||
|
||||
@@ -2290,7 +2290,7 @@ save_widgets_create (GtkFileChooserWidget *impl)
|
||||
}
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (vbox), "search-bar");
|
||||
gtk_widget_add_css_class (vbox, "search-bar");
|
||||
|
||||
impl->save_widgets_table = gtk_grid_new ();
|
||||
gtk_container_add (GTK_CONTAINER (vbox), impl->save_widgets_table);
|
||||
@@ -7222,6 +7222,8 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
|
||||
widget_class->unroot = gtk_file_chooser_widget_unroot;
|
||||
widget_class->css_changed = gtk_file_chooser_widget_css_changed;
|
||||
widget_class->size_allocate = gtk_file_chooser_widget_size_allocate;
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_child;
|
||||
widget_class->focus = gtk_widget_focus_child;
|
||||
|
||||
/*
|
||||
* Signals
|
||||
|
||||
+29
-52
@@ -129,28 +129,6 @@ static void gtk_flow_box_set_accept_unpaired_release (GtkFlowBox *box,
|
||||
|
||||
static void gtk_flow_box_check_model_compat (GtkFlowBox *box);
|
||||
|
||||
static void
|
||||
get_current_selection_modifiers (GtkWidget *widget,
|
||||
gboolean *modify,
|
||||
gboolean *extend)
|
||||
{
|
||||
GdkModifierType state = 0;
|
||||
GdkModifierType mask;
|
||||
|
||||
*modify = FALSE;
|
||||
*extend = FALSE;
|
||||
|
||||
if (gtk_get_current_event_state (&state))
|
||||
{
|
||||
mask = GDK_CONTROL_MASK;
|
||||
if ((state & mask) == mask)
|
||||
*modify = TRUE;
|
||||
mask = GDK_SHIFT_MASK;
|
||||
if ((state & mask) == mask)
|
||||
*extend = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
path_from_horizontal_line_rects (cairo_t *cr,
|
||||
GdkRectangle *lines,
|
||||
@@ -307,15 +285,8 @@ static void
|
||||
gtk_flow_box_child_set_focus (GtkFlowBoxChild *child)
|
||||
{
|
||||
GtkFlowBox *box = gtk_flow_box_child_get_box (child);
|
||||
gboolean modify;
|
||||
gboolean extend;
|
||||
|
||||
get_current_selection_modifiers (GTK_WIDGET (box), &modify, &extend);
|
||||
|
||||
if (modify)
|
||||
gtk_flow_box_update_cursor (box, child);
|
||||
else
|
||||
gtk_flow_box_update_selection (box, child, FALSE, FALSE);
|
||||
gtk_flow_box_update_selection (box, child, FALSE, FALSE);
|
||||
}
|
||||
|
||||
/* GtkWidget implementation {{{2 */
|
||||
@@ -613,7 +584,9 @@ struct _GtkFlowBoxClass
|
||||
void (*toggle_cursor_child) (GtkFlowBox *box);
|
||||
gboolean (*move_cursor) (GtkFlowBox *box,
|
||||
GtkMovementStep step,
|
||||
gint count);
|
||||
gint count,
|
||||
gboolean extend,
|
||||
gboolean modify);
|
||||
void (*select_all) (GtkFlowBox *box);
|
||||
void (*unselect_all) (GtkFlowBox *box);
|
||||
};
|
||||
@@ -2708,10 +2681,13 @@ gtk_flow_box_click_gesture_released (GtkGestureClick *gesture,
|
||||
GdkEventSequence *sequence;
|
||||
GdkInputSource source;
|
||||
GdkEvent *event;
|
||||
GdkModifierType state;
|
||||
gboolean modify;
|
||||
gboolean extend;
|
||||
|
||||
get_current_selection_modifiers (GTK_WIDGET (box), &modify, &extend);
|
||||
state = gtk_event_controller_get_current_event_state (GTK_EVENT_CONTROLLER (gesture));
|
||||
modify = (state & GDK_CONTROL_MASK) != 0;
|
||||
extend = (state & GDK_SHIFT_MASK) != 0;
|
||||
|
||||
/* With touch, we default to modifying the selection.
|
||||
* You can still clear the selection and start over
|
||||
@@ -2747,6 +2723,7 @@ gtk_flow_box_drag_gesture_begin (GtkGestureDrag *gesture,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkFlowBoxPrivate *priv = BOX_PRIV (widget);
|
||||
GdkModifierType state;
|
||||
|
||||
if (priv->selection_mode != GTK_SELECTION_MULTIPLE)
|
||||
{
|
||||
@@ -2757,7 +2734,10 @@ gtk_flow_box_drag_gesture_begin (GtkGestureDrag *gesture,
|
||||
priv->rubberband_select = FALSE;
|
||||
priv->rubberband_first = NULL;
|
||||
priv->rubberband_last = NULL;
|
||||
get_current_selection_modifiers (widget, &priv->rubberband_modify, &priv->rubberband_extend);
|
||||
|
||||
state = gtk_event_controller_get_current_event_state (GTK_EVENT_CONTROLLER (gesture));
|
||||
priv->rubberband_modify = (state & GDK_CONTROL_MASK) != 0;
|
||||
priv->rubberband_extend = (state & GDK_SHIFT_MASK) != 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2992,25 +2972,22 @@ gtk_flow_box_add_move_binding (GtkWidgetClass *widget_class,
|
||||
GtkMovementStep step,
|
||||
gint count)
|
||||
{
|
||||
GdkModifierType extend_mod_mask = GDK_SHIFT_MASK;
|
||||
GdkModifierType modify_mod_mask = GDK_CONTROL_MASK;
|
||||
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask,
|
||||
"move-cursor",
|
||||
"(ii)", step, count);
|
||||
"(iibb)", step, count, FALSE, FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask | extend_mod_mask,
|
||||
keyval, modmask | GDK_SHIFT_MASK,
|
||||
"move-cursor",
|
||||
"(ii)", step, count);
|
||||
"(iibb)", step, count, TRUE, FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask | modify_mod_mask,
|
||||
keyval, modmask | GDK_CONTROL_MASK,
|
||||
"move-cursor",
|
||||
"(ii)", step, count);
|
||||
"(iibb)", step, count, FALSE, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask | extend_mod_mask | modify_mod_mask,
|
||||
keyval, modmask | GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||
"move-cursor",
|
||||
"(ii)", step, count);
|
||||
"(iibb)", step, count, TRUE, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3038,11 +3015,11 @@ gtk_flow_box_toggle_cursor_child (GtkFlowBox *box)
|
||||
static gboolean
|
||||
gtk_flow_box_move_cursor (GtkFlowBox *box,
|
||||
GtkMovementStep step,
|
||||
gint count)
|
||||
gint count,
|
||||
gboolean extend,
|
||||
gboolean modify)
|
||||
{
|
||||
GtkFlowBoxPrivate *priv = BOX_PRIV (box);
|
||||
gboolean modify;
|
||||
gboolean extend;
|
||||
GtkFlowBoxChild *child;
|
||||
GtkFlowBoxChild *prev;
|
||||
GtkFlowBoxChild *next;
|
||||
@@ -3227,8 +3204,6 @@ gtk_flow_box_move_cursor (GtkFlowBox *box,
|
||||
}
|
||||
}
|
||||
|
||||
get_current_selection_modifiers (GTK_WIDGET (box), &modify, &extend);
|
||||
|
||||
gtk_flow_box_update_cursor (box, child);
|
||||
if (!modify)
|
||||
gtk_flow_box_update_selection (box, child, FALSE, extend);
|
||||
@@ -3577,6 +3552,8 @@ gtk_flow_box_class_init (GtkFlowBoxClass *class)
|
||||
* @box: the #GtkFlowBox on which the signal is emitted
|
||||
* @step: the granularity fo the move, as a #GtkMovementStep
|
||||
* @count: the number of @step units to move
|
||||
* @extend: whether to extend the selection
|
||||
* @modify: whether to modify the selection
|
||||
*
|
||||
* The ::move-cursor signal is a
|
||||
* [keybinding signal][GtkBindingSignal]
|
||||
@@ -3602,12 +3579,12 @@ gtk_flow_box_class_init (GtkFlowBoxClass *class)
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
||||
G_STRUCT_OFFSET (GtkFlowBoxClass, move_cursor),
|
||||
NULL, NULL,
|
||||
_gtk_marshal_BOOLEAN__ENUM_INT,
|
||||
G_TYPE_BOOLEAN, 2,
|
||||
GTK_TYPE_MOVEMENT_STEP, G_TYPE_INT);
|
||||
_gtk_marshal_BOOLEAN__ENUM_INT_BOOLEAN_BOOLEAN,
|
||||
G_TYPE_BOOLEAN, 4,
|
||||
GTK_TYPE_MOVEMENT_STEP, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
|
||||
g_signal_set_va_marshaller (signals[MOVE_CURSOR],
|
||||
G_TYPE_FROM_CLASS (class),
|
||||
_gtk_marshal_BOOLEAN__ENUM_INTv);
|
||||
_gtk_marshal_BOOLEAN__ENUM_INT_BOOLEAN_BOOLEANv);
|
||||
/**
|
||||
* GtkFlowBox::select-all:
|
||||
* @box: the #GtkFlowBox on which the signal is emitted
|
||||
|
||||
+242
-231
@@ -41,6 +41,7 @@
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkseparator.h"
|
||||
#include "gtkstylecontext.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
@@ -66,24 +67,14 @@ typedef struct _GtkFontButtonClass GtkFontButtonClass;
|
||||
struct _GtkFontButton
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
};
|
||||
|
||||
struct _GtkFontButtonClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
|
||||
void (* font_set) (GtkFontButton *gfp);
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gchar *title;
|
||||
|
||||
gchar *fontname;
|
||||
|
||||
guint use_font : 1;
|
||||
guint use_size : 1;
|
||||
guint show_preview_entry : 1;
|
||||
guint modal : 1;
|
||||
|
||||
GtkWidget *button;
|
||||
GtkWidget *font_dialog;
|
||||
@@ -105,7 +96,14 @@ typedef struct
|
||||
GtkCssProvider *provider;
|
||||
|
||||
GtkFontChooserLevel level;
|
||||
} GtkFontButtonPrivate;
|
||||
};
|
||||
|
||||
struct _GtkFontButtonClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
|
||||
void (* font_set) (GtkFontButton *gfp);
|
||||
};
|
||||
|
||||
/* Signals */
|
||||
enum
|
||||
@@ -118,6 +116,7 @@ enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_TITLE,
|
||||
PROP_MODAL,
|
||||
PROP_USE_FONT,
|
||||
PROP_USE_SIZE
|
||||
};
|
||||
@@ -181,32 +180,27 @@ gtk_font_button_font_chooser_iface_init (GtkFontChooserIface *iface)
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkFontButton, gtk_font_button, GTK_TYPE_WIDGET,
|
||||
G_ADD_PRIVATE (GtkFontButton)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_FONT_CHOOSER,
|
||||
gtk_font_button_font_chooser_iface_init))
|
||||
|
||||
static void
|
||||
clear_font_data (GtkFontButton *font_button)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
g_clear_object (&priv->font_family);
|
||||
g_clear_object (&priv->font_face);
|
||||
g_clear_pointer (&priv->font_desc, pango_font_description_free);
|
||||
g_clear_pointer (&priv->fontname, g_free);
|
||||
g_clear_pointer (&priv->font_features, g_free);
|
||||
g_clear_object (&font_button->font_family);
|
||||
g_clear_object (&font_button->font_face);
|
||||
g_clear_pointer (&font_button->font_desc, pango_font_description_free);
|
||||
g_clear_pointer (&font_button->fontname, g_free);
|
||||
g_clear_pointer (&font_button->font_features, g_free);
|
||||
}
|
||||
|
||||
static void
|
||||
clear_font_filter_data (GtkFontButton *font_button)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
if (priv->font_filter_data_destroy)
|
||||
priv->font_filter_data_destroy (priv->font_filter_data);
|
||||
priv->font_filter = NULL;
|
||||
priv->font_filter_data = NULL;
|
||||
priv->font_filter_data_destroy = NULL;
|
||||
if (font_button->font_filter_data_destroy)
|
||||
font_button->font_filter_data_destroy (font_button->font_filter_data);
|
||||
font_button->font_filter = NULL;
|
||||
font_button->font_filter_data = NULL;
|
||||
font_button->font_filter_data_destroy = NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -222,17 +216,16 @@ font_description_style_equal (const PangoFontDescription *a,
|
||||
static void
|
||||
gtk_font_button_update_font_data (GtkFontButton *font_button)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
PangoFontFamily **families;
|
||||
PangoFontFace **faces;
|
||||
gint n_families, n_faces, i;
|
||||
const gchar *family;
|
||||
|
||||
g_assert (priv->font_desc != NULL);
|
||||
g_assert (font_button->font_desc != NULL);
|
||||
|
||||
priv->fontname = pango_font_description_to_string (priv->font_desc);
|
||||
font_button->fontname = pango_font_description_to_string (font_button->font_desc);
|
||||
|
||||
family = pango_font_description_get_family (priv->font_desc);
|
||||
family = pango_font_description_get_family (font_button->font_desc);
|
||||
if (family == NULL)
|
||||
return;
|
||||
|
||||
@@ -248,7 +241,7 @@ gtk_font_button_update_font_data (GtkFontButton *font_button)
|
||||
|
||||
if (!g_ascii_strcasecmp (name, family))
|
||||
{
|
||||
priv->font_family = g_object_ref (families[i]);
|
||||
font_button->font_family = g_object_ref (families[i]);
|
||||
|
||||
pango_font_family_list_faces (families[i], &faces, &n_faces);
|
||||
break;
|
||||
@@ -260,9 +253,9 @@ gtk_font_button_update_font_data (GtkFontButton *font_button)
|
||||
{
|
||||
PangoFontDescription *tmp_desc = pango_font_face_describe (faces[i]);
|
||||
|
||||
if (font_description_style_equal (tmp_desc, priv->font_desc))
|
||||
if (font_description_style_equal (tmp_desc, font_button->font_desc))
|
||||
{
|
||||
priv->font_face = g_object_ref (faces[i]);
|
||||
font_button->font_face = g_object_ref (faces[i]);
|
||||
|
||||
pango_font_description_free (tmp_desc);
|
||||
break;
|
||||
@@ -277,56 +270,48 @@ gtk_font_button_update_font_data (GtkFontButton *font_button)
|
||||
static gchar *
|
||||
gtk_font_button_get_preview_text (GtkFontButton *font_button)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
if (font_button->font_dialog)
|
||||
return gtk_font_chooser_get_preview_text (GTK_FONT_CHOOSER (font_button->font_dialog));
|
||||
|
||||
if (priv->font_dialog)
|
||||
return gtk_font_chooser_get_preview_text (GTK_FONT_CHOOSER (priv->font_dialog));
|
||||
|
||||
return g_strdup (priv->preview_text);
|
||||
return g_strdup (font_button->preview_text);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_font_button_set_preview_text (GtkFontButton *font_button,
|
||||
const gchar *preview_text)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
if (priv->font_dialog)
|
||||
if (font_button->font_dialog)
|
||||
{
|
||||
gtk_font_chooser_set_preview_text (GTK_FONT_CHOOSER (priv->font_dialog),
|
||||
gtk_font_chooser_set_preview_text (GTK_FONT_CHOOSER (font_button->font_dialog),
|
||||
preview_text);
|
||||
return;
|
||||
}
|
||||
|
||||
g_free (priv->preview_text);
|
||||
priv->preview_text = g_strdup (preview_text);
|
||||
g_free (font_button->preview_text);
|
||||
font_button->preview_text = g_strdup (preview_text);
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
gtk_font_button_get_show_preview_entry (GtkFontButton *font_button)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
if (font_button->font_dialog)
|
||||
return gtk_font_chooser_get_show_preview_entry (GTK_FONT_CHOOSER (font_button->font_dialog));
|
||||
|
||||
if (priv->font_dialog)
|
||||
return gtk_font_chooser_get_show_preview_entry (GTK_FONT_CHOOSER (priv->font_dialog));
|
||||
|
||||
return priv->show_preview_entry;
|
||||
return font_button->show_preview_entry;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_font_button_set_show_preview_entry (GtkFontButton *font_button,
|
||||
gboolean show)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
show = show != FALSE;
|
||||
|
||||
if (priv->show_preview_entry != show)
|
||||
if (font_button->show_preview_entry != show)
|
||||
{
|
||||
priv->show_preview_entry = show;
|
||||
if (priv->font_dialog)
|
||||
gtk_font_chooser_set_show_preview_entry (GTK_FONT_CHOOSER (priv->font_dialog), show);
|
||||
font_button->show_preview_entry = show;
|
||||
if (font_button->font_dialog)
|
||||
gtk_font_chooser_set_show_preview_entry (GTK_FONT_CHOOSER (font_button->font_dialog), show);
|
||||
g_object_notify (G_OBJECT (font_button), "show-preview-entry");
|
||||
}
|
||||
}
|
||||
@@ -335,27 +320,24 @@ static PangoFontFamily *
|
||||
gtk_font_button_font_chooser_get_font_family (GtkFontChooser *chooser)
|
||||
{
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON (chooser);
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
return priv->font_family;
|
||||
return font_button->font_family;
|
||||
}
|
||||
|
||||
static PangoFontFace *
|
||||
gtk_font_button_font_chooser_get_font_face (GtkFontChooser *chooser)
|
||||
{
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON (chooser);
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
return priv->font_face;
|
||||
return font_button->font_face;
|
||||
}
|
||||
|
||||
static int
|
||||
gtk_font_button_font_chooser_get_font_size (GtkFontChooser *chooser)
|
||||
{
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON (chooser);
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
return priv->font_size;
|
||||
return font_button->font_size;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -365,11 +347,10 @@ gtk_font_button_font_chooser_set_filter_func (GtkFontChooser *chooser,
|
||||
GDestroyNotify data_destroy)
|
||||
{
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON (chooser);
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
if (priv->font_dialog)
|
||||
if (font_button->font_dialog)
|
||||
{
|
||||
gtk_font_chooser_set_filter_func (GTK_FONT_CHOOSER (priv->font_dialog),
|
||||
gtk_font_chooser_set_filter_func (GTK_FONT_CHOOSER (font_button->font_dialog),
|
||||
filter_func,
|
||||
filter_data,
|
||||
data_destroy);
|
||||
@@ -377,20 +358,19 @@ gtk_font_button_font_chooser_set_filter_func (GtkFontChooser *chooser,
|
||||
}
|
||||
|
||||
clear_font_filter_data (font_button);
|
||||
priv->font_filter = filter_func;
|
||||
priv->font_filter_data = filter_data;
|
||||
priv->font_filter_data_destroy = data_destroy;
|
||||
font_button->font_filter = filter_func;
|
||||
font_button->font_filter_data = filter_data;
|
||||
font_button->font_filter_data_destroy = data_destroy;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_font_button_take_font_desc (GtkFontButton *font_button,
|
||||
PangoFontDescription *font_desc)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
GObject *object = G_OBJECT (font_button);
|
||||
|
||||
if (priv->font_desc && font_desc &&
|
||||
pango_font_description_equal (priv->font_desc, font_desc))
|
||||
if (font_button->font_desc && font_desc &&
|
||||
pango_font_description_equal (font_button->font_desc, font_desc))
|
||||
{
|
||||
pango_font_description_free (font_desc);
|
||||
return;
|
||||
@@ -401,21 +381,21 @@ gtk_font_button_take_font_desc (GtkFontButton *font_button,
|
||||
clear_font_data (font_button);
|
||||
|
||||
if (font_desc)
|
||||
priv->font_desc = font_desc; /* adopted */
|
||||
font_button->font_desc = font_desc; /* adopted */
|
||||
else
|
||||
priv->font_desc = pango_font_description_from_string (_("Sans 12"));
|
||||
font_button->font_desc = pango_font_description_from_string (_("Sans 12"));
|
||||
|
||||
if (pango_font_description_get_size_is_absolute (priv->font_desc))
|
||||
priv->font_size = pango_font_description_get_size (priv->font_desc);
|
||||
if (pango_font_description_get_size_is_absolute (font_button->font_desc))
|
||||
font_button->font_size = pango_font_description_get_size (font_button->font_desc);
|
||||
else
|
||||
priv->font_size = pango_font_description_get_size (priv->font_desc) / PANGO_SCALE;
|
||||
font_button->font_size = pango_font_description_get_size (font_button->font_desc) / PANGO_SCALE;
|
||||
|
||||
gtk_font_button_update_font_data (font_button);
|
||||
gtk_font_button_update_font_info (font_button);
|
||||
|
||||
if (priv->font_dialog)
|
||||
gtk_font_chooser_set_font_desc (GTK_FONT_CHOOSER (priv->font_dialog),
|
||||
priv->font_desc);
|
||||
if (font_button->font_dialog)
|
||||
gtk_font_chooser_set_font_desc (GTK_FONT_CHOOSER (font_button->font_dialog),
|
||||
font_button->font_desc);
|
||||
|
||||
g_object_notify (G_OBJECT (font_button), "font");
|
||||
g_object_notify (G_OBJECT (font_button), "font-desc");
|
||||
@@ -426,9 +406,7 @@ gtk_font_button_take_font_desc (GtkFontButton *font_button,
|
||||
static const PangoFontDescription *
|
||||
gtk_font_button_get_font_desc (GtkFontButton *font_button)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
return priv->font_desc;
|
||||
return font_button->font_desc;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -436,16 +414,15 @@ gtk_font_button_font_chooser_set_font_map (GtkFontChooser *chooser,
|
||||
PangoFontMap *font_map)
|
||||
{
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON (chooser);
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
if (g_set_object (&priv->font_map, font_map))
|
||||
if (g_set_object (&font_button->font_map, font_map))
|
||||
{
|
||||
PangoContext *context;
|
||||
|
||||
if (!font_map)
|
||||
font_map = pango_cairo_font_map_get_default ();
|
||||
|
||||
context = gtk_widget_get_pango_context (priv->font_label);
|
||||
context = gtk_widget_get_pango_context (font_button->font_label);
|
||||
pango_context_set_font_map (context, font_map);
|
||||
}
|
||||
}
|
||||
@@ -454,9 +431,8 @@ static PangoFontMap *
|
||||
gtk_font_button_font_chooser_get_font_map (GtkFontChooser *chooser)
|
||||
{
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON (chooser);
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
return priv->font_map;
|
||||
return font_button->font_map;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -483,6 +459,9 @@ gtk_font_button_class_init (GtkFontButtonClass *klass)
|
||||
gobject_class->set_property = gtk_font_button_set_property;
|
||||
gobject_class->get_property = gtk_font_button_get_property;
|
||||
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_child;
|
||||
widget_class->focus = gtk_widget_focus_child;
|
||||
|
||||
klass->font_set = NULL;
|
||||
|
||||
_gtk_font_chooser_install_properties (gobject_class);
|
||||
@@ -528,6 +507,14 @@ gtk_font_button_class_init (GtkFontButtonClass *klass)
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_MODAL,
|
||||
g_param_spec_boolean ("modal",
|
||||
P_("Modal"),
|
||||
P_("Whether the dialog is modal"),
|
||||
TRUE,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
||||
|
||||
/**
|
||||
* GtkFontButton::font-set:
|
||||
* @widget: the object which received the signal.
|
||||
@@ -555,64 +542,63 @@ gtk_font_button_class_init (GtkFontButtonClass *klass)
|
||||
static void
|
||||
gtk_font_button_init (GtkFontButton *font_button)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
GtkWidget *box;
|
||||
|
||||
priv->button = gtk_button_new ();
|
||||
g_signal_connect (priv->button, "clicked", G_CALLBACK (gtk_font_button_clicked), font_button);
|
||||
priv->font_label = gtk_label_new (_("Font"));
|
||||
gtk_widget_set_hexpand (priv->font_label, TRUE);
|
||||
priv->size_label = gtk_label_new ("14");
|
||||
priv->font_size_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
font_button->button = gtk_button_new ();
|
||||
g_signal_connect (font_button->button, "clicked", G_CALLBACK (gtk_font_button_clicked), font_button);
|
||||
font_button->font_label = gtk_label_new (_("Font"));
|
||||
gtk_widget_set_hexpand (font_button->font_label, TRUE);
|
||||
font_button->size_label = gtk_label_new ("14");
|
||||
font_button->font_size_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_container_add (GTK_CONTAINER (box), priv->font_label);
|
||||
gtk_container_add (GTK_CONTAINER (box), font_button->font_label);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (priv->font_size_box), gtk_separator_new (GTK_ORIENTATION_VERTICAL));
|
||||
gtk_container_add (GTK_CONTAINER (priv->font_size_box), priv->size_label);
|
||||
gtk_container_add (GTK_CONTAINER (box), priv->font_size_box);
|
||||
gtk_container_add (GTK_CONTAINER (font_button->font_size_box), gtk_separator_new (GTK_ORIENTATION_VERTICAL));
|
||||
gtk_container_add (GTK_CONTAINER (font_button->font_size_box), font_button->size_label);
|
||||
gtk_container_add (GTK_CONTAINER (box), font_button->font_size_box);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (priv->button), box);
|
||||
gtk_widget_set_parent (priv->button, GTK_WIDGET (font_button));
|
||||
gtk_container_add (GTK_CONTAINER (font_button->button), box);
|
||||
gtk_widget_set_parent (font_button->button, GTK_WIDGET (font_button));
|
||||
|
||||
/* Initialize fields */
|
||||
priv->use_font = FALSE;
|
||||
priv->use_size = FALSE;
|
||||
priv->show_preview_entry = TRUE;
|
||||
priv->font_dialog = NULL;
|
||||
priv->font_family = NULL;
|
||||
priv->font_face = NULL;
|
||||
priv->font_size = -1;
|
||||
priv->title = g_strdup (_("Pick a Font"));
|
||||
priv->level = GTK_FONT_CHOOSER_LEVEL_FAMILY |
|
||||
GTK_FONT_CHOOSER_LEVEL_STYLE |
|
||||
GTK_FONT_CHOOSER_LEVEL_SIZE;
|
||||
priv->language = pango_language_get_default ();
|
||||
font_button->modal = TRUE;
|
||||
font_button->use_font = FALSE;
|
||||
font_button->use_size = FALSE;
|
||||
font_button->show_preview_entry = TRUE;
|
||||
font_button->font_dialog = NULL;
|
||||
font_button->font_family = NULL;
|
||||
font_button->font_face = NULL;
|
||||
font_button->font_size = -1;
|
||||
font_button->title = g_strdup (_("Pick a Font"));
|
||||
font_button->level = GTK_FONT_CHOOSER_LEVEL_FAMILY |
|
||||
GTK_FONT_CHOOSER_LEVEL_STYLE |
|
||||
GTK_FONT_CHOOSER_LEVEL_SIZE;
|
||||
font_button->language = pango_language_get_default ();
|
||||
|
||||
gtk_font_button_take_font_desc (font_button, NULL);
|
||||
|
||||
gtk_widget_add_css_class (priv->button, "font");
|
||||
gtk_widget_add_css_class (font_button->button, "font");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_font_button_finalize (GObject *object)
|
||||
{
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON (object);
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
if (priv->font_dialog != NULL)
|
||||
gtk_widget_destroy (priv->font_dialog);
|
||||
if (font_button->font_dialog != NULL)
|
||||
gtk_widget_destroy (font_button->font_dialog);
|
||||
|
||||
g_free (priv->title);
|
||||
g_free (font_button->title);
|
||||
|
||||
clear_font_data (font_button);
|
||||
clear_font_filter_data (font_button);
|
||||
|
||||
g_free (priv->preview_text);
|
||||
g_free (font_button->preview_text);
|
||||
|
||||
g_clear_object (&priv->provider);
|
||||
g_clear_object (&font_button->provider);
|
||||
|
||||
gtk_widget_unparent (priv->button);
|
||||
gtk_widget_unparent (font_button->button);
|
||||
|
||||
G_OBJECT_CLASS (gtk_font_button_parent_class)->finalize (object);
|
||||
}
|
||||
@@ -636,6 +622,9 @@ gtk_font_button_set_property (GObject *object,
|
||||
case PROP_TITLE:
|
||||
gtk_font_button_set_title (font_button, g_value_get_string (value));
|
||||
break;
|
||||
case PROP_MODAL:
|
||||
gtk_font_button_set_modal (font_button, g_value_get_boolean (value));
|
||||
break;
|
||||
case GTK_FONT_CHOOSER_PROP_FONT_DESC:
|
||||
gtk_font_button_take_font_desc (font_button, g_value_dup_boxed (value));
|
||||
break;
|
||||
@@ -667,7 +656,6 @@ gtk_font_button_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON (object);
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
@@ -680,17 +668,20 @@ gtk_font_button_get_property (GObject *object,
|
||||
case PROP_TITLE:
|
||||
g_value_set_string (value, gtk_font_button_get_title (font_button));
|
||||
break;
|
||||
case PROP_MODAL:
|
||||
g_value_set_boolean (value, gtk_font_button_get_modal (font_button));
|
||||
break;
|
||||
case GTK_FONT_CHOOSER_PROP_FONT_DESC:
|
||||
g_value_set_boxed (value, gtk_font_button_get_font_desc (font_button));
|
||||
break;
|
||||
case GTK_FONT_CHOOSER_PROP_FONT_FEATURES:
|
||||
g_value_set_string (value, priv->font_features);
|
||||
g_value_set_string (value, font_button->font_features);
|
||||
break;
|
||||
case GTK_FONT_CHOOSER_PROP_LANGUAGE:
|
||||
g_value_set_string (value, pango_language_to_string (priv->language));
|
||||
g_value_set_string (value, pango_language_to_string (font_button->language));
|
||||
break;
|
||||
case GTK_FONT_CHOOSER_PROP_LEVEL:
|
||||
g_value_set_flags (value, priv->level);
|
||||
g_value_set_flags (value, font_button->level);
|
||||
break;
|
||||
case GTK_FONT_CHOOSER_PROP_FONT:
|
||||
g_value_set_string (value, gtk_font_button_get_font_name (font_button));
|
||||
@@ -746,16 +737,15 @@ void
|
||||
gtk_font_button_set_title (GtkFontButton *font_button,
|
||||
const gchar *title)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
gchar *old_title;
|
||||
g_return_if_fail (GTK_IS_FONT_BUTTON (font_button));
|
||||
|
||||
old_title = priv->title;
|
||||
priv->title = g_strdup (title);
|
||||
old_title = font_button->title;
|
||||
font_button->title = g_strdup (title);
|
||||
g_free (old_title);
|
||||
|
||||
if (priv->font_dialog)
|
||||
gtk_window_set_title (GTK_WINDOW (priv->font_dialog), priv->title);
|
||||
if (font_button->font_dialog)
|
||||
gtk_window_set_title (GTK_WINDOW (font_button->font_dialog), font_button->title);
|
||||
|
||||
g_object_notify (G_OBJECT (font_button), "title");
|
||||
}
|
||||
@@ -771,13 +761,51 @@ gtk_font_button_set_title (GtkFontButton *font_button,
|
||||
const gchar*
|
||||
gtk_font_button_get_title (GtkFontButton *font_button)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_FONT_BUTTON (font_button), NULL);
|
||||
|
||||
return priv->title;
|
||||
return font_button->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_button_set_modal:
|
||||
* @font_button: a #GtkFontButton
|
||||
* @modal: %TRUE to make the dialog modal
|
||||
*
|
||||
* Sets whether the dialog should be modal.
|
||||
*/
|
||||
void
|
||||
gtk_font_button_set_modal (GtkFontButton *font_button,
|
||||
gboolean modal)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_FONT_BUTTON (font_button));
|
||||
|
||||
if (font_button->modal == modal)
|
||||
return;
|
||||
|
||||
font_button->modal = modal;
|
||||
|
||||
if (font_button->font_dialog)
|
||||
gtk_window_set_modal (GTK_WINDOW (font_button->font_dialog), font_button->modal);
|
||||
|
||||
g_object_notify (G_OBJECT (font_button), "modal");
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_button_get_modal:
|
||||
* @font_button: a #GtkFontButton
|
||||
*
|
||||
* Gets whether the dialog is modal.
|
||||
*
|
||||
* Returns: %TRUE if the dialog is modal
|
||||
*/
|
||||
gboolean
|
||||
gtk_font_button_get_modal (GtkFontButton *font_button)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FONT_BUTTON (font_button), FALSE);
|
||||
|
||||
return font_button->modal;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_button_get_use_font:
|
||||
* @font_button: a #GtkFontButton
|
||||
@@ -789,11 +817,9 @@ gtk_font_button_get_title (GtkFontButton *font_button)
|
||||
gboolean
|
||||
gtk_font_button_get_use_font (GtkFontButton *font_button)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_FONT_BUTTON (font_button), FALSE);
|
||||
|
||||
return priv->use_font;
|
||||
return font_button->use_font;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -807,14 +833,13 @@ void
|
||||
gtk_font_button_set_use_font (GtkFontButton *font_button,
|
||||
gboolean use_font)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
g_return_if_fail (GTK_IS_FONT_BUTTON (font_button));
|
||||
|
||||
use_font = (use_font != FALSE);
|
||||
|
||||
if (priv->use_font != use_font)
|
||||
if (font_button->use_font != use_font)
|
||||
{
|
||||
priv->use_font = use_font;
|
||||
font_button->use_font = use_font;
|
||||
|
||||
gtk_font_button_label_use_font (font_button);
|
||||
|
||||
@@ -834,11 +859,9 @@ gtk_font_button_set_use_font (GtkFontButton *font_button,
|
||||
gboolean
|
||||
gtk_font_button_get_use_size (GtkFontButton *font_button)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_FONT_BUTTON (font_button), FALSE);
|
||||
|
||||
return priv->use_size;
|
||||
return font_button->use_size;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -852,14 +875,12 @@ void
|
||||
gtk_font_button_set_use_size (GtkFontButton *font_button,
|
||||
gboolean use_size)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
g_return_if_fail (GTK_IS_FONT_BUTTON (font_button));
|
||||
|
||||
use_size = (use_size != FALSE);
|
||||
if (priv->use_size != use_size)
|
||||
if (font_button->use_size != use_size)
|
||||
{
|
||||
priv->use_size = use_size;
|
||||
font_button->use_size = use_size;
|
||||
|
||||
gtk_font_button_label_use_font (font_button);
|
||||
|
||||
@@ -870,11 +891,9 @@ gtk_font_button_set_use_size (GtkFontButton *font_button,
|
||||
static const gchar *
|
||||
gtk_font_button_get_font_name (GtkFontButton *font_button)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_FONT_BUTTON (font_button), NULL);
|
||||
|
||||
return priv->fontname;
|
||||
return font_button->fontname;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -893,42 +912,42 @@ gtk_font_button_clicked (GtkButton *button,
|
||||
{
|
||||
GtkFontChooser *font_dialog;
|
||||
GtkFontButton *font_button = user_data;
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
if (!priv->font_dialog)
|
||||
if (!font_button->font_dialog)
|
||||
{
|
||||
GtkWidget *parent;
|
||||
|
||||
parent = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (font_button)));
|
||||
|
||||
priv->font_dialog = gtk_font_chooser_dialog_new (priv->title, NULL);
|
||||
gtk_window_set_hide_on_close (GTK_WINDOW (priv->font_dialog), TRUE);
|
||||
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);
|
||||
|
||||
font_dialog = GTK_FONT_CHOOSER (priv->font_dialog);
|
||||
font_dialog = GTK_FONT_CHOOSER (font_button->font_dialog);
|
||||
|
||||
if (priv->font_map)
|
||||
gtk_font_chooser_set_font_map (font_dialog, priv->font_map);
|
||||
if (font_button->font_map)
|
||||
gtk_font_chooser_set_font_map (font_dialog, font_button->font_map);
|
||||
|
||||
gtk_font_chooser_set_show_preview_entry (font_dialog, priv->show_preview_entry);
|
||||
gtk_font_chooser_set_level (GTK_FONT_CHOOSER (font_dialog), priv->level);
|
||||
gtk_font_chooser_set_language (GTK_FONT_CHOOSER (font_dialog), pango_language_to_string (priv->language));
|
||||
gtk_font_chooser_set_show_preview_entry (font_dialog, font_button->show_preview_entry);
|
||||
gtk_font_chooser_set_level (GTK_FONT_CHOOSER (font_dialog), font_button->level);
|
||||
gtk_font_chooser_set_language (GTK_FONT_CHOOSER (font_dialog), pango_language_to_string (font_button->language));
|
||||
|
||||
if (priv->preview_text)
|
||||
if (font_button->preview_text)
|
||||
{
|
||||
gtk_font_chooser_set_preview_text (font_dialog, priv->preview_text);
|
||||
g_free (priv->preview_text);
|
||||
priv->preview_text = NULL;
|
||||
gtk_font_chooser_set_preview_text (font_dialog, font_button->preview_text);
|
||||
g_free (font_button->preview_text);
|
||||
font_button->preview_text = NULL;
|
||||
}
|
||||
|
||||
if (priv->font_filter)
|
||||
if (font_button->font_filter)
|
||||
{
|
||||
gtk_font_chooser_set_filter_func (font_dialog,
|
||||
priv->font_filter,
|
||||
priv->font_filter_data,
|
||||
priv->font_filter_data_destroy);
|
||||
priv->font_filter = NULL;
|
||||
priv->font_filter_data = NULL;
|
||||
priv->font_filter_data_destroy = NULL;
|
||||
font_button->font_filter,
|
||||
font_button->font_filter_data,
|
||||
font_button->font_filter_data_destroy);
|
||||
font_button->font_filter = NULL;
|
||||
font_button->font_filter_data = NULL;
|
||||
font_button->font_filter_data_destroy = NULL;
|
||||
}
|
||||
|
||||
if (GTK_IS_WINDOW (parent))
|
||||
@@ -936,8 +955,8 @@ gtk_font_button_clicked (GtkButton *button,
|
||||
if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (font_dialog)))
|
||||
gtk_window_set_transient_for (GTK_WINDOW (font_dialog), GTK_WINDOW (parent));
|
||||
|
||||
gtk_window_set_modal (GTK_WINDOW (font_dialog),
|
||||
gtk_window_get_modal (GTK_WINDOW (parent)));
|
||||
if (gtk_window_get_modal (GTK_WINDOW (parent)))
|
||||
gtk_window_set_modal (GTK_WINDOW (font_dialog), TRUE);
|
||||
}
|
||||
|
||||
g_signal_connect (font_dialog, "notify",
|
||||
@@ -950,14 +969,14 @@ gtk_font_button_clicked (GtkButton *button,
|
||||
G_CALLBACK (dialog_destroy), font_button);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (priv->font_dialog))
|
||||
if (!gtk_widget_get_visible (font_button->font_dialog))
|
||||
{
|
||||
font_dialog = GTK_FONT_CHOOSER (priv->font_dialog);
|
||||
gtk_font_chooser_set_font_desc (font_dialog, priv->font_desc);
|
||||
font_dialog = GTK_FONT_CHOOSER (font_button->font_dialog);
|
||||
gtk_font_chooser_set_font_desc (font_dialog, font_button->font_desc);
|
||||
}
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
gtk_window_present (GTK_WINDOW (priv->font_dialog));
|
||||
gtk_window_present (GTK_WINDOW (font_button->font_dialog));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
}
|
||||
|
||||
@@ -968,35 +987,34 @@ response_cb (GtkDialog *dialog,
|
||||
gpointer data)
|
||||
{
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON (data);
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
GtkFontChooser *font_chooser;
|
||||
GObject *object;
|
||||
|
||||
gtk_widget_hide (priv->font_dialog);
|
||||
gtk_widget_hide (font_button->font_dialog);
|
||||
|
||||
if (response_id != GTK_RESPONSE_OK)
|
||||
return;
|
||||
|
||||
font_chooser = GTK_FONT_CHOOSER (priv->font_dialog);
|
||||
font_chooser = GTK_FONT_CHOOSER (font_button->font_dialog);
|
||||
object = G_OBJECT (font_chooser);
|
||||
|
||||
g_object_freeze_notify (object);
|
||||
|
||||
clear_font_data (font_button);
|
||||
|
||||
priv->font_desc = gtk_font_chooser_get_font_desc (font_chooser);
|
||||
if (priv->font_desc)
|
||||
priv->fontname = pango_font_description_to_string (priv->font_desc);
|
||||
priv->font_family = gtk_font_chooser_get_font_family (font_chooser);
|
||||
if (priv->font_family)
|
||||
g_object_ref (priv->font_family);
|
||||
priv->font_face = gtk_font_chooser_get_font_face (font_chooser);
|
||||
if (priv->font_face)
|
||||
g_object_ref (priv->font_face);
|
||||
priv->font_size = gtk_font_chooser_get_font_size (font_chooser);
|
||||
g_free (priv->font_features);
|
||||
priv->font_features = gtk_font_chooser_get_font_features (font_chooser);
|
||||
priv->language = pango_language_from_string (gtk_font_chooser_get_language (font_chooser));
|
||||
font_button->font_desc = gtk_font_chooser_get_font_desc (font_chooser);
|
||||
if (font_button->font_desc)
|
||||
font_button->fontname = pango_font_description_to_string (font_button->font_desc);
|
||||
font_button->font_family = gtk_font_chooser_get_font_family (font_chooser);
|
||||
if (font_button->font_family)
|
||||
g_object_ref (font_button->font_family);
|
||||
font_button->font_face = gtk_font_chooser_get_font_face (font_chooser);
|
||||
if (font_button->font_face)
|
||||
g_object_ref (font_button->font_face);
|
||||
font_button->font_size = gtk_font_chooser_get_font_size (font_chooser);
|
||||
g_free (font_button->font_features);
|
||||
font_button->font_features = gtk_font_chooser_get_font_features (font_chooser);
|
||||
font_button->language = pango_language_from_string (gtk_font_chooser_get_language (font_chooser));
|
||||
|
||||
/* Set label font */
|
||||
gtk_font_button_update_font_info (font_button);
|
||||
@@ -1016,10 +1034,9 @@ dialog_destroy (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON (data);
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
/* Dialog will get destroyed so reference is not valid now */
|
||||
priv->font_dialog = NULL;
|
||||
font_button->font_dialog = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1225,17 +1242,16 @@ pango_font_description_to_css (PangoFontDescription *desc,
|
||||
static void
|
||||
gtk_font_button_label_use_font (GtkFontButton *font_button)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
GtkStyleContext *context;
|
||||
|
||||
context = gtk_widget_get_style_context (priv->font_label);
|
||||
context = gtk_widget_get_style_context (font_button->font_label);
|
||||
|
||||
if (!priv->use_font)
|
||||
if (!font_button->use_font)
|
||||
{
|
||||
if (priv->provider)
|
||||
if (font_button->provider)
|
||||
{
|
||||
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (priv->provider));
|
||||
g_clear_object (&priv->provider);
|
||||
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (font_button->provider));
|
||||
g_clear_object (&font_button->provider);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1243,23 +1259,23 @@ gtk_font_button_label_use_font (GtkFontButton *font_button)
|
||||
PangoFontDescription *desc;
|
||||
gchar *data;
|
||||
|
||||
if (!priv->provider)
|
||||
if (!font_button->provider)
|
||||
{
|
||||
priv->provider = gtk_css_provider_new ();
|
||||
font_button->provider = gtk_css_provider_new ();
|
||||
gtk_style_context_add_provider (context,
|
||||
GTK_STYLE_PROVIDER (priv->provider),
|
||||
GTK_STYLE_PROVIDER (font_button->provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
}
|
||||
|
||||
desc = pango_font_description_copy (priv->font_desc);
|
||||
desc = pango_font_description_copy (font_button->font_desc);
|
||||
|
||||
if (!priv->use_size)
|
||||
if (!font_button->use_size)
|
||||
pango_font_description_unset_fields (desc, PANGO_FONT_MASK_SIZE);
|
||||
|
||||
data = pango_font_description_to_css (desc,
|
||||
priv->font_features,
|
||||
pango_language_to_string (priv->language));
|
||||
gtk_css_provider_load_from_data (priv->provider, data, -1);
|
||||
font_button->font_features,
|
||||
pango_language_to_string (font_button->language));
|
||||
gtk_css_provider_load_from_data (font_button->provider, data, -1);
|
||||
|
||||
g_free (data);
|
||||
pango_font_description_free (desc);
|
||||
@@ -1269,43 +1285,42 @@ gtk_font_button_label_use_font (GtkFontButton *font_button)
|
||||
static void
|
||||
gtk_font_button_update_font_info (GtkFontButton *font_button)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
const gchar *fam_name;
|
||||
const gchar *face_name;
|
||||
gchar *family_style;
|
||||
|
||||
if (priv->font_family)
|
||||
fam_name = pango_font_family_get_name (priv->font_family);
|
||||
if (font_button->font_family)
|
||||
fam_name = pango_font_family_get_name (font_button->font_family);
|
||||
else
|
||||
fam_name = C_("font", "None");
|
||||
if (priv->font_face)
|
||||
face_name = pango_font_face_get_face_name (priv->font_face);
|
||||
if (font_button->font_face)
|
||||
face_name = pango_font_face_get_face_name (font_button->font_face);
|
||||
else
|
||||
face_name = "";
|
||||
|
||||
if ((priv->level & GTK_FONT_CHOOSER_LEVEL_STYLE) != 0)
|
||||
if ((font_button->level & GTK_FONT_CHOOSER_LEVEL_STYLE) != 0)
|
||||
family_style = g_strconcat (fam_name, " ", face_name, NULL);
|
||||
else
|
||||
family_style = g_strdup (fam_name);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (priv->font_label), family_style);
|
||||
gtk_label_set_text (GTK_LABEL (font_button->font_label), family_style);
|
||||
g_free (family_style);
|
||||
|
||||
if ((priv->level & GTK_FONT_CHOOSER_LEVEL_SIZE) != 0)
|
||||
if ((font_button->level & GTK_FONT_CHOOSER_LEVEL_SIZE) != 0)
|
||||
{
|
||||
/* mirror Pango, which doesn't translate this either */
|
||||
gchar *size = g_strdup_printf ("%2.4g%s",
|
||||
pango_font_description_get_size (priv->font_desc) / (double)PANGO_SCALE,
|
||||
pango_font_description_get_size_is_absolute (priv->font_desc) ? "px" : "");
|
||||
pango_font_description_get_size (font_button->font_desc) / (double)PANGO_SCALE,
|
||||
pango_font_description_get_size_is_absolute (font_button->font_desc) ? "px" : "");
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (priv->size_label), size);
|
||||
gtk_label_set_text (GTK_LABEL (font_button->size_label), size);
|
||||
|
||||
g_free (size);
|
||||
|
||||
gtk_widget_show (priv->font_size_box);
|
||||
gtk_widget_show (font_button->font_size_box);
|
||||
}
|
||||
else
|
||||
gtk_widget_hide (priv->font_size_box);
|
||||
gtk_widget_hide (font_button->font_size_box);
|
||||
|
||||
|
||||
gtk_font_button_label_use_font (font_button);
|
||||
@@ -1315,15 +1330,13 @@ static void
|
||||
gtk_font_button_set_level (GtkFontButton *font_button,
|
||||
GtkFontChooserLevel level)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
|
||||
if (priv->level == level)
|
||||
if (font_button->level == level)
|
||||
return;
|
||||
|
||||
priv->level = level;
|
||||
font_button->level = level;
|
||||
|
||||
if (priv->font_dialog)
|
||||
gtk_font_chooser_set_level (GTK_FONT_CHOOSER (priv->font_dialog), level);
|
||||
if (font_button->font_dialog)
|
||||
gtk_font_chooser_set_level (GTK_FONT_CHOOSER (font_button->font_dialog), level);
|
||||
|
||||
gtk_font_button_update_font_info (font_button);
|
||||
|
||||
@@ -1334,12 +1347,10 @@ static void
|
||||
gtk_font_button_set_language (GtkFontButton *font_button,
|
||||
const char *language)
|
||||
{
|
||||
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
|
||||
font_button->language = pango_language_from_string (language);
|
||||
|
||||
priv->language = pango_language_from_string (language);
|
||||
|
||||
if (priv->font_dialog)
|
||||
gtk_font_chooser_set_language (GTK_FONT_CHOOSER (priv->font_dialog), language);
|
||||
if (font_button->font_dialog)
|
||||
gtk_font_chooser_set_language (GTK_FONT_CHOOSER (font_button->font_dialog), language);
|
||||
|
||||
g_object_notify (G_OBJECT (font_button), "language");
|
||||
}
|
||||
|
||||
@@ -54,6 +54,11 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gtk_font_button_set_title (GtkFontButton *font_button,
|
||||
const gchar *title);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_font_button_get_modal (GtkFontButton *font_button);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_font_button_set_modal (GtkFontButton *font_button,
|
||||
gboolean modal);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_font_button_get_use_font (GtkFontButton *font_button);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_font_button_set_use_font (GtkFontButton *font_button,
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
#include "gtktextview.h"
|
||||
#include "gtktreeselection.h"
|
||||
#include "gtktreeview.h"
|
||||
#include "gtkwidget.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtksettings.h"
|
||||
#include "gtkdialog.h"
|
||||
#include "gtkradiobutton.h"
|
||||
@@ -737,6 +737,8 @@ gtk_font_chooser_widget_class_init (GtkFontChooserWidgetClass *klass)
|
||||
widget_class->unroot = gtk_font_chooser_widget_unroot;
|
||||
widget_class->map = gtk_font_chooser_widget_map;
|
||||
widget_class->unmap = gtk_font_chooser_widget_unmap;
|
||||
widget_class->focus = gtk_widget_focus_child;
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_child;
|
||||
|
||||
gobject_class->finalize = gtk_font_chooser_widget_finalize;
|
||||
gobject_class->dispose = gtk_font_chooser_widget_dispose;
|
||||
|
||||
+34
-5
@@ -59,6 +59,29 @@ gtk_gizmo_contains (GtkWidget *widget,
|
||||
return GTK_WIDGET_CLASS (gtk_gizmo_parent_class)->contains (widget, x, y);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_gizmo_focus (GtkWidget *widget,
|
||||
GtkDirectionType direction)
|
||||
{
|
||||
GtkGizmo *self = GTK_GIZMO (widget);
|
||||
|
||||
if (self->focus_func)
|
||||
return self->focus_func (self, direction);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_gizmo_grab_focus (GtkWidget *widget)
|
||||
{
|
||||
GtkGizmo *self = GTK_GIZMO (widget);
|
||||
|
||||
if (self->grab_focus_func)
|
||||
return self->grab_focus_func (self);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_gizmo_finalize (GObject *object)
|
||||
{
|
||||
@@ -90,6 +113,8 @@ gtk_gizmo_class_init (GtkGizmoClass *klass)
|
||||
widget_class->size_allocate = gtk_gizmo_size_allocate;
|
||||
widget_class->snapshot = gtk_gizmo_snapshot;
|
||||
widget_class->contains = gtk_gizmo_contains;
|
||||
widget_class->grab_focus = gtk_gizmo_grab_focus;
|
||||
widget_class->focus = gtk_gizmo_focus;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -98,11 +123,13 @@ gtk_gizmo_init (GtkGizmo *self)
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gtk_gizmo_new (const char *css_name,
|
||||
GtkGizmoMeasureFunc measure_func,
|
||||
GtkGizmoAllocateFunc allocate_func,
|
||||
GtkGizmoSnapshotFunc snapshot_func,
|
||||
GtkGizmoContainsFunc contains_func)
|
||||
gtk_gizmo_new (const char *css_name,
|
||||
GtkGizmoMeasureFunc measure_func,
|
||||
GtkGizmoAllocateFunc allocate_func,
|
||||
GtkGizmoSnapshotFunc snapshot_func,
|
||||
GtkGizmoContainsFunc contains_func,
|
||||
GtkGizmoFocusFunc focus_func,
|
||||
GtkGizmoGrabFocusFunc grab_focus_func)
|
||||
{
|
||||
GtkGizmo *gizmo = GTK_GIZMO (g_object_new (GTK_TYPE_GIZMO,
|
||||
"css-name", css_name,
|
||||
@@ -112,6 +139,8 @@ gtk_gizmo_new (const char *css_name,
|
||||
gizmo->allocate_func = allocate_func;
|
||||
gizmo->snapshot_func = snapshot_func;
|
||||
gizmo->contains_func = contains_func;
|
||||
gizmo->focus_func = focus_func;
|
||||
gizmo->grab_focus_func = grab_focus_func;
|
||||
|
||||
return GTK_WIDGET (gizmo);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user