Compare commits

..

11 Commits

Author SHA1 Message Date
Matthias Clasen b1038c5d19 settings: Add a :theme-change signal
This signal allows applications to intercept and override
what theme gets loaded when the theme settings change.
One possibility is to only load themes from a fixed list
of supported themes. Another is to ignore the user preference
and only load dark themes.
2020-04-13 10:40:32 -04:00
Matthias Clasen b16b44f1ae inspector: Use theme apis
We can now use gtk_theme_get_available_themes instead
of our own copy of that code.
2020-04-13 10:40:32 -04:00
Matthias Clasen 37c151ce0f Add some theme apis
Add apis to get the list of available themes,
as well as the dark or light variant of a theme.
2020-04-13 10:40:32 -04:00
Matthias Clasen eb7ad4bbad Introduce a gtk-user-theme-preference setting
This setting will be interpreted as prefers dark/
prefers light/don't care. Since we don't have any
useful metadata for themes, we simply look for
the NAME/NAME-dark naming convention when identifying
light or dark theme variants.
2020-04-13 10:20:36 -04:00
Matthias Clasen cdec487998 cssprovider: Stop supporting theme variants
We are no longer using variants, so drop the variant
argument from gtk_css_provider_load_named().
2020-04-13 10:20:36 -04:00
Matthias Clasen 80d3c68615 testsuite: Stop loading theme variants 2020-04-13 10:20:35 -04:00
Matthias Clasen ed4b3f8033 Drop the prefer-dark setting
There is no way to win with this setting, so instead
of trying to add yet more override knobs for application
developers, do away with theme variants altogether.

As a user, just pick your favorite theme, and if it
is dark, so be it.

As an app developer, you can inspect the gtk-theme-name
property and match that against your supported themes.
If that is not good enough for you, you can volunteer
to implement a theme property API that would let themes
declare whether they are dark or light.
2020-04-13 10:20:35 -04:00
Matthias Clasen 451e7a5ad2 themes: Make Adwaita-dark a separate theme
We are moving away from theme variants.
2020-04-13 10:20:35 -04:00
Matthias Clasen 89360b26af window: Stop dealing with prefer-dark
Its 2020.  If you want maching window decorations, use CSD.
2020-04-13 10:20:35 -04:00
Matthias Clasen d3d4fe14c2 inspector: Stop dealing with prefer-dark
This setting is going away.
2020-04-13 10:20:35 -04:00
Matthias Clasen 040175cd92 widget-factory: Stop dealing with prefer-dark
Instead, just toggle between known light/dark pairs
for the builtin themes.
2020-04-13 10:20:35 -04:00
230 changed files with 13528 additions and 12482 deletions
-76
View File
@@ -1,79 +1,3 @@
Overview of Changes in GTK 3.98.3
=================================
* GtkEntry:
- Support setting attributes in ui files
* GtkScaleButton:
- Don't derive from GtkButton
* GtkAboutDialog:
- Support more common licenses
* GtkEmojiChooser:
- Improve keyboard navigation
* GtkLabel:
- Remove pattern API
* GtkAspectFrame:
- Modernize and simplify
* Chooser buttons:
- Make dialogs modal by default
* Various widgets:
- Replace shadow-type and relief properties by
a simpler has-frame
* CSS:
- Use :focus-visible instead of :focus(visible)
- Add support for :focus-within
* Focus handling
- Fix crossing event generation
- Fix focus handling in various widgets
- Change :can-focus to be recursive
- Fix GtkWindow:is-active setting
* Scrolling
- gtk_container_set_focus_[hv]adjustment has been removed
- gtk_viewport_set_scroll_to_focus has been added
* Accessibility:
- Add a cursor-aspect-ratio setting
- Set focus-related states properly
* Themes:
- Use blue focus outlines more
- Numerous minor improvements
* Wayland:
- Fix .Compose file loading
- Support popup repositioning
- Fix problems with autohide popovers
* GDK:
- Remove GdkKeymap from public API, replaced by
GdkDevice properties
- Add full keyboard translation state to key events
- Simplify modifier support, drop GdkModifierIntent
- Move key event matching to GDK
- Add GdkSurface::enter/leave-monitor signals
- Turn GskEvent into a derivable type, and make
it introspectable
* GSK:
- Turn GskRenderNode into a derivable type, and make
it introspectable
- Fall back to cairo if compiling shaders fails
* Translation updates:
- Japanese
- Lithuanian
- Turkish
Overview of Changes in GTK 3.98.2
=================================
@@ -613,19 +613,19 @@ create_widget_func (gpointer item,
if (GTK_IS_CONSTRAINT (item) || GTK_IS_CONSTRAINT_GUIDE (item))
{
button = gtk_button_new_from_icon_name ("document-edit-symbolic");
gtk_button_set_has_frame (GTK_BUTTON (button), FALSE);
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
g_signal_connect (button, "clicked", G_CALLBACK (row_edit), win);
g_object_set_data (G_OBJECT (row), "edit", button);
gtk_container_add (GTK_CONTAINER (box), button);
button = gtk_button_new_from_icon_name ("edit-delete-symbolic");
gtk_button_set_has_frame (GTK_BUTTON (button), FALSE);
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
g_signal_connect (button, "clicked", G_CALLBACK (row_delete), win);
gtk_container_add (GTK_CONTAINER (box), button);
}
else if (GTK_IS_WIDGET (item))
{
button = gtk_button_new_from_icon_name ("edit-delete-symbolic");
gtk_button_set_has_frame (GTK_BUTTON (button), FALSE);
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
g_signal_connect (button, "clicked", G_CALLBACK (row_delete), win);
gtk_container_add (GTK_CONTAINER (box), button);
}
+1 -1
View File
@@ -61,7 +61,7 @@
</child>
<child>
<object class="GtkScrolledWindow">
<property name="has-frame">1</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkTextView">
<property name="hexpand">1</property>
+1 -1
View File
@@ -26,7 +26,7 @@
<child>
<object class="GtkScrolledWindow" id="scrolledwindow">
<property name="vexpand">1</property>
<property name="has-frame">1</property>
<property name="shadow-type">in</property>
<property name="min-content-width">150</property>
<layout>
<property name="left-attach">0</property>
+1
View File
@@ -90,6 +90,7 @@ do_colorsel (GtkWidget *do_widget)
*/
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (vbox), frame);
da = gtk_drawing_area_new ();
+1 -1
View File
@@ -166,7 +166,7 @@
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="has-frame">1</property>
<property name="shadow-type">in</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<child>
+1 -1
View File
@@ -472,7 +472,7 @@ demo_tagged_entry_tag_set_has_close_button (DemoTaggedEntryTag *tag,
gtk_container_add (GTK_CONTAINER (tag->button), image);
gtk_widget_set_halign (tag->button, GTK_ALIGN_CENTER);
gtk_widget_set_valign (tag->button, GTK_ALIGN_CENTER);
gtk_button_set_has_frame (GTK_BUTTON (tag->button), FALSE);
gtk_button_set_relief (GTK_BUTTON (tag->button), GTK_RELIEF_NONE);
gtk_container_add (GTK_CONTAINER (tag->box), tag->button);
g_signal_connect (tag->button, "clicked", G_CALLBACK (on_button_clicked), tag);
}
+7 -7
View File
@@ -279,11 +279,11 @@ pressed_cb (GtkGesture *gesture,
gtk_container_add (GTK_CONTAINER (menu), box);
item = gtk_button_new_with_label ("New Label");
gtk_button_set_has_frame (GTK_BUTTON (item), FALSE);
gtk_button_set_relief (GTK_BUTTON (item), GTK_RELIEF_NONE);
g_signal_connect (item, "clicked", G_CALLBACK (new_label_cb), widget);
gtk_container_add (GTK_CONTAINER (box), item);
item = gtk_button_new_with_label ("New Spinner");
gtk_button_set_has_frame (GTK_BUTTON (item), FALSE);
gtk_button_set_relief (GTK_BUTTON (item), GTK_RELIEF_NONE);
g_signal_connect (item, "clicked", G_CALLBACK (new_spinner_cb), widget);
gtk_container_add (GTK_CONTAINER (box), item);
@@ -291,7 +291,7 @@ pressed_cb (GtkGesture *gesture,
gtk_container_add (GTK_CONTAINER (box), item);
item = gtk_button_new_with_label ("Edit");
gtk_button_set_has_frame (GTK_BUTTON (item), FALSE);
gtk_button_set_relief (GTK_BUTTON (item), GTK_RELIEF_NONE);
gtk_widget_set_sensitive (item, child != NULL && child != widget);
g_signal_connect (item, "clicked", G_CALLBACK (edit_cb), child);
gtk_container_add (GTK_CONTAINER (box), item);
@@ -300,24 +300,24 @@ pressed_cb (GtkGesture *gesture,
gtk_container_add (GTK_CONTAINER (box), item);
item = gtk_button_new_with_label ("Cut");
gtk_button_set_has_frame (GTK_BUTTON (item), FALSE);
gtk_button_set_relief (GTK_BUTTON (item), GTK_RELIEF_NONE);
gtk_widget_set_sensitive (item, child != NULL && child != widget);
g_signal_connect (item, "clicked", G_CALLBACK (cut_cb), child);
gtk_container_add (GTK_CONTAINER (box), item);
item = gtk_button_new_with_label ("Copy");
gtk_button_set_has_frame (GTK_BUTTON (item), FALSE);
gtk_button_set_relief (GTK_BUTTON (item), GTK_RELIEF_NONE);
gtk_widget_set_sensitive (item, child != NULL && child != widget);
g_signal_connect (item, "clicked", G_CALLBACK (copy_cb), child);
gtk_container_add (GTK_CONTAINER (box), item);
item = gtk_button_new_with_label ("Paste");
gtk_button_set_has_frame (GTK_BUTTON (item), FALSE);
gtk_button_set_relief (GTK_BUTTON (item), GTK_RELIEF_NONE);
clipboard = gdk_display_get_clipboard (gdk_display_get_default ());
gtk_widget_set_sensitive (item,
gdk_content_formats_contain_gtype (gdk_clipboard_get_formats (clipboard), GTK_TYPE_DEMO_WIDGET));
g_signal_connect (item, "clicked", G_CALLBACK (paste_cb), widget);
gtk_container_add (GTK_CONTAINER (box), item);
item = gtk_button_new_with_label ("Delete");
gtk_button_set_has_frame (GTK_BUTTON (item), FALSE);
gtk_button_set_relief (GTK_BUTTON (item), GTK_RELIEF_NONE);
gtk_widget_set_sensitive (item, child != NULL && child != widget);
g_signal_connect (item, "clicked", G_CALLBACK (delete_cb), child);
gtk_container_add (GTK_CONTAINER (box), item);
+2
View File
@@ -214,6 +214,7 @@ do_drawingarea (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (vbox), label);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_widget_set_vexpand (frame, TRUE);
gtk_container_add (GTK_CONTAINER (vbox), frame);
@@ -234,6 +235,7 @@ do_drawingarea (GtkWidget *do_widget)
frame = gtk_frame_new (NULL);
gtk_widget_set_vexpand (frame, TRUE);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (vbox), frame);
da = gtk_drawing_area_new ();
+2 -1
View File
@@ -366,7 +366,8 @@ do_editable_cells (GtkWidget *do_widget)
gtk_label_new ("Shopping list (you can edit the cells!)"));
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
GTK_SHADOW_ETCHED_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
+1 -1
View File
@@ -59,7 +59,7 @@ do_expander (GtkWidget *do_widget)
gtk_widget_set_vexpand (expander, TRUE);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (sw), 100);
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
+1 -1
View File
@@ -49,7 +49,7 @@
<child type="end">
<object class="GtkToggleButton" id="changes_allow">
<property name="icon-name">changes-allow</property>
<property name="has-frame">0</property>
<property name="relief">none</property>
<signal name="notify::active" handler="fishbowl_changes_toggled_cb"/>
</object>
</child>
+1 -1
View File
@@ -193,7 +193,7 @@
<child>
<object class="GtkScrolledWindow">
<property name="propagate-natural-height">1</property>
<property name="has-frame">1</property>
<property name="shadow-type">in</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<child>
+2 -1
View File
@@ -277,7 +277,8 @@ do_iconview (GtkWidget *do_widget)
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
GTK_SHADOW_ETCHED_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
+5
View File
@@ -360,6 +360,7 @@ do_images (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (vbox), label);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
gtk_container_add (GTK_CONTAINER (vbox), frame);
@@ -378,6 +379,7 @@ do_images (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (vbox), label);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
gtk_container_add (GTK_CONTAINER (vbox), frame);
@@ -394,6 +396,7 @@ do_images (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (vbox), label);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
gtk_container_add (GTK_CONTAINER (vbox), frame);
@@ -415,6 +418,7 @@ do_images (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (vbox), label);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
gtk_container_add (GTK_CONTAINER (vbox), frame);
@@ -437,6 +441,7 @@ do_images (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (vbox), label);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
gtk_container_add (GTK_CONTAINER (vbox), frame);
+2 -1
View File
@@ -272,7 +272,8 @@ do_list_store (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (vbox), label);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
GTK_SHADOW_ETCHED_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
+10 -8
View File
@@ -40,7 +40,7 @@
<object class="GtkButton" id="button2">
<property name="receives-default">1</property>
<property name="valign">baseline</property>
<property name="has-frame">0</property>
<property name="relief">none</property>
<child>
<object class="GtkLabel" id="source_name">
<property name="valign">baseline</property>
@@ -109,7 +109,7 @@
<object class="GtkLinkButton" id="resent_by_button">
<property name="label" translatable="0">reshareer</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<property name="relief">none</property>
<property name="uri">http://www.gtk.org</property>
</object>
</child>
@@ -126,7 +126,7 @@
<object class="GtkButton" id="expand_button">
<property name="label" translatable="yes">Expand</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<property name="relief">none</property>
<signal name="clicked" handler="expand_clicked" swapped="yes"/>
</object>
</child>
@@ -138,14 +138,14 @@
<object class="GtkButton" id="reply-button">
<property name="label" translatable="yes">Reply</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<property name="relief">none</property>
</object>
</child>
<child>
<object class="GtkButton" id="reshare-button">
<property name="label" translatable="yes">Reshare</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<property name="relief">none</property>
<signal name="clicked" handler="reshare_clicked" swapped="yes"/>
</object>
</child>
@@ -153,7 +153,7 @@
<object class="GtkButton" id="favorite-buttton">
<property name="label" translatable="yes">Favorite</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<property name="relief">none</property>
<signal name="clicked" handler="favorite_clicked" swapped="yes"/>
</object>
</child>
@@ -161,7 +161,7 @@
<object class="GtkMenuButton" id="more-button">
<property name="receives-default">1</property>
<property name="menu-model">menu1</property>
<property name="has-frame">0</property>
<property name="relief">none</property>
<property name="label" translatable="yes">More...</property>
</object>
</child>
@@ -185,6 +185,7 @@
<property name="spacing">8</property>
<child>
<object class="GtkFrame" id="frame1">
<property name="shadow-type">none</property>
<child>
<object class="GtkLabel" id="n_reshares_label">
<property name="label" translatable="0">&lt;b&gt;2&lt;/b&gt;
@@ -197,6 +198,7 @@ Reshares</property>
</child>
<child>
<object class="GtkFrame" id="frame2">
<property name="shadow-type">none</property>
<child>
<object class="GtkLabel" id="n_favorites_label">
<property name="label" translatable="0">&lt;b&gt;2&lt;/b&gt;
@@ -223,7 +225,7 @@ FAVORITES</property>
<object class="GtkButton" id="button5">
<property name="label" translatable="yes">Details</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<property name="relief">none</property>
<style>
<class name="dim-label"/>
</style>
+2
View File
@@ -612,6 +612,8 @@ display_text (const char *resource)
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
GTK_SHADOW_NONE);
gtk_container_add (GTK_CONTAINER (sw), textview);
return sw;
+3
View File
@@ -172,6 +172,7 @@ do_panes (GtkWidget *do_widget)
gtk_paned_add1 (GTK_PANED (vpaned), hpaned);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
gtk_widget_set_size_request (frame, 60, 60);
gtk_paned_add1 (GTK_PANED (hpaned), frame);
@@ -179,10 +180,12 @@ do_panes (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER(frame), button);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
gtk_widget_set_size_request (frame, 80, 60);
gtk_paned_add2 (GTK_PANED (hpaned), frame);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
gtk_widget_set_size_request (frame, 60, 80);
gtk_paned_add2 (GTK_PANED (vpaned), frame);
+2 -3
View File
@@ -279,8 +279,7 @@ start_puzzle (GdkPaintable *paintable)
aspect_ratio = gdk_paintable_get_intrinsic_aspect_ratio (paintable);
if (aspect_ratio == 0.0)
aspect_ratio = 1.0;
gtk_aspect_frame_set_ratio (GTK_ASPECT_FRAME (frame), aspect_ratio);
gtk_aspect_frame_set_obey_child (GTK_ASPECT_FRAME (frame), FALSE);
gtk_aspect_frame_set (GTK_ASPECT_FRAME (frame), 0.5, 0.5, aspect_ratio, FALSE);
/* Add shortcuts so people can use the arrow
* keys to move the puzzle */
@@ -467,7 +466,7 @@ do_sliding_puzzle (GtkWidget *do_widget)
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
frame = gtk_aspect_frame_new (0.5, 0.5, (float) gdk_paintable_get_intrinsic_aspect_ratio (puzzle), FALSE);
frame = gtk_aspect_frame_new (NULL, 0.5, 0.5, (float) gdk_paintable_get_intrinsic_aspect_ratio (puzzle), FALSE);
gtk_container_add (GTK_CONTAINER (window), frame);
start_puzzle (puzzle);
+2 -1
View File
@@ -408,7 +408,8 @@ do_tree_store (GtkWidget *do_widget)
gtk_label_new ("Jonathan's Holiday Card Planning Sheet"));
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
GTK_SHADOW_ETCHED_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
+1 -1
View File
@@ -83,7 +83,6 @@
<property name="title" translatable="yes">GTK Node Editor</property>
<property name="default-width">1024</property>
<property name="default-height">768</property>
<property name="focus-widget">text_view</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
<property name="title" translatable="yes">GTK Node Editor</property>
@@ -140,6 +139,7 @@
<object class="GtkTextView" id="text_view">
<property name="wrap-mode">word</property>
<property name="monospace">1</property>
<property name="has-focus">1</property>
<property name="top-margin">6</property>
<property name="left-margin">6</property>
<property name="right-margin">6</property>
+32 -24
View File
@@ -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);
@@ -839,7 +855,6 @@ overshot (GtkScrolledWindow *sw, GtkPositionType pos, GtkWidget *widget)
gdk_rgba_parse (&rgba, color);
swatch = g_object_new (g_type_from_name ("GtkColorSwatch"),
"rgba", &rgba,
"can-focus", FALSE,
"selectable", FALSE,
"halign", GTK_ALIGN_END,
"valign", GTK_ALIGN_CENTER,
@@ -958,7 +973,6 @@ populate_colors (GtkWidget *widget, GtkWidget *chooser)
swatch = g_object_new (g_type_from_name ("GtkColorSwatch"),
"rgba", &rgba,
"selectable", FALSE,
"can-focus", FALSE,
"halign", GTK_ALIGN_END,
"valign", GTK_ALIGN_CENTER,
"margin-start", 6,
@@ -1738,11 +1752,9 @@ activate (GApplication *app)
gint i;
GPermission *permission;
GAction *action;
GError *error = NULL;
g_object_get (gtk_settings_get_default (),
"gtk-theme-name", &current_theme,
"gtk-application-prefer-dark-theme", &current_dark,
NULL);
g_type_ensure (my_text_view_get_type ());
@@ -1771,11 +1783,7 @@ activate (GApplication *app)
NULL);
gtk_builder_set_scope (builder, scope);
g_object_unref (scope);
if (!gtk_builder_add_from_resource (builder, "/org/gtk/WidgetFactory4/widget-factory.ui", &error))
{
g_critical ("%s", error->message);
g_clear_error (&error);
}
gtk_builder_add_from_resource (builder, "/org/gtk/WidgetFactory4/widget-factory.ui", NULL);
window = (GtkWindow *)gtk_builder_get_object (builder, "window");
gtk_application_add_window (GTK_APPLICATION (app), window);
+15 -17
View File
@@ -864,7 +864,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="label" translatable="yes">link button</property>
<property name="receives-default">1</property>
<property name="has-tooltip">1</property>
<property name="has-frame">0</property>
<property name="relief">none</property>
<property name="uri">http://www.gtk.org</property>
</object>
</child>
@@ -1113,7 +1113,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="width-request">150</property>
<property name="vscrollbar-policy">always</property>
<property name="has-frame">1</property>
<property name="shadow-type">in</property>
<property name="vexpand">1</property>
<child>
<object class="GtkTreeView" id="treeview1">
@@ -1187,7 +1187,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow2">
<property name="has-frame">1</property>
<property name="shadow-type">in</property>
<property name="vexpand">1</property>
<child>
<object class="GtkTextView" id="textview1">
@@ -1449,7 +1449,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkButton" id="page2dismiss">
<property name="focus-on-click">0</property>
<property name="has-frame">0</property>
<property name="relief">none</property>
<property name="icon-name">window-close-symbolic</property>
</object>
</child>
@@ -1597,7 +1597,7 @@ microphone-sensitivity-medium-symbolic</property>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="has-frame">1</property>
<property name="shadow-type">in</property>
<property name="hscrollbar-policy">never</property>
<property name="min-content-height">200</property>
<property name="hexpand">0</property>
@@ -1999,7 +1999,7 @@ microphone-sensitivity-medium-symbolic</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow3">
<property name="has-frame">1</property>
<property name="shadow-type">in</property>
<property name="margin-top">6</property>
<property name="height-request">226</property>
<child>
@@ -2105,7 +2105,7 @@ microphone-sensitivity-medium-symbolic</property>
<property name="hscrollbar-policy">never</property>
<property name="vscrollbar-policy">always</property>
<property name="height-request">300</property>
<property name="has-frame">1</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkTreeView" id="charletree">
<property name="enable-grid-lines">vertical</property>
@@ -2171,7 +2171,7 @@ microphone-sensitivity-medium-symbolic</property>
<object class="GtkScrolledWindow">
<property name="hscrollbar-policy">never</property>
<property name="vexpand">1</property>
<property name="has-frame">1</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkListBox" id="munsell">
<property name="selection-mode">multiple</property>
@@ -2271,7 +2271,7 @@ microphone-sensitivity-medium-symbolic</property>
<child>
<object class="GtkMenuButton">
<property name="icon-name">view-more-symbolic</property>
<property name="menu-model">new_style_menu_model</property>
<property name="popover">new_style_menu</property>
</object>
</child>
</object>
@@ -2639,7 +2639,7 @@ microphone-sensitivity-medium-symbolic</property>
<property name="valign">center</property>
<property name="popover">notebook_info_popover2</property>
<property name="icon-name">emblem-important-symbolic</property>
<property name="has-frame">0</property>
<property name="relief">none</property>
<style>
<class name="circular"/>
</style>
@@ -2664,7 +2664,7 @@ microphone-sensitivity-medium-symbolic</property>
</child>
<child>
<object class="GtkButton">
<property name="has-frame">0</property>
<property name="relief">none</property>
<property name="focus-on-click">0</property>
<property name="icon-name">window-close-symbolic</property>
<signal name="clicked" handler="tab_close_cb" object="closable_page_1"/>
@@ -2696,7 +2696,7 @@ microphone-sensitivity-medium-symbolic</property>
</child>
<child>
<object class="GtkButton">
<property name="has-frame">0</property>
<property name="relief">none</property>
<property name="focus-on-click">0</property>
<property name="icon-name">window-close-symbolic</property>
<signal name="clicked" handler="tab_close_cb" object="closable_page_2"/>
@@ -2783,7 +2783,7 @@ microphone-sensitivity-medium-symbolic</property>
<property name="valign">center</property>
<property name="popover">notebook_info_popover</property>
<property name="icon-name">emblem-important-symbolic</property>
<property name="has-frame">0</property>
<property name="relief">none</property>
<style>
<class name="circular"/>
</style>
@@ -3141,7 +3141,7 @@ bad things might happen.</property>
<child>
<object class="GtkScrolledWindow">
<property name="valign">start</property>
<property name="has-frame">1</property>
<property name="shadow-type">in</property>
<property name="min-content-height">70</property>
<property name="max-content-height">120</property>
<property name="min-content-width">100</property>
@@ -3275,7 +3275,7 @@ bad things might happen.</property>
<property name="valign">center</property>
<property name="popover">notebook_info_popover3</property>
<property name="icon-name">emblem-important-symbolic</property>
<property name="has-frame">0</property>
<property name="relief">none</property>
<style>
<class name="circular"/>
</style>
@@ -3285,7 +3285,6 @@ bad things might happen.</property>
</child>
</object>
<object class="GtkPopover" id="new_style_menu">
<style><class name="menu"/></style>
<child>
<object class="GtkStack">
<child>
@@ -3597,7 +3596,6 @@ bad things might happen.</property>
</submenu>
</section>
<section>
<attribute name="label" translatable="yes">Size</attribute>
<item>
<attribute name="label" translatable="yes">Large</attribute>
<attribute name="action">app.size</attribute>
+3
View File
@@ -171,6 +171,8 @@ gdk_rgba_get_type
<TITLE>GdkSurface</TITLE>
<FILE>gdksurface</FILE>
GdkSurface
GdkSurfaceHints
GdkGeometry
GdkGravity
GdkSurfaceEdge
GdkSurfaceTypeHint
@@ -188,6 +190,7 @@ gdk_surface_get_height
gdk_surface_translate_coordinates
gdk_surface_begin_resize_drag
gdk_surface_begin_move_drag
gdk_surface_constrain_size
gdk_surface_beep
gdk_surface_get_scale_factor
gdk_surface_set_opaque_region
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+7 -7
View File
@@ -203,12 +203,12 @@
<title>Hierarchical drawing</title>
<para>
During the Paint phase GTK receives a single #GdkSurface::render signal on
the toplevel surface. The signal handler will create a snapshot object
(which is a helper for creating a scene graph) and call the
#GtkWidget::snapshot() vfunc, which will propagate down the widget hierarchy.
This lets each widget snapshot its content at the right place and time,
correctly handling things like partial transparencies and overlapping widgets.
During the Paint phase GTK receives a single ::render signal on the toplevel
window. The signal handler will create a snapshot object (which is a
helper for creating a scene graph) and emit a GtkWidget::snapshot() signal,
which will propagate down the widget hierarchy. This lets each widget
snapshot its content at the right place and time, correctly handling things
like partial transparencies and overlapping widgets.
</para>
<para>
@@ -217,7 +217,7 @@
the render nodes of children, and grandchildren, and so on), and will reuse
that node during the Paint phase. Invalidating a widget (by calling
gtk_widget_queue_draw()) discards the cached render node, forcing the widget
to regenerate it the next time it needs to produce a snapshot.
to regenerate it the next time it needs to handle a ::snapshot.
</para>
</refsect2>
+3 -8
View File
@@ -19,15 +19,11 @@
</bookinfo>
<part id="gtk">
<title>Introduction</title>
<title>GTK Overview</title>
<xi:include href="overview.xml"/>
<xi:include href="xml/getting_started.xml"/>
<xi:include href="resources.xml" />
<xi:include href="xml/question_index.xml" />
</part>
<part id="concepts">
<title>GTK Concepts</title>
<xi:include href="xml/drawing-model.xml" />
<xi:include href="xml/input-handling.xml" />
<xi:include href="xml/actions.xml" />
@@ -117,10 +113,9 @@
<xi:include href="xml/gtklayoutchild.xml" />
<xi:include href="xml/gtkbinlayout.xml" />
<xi:include href="xml/gtkboxlayout.xml" />
<xi:include href="xml/gtkcenterlayout.xml" />
<xi:include href="xml/gtkcustomlayout.xml" />
<xi:include href="xml/gtkfixedlayout.xml" />
<xi:include href="xml/gtkgridlayout.xml" />
<xi:include href="xml/gtkcustomlayout.xml" />
<xi:include href="xml/gtkconstraintlayout.xml" />
<xi:include href="xml/gtkconstraint.xml" />
<xi:include href="xml/gtkconstraintguide.xml" />
@@ -285,7 +280,6 @@
<xi:include href="xml/gtkshortcutssection.xml" />
<xi:include href="xml/gtkshortcutsgroup.xml" />
<xi:include href="xml/gtkshortcutsshortcut.xml" />
<xi:include href="xml/gtkshortcutlabel.xml" />
</chapter>
<chapter id="MiscObjects">
@@ -377,6 +371,7 @@
<part id="theming">
<title>Theming in GTK</title>
<xi:include href="css-overview.xml" />
<xi:include href="css-properties.xml" />
<xi:include href="xml/gtkstylecontext.xml" />
<xi:include href="xml/gtkcssprovider.xml" />
<xi:include href="xml/gtkstyleprovider.xml" />
+32 -58
View File
@@ -74,8 +74,6 @@ gtk_accel_label_get_accel
gtk_accel_label_refetch
gtk_accel_label_set_label
gtk_accel_label_get_label
gtk_accel_label_get_use_underline
gtk_accel_label_set_use_underline
<SUBSECTION Standard>
GTK_ACCEL_LABEL
GTK_IS_ACCEL_LABEL
@@ -182,7 +180,6 @@ GTK_ASSISTANT_GET_CLASS
<SUBSECTION Private>
GtkAssistantPrivate
gtk_assistant_get_type
gtk_assistant_page_get_type
</SECTION>
<SECTION>
@@ -190,14 +187,7 @@ gtk_assistant_page_get_type
<TITLE>GtkAspectFrame</TITLE>
GtkAspectFrame
gtk_aspect_frame_new
gtk_aspect_frame_set_xalign
gtk_aspect_frame_get_xalign
gtk_aspect_frame_set_yalign
gtk_aspect_frame_get_yalign
gtk_aspect_frame_set_ratio
gtk_aspect_frame_get_ratio
gtk_aspect_frame_set_obey_child
gtk_aspect_frame_get_obey_child
gtk_aspect_frame_set
<SUBSECTION Standard>
GTK_ASPECT_FRAME
GTK_IS_ASPECT_FRAME
@@ -206,6 +196,7 @@ GTK_ASPECT_FRAME_CLASS
GTK_IS_ASPECT_FRAME_CLASS
GTK_ASPECT_FRAME_GET_CLASS
<SUBSECTION Private>
GtkAspectFramePrivate
gtk_aspect_frame_get_type
</SECTION>
@@ -529,8 +520,8 @@ gtk_button_new
gtk_button_new_with_label
gtk_button_new_with_mnemonic
gtk_button_new_from_icon_name
gtk_button_set_has_frame
gtk_button_get_has_frame
gtk_button_set_relief
gtk_button_get_relief
gtk_button_get_label
gtk_button_set_label
gtk_button_get_use_underline
@@ -562,12 +553,6 @@ gtk_calendar_mark_day
gtk_calendar_unmark_day
gtk_calendar_get_day_is_marked
gtk_calendar_clear_marks
gtk_calendar_get_show_day_names
gtk_calendar_set_show_day_names
gtk_calendar_get_show_heading
gtk_calendar_set_show_heading
gtk_calendar_get_show_week_numbers
gtk_calendar_set_show_week_numbers
<SUBSECTION>
gtk_calendar_get_date
@@ -709,6 +694,10 @@ gtk_container_add
gtk_container_remove
gtk_container_foreach
gtk_container_get_children
gtk_container_get_focus_vadjustment
gtk_container_set_focus_vadjustment
gtk_container_get_focus_hadjustment
gtk_container_set_focus_hadjustment
gtk_container_child_type
gtk_container_forall
@@ -1383,11 +1372,13 @@ GtkFrame
GtkFrameClass
gtk_frame_new
gtk_frame_set_label
gtk_frame_get_label
gtk_frame_set_label_widget
gtk_frame_get_label_widget
gtk_frame_set_label_align
gtk_frame_set_shadow_type
gtk_frame_get_label
gtk_frame_get_label_align
gtk_frame_get_label_widget
gtk_frame_get_shadow_type
<SUBSECTION Standard>
GTK_FRAME
GTK_IS_FRAME
@@ -1600,6 +1591,7 @@ gtk_label_set_text
gtk_label_set_attributes
gtk_label_set_markup
gtk_label_set_markup_with_mnemonic
gtk_label_set_pattern
gtk_label_set_justify
gtk_label_set_xalign
gtk_label_set_yalign
@@ -1640,6 +1632,8 @@ gtk_label_set_use_markup
gtk_label_set_use_underline
gtk_label_set_single_line_mode
gtk_label_get_current_uri
gtk_label_set_track_visited_links
gtk_label_get_track_visited_links
gtk_label_set_extra_menu
gtk_label_get_extra_menu
@@ -1718,10 +1712,8 @@ gtk_menu_button_set_icon_name
gtk_menu_button_get_icon_name
gtk_menu_button_set_label
gtk_menu_button_get_label
gtk_menu_button_set_has_frame
gtk_menu_button_get_has_frame
gtk_menu_button_get_use_underline
gtk_menu_button_set_use_underline
gtk_menu_button_set_relief
gtk_menu_button_get_relief
gtk_menu_button_popup
gtk_menu_button_popdown
GtkMenuButtonCreatePopupFunc
@@ -2213,8 +2205,8 @@ GtkCornerType
gtk_scrolled_window_get_placement
gtk_scrolled_window_set_placement
gtk_scrolled_window_unset_placement
gtk_scrolled_window_get_has_frame
gtk_scrolled_window_set_has_frame
gtk_scrolled_window_get_shadow_type
gtk_scrolled_window_set_shadow_type
gtk_scrolled_window_get_kinetic_scrolling
gtk_scrolled_window_set_kinetic_scrolling
gtk_scrolled_window_get_capture_button_press
@@ -2312,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
@@ -3851,8 +3849,8 @@ gtk_list_store_get_type
<TITLE>GtkViewport</TITLE>
GtkViewport
gtk_viewport_new
gtk_viewport_set_scroll_to_focus
gtk_viewport_get_scroll_to_focus
gtk_viewport_set_shadow_type
gtk_viewport_get_shadow_type
<SUBSECTION Standard>
GTK_VIEWPORT
GTK_IS_VIEWPORT
@@ -3981,9 +3979,7 @@ gtk_widget_allocate
gtk_widget_class_add_shortcut
gtk_widget_class_add_binding
gtk_widget_class_add_binding_signal
gtk_widget_class_add_binding_action
gtk_widget_class_set_layout_manager_type
gtk_widget_class_get_layout_manager_type
gtk_widget_can_activate_accel
gtk_widget_activate
gtk_widget_is_focus
gtk_widget_grab_focus
@@ -4548,9 +4544,11 @@ GtkMovementStep
GtkOrientation
GtkPackType
GtkPositionType
GtkReliefStyle
GtkScrollStep
GtkScrollType
GtkSelectionMode
GtkShadowType
GtkStateFlags
GtkSortType
GtkIconSize
@@ -5826,8 +5824,6 @@ gtk_event_controller_get_propagation_limit
gtk_event_controller_set_propagation_limit
gtk_event_controller_get_widget
gtk_event_controller_reset
gtk_event_controller_get_name
gtk_event_controller_set_name
<SUBSECTION>
gtk_event_controller_get_current_event
@@ -6002,7 +5998,6 @@ gtk_mnemonic_trigger_get_keyval
GtkAlternativeTrigger
gtk_alternative_trigger_new
gtk_alternative_trigger_get_first
gtk_alternative_trigger_get_second
<SUBSECTION>
GtkNeverTrigger
@@ -6088,7 +6083,7 @@ GtkShortcutManagerInterface
<TITLE>GtkShortcutController</TITLE>
GtkShortcutController
gtk_shortcut_controller_new
gtk_shortcut_controller_new_for_model
gtk_shortcut_controller_new_with_model
GtkShortcutScope
GtkShortcutManager
GtkShortcutManagerInterface
@@ -6469,8 +6464,8 @@ GTK_SHORTCUTS_SHORTCUT_GET_CLASS
GtkShortcutLabel
gtk_shortcut_label_new
gtk_shortcut_label_get_accelerator
gtk_shortcut_label_set_accelerator
gtk_shortcut_label_get_disabled_text
gtk_shortcut_label_set_accelerator
gtk_shortcut_label_set_disabled_text
<SUBSECTION Private>
@@ -6654,27 +6649,6 @@ GTK_TYPE_BOX_LAYOUT
gtk_box_layout_get_type
</SECTION>
<SECTION>
<FILE>gtkcenterlayout</FILE>
GtkCenterLayout
gtk_center_layout_new
gtk_center_layout_set_orientation
gtk_center_layout_get_orientation
gtk_center_layout_set_baseline_position
gtk_center_layout_get_baseline_position
gtk_center_layout_set_start_widget
gtk_center_layout_get_start_widget
gtk_center_layout_set_center_widget
gtk_center_layout_get_center_widget
gtk_center_layout_set_end_widget
gtk_center_layout_get_end_widget
<SUBSECTION Standard>
GTK_TYPE_CENTER_LAYOUT
gtk_center_layout_get_type
</SECTION>
<SECTION>
<FILE>gtkcustomlayout</FILE>
GtkCustomLayout
-1
View File
@@ -41,7 +41,6 @@ gtk_cell_renderer_spinner_get_type
gtk_cell_renderer_text_get_type
gtk_cell_renderer_toggle_get_type
gtk_cell_view_get_type
gtk_center_layout_get_type
gtk_check_button_get_type
gtk_color_button_get_type
gtk_color_chooser_get_type
+11 -6
View File
@@ -73,12 +73,6 @@
between different events by looking at their type, using
gdk_event_get_event_type().
</para>
<para>
Some events, such as touch events or button press-release pairs,
are connected in to each other in an “event sequence” that
univocally identifies events that are related to the same
interaction.
</para>
<para>
When GTK creates a GdkSurface, it connects to the #GdkSurface::event
signal on it, which receives all of these input events. Surfaces have
@@ -187,6 +181,17 @@
</para>
</refsect2>
<refsect2>
<title>Touch events</title>
<para>
Touch events are emitted as events of type %GDK_TOUCH_BEGIN,
%GDK_TOUCH_UPDATE or %GDK_TOUCH_END, those events contain an
“event sequence” that univocally identifies the physical touch
until it is lifted from the device.
</para>
</refsect2>
<refsect2>
<title>Keyboard input</title>
+2
View File
@@ -23,6 +23,7 @@ private_headers = [
'gtkcolorscaleprivate.h',
'gtkcolorswatchprivate.h',
'gtkcomboboxprivate.h',
'gtkcontainerprivate.h',
'gtkconstraintexpressionprivate.h',
'gtkconstraintguideprivate.h',
'gtkconstraintlayoutprivate.h',
@@ -342,6 +343,7 @@ content_files = [
'building.xml',
'compiling.xml',
'css-overview.xml',
'css-properties.xml',
'drawing-model.xml',
'glossary.xml',
'gtk4-broadwayd.xml',
+5 -38
View File
@@ -299,9 +299,8 @@
in GTK 4.
</para>
<para>
GdkEvent is now a strictly read-only type, and you
can no longer change any of its fields, or construct new
events.
GdkEvent is now a strictly read-only boxed type, and you
can no longer change any of its fields.
</para>
</section>
@@ -309,7 +308,7 @@
<title>Stop using gdk_surface_set_event_compression</title>
<para>
Event compression is now always enabled. If you need to see the uncoalesced
motion history, use gdk_motion_event_get_history() on the latest motion event.
motion history, use gdk_event_get_motion_history().
</para>
</section>
@@ -319,8 +318,8 @@
Warping the pointer is disorienting and unfriendly to users.
GTK 4 does not support it. In special circumstances (such as when
implementing remote connection UIs) it can be necessary to
warp the pointer; in this case, use platform APIs such as
<function>XWarpPointer()</function> directly.
warp the pointer; in this case, use platform APIs such as XWarpPointer
directly.
</para>
</section>
@@ -494,12 +493,6 @@
The recommended way to influence focus behavior of custom widgets
in GTK 4 is to override the focus() and grab_focus() vfuncs.
</para>
<para>
The feature to automatically keep the focus widget scrolled into view
with gtk_container_set_focus_vadjustment() has been removed from
GtkContainer, and is provided by scrollables instead. In the common case
that the scrollable is a #GtkViewport, use #GtkViewport:scroll-to-focus.
</para>
</section>
<section>
@@ -569,12 +562,6 @@
and always use the context's current state. Update all callers
to omit the state argument.
</para>
<para>
The most commonly used GtkStyleContext API, gtk_style_context_add_class(),
has been moved to GtkWidget as gtk_widget_add_css_class(), as have the
corresponding gtk_style_context_remove_class() and
gtk_style_context_has_class() APIs.
</para>
</section>
<section>
@@ -599,17 +586,6 @@
</para>
</section>
<section>
<title>Stop using GtkShadowType and GtkRelief properties</title>
<para>
The shadow-type properties in GtkScrolledWindow, GtkViewport,
and GtkFrame, as well as the relief properties in GtkButton
and its subclasses have been removed. GtkScrolledWindow, GtkButton
and GtkMenuButton have instead gained a boolean has-frame
property.
</para>
</section>
<section>
<title>Adapt to GtkWidget's size request changes</title>
<para>
@@ -1060,15 +1036,6 @@
</para>
</section>
<section>
<title>GtkAspectFrame is no longer a frame</title>
<para>
GtkAspectFrame is no longer derived from GtkFrame and does not
place a label and frame around its child anymore. It still lets
you control the aspect ratio of its child.
</para>
</section>
<section>
<title>Stop using custom tooltip windows</title>
<para>
+2 -3
View File
@@ -3,9 +3,8 @@ if get_option('gtk_doc')
error('Building the GTK documentation requires Meson 0.52.0')
endif
# Use gtk-doc as a sub-project from the gtk-doc-for-gtk4 branch
# for the time being
dependency('gtk-doc', version: '>=1.99',
# Use gtk-doc as a sub-project if the version isn't new enough
dependency('gtk-doc', version: '>=1.32',
fallback: ['gtk-doc', 'dummy_dep'],
default_options: ['tests=false'])
+18 -4
View File
@@ -455,6 +455,7 @@ create_text_view (void)
GtkWidget *text_view;
widget = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
text_view = gtk_text_view_new ();
gtk_container_add (GTK_CONTAINER (widget), text_view);
/* Bad hack to add some size to the widget */
@@ -475,6 +476,7 @@ create_tree_view (void)
WidgetInfo *info;
widget = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
store = gtk_tree_store_new (3, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING);
gtk_tree_store_append (store, &iter, NULL);
gtk_tree_store_set (store, &iter, 0, "Line One", 1, FALSE, 2, "A", -1);
@@ -518,6 +520,7 @@ create_icon_view (void)
WidgetInfo *info;
widget = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
list_store = gtk_list_store_new (2, G_TYPE_STRING, GDK_TYPE_PIXBUF);
gtk_list_store_append (list_store, &iter);
pixbuf = gdk_pixbuf_new_from_file ("folder.png", NULL);
@@ -662,19 +665,27 @@ create_panes (void)
gtk_box_set_homogeneous (GTK_BOX (hbox), TRUE);
pane = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
gtk_paned_pack1 (GTK_PANED (pane),
g_object_new (GTK_TYPE_FRAME, NULL),
g_object_new (GTK_TYPE_FRAME,
"shadow-type", GTK_SHADOW_IN,
NULL),
FALSE, FALSE);
gtk_paned_pack2 (GTK_PANED (pane),
g_object_new (GTK_TYPE_FRAME, NULL),
g_object_new (GTK_TYPE_FRAME,
"shadow-type", GTK_SHADOW_IN,
NULL),
FALSE, FALSE);
gtk_container_add (GTK_CONTAINER (hbox),
pane);
pane = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
gtk_paned_pack1 (GTK_PANED (pane),
g_object_new (GTK_TYPE_FRAME, NULL),
g_object_new (GTK_TYPE_FRAME,
"shadow-type", GTK_SHADOW_IN,
NULL),
FALSE, FALSE);
gtk_paned_pack2 (GTK_PANED (pane),
g_object_new (GTK_TYPE_FRAME, NULL),
g_object_new (GTK_TYPE_FRAME,
"shadow-type", GTK_SHADOW_IN,
NULL),
FALSE, FALSE);
gtk_container_add (GTK_CONTAINER (hbox),
pane);
@@ -1248,6 +1259,7 @@ create_list_box (void)
WidgetInfo *info;
widget = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
list = gtk_list_box_new ();
gtk_list_box_set_selection_mode (GTK_LIST_BOX (list), GTK_SELECTION_BROWSE);
@@ -1300,6 +1312,7 @@ create_flow_box (void)
WidgetInfo *info;
widget = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
box = gtk_flow_box_new ();
gtk_flow_box_set_min_children_per_line (GTK_FLOW_BOX (box), 2);
@@ -1338,6 +1351,7 @@ create_gl_area (void)
GtkWidget *gears;
widget = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
gears = gtk_gears_new ();
gtk_container_add (GTK_CONTAINER (widget), gears);
+1
View File
@@ -143,6 +143,7 @@ activate (GtkApplication *app,
g_signal_connect (window, "destroy", G_CALLBACK (close_window), NULL);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (window), frame);
drawing_area = gtk_drawing_area_new ();
+10 -10
View File
@@ -100,7 +100,7 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_surface_id));
if (surface)
{
event = gdk_crossing_event_new (GDK_ENTER_NOTIFY,
event = gdk_event_crossing_new (GDK_ENTER_NOTIFY,
surface,
gdk_seat_get_pointer (seat),
gdk_seat_get_pointer (seat),
@@ -119,7 +119,7 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_surface_id));
if (surface)
{
event = gdk_crossing_event_new (GDK_LEAVE_NOTIFY,
event = gdk_event_crossing_new (GDK_LEAVE_NOTIFY,
surface,
gdk_seat_get_pointer (seat),
gdk_seat_get_pointer (seat),
@@ -141,7 +141,7 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_surface_id));
if (surface)
{
event = gdk_motion_event_new (surface,
event = gdk_event_motion_new (surface,
gdk_seat_get_pointer (seat),
gdk_seat_get_pointer (seat),
NULL,
@@ -165,7 +165,7 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_surface_id));
if (surface)
{
event = gdk_button_event_new (message->base.type == BROADWAY_EVENT_BUTTON_PRESS
event = gdk_event_button_new (message->base.type == BROADWAY_EVENT_BUTTON_PRESS
? GDK_BUTTON_PRESS
: GDK_BUTTON_RELEASE,
surface,
@@ -188,7 +188,7 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_surface_id));
if (surface)
{
event = gdk_scroll_event_new_discrete (surface,
event = gdk_event_discrete_scroll_new (surface,
gdk_seat_get_pointer (seat),
gdk_seat_get_pointer (seat),
NULL,
@@ -243,7 +243,7 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
if (event_type == GDK_TOUCH_BEGIN || event_type == GDK_TOUCH_UPDATE)
state |= GDK_BUTTON1_MASK;
event = gdk_touch_event_new (event_type,
event = gdk_event_touch_new (event_type,
GUINT_TO_POINTER (message->touch.sequence_id),
surface,
gdk_seat_get_pointer (seat),
@@ -271,7 +271,7 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
translated.consumed = 0;
translated.layout = 0;
translated.level = 0;
event = gdk_key_event_new (message->base.type == BROADWAY_EVENT_KEY_PRESS
event = gdk_event_key_new (message->base.type == BROADWAY_EVENT_KEY_PRESS
? GDK_KEY_PRESS
: GDK_KEY_RELEASE,
surface,
@@ -298,7 +298,7 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->configure_notify.id));
if (surface)
{
event = gdk_configure_event_new (surface,
event = gdk_event_configure_new (surface,
message->configure_notify.width,
message->configure_notify.height);
@@ -329,7 +329,7 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->focus.old_id));
if (surface)
{
event = gdk_focus_event_new (surface,
event = gdk_event_focus_new (surface,
gdk_seat_get_keyboard (seat),
gdk_seat_get_keyboard (seat),
FALSE);
@@ -340,7 +340,7 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->focus.new_id));
if (surface)
{
event = gdk_focus_event_new (surface,
event = gdk_event_focus_new (surface,
gdk_seat_get_keyboard (seat),
gdk_seat_get_keyboard (seat),
TRUE);
-1
View File
@@ -27,7 +27,6 @@
#include <gdk/gdksurfaceprivate.h>
#include "gdkbroadwaysurface.h"
#include "gdkinternals.h"
G_BEGIN_DECLS
+1 -1
View File
@@ -505,7 +505,7 @@ generate_grab_broken_event (GdkDisplay *display,
{
GdkEvent *event;
event = gdk_grab_broken_event_new (surface,
event = gdk_event_grab_broken_new (surface,
device,
device,
grab_surface,
+24 -24
View File
@@ -915,12 +915,12 @@ gdk_drop_emit_enter_event (GdkDrop *self,
g_warn_if_fail (!priv->entered);
event = gdk_dnd_event_new (GDK_DRAG_ENTER,
priv->surface,
priv->device,
self,
time,
0, 0);
event = gdk_event_drag_new (GDK_DRAG_ENTER,
priv->surface,
priv->device,
self,
time,
0, 0);
priv->entered = TRUE;
@@ -939,12 +939,12 @@ gdk_drop_emit_motion_event (GdkDrop *self,
g_warn_if_fail (priv->entered);
event = gdk_dnd_event_new (GDK_DRAG_MOTION,
priv->surface,
priv->device,
self,
time,
x, y);
event = gdk_event_drag_new (GDK_DRAG_MOTION,
priv->surface,
priv->device,
self,
time,
x, y);
gdk_drop_do_emit_event (event, dont_queue);
}
@@ -959,12 +959,12 @@ gdk_drop_emit_leave_event (GdkDrop *self,
g_warn_if_fail (priv->entered);
event = gdk_dnd_event_new (GDK_DRAG_LEAVE,
priv->surface,
priv->device,
self,
time,
0, 0);
event = gdk_event_drag_new (GDK_DRAG_LEAVE,
priv->surface,
priv->device,
self,
time,
0, 0);
priv->entered = FALSE;
@@ -984,12 +984,12 @@ gdk_drop_emit_drop_event (GdkDrop *self,
g_warn_if_fail (priv->entered);
g_warn_if_fail (priv->state == GDK_DROP_STATE_NONE);
event = gdk_dnd_event_new (GDK_DROP_START,
priv->surface,
priv->device,
self,
time,
x, y);
event = gdk_event_drag_new (GDK_DROP_START,
priv->surface,
priv->device,
self,
time,
x, y);
priv->state = GDK_DROP_STATE_DROPPING;
+1298 -2099
View File
File diff suppressed because it is too large Load Diff
+14 -79
View File
@@ -41,10 +41,6 @@ G_BEGIN_DECLS
#define GDK_TYPE_EVENT (gdk_event_get_type ())
#define GDK_TYPE_EVENT_SEQUENCE (gdk_event_sequence_get_type ())
#define GDK_IS_EVENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_EVENT))
#define GDK_EVENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_EVENT, GdkEvent))
#define GDK_IS_EVENT_TYPE(event, type) (gdk_event_get_event_type ((event)) == (type))
/**
* GDK_PRIORITY_EVENTS:
@@ -102,38 +98,9 @@ G_BEGIN_DECLS
*/
#define GDK_BUTTON_SECONDARY (3)
typedef struct _GdkEventSequence GdkEventSequence;
typedef struct _GdkEvent GdkEvent;
#define GDK_TYPE_BUTTON_EVENT (gdk_button_event_get_type())
#define GDK_TYPE_CONFIGURE_EVENT (gdk_configure_event_get_type())
#define GDK_TYPE_CROSSING_EVENT (gdk_crossing_event_get_type())
#define GDK_TYPE_DELETE_EVENT (gdk_delete_event_get_type())
#define GDK_TYPE_DND_EVENT (gdk_dnd_event_get_type())
#define GDK_TYPE_FOCUS_EVENT (gdk_focus_event_get_type())
#define GDK_TYPE_GRAB_BROKEN_EVENT (gdk_grab_broken_event_get_type())
#define GDK_TYPE_KEY_EVENT (gdk_key_event_get_type())
#define GDK_TYPE_MOTION_EVENT (gdk_motion_event_get_type())
#define GDK_TYPE_PAD_EVENT (gdk_pad_event_get_type())
#define GDK_TYPE_PROXIMITY_EVENT (gdk_proximity_event_get_type())
#define GDK_TYPE_SCROLL_EVENT (gdk_scroll_event_get_type())
#define GDK_TYPE_TOUCH_EVENT (gdk_touch_event_get_type())
#define GDK_TYPE_TOUCHPAD_EVENT (gdk_touchpad_event_get_type())
typedef struct _GdkButtonEvent GdkButtonEvent;
typedef struct _GdkConfigureEvent GdkConfigureEvent;
typedef struct _GdkCrossingEvent GdkCrossingEvent;
typedef struct _GdkDeleteEvent GdkDeleteEvent;
typedef struct _GdkDNDEvent GdkDNDEvent;
typedef struct _GdkFocusEvent GdkFocusEvent;
typedef struct _GdkGrabBrokenEvent GdkGrabBrokenEvent;
typedef struct _GdkKeyEvent GdkKeyEvent;
typedef struct _GdkMotionEvent GdkMotionEvent;
typedef struct _GdkPadEvent GdkPadEvent;
typedef struct _GdkProximityEvent GdkProximityEvent;
typedef struct _GdkScrollEvent GdkScrollEvent;
typedef struct _GdkTouchEvent GdkTouchEvent;
typedef struct _GdkTouchpadEvent GdkTouchpadEvent;
typedef struct _GdkEventSequence GdkEventSequence;
typedef union _GdkEvent GdkEvent;
/**
* GdkEventType:
@@ -330,6 +297,7 @@ typedef enum
GDK_AVAILABLE_IN_ALL
GType gdk_event_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GType gdk_event_sequence_get_type (void) G_GNUC_CONST;
@@ -380,13 +348,9 @@ gboolean gdk_event_get_axis (GdkEvent *event,
GDK_AVAILABLE_IN_ALL
gboolean gdk_event_get_pointer_emulated (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
GType gdk_button_event_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
guint gdk_button_event_get_button (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
GType gdk_scroll_event_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GdkScrollDirection gdk_scroll_event_get_direction (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
void gdk_scroll_event_get_deltas (GdkEvent *event,
@@ -395,8 +359,6 @@ void gdk_scroll_event_get_deltas (GdkEvent *event,
GDK_AVAILABLE_IN_ALL
gboolean gdk_scroll_event_is_stop (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
GType gdk_key_event_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
guint gdk_key_event_get_keyval (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
guint gdk_key_event_get_keycode (GdkEvent *event);
@@ -409,30 +371,18 @@ guint gdk_key_event_get_level (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
gboolean gdk_key_event_is_modifier (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
GType gdk_focus_event_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
gboolean gdk_focus_event_get_in (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
GType gdk_touch_event_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
gboolean gdk_touch_event_get_emulating_pointer (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
GType gdk_crossing_event_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GdkCrossingMode gdk_crossing_event_get_mode (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
GdkNotifyType gdk_crossing_event_get_detail (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
gboolean gdk_crossing_event_get_focus (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
GType gdk_configure_event_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
void gdk_configure_event_get_size (GdkEvent *event,
int *width,
int *height);
GDK_AVAILABLE_IN_ALL
GType gdk_touchpad_event_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GdkTouchpadGesturePhase
gdk_touchpad_event_get_gesture_phase (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
@@ -442,41 +392,26 @@ void gdk_touchpad_event_get_deltas (GdkEvent *event,
double *dx,
double *dy);
GDK_AVAILABLE_IN_ALL
double gdk_touchpad_event_get_pinch_angle_delta (GdkEvent *event);
double gdk_touchpad_pinch_event_get_angle_delta (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
double gdk_touchpad_event_get_pinch_scale (GdkEvent *event);
double gdk_touchpad_pinch_event_get_scale (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
GType gdk_pad_event_get_type (void) G_GNUC_CONST;
guint gdk_pad_button_event_get_button (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
guint gdk_pad_event_get_button (GdkEvent *event);
void gdk_pad_axis_event_get_value (GdkEvent *event,
guint *index,
double *value);
GDK_AVAILABLE_IN_ALL
void gdk_pad_event_get_axis_value (GdkEvent *event,
guint *index,
double *value);
void gdk_pad_event_get_group_mode (GdkEvent *event,
guint *group,
guint *mode);
GDK_AVAILABLE_IN_ALL
void gdk_pad_event_get_group_mode (GdkEvent *event,
guint *group,
guint *mode);
GDK_AVAILABLE_IN_ALL
GType gdk_dnd_event_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GdkDrop * gdk_dnd_event_get_drop (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
GType gdk_grab_broken_event_get_type (void) G_GNUC_CONST;
GdkDrop * gdk_drag_event_get_drop (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
GdkSurface * gdk_grab_broken_event_get_grab_surface (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
gboolean gdk_grab_broken_event_get_implicit (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
GType gdk_motion_event_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GList * gdk_motion_event_get_history (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
GType gdk_delete_event_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GType gdk_proximity_event_get_type (void) G_GNUC_CONST;
GList * gdk_event_get_motion_history (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
gboolean gdk_event_triggers_context_menu (GdkEvent *event);
+301 -191
View File
@@ -30,98 +30,74 @@
#include <gdk/gdkdevice.h>
#include <gdk/gdkdevicetool.h>
G_BEGIN_DECLS
#define GDK_EVENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_EVENT, GdkEventClass))
typedef struct _GdkEventAny GdkEventAny;
typedef struct _GdkEventMotion GdkEventMotion;
typedef struct _GdkEventButton GdkEventButton;
typedef struct _GdkEventTouch GdkEventTouch;
typedef struct _GdkEventScroll GdkEventScroll;
typedef struct _GdkEventKey GdkEventKey;
typedef struct _GdkEventFocus GdkEventFocus;
typedef struct _GdkEventCrossing GdkEventCrossing;
typedef struct _GdkEventConfigure GdkEventConfigure;
typedef struct _GdkEventProximity GdkEventProximity;
typedef struct _GdkEventDND GdkEventDND;
typedef struct _GdkEventSetting GdkEventSetting;
typedef struct _GdkEventGrabBroken GdkEventGrabBroken;
typedef struct _GdkEventTouchpadSwipe GdkEventTouchpadSwipe;
typedef struct _GdkEventTouchpadPinch GdkEventTouchpadPinch;
typedef struct _GdkEventPadButton GdkEventPadButton;
typedef struct _GdkEventPadAxis GdkEventPadAxis;
typedef struct _GdkEventPadGroupMode GdkEventPadGroupMode;
typedef struct _GdkEventClass GdkEventClass;
/*< private >
* GdkEvent:
* @ref_count: the reference count of the event
* @event_type: the specialized event type
* @surface: the surface of the event
* @device: the device of the event
* @source_device: the source device
* @time: a serial identifier of the event that can be used to order
* two events
* @flags: event flags
/*
* GdkEventAny:
* @type: the type of the event.
* @surface: the surface which received the event.
* @send_event: %TRUE if the event was sent explicitly.
*
* The abstract type for all windowing system events.
* Contains the fields which are common to all event structs.
* Any event pointer can safely be cast to a pointer to a #GdkEventAny to
* access these fields.
*/
struct _GdkEvent
struct _GdkEventAny
{
GTypeInstance parent_instance;
grefcount ref_count;
/* Specialised event type */
GdkEventType event_type;
/* The surface of the event */
int ref_count;
GdkEventType type;
GdkSurface *surface;
/* The devices associated to the event */
GdkDevice *device;
GdkDevice *source_device;
guint32 time;
guint16 flags;
};
/*< private >
* GdkEventClass:
* @finalize: a function called when the last reference held on an event is
* released; implementations of GdkEvent must chain up to the parent class
*
* The base class for events.
*/
struct _GdkEventClass
{
GTypeClass parent_class;
void (* finalize) (GdkEvent *event);
GdkModifierType (* get_state) (GdkEvent *event);
gboolean (* get_position) (GdkEvent *event,
double *x,
double *y);
GdkEventSequence * (* get_sequence) (GdkEvent *event);
GdkDeviceTool * (* get_tool) (GdkEvent *event);
gboolean (* get_axes) (GdkEvent *event,
double **axes,
guint *n_axes);
guint pointer_emulated : 1;
guint touch_emulating : 1;
guint scroll_is_stop : 1;
guint key_is_modifier : 1;
guint focus_in : 1;
GdkDevice *device;
GdkDevice *source_device;
};
/*
* GdkDeleteEvent:
*
* Generated when a surface is deleted.
*/
struct _GdkDeleteEvent
{
GdkEvent parent_instance;
};
/*
* GdkMotionEvent:
* @state: (type GdkModifierType): a bit-mask representing the state of
* the modifier keys (e.g. Control, Shift and Alt) set during the motion
* event. See #GdkModifierType.
* GdkEventMotion:
* @type: the type of the event.
* @surface: the surface which received the event.
* @send_event: %TRUE if the event was sent explicitly.
* @time: the time of the event in milliseconds.
* @x: the x coordinate of the pointer relative to the surface.
* @y: the y coordinate of the pointer relative to the surface.
* @axes: @x, @y translated to the axes of @device, or %NULL if @device is
* the mouse.
* @history: (element-type GdkTimeCoord): a list of time and coordinates
* for other motion events that were compressed before delivering the
* current event
* @state: (type GdkModifierType): a bit-mask representing the state of
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
* buttons. See #GdkModifierType.
* @device: the master device that the event originated from. Use
* gdk_event_get_source_device() to get the slave device.
* screen.
*
* Generated when the pointer moves.
*/
struct _GdkMotionEvent
struct _GdkEventMotion
{
GdkEvent parent_instance;
GdkEventAny any;
GdkModifierType state;
double x;
double y;
@@ -131,7 +107,15 @@ struct _GdkMotionEvent
};
/*
* GdkButtonEvent:
* GdkEventButton:
* @type: the type of the event (%GDK_BUTTON_PRESS or %GDK_BUTTON_RELEASE).
* @surface: the surface which received the event.
* @send_event: %TRUE if the event was sent explicitly.
* @time: the time of the event in milliseconds.
* @x: the x coordinate of the pointer relative to the surface.
* @y: the y coordinate of the pointer relative to the surface.
* @axes: @x, @y translated to the axes of @device, or %NULL if @device is
* the mouse.
* @state: (type GdkModifierType): a bit-mask representing the state of
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
* buttons. See #GdkModifierType.
@@ -139,19 +123,16 @@ struct _GdkMotionEvent
* Normally button 1 is the left mouse button, 2 is the middle button,
* and 3 is the right button. On 2-button mice, the middle button can
* often be simulated by pressing both mouse buttons together.
* @x: the x coordinate of the pointer relative to the surface.
* @y: the y coordinate of the pointer relative to the surface.
* @axes: @x, @y translated to the axes of @device, or %NULL if @device is
* the mouse.
* @tool: a #GdkDeviceTool
* @device: the master device that the event originated from. Use
* gdk_event_get_source_device() to get the slave device.
* screen.
*
* Used for button press and button release events. The
* @type field will be one of %GDK_BUTTON_PRESS or %GDK_BUTTON_RELEASE,
*/
struct _GdkButtonEvent
struct _GdkEventButton
{
GdkEvent parent_instance;
GdkEventAny any;
GdkModifierType state;
guint button;
double x;
@@ -161,16 +142,25 @@ struct _GdkButtonEvent
};
/*
* GdkTouchEvent:
* GdkEventTouch:
* @type: the type of the event (%GDK_TOUCH_BEGIN, %GDK_TOUCH_UPDATE,
* %GDK_TOUCH_END, %GDK_TOUCH_CANCEL)
* @surface: the surface which received the event
* @send_event: %TRUE if the event was sent explicitly.
* @time: the time of the event in milliseconds.
* @x: the x coordinate of the pointer relative to the surface
* @y: the y coordinate of the pointer relative to the surface
* @axes: @x, @y translated to the axes of @device, or %NULL if @device is
* the mouse
* @state: (type GdkModifierType): a bit-mask representing the state of
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
* buttons. See #GdkModifierType
* @x: the x coordinate of the pointer relative to the surface
* @y: the y coordinate of the pointer relative to the surface
* @axes: @x, @y translated to the axes of the event's device, or %NULL
* if @device is the mouse
* @sequence: the event sequence that the event belongs to
* @emulated: whether the event is the result of a pointer emulation
* @emulating_pointer: whether the event should be used for emulating
* pointer event
* @device: the master device that the event originated from. Use
* gdk_event_get_source_device() to get the slave device.
* screen
*
* Used for touch events.
* @type field will be one of %GDK_TOUCH_BEGIN, %GDK_TOUCH_UPDATE,
@@ -183,21 +173,22 @@ struct _GdkButtonEvent
* (or %GDK_TOUCH_CANCEL) event. With multitouch devices, there may be
* several active sequences at the same time.
*/
struct _GdkTouchEvent
struct _GdkEventTouch
{
GdkEvent parent_instance;
GdkEventAny any;
GdkModifierType state;
double x;
double y;
double *axes;
GdkEventSequence *sequence;
gboolean touch_emulating;
gboolean pointer_emulated;
};
/*
* GdkScrollEvent:
* GdkEventScroll:
* @type: the type of the event (%GDK_SCROLL).
* @surface: the surface which received the event.
* @send_event: %TRUE if the event was sent explicitly.
* @time: the time of the event in milliseconds.
* @x: the x coordinate of the pointer relative to the surface.
* @y: the y coordinate of the pointer relative to the surface.
* @state: (type GdkModifierType): a bit-mask representing the state of
@@ -206,11 +197,10 @@ struct _GdkTouchEvent
* @direction: the direction to scroll to (one of %GDK_SCROLL_UP,
* %GDK_SCROLL_DOWN, %GDK_SCROLL_LEFT, %GDK_SCROLL_RIGHT or
* %GDK_SCROLL_SMOOTH).
* @device: the master device that the event originated from. Use
* gdk_event_get_source_device() to get the slave device.
* @delta_x: the x coordinate of the scroll delta
* @delta_y: the y coordinate of the scroll delta
* @pointer_emulated: whether the scroll event was the result of
* a pointer emulation
* @tool: a #GdkDeviceTool
*
* Generated from button presses for the buttons 4 to 7. Wheel mice are
* usually configured to generate button press events for buttons 4 and 5
@@ -221,30 +211,18 @@ struct _GdkTouchEvent
* these, the scroll deltas can be obtained with
* gdk_event_get_scroll_deltas().
*/
struct _GdkScrollEvent
struct _GdkEventScroll
{
GdkEvent parent_instance;
GdkEventAny any;
double x;
double y;
GdkModifierType state;
GdkScrollDirection direction;
double delta_x;
double delta_y;
gboolean pointer_emulated;
gboolean is_stop;
GdkDeviceTool *tool;
};
/*
* GdkTranslatedKey:
* @keyval: the translated key symbol
* @consumed: the consumed modifiers
* @layout: the keyboard layout
* @level: the layout level
*
* Describes a translated key code.
*/
typedef struct {
guint keyval;
GdkModifierType consumed;
@@ -253,7 +231,11 @@ typedef struct {
} GdkTranslatedKey;
/*
* GdkKeyEvent:
* GdkEventKey:
* @type: the type of the event (%GDK_KEY_PRESS or %GDK_KEY_RELEASE).
* @surface: the surface which received the event.
* @send_event: %TRUE if the event was sent explicitly.
* @time: the time of the event in milliseconds.
* @state: (type GdkModifierType): a bit-mask representing the state of
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
* buttons. See #GdkModifierType.
@@ -263,40 +245,41 @@ typedef struct {
*
* Describes a key press or key release event.
*/
struct _GdkKeyEvent
struct _GdkEventKey
{
GdkEvent parent_instance;
GdkEventAny any;
GdkModifierType state;
guint32 keycode;
gboolean key_is_modifier;
GdkTranslatedKey translated[2];
};
/*
* GdkCrossingEvent:
* @state: (type GdkModifierType): a bit-mask representing the state of
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
* buttons. See #GdkModifierType.
* GdkEventCrossing:
* @type: the type of the event (%GDK_ENTER_NOTIFY or %GDK_LEAVE_NOTIFY).
* @surface: the surface which received the event.
* @send_event: %TRUE if the event was sent explicitly.
* @child_surface: the surface that was entered or left.
* @time: the time of the event in milliseconds.
* @x: the x coordinate of the pointer relative to the surface.
* @y: the y coordinate of the pointer relative to the surface.
* @mode: the crossing mode (%GDK_CROSSING_NORMAL, %GDK_CROSSING_GRAB,
* %GDK_CROSSING_UNGRAB, %GDK_CROSSING_GTK_GRAB, %GDK_CROSSING_GTK_UNGRAB or
* %GDK_CROSSING_STATE_CHANGED). %GDK_CROSSING_GTK_GRAB, %GDK_CROSSING_GTK_UNGRAB,
* and %GDK_CROSSING_STATE_CHANGED were added in 2.14 and are always synthesized,
* never native.
* @x: the x coordinate of the pointer relative to the surface.
* @y: the y coordinate of the pointer relative to the surface.
* @detail: the kind of crossing that happened (%GDK_NOTIFY_INFERIOR,
* %GDK_NOTIFY_ANCESTOR, %GDK_NOTIFY_VIRTUAL, %GDK_NOTIFY_NONLINEAR or
* %GDK_NOTIFY_NONLINEAR_VIRTUAL).
* @focus: %TRUE if @surface is the focus surface or an inferior.
* @child_surface: the surface that was entered or left.
* @state: (type GdkModifierType): a bit-mask representing the state of
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
* buttons. See #GdkModifierType.
*
* Generated when the pointer enters or leaves a surface.
*/
struct _GdkCrossingEvent
struct _GdkEventCrossing
{
GdkEvent parent_instance;
GdkEventAny any;
GdkModifierType state;
GdkCrossingMode mode;
double x;
@@ -307,7 +290,10 @@ struct _GdkCrossingEvent
};
/*
* GdkFocusEvent:
* GdkEventFocus:
* @type: the type of the event (%GDK_FOCUS_CHANGE).
* @surface: the surface which received the event.
* @send_event: %TRUE if the event was sent explicitly.
* @in: %TRUE if the surface has gained the keyboard focus, %FALSE if
* it has lost the focus.
* @mode: the crossing mode
@@ -315,15 +301,19 @@ struct _GdkCrossingEvent
*
* Describes a change of keyboard focus.
*/
struct _GdkFocusEvent
struct _GdkEventFocus
{
GdkEvent parent_instance;
gboolean focus_in;
GdkEventAny any;
gint16 in;
GdkCrossingMode mode;
GdkNotifyType detail;
};
/*
* GdkConfigureEvent:
* GdkEventConfigure:
* @type: the type of the event (%GDK_CONFIGURE).
* @surface: the surface which received the event.
* @send_event: %TRUE if the event was sent explicitly.
* @x: the new x coordinate of the surface, relative to its parent.
* @y: the new y coordinate of the surface, relative to its parent.
* @width: the new width of the surface.
@@ -331,10 +321,9 @@ struct _GdkFocusEvent
*
* Generated when a surface size or position has changed.
*/
struct _GdkConfigureEvent
struct _GdkEventConfigure
{
GdkEvent parent_instance;
GdkEventAny any;
int x;
int y;
int width;
@@ -342,23 +331,36 @@ struct _GdkConfigureEvent
};
/*
* GdkProximityEvent:
* @tool: the #GdkDeviceTool associated to the event
* GdkEventProximity:
* @type: the type of the event (%GDK_PROXIMITY_IN or %GDK_PROXIMITY_OUT).
* @surface: the surface which received the event.
* @send_event: %TRUE if the event was sent explicitly.
* @time: the time of the event in milliseconds.
* @device: the master device that the event originated from. Use
* gdk_event_get_source_device() to get the slave device.
*
* A proximity event indicates that a tool of a graphic tablet, or similar
* devices that report proximity, has moved in or out of contact with the
* tablet, or perhaps that the users finger has moved in or out of contact
* with a touch screen.
* Proximity events are generated when using GDKs wrapper for the
* XInput extension. The XInput extension is an add-on for standard X
* that allows you to use nonstandard devices such as graphics tablets.
* A proximity event indicates that the stylus has moved in or out of
* contact with the tablet, or perhaps that the users finger has moved
* in or out of contact with a touch screen.
*
* This event type will be used pretty rarely. It only is important for
* XInput aware programs that are drawing their own cursor.
*/
struct _GdkProximityEvent
struct _GdkEventProximity
{
GdkEvent parent_instance;
GdkEventAny any;
GdkDeviceTool *tool;
};
/*
* GdkGrabBrokenEvent:
* GdkEventGrabBroken:
* @type: the type of the event (%GDK_GRAB_BROKEN)
* @surface: the surface which received the event, i.e. the surface
* that previously owned the grab
* @send_event: %TRUE if the event was sent explicitly.
* @keyboard: %TRUE if a keyboard grab was broken, %FALSE if a pointer
* grab was broken
* @implicit: %TRUE if the broken grab was implicit
@@ -370,39 +372,67 @@ struct _GdkProximityEvent
* when the grab surface becomes unviewable (i.e. it or one of its ancestors
* is unmapped), or if the same application grabs the pointer or keyboard
* again. Note that implicit grabs (which are initiated by button presses)
* can also cause #GdkGrabBrokenEvent events.
* can also cause #GdkEventGrabBroken events.
*/
struct _GdkGrabBrokenEvent
{
GdkEvent parent_instance;
struct _GdkEventGrabBroken {
GdkEventAny any;
gboolean keyboard;
gboolean implicit;
GdkSurface *grab_surface;
};
/*
* GdkDNDEvent:
* GdkEventDND:
* @type: the type of the event (%GDK_DRAG_ENTER, %GDK_DRAG_LEAVE,
* %GDK_DRAG_MOTION or %GDK_DROP_START)
* @surface: the surface which received the event.
* @send_event: %TRUE if the event was sent explicitly.
* @drop: the #GdkDrop for the current DND operation.
* @x: the X coordinate of the pointer
* @y: the Y coordinate of the pointer
* @time: the time of the event in milliseconds.
*
* Generated during DND operations.
*/
struct _GdkDNDEvent
{
GdkEvent parent_instance;
struct _GdkEventDND {
GdkEventAny any;
GdkDrop *drop;
double x;
double y;
};
/*
* GdkTouchpadEvent:
* GdkEventTouchpadSwipe:
* @type: the type of the event (%GDK_TOUCHPAD_SWIPE)
* @surface: the surface which received the event
* @send_event: %TRUE if the event was sent explicitly
* @phase: (type GdkTouchpadGesturePhase): the current phase of the gesture
* @n_fingers: The number of fingers triggering the swipe
* @time: the time of the event in milliseconds
* @x: The X coordinate of the pointer
* @y: The Y coordinate of the pointer
* @dx: Movement delta in the X axis of the swipe focal point
* @dy: Movement delta in the Y axis of the swipe focal point
* @state: (type GdkModifierType): a bit-mask representing the state of
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
* buttons. See #GdkModifierType.
*
* Generated during touchpad swipe gestures.
*/
struct _GdkEventTouchpadSwipe {
GdkEventAny any;
GdkModifierType state;
gint8 phase;
gint8 n_fingers;
double x;
double y;
double dx;
double dy;
};
/*
* GdkEventTouchpadPinch:
* @type: the type of the event (%GDK_TOUCHPAD_PINCH)
* @surface: the surface which received the event
* @send_event: %TRUE if the event was sent explicitly
* @phase: (type GdkTouchpadGesturePhase): the current phase of the gesture
* @n_fingers: The number of fingers triggering the pinch
* @time: the time of the event in milliseconds
@@ -410,17 +440,18 @@ struct _GdkDNDEvent
* @y: The Y coordinate of the pointer
* @dx: Movement delta in the X axis of the swipe focal point
* @dy: Movement delta in the Y axis of the swipe focal point
* @angle_delta: For pinch events, the angle change in radians, negative angles
* @angle_delta: The angle change in radians, negative angles
* denote counter-clockwise movements
* @scale: For pinch events, the current scale, relative to that at the time of
* @scale: The current scale, relative to that at the time of
* the corresponding %GDK_TOUCHPAD_GESTURE_PHASE_BEGIN event
* @state: (type GdkModifierType): a bit-mask representing the state of
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
* buttons. See #GdkModifierType.
*
* Generated during touchpad gestures.
* Generated during touchpad swipe gestures.
*/
struct _GdkTouchpadEvent
{
GdkEvent parent_instance;
struct _GdkEventTouchpadPinch {
GdkEventAny any;
GdkModifierType state;
gint8 phase;
gint8 n_fingers;
@@ -432,20 +463,99 @@ struct _GdkTouchpadEvent
double scale;
};
struct _GdkPadEvent
{
GdkEvent parent_instance;
/*
* GdkEventPadButton:
* @type: the type of the event (%GDK_PAD_BUTTON_PRESS or %GDK_PAD_BUTTON_RELEASE).
* @surface: the surface which received the event.
* @send_event: %TRUE if the event was sent explicitly.
* @time: the time of the event in milliseconds.
* @group: the pad group the button belongs to. A %GDK_SOURCE_TABLET_PAD device
* may have one or more groups containing a set of buttons/rings/strips each.
* @button: The pad button that was pressed.
* @mode: The current mode of @group. Different groups in a %GDK_SOURCE_TABLET_PAD
* device may have different current modes.
*
* Generated during %GDK_SOURCE_TABLET_PAD button presses and releases.
*/
struct _GdkEventPadButton {
GdkEventAny any;
guint group;
guint mode;
guint button;
guint mode;
};
/*
* GdkEventPadAxis:
* @type: the type of the event (%GDK_PAD_RING or %GDK_PAD_STRIP).
* @surface: the surface which received the event.
* @send_event: %TRUE if the event was sent explicitly.
* @time: the time of the event in milliseconds.
* @group: the pad group the ring/strip belongs to. A %GDK_SOURCE_TABLET_PAD
* device may have one or more groups containing a set of buttons/rings/strips
* each.
* @index: number of strip/ring that was interacted. This number is 0-indexed.
* @mode: The current mode of @group. Different groups in a %GDK_SOURCE_TABLET_PAD
* device may have different current modes.
* @value: The current value for the given axis.
*
* Generated during %GDK_SOURCE_TABLET_PAD interaction with tactile sensors.
*/
struct _GdkEventPadAxis {
GdkEventAny any;
guint group;
guint index;
guint mode;
double value;
};
void gdk_event_init_types (void);
/*
* GdkEventPadGroupMode:
* @type: the type of the event (%GDK_PAD_GROUP_MODE).
* @surface: the surface which received the event.
* @send_event: %TRUE if the event was sent explicitly.
* @time: the time of the event in milliseconds.
* @group: the pad group that is switching mode. A %GDK_SOURCE_TABLET_PAD
* device may have one or more groups containing a set of buttons/rings/strips
* each.
* @mode: The new mode of @group. Different groups in a %GDK_SOURCE_TABLET_PAD
* device may have different current modes.
*
* Generated during %GDK_SOURCE_TABLET_PAD mode switches in a group.
*/
struct _GdkEventPadGroupMode {
GdkEventAny any;
guint group;
guint mode;
};
GdkEvent * gdk_button_event_new (GdkEventType type,
/*
* GdkEvent:
*
* The GdkEvent struct is private and should only be accessed
* using the accessor functions.
*/
union _GdkEvent
{
GdkEventAny any;
GdkEventMotion motion;
GdkEventButton button;
GdkEventTouch touch;
GdkEventScroll scroll;
GdkEventKey key;
GdkEventCrossing crossing;
GdkEventFocus focus_change;
GdkEventConfigure configure;
GdkEventProximity proximity;
GdkEventDND dnd;
GdkEventGrabBroken grab_broken;
GdkEventTouchpadSwipe touchpad_swipe;
GdkEventTouchpadPinch touchpad_pinch;
GdkEventPadButton pad_button;
GdkEventPadAxis pad_axis;
GdkEventPadGroupMode pad_group_mode;
};
GdkEvent * gdk_event_button_new (GdkEventType type,
GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
@@ -457,7 +567,7 @@ GdkEvent * gdk_button_event_new (GdkEventType type,
double y,
double *axes);
GdkEvent * gdk_motion_event_new (GdkSurface *surface,
GdkEvent * gdk_event_motion_new (GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
GdkDeviceTool *tool,
@@ -467,7 +577,7 @@ GdkEvent * gdk_motion_event_new (GdkSurface *surface,
double y,
double *axes);
GdkEvent * gdk_crossing_event_new (GdkEventType type,
GdkEvent * gdk_event_crossing_new (GdkEventType type,
GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
@@ -478,14 +588,14 @@ GdkEvent * gdk_crossing_event_new (GdkEventType type,
GdkCrossingMode mode,
GdkNotifyType notify);
GdkEvent * gdk_proximity_event_new (GdkEventType type,
GdkEvent * gdk_event_proximity_new (GdkEventType type,
GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
GdkDeviceTool *tool,
guint32 time);
GdkEvent * gdk_key_event_new (GdkEventType type,
GdkEvent * gdk_event_key_new (GdkEventType type,
GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
@@ -496,18 +606,18 @@ GdkEvent * gdk_key_event_new (GdkEventType type,
GdkTranslatedKey *translated,
GdkTranslatedKey *no_lock);
GdkEvent * gdk_focus_event_new (GdkSurface *surface,
GdkEvent * gdk_event_focus_new (GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
gboolean focus_in);
GdkEvent * gdk_configure_event_new (GdkSurface *surface,
GdkEvent * gdk_event_configure_new (GdkSurface *surface,
int width,
int height);
GdkEvent * gdk_delete_event_new (GdkSurface *surface);
GdkEvent * gdk_event_delete_new (GdkSurface *surface);
GdkEvent * gdk_scroll_event_new (GdkSurface *surface,
GdkEvent * gdk_event_scroll_new (GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
GdkDeviceTool *tool,
@@ -517,7 +627,7 @@ GdkEvent * gdk_scroll_event_new (GdkSurface *surface,
double delta_y,
gboolean is_stop);
GdkEvent * gdk_scroll_event_new_discrete (GdkSurface *surface,
GdkEvent * gdk_event_discrete_scroll_new (GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
GdkDeviceTool *tool,
@@ -526,7 +636,7 @@ GdkEvent * gdk_scroll_event_new_discrete (GdkSurface *surface,
GdkScrollDirection direction,
gboolean emulated);
GdkEvent * gdk_touch_event_new (GdkEventType type,
GdkEvent * gdk_event_touch_new (GdkEventType type,
GdkEventSequence *sequence,
GdkSurface *surface,
GdkDevice *device,
@@ -538,7 +648,7 @@ GdkEvent * gdk_touch_event_new (GdkEventType type,
double *axes,
gboolean emulating);
GdkEvent * gdk_touchpad_event_new_swipe (GdkSurface *surface,
GdkEvent * gdk_event_touchpad_swipe_new (GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
guint32 time,
@@ -550,7 +660,7 @@ GdkEvent * gdk_touchpad_event_new_swipe (GdkSurface *surface,
double dx,
double dy);
GdkEvent * gdk_touchpad_event_new_pinch (GdkSurface *surface,
GdkEvent * gdk_event_touchpad_pinch_new (GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
guint32 time,
@@ -564,7 +674,7 @@ GdkEvent * gdk_touchpad_event_new_pinch (GdkSurface *surface,
double scale,
double angle_delta);
GdkEvent * gdk_pad_event_new_ring (GdkSurface *surface,
GdkEvent * gdk_event_pad_ring_new (GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
guint32 time,
@@ -573,7 +683,7 @@ GdkEvent * gdk_pad_event_new_ring (GdkSurface *surface,
guint mode,
double value);
GdkEvent * gdk_pad_event_new_strip (GdkSurface *surface,
GdkEvent * gdk_event_pad_strip_new (GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
guint32 time,
@@ -582,7 +692,7 @@ GdkEvent * gdk_pad_event_new_strip (GdkSurface *surface,
guint mode,
double value);
GdkEvent * gdk_pad_event_new_button (GdkEventType type,
GdkEvent * gdk_event_pad_button_new (GdkEventType type,
GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
@@ -591,14 +701,14 @@ GdkEvent * gdk_pad_event_new_button (GdkEventType type,
guint button,
guint mode);
GdkEvent * gdk_pad_event_new_group_mode (GdkSurface *surface,
GdkEvent * gdk_event_pad_group_mode_new (GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
guint32 time,
guint group,
guint mode);
GdkEvent * gdk_dnd_event_new (GdkEventType type,
GdkEvent * gdk_event_drag_new (GdkEventType type,
GdkSurface *surface,
GdkDevice *device,
GdkDrop *drop,
@@ -606,12 +716,12 @@ GdkEvent * gdk_dnd_event_new (GdkEventType type,
double x,
double y);
GdkEvent * gdk_grab_broken_event_new (GdkSurface *surface,
GdkEvent * gdk_event_grab_broken_new (GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
GdkSurface *grab_surface,
gboolean implicit);
G_END_DECLS
#endif /* __GDK_EVENTS_PRIVATE_H__ */
-41
View File
@@ -185,11 +185,6 @@ gboolean gdk_surface_handle_event (GdkEvent *event);
GdkSeat * gdk_surface_get_seat_from_event (GdkSurface *surface,
GdkEvent *event);
void gdk_surface_enter_monitor (GdkSurface *surface,
GdkMonitor *monitor);
void gdk_surface_leave_monitor (GdkSurface *surface,
GdkMonitor *monitor);
/*****************************************
* Interfaces provided by windowing code *
*****************************************/
@@ -301,42 +296,6 @@ void gdk_surface_get_geometry (GdkSurface *surface,
GdkGLContext *gdk_surface_get_shared_data_gl_context (GdkSurface *surface);
typedef enum
{
GDK_HINT_POS = 1 << 0,
GDK_HINT_MIN_SIZE = 1 << 1,
GDK_HINT_MAX_SIZE = 1 << 2,
GDK_HINT_BASE_SIZE = 1 << 3,
GDK_HINT_ASPECT = 1 << 4,
GDK_HINT_RESIZE_INC = 1 << 5,
GDK_HINT_WIN_GRAVITY = 1 << 6,
GDK_HINT_USER_POS = 1 << 7,
GDK_HINT_USER_SIZE = 1 << 8
} GdkSurfaceHints;
struct _GdkGeometry
{
gint min_width;
gint min_height;
gint max_width;
gint max_height;
gint base_width;
gint base_height;
gint width_inc;
gint height_inc;
gdouble min_aspect;
gdouble max_aspect;
GdkGravity win_gravity;
};
GDK_AVAILABLE_IN_ALL
void gdk_surface_constrain_size (GdkGeometry *geometry,
GdkSurfaceHints flags,
gint width,
gint height,
gint *new_width,
gint *new_height);
/*
* GdkSeatGrabPrepareFunc:
* @seat: the #GdkSeat being grabbed
+67 -82
View File
@@ -76,8 +76,6 @@ enum {
SIZE_CHANGED,
RENDER,
EVENT,
ENTER_MONITOR,
LEAVE_MONITOR,
LAST_SIGNAL
};
@@ -473,9 +471,6 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
* @height: the new height
*
* Emitted when the size of @surface is changed.
*
* Surface size is reported in application pixels, not
* device pixels (see gdk_surface_get_scale_factor()).
*/
signals[SIZE_CHANGED] =
g_signal_new (g_intern_static_string ("size-changed"),
@@ -530,51 +525,13 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
0,
g_signal_accumulator_true_handled,
NULL,
_gdk_marshal_BOOLEAN__POINTER,
_gdk_marshal_BOOLEAN__BOXED,
G_TYPE_BOOLEAN,
1,
GDK_TYPE_EVENT);
g_signal_set_va_marshaller (signals[EVENT],
G_OBJECT_CLASS_TYPE (object_class),
_gdk_marshal_BOOLEAN__POINTERv);
/**
* GdkSurface::enter-montor:
* @surface: the #GdkSurface
* @monitor: the monitor
*
* Emitted when @surface starts being present on the monitor.
*/
signals[ENTER_MONITOR] =
g_signal_new (g_intern_static_string ("enter-monitor"),
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
NULL,
NULL,
NULL,
G_TYPE_NONE,
1,
GDK_TYPE_MONITOR);
/**
* GdkSurface::leave-montor:
* @surface: the #GdkSurface
* @monitor: the monitor
*
* Emitted when @surface stops being present on the monitor.
*/
signals[LEAVE_MONITOR] =
g_signal_new (g_intern_static_string ("leave-monitor"),
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
NULL,
NULL,
NULL,
G_TYPE_NONE,
1,
GDK_TYPE_MONITOR);
_gdk_marshal_BOOLEAN__BOXEDv);
}
static void
@@ -1984,8 +1941,9 @@ gdk_surface_get_geometry (GdkSurface *surface,
*
* Returns the width of the given @surface.
*
* Surface size is reported in application pixels, not
* device pixels (see gdk_surface_get_scale_factor()).
* On the X11 platform the returned size is the size reported in the
* most-recently-processed configure event, rather than the current
* size on the X server.
*
* Returns: The width of @surface
*/
@@ -2003,8 +1961,9 @@ gdk_surface_get_width (GdkSurface *surface)
*
* Returns the height of the given @surface.
*
* Surface size is reported in application pixels, not
* device pixels (see gdk_surface_get_scale_factor()).
* On the X11 platform the returned size is the size reported in the
* most-recently-processed configure event, rather than the current
* size on the X server.
*
* Returns: The height of @surface
*/
@@ -2783,18 +2742,6 @@ gdk_synthesize_surface_state (GdkSurface *surface,
gdk_surface_set_state (surface, (surface->state | set_flags) & ~unset_flags);
}
static void
hide_popup_chain (GdkSurface *surface)
{
GdkSurface *parent;
gdk_surface_hide (surface);
parent = surface->parent;
if (parent->autohide)
hide_popup_chain (parent);
}
static gboolean
check_autohide (GdkEvent *event)
{
@@ -2824,7 +2771,7 @@ check_autohide (GdkEvent *event)
if (grab_surface != gdk_event_get_surface (event) &&
grab_surface->autohide)
{
hide_popup_chain (grab_surface);
gdk_surface_hide (grab_surface);
return TRUE;
}
}
@@ -2835,6 +2782,53 @@ check_autohide (GdkEvent *event)
return FALSE;
}
static gboolean
is_keyboard_event (GdkEvent *event)
{
switch ((guint) gdk_event_get_event_type (event))
{
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
case GDK_FOCUS_CHANGE:
return TRUE;
default:;
}
return FALSE;
}
static GdkEvent *
rewrite_event_for_toplevel (GdkEvent *event)
{
GdkSurface *surface;
surface = gdk_event_get_surface (event);
if (!surface->parent)
return gdk_event_ref (event);
while (surface->parent)
surface = surface->parent;
if (gdk_event_get_event_type (event) == GDK_FOCUS_CHANGE)
return gdk_event_focus_new (surface,
gdk_event_get_device (event),
gdk_event_get_source_device (event),
gdk_focus_event_get_in (event));
else
{
return gdk_event_key_new (gdk_event_get_event_type (event),
surface,
gdk_event_get_device (event),
gdk_event_get_source_device (event),
gdk_event_get_time (event),
gdk_key_event_get_keycode (event),
gdk_event_get_modifier_state (event),
gdk_key_event_is_modifier (event),
&event->key.translated[0],
&event->key.translated[1]);
}
}
static void
add_event_mark (GdkEvent *event,
gint64 time,
@@ -2852,7 +2846,7 @@ add_event_mark (GdkEvent *event,
g_type_class_unref (class);
kind = value ? value->value_nick : "event";
switch ((int) event_type)
switch (event_type)
{
case GDK_MOTION_NOTIFY:
{
@@ -2944,16 +2938,21 @@ gdk_surface_handle_event (GdkEvent *event)
if (gdk_event_get_event_type (event) == GDK_CONFIGURE)
{
int width, height;
gdk_configure_event_get_size (event, &width, &height);
g_signal_emit (gdk_event_get_surface (event), signals[SIZE_CHANGED], 0,
width, height);
event->configure.width, event->configure.height);
handled = TRUE;
}
else
{
g_signal_emit (gdk_event_get_surface (event), signals[EVENT], 0, event, &handled);
GdkEvent *emitted;
if (is_keyboard_event (event))
emitted = rewrite_event_for_toplevel (event);
else
emitted = gdk_event_ref (event);
g_signal_emit (gdk_event_get_surface (emitted), signals[EVENT], 0, emitted, &handled);
gdk_event_unref (emitted);
}
if (GDK_PROFILER_IS_RUNNING)
@@ -3036,17 +3035,3 @@ gdk_surface_get_seat_from_event (GdkSurface *surface,
}
return gdk_display_get_default_seat (surface->display);
}
void
gdk_surface_enter_monitor (GdkSurface *surface,
GdkMonitor *monitor)
{
g_signal_emit (surface, signals[ENTER_MONITOR], 0, monitor);
}
void
gdk_surface_leave_monitor (GdkSurface *surface,
GdkMonitor *monitor)
{
g_signal_emit (surface, signals[LEAVE_MONITOR], 0, monitor);
}
+137
View File
@@ -38,6 +38,44 @@
G_BEGIN_DECLS
/* Size restriction enumeration.
*/
/**
* GdkSurfaceHints:
* @GDK_HINT_POS: indicates that the program has positioned the surface
* @GDK_HINT_MIN_SIZE: min size fields are set
* @GDK_HINT_MAX_SIZE: max size fields are set
* @GDK_HINT_BASE_SIZE: base size fields are set
* @GDK_HINT_ASPECT: aspect ratio fields are set
* @GDK_HINT_RESIZE_INC: resize increment fields are set
* @GDK_HINT_WIN_GRAVITY: surface gravity field is set
* @GDK_HINT_USER_POS: indicates that the surfaces position was explicitly set
* by the user
* @GDK_HINT_USER_SIZE: indicates that the surfaces size was explicitly set by
* the user
*
* Used to indicate which fields of a #GdkGeometry struct should be paid
* attention to. Also, the presence/absence of @GDK_HINT_POS,
* @GDK_HINT_USER_POS, and @GDK_HINT_USER_SIZE is significant, though they don't
* directly refer to #GdkGeometry fields. @GDK_HINT_USER_POS will be set
* automatically by #GtkWindow if you call gtk_window_move().
* @GDK_HINT_USER_POS and @GDK_HINT_USER_SIZE should be set if the user
* specified a size/position using a --geometry command-line argument;
* gtk_window_parse_geometry() automatically sets these flags.
*/
typedef enum
{
GDK_HINT_POS = 1 << 0,
GDK_HINT_MIN_SIZE = 1 << 1,
GDK_HINT_MAX_SIZE = 1 << 2,
GDK_HINT_BASE_SIZE = 1 << 3,
GDK_HINT_ASPECT = 1 << 4,
GDK_HINT_RESIZE_INC = 1 << 5,
GDK_HINT_WIN_GRAVITY = 1 << 6,
GDK_HINT_USER_POS = 1 << 7,
GDK_HINT_USER_SIZE = 1 << 8
} GdkSurfaceHints;
/**
* GdkSurfaceEdge:
* @GDK_SURFACE_EDGE_NORTH_WEST: the top left corner.
@@ -77,6 +115,97 @@ typedef enum
GDK_FULLSCREEN_ON_ALL_MONITORS
} GdkFullscreenMode;
/**
* GdkGeometry:
* @min_width: minimum width of surface (or -1 to use requisition, with
* #GtkWindow only)
* @min_height: minimum height of surface (or -1 to use requisition, with
* #GtkWindow only)
* @max_width: maximum width of surface (or -1 to use requisition, with
* #GtkWindow only)
* @max_height: maximum height of surface (or -1 to use requisition, with
* #GtkWindow only)
* @base_width: allowed surface widths are @base_width + @width_inc * N where N
* is any integer (-1 allowed with #GtkWindow)
* @base_height: allowed surface widths are @base_height + @height_inc * N where
* N is any integer (-1 allowed with #GtkWindow)
* @width_inc: width resize increment
* @height_inc: height resize increment
* @min_aspect: minimum width/height ratio
* @max_aspect: maximum width/height ratio
* @win_gravity: surface gravity, see gtk_window_set_gravity()
*
* The #GdkGeometry struct gives the window manager information about
* a surfaces geometry constraints. Normally you would set these on
* the GTK+ level using gtk_window_set_geometry_hints(). #GtkWindow
* then sets the hints on the #GdkSurface it creates.
*
* gdk_surface_set_geometry_hints() expects the hints to be fully valid already
* and simply passes them to the window manager; in contrast,
* gtk_window_set_geometry_hints() performs some interpretation. For example,
* #GtkWindow will apply the hints to the geometry widget instead of the
* toplevel window, if you set a geometry widget. Also, the
* @min_width/@min_height/@max_width/@max_height fields may be set to -1, and
* #GtkWindow will substitute the size request of the surface or geometry widget.
* If the minimum size hint is not provided, #GtkWindow will use its requisition
* as the minimum size. If the minimum size is provided and a geometry widget is
* set, #GtkWindow will take the minimum size as the minimum size of the
* geometry widget rather than the entire surface. The base size is treated
* similarly.
*
* The canonical use-case for gtk_window_set_geometry_hints() is to get a
* terminal widget to resize properly. Here, the terminal text area should be
* the geometry widget; #GtkWindow will then automatically set the base size to
* the size of other widgets in the terminal window, such as the menubar and
* scrollbar. Then, the @width_inc and @height_inc fields should be set to the
* size of one character in the terminal. Finally, the base size should be set
* to the size of one character. The net effect is that the minimum size of the
* terminal will have a 1x1 character terminal area, and only terminal sizes on
* the character grid will be allowed.
*
* Heres an example of how the terminal example would be implemented, assuming
* a terminal area widget called terminal and a toplevel window toplevel:
*
* |[<!-- language="C" -->
* GdkGeometry hints;
*
* hints.base_width = terminal->char_width;
* hints.base_height = terminal->char_height;
* hints.min_width = terminal->char_width;
* hints.min_height = terminal->char_height;
* hints.width_inc = terminal->char_width;
* hints.height_inc = terminal->char_height;
*
* gtk_window_set_geometry_hints (GTK_WINDOW (toplevel),
* GTK_WIDGET (terminal),
* &hints,
* GDK_HINT_RESIZE_INC |
* GDK_HINT_MIN_SIZE |
* GDK_HINT_BASE_SIZE);
* ]|
*
* The other useful fields are the @min_aspect and @max_aspect fields; these
* contain a width/height ratio as a floating point number. If a geometry widget
* is set, the aspect applies to the geometry widget rather than the entire
* window. The most common use of these hints is probably to set @min_aspect and
* @max_aspect to the same value, thus forcing the window to keep a constant
* aspect ratio.
*/
struct _GdkGeometry
{
gint min_width;
gint min_height;
gint max_width;
gint max_height;
gint base_width;
gint base_height;
gint width_inc;
gint height_inc;
gdouble min_aspect;
gdouble max_aspect;
GdkGravity win_gravity;
};
/**
* GdkSurfaceState:
* @GDK_SURFACE_STATE_WITHDRAWN: the surface is not shown
@@ -233,6 +362,14 @@ void gdk_surface_freeze_updates (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_thaw_updates (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_constrain_size (GdkGeometry *geometry,
GdkSurfaceHints flags,
gint width,
gint height,
gint *new_width,
gint *new_height);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_support_multidevice (GdkSurface *surface,
gboolean support_multidevice);
-3
View File
@@ -61,9 +61,6 @@ G_DEFINE_BOXED_TYPE (GdkToplevelLayout, gdk_toplevel_layout,
* Used together with gdk_toplevel_present() to describe
* how a toplevel surface should be placed and behave on-screen.
*
* The size is in application pixels, not
* device pixels (see gdk_surface_get_scale_factor()).
*
* Returns: (transfer full): newly created instance of #GdkToplevelLayout
*/
GdkToplevelLayout *
+29 -29
View File
@@ -589,7 +589,7 @@ emulate_crossing (GdkSurface *surface,
double x, y;
gdk_surface_get_device_position (surface, device, &x, &y, &state);
event = gdk_crossing_event_new (type,
event = gdk_event_crossing_new (type,
surface,
device,
device,
@@ -614,7 +614,7 @@ emulate_touch_crossing (GdkSurface *surface,
{
GdkEvent *event;
event = gdk_crossing_event_new (type,
event = gdk_event_crossing_new (type,
surface,
device,
source,
@@ -633,7 +633,7 @@ emulate_focus (GdkSurface *surface,
gboolean focus_in,
guint32 time_)
{
GdkEvent *event = gdk_focus_event_new (surface, device, device, focus_in);
GdkEvent *event = gdk_event_focus_new (surface, device, device, focus_in);
_gdk_wayland_display_deliver_event (gdk_surface_get_display (surface), event);
}
@@ -1360,7 +1360,7 @@ flush_discrete_scroll_event (GdkWaylandSeat *seat,
GdkDevice *source;
source = get_scroll_device (seat, seat->pointer_info.frame.source);
event = gdk_scroll_event_new_discrete (seat->pointer_info.focus,
event = gdk_event_discrete_scroll_new (seat->pointer_info.focus,
seat->master_pointer,
source,
NULL,
@@ -1382,7 +1382,7 @@ flush_smooth_scroll_event (GdkWaylandSeat *seat,
GdkDevice *source;
source = get_scroll_device (seat, seat->pointer_info.frame.source);
event = gdk_scroll_event_new (seat->pointer_info.focus,
event = gdk_event_scroll_new (seat->pointer_info.focus,
seat->master_pointer,
source,
NULL,
@@ -1498,7 +1498,7 @@ pointer_handle_enter (void *data,
seat->pointer_info.surface_y = wl_fixed_to_double (sy);
seat->pointer_info.enter_serial = serial;
event = gdk_crossing_event_new (GDK_ENTER_NOTIFY,
event = gdk_event_crossing_new (GDK_ENTER_NOTIFY,
seat->pointer_info.focus,
seat->master_pointer,
seat->pointer,
@@ -1541,7 +1541,7 @@ pointer_handle_leave (void *data,
_gdk_wayland_display_update_serial (display_wayland, serial);
event = gdk_crossing_event_new (GDK_LEAVE_NOTIFY,
event = gdk_event_crossing_new (GDK_LEAVE_NOTIFY,
seat->pointer_info.focus,
seat->master_pointer,
seat->pointer,
@@ -1586,7 +1586,7 @@ pointer_handle_motion (void *data,
seat->pointer_info.surface_x = wl_fixed_to_double (sx);
seat->pointer_info.surface_y = wl_fixed_to_double (sy);
event = gdk_motion_event_new (seat->pointer_info.focus,
event = gdk_event_motion_new (seat->pointer_info.focus,
seat->master_pointer,
seat->pointer,
NULL,
@@ -1649,7 +1649,7 @@ pointer_handle_button (void *data,
if (state)
seat->pointer_info.press_serial = serial;
event = gdk_button_event_new (state ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE,
event = gdk_event_button_new (state ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE,
seat->pointer_info.focus,
seat->master_pointer,
seat->pointer,
@@ -1914,7 +1914,7 @@ keyboard_handle_enter (void *data,
g_object_ref (seat->keyboard_focus);
seat->repeat_key = 0;
event = gdk_focus_event_new (seat->keyboard_focus,
event = gdk_event_focus_new (seat->keyboard_focus,
seat->master_keyboard,
seat->keyboard,
TRUE);
@@ -1949,7 +1949,7 @@ keyboard_handle_leave (void *data,
_gdk_wayland_display_update_serial (display, serial);
event = gdk_focus_event_new (seat->keyboard_focus,
event = gdk_event_focus_new (seat->keyboard_focus,
seat->master_keyboard,
seat->keyboard,
FALSE);
@@ -2075,7 +2075,7 @@ deliver_key_event (GdkWaylandSeat *seat,
no_lock = translated;
}
event = gdk_key_event_new (state ? GDK_KEY_PRESS : GDK_KEY_RELEASE,
event = gdk_event_key_new (state ? GDK_KEY_PRESS : GDK_KEY_RELEASE,
seat->keyboard_focus,
seat->master_keyboard,
seat->keyboard,
@@ -2375,7 +2375,7 @@ touch_handle_down (void *data,
touch->y = wl_fixed_to_double (y);
touch->touch_down_serial = serial;
event = gdk_touch_event_new (GDK_TOUCH_BEGIN,
event = gdk_event_touch_new (GDK_TOUCH_BEGIN,
GDK_SLOT_TO_EVENT_SEQUENCE (touch->id),
touch->surface,
seat->touch_master,
@@ -2418,7 +2418,7 @@ touch_handle_up (void *data,
_gdk_wayland_display_update_serial (display, serial);
touch = gdk_wayland_seat_get_touch (seat, id);
event = gdk_touch_event_new (GDK_TOUCH_END,
event = gdk_event_touch_new (GDK_TOUCH_END,
GDK_SLOT_TO_EVENT_SEQUENCE (touch->id),
touch->surface,
seat->touch_master,
@@ -2463,7 +2463,7 @@ touch_handle_motion (void *data,
if (touch->initial_touch)
mimic_pointer_emulating_touch_info (seat->touch_master, touch);
event = gdk_touch_event_new (GDK_TOUCH_UPDATE,
event = gdk_event_touch_new (GDK_TOUCH_UPDATE,
GDK_SLOT_TO_EVENT_SEQUENCE (touch->id),
touch->surface,
seat->touch_master,
@@ -2509,7 +2509,7 @@ touch_handle_cancel (void *data,
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &touch))
{
event = gdk_touch_event_new (GDK_TOUCH_CANCEL,
event = gdk_event_touch_new (GDK_TOUCH_CANCEL,
GDK_SLOT_TO_EVENT_SEQUENCE (touch->id),
touch->surface,
seat->touch_master,
@@ -2541,7 +2541,7 @@ emit_gesture_swipe_event (GdkWaylandSeat *seat,
seat->pointer_info.time = _time;
event = gdk_touchpad_event_new_swipe (seat->pointer_info.focus,
event = gdk_event_touchpad_swipe_new (seat->pointer_info.focus,
seat->master_pointer,
seat->pointer,
_time,
@@ -2638,7 +2638,7 @@ emit_gesture_pinch_event (GdkWaylandSeat *seat,
seat->pointer_info.time = _time;
event = gdk_touchpad_event_new_pinch (seat->pointer_info.focus,
event = gdk_event_touchpad_pinch_new (seat->pointer_info.focus,
seat->master_pointer,
seat->pointer,
_time,
@@ -3469,7 +3469,7 @@ tablet_tool_handle_proximity_in (void *data,
gdk_wayland_device_tablet_clone_tool_axes (tablet, tool->tool);
gdk_wayland_mimic_device_axes (tablet->master, tablet->current_device);
event = gdk_proximity_event_new (GDK_PROXIMITY_IN,
event = gdk_event_proximity_new (GDK_PROXIMITY_IN,
tablet->pointer_info.focus,
tablet->master,
tablet->current_device,
@@ -3500,7 +3500,7 @@ tablet_tool_handle_proximity_out (void *data,
g_message ("proximity out, seat %p, tool %d", tool->seat,
gdk_device_tool_get_tool_type (tool->tool)));
event = gdk_proximity_event_new (GDK_PROXIMITY_OUT,
event = gdk_event_proximity_new (GDK_PROXIMITY_OUT,
tablet->pointer_info.focus,
tablet->master,
tablet->current_device,
@@ -3537,7 +3537,7 @@ tablet_create_button_event_frame (GdkWaylandTabletData *tablet,
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
GdkEvent *event;
event = gdk_button_event_new (evtype,
event = gdk_event_button_new (evtype,
tablet->pointer_info.focus,
tablet->master,
tablet->current_device,
@@ -3603,7 +3603,7 @@ tablet_tool_handle_motion (void *data,
tablet->pointer_info.surface_x,
tablet->pointer_info.surface_y));
event = gdk_motion_event_new (tablet->pointer_info.focus,
event = gdk_event_motion_new (tablet->pointer_info.focus,
tablet->master,
tablet->current_device,
tool->tool,
@@ -3765,7 +3765,7 @@ tablet_tool_handle_wheel (void *data,
return;
/* Send smooth event */
event = gdk_scroll_event_new (tablet->pointer_info.focus,
event = gdk_event_scroll_new (tablet->pointer_info.focus,
tablet->master,
tablet->current_device,
tablet->current_tool->tool,
@@ -3777,7 +3777,7 @@ tablet_tool_handle_wheel (void *data,
_gdk_wayland_display_deliver_event (seat->display, event);
/* Send discrete event */
event = gdk_scroll_event_new_discrete (tablet->pointer_info.focus,
event = gdk_event_discrete_scroll_new (tablet->pointer_info.focus,
tablet->master,
tablet->current_device,
tablet->current_tool->tool,
@@ -3888,7 +3888,7 @@ tablet_pad_ring_handle_frame (void *data,
GDK_SEAT_NOTE (seat, EVENTS,
g_message ("tablet pad ring handle frame, ring = %p", wp_tablet_pad_ring));
event = gdk_pad_event_new_ring (seat->keyboard_focus,
event = gdk_event_pad_ring_new (seat->keyboard_focus,
pad->device,
pad->device,
time,
@@ -3963,7 +3963,7 @@ tablet_pad_strip_handle_frame (void *data,
g_message ("tablet pad strip handle frame, strip = %p",
wp_tablet_pad_strip));
event = gdk_pad_event_new_strip (seat->keyboard_focus,
event = gdk_event_pad_strip_new (seat->keyboard_focus,
pad->device,
pad->device,
time,
@@ -4089,7 +4089,7 @@ tablet_pad_group_handle_mode (void *data,
group->current_mode = mode;
n_group = g_list_index (pad->mode_groups, group);
event = gdk_pad_event_new_group_mode (seat->keyboard_focus,
event = gdk_event_pad_group_mode_new (seat->keyboard_focus,
pad->device,
pad->device,
time,
@@ -4201,7 +4201,7 @@ tablet_pad_handle_button (void *data,
g_assert (group != NULL);
n_group = g_list_index (pad->mode_groups, group);
event = gdk_pad_event_new_button (state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED
event = gdk_event_pad_button_new (state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED
? GDK_PAD_BUTTON_PRESS
: GDK_PAD_BUTTON_RELEASE,
GDK_WAYLAND_SEAT (pad->seat)->keyboard_focus,
@@ -5031,7 +5031,7 @@ gdk_wayland_device_unset_touch_grab (GdkDevice *gdk_device,
GDK_CURRENT_TIME);
}
event = gdk_touch_event_new (GDK_TOUCH_CANCEL,
event = gdk_event_touch_new (GDK_TOUCH_CANCEL,
GDK_SLOT_TO_EVENT_SEQUENCE (touch->id),
touch->surface,
seat->touch_master,
-7
View File
@@ -2539,13 +2539,6 @@ get_monitor_for_output (GdkWaylandDisplay *display_wayland,
return NULL;
}
GdkMonitor *
gdk_wayland_display_get_monitor_for_output (GdkDisplay *display,
struct wl_output *output)
{
return (GdkMonitor *)get_monitor_for_output (GDK_WAYLAND_DISPLAY (display), output);
}
static void
gdk_wayland_display_remove_output (GdkWaylandDisplay *display_wayland,
guint32 id)
-2
View File
@@ -163,8 +163,6 @@ guint32 gdk_wayland_display_get_output_scale (GdkWaylandDisplay *display_wayland
struct wl_output *output);
struct wl_output *gdk_wayland_display_get_wl_output (GdkDisplay *display,
int monitor_num);
GdkMonitor *gdk_wayland_display_get_monitor_for_output (GdkDisplay *display,
struct wl_output *output);
void _gdk_wayland_surface_set_grab_seat (GdkSurface *surface,
GdkSeat *seat);
+14 -29
View File
@@ -891,7 +891,7 @@ gdk_wayland_surface_resize (GdkSurface *surface,
GdkDisplay *display;
GdkEvent *event;
event = gdk_configure_event_new (surface, width, height);
event = gdk_event_configure_new (surface, width, height);
gdk_wayland_surface_update_size (surface, width, height, scale);
_gdk_surface_update_size (surface);
@@ -1201,8 +1201,6 @@ surface_enter (void *data,
{
GdkSurface *surface = GDK_SURFACE (data);
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
GdkDisplay *display = gdk_surface_get_display (surface);
GdkMonitor *monitor;
GDK_DISPLAY_NOTE (gdk_surface_get_display (surface), EVENTS,
g_message ("surface enter, surface %p output %p", surface, output));
@@ -1210,9 +1208,6 @@ surface_enter (void *data,
impl->display_server.outputs = g_slist_prepend (impl->display_server.outputs, output);
gdk_wayland_surface_update_scale (surface);
monitor = gdk_wayland_display_get_monitor_for_output (display, output);
gdk_surface_enter_monitor (surface, monitor);
}
static void
@@ -1222,8 +1217,6 @@ surface_leave (void *data,
{
GdkSurface *surface = GDK_SURFACE (data);
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
GdkDisplay *display = gdk_surface_get_display (surface);
GdkMonitor *monitor;
GDK_DISPLAY_NOTE (gdk_surface_get_display (surface), EVENTS,
g_message ("surface leave, surface %p output %p", surface, output));
@@ -1232,9 +1225,6 @@ surface_leave (void *data,
if (impl->display_server.outputs)
gdk_wayland_surface_update_scale (surface);
monitor = gdk_wayland_display_get_monitor_for_output (display, output);
gdk_surface_leave_monitor (surface, monitor);
}
static const struct wl_surface_listener surface_listener = {
@@ -1461,7 +1451,7 @@ gdk_wayland_surface_handle_close (GdkSurface *surface)
GDK_DISPLAY_NOTE (display, EVENTS, g_message ("close %p", surface));
event = gdk_delete_event_new (surface);
event = gdk_event_delete_new (surface);
_gdk_wayland_display_deliver_event (display, event);
}
@@ -2334,7 +2324,7 @@ can_map_grabbing_popup (GdkSurface *surface,
return top_most_popup == parent;
}
static gboolean
static void
gdk_wayland_surface_create_xdg_popup (GdkSurface *surface,
GdkSurface *parent,
GdkWaylandSeat *grab_input_seat,
@@ -2348,27 +2338,27 @@ gdk_wayland_surface_create_xdg_popup (GdkSurface *surface,
gpointer positioner;
if (!impl->display_server.wl_surface)
return FALSE;
return;
if (!is_realized_shell_surface (parent))
return FALSE;
return;
if (is_realized_toplevel (surface))
{
g_warning ("Can't map popup, already mapped as toplevel");
return FALSE;
return;
}
if (is_realized_popup (surface))
{
g_warning ("Can't map popup, already mapped");
return FALSE;
return;
}
if (grab_input_seat &&
!can_map_grabbing_popup (surface, parent))
{
g_warning ("Tried to map a grabbing popup with a non-top most parent");
return FALSE;
return;
}
gdk_surface_freeze_updates (surface);
@@ -2453,8 +2443,6 @@ gdk_wayland_surface_create_xdg_popup (GdkSurface *surface,
display->current_grabbing_popups =
g_list_prepend (display->current_grabbing_popups, surface);
}
return TRUE;
}
static GdkWaylandSeat *
@@ -2829,13 +2817,11 @@ gdk_wayland_surface_map_popup (GdkSurface *surface,
grab_input_seat = find_grab_input_seat (surface, parent);
else
grab_input_seat = NULL;
if (!gdk_wayland_surface_create_xdg_popup (surface,
parent,
grab_input_seat,
width, height,
layout))
return;
gdk_wayland_surface_create_xdg_popup (surface,
parent,
grab_input_seat,
width, height,
layout);
impl->popup.layout = gdk_popup_layout_copy (layout);
impl->popup.unconstrained_width = width;
@@ -3821,8 +3807,7 @@ gdk_wayland_surface_show_window_menu (GdkSurface *surface,
double x, y;
uint32_t serial;
GdkEventType event_type = gdk_event_get_event_type (event);
switch ((guint) event_type)
switch ((guint) event->any.type)
{
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
+6 -8
View File
@@ -1063,7 +1063,7 @@ gdk_input_other_event (GdkDisplay *display,
| GDK_BUTTON3_MASK | GDK_BUTTON4_MASK
| GDK_BUTTON5_MASK));
event = gdk_button_event_new (event_type,
event = gdk_event_button_new (event_type,
window,
device_manager->core_pointer,
GDK_DEVICE (source_device),
@@ -1077,11 +1077,10 @@ gdk_input_other_event (GdkDisplay *display,
GDK_NOTE (EVENTS_OR_INPUT,
g_print ("WINTAB button %s:%d %g,%g\n",
(event->event_type == GDK_BUTTON_PRESS ?
(event->any.type == GDK_BUTTON_PRESS ?
"press" : "release"),
((GdkButtonEvent *) event)->button,
((GdkButtonEvent *) event)->x,
((GdkButtonEvent *) event)->y));
event->button.button,
event->button.x, event->button.y));
}
else
{
@@ -1098,7 +1097,7 @@ gdk_input_other_event (GdkDisplay *display,
| GDK_BUTTON3_MASK | GDK_BUTTON4_MASK
| GDK_BUTTON5_MASK));
event = gdk_motion_event_new (window,
event = gdk_event_motion_new (window,
device_manager->core_pointer,
GDK_DEVICE (source_device),
NULL,
@@ -1109,8 +1108,7 @@ gdk_input_other_event (GdkDisplay *display,
axes);
GDK_NOTE (EVENTS_OR_INPUT,
g_print ("WINTAB motion: %g,%g\n",
((GdkMotionEvent *) event)->x,
((GdkMotionEvent *) event)->y));
event->motion.x, event->motion.y));
}
return event;
+1 -2
View File
@@ -2515,8 +2515,7 @@ gdk_win32_drag_handle_event (GdkDrag *drag,
if (!drag_win32->handle_events)
{
/* FIXME: remove this functionality once gtk no longer calls DnD after drag_done() */
g_warning ("Got an event %d for drag context %p, even though it's done!",
event->event_type, drag);
g_warning ("Got an event %d for drag context %p, even though it's done!", event->any.type, drag);
return FALSE;
}
+19 -15
View File
@@ -207,7 +207,7 @@ generate_focus_event (GdkDeviceManagerWin32 *device_manager,
device = GDK_DEVICE_MANAGER_WIN32 (device_manager)->core_keyboard;
source_device = GDK_DEVICE_MANAGER_WIN32 (device_manager)->system_keyboard;
event = gdk_focus_event_new (window, device, source_device, in);
event = gdk_event_focus_new (window, device, source_device, in);
_gdk_win32_append_event (event);
}
@@ -233,7 +233,7 @@ generate_grab_broken_event (GdkDeviceManagerWin32 *device_manager,
source_device = device_manager->system_pointer;
}
event = gdk_grab_broken_event_new (window,
event = gdk_event_grab_broken_new (window,
device,
source_device,
grab_window,
@@ -885,8 +885,12 @@ decode_key_lparam (LPARAM lParam)
static void
fixup_event (GdkEvent *event)
{
if (event->surface)
g_object_ref (event->surface);
if (event->any.surface)
g_object_ref (event->any.surface);
if (((event->any.type == GDK_ENTER_NOTIFY) ||
(event->any.type == GDK_LEAVE_NOTIFY)) &&
(event->crossing.child_surface != NULL))
g_object_ref (event->crossing.child_surface);
}
void
@@ -1076,7 +1080,7 @@ send_crossing_event (GdkDisplay *display,
pt = *screen_pt;
ScreenToClient (GDK_SURFACE_HWND (window), &pt);
event = gdk_crossing_event_new (type,
event = gdk_event_crossing_new (type,
window,
device_manager->core_pointer,
device_manager->system_pointer,
@@ -1585,7 +1589,7 @@ generate_button_event (GdkEventType type,
current_x = (gint16) GET_X_LPARAM (msg->lParam) / impl->surface_scale;
current_y = (gint16) GET_Y_LPARAM (msg->lParam) / impl->surface_scale;
event = gdk_button_event_new (type,
event = gdk_event_button_new (type,
window,
device_manager->core_pointer,
device_manager->system_pointer,
@@ -2129,7 +2133,7 @@ gdk_event_translate (MSG *msg,
translated.consumed = 0;
translated.layout = 0;
translated.level = 0;
event = gdk_key_event_new (GDK_KEY_PRESS,
event = gdk_event_key_new (GDK_KEY_PRESS,
window,
device_manager_win32->core_keyboard,
device_manager_win32->system_keyboard,
@@ -2332,7 +2336,7 @@ gdk_event_translate (MSG *msg,
translated.consumed = 0;
translated.layout = group;
translated.level = 0;
event = gdk_key_event_new ((msg->message == WM_KEYDOWN || msg->message == WM_SYSKEYDOWN)
event = gdk_event_key_new ((msg->message == WM_KEYDOWN || msg->message == WM_SYSKEYDOWN)
? GDK_KEY_PRESS
: GDK_KEY_RELEASE,
window,
@@ -2409,7 +2413,7 @@ gdk_event_translate (MSG *msg,
translated.consumed = 0;
translated.layout = get_active_group ();
translated.level = 0;
event = gdk_key_event_new (GDK_KEY_PRESS,
event = gdk_event_key_new (GDK_KEY_PRESS,
window,
device_manager_win32->core_keyboard,
device_manager_win32->system_keyboard,
@@ -2423,7 +2427,7 @@ gdk_event_translate (MSG *msg,
_gdk_win32_append_event (event);
/* Build a key release event. */
event = gdk_key_event_new (GDK_KEY_RELEASE,
event = gdk_event_key_new (GDK_KEY_RELEASE,
window,
device_manager_win32->core_keyboard,
device_manager_win32->system_keyboard,
@@ -2637,7 +2641,7 @@ gdk_event_translate (MSG *msg,
current_x = (gint16) GET_X_LPARAM (msg->lParam) / impl->surface_scale;
current_y = (gint16) GET_Y_LPARAM (msg->lParam) / impl->surface_scale;
event = gdk_motion_event_new (window,
event = gdk_event_motion_new (window,
device_manager_win32->core_pointer,
device_manager_win32->system_pointer,
NULL,
@@ -2763,7 +2767,7 @@ gdk_event_translate (MSG *msg,
*/
delta_y *= -1.0;
event = gdk_scroll_event_new (window,
event = gdk_event_scroll_new (window,
device_manager_win32->core_pointer,
device_manager_win32->system_pointer,
NULL,
@@ -2786,7 +2790,7 @@ gdk_event_translate (MSG *msg,
? GDK_SCROLL_RIGHT
: GDK_SCROLL_LEFT;
event = gdk_scroll_event_new_discrete (window,
event = gdk_event_discrete_scroll_new (window,
device_manager_win32->core_pointer,
device_manager_win32->system_pointer,
NULL,
@@ -3421,7 +3425,7 @@ gdk_event_translate (MSG *msg,
if (GDK_SURFACE_DESTROYED (window))
break;
event = gdk_delete_event_new (window);
event = gdk_event_delete_new (window);
_gdk_win32_append_event (event);
@@ -3455,7 +3459,7 @@ gdk_event_translate (MSG *msg,
if (window == NULL || GDK_SURFACE_DESTROYED (window))
break;
event = gdk_delete_event_new (window);
event = gdk_event_delete_new (window);
_gdk_win32_append_event (event);
+1 -1
View File
@@ -4462,7 +4462,7 @@ gdk_win32_surface_show_window_menu (GdkSurface *window,
gint x, y;
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
switch ((int) event->event_type)
switch (event->any.type)
{
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
-1
View File
@@ -30,7 +30,6 @@
#include "gdk/win32/gdkwin32surface.h"
#include "gdk/gdksurfaceprivate.h"
#include "gdk/gdkcursor.h"
#include "gdk/gdkinternals.h"
#include <windows.h>
+9 -9
View File
@@ -1448,7 +1448,7 @@ _gdk_device_manager_xi2_handle_focus (GdkSurface *surface,
{
GdkEvent *event;
event = gdk_focus_event_new (surface, device, source_device, focus_in);
event = gdk_event_focus_new (surface, device, source_device, focus_in);
gdk_display_put_event (gdk_surface_get_display (surface), event);
gdk_event_unref (event);
}
@@ -1584,7 +1584,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
{
no_lock = translated;
}
event = gdk_key_event_new (xev->evtype == XI_KeyPress
event = gdk_event_key_new (xev->evtype == XI_KeyPress
? GDK_KEY_PRESS
: GDK_KEY_RELEASE,
surface,
@@ -1654,7 +1654,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
source_device = g_hash_table_lookup (device_manager->id_table,
GUINT_TO_POINTER (xev->sourceid));
event = gdk_scroll_event_new_discrete (surface,
event = gdk_event_discrete_scroll_new (surface,
device,
source_device,
NULL,
@@ -1684,7 +1684,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
x = (double) xev->event_x / scale;
y = (double) xev->event_y / scale;
event = gdk_button_event_new (ev->evtype == XI_ButtonPress
event = gdk_event_button_new (ev->evtype == XI_ButtonPress
? GDK_BUTTON_PRESS
: GDK_BUTTON_RELEASE,
surface,
@@ -1739,7 +1739,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
xev->deviceid, xev->sourceid,
xev->event, delta_x, delta_y));
event = gdk_scroll_event_new (surface,
event = gdk_event_scroll_new (surface,
device,
source_device,
NULL,
@@ -1760,7 +1760,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
x = (double) xev->event_x / scale;
y = (double) xev->event_y / scale;
event = gdk_motion_event_new (surface,
event = gdk_event_motion_new (surface,
device,
source_device,
source_device->last_tool,
@@ -1808,7 +1808,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
x = (double) xev->event_x / scale;
y = (double) xev->event_y / scale;
event = gdk_touch_event_new (ev->evtype == XI_TouchBegin
event = gdk_event_touch_new (ev->evtype == XI_TouchBegin
? GDK_TOUCH_BEGIN
: GDK_TOUCH_END,
GUINT_TO_POINTER (xev->detail),
@@ -1858,7 +1858,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
x = (double) xev->event_x / scale;
y = (double) xev->event_y / scale;
event = gdk_touch_event_new (GDK_TOUCH_UPDATE,
event = gdk_event_touch_new (GDK_TOUCH_UPDATE,
GUINT_TO_POINTER (xev->detail),
surface,
device,
@@ -1911,7 +1911,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
}
}
event = gdk_crossing_event_new (ev->evtype == XI_Enter
event = gdk_event_crossing_new (ev->evtype == XI_Enter
? GDK_ENTER_NOTIFY
: GDK_LEAVE_NOTIFY,
surface,
+15 -15
View File
@@ -799,7 +799,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
if (!is_substructure)
{
event = gdk_delete_event_new (surface);
event = gdk_event_delete_new (surface);
if (surface && GDK_SURFACE_XID (surface) != x11_screen->xroot_window)
gdk_surface_destroy_notify (surface);
@@ -918,10 +918,10 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
xevent->xconfigure.event == xevent->xconfigure.window)
{
int x, y;
int c_w = (xevent->xconfigure.width + surface_impl->surface_scale - 1) / surface_impl->surface_scale;
int c_h = (xevent->xconfigure.height + surface_impl->surface_scale - 1) / surface_impl->surface_scale;
event = gdk_configure_event_new (surface, c_w, c_h);
event = gdk_event_configure_new (surface,
(xevent->xconfigure.width + surface_impl->surface_scale - 1) / surface_impl->surface_scale,
(xevent->xconfigure.height + surface_impl->surface_scale - 1) / surface_impl->surface_scale);
if (!xevent->xconfigure.send_event &&
!xevent->xconfigure.override_redirect &&
@@ -974,7 +974,8 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
{
surface_impl->unscaled_width = xevent->xconfigure.width;
surface_impl->unscaled_height = xevent->xconfigure.height;
gdk_configure_event_get_size (event, &surface->width, &surface->height);
surface->width = event->configure.width;
surface->height = event->configure.height;
_gdk_surface_update_size (surface);
_gdk_x11_surface_update_size (surface_impl);
@@ -989,7 +990,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
}
gdk_x11_surface_update_popups (surface);
gdk_x11_surface_enter_leave_monitors (surface);
}
}
break;
@@ -1251,19 +1251,19 @@ _gdk_wm_protocols_filter (const XEvent *xevent,
if (atom == gdk_x11_get_xatom_by_name_for_display (display, "WM_DELETE_WINDOW"))
{
/* The delete window request specifies a window
* to delete. We don't actually destroy the
* window because "it is only a request". (The
* window might contain vital data that the
* program does not want destroyed). Instead
* the event is passed along to the program,
* which should then destroy the window.
*/
/* The delete window request specifies a window
* to delete. We don't actually destroy the
* window because "it is only a request". (The
* window might contain vital data that the
* program does not want destroyed). Instead
* the event is passed along to the program,
* which should then destroy the window.
*/
GDK_DISPLAY_NOTE (display, EVENTS,
g_message ("delete window:\t\twindow: %ld",
xevent->xclient.window));
*event = gdk_delete_event_new (win);
*event = gdk_event_delete_new (win);
gdk_x11_surface_set_user_time (win, xevent->xclient.data.l[1]);
+25 -34
View File
@@ -1023,7 +1023,7 @@ send_client_message_async (GdkDrag *drag,
static void
xdnd_send_xevent (GdkX11Drag *drag_x11,
XEvent *event_send)
XEvent *event_send)
{
GdkDrag *drag = GDK_DRAG (drag_x11);
GdkDisplay *display = gdk_drag_get_display (drag);
@@ -2184,15 +2184,15 @@ gdk_drag_update (GdkDrag *drag,
}
static gboolean
gdk_dnd_handle_motion_event (GdkDrag *drag,
GdkEvent *event)
gdk_dnd_handle_motion_event (GdkDrag *drag,
GdkEvent *event)
{
double x, y;
int x_root, y_root;
gdk_event_get_position (event, &x, &y);
x_root = event->surface->x + x;
y_root = event->surface->y + y;
x_root = event->any.surface->x + x;
y_root = event->any.surface->y + y;
gdk_drag_update (drag, x_root, y_root,
gdk_event_get_modifier_state (event),
gdk_event_get_time (event));
@@ -2200,8 +2200,8 @@ gdk_dnd_handle_motion_event (GdkDrag *drag,
}
static gboolean
gdk_dnd_handle_key_event (GdkDrag *drag,
GdkEvent *event)
gdk_dnd_handle_key_event (GdkDrag *drag,
GdkEventKey *event)
{
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
GdkModifierType state;
@@ -2209,14 +2209,12 @@ gdk_dnd_handle_key_event (GdkDrag *drag,
gint dx, dy;
dx = dy = 0;
state = gdk_event_get_modifier_state (event);
pointer = gdk_device_get_associated_device (gdk_event_get_device (event));
state = event->state;
pointer = gdk_device_get_associated_device (gdk_event_get_device ((GdkEvent *) event));
if (event->event_type == GDK_KEY_PRESS)
if (event->any.type == GDK_KEY_PRESS)
{
guint keyval = gdk_key_event_get_keyval (event);
switch (keyval)
switch (event->translated[0].keyval)
{
case GDK_KEY_Escape:
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_USER_CANCELLED);
@@ -2289,40 +2287,37 @@ gdk_dnd_handle_key_event (GdkDrag *drag,
}
gdk_drag_update (drag, x11_drag->last_x, x11_drag->last_y, state,
gdk_event_get_time (event));
gdk_event_get_time ((GdkEvent *) event));
return TRUE;
}
static gboolean
gdk_dnd_handle_grab_broken_event (GdkDrag *drag,
GdkEvent *event)
gdk_dnd_handle_grab_broken_event (GdkDrag *drag,
GdkEventGrabBroken *event)
{
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
gboolean is_implicit = gdk_grab_broken_event_get_implicit (event);
GdkSurface *grab_surface = gdk_grab_broken_event_get_grab_surface (event);
/* Don't cancel if we break the implicit grab from the initial button_press.
* Also, don't cancel if we re-grab on the widget or on our IPC window, for
* example, when changing the drag cursor.
*/
if (is_implicit ||
grab_surface == x11_drag->drag_surface ||
grab_surface == x11_drag->ipc_surface)
if (event->implicit ||
event->grab_surface == x11_drag->drag_surface ||
event->grab_surface == x11_drag->ipc_surface)
return FALSE;
if (gdk_event_get_device (event) != gdk_drag_get_device (drag))
if (gdk_event_get_device ((GdkEvent *) event) !=
gdk_drag_get_device (drag))
return FALSE;
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_ERROR);
return TRUE;
}
static gboolean
gdk_dnd_handle_button_event (GdkDrag *drag,
GdkEvent *event)
gdk_dnd_handle_button_event (GdkDrag *drag,
GdkEventButton *event)
{
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
@@ -2352,21 +2347,17 @@ gdk_x11_drag_handle_event (GdkDrag *drag,
if (!x11_drag->grab_seat)
return FALSE;
switch ((guint) event->event_type)
switch ((guint) event->any.type)
{
case GDK_MOTION_NOTIFY:
return gdk_dnd_handle_motion_event (drag, event);
case GDK_BUTTON_RELEASE:
return gdk_dnd_handle_button_event (drag, event);
return gdk_dnd_handle_button_event (drag, &event->button);
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
return gdk_dnd_handle_key_event (drag, event);
return gdk_dnd_handle_key_event (drag, &event->key);
case GDK_GRAB_BROKEN:
return gdk_dnd_handle_grab_broken_event (drag, event);
return gdk_dnd_handle_grab_broken_event (drag, &event->grab_broken);
default:
break;
}
+3 -3
View File
@@ -105,7 +105,7 @@ handle_focus_change (GdkEvent *event)
toplevel->has_pointer = focus_in;
if (!gdk_crossing_event_get_focus (event) || toplevel->has_focus_window)
if (!event->crossing.focus || toplevel->has_focus_window)
return;
had_focus = HAS_FOCUS (toplevel);
@@ -115,7 +115,7 @@ handle_focus_change (GdkEvent *event)
{
GdkEvent *focus_event;
focus_event = gdk_focus_event_new (gdk_event_get_surface (event),
focus_event = gdk_event_focus_new (gdk_event_get_surface (event),
gdk_event_get_device (event),
gdk_event_get_source_device (event),
focus_in);
@@ -135,7 +135,7 @@ create_synth_crossing_event (GdkEventType evtype,
g_assert (evtype == GDK_ENTER_NOTIFY || evtype == GDK_LEAVE_NOTIFY);
gdk_event_get_position (real_event, &x, &y);
event = gdk_crossing_event_new (evtype,
event = gdk_event_crossing_new (evtype,
gdk_event_get_surface (real_event),
gdk_event_get_device (real_event),
gdk_event_get_source_device (real_event),
-2
View File
@@ -217,8 +217,6 @@ void _gdk_x11_surface_register_dnd (GdkSurface *window);
void gdk_x11_surface_update_popups (GdkSurface *surface);
void gdk_x11_surface_enter_leave_monitors (GdkSurface *surface);
GdkDrag * _gdk_x11_surface_drag_begin (GdkSurface *window,
GdkDevice *device,
GdkContentProvider *content,
+1 -104
View File
@@ -110,10 +110,6 @@ static void set_wm_name (GdkDisplay *display,
const gchar *name);
static void move_to_current_desktop (GdkSurface *surface);
static void gdk_x11_toplevel_state_callback (GdkSurface *surface);
static void gdk_x11_surface_on_monitor_added (GdkSurface *surface,
GdkMonitor *monitor);
static void gdk_x11_surface_on_monitor_removed (GdkSurface *surface,
GdkMonitor *monitor);
/* Return whether time1 is considered later than time2 as far as xserver
* time is concerned. Accounts for wraparound.
@@ -138,7 +134,6 @@ gdk_x11_surface_init (GdkX11Surface *impl)
{
impl->surface_scale = 1;
impl->frame_sync_enabled = TRUE;
impl->surface_is_on_monitor = NULL;
}
GdkToplevelX11 *
@@ -467,17 +462,8 @@ gdk_x11_surface_finalize (GObject *object)
_gdk_x11_display_remove_window (display, impl->xid);
if (impl->toplevel && impl->toplevel->focus_window)
_gdk_x11_display_remove_window (display, impl->toplevel->focus_window);
g_signal_handlers_disconnect_by_func (display,
gdk_x11_surface_on_monitor_added,
GDK_SURFACE (object));
g_signal_handlers_disconnect_by_func (display,
gdk_x11_surface_on_monitor_removed,
GDK_SURFACE (object));
}
g_clear_pointer (&impl->surface_is_on_monitor, g_list_free);
g_free (impl->toplevel);
if (impl->cursor)
@@ -988,13 +974,6 @@ _gdk_x11_display_create_surface (GdkDisplay *display,
gdk_surface_freeze_updates (surface);
g_signal_connect_swapped (surface->display, "monitor-added",
G_CALLBACK (gdk_x11_surface_on_monitor_added),
surface);
g_signal_connect_swapped (surface->display, "monitor-removed",
G_CALLBACK (gdk_x11_surface_on_monitor_removed),
surface);
return surface;
}
@@ -1578,86 +1557,6 @@ gdk_x11_surface_update_popups (GdkSurface *parent)
}
}
static void
gdk_x11_surface_set_is_on_monitor (GdkSurface *surface,
GdkMonitor *monitor,
gboolean is_on_monitor)
{
GdkX11Surface *impl = GDK_X11_SURFACE (surface);
GList *was_on_monitor;
was_on_monitor = g_list_find (impl->surface_is_on_monitor, monitor);
if (!was_on_monitor && is_on_monitor)
{
impl->surface_is_on_monitor = g_list_append (impl->surface_is_on_monitor,
monitor);
gdk_surface_enter_monitor (surface, monitor);
}
else if (was_on_monitor && !is_on_monitor)
{
impl->surface_is_on_monitor = g_list_remove (impl->surface_is_on_monitor,
monitor);
gdk_surface_leave_monitor (surface, monitor);
}
}
static void
gdk_x11_surface_check_monitor (GdkSurface *surface,
GdkMonitor *monitor)
{
GdkRectangle monitor_geometry;
GdkRectangle surface_geometry;
gboolean is_on_monitor;
gdk_monitor_get_geometry (monitor, &monitor_geometry);
gdk_surface_get_geometry (surface,
&surface_geometry.x,
&surface_geometry.y,
&surface_geometry.width,
&surface_geometry.height);
is_on_monitor = gdk_rectangle_intersect (&surface_geometry,
&monitor_geometry,
NULL);
gdk_x11_surface_set_is_on_monitor (surface, monitor, is_on_monitor);
}
void
gdk_x11_surface_enter_leave_monitors (GdkSurface *surface)
{
GdkDisplay *display = gdk_surface_get_display (surface);
int n_monitors, i;
n_monitors = gdk_display_get_n_monitors (display);
for (i = 0; i < n_monitors; i++)
{
GdkMonitor *monitor = gdk_display_get_monitor (display, i);
gdk_x11_surface_check_monitor (surface, monitor);
}
}
static void
gdk_x11_surface_on_monitor_added (GdkSurface *surface,
GdkMonitor *monitor)
{
gdk_x11_surface_check_monitor (surface, monitor);
g_signal_connect_swapped (G_OBJECT (monitor), "notify::geometry",
G_CALLBACK (gdk_x11_surface_check_monitor),
surface);
}
static void
gdk_x11_surface_on_monitor_removed (GdkSurface *surface,
GdkMonitor *monitor)
{
gdk_x11_surface_check_monitor (surface, monitor);
g_signal_handlers_disconnect_by_func (G_OBJECT (monitor),
gdk_x11_surface_check_monitor,
monitor);
}
static void gdk_x11_surface_set_geometry_hints (GdkSurface *surface,
const GdkGeometry *geometry,
GdkSurfaceHints geom_mask);
@@ -4574,9 +4473,7 @@ gdk_x11_surface_show_window_menu (GdkSurface *surface,
int x_root, y_root;
XClientMessageEvent xclient = { 0 };
GdkEventType event_type = gdk_event_get_event_type (event);
switch ((guint) event_type)
switch ((guint) event->any.type)
{
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
-3
View File
@@ -27,7 +27,6 @@
#include "gdksurfaceprivate.h"
#include "gdkx11surface.h"
#include "gdkinternals.h"
#include <X11/Xlib.h>
@@ -81,8 +80,6 @@ struct _GdkX11Surface
int abs_y;
guint64 map_time;
GList *surface_is_on_monitor;
};
struct _GdkX11SurfaceClass
+1 -5
View File
@@ -50,11 +50,7 @@
G_STMT_START{\
programs->program_name ## _program.program_name.uniform_basename ## _location = \
glGetUniformLocation(programs->program_name ## _program.id, "u_" #uniform_basename);\
if (programs->program_name ## _program.program_name.uniform_basename ## _location == -1) \
{ \
g_clear_pointer (&programs, gsk_gl_renderer_programs_unref); \
goto out; \
} \
g_assert_cmpint (programs->program_name ## _program.program_name.uniform_basename ## _location, >, -1); \
}G_STMT_END
#define INIT_COMMON_UNIFORM_LOCATION(program_ptr, uniform_basename) \
+29 -29
View File
@@ -399,6 +399,32 @@ check_for_selection_change (GtkLabelAccessible *accessible,
return ret_val;
}
static void
gtk_label_accessible_notify_gtk (GObject *obj,
GParamSpec *pspec)
{
GtkWidget *widget = GTK_WIDGET (obj);
AtkObject* atk_obj = gtk_widget_get_accessible (widget);
GtkLabelAccessible *accessible;
accessible = GTK_LABEL_ACCESSIBLE (atk_obj);
if (g_strcmp0 (pspec->name, "cursor-position") == 0)
{
g_signal_emit_by_name (atk_obj, "text-caret-moved",
_gtk_label_get_cursor_position (GTK_LABEL (widget)));
if (check_for_selection_change (accessible, GTK_LABEL (widget)))
g_signal_emit_by_name (atk_obj, "text-selection-changed");
}
else if (g_strcmp0 (pspec->name, "selection-bound") == 0)
{
if (check_for_selection_change (accessible, GTK_LABEL (widget)))
g_signal_emit_by_name (atk_obj, "text-selection-changed");
}
else
GTK_WIDGET_ACCESSIBLE_CLASS (gtk_label_accessible_parent_class)->notify_gtk (obj, pspec);
}
/* atkobject.h */
static AtkStateSet *
@@ -548,6 +574,7 @@ gtk_label_accessible_class_init (GtkLabelAccessibleClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
GtkWidgetAccessibleClass *widget_class = GTK_WIDGET_ACCESSIBLE_CLASS (klass);
object_class->finalize = gtk_label_accessible_finalize;
@@ -558,39 +585,12 @@ gtk_label_accessible_class_init (GtkLabelAccessibleClass *klass)
class->get_n_children = gtk_label_accessible_get_n_children;
class->ref_child = gtk_label_accessible_ref_child;
widget_class->notify_gtk = gtk_label_accessible_notify_gtk;
}
/* 'Public' API {{{2 */
void
_gtk_label_accessible_selection_bound_changed (GtkLabel *label)
{
AtkObject *obj;
obj = _gtk_widget_peek_accessible (GTK_WIDGET (label));
if (obj == NULL)
return;
if (check_for_selection_change (GTK_LABEL_ACCESSIBLE (obj), label))
g_signal_emit_by_name (obj, "text-selection-changed");
}
void
_gtk_label_accessible_cursor_position_changed (GtkLabel *label)
{
AtkObject *obj;
obj = _gtk_widget_peek_accessible (GTK_WIDGET (label));
if (obj == NULL)
return;
g_signal_emit_by_name (obj, "text-caret-moved", _gtk_label_get_cursor_position (label));
if (check_for_selection_change (GTK_LABEL_ACCESSIBLE (obj), label))
g_signal_emit_by_name (obj, "text-selection-changed");
}
void
_gtk_label_accessible_text_deleted (GtkLabel *label)
{
-2
View File
@@ -26,8 +26,6 @@ void _gtk_label_accessible_text_deleted (GtkLabel *label);
void _gtk_label_accessible_text_inserted (GtkLabel *label);
void _gtk_label_accessible_update_links (GtkLabel *label);
void _gtk_label_accessible_focus_link_changed (GtkLabel *label);
void _gtk_label_accessible_selection_bound_changed (GtkLabel *label);
void _gtk_label_accessible_cursor_position_changed (GtkLabel *label);
G_END_DECLS
+44
View File
@@ -55,6 +55,35 @@ parse_code (GVariantBuilder *b,
return TRUE;
}
static const char *blacklist[] = {
"child",
"adult",
"older adult",
"woman with headscarf",
"bearded person",
"breast-feeding",
"mage",
"fairy",
"vampire",
"merperson",
"merman",
"mermaid",
" elf", // avoid matching selfie
"genie",
"zombie",
"in steamy room",
"climbing",
"in lotus position",
"person in bed",
"man in suit levitating",
"horse racing",
"snowboarder",
"golfing",
"love-you gesture",
"palms up together",
NULL
};
int
main (int argc, char *argv[])
{
@@ -142,6 +171,21 @@ main (int argc, char *argv[])
name = json_object_get_string_member (obj, "name");
code = g_strdup (json_object_get_string_member (obj, "code"));
if (strcmp (name, "world map") == 0)
continue;
skip = FALSE;
for (j = 0; blacklist[j]; j++)
{
if (strstr (name, blacklist[j]) != 0)
{
skip = TRUE;
break;
}
}
if (skip)
continue;
has_variations = FALSE;
while (i < length)
{
Binary file not shown.
+1 -1
View File
@@ -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>
'''
+1
View 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>
-3
View File
@@ -55,9 +55,6 @@ typedef struct _GtkAboutDialog GtkAboutDialog;
* @GTK_LICENSE_LGPL_3_0_ONLY: The GNU Lesser General Public License, version 3.0 only
* @GTK_LICENSE_AGPL_3_0: The GNU Affero General Public License, version 3.0 or later
* @GTK_LICENSE_AGPL_3_0_ONLY: The GNU Affero General Public License, version 3.0 only
* @GTK_LICENSE_BSD_3: The 3-clause BSD licence
* @GTK_LICENSE_APACHE_2_0: The Apache License, version 2.0
* @GTK_LICENSE_MPL_2_0: The Mozilla Public License, version 2.0
*
* The type of license for an application.
*
+51 -36
View File
@@ -570,28 +570,20 @@ gtk_accelerator_name_with_keycode (GdkDisplay *display,
*
* Returns: a newly-allocated accelerator name
*/
char *
gchar*
gtk_accelerator_name (guint accelerator_key,
GdkModifierType accelerator_mods)
{
static const struct {
guint mask;
const char *text;
gsize text_len;
} mask_text[] = {
{ GDK_SHIFT_MASK, "<Shift>", strlen ("<Shift>") },
{ GDK_CONTROL_MASK, "<Control>", strlen ("<Control>") },
{ GDK_ALT_MASK, "<Alt>", strlen ("<Alt>") },
{ GDK_META_MASK, "<Meta>", strlen ("<Meta>") },
{ GDK_SUPER_MASK, "<Super>", strlen ("<Super>") },
{ GDK_HYPER_MASK, "<Hyper>", strlen ("<Hyper>") }
};
static const gchar text_shift[] = "<Shift>";
static const gchar text_control[] = "<Control>";
static const gchar text_alt[] = "<Alt>";
static const gchar text_meta[] = "<Meta>";
static const gchar text_super[] = "<Super>";
static const gchar text_hyper[] = "<Hyper>";
GdkModifierType saved_mods;
guint l;
guint name_len;
const char *keyval_name;
char *accelerator;
int i;
gchar *accelerator;
accelerator_mods &= GDK_MODIFIER_MASK;
@@ -599,34 +591,57 @@ gtk_accelerator_name (guint accelerator_key,
if (!keyval_name)
keyval_name = "";
name_len = strlen (keyval_name);
saved_mods = accelerator_mods;
for (i = 0; i < G_N_ELEMENTS (mask_text); i++)
{
if (accelerator_mods & mask_text[i].mask)
name_len += mask_text[i].text_len;
}
l = strlen (keyval_name);
if (accelerator_mods & GDK_SHIFT_MASK)
l += sizeof (text_shift) - 1;
if (accelerator_mods & GDK_CONTROL_MASK)
l += sizeof (text_control) - 1;
if (accelerator_mods & GDK_ALT_MASK)
l += sizeof (text_alt) - 1;
if (accelerator_mods & GDK_META_MASK)
l += sizeof (text_meta) - 1;
if (accelerator_mods & GDK_HYPER_MASK)
l += sizeof (text_hyper) - 1;
if (accelerator_mods & GDK_SUPER_MASK)
l += sizeof (text_super) - 1;
if (name_len == 0)
return g_strdup (keyval_name);
name_len += 1; /* NUL byte */
accelerator = g_new (char, name_len);
accelerator = g_new (gchar, l + 1);
accelerator_mods = saved_mods;
l = 0;
for (i = 0; i < G_N_ELEMENTS (mask_text); i++)
accelerator[l] = 0;
if (accelerator_mods & GDK_SHIFT_MASK)
{
if (accelerator_mods & mask_text[i].mask)
{
strcpy (accelerator + l, mask_text[i].text);
l += mask_text[i].text_len;
}
strcpy (accelerator + l, text_shift);
l += sizeof (text_shift) - 1;
}
if (accelerator_mods & GDK_CONTROL_MASK)
{
strcpy (accelerator + l, text_control);
l += sizeof (text_control) - 1;
}
if (accelerator_mods & GDK_ALT_MASK)
{
strcpy (accelerator + l, text_alt);
l += sizeof (text_alt) - 1;
}
if (accelerator_mods & GDK_META_MASK)
{
strcpy (accelerator + l, text_meta);
l += sizeof (text_meta) - 1;
}
if (accelerator_mods & GDK_HYPER_MASK)
{
strcpy (accelerator + l, text_hyper);
l += sizeof (text_hyper) - 1;
}
if (accelerator_mods & GDK_SUPER_MASK)
{
strcpy (accelerator + l, text_super);
l += sizeof (text_super) - 1;
}
strcpy (accelerator + l, keyval_name);
accelerator[name_len - 1] = '\0';
return accelerator;
}
+1
View File
@@ -27,6 +27,7 @@
#include "gtkbox.h"
#include "gtkrevealer.h"
#include "gtkwidgetprivate.h"
#include "gtkcontainerprivate.h"
#include "gtkprivate.h"
#include "gtkcenterbox.h"
#include "gtkbinlayout.h"
+159 -110
View File
@@ -73,10 +73,23 @@
*/
typedef struct _GtkAppChooserWidgetClass GtkAppChooserWidgetClass;
typedef struct _GtkAppChooserWidgetPrivate GtkAppChooserWidgetPrivate;
struct _GtkAppChooserWidget {
GtkWidget parent_instance;
};
struct _GtkAppChooserWidgetClass {
GtkWidgetClass parent_class;
void (* application_selected) (GtkAppChooserWidget *self,
GAppInfo *app_info);
void (* application_activated) (GtkAppChooserWidget *self,
GAppInfo *app_info);
};
struct _GtkAppChooserWidgetPrivate {
GAppInfo *selected_app_info;
GtkWidget *overlay;
@@ -104,16 +117,6 @@ struct _GtkAppChooserWidget {
GtkWidget *popup_menu;
};
struct _GtkAppChooserWidgetClass {
GtkWidgetClass parent_class;
void (* application_selected) (GtkAppChooserWidget *self,
GAppInfo *app_info);
void (* application_activated) (GtkAppChooserWidget *self,
GAppInfo *app_info);
};
enum {
COLUMN_APP_INFO,
COLUMN_GICON,
@@ -152,6 +155,7 @@ static guint signals[N_SIGNALS] = { 0, };
static void gtk_app_chooser_widget_iface_init (GtkAppChooserIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkAppChooserWidget, gtk_app_chooser_widget, GTK_TYPE_WIDGET,
G_ADD_PRIVATE (GtkAppChooserWidget)
G_IMPLEMENT_INTERFACE (GTK_TYPE_APP_CHOOSER,
gtk_app_chooser_widget_iface_init));
@@ -159,6 +163,7 @@ static void
refresh_and_emit_app_selected (GtkAppChooserWidget *self,
GtkTreeSelection *selection)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
GtkTreeModel *model;
GtkTreeIter iter;
GAppInfo *info = NULL;
@@ -170,25 +175,25 @@ refresh_and_emit_app_selected (GtkAppChooserWidget *self,
if (info == NULL)
return;
if (self->selected_app_info)
if (priv->selected_app_info)
{
if (!g_app_info_equal (self->selected_app_info, info))
if (!g_app_info_equal (priv->selected_app_info, info))
{
should_emit = TRUE;
g_set_object (&self->selected_app_info, info);
g_set_object (&priv->selected_app_info, info);
}
}
else
{
should_emit = TRUE;
g_set_object (&self->selected_app_info, info);
g_set_object (&priv->selected_app_info, info);
}
g_object_unref (info);
if (should_emit)
g_signal_emit (self, signals[SIGNAL_APPLICATION_SELECTED], 0,
self->selected_app_info);
priv->selected_app_info);
}
static gboolean
@@ -215,17 +220,18 @@ program_list_selection_activated (GtkTreeView *view,
gpointer user_data)
{
GtkAppChooserWidget *self = user_data;
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
GtkTreeSelection *selection;
if (path_is_heading (view, path))
return;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->program_list));
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->program_list));
refresh_and_emit_app_selected (self, selection);
g_signal_emit (self, signals[SIGNAL_APPLICATION_ACTIVATED], 0,
self->selected_app_info);
priv->selected_app_info);
}
static gboolean
@@ -431,6 +437,7 @@ gtk_app_chooser_widget_add_section (GtkAppChooserWidget *self,
GList *applications,
GList *exclude_apps)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
gboolean heading_added, unref_icon;
GtkTreeIter iter;
GAppInfo *app;
@@ -447,7 +454,7 @@ gtk_app_chooser_widget_add_section (GtkAppChooserWidget *self,
{
app = l->data;
if (self->content_type != NULL &&
if (priv->content_type != NULL &&
!g_app_info_supports_uris (app) &&
!g_app_info_supports_files (app))
continue;
@@ -458,8 +465,8 @@ gtk_app_chooser_widget_add_section (GtkAppChooserWidget *self,
if (!heading_added && show_headings)
{
gtk_list_store_append (self->program_list_store, &iter);
gtk_list_store_set (self->program_list_store, &iter,
gtk_list_store_append (priv->program_list_store, &iter);
gtk_list_store_set (priv->program_list_store, &iter,
COLUMN_HEADING_TEXT, bold_string,
COLUMN_HEADING, TRUE,
COLUMN_RECOMMENDED, recommended,
@@ -481,8 +488,8 @@ gtk_app_chooser_widget_add_section (GtkAppChooserWidget *self,
unref_icon = TRUE;
}
gtk_list_store_append (self->program_list_store, &iter);
gtk_list_store_set (self->program_list_store, &iter,
gtk_list_store_append (priv->program_list_store, &iter);
gtk_list_store_set (priv->program_list_store, &iter,
COLUMN_APP_INFO, app,
COLUMN_GICON, icon,
COLUMN_NAME, g_app_info_get_name (app),
@@ -510,6 +517,7 @@ static void
gtk_app_chooser_add_default (GtkAppChooserWidget *self,
GAppInfo *app)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
GtkTreeIter iter;
GIcon *icon;
gchar *string;
@@ -518,8 +526,8 @@ gtk_app_chooser_add_default (GtkAppChooserWidget *self,
unref_icon = FALSE;
string = g_strdup_printf ("<b>%s</b>", _("Default Application"));
gtk_list_store_append (self->program_list_store, &iter);
gtk_list_store_set (self->program_list_store, &iter,
gtk_list_store_append (priv->program_list_store, &iter);
gtk_list_store_set (priv->program_list_store, &iter,
COLUMN_HEADING_TEXT, string,
COLUMN_HEADING, TRUE,
COLUMN_DEFAULT, TRUE,
@@ -538,8 +546,8 @@ gtk_app_chooser_add_default (GtkAppChooserWidget *self,
unref_icon = TRUE;
}
gtk_list_store_append (self->program_list_store, &iter);
gtk_list_store_set (self->program_list_store, &iter,
gtk_list_store_append (priv->program_list_store, &iter);
gtk_list_store_set (priv->program_list_store, &iter,
COLUMN_APP_INFO, app,
COLUMN_GICON, icon,
COLUMN_NAME, g_app_info_get_name (app),
@@ -558,23 +566,24 @@ gtk_app_chooser_add_default (GtkAppChooserWidget *self,
static void
update_no_applications_label (GtkAppChooserWidget *self)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
gchar *text = NULL, *desc = NULL;
const gchar *string;
if (self->default_text == NULL)
if (priv->default_text == NULL)
{
if (self->content_type)
desc = g_content_type_get_description (self->content_type);
if (priv->content_type)
desc = g_content_type_get_description (priv->content_type);
string = text = g_strdup_printf (_("No applications found for “%s”."), desc);
g_free (desc);
}
else
{
string = self->default_text;
string = priv->default_text;
}
gtk_label_set_text (GTK_LABEL (self->no_apps_label), string);
gtk_label_set_text (GTK_LABEL (priv->no_apps_label), string);
g_free (text);
}
@@ -582,11 +591,12 @@ update_no_applications_label (GtkAppChooserWidget *self)
static void
gtk_app_chooser_widget_select_first (GtkAppChooserWidget *self)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
GtkTreeIter iter;
GAppInfo *info = NULL;
GtkTreeModel *model;
model = gtk_tree_view_get_model (GTK_TREE_VIEW (self->program_list));
model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->program_list));
if (!gtk_tree_model_get_iter_first (model, &iter))
return;
@@ -607,7 +617,7 @@ gtk_app_chooser_widget_select_first (GtkAppChooserWidget *self)
{
GtkTreeSelection *selection;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->program_list));
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->program_list));
gtk_tree_selection_select_iter (selection, &iter);
g_object_unref (info);
@@ -617,6 +627,7 @@ gtk_app_chooser_widget_select_first (GtkAppChooserWidget *self)
static void
gtk_app_chooser_widget_real_add_items (GtkAppChooserWidget *self)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
GList *all_applications = NULL;
GList *recommended_apps = NULL;
GList *fallback_apps = NULL;
@@ -628,12 +639,12 @@ gtk_app_chooser_widget_real_add_items (GtkAppChooserWidget *self)
show_headings = TRUE;
apps_added = FALSE;
if (self->show_all)
if (priv->show_all)
show_headings = FALSE;
if (self->show_default && self->content_type)
if (priv->show_default && priv->content_type)
{
default_app = g_app_info_get_default_for_type (self->content_type, FALSE);
default_app = g_app_info_get_default_for_type (priv->content_type, FALSE);
if (default_app != NULL)
{
@@ -644,14 +655,14 @@ gtk_app_chooser_widget_real_add_items (GtkAppChooserWidget *self)
}
#ifndef G_OS_WIN32
if ((self->content_type && self->show_recommended) || self->show_all)
if ((priv->content_type && priv->show_recommended) || priv->show_all)
{
if (self->content_type)
recommended_apps = g_app_info_get_recommended_for_type (self->content_type);
if (priv->content_type)
recommended_apps = g_app_info_get_recommended_for_type (priv->content_type);
apps_added |= gtk_app_chooser_widget_add_section (self, _("Recommended Applications"),
show_headings,
!self->show_all, /* mark as recommended */
!priv->show_all, /* mark as recommended */
FALSE, /* mark as fallback */
recommended_apps, exclude_apps);
@@ -659,22 +670,22 @@ gtk_app_chooser_widget_real_add_items (GtkAppChooserWidget *self)
g_list_copy (recommended_apps));
}
if ((self->content_type && self->show_fallback) || self->show_all)
if ((priv->content_type && priv->show_fallback) || priv->show_all)
{
if (self->content_type)
fallback_apps = g_app_info_get_fallback_for_type (self->content_type);
if (priv->content_type)
fallback_apps = g_app_info_get_fallback_for_type (priv->content_type);
apps_added |= gtk_app_chooser_widget_add_section (self, _("Related Applications"),
show_headings,
FALSE, /* mark as recommended */
!self->show_all, /* mark as fallback */
!priv->show_all, /* mark as fallback */
fallback_apps, exclude_apps);
exclude_apps = g_list_concat (exclude_apps,
g_list_copy (fallback_apps));
}
#endif
if (self->show_other || self->show_all)
if (priv->show_other || priv->show_all)
{
all_applications = g_app_info_get_all ();
@@ -688,7 +699,7 @@ gtk_app_chooser_widget_real_add_items (GtkAppChooserWidget *self)
if (!apps_added)
update_no_applications_label (self);
gtk_widget_set_visible (self->no_apps, !apps_added);
gtk_widget_set_visible (priv->no_apps, !apps_added);
gtk_app_chooser_widget_select_first (self);
@@ -704,9 +715,11 @@ gtk_app_chooser_widget_real_add_items (GtkAppChooserWidget *self)
static void
gtk_app_chooser_widget_initialize_items (GtkAppChooserWidget *self)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
/* initial padding */
g_object_set (self->padding_renderer,
"xpad", self->show_all ? 0 : 6,
g_object_set (priv->padding_renderer,
"xpad", priv->show_all ? 0 : 6,
NULL);
/* populate the widget */
@@ -727,11 +740,12 @@ gtk_app_chooser_widget_set_property (GObject *object,
GParamSpec *pspec)
{
GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (object);
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
switch (property_id)
{
case PROP_CONTENT_TYPE:
self->content_type = g_value_dup_string (value);
priv->content_type = g_value_dup_string (value);
break;
case PROP_SHOW_DEFAULT:
gtk_app_chooser_widget_set_show_default (self, g_value_get_boolean (value));
@@ -764,29 +778,30 @@ gtk_app_chooser_widget_get_property (GObject *object,
GParamSpec *pspec)
{
GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (object);
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
switch (property_id)
{
case PROP_CONTENT_TYPE:
g_value_set_string (value, self->content_type);
g_value_set_string (value, priv->content_type);
break;
case PROP_SHOW_DEFAULT:
g_value_set_boolean (value, self->show_default);
g_value_set_boolean (value, priv->show_default);
break;
case PROP_SHOW_RECOMMENDED:
g_value_set_boolean (value, self->show_recommended);
g_value_set_boolean (value, priv->show_recommended);
break;
case PROP_SHOW_FALLBACK:
g_value_set_boolean (value, self->show_fallback);
g_value_set_boolean (value, priv->show_fallback);
break;
case PROP_SHOW_OTHER:
g_value_set_boolean (value, self->show_other);
g_value_set_boolean (value, priv->show_other);
break;
case PROP_SHOW_ALL:
g_value_set_boolean (value, self->show_all);
g_value_set_boolean (value, priv->show_all);
break;
case PROP_DEFAULT_TEXT:
g_value_set_string (value, self->default_text);
g_value_set_string (value, priv->default_text);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -809,11 +824,12 @@ static void
gtk_app_chooser_widget_finalize (GObject *object)
{
GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (object);
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
g_free (self->content_type);
g_free (self->default_text);
g_signal_handlers_disconnect_by_func (self->monitor, app_info_changed, self);
g_object_unref (self->monitor);
g_free (priv->content_type);
g_free (priv->default_text);
g_signal_handlers_disconnect_by_func (priv->monitor, app_info_changed, self);
g_object_unref (priv->monitor);
G_OBJECT_CLASS (gtk_app_chooser_widget_parent_class)->finalize (object);
}
@@ -822,13 +838,14 @@ static void
gtk_app_chooser_widget_dispose (GObject *object)
{
GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (object);
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
g_clear_object (&self->selected_app_info);
g_clear_object (&priv->selected_app_info);
if (self->overlay)
if (priv->overlay)
{
gtk_widget_unparent (self->overlay);
self->overlay = NULL;
gtk_widget_unparent (priv->overlay);
priv->overlay = NULL;
}
G_OBJECT_CLASS (gtk_app_chooser_widget_parent_class)->dispose (object);
@@ -844,8 +861,9 @@ gtk_app_chooser_widget_measure (GtkWidget *widget,
int *natural_baseline)
{
GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (widget);
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
gtk_widget_measure (self->overlay, orientation, for_size,
gtk_widget_measure (priv->overlay, orientation, for_size,
minimum, natural,
minimum_baseline, natural_baseline);
}
@@ -855,8 +873,9 @@ gtk_app_chooser_widget_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (widget);
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
gtk_widget_snapshot_child (widget, self->overlay, snapshot);
gtk_widget_snapshot_child (widget, priv->overlay, snapshot);
}
static void
@@ -866,10 +885,11 @@ gtk_app_chooser_widget_size_allocate (GtkWidget *widget,
int baseline)
{
GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (widget);
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
GTK_WIDGET_CLASS (gtk_app_chooser_widget_parent_class)->size_allocate (widget, width, height, baseline);
gtk_widget_size_allocate (self->overlay,
gtk_widget_size_allocate (priv->overlay,
&(GtkAllocation) {
0, 0,
width, height
@@ -1028,14 +1048,14 @@ gtk_app_chooser_widget_class_init (GtkAppChooserWidgetClass *klass)
*/
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gtk/libgtk/ui/gtkappchooserwidget.ui");
gtk_widget_class_bind_template_child (widget_class, GtkAppChooserWidget, program_list);
gtk_widget_class_bind_template_child (widget_class, GtkAppChooserWidget, program_list_store);
gtk_widget_class_bind_template_child (widget_class, GtkAppChooserWidget, column);
gtk_widget_class_bind_template_child (widget_class, GtkAppChooserWidget, padding_renderer);
gtk_widget_class_bind_template_child (widget_class, GtkAppChooserWidget, secondary_padding);
gtk_widget_class_bind_template_child (widget_class, GtkAppChooserWidget, no_apps_label);
gtk_widget_class_bind_template_child (widget_class, GtkAppChooserWidget, no_apps);
gtk_widget_class_bind_template_child (widget_class, GtkAppChooserWidget, overlay);
gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserWidget, program_list);
gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserWidget, program_list_store);
gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserWidget, column);
gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserWidget, padding_renderer);
gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserWidget, secondary_padding);
gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserWidget, no_apps_label);
gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserWidget, no_apps);
gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserWidget, overlay);
gtk_widget_class_bind_template_callback (widget_class, refresh_and_emit_app_selected);
gtk_widget_class_bind_template_callback (widget_class, program_list_selection_activated);
@@ -1045,6 +1065,7 @@ gtk_app_chooser_widget_class_init (GtkAppChooserWidgetClass *klass)
static void
gtk_app_chooser_widget_init (GtkAppChooserWidget *self)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
GtkTreeSelection *selection;
GtkTreeModel *sort;
@@ -1053,11 +1074,11 @@ gtk_app_chooser_widget_init (GtkAppChooserWidget *self)
/* Various parts of the GtkTreeView code need custom code to setup, mostly
* because we lack signals to connect to, or properties to set.
*/
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->program_list));
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->program_list));
gtk_tree_selection_set_select_function (selection, gtk_app_chooser_selection_func,
self, NULL);
sort = gtk_tree_view_get_model (GTK_TREE_VIEW (self->program_list));
sort = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->program_list));
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort),
COLUMN_NAME,
GTK_SORT_ASCENDING);
@@ -1066,18 +1087,18 @@ gtk_app_chooser_widget_init (GtkAppChooserWidget *self)
gtk_app_chooser_sort_func,
self, NULL);
gtk_tree_view_set_search_column (GTK_TREE_VIEW (self->program_list), COLUMN_NAME);
gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (self->program_list),
gtk_tree_view_set_search_column (GTK_TREE_VIEW (priv->program_list), COLUMN_NAME);
gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (priv->program_list),
gtk_app_chooser_search_equal_func,
NULL, NULL);
gtk_tree_view_column_set_cell_data_func (self->column,
self->secondary_padding,
gtk_tree_view_column_set_cell_data_func (priv->column,
priv->secondary_padding,
padding_cell_renderer_func,
NULL, NULL);
self->monitor = g_app_info_monitor_get ();
g_signal_connect (self->monitor, "changed",
priv->monitor = g_app_info_monitor_get ();
g_signal_connect (priv->monitor, "changed",
G_CALLBACK (app_info_changed), self);
}
@@ -1085,25 +1106,27 @@ static GAppInfo *
gtk_app_chooser_widget_get_app_info (GtkAppChooser *object)
{
GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (object);
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
if (self->selected_app_info == NULL)
if (priv->selected_app_info == NULL)
return NULL;
return g_object_ref (self->selected_app_info);
return g_object_ref (priv->selected_app_info);
}
static void
gtk_app_chooser_widget_refresh (GtkAppChooser *object)
{
GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (object);
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
if (self->program_list_store != NULL)
if (priv->program_list_store != NULL)
{
gtk_list_store_clear (self->program_list_store);
gtk_list_store_clear (priv->program_list_store);
/* don't add additional xpad if we don't have headings */
g_object_set (self->padding_renderer,
"visible", !self->show_all,
g_object_set (priv->padding_renderer,
"visible", !priv->show_all,
NULL);
gtk_app_chooser_widget_real_add_items (self);
@@ -1146,11 +1169,13 @@ void
gtk_app_chooser_widget_set_show_default (GtkAppChooserWidget *self,
gboolean setting)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
g_return_if_fail (GTK_IS_APP_CHOOSER_WIDGET (self));
if (self->show_default != setting)
if (priv->show_default != setting)
{
self->show_default = setting;
priv->show_default = setting;
g_object_notify (G_OBJECT (self), "show-default");
@@ -1170,9 +1195,11 @@ gtk_app_chooser_widget_set_show_default (GtkAppChooserWidget *self,
gboolean
gtk_app_chooser_widget_get_show_default (GtkAppChooserWidget *self)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
g_return_val_if_fail (GTK_IS_APP_CHOOSER_WIDGET (self), FALSE);
return self->show_default;
return priv->show_default;
}
/**
@@ -1187,11 +1214,13 @@ void
gtk_app_chooser_widget_set_show_recommended (GtkAppChooserWidget *self,
gboolean setting)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
g_return_if_fail (GTK_IS_APP_CHOOSER_WIDGET (self));
if (self->show_recommended != setting)
if (priv->show_recommended != setting)
{
self->show_recommended = setting;
priv->show_recommended = setting;
g_object_notify (G_OBJECT (self), "show-recommended");
@@ -1211,9 +1240,11 @@ gtk_app_chooser_widget_set_show_recommended (GtkAppChooserWidget *self,
gboolean
gtk_app_chooser_widget_get_show_recommended (GtkAppChooserWidget *self)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
g_return_val_if_fail (GTK_IS_APP_CHOOSER_WIDGET (self), FALSE);
return self->show_recommended;
return priv->show_recommended;
}
/**
@@ -1228,11 +1259,13 @@ void
gtk_app_chooser_widget_set_show_fallback (GtkAppChooserWidget *self,
gboolean setting)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
g_return_if_fail (GTK_IS_APP_CHOOSER_WIDGET (self));
if (self->show_fallback != setting)
if (priv->show_fallback != setting)
{
self->show_fallback = setting;
priv->show_fallback = setting;
g_object_notify (G_OBJECT (self), "show-fallback");
@@ -1252,9 +1285,11 @@ gtk_app_chooser_widget_set_show_fallback (GtkAppChooserWidget *self,
gboolean
gtk_app_chooser_widget_get_show_fallback (GtkAppChooserWidget *self)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
g_return_val_if_fail (GTK_IS_APP_CHOOSER_WIDGET (self), FALSE);
return self->show_fallback;
return priv->show_fallback;
}
/**
@@ -1269,11 +1304,13 @@ void
gtk_app_chooser_widget_set_show_other (GtkAppChooserWidget *self,
gboolean setting)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
g_return_if_fail (GTK_IS_APP_CHOOSER_WIDGET (self));
if (self->show_other != setting)
if (priv->show_other != setting)
{
self->show_other = setting;
priv->show_other = setting;
g_object_notify (G_OBJECT (self), "show-other");
@@ -1293,9 +1330,11 @@ gtk_app_chooser_widget_set_show_other (GtkAppChooserWidget *self,
gboolean
gtk_app_chooser_widget_get_show_other (GtkAppChooserWidget *self)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
g_return_val_if_fail (GTK_IS_APP_CHOOSER_WIDGET (self), FALSE);
return self->show_other;
return priv->show_other;
}
/**
@@ -1310,11 +1349,13 @@ void
gtk_app_chooser_widget_set_show_all (GtkAppChooserWidget *self,
gboolean setting)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
g_return_if_fail (GTK_IS_APP_CHOOSER_WIDGET (self));
if (self->show_all != setting)
if (priv->show_all != setting)
{
self->show_all = setting;
priv->show_all = setting;
g_object_notify (G_OBJECT (self), "show-all");
@@ -1334,9 +1375,11 @@ gtk_app_chooser_widget_set_show_all (GtkAppChooserWidget *self,
gboolean
gtk_app_chooser_widget_get_show_all (GtkAppChooserWidget *self)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
g_return_val_if_fail (GTK_IS_APP_CHOOSER_WIDGET (self), FALSE);
return self->show_all;
return priv->show_all;
}
/**
@@ -1351,12 +1394,14 @@ void
gtk_app_chooser_widget_set_default_text (GtkAppChooserWidget *self,
const gchar *text)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
g_return_if_fail (GTK_IS_APP_CHOOSER_WIDGET (self));
if (g_strcmp0 (text, self->default_text) != 0)
if (g_strcmp0 (text, priv->default_text) != 0)
{
g_free (self->default_text);
self->default_text = g_strdup (text);
g_free (priv->default_text);
priv->default_text = g_strdup (text);
g_object_notify (G_OBJECT (self), "default-text");
@@ -1376,18 +1421,22 @@ gtk_app_chooser_widget_set_default_text (GtkAppChooserWidget *self,
const gchar *
gtk_app_chooser_widget_get_default_text (GtkAppChooserWidget *self)
{
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
g_return_val_if_fail (GTK_IS_APP_CHOOSER_WIDGET (self), NULL);
return self->default_text;
return priv->default_text;
}
void
_gtk_app_chooser_widget_set_search_entry (GtkAppChooserWidget *self,
GtkEditable *entry)
{
gtk_tree_view_set_search_entry (GTK_TREE_VIEW (self->program_list), entry);
GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);
g_object_bind_property (self->no_apps, "visible",
gtk_tree_view_set_search_entry (GTK_TREE_VIEW (priv->program_list), entry);
g_object_bind_property (priv->no_apps, "visible",
entry, "sensitive",
G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
}
+136 -234
View File
@@ -48,7 +48,6 @@
#include "config.h"
#include "gtkaspectframe.h"
#include "gtkbin.h"
#include "gtksizerequest.h"
@@ -60,19 +59,23 @@ typedef struct _GtkAspectFrameClass GtkAspectFrameClass;
struct _GtkAspectFrame
{
GtkBin parent_instance;
gboolean obey_child;
float xalign;
float yalign;
float ratio;
GtkFrame parent_instance;
};
struct _GtkAspectFrameClass
{
GtkBinClass parent_class;
GtkFrameClass parent_class;
};
typedef struct
{
gboolean obey_child;
gfloat xalign;
gfloat yalign;
gfloat ratio;
} GtkAspectFramePrivate;
enum {
PROP_0,
PROP_XALIGN,
@@ -89,26 +92,27 @@ static void gtk_aspect_frame_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gtk_aspect_frame_size_allocate (GtkWidget *widget,
int width,
int height,
int baseline);
static void gtk_aspect_frame_compute_child_allocation (GtkFrame *frame,
GtkAllocation *child_allocation);
#define MAX_RATIO 10000.0
#define MIN_RATIO 0.0001
G_DEFINE_TYPE (GtkAspectFrame, gtk_aspect_frame, GTK_TYPE_BIN)
G_DEFINE_TYPE_WITH_PRIVATE (GtkAspectFrame, gtk_aspect_frame, GTK_TYPE_FRAME)
static void
gtk_aspect_frame_class_init (GtkAspectFrameClass *class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
GObjectClass *gobject_class;
GtkFrameClass *frame_class;
gobject_class = (GObjectClass*) class;
frame_class = (GtkFrameClass*) class;
gobject_class->set_property = gtk_aspect_frame_set_property;
gobject_class->get_property = gtk_aspect_frame_get_property;
widget_class->size_allocate = gtk_aspect_frame_size_allocate;
frame_class->compute_child_allocation = gtk_aspect_frame_compute_child_allocation;
g_object_class_install_property (gobject_class,
PROP_XALIGN,
@@ -139,16 +143,18 @@ gtk_aspect_frame_class_init (GtkAspectFrameClass *class)
TRUE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (class), I_("aspectframe"));
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (class), I_("frame"));
}
static void
gtk_aspect_frame_init (GtkAspectFrame *self)
gtk_aspect_frame_init (GtkAspectFrame *aspect_frame)
{
self->xalign = 0.5;
self->yalign = 0.5;
self->ratio = 1.0;
self->obey_child = TRUE;
GtkAspectFramePrivate *priv = gtk_aspect_frame_get_instance_private (aspect_frame);
priv->xalign = 0.5;
priv->yalign = 0.5;
priv->ratio = 1.0;
priv->obey_child = TRUE;
}
static void
@@ -157,22 +163,39 @@ gtk_aspect_frame_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
GtkAspectFrame *self = GTK_ASPECT_FRAME (object);
GtkAspectFrame *aspect_frame = GTK_ASPECT_FRAME (object);
GtkAspectFramePrivate *priv = gtk_aspect_frame_get_instance_private (aspect_frame);
switch (prop_id)
{
/* g_object_notify is handled by the _frame_set function */
case PROP_XALIGN:
gtk_aspect_frame_set_xalign (self, g_value_get_float (value));
gtk_aspect_frame_set (aspect_frame,
g_value_get_float (value),
priv->yalign,
priv->ratio,
priv->obey_child);
break;
case PROP_YALIGN:
gtk_aspect_frame_set_yalign (self, g_value_get_float (value));
gtk_aspect_frame_set (aspect_frame,
priv->xalign,
g_value_get_float (value),
priv->ratio,
priv->obey_child);
break;
case PROP_RATIO:
gtk_aspect_frame_set_ratio (self, g_value_get_float (value));
gtk_aspect_frame_set (aspect_frame,
priv->xalign,
priv->yalign,
g_value_get_float (value),
priv->obey_child);
break;
case PROP_OBEY_CHILD:
gtk_aspect_frame_set_obey_child (self, g_value_get_boolean (value));
gtk_aspect_frame_set (aspect_frame,
priv->xalign,
priv->yalign,
priv->ratio,
g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -186,21 +209,22 @@ gtk_aspect_frame_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
GtkAspectFrame *self = GTK_ASPECT_FRAME (object);
GtkAspectFrame *aspect_frame = GTK_ASPECT_FRAME (object);
GtkAspectFramePrivate *priv = gtk_aspect_frame_get_instance_private (aspect_frame);
switch (prop_id)
{
case PROP_XALIGN:
g_value_set_float (value, self->xalign);
g_value_set_float (value, priv->xalign);
break;
case PROP_YALIGN:
g_value_set_float (value, self->yalign);
g_value_set_float (value, priv->yalign);
break;
case PROP_RATIO:
g_value_set_float (value, self->ratio);
g_value_set_float (value, priv->ratio);
break;
case PROP_OBEY_CHILD:
g_value_set_boolean (value, self->obey_child);
g_value_set_boolean (value, priv->obey_child);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -210,6 +234,7 @@ gtk_aspect_frame_get_property (GObject *object,
/**
* gtk_aspect_frame_new:
* @label: (allow-none): Label text.
* @xalign: Horizontal alignment of the child within the allocation of
* the #GtkAspectFrame. This ranges from 0.0 (left aligned)
* to 1.0 (right aligned)
@@ -224,206 +249,100 @@ gtk_aspect_frame_get_property (GObject *object,
*
* Returns: the new #GtkAspectFrame.
*/
GtkWidget *
gtk_aspect_frame_new (float xalign,
float yalign,
float ratio,
gboolean obey_child)
GtkWidget*
gtk_aspect_frame_new (const gchar *label,
gfloat xalign,
gfloat yalign,
gfloat ratio,
gboolean obey_child)
{
GtkAspectFrame *self;
GtkAspectFrame *aspect_frame;
GtkAspectFramePrivate *priv;
self = g_object_new (GTK_TYPE_ASPECT_FRAME, NULL);
aspect_frame = g_object_new (GTK_TYPE_ASPECT_FRAME, NULL);
priv = gtk_aspect_frame_get_instance_private (aspect_frame);
self->xalign = CLAMP (xalign, 0.0, 1.0);
self->yalign = CLAMP (yalign, 0.0, 1.0);
self->ratio = CLAMP (ratio, MIN_RATIO, MAX_RATIO);
self->obey_child = obey_child != FALSE;
priv->xalign = CLAMP (xalign, 0.0, 1.0);
priv->yalign = CLAMP (yalign, 0.0, 1.0);
priv->ratio = CLAMP (ratio, MIN_RATIO, MAX_RATIO);
priv->obey_child = obey_child != FALSE;
return GTK_WIDGET (self);
gtk_frame_set_label (GTK_FRAME(aspect_frame), label);
return GTK_WIDGET (aspect_frame);
}
/**
* gtk_aspect_frame_set_xalign:
* @self: a #GtkAspectFrame
* @xalign: horizontal alignment, from 0.0 (left aligned) to 1.0 (right aligned)
* gtk_aspect_frame_set:
* @aspect_frame: a #GtkAspectFrame
* @xalign: Horizontal alignment of the child within the allocation of
* the #GtkAspectFrame. This ranges from 0.0 (left aligned)
* to 1.0 (right aligned)
* @yalign: Vertical alignment of the child within the allocation of
* the #GtkAspectFrame. This ranges from 0.0 (top aligned)
* to 1.0 (bottom aligned)
* @ratio: The desired aspect ratio.
* @obey_child: If %TRUE, @ratio is ignored, and the aspect
* ratio is taken from the requistion of the child.
*
* Sets the horizontal alignment of the child within the allocation
* of the #GtkAspectFrame.
* Set parameters for an existing #GtkAspectFrame.
*/
void
gtk_aspect_frame_set_xalign (GtkAspectFrame *self,
float xalign)
gtk_aspect_frame_set (GtkAspectFrame *aspect_frame,
gfloat xalign,
gfloat yalign,
gfloat ratio,
gboolean obey_child)
{
g_return_if_fail (GTK_IS_ASPECT_FRAME (self));
GtkAspectFramePrivate *priv = gtk_aspect_frame_get_instance_private (aspect_frame);
g_return_if_fail (GTK_IS_ASPECT_FRAME (aspect_frame));
xalign = CLAMP (xalign, 0.0, 1.0);
if (self->xalign == xalign)
return;
self->xalign = xalign;
g_object_notify (G_OBJECT (self), "xalign");
gtk_widget_queue_resize (GTK_WIDGET (self));
}
/**
* gtk_aspect_frame_get_xalign:
* @self: a #GtkAspectFrame
*
* Returns the horizontal alignment of the child within the
* allocation of the #GtkAspectFrame.
*
* Returns: the horizontal alignment
*/
float
gtk_aspect_frame_get_xalign (GtkAspectFrame *self)
{
g_return_val_if_fail (GTK_IS_ASPECT_FRAME (self), 0.5);
return self->xalign;
}
/**
* gtk_aspect_frame_set_yalign:
* @self: a #GtkAspectFrame
* @yalign: horizontal alignment, from 0.0 (top aligned) to 1.0 (bottom aligned)
*
* Sets the vertical alignment of the child within the allocation
* of the #GtkAspectFrame.
*/
void
gtk_aspect_frame_set_yalign (GtkAspectFrame *self,
float yalign)
{
g_return_if_fail (GTK_IS_ASPECT_FRAME (self));
yalign = CLAMP (yalign, 0.0, 1.0);
if (self->yalign == yalign)
return;
self->yalign = yalign;
g_object_notify (G_OBJECT (self), "yalign");
gtk_widget_queue_resize (GTK_WIDGET (self));
}
/**
* gtk_aspect_frame_get_yalign:
* @self: a #GtkAspectFrame
*
* Returns the vertical alignment of the child within the
* allocation of the #GtkAspectFrame.
*
* Returns: the vertical alignment
*/
float
gtk_aspect_frame_get_yalign (GtkAspectFrame *self)
{
g_return_val_if_fail (GTK_IS_ASPECT_FRAME (self), 0.5);
return self->xalign;
}
/**
* gtk_aspect_frame_set_ratio:
* @self: a #GtkAspectFrame
* @ratio: aspect ratio of the child
*
* Sets the desired aspect ratio of the child.
*/
void
gtk_aspect_frame_set_ratio (GtkAspectFrame *self,
float ratio)
{
g_return_if_fail (GTK_IS_ASPECT_FRAME (self));
ratio = CLAMP (ratio, MIN_RATIO, MAX_RATIO);
obey_child = obey_child != FALSE;
if (priv->xalign != xalign
|| priv->yalign != yalign
|| priv->ratio != ratio
|| priv->obey_child != obey_child)
{
g_object_freeze_notify (G_OBJECT (aspect_frame));
if (self->ratio == ratio)
return;
if (priv->xalign != xalign)
{
priv->xalign = xalign;
g_object_notify (G_OBJECT (aspect_frame), "xalign");
}
if (priv->yalign != yalign)
{
priv->yalign = yalign;
g_object_notify (G_OBJECT (aspect_frame), "yalign");
}
if (priv->ratio != ratio)
{
priv->ratio = ratio;
g_object_notify (G_OBJECT (aspect_frame), "ratio");
}
if (priv->obey_child != obey_child)
{
priv->obey_child = obey_child;
g_object_notify (G_OBJECT (aspect_frame), "obey-child");
}
g_object_thaw_notify (G_OBJECT (aspect_frame));
self->ratio = ratio;
g_object_notify (G_OBJECT (self), "ratio");
gtk_widget_queue_resize (GTK_WIDGET (self));
}
/**
* gtk_aspect_frame_get_ratio:
* @self: a #GtkAspectFrame
*
* Returns the desired aspect ratio of the child.
*
* Returns: the desired aspect ratio
*/
float
gtk_aspect_frame_get_ratio (GtkAspectFrame *self)
{
g_return_val_if_fail (GTK_IS_ASPECT_FRAME (self), 1.0);
return self->ratio;
}
/**
* gtk_aspect_frame_set_obey_child:
* @self: a #GtkAspectFrame
* @obey_child: If %TRUE, @ratio is ignored, and the aspect
* ratio is taken from the requistion of the child.
*
* Sets whether the aspect ratio of the childs size
* request should override the set aspect ratio of
* the #GtkAspectFrame.
*/
void
gtk_aspect_frame_set_obey_child (GtkAspectFrame *self,
gboolean obey_child)
{
g_return_if_fail (GTK_IS_ASPECT_FRAME (self));
if (self->obey_child == obey_child)
return;
self->obey_child = obey_child;
g_object_notify (G_OBJECT (self), "obey-child");
gtk_widget_queue_resize (GTK_WIDGET (self));
}
/**
* gtk_aspect_frame_get_obey_child:
* @self: a #GtkAspectFrame
*
* Returns whether the childs size request should override
* the set aspect ratio of the #GtkAspectFrame.
*
* Returns: whether to obey the childs size request
*/
gboolean
gtk_aspect_frame_get_obey_child (GtkAspectFrame *self)
{
g_return_val_if_fail (GTK_IS_ASPECT_FRAME (self), TRUE);
return self->obey_child;
gtk_widget_queue_resize (GTK_WIDGET (aspect_frame));
}
}
static void
get_full_allocation (GtkAspectFrame *self,
GtkAllocation *child_allocation)
gtk_aspect_frame_compute_child_allocation (GtkFrame *frame,
GtkAllocation *child_allocation)
{
child_allocation->x = 0;
child_allocation->y = 0;
child_allocation->width = gtk_widget_get_width (GTK_WIDGET (self));
child_allocation->height = gtk_widget_get_height (GTK_WIDGET (self));
}
static void
compute_child_allocation (GtkAspectFrame *self,
GtkAllocation *child_allocation)
{
GtkBin *bin = GTK_BIN (self);
GtkAspectFrame *aspect_frame = GTK_ASPECT_FRAME (frame);
GtkAspectFramePrivate *priv = gtk_aspect_frame_get_instance_private (aspect_frame);
GtkBin *bin = GTK_BIN (frame);
GtkWidget *child;
gdouble ratio;
@@ -432,7 +351,7 @@ compute_child_allocation (GtkAspectFrame *self,
{
GtkAllocation full_allocation;
if (self->obey_child)
if (priv->obey_child)
{
GtkRequisition child_requisition;
@@ -450,9 +369,9 @@ compute_child_allocation (GtkAspectFrame *self,
ratio = 1.0;
}
else
ratio = self->ratio;
ratio = priv->ratio;
get_full_allocation (self, &full_allocation);
GTK_FRAME_CLASS (gtk_aspect_frame_parent_class)->compute_child_allocation (frame, &full_allocation);
if (ratio * full_allocation.height > full_allocation.width)
{
@@ -465,26 +384,9 @@ compute_child_allocation (GtkAspectFrame *self,
child_allocation->height = full_allocation.height;
}
child_allocation->x = full_allocation.x + self->xalign * (full_allocation.width - child_allocation->width);
child_allocation->y = full_allocation.y + self->yalign * (full_allocation.height - child_allocation->height);
child_allocation->x = full_allocation.x + priv->xalign * (full_allocation.width - child_allocation->width);
child_allocation->y = full_allocation.y + priv->yalign * (full_allocation.height - child_allocation->height);
}
else
get_full_allocation (self, child_allocation);
}
static void
gtk_aspect_frame_size_allocate (GtkWidget *widget,
int width,
int height,
int baseline)
{
GtkAspectFrame *self = GTK_ASPECT_FRAME (widget);
GtkWidget *child;
GtkAllocation new_allocation;
compute_child_allocation (self, &new_allocation);
child = gtk_bin_get_child (GTK_BIN (widget));
if (child && gtk_widget_get_visible (child))
gtk_widget_size_allocate (child, &new_allocation, -1);
GTK_FRAME_CLASS (gtk_aspect_frame_parent_class)->compute_child_allocation (frame, child_allocation);
}
+11 -27
View File
@@ -30,7 +30,7 @@
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/gtkwidget.h>
#include <gtk/gtkframe.h>
G_BEGIN_DECLS
@@ -44,34 +44,18 @@ typedef struct _GtkAspectFrame GtkAspectFrame;
GDK_AVAILABLE_IN_ALL
GType gtk_aspect_frame_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkWidget* gtk_aspect_frame_new (float xalign,
float yalign,
float ratio,
GtkWidget* gtk_aspect_frame_new (const gchar *label,
gfloat xalign,
gfloat yalign,
gfloat ratio,
gboolean obey_child);
GDK_AVAILABLE_IN_ALL
void gtk_aspect_frame_set (GtkAspectFrame *aspect_frame,
gfloat xalign,
gfloat yalign,
gfloat ratio,
gboolean obey_child);
GDK_AVAILABLE_IN_ALL
void gtk_aspect_frame_set_xalign (GtkAspectFrame *self,
float xalign);
GDK_AVAILABLE_IN_ALL
float gtk_aspect_frame_get_xalign (GtkAspectFrame *self);
GDK_AVAILABLE_IN_ALL
void gtk_aspect_frame_set_yalign (GtkAspectFrame *self,
float yalign);
GDK_AVAILABLE_IN_ALL
float gtk_aspect_frame_get_yalign (GtkAspectFrame *self);
GDK_AVAILABLE_IN_ALL
void gtk_aspect_frame_set_ratio (GtkAspectFrame *self,
float ratio);
GDK_AVAILABLE_IN_ALL
float gtk_aspect_frame_get_ratio (GtkAspectFrame *self);
GDK_AVAILABLE_IN_ALL
void gtk_aspect_frame_set_obey_child (GtkAspectFrame *self,
gboolean obey_child);
GDK_AVAILABLE_IN_ALL
gboolean gtk_aspect_frame_get_obey_child (GtkAspectFrame *self);
G_END_DECLS
+42 -34
View File
@@ -57,6 +57,7 @@
#include "gtkactionhelperprivate.h"
#include "gtkcheckbutton.h"
#include "gtkcontainerprivate.h"
#include "gtkgestureclick.h"
#include "gtkeventcontrollerkey.h"
#include "gtkimage.h"
@@ -101,7 +102,7 @@ enum {
enum {
PROP_0,
PROP_LABEL,
PROP_HAS_FRAME,
PROP_RELIEF,
PROP_USE_UNDERLINE,
PROP_ICON_NAME,
@@ -227,12 +228,13 @@ gtk_button_class_init (GtkButtonClass *klass)
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
props[PROP_HAS_FRAME] =
g_param_spec_boolean ("has-frame",
P_("Has Frame"),
P_("Whether the button has a frame"),
TRUE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
props[PROP_RELIEF] =
g_param_spec_enum ("relief",
P_("Border relief"),
P_("The border relief style"),
GTK_TYPE_RELIEF_STYLE,
GTK_RELIEF_NORMAL,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
props[PROP_ICON_NAME] =
g_param_spec_string ("icon-name",
@@ -482,8 +484,8 @@ gtk_button_set_property (GObject *object,
case PROP_LABEL:
gtk_button_set_label (button, g_value_get_string (value));
break;
case PROP_HAS_FRAME:
gtk_button_set_has_frame (button, g_value_get_boolean (value));
case PROP_RELIEF:
gtk_button_set_relief (button, g_value_get_enum (value));
break;
case PROP_USE_UNDERLINE:
gtk_button_set_use_underline (button, g_value_get_boolean (value));
@@ -517,8 +519,8 @@ gtk_button_get_property (GObject *object,
case PROP_LABEL:
g_value_set_string (value, gtk_button_get_label (button));
break;
case PROP_HAS_FRAME:
g_value_set_boolean (value, gtk_button_get_has_frame (button));
case PROP_RELIEF:
g_value_set_enum (value, gtk_button_get_relief (button));
break;
case PROP_USE_UNDERLINE:
g_value_set_boolean (value, priv->use_underline);
@@ -639,45 +641,51 @@ gtk_button_new_with_mnemonic (const gchar *label)
}
/**
* gtk_button_set_has_frame:
* @button: a #GtkButton
* @has_frame: whether the button should have a visible frame
* gtk_button_set_relief:
* @button: The #GtkButton you want to set relief styles of
* @relief: The GtkReliefStyle as described above
*
* Sets the style of the button. Buttons can has a flat appearance
* or have a frame drawn around them.
* Sets the relief style of the edges of the given #GtkButton widget.
* Two styles exist, %GTK_RELIEF_NORMAL and %GTK_RELIEF_NONE.
* The default style is, as one can guess, %GTK_RELIEF_NORMAL.
*/
void
gtk_button_set_has_frame (GtkButton *button,
gboolean has_frame)
gtk_button_set_relief (GtkButton *button,
GtkReliefStyle relief)
{
GtkReliefStyle old_relief;
g_return_if_fail (GTK_IS_BUTTON (button));
if (gtk_button_get_has_frame (button) == has_frame)
return;
old_relief = gtk_button_get_relief (button);
if (old_relief != relief)
{
if (relief == GTK_RELIEF_NONE)
gtk_widget_add_css_class (GTK_WIDGET (button), GTK_STYLE_CLASS_FLAT);
else
gtk_widget_remove_css_class (GTK_WIDGET (button), GTK_STYLE_CLASS_FLAT);
if (has_frame)
gtk_widget_remove_css_class (GTK_WIDGET (button), GTK_STYLE_CLASS_FLAT);
else
gtk_widget_add_css_class (GTK_WIDGET (button), GTK_STYLE_CLASS_FLAT);
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_HAS_FRAME]);
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_RELIEF]);
}
}
/**
* gtk_button_get_has_frame:
* @button: a #GtkButton
* gtk_button_get_relief:
* @button: The #GtkButton you want the #GtkReliefStyle from.
*
* Returns whether the button has a frame.
* Returns the current relief style of the given #GtkButton.
*
* Returns: %TRUE if the button has a frame
* Returns: The current #GtkReliefStyle
*/
gboolean
gtk_button_get_has_frame (GtkButton *button)
GtkReliefStyle
gtk_button_get_relief (GtkButton *button)
{
g_return_val_if_fail (GTK_IS_BUTTON (button), TRUE);
g_return_val_if_fail (GTK_IS_BUTTON (button), GTK_RELIEF_NORMAL);
return !gtk_widget_has_css_class (GTK_WIDGET (button), GTK_STYLE_CLASS_FLAT);
if (gtk_widget_has_css_class (GTK_WIDGET (button), GTK_STYLE_CLASS_FLAT))
return GTK_RELIEF_NONE;
else
return GTK_RELIEF_NORMAL;
}
static void
+3 -3
View File
@@ -86,10 +86,10 @@ GDK_AVAILABLE_IN_ALL
GtkWidget* gtk_button_new_with_mnemonic (const gchar *label);
GDK_AVAILABLE_IN_ALL
void gtk_button_set_has_frame (GtkButton *button,
gboolean has_frame);
void gtk_button_set_relief (GtkButton *button,
GtkReliefStyle relief);
GDK_AVAILABLE_IN_ALL
gboolean gtk_button_get_has_frame (GtkButton *button);
GtkReliefStyle gtk_button_get_relief (GtkButton *button);
GDK_AVAILABLE_IN_ALL
void gtk_button_set_label (GtkButton *button,
const gchar *label);
+40 -76
View File
@@ -1181,31 +1181,13 @@ gtk_calendar_scroll_controller_scroll (GtkEventControllerScroll *scroll,
static void
move_focus (GtkCalendar *calendar,
int direction,
int updown)
gint direction)
{
GtkCalendarPrivate *priv = gtk_calendar_get_instance_private (calendar);
GtkTextDirection text_dir = gtk_widget_get_direction (GTK_WIDGET (calendar));
int x, y;
if (updown == 1)
{
if (priv->focus_row > 0)
priv->focus_row--;
if (priv->focus_row < 0)
priv->focus_row = 5;
if (priv->focus_col < 0)
priv->focus_col = 6;
}
else if (updown == -1)
{
if (priv->focus_row < 5)
priv->focus_row++;
if (priv->focus_col < 0)
priv->focus_col = 0;
}
else if ((text_dir == GTK_TEXT_DIR_LTR && direction == -1) ||
(text_dir == GTK_TEXT_DIR_RTL && direction == 1))
if ((text_dir == GTK_TEXT_DIR_LTR && direction == -1) ||
(text_dir == GTK_TEXT_DIR_RTL && direction == 1))
{
if (priv->focus_col > 0)
priv->focus_col--;
@@ -1235,17 +1217,6 @@ move_focus (GtkCalendar *calendar,
if (priv->focus_row < 0)
priv->focus_row = 0;
}
for (y = 0; y < 6; y ++)
for (x = 0; x < 7; x ++)
{
GtkWidget *label = priv->day_number_labels[y][x];
if (priv->focus_row == y && priv->focus_col == x)
gtk_widget_set_state_flags (label, GTK_STATE_FLAG_FOCUSED, FALSE);
else
gtk_widget_unset_state_flags (label, GTK_STATE_FLAG_FOCUSED);
}
}
static gboolean
@@ -1276,9 +1247,10 @@ gtk_calendar_key_controller_key_pressed (GtkEventControllerKey *controller,
calendar_set_month_prev (calendar);
else
{
move_focus (calendar, -1, 0);
move_focus (calendar, -1);
calendar_invalidate_day (calendar, old_focus_row, old_focus_col);
calendar_invalidate_day (calendar, priv->focus_row, priv->focus_col);
calendar_invalidate_day (calendar, priv->focus_row,
priv->focus_col);
}
break;
case GDK_KEY_KP_Right:
@@ -1288,9 +1260,10 @@ gtk_calendar_key_controller_key_pressed (GtkEventControllerKey *controller,
calendar_set_month_next (calendar);
else
{
move_focus (calendar, 1, 0);
move_focus (calendar, 1);
calendar_invalidate_day (calendar, old_focus_row, old_focus_col);
calendar_invalidate_day (calendar, priv->focus_row, priv->focus_col);
calendar_invalidate_day (calendar, priv->focus_row,
priv->focus_col);
}
break;
case GDK_KEY_KP_Up:
@@ -1300,9 +1273,15 @@ gtk_calendar_key_controller_key_pressed (GtkEventControllerKey *controller,
calendar_set_year_prev (calendar);
else
{
move_focus (calendar, 0, 1);
if (priv->focus_row > 0)
priv->focus_row--;
if (priv->focus_row < 0)
priv->focus_row = 5;
if (priv->focus_col < 0)
priv->focus_col = 6;
calendar_invalidate_day (calendar, old_focus_row, old_focus_col);
calendar_invalidate_day (calendar, priv->focus_row, priv->focus_col);
calendar_invalidate_day (calendar, priv->focus_row,
priv->focus_col);
}
break;
case GDK_KEY_KP_Down:
@@ -1312,9 +1291,13 @@ gtk_calendar_key_controller_key_pressed (GtkEventControllerKey *controller,
calendar_set_year_next (calendar);
else
{
move_focus (calendar, 0, -1);
if (priv->focus_row < 5)
priv->focus_row++;
if (priv->focus_col < 0)
priv->focus_col = 0;
calendar_invalidate_day (calendar, old_focus_row, old_focus_col);
calendar_invalidate_day (calendar, priv->focus_row, priv->focus_col);
calendar_invalidate_day (calendar, priv->focus_row,
priv->focus_col);
}
break;
case GDK_KEY_KP_Space:
@@ -1477,11 +1460,6 @@ gtk_calendar_select_day (GtkCalendar *self,
else
gtk_widget_unset_state_flags (label, GTK_STATE_FLAG_SELECTED);
if (priv->focus_row == y && priv->focus_col == x)
gtk_widget_set_state_flags (label, GTK_STATE_FLAG_FOCUSED, FALSE);
else
gtk_widget_unset_state_flags (label, GTK_STATE_FLAG_FOCUSED);
if (day == today_day &&
priv->day_month[y][x] == MONTH_CURRENT)
gtk_widget_add_css_class (label, "today");
@@ -1635,12 +1613,8 @@ gtk_calendar_unmark_day (GtkCalendar *calendar,
* gtk_calendar_get_date:
* @self: a #GtkCalendar
*
* Returns a #GDateTime representing the shown
* year, month and the selected day, in the local
* time zone.
*
* Returns: (transfer full): the #GDate representing
* the shown date.
* Returns: (transfer full): A #GDateTime representing the shown
* year, month and the selected day, in the local time zone.
*/
GDateTime *
gtk_calendar_get_date (GtkCalendar *self)
@@ -1653,9 +1627,9 @@ gtk_calendar_get_date (GtkCalendar *self)
}
/**
* gtk_calendar_set_show_week_numbers:
* gtk_calendar_set_show_week_numbers
* @self: a #GtkCalendar
* @value: whether to show week numbers on the left of the days
* @value: Whether to show week numbers on the left of the days
*
* Sets whether week numbers are shown in the calendar.
*/
@@ -1684,11 +1658,8 @@ gtk_calendar_set_show_week_numbers (GtkCalendar *self,
* gtk_calendar_get_show_week_numbers:
* @self: a #GtkCalendar
*
* Returns whether @self is showing week numbers right
* now, i.e. the value of the #GtkCalendar:show-week-numbers
* property.
*
* Return: Whether the calendar is showing week numbers.
* Returns: Whether @self is showing week numbers right now,
* i.e. the value of the #GtkCalendar:show-week-numbers property.
*/
gboolean
gtk_calendar_get_show_week_numbers (GtkCalendar *self)
@@ -1703,11 +1674,9 @@ gtk_calendar_get_show_week_numbers (GtkCalendar *self)
/**
* gtk_calendar_set_show_heading:
* @self: a #GtkCalendar
* @value: Whether to show the heading in the calendar
*
* Sets whether the calendar should show a heading
* containing the current year and month as well as
* buttons for changing both.
* @value: Whether to show the heading in the calendar,
* containing the current year and month as well as
* buttons for changing both.
*/
void
gtk_calendar_set_show_heading (GtkCalendar *self,
@@ -1731,10 +1700,8 @@ gtk_calendar_set_show_heading (GtkCalendar *self,
* gtk_calendar_get_show_heading:
* @self: a #GtkCalendar
*
* Returns whether @self is currently showing the heading,
* i.e. the value of the #GtkCalendar:show-heading property.
*
* Return: Whether the calendar is showing a heading.
* Returns: Whether @self is currently showing the heading,
* i.e. the value of the #GtkCalendar:show-heading property.
*/
gboolean
gtk_calendar_get_show_heading (GtkCalendar *self)
@@ -1749,9 +1716,8 @@ gtk_calendar_get_show_heading (GtkCalendar *self)
/**
* gtk_calendar_set_show_day_names:
* @self: a #GtkCalendar
* @value: Whether to show day names above the day numbers
*
* Sets whether the calendar shows day names.
* @value: Whether to show week day names above the
* day numbers
*/
void
gtk_calendar_set_show_day_names (GtkCalendar *self,
@@ -1775,14 +1741,12 @@ gtk_calendar_set_show_day_names (GtkCalendar *self,
}
/**
* gtk_calendar_get_show_day_names:
* gtk_calendar_get_day_names:
* @self: a #GtkCalendar
*
* Returns whether @self is currently showing the names
* of the week days above the day numbers, i.e. the value
* of the #GtkCalendar:show-day-names property.
*
* Returns: Whether the calendar shows day names.
* Returns: Whether @self is currently showing the names
* of the week days above the day numbers, i.e. the value
* of the #GtkCalendar:show-day-names property.
*/
gboolean
gtk_calendar_get_show_day_names (GtkCalendar *self)
-9
View File
@@ -568,7 +568,6 @@ gtk_center_layout_set_orientation (GtkCenterLayout *self,
* gtk_center_layout_get_orientation:
* @self: a #GtkCenterLayout
*
* Gets the current orienration of the layout manager.
*
* Returns: The current orientation of @self
*/
@@ -600,8 +599,6 @@ gtk_center_layout_set_baseline_position (GtkCenterLayout *self,
* gtk_center_layout_get_baseline_position:
* @self: a #GtkCenterLayout
*
* Returns the baseline position of the layout.
*
* Returns: The current baseline position of @self.
*/
GtkBaselinePosition
@@ -628,8 +625,6 @@ gtk_center_layout_set_start_widget (GtkCenterLayout *self,
* gtk_center_layout_get_start_widget:
* @self: a #GtkCenterLayout
*
* Returns the start widget fo the layout.
*
* Returns: (transfer none): The current start widget of @self
*/
GtkWidget *
@@ -656,8 +651,6 @@ gtk_center_layout_set_center_widget (GtkCenterLayout *self,
* gtk_center_layout_get_center_widget:
* @self: a #GtkCenterLayout
*
* Returns the center widget of the layout.
*
* Returns: (transfer none): the current center widget of @self
*/
GtkWidget *
@@ -684,8 +677,6 @@ gtk_center_layout_set_end_widget (GtkCenterLayout *self,
* gtk_center_layout_get_end_widget:
* @self: a #GtkCenterLayout
*
* Returns the end widget of the layout.
*
* Returns: (transfer none): the current end widget of @self
*/
GtkWidget *
+1
View File
@@ -33,6 +33,7 @@
#include "gtkprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtkcontainerprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkradiobutton.h"
-3
View File
@@ -794,9 +794,6 @@ add_custom_color (GtkColorChooserWidget *cc,
{
GtkWidget *last = gtk_widget_get_last_child (cc->custom);
if (last == (GtkWidget *)cc->current)
cc->current = NULL;
gtk_container_remove (GTK_CONTAINER (cc->custom), last);
}
g_list_free (children);
+109 -89
View File
@@ -53,12 +53,8 @@
* be removed for non-activatable swatches.
*/
typedef struct _GtkColorSwatchClass GtkColorSwatchClass;
struct _GtkColorSwatch
typedef struct
{
GtkWidget parent_instance;
GdkRGBA color;
gdouble radius[4];
gchar *icon;
@@ -71,15 +67,7 @@ struct _GtkColorSwatch
GtkWidget *popover;
GtkDropTarget *dest;
};
struct _GtkColorSwatchClass
{
GtkWidgetClass parent_class;
void ( * activate) (GtkColorSwatch *swatch);
void ( * customize) (GtkColorSwatch *swatch);
};
} GtkColorSwatchPrivate;
enum
{
@@ -90,7 +78,7 @@ enum
PROP_CAN_DROP
};
G_DEFINE_TYPE (GtkColorSwatch, gtk_color_swatch, GTK_TYPE_WIDGET)
G_DEFINE_TYPE_WITH_PRIVATE (GtkColorSwatch, gtk_color_swatch, GTK_TYPE_WIDGET)
#define INTENSITY(r, g, b) ((r) * 0.30 + (g) * 0.59 + (b) * 0.11)
static void
@@ -98,22 +86,23 @@ swatch_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
const int width = gtk_widget_get_width (widget);
const int height = gtk_widget_get_height (widget);
const GdkRGBA *color;
color = &swatch->color;
if (swatch->dest)
color = &priv->color;
if (priv->dest)
{
const GValue *value = gtk_drop_target_get_value (swatch->dest);
const GValue *value = gtk_drop_target_get_value (priv->dest);
if (value)
color = g_value_get_boxed (value);
}
if (swatch->has_color)
if (priv->has_color)
{
if (swatch->use_alpha && !gdk_rgba_is_opaque (color))
if (priv->use_alpha && !gdk_rgba_is_opaque (color))
{
_gtk_color_chooser_snapshot_checkered_pattern (snapshot, width, height);
@@ -133,7 +122,7 @@ swatch_snapshot (GtkWidget *widget,
}
}
gtk_widget_snapshot_child (widget, swatch->overlay_widget, snapshot);
gtk_widget_snapshot_child (widget, priv->overlay_widget, snapshot);
}
static gboolean
@@ -152,12 +141,13 @@ swatch_drag_drop (GtkDropTarget *dest,
static void
activate_color (GtkColorSwatch *swatch)
{
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
double red, green, blue, alpha;
red = swatch->color.red;
green = swatch->color.green;
blue = swatch->color.blue;
alpha = swatch->color.alpha;
red = priv->color.red;
green = priv->color.green;
blue = priv->color.blue;
alpha = priv->color.alpha;
gtk_widget_activate_action (GTK_WIDGET (swatch),
"color.select", "(dddd)", red, green, blue, alpha);
@@ -166,12 +156,13 @@ activate_color (GtkColorSwatch *swatch)
static void
customize_color (GtkColorSwatch *swatch)
{
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
double red, green, blue, alpha;
red = swatch->color.red;
green = swatch->color.green;
blue = swatch->color.blue;
alpha = swatch->color.alpha;
red = priv->color.red;
green = priv->color.green;
blue = priv->color.blue;
alpha = priv->color.alpha;
gtk_widget_activate_action (GTK_WIDGET (swatch),
"color.customize", "(dddd)", red, green, blue, alpha);
@@ -185,6 +176,7 @@ key_controller_key_pressed (GtkEventControllerKey *controller,
GtkWidget *widget)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
if (keyval == GDK_KEY_space ||
keyval == GDK_KEY_Return ||
@@ -192,8 +184,8 @@ key_controller_key_pressed (GtkEventControllerKey *controller,
keyval == GDK_KEY_KP_Enter ||
keyval == GDK_KEY_KP_Space)
{
if (swatch->has_color &&
swatch->selectable &&
if (priv->has_color &&
priv->selectable &&
(gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_SELECTED) == 0)
gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_SELECTED, FALSE);
else
@@ -208,16 +200,17 @@ key_controller_key_pressed (GtkEventControllerKey *controller,
static GMenuModel *
gtk_color_swatch_get_menu_model (GtkColorSwatch *swatch)
{
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
GMenu *menu, *section;
GMenuItem *item;
double red, green, blue, alpha;
menu = g_menu_new ();
red = swatch->color.red;
green = swatch->color.green;
blue = swatch->color.blue;
alpha = swatch->color.alpha;
red = priv->color.red;
green = priv->color.green;
blue = priv->color.blue;
alpha = priv->color.alpha;
section = g_menu_new ();
item = g_menu_item_new (_("Customize"), NULL);
@@ -235,31 +228,33 @@ gtk_color_swatch_get_menu_model (GtkColorSwatch *swatch)
static void
do_popup (GtkColorSwatch *swatch)
{
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
GMenuModel *model;
g_clear_pointer (&swatch->popover, gtk_widget_unparent);
g_clear_pointer (&priv->popover, gtk_widget_unparent);
model = gtk_color_swatch_get_menu_model (swatch);
swatch->popover = gtk_popover_menu_new_from_model (model);
gtk_widget_set_parent (swatch->popover, GTK_WIDGET (swatch));
priv->popover = gtk_popover_menu_new_from_model (model);
gtk_widget_set_parent (priv->popover, GTK_WIDGET (swatch));
g_object_unref (model);
gtk_popover_popup (GTK_POPOVER (swatch->popover));
gtk_popover_popup (GTK_POPOVER (priv->popover));
}
static gboolean
swatch_primary_action (GtkColorSwatch *swatch)
{
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
GtkWidget *widget = (GtkWidget *)swatch;
GtkStateFlags flags;
flags = gtk_widget_get_state_flags (widget);
if (!swatch->has_color)
if (!priv->has_color)
{
customize_color (swatch);
return TRUE;
}
else if (swatch->selectable &&
else if (priv->selectable &&
(flags & GTK_STATE_FLAG_SELECTED) == 0)
{
gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_SELECTED, FALSE);
@@ -286,6 +281,7 @@ tap_action (GtkGestureClick *gesture,
gdouble y,
GtkColorSwatch *swatch)
{
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
guint button;
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
@@ -299,7 +295,7 @@ tap_action (GtkGestureClick *gesture,
}
else if (button == GDK_BUTTON_SECONDARY)
{
if (swatch->has_color && swatch->has_menu)
if (priv->has_color && priv->has_menu)
do_popup (swatch);
}
}
@@ -311,15 +307,16 @@ swatch_size_allocate (GtkWidget *widget,
int baseline)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
gtk_widget_size_allocate (swatch->overlay_widget,
gtk_widget_size_allocate (priv->overlay_widget,
&(GtkAllocation) {
0, 0,
width, height
}, -1);
if (swatch->popover)
gtk_native_check_resize (GTK_NATIVE (swatch->popover));
if (priv->popover)
gtk_native_check_resize (GTK_NATIVE (priv->popover));
}
static void
@@ -332,9 +329,10 @@ gtk_color_swatch_measure (GtkWidget *widget,
int *natural_baseline)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
gint w, h, min;
gtk_widget_measure (swatch->overlay_widget,
gtk_widget_measure (priv->overlay_widget,
orientation,
-1,
minimum, natural,
@@ -361,10 +359,11 @@ swatch_popup_menu (GtkWidget *widget,
static void
update_icon (GtkColorSwatch *swatch)
{
GtkImage *image = GTK_IMAGE (swatch->overlay_widget);
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
GtkImage *image = GTK_IMAGE (priv->overlay_widget);
if (swatch->icon)
gtk_image_set_from_icon_name (image, swatch->icon);
if (priv->icon)
gtk_image_set_from_icon_name (image, priv->icon);
else if (gtk_widget_get_state_flags (GTK_WIDGET (swatch)) & GTK_STATE_FLAG_SELECTED)
gtk_image_set_from_icon_name (image, "object-select-symbolic");
else
@@ -391,6 +390,7 @@ swatch_get_property (GObject *object,
GParamSpec *pspec)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (object);
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
GdkRGBA color;
switch (prop_id)
@@ -403,10 +403,10 @@ swatch_get_property (GObject *object,
g_value_set_boolean (value, gtk_color_swatch_get_selectable (swatch));
break;
case PROP_HAS_MENU:
g_value_set_boolean (value, swatch->has_menu);
g_value_set_boolean (value, priv->has_menu);
break;
case PROP_CAN_DROP:
g_value_set_boolean (value, swatch->dest != NULL);
g_value_set_boolean (value, priv->dest != NULL);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -421,6 +421,7 @@ swatch_set_property (GObject *object,
GParamSpec *pspec)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (object);
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
switch (prop_id)
{
@@ -431,7 +432,7 @@ swatch_set_property (GObject *object,
gtk_color_swatch_set_selectable (swatch, g_value_get_boolean (value));
break;
case PROP_HAS_MENU:
swatch->has_menu = g_value_get_boolean (value);
priv->has_menu = g_value_get_boolean (value);
break;
case PROP_CAN_DROP:
gtk_color_swatch_set_can_drop (swatch, g_value_get_boolean (value));
@@ -446,9 +447,10 @@ static void
swatch_finalize (GObject *object)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (object);
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
g_free (swatch->icon);
gtk_widget_unparent (swatch->overlay_widget);
g_free (priv->icon);
gtk_widget_unparent (priv->overlay_widget);
G_OBJECT_CLASS (gtk_color_swatch_parent_class)->finalize (object);
}
@@ -457,8 +459,9 @@ static void
swatch_dispose (GObject *object)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (object);
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
g_clear_pointer (&swatch->popover, gtk_widget_unparent);
g_clear_pointer (&priv->popover, gtk_widget_unparent);
G_OBJECT_CLASS (gtk_color_swatch_parent_class)->dispose (object);
}
@@ -517,16 +520,17 @@ gtk_color_swatch_class_init (GtkColorSwatchClass *class)
static void
gtk_color_swatch_init (GtkColorSwatch *swatch)
{
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
GtkEventController *controller;
GtkGesture *gesture;
swatch->use_alpha = TRUE;
swatch->selectable = TRUE;
swatch->has_menu = TRUE;
swatch->color.red = 0.75;
swatch->color.green = 0.25;
swatch->color.blue = 0.25;
swatch->color.alpha = 1.0;
priv->use_alpha = TRUE;
priv->selectable = TRUE;
priv->has_menu = TRUE;
priv->color.red = 0.75;
priv->color.green = 0.25;
priv->color.blue = 0.25;
priv->color.alpha = 1.0;
gtk_widget_set_can_focus (GTK_WIDGET (swatch), TRUE);
gtk_widget_set_overflow (GTK_WIDGET (swatch), GTK_OVERFLOW_HIDDEN);
@@ -551,10 +555,10 @@ gtk_color_swatch_init (GtkColorSwatch *swatch)
gtk_widget_add_css_class (GTK_WIDGET (swatch), "activatable");
swatch->overlay_widget = g_object_new (GTK_TYPE_IMAGE,
priv->overlay_widget = g_object_new (GTK_TYPE_IMAGE,
"css-name", "overlay",
NULL);
gtk_widget_set_parent (swatch->overlay_widget, GTK_WIDGET (swatch));
gtk_widget_set_parent (priv->overlay_widget, GTK_WIDGET (swatch));
}
/* Public API {{{1 */
@@ -571,14 +575,18 @@ gtk_color_swatch_drag_prepare (GtkDragSource *source,
double y,
GtkColorSwatch *swatch)
{
return gdk_content_provider_new_typed (GDK_TYPE_RGBA, &swatch->color);
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
return gdk_content_provider_new_typed (GDK_TYPE_RGBA, &priv->color);
}
void
gtk_color_swatch_set_rgba (GtkColorSwatch *swatch,
const GdkRGBA *color)
{
if (!swatch->has_color)
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
if (!priv->has_color)
{
GtkDragSource *source;
@@ -588,10 +596,10 @@ gtk_color_swatch_set_rgba (GtkColorSwatch *swatch,
gtk_widget_add_controller (GTK_WIDGET (swatch), GTK_EVENT_CONTROLLER (source));
}
swatch->has_color = TRUE;
swatch->color = *color;
priv->has_color = TRUE;
priv->color = *color;
if (INTENSITY (swatch->color.red, swatch->color.green, swatch->color.blue) > 0.5)
if (INTENSITY (priv->color.red, priv->color.green, priv->color.blue) > 0.5)
{
gtk_widget_add_css_class (GTK_WIDGET (swatch), "light");
gtk_widget_remove_css_class (GTK_WIDGET (swatch), "dark");
@@ -610,12 +618,14 @@ gboolean
gtk_color_swatch_get_rgba (GtkColorSwatch *swatch,
GdkRGBA *color)
{
if (swatch->has_color)
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
if (priv->has_color)
{
color->red = swatch->color.red;
color->green = swatch->color.green;
color->blue = swatch->color.blue;
color->alpha = swatch->color.alpha;
color->red = priv->color.red;
color->green = priv->color.green;
color->blue = priv->color.blue;
color->alpha = priv->color.alpha;
return TRUE;
}
else
@@ -632,7 +642,9 @@ void
gtk_color_swatch_set_icon (GtkColorSwatch *swatch,
const gchar *icon)
{
swatch->icon = g_strdup (icon);
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
priv->icon = g_strdup (icon);
update_icon (swatch);
gtk_widget_queue_draw (GTK_WIDGET (swatch));
}
@@ -641,21 +653,23 @@ void
gtk_color_swatch_set_can_drop (GtkColorSwatch *swatch,
gboolean can_drop)
{
if (can_drop == (swatch->dest != NULL))
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
if (can_drop == (priv->dest != NULL))
return;
if (can_drop && !swatch->dest)
if (can_drop && !priv->dest)
{
swatch->dest = gtk_drop_target_new (GDK_TYPE_RGBA, GDK_ACTION_COPY);
gtk_drop_target_set_preload (swatch->dest, TRUE);
g_signal_connect (swatch->dest, "drop", G_CALLBACK (swatch_drag_drop), swatch);
g_signal_connect_swapped (swatch->dest, "notify::value", G_CALLBACK (gtk_widget_queue_draw), swatch);
gtk_widget_add_controller (GTK_WIDGET (swatch), GTK_EVENT_CONTROLLER (swatch->dest));
priv->dest = gtk_drop_target_new (GDK_TYPE_RGBA, GDK_ACTION_COPY);
gtk_drop_target_set_preload (priv->dest, TRUE);
g_signal_connect (priv->dest, "drop", G_CALLBACK (swatch_drag_drop), swatch);
g_signal_connect_swapped (priv->dest, "notify::value", G_CALLBACK (gtk_widget_queue_draw), swatch);
gtk_widget_add_controller (GTK_WIDGET (swatch), GTK_EVENT_CONTROLLER (priv->dest));
}
if (!can_drop && swatch->dest)
if (!can_drop && priv->dest)
{
gtk_widget_remove_controller (GTK_WIDGET (swatch), GTK_EVENT_CONTROLLER (swatch->dest));
swatch->dest = NULL;
gtk_widget_remove_controller (GTK_WIDGET (swatch), GTK_EVENT_CONTROLLER (priv->dest));
priv->dest = NULL;
}
g_object_notify (G_OBJECT (swatch), "can-drop");
@@ -665,7 +679,9 @@ void
gtk_color_swatch_set_use_alpha (GtkColorSwatch *swatch,
gboolean use_alpha)
{
swatch->use_alpha = use_alpha;
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
priv->use_alpha = use_alpha;
gtk_widget_queue_draw (GTK_WIDGET (swatch));
}
@@ -673,17 +689,21 @@ void
gtk_color_swatch_set_selectable (GtkColorSwatch *swatch,
gboolean selectable)
{
if (selectable == swatch->selectable)
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
if (selectable == priv->selectable)
return;
swatch->selectable = selectable;
priv->selectable = selectable;
g_object_notify (G_OBJECT (swatch), "selectable");
}
gboolean
gtk_color_swatch_get_selectable (GtkColorSwatch *swatch)
{
return swatch->selectable;
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
return priv->selectable;
}
/* vim:set foldmethod=marker: */
+24
View File
@@ -24,10 +24,34 @@ G_BEGIN_DECLS
#define GTK_TYPE_COLOR_SWATCH (gtk_color_swatch_get_type ())
#define GTK_COLOR_SWATCH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COLOR_SWATCH, GtkColorSwatch))
#define GTK_COLOR_SWATCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_COLOR_SWATCH, GtkColorSwatchClass))
#define GTK_IS_COLOR_SWATCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COLOR_SWATCH))
#define GTK_IS_COLOR_SWATCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_COLOR_SWATCH))
#define GTK_COLOR_SWATCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_COLOR_SWATCH, GtkColorSwatchClass))
typedef struct _GtkColorSwatch GtkColorSwatch;
typedef struct _GtkColorSwatchClass GtkColorSwatchClass;
struct _GtkColorSwatch
{
GtkWidget parent_instance;
};
struct _GtkColorSwatchClass
{
GtkWidgetClass parent_class;
void ( * activate) (GtkColorSwatch *swatch);
void ( * customize) (GtkColorSwatch *swatch);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
GType gtk_color_swatch_get_type (void) G_GNUC_CONST;
GtkWidget * gtk_color_swatch_new (void);
+306
View File
@@ -24,6 +24,8 @@
#include "config.h"
#include "gtkcontainerprivate.h"
#include "gtkadjustment.h"
#include "gtkbuildable.h"
#include "gtkbuilderprivate.h"
@@ -84,6 +86,14 @@
* See more about implementing custom widgets at https://wiki.gnome.org/HowDoI/CustomWidgets
*/
struct _GtkContainerPrivate
{
guint resize_handler;
guint restyle_pending : 1;
};
enum {
ADD,
REMOVE,
@@ -99,6 +109,8 @@ static void gtk_container_remove_unimplemented (GtkContainer *container
static void gtk_container_compute_expand (GtkWidget *widget,
gboolean *hexpand_p,
gboolean *vexpand_p);
static void gtk_container_real_set_focus_child (GtkContainer *container,
GtkWidget *widget);
static void gtk_container_children_callback (GtkWidget *widget,
gpointer client_data);
static GtkSizeRequestMode gtk_container_get_request_mode (GtkWidget *widget);
@@ -107,9 +119,12 @@ static GtkSizeRequestMode gtk_container_get_request_mode (GtkWidget *widget);
static void gtk_container_buildable_init (GtkBuildableIface *iface);
static GtkBuildableIface *parent_buildable_iface;
static GQuark vadjustment_key_id;
static GQuark hadjustment_key_id;
static guint container_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GtkContainer, gtk_container, GTK_TYPE_WIDGET,
G_ADD_PRIVATE (GtkContainer)
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
gtk_container_buildable_init))
@@ -119,6 +134,9 @@ gtk_container_class_init (GtkContainerClass *class)
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
vadjustment_key_id = g_quark_from_static_string ("gtk-vadjustment");
hadjustment_key_id = g_quark_from_static_string ("gtk-hadjustment");
widget_class->destroy = gtk_container_destroy;
widget_class->compute_expand = gtk_container_compute_expand;
widget_class->get_request_mode = gtk_container_get_request_mode;
@@ -128,6 +146,7 @@ gtk_container_class_init (GtkContainerClass *class)
class->add = gtk_container_add_unimplemented;
class->remove = gtk_container_remove_unimplemented;
class->forall = NULL;
class->set_focus_child = gtk_container_real_set_focus_child;
class->child_type = NULL;
container_signals[ADD] =
@@ -225,6 +244,10 @@ static void
gtk_container_destroy (GtkWidget *widget)
{
GtkContainer *container = GTK_CONTAINER (widget);
GtkContainerPrivate *priv = gtk_container_get_instance_private (container);
if (priv->restyle_pending)
priv->restyle_pending = FALSE;
gtk_container_foreach (container, (GtkCallback) gtk_widget_destroy, NULL);
@@ -309,6 +332,113 @@ gtk_container_remove (GtkContainer *container,
g_object_unref (container);
}
static gboolean
gtk_container_needs_idle_sizer (GtkContainer *container)
{
GtkContainerPrivate *priv = gtk_container_get_instance_private (container);
if (priv->restyle_pending)
return TRUE;
return gtk_widget_needs_allocate (GTK_WIDGET (container));
}
static void
gtk_container_idle_sizer (GdkFrameClock *clock,
GtkContainer *container)
{
GtkContainerPrivate *priv = gtk_container_get_instance_private (container);
/* We validate the style contexts in a single loop before even trying
* to handle resizes instead of doing validations inline.
* This is mostly necessary for compatibility reasons with old code,
* because both css_changed and size_allocate functions often change
* styles and so could cause infinite loops in this function.
*
* It's important to note that even an invalid style context returns
* sane values. So the result of an invalid style context will never be
* a program crash, but only a wrong layout or rendering.
*/
if (priv->restyle_pending)
{
priv->restyle_pending = FALSE;
gtk_css_node_validate (gtk_widget_get_css_node (GTK_WIDGET (container)));
}
/* we may be invoked with a container_resize_queue of NULL, because
* queue_resize could have been adding an extra idle function while
* the queue still got processed. we better just ignore such case
* than trying to explicitly work around them with some extra flags,
* since it doesn't cause any actual harm.
*/
if (gtk_widget_needs_allocate (GTK_WIDGET (container)))
{
if (GTK_IS_ROOT (container))
gtk_native_check_resize (GTK_NATIVE (container));
else
g_warning ("gtk_container_idle_sizer() called on a non-native non-window");
}
if (!gtk_container_needs_idle_sizer (container))
{
gtk_container_stop_idle_sizer (container);
}
else
{
gdk_frame_clock_request_phase (clock,
GDK_FRAME_CLOCK_PHASE_LAYOUT);
}
}
void
gtk_container_start_idle_sizer (GtkContainer *container)
{
GtkContainerPrivate *priv = gtk_container_get_instance_private (container);
GdkFrameClock *clock;
if (priv->resize_handler != 0)
return;
if (!gtk_container_needs_idle_sizer (container))
return;
clock = gtk_widget_get_frame_clock (GTK_WIDGET (container));
if (clock == NULL)
return;
priv->resize_handler = g_signal_connect (clock, "layout",
G_CALLBACK (gtk_container_idle_sizer), container);
gdk_frame_clock_request_phase (clock,
GDK_FRAME_CLOCK_PHASE_LAYOUT);
}
void
gtk_container_stop_idle_sizer (GtkContainer *container)
{
GtkContainerPrivate *priv = gtk_container_get_instance_private (container);
if (priv->resize_handler == 0)
return;
g_signal_handler_disconnect (gtk_widget_get_frame_clock (GTK_WIDGET (container)),
priv->resize_handler);
priv->resize_handler = 0;
}
void
_gtk_container_queue_restyle (GtkContainer *container)
{
GtkContainerPrivate *priv = gtk_container_get_instance_private (container);
g_return_if_fail (GTK_CONTAINER (container));
if (priv->restyle_pending)
return;
priv->restyle_pending = TRUE;
gtk_container_start_idle_sizer (container);
}
static GtkSizeRequestMode
gtk_container_get_request_mode (GtkWidget *widget)
{
@@ -399,6 +529,31 @@ gtk_container_foreach (GtkContainer *container,
GTK_CONTAINER_GET_CLASS (container)->forall (container, callback, callback_data);
}
/**
* gtk_container_set_focus_child:
* @container: a #GtkContainer
* @child: (allow-none): a #GtkWidget, or %NULL
*
* Sets, or unsets if @child is %NULL, the focused child of @container.
*
* This function emits the GtkContainer::set_focus_child signal of
* @container. Implementations of #GtkContainer can override the
* default behaviour by overriding the class closure of this signal.
*
* This is function is mostly meant to be used by widgets. Applications can use
* gtk_widget_grab_focus() to manually set the focus to a specific widget.
*/
void
gtk_container_set_focus_child (GtkContainer *container,
GtkWidget *child)
{
g_return_if_fail (GTK_IS_CONTAINER (container));
if (child)
g_return_if_fail (GTK_IS_WIDGET (child));
GTK_CONTAINER_GET_CLASS (container)->set_focus_child (container, child);
}
/**
* gtk_container_get_children:
* @container: a #GtkContainer
@@ -452,6 +607,46 @@ gtk_container_compute_expand (GtkWidget *widget,
*vexpand_p = vexpand;
}
static void
gtk_container_real_set_focus_child (GtkContainer *container,
GtkWidget *focus_child)
{
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (focus_child == NULL || GTK_IS_WIDGET (focus_child));
/* Check for h/v adjustments and scroll to show the focus child if possible */
if (focus_child)
{
GtkAdjustment *hadj;
GtkAdjustment *vadj;
gint x, y;
hadj = g_object_get_qdata (G_OBJECT (container), hadjustment_key_id);
vadj = g_object_get_qdata (G_OBJECT (container), vadjustment_key_id);
if (hadj || vadj)
{
GtkWidget *child = focus_child;
graphene_rect_t child_bounds;
while (gtk_widget_get_focus_child (child))
child = gtk_widget_get_focus_child (child);
if (!gtk_widget_translate_coordinates (child, focus_child,
0, 0, &x, &y))
return;
if (!gtk_widget_compute_bounds (child, child, &child_bounds))
return;
if (vadj)
gtk_adjustment_clamp_page (vadj, y, y + child_bounds.size.height);
if (hadj)
gtk_adjustment_clamp_page (hadj, x, x + child_bounds.size.width);
}
}
}
static void
gtk_container_children_callback (GtkWidget *widget,
gpointer client_data)
@@ -461,3 +656,114 @@ gtk_container_children_callback (GtkWidget *widget,
children = (GList**) client_data;
*children = g_list_prepend (*children, widget);
}
/**
* gtk_container_set_focus_vadjustment:
* @container: a #GtkContainer
* @adjustment: an adjustment which should be adjusted when the focus
* is moved among the descendents of @container
*
* Hooks up an adjustment to focus handling in a container, so when a
* child of the container is focused, the adjustment is scrolled to
* show that widget. This function sets the vertical alignment. See
* gtk_scrolled_window_get_vadjustment() for a typical way of obtaining
* the adjustment and gtk_container_set_focus_hadjustment() for setting
* the horizontal adjustment.
*
* The adjustments have to be in pixel units and in the same coordinate
* system as the allocation for immediate children of the container.
*/
void
gtk_container_set_focus_vadjustment (GtkContainer *container,
GtkAdjustment *adjustment)
{
g_return_if_fail (GTK_IS_CONTAINER (container));
if (adjustment)
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
if (adjustment)
g_object_ref (adjustment);
g_object_set_qdata_full (G_OBJECT (container),
vadjustment_key_id,
adjustment,
g_object_unref);
}
/**
* gtk_container_get_focus_vadjustment:
* @container: a #GtkContainer
*
* Retrieves the vertical focus adjustment for the container. See
* gtk_container_set_focus_vadjustment().
*
* Returns: (nullable) (transfer none): the vertical focus adjustment, or
* %NULL if none has been set.
**/
GtkAdjustment *
gtk_container_get_focus_vadjustment (GtkContainer *container)
{
GtkAdjustment *vadjustment;
g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
vadjustment = g_object_get_qdata (G_OBJECT (container), vadjustment_key_id);
return vadjustment;
}
/**
* gtk_container_set_focus_hadjustment:
* @container: a #GtkContainer
* @adjustment: an adjustment which should be adjusted when the focus is
* moved among the descendents of @container
*
* Hooks up an adjustment to focus handling in a container, so when a child
* of the container is focused, the adjustment is scrolled to show that
* widget. This function sets the horizontal alignment.
* See gtk_scrolled_window_get_hadjustment() for a typical way of obtaining
* the adjustment and gtk_container_set_focus_vadjustment() for setting
* the vertical adjustment.
*
* The adjustments have to be in pixel units and in the same coordinate
* system as the allocation for immediate children of the container.
*/
void
gtk_container_set_focus_hadjustment (GtkContainer *container,
GtkAdjustment *adjustment)
{
g_return_if_fail (GTK_IS_CONTAINER (container));
if (adjustment)
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
if (adjustment)
g_object_ref (adjustment);
g_object_set_qdata_full (G_OBJECT (container),
hadjustment_key_id,
adjustment,
g_object_unref);
}
/**
* gtk_container_get_focus_hadjustment:
* @container: a #GtkContainer
*
* Retrieves the horizontal focus adjustment for the container. See
* gtk_container_set_focus_hadjustment ().
*
* Returns: (nullable) (transfer none): the horizontal focus adjustment, or %NULL if
* none has been set.
**/
GtkAdjustment *
gtk_container_get_focus_hadjustment (GtkContainer *container)
{
GtkAdjustment *hadjustment;
g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
hadjustment = g_object_get_qdata (G_OBJECT (container), hadjustment_key_id);
return hadjustment;
}
+17
View File
@@ -58,7 +58,10 @@ struct _GtkContainer
* @remove: Signal emitted when a widget is removed from container.
* @forall: Invokes callback on each child of container. The callback handler
* may remove the child.
* @set_focus_child: Sets the focused child of container.
* @child_type: Returns the type of the children supported by the container.
* @set_child_property: Set a property on a child of container.
* @get_child_property: Get a property from a child of container.
*
* Base class for containers.
*/
@@ -75,6 +78,8 @@ struct _GtkContainerClass
void (*forall) (GtkContainer *container,
GtkCallback callback,
gpointer callback_data);
void (*set_focus_child) (GtkContainer *container,
GtkWidget *child);
GType (*child_type) (GtkContainer *container);
@@ -103,6 +108,18 @@ void gtk_container_foreach (GtkContainer *container,
GDK_AVAILABLE_IN_ALL
GList* gtk_container_get_children (GtkContainer *container);
/* Widget-level methods */
GDK_AVAILABLE_IN_ALL
void gtk_container_set_focus_vadjustment (GtkContainer *container,
GtkAdjustment *adjustment);
GDK_AVAILABLE_IN_ALL
GtkAdjustment *gtk_container_get_focus_vadjustment (GtkContainer *container);
GDK_AVAILABLE_IN_ALL
void gtk_container_set_focus_hadjustment (GtkContainer *container,
GtkAdjustment *adjustment);
GDK_AVAILABLE_IN_ALL
GtkAdjustment *gtk_container_get_focus_hadjustment (GtkContainer *container);
GDK_AVAILABLE_IN_ALL
GType gtk_container_child_type (GtkContainer *container);
+38
View File
@@ -0,0 +1,38 @@
/* GTK - The GIMP Toolkit
*
* Copyright (C) 2011 Javier Jardón
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_CONTAINER_PRIVATE_H__
#define __GTK_CONTAINER_PRIVATE_H__
#include "gtkcontainer.h"
#include <gsk/gsk.h>
G_BEGIN_DECLS
void _gtk_container_queue_restyle (GtkContainer *container);
void gtk_container_stop_idle_sizer (GtkContainer *container);
void gtk_container_start_idle_sizer (GtkContainer *container);
void gtk_container_set_focus_child (GtkContainer *container,
GtkWidget *child);
G_END_DECLS
#endif /* __GTK_CONTAINER_PRIVATE_H__ */
+3 -3
View File
@@ -248,10 +248,10 @@ gtk_css_value_dimension_transition (GtkCssValue *start,
guint property_id,
double progress)
{
if (start->unit == end->unit)
return gtk_css_dimension_value_new (start->value + (end->value - start->value) * progress, start->unit);
if (start->unit != end->unit)
return NULL;
return gtk_css_number_value_transition (start, end, property_id, progress);
return gtk_css_dimension_value_new (start->value + (end->value - start->value) * progress, start->unit);
}
static const GtkCssNumberValueClass GTK_CSS_VALUE_DIMENSION = {
+2 -2
View File
@@ -703,7 +703,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FILTER = {
gtk_css_value_filter_print
};
static GtkCssValue filter_none_singleton = { &GTK_CSS_VALUE_FILTER, 1, TRUE, 0, { { GTK_CSS_FILTER_NONE } } };
static GtkCssValue none_singleton = { &GTK_CSS_VALUE_FILTER, 1, TRUE, 0, { { GTK_CSS_FILTER_NONE } } };
static GtkCssValue *
gtk_css_filter_value_alloc (guint n_filters)
@@ -721,7 +721,7 @@ gtk_css_filter_value_alloc (guint n_filters)
GtkCssValue *
gtk_css_filter_value_new_none (void)
{
return _gtk_css_value_ref (&filter_none_singleton);
return _gtk_css_value_ref (&none_singleton);
}
static gboolean
+2 -2
View File
@@ -136,11 +136,11 @@ static const GtkCssValueClass GTK_CSS_VALUE_IMAGE = {
GtkCssValue *
_gtk_css_image_value_new (GtkCssImage *image)
{
static GtkCssValue image_none_singleton = { &GTK_CSS_VALUE_IMAGE, 1, TRUE, NULL };
static GtkCssValue none_singleton = { &GTK_CSS_VALUE_IMAGE, 1, TRUE, NULL };
GtkCssValue *value;
if (image == NULL)
return _gtk_css_value_ref (&image_none_singleton);
return _gtk_css_value_ref (&none_singleton);
value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_IMAGE);
value->image = image;
+16 -36
View File
@@ -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);
}
}
+1 -2
View File
@@ -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
+2
View File
@@ -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
+13 -2
View File
@@ -1282,8 +1282,6 @@ gtk_css_selector_parse_selector_pseudo_class (GtkCssParser *parser,
{ "link", GTK_STATE_FLAG_LINK, },
{ "visited", GTK_STATE_FLAG_VISITED, },
{ "checked", GTK_STATE_FLAG_CHECKED, },
{ "focus-visible", GTK_STATE_FLAG_FOCUS_VISIBLE, },
{ "focus-within", GTK_STATE_FLAG_FOCUS_WITHIN, },
};
guint i;
@@ -1450,6 +1448,19 @@ gtk_css_selector_parse_selector_pseudo_class (GtkCssParser *parser,
selector);
selector->state.state = GTK_STATE_FLAG_DROP_ACTIVE;
}
else if (gtk_css_token_is_function (token, "focus"))
{
if (!gtk_css_parser_consume_function (parser, 1, 1, parse_identifier_arg, (gpointer) "visible"))
{
if (selector)
_gtk_css_selector_free (selector);
return NULL;
}
selector = gtk_css_selector_new (negate ? &GTK_CSS_SELECTOR_NOT_PSEUDOCLASS_STATE
: &GTK_CSS_SELECTOR_PSEUDOCLASS_STATE,
selector);
selector->state.state = GTK_STATE_FLAG_FOCUS_VISIBLE;
}
else
{
gtk_css_parser_error (parser,
+2 -2
View File
@@ -288,12 +288,12 @@ static const GtkCssValueClass GTK_CSS_VALUE_SHADOW = {
gtk_css_value_shadow_print
};
static GtkCssValue shadow_none_singleton = { &GTK_CSS_VALUE_SHADOW, 1, TRUE, 0 };
static GtkCssValue none_singleton = { &GTK_CSS_VALUE_SHADOW, 1, TRUE, 0 };
GtkCssValue *
gtk_css_shadow_value_new_none (void)
{
return _gtk_css_value_ref (&shadow_none_singleton);
return _gtk_css_value_ref (&none_singleton);
}
static GtkCssValue *
+46 -55
View File
@@ -412,16 +412,11 @@ add_pango_attr (PangoAttrList *attrs,
}
static void
append_separated (GString **s,
const char *text)
append_separated (GString *s, const char *text)
{
if (G_UNLIKELY (!*s))
*s = g_string_new (NULL);
if ((*s)->len > 0)
g_string_append (*s, ", ");
g_string_append (*s, text);
if (s->len > 0)
g_string_append (s, ", ");
g_string_append (s, text);
}
PangoAttrList *
@@ -477,15 +472,15 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
/* OpenType features */
s = NULL;
s = g_string_new ("");
switch (_gtk_css_font_kerning_value_get (style->font_variant->font_kerning))
{
case GTK_CSS_FONT_KERNING_NORMAL:
append_separated (&s, "kern 1");
append_separated (s, "kern 1");
break;
case GTK_CSS_FONT_KERNING_NONE:
append_separated (&s, "kern 0");
append_separated (s, "kern 0");
break;
case GTK_CSS_FONT_KERNING_AUTO:
default:
@@ -498,34 +493,34 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
/* all defaults */
}
else if (ligatures == GTK_CSS_FONT_VARIANT_LIGATURE_NONE)
append_separated (&s, "liga 0, clig 0, dlig 0, hlig 0, calt 0");
append_separated (s, "liga 0, clig 0, dlig 0, hlig 0, calt 0");
else
{
if (ligatures & GTK_CSS_FONT_VARIANT_LIGATURE_COMMON_LIGATURES)
append_separated (&s, "liga 1, clig 1");
append_separated (s, "liga 1, clig 1");
if (ligatures & GTK_CSS_FONT_VARIANT_LIGATURE_NO_COMMON_LIGATURES)
append_separated (&s, "liga 0, clig 0");
append_separated (s, "liga 0, clig 0");
if (ligatures & GTK_CSS_FONT_VARIANT_LIGATURE_DISCRETIONARY_LIGATURES)
append_separated (&s, "dlig 1");
append_separated (s, "dlig 1");
if (ligatures & GTK_CSS_FONT_VARIANT_LIGATURE_NO_DISCRETIONARY_LIGATURES)
append_separated (&s, "dlig 0");
append_separated (s, "dlig 0");
if (ligatures & GTK_CSS_FONT_VARIANT_LIGATURE_HISTORICAL_LIGATURES)
append_separated (&s, "hlig 1");
append_separated (s, "hlig 1");
if (ligatures & GTK_CSS_FONT_VARIANT_LIGATURE_NO_HISTORICAL_LIGATURES)
append_separated (&s, "hlig 0");
append_separated (s, "hlig 0");
if (ligatures & GTK_CSS_FONT_VARIANT_LIGATURE_CONTEXTUAL)
append_separated (&s, "calt 1");
append_separated (s, "calt 1");
if (ligatures & GTK_CSS_FONT_VARIANT_LIGATURE_NO_CONTEXTUAL)
append_separated (&s, "calt 0");
append_separated (s, "calt 0");
}
switch (_gtk_css_font_variant_position_value_get (style->font_variant->font_variant_position))
{
case GTK_CSS_FONT_VARIANT_POSITION_SUB:
append_separated (&s, "subs 1");
append_separated (s, "subs 1");
break;
case GTK_CSS_FONT_VARIANT_POSITION_SUPER:
append_separated (&s, "sups 1");
append_separated (s, "sups 1");
break;
case GTK_CSS_FONT_VARIANT_POSITION_NORMAL:
default:
@@ -535,22 +530,22 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
switch (_gtk_css_font_variant_caps_value_get (style->font_variant->font_variant_caps))
{
case GTK_CSS_FONT_VARIANT_CAPS_SMALL_CAPS:
append_separated (&s, "smcp 1");
append_separated (s, "smcp 1");
break;
case GTK_CSS_FONT_VARIANT_CAPS_ALL_SMALL_CAPS:
append_separated (&s, "c2sc 1, smcp 1");
append_separated (s, "c2sc 1, smcp 1");
break;
case GTK_CSS_FONT_VARIANT_CAPS_PETITE_CAPS:
append_separated (&s, "pcap 1");
append_separated (s, "pcap 1");
break;
case GTK_CSS_FONT_VARIANT_CAPS_ALL_PETITE_CAPS:
append_separated (&s, "c2pc 1, pcap 1");
append_separated (s, "c2pc 1, pcap 1");
break;
case GTK_CSS_FONT_VARIANT_CAPS_UNICASE:
append_separated (&s, "unic 1");
append_separated (s, "unic 1");
break;
case GTK_CSS_FONT_VARIANT_CAPS_TITLING_CAPS:
append_separated (&s, "titl 1");
append_separated (s, "titl 1");
break;
case GTK_CSS_FONT_VARIANT_CAPS_NORMAL:
default:
@@ -565,27 +560,27 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
else
{
if (numeric & GTK_CSS_FONT_VARIANT_NUMERIC_LINING_NUMS)
append_separated (&s, "lnum 1");
append_separated (s, "lnum 1");
if (numeric & GTK_CSS_FONT_VARIANT_NUMERIC_OLDSTYLE_NUMS)
append_separated (&s, "onum 1");
append_separated (s, "onum 1");
if (numeric & GTK_CSS_FONT_VARIANT_NUMERIC_PROPORTIONAL_NUMS)
append_separated (&s, "pnum 1");
append_separated (s, "pnum 1");
if (numeric & GTK_CSS_FONT_VARIANT_NUMERIC_TABULAR_NUMS)
append_separated (&s, "tnum 1");
append_separated (s, "tnum 1");
if (numeric & GTK_CSS_FONT_VARIANT_NUMERIC_DIAGONAL_FRACTIONS)
append_separated (&s, "frac 1");
append_separated (s, "frac 1");
if (numeric & GTK_CSS_FONT_VARIANT_NUMERIC_STACKED_FRACTIONS)
append_separated (&s, "afrc 1");
append_separated (s, "afrc 1");
if (numeric & GTK_CSS_FONT_VARIANT_NUMERIC_ORDINAL)
append_separated (&s, "ordn 1");
append_separated (s, "ordn 1");
if (numeric & GTK_CSS_FONT_VARIANT_NUMERIC_SLASHED_ZERO)
append_separated (&s, "zero 1");
append_separated (s, "zero 1");
}
switch (_gtk_css_font_variant_alternate_value_get (style->font_variant->font_variant_alternates))
{
case GTK_CSS_FONT_VARIANT_ALTERNATE_HISTORICAL_FORMS:
append_separated (&s, "hist 1");
append_separated (s, "hist 1");
break;
case GTK_CSS_FONT_VARIANT_ALTERNATE_NORMAL:
default:
@@ -600,37 +595,34 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
else
{
if (east_asian & GTK_CSS_FONT_VARIANT_EAST_ASIAN_JIS78)
append_separated (&s, "jp78 1");
append_separated (s, "jp78 1");
if (east_asian & GTK_CSS_FONT_VARIANT_EAST_ASIAN_JIS83)
append_separated (&s, "jp83 1");
append_separated (s, "jp83 1");
if (east_asian & GTK_CSS_FONT_VARIANT_EAST_ASIAN_JIS90)
append_separated (&s, "jp90 1");
append_separated (s, "jp90 1");
if (east_asian & GTK_CSS_FONT_VARIANT_EAST_ASIAN_JIS04)
append_separated (&s, "jp04 1");
append_separated (s, "jp04 1");
if (east_asian & GTK_CSS_FONT_VARIANT_EAST_ASIAN_SIMPLIFIED)
append_separated (&s, "smpl 1");
append_separated (s, "smpl 1");
if (east_asian & GTK_CSS_FONT_VARIANT_EAST_ASIAN_TRADITIONAL)
append_separated (&s, "trad 1");
append_separated (s, "trad 1");
if (east_asian & GTK_CSS_FONT_VARIANT_EAST_ASIAN_FULL_WIDTH)
append_separated (&s, "fwid 1");
append_separated (s, "fwid 1");
if (east_asian & GTK_CSS_FONT_VARIANT_EAST_ASIAN_PROPORTIONAL)
append_separated (&s, "pwid 1");
append_separated (s, "pwid 1");
if (east_asian & GTK_CSS_FONT_VARIANT_EAST_ASIAN_RUBY)
append_separated (&s, "ruby 1");
append_separated (s, "ruby 1");
}
settings = gtk_css_font_features_value_get_features (style->font->font_feature_settings);
if (settings)
{
append_separated (&s, settings);
append_separated (s, settings);
g_free (settings);
}
if (s)
{
attrs = add_pango_attr (attrs, pango_attr_font_features_new (s->str));
g_string_free (s, TRUE);
}
attrs = add_pango_attr (attrs, pango_attr_font_features_new (s->str));
g_string_free (s, TRUE);
return attrs;
}
@@ -680,8 +672,7 @@ gtk_css_style_get_pango_font (GtkCssStyle *style)
v = style->font->font_variation_settings;
str = gtk_css_font_variations_value_get_variations (v);
if (str)
pango_font_description_set_variations (description, str);
pango_font_description_set_variations (description, str);
g_free (str);
return description;
+2 -2
View File
@@ -800,7 +800,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_TRANSFORM = {
gtk_css_value_transform_print
};
static GtkCssValue transform_none_singleton = { &GTK_CSS_VALUE_TRANSFORM, 1, TRUE, 0, { { GTK_CSS_TRANSFORM_NONE } } };
static GtkCssValue none_singleton = { &GTK_CSS_VALUE_TRANSFORM, 1, TRUE, 0, { { GTK_CSS_TRANSFORM_NONE } } };
static GtkCssValue *
gtk_css_transform_value_alloc (guint n_transforms)
@@ -818,7 +818,7 @@ gtk_css_transform_value_alloc (guint n_transforms)
GtkCssValue *
_gtk_css_transform_value_new_none (void)
{
return _gtk_css_value_ref (&transform_none_singleton);
return _gtk_css_value_ref (&none_singleton);
}
static gboolean
+1 -2
View File
@@ -232,8 +232,7 @@ gtk_css_pseudoclass_name (GtkStateFlags state)
"visited",
"checked",
"drop(active)",
"focus-visible",
"focus-within"
"focus(visible)"
};
guint i;
+5 -3
View File
@@ -19,12 +19,12 @@
#include "gtkcsswidgetnodeprivate.h"
#include "gtkcontainerprivate.h"
#include "gtkcssanimatedstyleprivate.h"
#include "gtkprivate.h"
#include "gtksettingsprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkwindowprivate.h"
G_DEFINE_TYPE (GtkCssWidgetNode, gtk_css_widget_node, GTK_TYPE_CSS_NODE)
@@ -46,7 +46,7 @@ gtk_css_widget_node_queue_callback (GtkWidget *widget,
GtkCssNode *node = user_data;
gtk_css_node_invalidate_frame_clock (node, TRUE);
gtk_window_queue_restyle (GTK_WINDOW (widget));
_gtk_container_queue_restyle (GTK_CONTAINER (widget));
return G_SOURCE_CONTINUE;
}
@@ -56,7 +56,9 @@ gtk_css_widget_node_queue_validate (GtkCssNode *node)
{
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
if (widget_node->widget && GTK_IS_ROOT (widget_node->widget))
if (widget_node->widget &&
GTK_IS_ROOT (widget_node->widget) &&
GTK_IS_CONTAINER (widget_node->widget))
widget_node->validate_cb_id = gtk_widget_add_tick_callback (widget_node->widget,
gtk_css_widget_node_queue_callback,
node,

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