Compare commits

...

35 Commits

Author SHA1 Message Date
Matthias Clasen
05e8057b5b Fix gtk_column_view_sort_by_column
We must clear the current sort columns before
setting the new one, to prevent double arrows
in the headers.

Fixes: #4696
2022-04-18 20:37:04 -04:00
Matthias Clasen
e89365e9e3 gtk-builder-tool: Error out if screenshooting fails
If we don't produce a texture for whatever reason,
apologize and fail.
2022-04-18 11:16:05 -04:00
Timm Bäder
6484807719 Merge branch 'badcel/fix-typo' into 'main'
docs: Fix typo in description of GtkExpression

See merge request GNOME/gtk!4647
2022-04-18 09:27:05 +00:00
Marcel Tiede
527ff05107 docs: Fix typo in description of GtkExpression 2022-04-18 06:20:19 +00:00
Matthias Clasen
b89cfdb77f Merge branch 'screenshot-command' into 'main'
gtk-builder-tool: Add a screenshot command

See merge request GNOME/gtk!4645
2022-04-17 17:40:46 +00:00
Matthias Clasen
499687a11d gtk-builder-tool: Add a screenshot command
This is an obvious variation of the preview
command. It can save a .ui file as either
.png or .node.
2022-04-17 12:57:46 -04:00
Matthias Clasen
c5e26dd591 gtk-builder-tool: Reshuffle --help
Use GOptionContext better.
2022-04-17 12:57:46 -04:00
Matthias Clasen
bc17d1d5ea Merge branch 'wip/exalm/scrolled-window' into 'main'
scrolledwindow: Pick up gtk-overlay-scrolling changes on the fly

See merge request GNOME/gtk!4642
2022-04-17 16:07:59 +00:00
Matthias Clasen
b88ac0890e gtk-builder-tool: Small reshuffle
Move the display check into the preview command.
2022-04-17 11:23:00 -04:00
Matthias Clasen
d30baf34b3 Merge branch 'filechooser-entry-popup' into 'main'
filechooser: Prevent random completion popups

See merge request GNOME/gtk!4643
2022-04-17 03:51:32 +00:00
Matthias Clasen
b927ad2c87 Merge branch 'filechooser-save-sensitive' into 'main'
filechooser: Small fix for save mode

Closes #4851

See merge request GNOME/gtk!4644
2022-04-17 03:31:39 +00:00
Matthias Clasen
4540dac11a filechooser: Prevent random completion popups
It is very irritating when the entry completion popup
appears not in response to user input in the entry.
In particular, when that happens right as the dialog
is shown.

To prevent that, temporarily disable completion
when setting the entry text programmatically.
2022-04-16 23:29:04 -04:00
Matthias Clasen
aa9cac695d filechooser: Small fix for save mode
When changing folders, we were making the select
button insensitive when there's no files around.
That doesn't make sense in save mode when we don't
want to select a file but create one.

Fixes: #4851
2022-04-16 22:00:22 -04:00
Alexander Mikhaylenko
52412ca944 scrolledwindow: Pick up gtk-overlay-scrolling changes on the fly 2022-04-16 16:56:17 +04:00
Alexander Mikhaylenko
cd82b18cfd scrolledwindow: Fix :kinetic-scrolling setter 2022-04-16 16:30:33 +04:00
Matthias Clasen
da5bb6ff22 Merge branch 'wip/exalm/tooltip' into 'main'
tooltipwindow: Don't restrict minimum tooltip label length

Closes #3741

See merge request GNOME/gtk!4640
2022-04-16 00:07:21 +00:00
Alexander Mikhaylenko
7871f1e13b tooltipwindow: Don't restrict minimum tooltip label length
We only care about wrapping at that length, we still want short tooltips
for short labels.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3741
2022-04-16 03:48:21 +04:00
Alexander Mikhaylenko
dd18c7dedf tooltipwindow: Remove a duplicate gtk_widget_class_set_css_name() call 2022-04-16 03:28:50 +04:00
Matthias Clasen
a34a6e9b84 Merge branch 'ebassi/for-main' into 'main'
docs: Fix the GtkPaned style

See merge request GNOME/gtk!4637
2022-04-15 00:09:42 +00:00
Emmanuele Bassi
0a5f29c9eb Mark nullable arguments in GtkPaned
The set_start_child() and set_end_child() methods take NULL for the
child argument, as a way to remove the child from the paned widget.
2022-04-14 22:44:17 +01:00
Emmanuele Bassi
417be0719b docs: Fix the GtkPaned style
Use proper links to properties and methods, and drop gtk-doc'isms.
2022-04-14 22:43:40 +01:00
Matthias Clasen
3263a26cad Merge branch 'fix_tooltip' into 'main'
label: Maintain value for `has-tooltip` for labels with links

See merge request GNOME/gtk!4635
2022-04-14 18:00:43 +00:00
Matthias Clasen
00916c2b47 Merge branch 'fix_link_tabs' into 'main'
label: Move focus out of widget after last link

Closes #4681

See merge request GNOME/gtk!4636
2022-04-14 11:36:19 +00:00
Julian Sparber
e3320633a6 label: Move focus out of widget after last link
This allows the user to navigate via tab the links in a label and exits
the widget after the last link, when moving forward, and first link,
when moving backward.

This also ensures that ellipsised links arn't focused.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4681
2022-04-14 12:48:20 +02:00
Julian Sparber
764a8cea59 label: Maintain value for has-tooltip for labels with links
The `has-tooltip` property gets set to `false` for label with links if no
link is selected. This makes sure to only change the property to `true`
but never to `false`.
2022-04-13 19:05:53 +02:00
Benjamin Otte
a2599c2bb9 Merge branch 'clarify-scrollable-docs' into 'main'
scrollable: Clarify when to set adjustment props

See merge request GNOME/gtk!4632
2022-04-12 23:48:55 +00:00
Ivan Molodetskikh
e2675306e1 scrollable: Clarify when to set adjustment props
Instead of populating the properties right away (when the widget might
not have been allocated yet, and hence cannot know the right values),
the widget should queue an allocation, where it will populate the
values.
2022-04-12 17:22:51 +03:00
Benjamin Otte
7d1429cb91 Merge branch 'gles-win32' into 'main'
Inspector: Fix running on Windows with GLES (was: fix running GL demos with GLES on Windows)

See merge request GNOME/gtk!4595
2022-04-08 22:00:33 +00:00
Matthias Clasen
f13a018739 Merge branch 'matthiasc/for-main' into 'main'
gsk/gl: Typo fix

See merge request GNOME/gtk!4628
2022-04-08 16:14:43 +00:00
Matthias Clasen
84b3b1fab5 gsk/gl: Typo fix 2022-04-08 11:20:12 -04:00
Luca Bacci
048bb6db6f Merge branch 'gdk-win32-fix-mouse-move-crossing-events' into 'main'
GdkWin32: Mouse events fixes

Closes #4722 and #4813

See merge request GNOME/gtk!4620
2022-04-08 08:31:14 +00:00
Luca Bacci
cb0c1b3f08 GdkWin32: Generate crossing event after button release
Fixes #4813
2022-04-06 20:27:46 +02:00
Luca Bacci
91f200167e GdkWin32: Correct generation of crossing events when holding an implicit grab
Fixes #4722
2022-04-06 20:27:32 +02:00
Luca Bacci
2b6fb005a8 GdkWin32: Report serial for events 2022-04-06 19:45:50 +02:00
Chun-wei Fan
89d87e3482 inspector/general.c: Check whether GL context supports WGL
We may well be using an EGL context that does not support Desktop (W)GL on
Windows, such as in the case of using libANGLE.  So, check whether WGL is
supported for this running instance before trying to query WGL extensions.

This will get rid of warning messages from libepoxy.
2022-03-30 16:09:18 +08:00
21 changed files with 676 additions and 185 deletions

View File

@@ -16,6 +16,7 @@ SYNOPSIS
| **gtk4-builder-tool** enumerate <FILE>
| **gtk4-builder-tool** simplify [OPTIONS...] <FILE>
| **gtk4-builder-tool** preview [OPTIONS...] <FILE>
| **gtk4-builder-tool** screenshot [OPTIONS...] <FILE>
DESCRIPTION
-----------
@@ -41,7 +42,7 @@ definition file.
Preview
^^^^^^^
The ``preview`` command displays the UI dfinition file.
The ``preview`` command displays the UI definition file.
This command accepts options to specify the ID of the toplevel object and a CSS
file to use.
@@ -55,6 +56,33 @@ file to use.
Load style information from the given CSS file.
Screenshot
^^^^^^^^^^
The ``screenshot`` command saves a rendering of the UI definition file
as a png image or node file. The name of the file to write can be specified as
a second FILE argument.
This command accepts options to specify the ID of the toplevel object and a CSS
file to use.
``--id=ID``
The ID of the object to preview. If not specified, gtk4-builder-tool will
choose a suitable object on its own.
``--css=FILE``
Load style information from the given CSS file.
``--node``
Write a serialized node file instead of a png image.
``--force``
Overwrite an existing file.
Simplification
^^^^^^^^^^^^^^

View File

@@ -873,6 +873,7 @@ _gdk_win32_append_event (GdkEvent *event)
{
GdkDisplay *display;
GList *link;
gulong serial;
display = gdk_display_get_default ();
@@ -880,8 +881,9 @@ _gdk_win32_append_event (GdkEvent *event)
#if 1
link = _gdk_event_queue_append (display, event);
GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
serial = _gdk_display_get_next_serial (display);
/* event morphing, the passed in may not be valid afterwards */
_gdk_windowing_got_event (display, link, event, 0);
_gdk_windowing_got_event (display, link, event, serial);
#else
_gdk_event_queue_append (display, event);
GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
@@ -2242,6 +2244,10 @@ gdk_event_translate (MSG *msg,
button = 5;
buttonup0:
{
gboolean release_implicit_grab = FALSE;
GdkSurface *prev_surface = NULL;
GDK_NOTE (EVENTS,
g_print (" (%d,%d)",
GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
@@ -2251,41 +2257,18 @@ gdk_event_translate (MSG *msg,
g_set_object (&window, find_window_for_mouse_event (window, msg));
if (pointer_grab != NULL && pointer_grab->implicit)
{
int state = build_pointer_event_state (msg);
{
int state = build_pointer_event_state (msg);
/* We keep the implicit grab until no buttons at all are held down */
if ((state & GDK_ANY_BUTTON_MASK & ~(GDK_BUTTON1_MASK << (button - 1))) == 0)
{
ReleaseCapture ();
/* We keep the implicit grab until no buttons at all are held down */
if ((state & GDK_ANY_BUTTON_MASK & ~(GDK_BUTTON1_MASK << (button - 1))) == 0)
{
release_implicit_grab = TRUE;
prev_surface = pointer_grab->surface;
}
}
new_window = NULL;
hwnd = WindowFromPoint (msg->pt);
if (hwnd != NULL)
{
POINT client_pt = msg->pt;
ScreenToClient (hwnd, &client_pt);
GetClientRect (hwnd, &rect);
if (PtInRect (&rect, client_pt))
new_window = gdk_win32_handle_table_lookup (hwnd);
}
synthesize_crossing_events (display,
_gdk_device_manager->system_pointer,
pointer_grab->surface, new_window,
GDK_CROSSING_UNGRAB,
&msg->pt,
0, /* TODO: Set right mask */
_gdk_win32_get_next_tick (msg->time),
FALSE);
g_set_object (&mouse_window, new_window);
mouse_window_ignored_leave = NULL;
}
}
generate_button_event (GDK_BUTTON_RELEASE, button,
window, msg);
generate_button_event (GDK_BUTTON_RELEASE, button, window, msg);
impl = GDK_WIN32_SURFACE (window);
@@ -2294,8 +2277,37 @@ gdk_event_translate (MSG *msg,
impl->drag_move_resize_context.button == button)
gdk_win32_surface_end_move_resize_drag (window);
if (release_implicit_grab)
{
ReleaseCapture ();
new_window = NULL;
hwnd = WindowFromPoint (msg->pt);
if (hwnd != NULL)
{
POINT client_pt = msg->pt;
ScreenToClient (hwnd, &client_pt);
GetClientRect (hwnd, &rect);
if (PtInRect (&rect, client_pt))
new_window = gdk_win32_handle_table_lookup (hwnd);
}
synthesize_crossing_events (display,
_gdk_device_manager->system_pointer,
prev_surface, new_window,
GDK_CROSSING_UNGRAB,
&msg->pt,
0, /* TODO: Set right mask */
_gdk_win32_get_next_tick (msg->time),
FALSE);
g_set_object (&mouse_window, new_window);
mouse_window_ignored_leave = NULL;
}
return_val = TRUE;
break;
}
case WM_MOUSEMOVE:
GDK_NOTE (EVENTS,
@@ -2320,60 +2332,35 @@ gdk_event_translate (MSG *msg,
pen_touch_input = FALSE;
new_window = window;
g_set_object (&window, find_window_for_mouse_event (window, msg));
if (pointer_grab != NULL)
{
POINT pt;
pt = msg->pt;
new_window = NULL;
hwnd = WindowFromPoint (pt);
if (hwnd != NULL)
{
POINT client_pt = pt;
ScreenToClient (hwnd, &client_pt);
GetClientRect (hwnd, &rect);
if (PtInRect (&rect, client_pt))
new_window = gdk_win32_handle_table_lookup (hwnd);
}
if (!pointer_grab->owner_events &&
new_window != NULL &&
new_window != pointer_grab->surface)
new_window = NULL;
}
if (mouse_window != new_window)
if (mouse_window != window)
{
GDK_NOTE (EVENTS, g_print (" mouse_window %p -> %p",
mouse_window ? GDK_SURFACE_HWND (mouse_window) : NULL,
new_window ? GDK_SURFACE_HWND (new_window) : NULL));
window ? GDK_SURFACE_HWND (window) : NULL));
synthesize_crossing_events (display,
_gdk_device_manager->system_pointer,
mouse_window, new_window,
mouse_window, window,
GDK_CROSSING_NORMAL,
&msg->pt,
0, /* TODO: Set right mask */
_gdk_win32_get_next_tick (msg->time),
FALSE);
g_set_object (&mouse_window, new_window);
g_set_object (&mouse_window, window);
mouse_window_ignored_leave = NULL;
if (new_window != NULL)
track_mouse_event (TME_LEAVE, GDK_SURFACE_HWND (new_window));
if (window != NULL)
track_mouse_event (TME_LEAVE, GDK_SURFACE_HWND (window));
}
else if (new_window != NULL &&
new_window == mouse_window_ignored_leave)
else if (window != NULL && window == mouse_window_ignored_leave)
{
/* If we ignored a leave event for this window and we're now getting
input again we need to re-arm the mouse tracking, as that was
cancelled by the mouseleave. */
mouse_window_ignored_leave = NULL;
track_mouse_event (TME_LEAVE, GDK_SURFACE_HWND (new_window));
track_mouse_event (TME_LEAVE, GDK_SURFACE_HWND (window));
}
g_set_object (&window, find_window_for_mouse_event (window, msg));
impl = GDK_WIN32_SURFACE (window);
/* If we haven't moved, don't create any GDK event. Windows

View File

@@ -796,7 +796,7 @@ gsk_gl_driver_load_texture (GskGLDriver *self,
* to upload data, map to a framebuffer, or other uses which may
* modify the texture immediately.
*
* Typical examples for @format are GK_RGBA8, GL_RGBA16F or GL_RGBA32F.
* Typical examples for @format are GL_RGBA8, GL_RGBA16F or GL_RGBA32F.
*
* Use gsk_gl_driver_release_texture() to release this texture back into
* the pool so it may be reused later in the pipeline.

View File

@@ -1703,9 +1703,8 @@ gtk_column_view_sort_by_column (GtkColumnView *self,
g_return_if_fail (column == NULL || GTK_IS_COLUMN_VIEW_COLUMN (column));
g_return_if_fail (column == NULL || gtk_column_view_column_get_column_view (column) == self);
if (column == NULL)
gtk_column_view_sorter_clear (GTK_COLUMN_VIEW_SORTER (self->sorter));
else
gtk_column_view_sorter_clear (GTK_COLUMN_VIEW_SORTER (self->sorter));
if (column != NULL)
gtk_column_view_sorter_set_column (GTK_COLUMN_VIEW_SORTER (self->sorter),
column,
direction == GTK_SORT_DESCENDING);

View File

@@ -125,7 +125,7 @@
* a `GtkExpression` object is needed like in a `<property>` tag for an expression
* property, or in a `<binding name="property">` tag to bind a property to an expression.
*
* To create an property expression, use the `<lookup>` element. It can have a `type`
* To create a property expression, use the `<lookup>` element. It can have a `type`
* attribute to specify the object type, and a `name` attribute to specify the property
* to look up. The content of `<lookup>` can either be an element specfiying the expression
* to use the object, or a string that specifies the name of the object to use.

View File

@@ -2193,7 +2193,7 @@ update_default (GtkFileChooserWidget *impl)
return;
files = gtk_file_chooser_get_files (GTK_FILE_CHOOSER (impl));
sensitive = (g_list_model_get_n_items (files) > 0);
sensitive = (g_list_model_get_n_items (files) > 0 || impl->action == GTK_FILE_CHOOSER_ACTION_SAVE);
gtk_widget_set_sensitive (button, sensitive);
g_object_unref (files);
@@ -4748,9 +4748,15 @@ update_chooser_entry (GtkFileChooserWidget *impl)
if (change_entry && !impl->auto_selecting_first_row)
{
GtkEntryCompletion *completion = gtk_entry_get_completion (GTK_ENTRY (impl->location_entry));
if (completion)
gtk_entry_completion_set_popup_completion (completion, FALSE);
g_signal_handlers_block_by_func (impl->location_entry, G_CALLBACK (location_entry_changed_cb), impl);
gtk_editable_set_text (GTK_EDITABLE (impl->location_entry), impl->browse_files_last_selected_name);
g_signal_handlers_unblock_by_func (impl->location_entry, G_CALLBACK (location_entry_changed_cb), impl);
if (completion)
gtk_entry_completion_set_popup_completion (completion, TRUE);
if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
_gtk_file_chooser_entry_select_filename (GTK_FILE_CHOOSER_ENTRY (impl->location_entry));

View File

@@ -1793,6 +1793,7 @@ gtk_label_focus (GtkWidget *widget,
{
info->selection_anchor = focus_link->start;
info->selection_end = focus_link->start;
break;
}
}
}
@@ -1856,7 +1857,6 @@ gtk_label_focus (GtkWidget *widget,
{
int focus_link_index;
int new_index = -1;
int i;
if (info->n_links == 0)
goto out;
@@ -1870,29 +1870,39 @@ gtk_label_focus (GtkWidget *widget,
{
case GTK_DIR_TAB_FORWARD:
if (focus_link)
new_index = (focus_link_index + 1) % info->n_links;
new_index = focus_link_index + 1;
else
new_index = 0;
for (i = new_index; i < info->n_links; i++)
if (new_index >= info->n_links)
goto out;
while (new_index < info->n_links)
{
const GtkLabelLink *link = &info->links[i];
const GtkLabelLink *link = &info->links[new_index];
if (!range_is_in_ellipsis (self, link->start, link->end))
break;
new_index++;
}
break;
case GTK_DIR_TAB_BACKWARD:
if (focus_link)
new_index = focus_link_index == 0 ? info->n_links - 1 : focus_link_index - 1;
new_index = focus_link_index - 1;
else
new_index = info->n_links - 1;
for (i = new_index; i >= 0; i--)
if (new_index < 0)
goto out;
while (new_index >= 0)
{
const GtkLabelLink *link = &info->links[i];
const GtkLabelLink *link = &info->links[new_index];
if (!range_is_in_ellipsis (self, link->start, link->end))
break;
new_index--;
}
break;
@@ -1904,7 +1914,7 @@ gtk_label_focus (GtkWidget *widget,
goto out;
}
if (new_index != -1)
if (new_index != -1 && new_index < info->n_links)
{
focus_link = &info->links[new_index];
info->selection_anchor = focus_link->start;
@@ -3615,7 +3625,11 @@ static void
gtk_label_ensure_has_tooltip (GtkLabel *self)
{
guint i;
gboolean has_tooltip = FALSE;
gboolean has_tooltip = gtk_widget_get_has_tooltip(GTK_WIDGET(self));
if (has_tooltip) {
return;
}
for (i = 0; i < self->select_info->n_links; i++)
{

View File

@@ -44,7 +44,7 @@
/**
* GtkPaned:
*
* `GtkPaned` has two panes, arranged either horizontally or vertically.
* A widget with two panes, arranged either horizontally or vertically.
*
* ![An example GtkPaned](panes.png)
*
@@ -63,13 +63,13 @@
* each child inside a [class@Gtk.Frame] so that the gutter appears as a
* ridge. No separator is drawn if one of the children is missing.
*
* Each child has two options that can be set, @resize and @shrink. If
* @resize is true, then when the `GtkPaned` is resized, that child will
* expand or shrink along with the paned widget. If @shrink is true, then
* Each child has two options that can be set, "resize" and "shrink". If
* "resize" is true then, when the `GtkPaned` is resized, that child will
* expand or shrink along with the paned widget. If "shrink" is true, then
* that child can be made smaller than its requisition by the user.
* Setting @shrink to %FALSE allows the application to set a minimum size.
* If @resize is false for both children, then this is treated as if
* @resize is true for both children.
* Setting "shrink" to false allows the application to set a minimum size.
* If "resize" is false for both children, then this is treated as if
* "resize" is true for both children.
*
* The application can set the position of the slider as if it were set
* by the user, by calling [method@Gtk.Paned.set_position].
@@ -431,7 +431,7 @@ gtk_paned_class_init (GtkPanedClass *class)
/**
* GtkPaned:position-set:
*
* %TRUE if the `position` property has been set.
* Whether the [property@Gtk.Paned:position] property has been set.
*/
paned_props[PROP_POSITION_SET] =
g_param_spec_boolean ("position-set",
@@ -443,7 +443,8 @@ gtk_paned_class_init (GtkPanedClass *class)
/**
* GtkPaned:min-position:
*
* The smallest possible value for the position property.
* The smallest possible value for the [property@Gtk.Paned:position]
* property.
*
* This property is derived from the size and shrinkability
* of the widget's children.
@@ -458,7 +459,8 @@ gtk_paned_class_init (GtkPanedClass *class)
/**
* GtkPaned:max-position:
*
* The largest possible value for the position property.
* The largest possible value for the [property@Gtk.Paned:position]
* property.
*
* This property is derived from the size and shrinkability
* of the widget's children.
@@ -573,7 +575,7 @@ gtk_paned_class_init (GtkPanedClass *class)
*
* This is a [keybinding signal](class.SignalAction.html).
*
* The default binding is F6.
* The default binding is <kbd>F6</kbd>.
*/
signals [CYCLE_CHILD_FOCUS] =
g_signal_new (I_("cycle-child-focus"),
@@ -594,7 +596,7 @@ gtk_paned_class_init (GtkPanedClass *class)
*
* This is a [keybinding signal](class.SignalAction.html).
*
* The default binding is Tab.
* The default binding is <kbd>Tab</kbd>.
*/
signals [TOGGLE_HANDLE_FOCUS] =
g_signal_new (I_("toggle-handle-focus"),
@@ -634,7 +636,7 @@ gtk_paned_class_init (GtkPanedClass *class)
*
* This is a [keybinding signal](class.SignalAction.html).
*
* The default binding for this signal is F8.
* The default binding for this signal is <kbd>F8</kbd>.
*/
signals [CYCLE_HANDLE_FOCUS] =
g_signal_new (I_("cycle-handle-focus"),
@@ -655,7 +657,8 @@ gtk_paned_class_init (GtkPanedClass *class)
*
* This is a [keybinding signal](class.SignalAction.html).
*
* The default binding for this signal is Return or Space.
* The default binding for this signal is <kbd>Return</kbd> or
* <kbd>Space</kbd>.
*/
signals [ACCEPT_POSITION] =
g_signal_new (I_("accept-position"),
@@ -678,7 +681,7 @@ gtk_paned_class_init (GtkPanedClass *class)
*
* This is a [keybinding signal](class.SignalAction.html).
*
* The default binding for this signal is Escape.
* The default binding for this signal is <kbd>Escape</kbd>.
*/
signals [CANCEL_POSITION] =
g_signal_new (I_("cancel-position"),
@@ -1555,7 +1558,7 @@ gtk_paned_css_changed (GtkWidget *widget,
*
* Creates a new `GtkPaned` widget.
*
* Returns: a new `GtkPaned`.
* Returns: the newly created paned widget
*/
GtkWidget *
gtk_paned_new (GtkOrientation orientation)
@@ -1568,9 +1571,11 @@ gtk_paned_new (GtkOrientation orientation)
/**
* gtk_paned_set_start_child: (attributes org.gtk.Method.set_property=start-child)
* @paned: a `GtkPaned`
* @child: the widget to add
* @child: (nullable): the widget to add
*
* Sets the start child of @paned to @child.
*
* If @child is `NULL`, the existing child will be removed.
*/
void
gtk_paned_set_start_child (GtkPaned *paned,
@@ -1596,8 +1601,6 @@ gtk_paned_set_start_child (GtkPaned *paned,
*
* Retrieves the start child of the given `GtkPaned`.
*
* See also: `GtkPaned`:start-child
*
* Returns: (transfer none) (nullable): the start child widget
*/
GtkWidget *
@@ -1611,9 +1614,9 @@ gtk_paned_get_start_child (GtkPaned *paned)
/**
* gtk_paned_set_resize_start_child: (attributes org.gtk.Method.set_property=resize-start-child)
* @paned: a `GtkPaned`
* @resize: %TRUE to let the start child be resized
* @resize: true to let the start child be resized
*
* Sets the `GtkPaned`:resize-start-child property
* Sets whether the [property@Gtk.Paned:start-child] can be resized.
*/
void
gtk_paned_set_resize_start_child (GtkPaned *paned,
@@ -1633,9 +1636,9 @@ gtk_paned_set_resize_start_child (GtkPaned *paned,
* gtk_paned_get_resize_start_child: (attributes org.gtk.Method.get_property=resize-start-child)
* @paned: a `GtkPaned`
*
* Returns whether the start child can be resized.
* Returns whether the [property@Gtk.Paned:start-child] can be resized.
*
* Returns: %TRUE if the start child is resizable
* Returns: true if the start child is resizable
*/
gboolean
gtk_paned_get_resize_start_child (GtkPaned *paned)
@@ -1648,9 +1651,9 @@ gtk_paned_get_resize_start_child (GtkPaned *paned)
/**
* gtk_paned_set_shrink_start_child: (attributes org.gtk.Method.set_property=shrink-start-child)
* @paned: a `GtkPaned`
* @resize: %TRUE to let the start child be shrunk
* @resize: true to let the start child be shrunk
*
* Sets the `GtkPaned`:shrink-start-child property
* Sets whether the [property@Gtk.Paned:start-child] can shrink.
*/
void
gtk_paned_set_shrink_start_child (GtkPaned *paned,
@@ -1670,9 +1673,9 @@ gtk_paned_set_shrink_start_child (GtkPaned *paned,
* gtk_paned_get_shrink_start_child: (attributes org.gtk.Method.get_property=shrink-start-child)
* @paned: a `GtkPaned`
*
* Returns whether the start child can be shrunk.
* Returns whether the [property@Gtk.Paned:start-child] can shrink.
*
* Returns: %TRUE if the start child is shrinkable
* Returns: true if the start child is shrinkable
*/
gboolean
gtk_paned_get_shrink_start_child (GtkPaned *paned)
@@ -1685,9 +1688,11 @@ gtk_paned_get_shrink_start_child (GtkPaned *paned)
/**
* gtk_paned_set_end_child: (attributes org.gtk.Method.set_property=end-child)
* @paned: a `GtkPaned`
* @child: the widget to add
* @child: (nullable): the widget to add
*
* Sets the end child of @paned to @child.
*
* If @child is `NULL`, the existing child will be removed.
*/
void
gtk_paned_set_end_child (GtkPaned *paned,
@@ -1713,8 +1718,6 @@ gtk_paned_set_end_child (GtkPaned *paned,
*
* Retrieves the end child of the given `GtkPaned`.
*
* See also: `GtkPaned`:end-child
*
* Returns: (transfer none) (nullable): the end child widget
*/
GtkWidget *
@@ -1728,9 +1731,9 @@ gtk_paned_get_end_child (GtkPaned *paned)
/**
* gtk_paned_set_resize_end_child: (attributes org.gtk.Method.set_property=resize-end-child)
* @paned: a `GtkPaned`
* @resize: %TRUE to let the end child be resized
* @resize: true to let the end child be resized
*
* Sets the `GtkPaned`:resize-end-child property
* Sets whether the [property@Gtk.Paned:end-child] can be resized.
*/
void
gtk_paned_set_resize_end_child (GtkPaned *paned,
@@ -1750,9 +1753,9 @@ gtk_paned_set_resize_end_child (GtkPaned *paned,
* gtk_paned_get_resize_end_child: (attributes org.gtk.Method.get_property=resize-end-child)
* @paned: a `GtkPaned`
*
* Returns whether the end child can be resized.
* Returns whether the [property@Gtk.Paned:end-child] can be resized.
*
* Returns: %TRUE if the end child is resizable
* Returns: true if the end child is resizable
*/
gboolean
gtk_paned_get_resize_end_child (GtkPaned *paned)
@@ -1765,9 +1768,9 @@ gtk_paned_get_resize_end_child (GtkPaned *paned)
/**
* gtk_paned_set_shrink_end_child: (attributes org.gtk.Method.set_property=shrink-end-child)
* @paned: a `GtkPaned`
* @resize: %TRUE to let the end child be shrunk
* @resize: true to let the end child be shrunk
*
* Sets the `GtkPaned`:shrink-end-child property
* Sets whether the [property@Gtk.Paned:end-child] can shrink.
*/
void
gtk_paned_set_shrink_end_child (GtkPaned *paned,
@@ -1787,9 +1790,9 @@ gtk_paned_set_shrink_end_child (GtkPaned *paned,
* gtk_paned_get_shrink_end_child: (attributes org.gtk.Method.get_property=shrink-end-child)
* @paned: a `GtkPaned`
*
* Returns whether the end child can be shrunk.
* Returns whether the [property@Gtk.Paned:end-child] can shrink.
*
* Returns: %TRUE if the end child is shrinkable
* Returns: true if the end child is shrinkable
*/
gboolean
gtk_paned_get_shrink_end_child (GtkPaned *paned)
@@ -1805,7 +1808,7 @@ gtk_paned_get_shrink_end_child (GtkPaned *paned)
*
* Obtains the position of the divider between the two panes.
*
* Returns: position of the divider
* Returns: the position of the divider, in pixels
**/
int
gtk_paned_get_position (GtkPaned *paned)
@@ -1822,7 +1825,7 @@ gtk_paned_get_position (GtkPaned *paned)
* is unset
*
* Sets the position of the divider between the two panes.
**/
*/
void
gtk_paned_set_position (GtkPaned *paned,
int position)

View File

@@ -29,13 +29,11 @@
* All scrollable widgets should do the following.
*
* - When a parent widget sets the scrollable child widgets adjustments,
* the widget should populate the adjustments
* [property@Gtk.Adjustment:lower],
* [property@Gtk.Adjustment:upper],
* [property@Gtk.Adjustment:step-increment],
* [property@Gtk.Adjustment:page-increment] and
* [property@Gtk.Adjustment:page-size] properties and connect to the
* [signal@Gtk.Adjustment::value-changed] signal.
* the widget should connect to the [signal@Gtk.Adjustment::value-changed]
* signal. The child widget should then populate the adjustments properties
* as soon as possible, which usually means queueing an allocation right away
* and populating the properties in the [vfunc@Gtk.Widget.size_allocate]
* implementation.
*
* - Because its preferred size is the size for a fully expanded widget,
* the scrollable widget must be able to cope with underallocations.
@@ -43,7 +41,8 @@
* [vfunc@Gtk.Widget.size_allocate] implementation.
*
* - When the parent allocates space to the scrollable child widget,
* the widget should update the adjustments properties with new values.
* the widget must ensure the adjustments property values are correct and up
* to date, for example using [method@Gtk.Adjustment.configure].
*
* - When any of the adjustments emits the [signal@Gtk.Adjustment::value-changed]
* signal, the scrollable widget should scroll its contents.

View File

@@ -379,6 +379,7 @@ static void gtk_scrolled_window_measure (GtkWidget *widget,
static void gtk_scrolled_window_map (GtkWidget *widget);
static void gtk_scrolled_window_unmap (GtkWidget *widget);
static void gtk_scrolled_window_realize (GtkWidget *widget);
static void gtk_scrolled_window_unrealize (GtkWidget *widget);
static void _gtk_scrolled_window_set_adjustment_value (GtkScrolledWindow *scrolled_window,
GtkAdjustment *adjustment,
double value);
@@ -587,6 +588,7 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
widget_class->map = gtk_scrolled_window_map;
widget_class->unmap = gtk_scrolled_window_unmap;
widget_class->realize = gtk_scrolled_window_realize;
widget_class->unrealize = gtk_scrolled_window_unrealize;
widget_class->direction_changed = gtk_scrolled_window_direction_changed;
widget_class->compute_expand = gtk_scrolled_window_compute_expand;
widget_class->get_request_mode = gtk_scrolled_window_get_request_mode;
@@ -700,7 +702,7 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkScrolledWindow:kinetic-scrolling: (attributes org.gtk.Property.get=gtk_scrolled_window_get_kinetic_scrolling org.gtk.Property.set=gtk_scrolled_window_set_overlay_scrolling)
* GtkScrolledWindow:kinetic-scrolling: (attributes org.gtk.Property.get=gtk_scrolled_window_get_kinetic_scrolling org.gtk.Property.set=gtk_scrolled_window_set_kinetic_scrolling)
*
* Whether kinetic scrolling is enabled or not.
*
@@ -3864,15 +3866,32 @@ gtk_scrolled_window_realize (GtkWidget *widget)
{
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GtkSettings *settings;
priv->hindicator.scrollbar = priv->hscrollbar;
priv->vindicator.scrollbar = priv->vscrollbar;
gtk_scrolled_window_sync_use_indicators (scrolled_window);
settings = gtk_widget_get_settings (widget);
g_signal_connect_swapped (settings, "notify::gtk-overlay-scrolling",
G_CALLBACK (gtk_scrolled_window_update_use_indicators), widget);
GTK_WIDGET_CLASS (gtk_scrolled_window_parent_class)->realize (widget);
}
static void
gtk_scrolled_window_unrealize (GtkWidget *widget)
{
GtkSettings *settings;
settings = gtk_widget_get_settings (widget);
g_signal_handlers_disconnect_by_func (settings, gtk_scrolled_window_sync_use_indicators, widget);
GTK_WIDGET_CLASS (gtk_scrolled_window_parent_class)->unrealize (widget);
}
/**
* gtk_scrolled_window_get_min_content_width: (attributes org.gtk.Method.get_property=min-content-width)
* @scrolled_window: a `GtkScrolledWindow`

View File

@@ -388,8 +388,6 @@ gtk_tooltip_window_class_init (GtkTooltipWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, GtkTooltipWindow, box);
gtk_widget_class_bind_template_child (widget_class, GtkTooltipWindow, image);
gtk_widget_class_bind_template_child (widget_class, GtkTooltipWindow, label);
gtk_widget_class_set_css_name (widget_class, "tooltip");
}
static void
@@ -420,7 +418,6 @@ update_label_width (GtkLabel *label)
len = g_utf8_strlen (text, -1);
gtk_label_set_width_chars (label, MIN (len, 50));
gtk_label_set_max_width_chars (label, MIN (len, 50));
gtk_label_set_wrap (label, TRUE);
}

View File

@@ -45,12 +45,12 @@
#ifdef GDK_WINDOWING_WIN32
#include "win32/gdkwin32.h"
#include "gdkglcontextprivate.h"
#include <epoxy/wgl.h>
#endif
#ifdef GDK_WIN32_ENABLE_EGL
#include <epoxy/egl.h>
#endif
#endif
#ifdef GDK_WINDOWING_MACOS
#include "macos/gdkmacos.h"
@@ -387,7 +387,8 @@ init_gl (GtkInspectorGeneral *gen)
else
#endif
#ifdef GDK_WINDOWING_WIN32
if (GDK_IS_WIN32_DISPLAY (gen->display))
if (GDK_IS_WIN32_DISPLAY (gen->display) &&
gdk_gl_backend_can_be_used (GDK_GL_WGL, NULL))
{
int gl_version;
char *version;

View File

@@ -403,6 +403,10 @@ modules/printbackends/gtkprintbackendlpr.c
modules/printbackends/gtkprintercups.c
tools/encodesymbolic.c
tools/gtk-builder-tool.c
tools/gtk-builder-tool-enumerate.c
tools/gtk-builder-tool-preview.c
tools/gtk-builder-tool-screenshot.c
tools/gtk-builder-tool-simplify.c
tools/gtk-builder-tool-validate.c
tools/gtk-launch.c
tools/updateiconcache.c

View File

@@ -17,6 +17,8 @@
* Author: Matthias Clasen
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
@@ -46,12 +48,42 @@ do_enumerate (int *argc, const char ***argv)
GSList *list, *l;
GObject *object;
const char *name;
const char *filename;
char **filenames = NULL;
GOptionContext *context;
const GOptionEntry entries[] = {
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL, N_("FILE") },
{ NULL, }
};
filename = (*argv)[1];
g_set_prgname ("gtk4-builder-tool enumerate");
context = g_option_context_new (NULL);
g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
g_option_context_add_main_entries (context, entries, NULL);
g_option_context_set_summary (context, _("List all named objects."));
if (!g_option_context_parse (context, argc, (char ***)argv, &error))
{
g_printerr ("%s\n", error->message);
g_error_free (error);
exit (1);
}
g_option_context_free (context);
if (filenames == NULL)
{
g_printerr ("No .ui file specified\n");
exit (1);
}
if (g_strv_length (filenames) > 1)
{
g_printerr ("Can only enumerate a single .ui file\n");
exit (1);
}
builder = gtk_builder_new ();
ret = gtk_builder_add_from_file (builder, filename, &error);
ret = gtk_builder_add_from_file (builder, filenames[0], &error);
if (ret == 0)
{
@@ -72,4 +104,6 @@ do_enumerate (int *argc, const char ***argv)
g_slist_free (list);
g_object_unref (builder);
g_strfreev (filenames);
}

View File

@@ -17,6 +17,8 @@
* Author: Matthias Clasen
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
@@ -173,16 +175,24 @@ do_preview (int *argc,
char *css = NULL;
char **filenames = NULL;
const GOptionEntry entries[] = {
{ "id", 0, 0, G_OPTION_ARG_STRING, &id, NULL, NULL },
{ "css", 0, 0, G_OPTION_ARG_FILENAME, &css, NULL, NULL },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL, NULL },
{ "id", 0, 0, G_OPTION_ARG_STRING, &id, N_("Preview only the named object"), N_("ID") },
{ "css", 0, 0, G_OPTION_ARG_FILENAME, &css, N_("Use style from CSS file"), N_("FILE") },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL, N_("FILE") },
{ NULL, }
};
GError *error = NULL;
if (gdk_display_get_default () == NULL)
{
g_printerr ("Could not initialize windowing system\n");
exit (1);
}
g_set_prgname ("gtk4-builder-tool preview");
context = g_option_context_new (NULL);
g_option_context_set_help_enabled (context, FALSE);
g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
g_option_context_add_main_entries (context, entries, NULL);
g_option_context_set_summary (context, _("Preview the file."));
if (!g_option_context_parse (context, argc, (char ***)argv, &error))
{

View File

@@ -0,0 +1,368 @@
/* Copyright 2015 Red Hat, Inc.
*
* GTK+ is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* GLib 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 GTK+; see the file COPYING. If not,
* see <http://www.gnu.org/licenses/>.
*
* Author: Matthias Clasen
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <glib/gi18n.h>
#include <glib/gprintf.h>
#include <glib/gstdio.h>
#include <gtk/gtk.h>
#include "gtkbuilderprivate.h"
#include "gtk-builder-tool.h"
static gboolean
quit_when_idle (gpointer loop)
{
g_main_loop_quit (loop);
return G_SOURCE_REMOVE;
}
static GMainLoop *loop;
static void
draw_paintable (GdkPaintable *paintable,
gpointer out_texture)
{
GtkSnapshot *snapshot;
GskRenderNode *node;
GdkTexture *texture;
GskRenderer *renderer;
snapshot = gtk_snapshot_new ();
gdk_paintable_snapshot (paintable,
snapshot,
gdk_paintable_get_intrinsic_width (paintable),
gdk_paintable_get_intrinsic_height (paintable));
node = gtk_snapshot_free_to_node (snapshot);
/* If the window literally draws nothing, we assume it hasn't been mapped yet and as such
* the invalidations were only side effects of resizes.
*/
if (node == NULL)
return;
renderer = gtk_native_get_renderer (
gtk_widget_get_native (
gtk_widget_paintable_get_widget (GTK_WIDGET_PAINTABLE (paintable))));
texture = gsk_renderer_render_texture (renderer,
node,
&GRAPHENE_RECT_INIT (
0, 0,
gdk_paintable_get_intrinsic_width (paintable),
gdk_paintable_get_intrinsic_height (paintable)
));
g_object_set_data_full (G_OBJECT (texture),
"source-render-node",
node,
(GDestroyNotify) gsk_render_node_unref);
g_signal_handlers_disconnect_by_func (paintable, draw_paintable, out_texture);
*(GdkTexture **) out_texture = texture;
g_idle_add (quit_when_idle, loop);
}
static GdkTexture *
snapshot_widget (GtkWidget *widget)
{
GdkPaintable *paintable;
GdkTexture *texture = NULL;
g_assert_true (gtk_widget_get_realized (widget));
loop = g_main_loop_new (NULL, FALSE);
/* We wait until the widget is drawn for the first time.
*
* We also use an inhibit mechanism, to give module functions a chance
* to delay the snapshot.
*/
paintable = gtk_widget_paintable_new (widget);
g_signal_connect (paintable, "invalidate-contents", G_CALLBACK (draw_paintable), &texture);
g_main_loop_run (loop);
g_main_loop_unref (loop);
g_object_unref (paintable);
gtk_window_destroy (GTK_WINDOW (widget));
return texture;
}
static void
set_window_title (GtkWindow *window,
const char *filename,
const char *id)
{
char *name;
char *title;
name = g_path_get_basename (filename);
if (id)
title = g_strdup_printf ("%s in %s", id, name);
else
title = g_strdup (name);
gtk_window_set_title (window, title);
g_free (title);
g_free (name);
}
static char *
get_save_filename (const char *filename,
gboolean as_node)
{
int length = strlen (filename);
const char *extension = as_node ? ".node" : ".png";
char *result;
if (strcmp (filename + (length - 3), ".ui") == 0)
{
char *basename = g_strndup (filename, length - 3);
result = g_strconcat (basename, extension, NULL);
g_free (basename);
}
else
result = g_strconcat (filename, extension, NULL);
return result;
}
static void
screenshot_file (const char *filename,
const char *id,
const char *cssfile,
const char *save_file,
gboolean as_node,
gboolean force)
{
GtkBuilder *builder;
GError *error = NULL;
GObject *object;
GtkWidget *window;
GdkTexture *texture;
char *save_to;
GBytes *bytes;
if (cssfile)
{
GtkCssProvider *provider;
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_path (provider, cssfile);
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
builder = gtk_builder_new ();
if (!gtk_builder_add_from_file (builder, filename, &error))
{
g_printerr ("%s\n", error->message);
exit (1);
}
object = NULL;
if (id)
{
object = gtk_builder_get_object (builder, id);
}
else
{
GSList *objects, *l;
objects = gtk_builder_get_objects (builder);
for (l = objects; l; l = l->next)
{
GObject *obj = l->data;
if (GTK_IS_WINDOW (obj))
{
object = obj;
break;
}
else if (GTK_IS_WIDGET (obj))
{
if (object == NULL)
object = obj;
}
}
g_slist_free (objects);
}
if (object == NULL)
{
if (id)
g_printerr ("No object with ID '%s' found\n", id);
else
g_printerr ("No object found\n");
exit (1);
}
if (!GTK_IS_WIDGET (object))
{
g_printerr ("Objects of type %s can't be screenshot\n", G_OBJECT_TYPE_NAME (object));
exit (1);
}
if (GTK_IS_WINDOW (object))
window = GTK_WIDGET (object);
else
{
GtkWidget *widget = GTK_WIDGET (object);
window = gtk_window_new ();
if (GTK_IS_BUILDABLE (object))
id = gtk_buildable_get_buildable_id (GTK_BUILDABLE (object));
set_window_title (GTK_WINDOW (window), filename, id);
g_object_ref (widget);
if (gtk_widget_get_parent (widget) != NULL)
gtk_box_remove (GTK_BOX (gtk_widget_get_parent (widget)), widget);
gtk_window_set_child (GTK_WINDOW (window), widget);
g_object_unref (widget);
}
gtk_widget_show (window);
texture = snapshot_widget (window);
g_object_unref (builder);
if (texture == NULL)
{
g_printerr ("Failed to take a screenshot\n");
exit (1);
}
save_to = (char *)save_file;
if (save_to == NULL)
save_to = get_save_filename (filename, as_node);
if (g_file_test (save_to, G_FILE_TEST_EXISTS) && !force)
{
g_printerr ("File %s exists.\n"
"Use --force to overwrite.\n", save_to);
exit (1);
}
if (as_node)
{
GskRenderNode *node;
node = (GskRenderNode *) g_object_get_data (G_OBJECT (texture), "source-render-node");
bytes = gsk_render_node_serialize (node);
}
else
{
bytes = gdk_texture_save_to_png_bytes (texture);
}
if (g_file_set_contents (save_to,
g_bytes_get_data (bytes, NULL),
g_bytes_get_size (bytes),
&error))
{
g_print ("Output written to %s.\n", save_to);
}
else
{
g_printerr ("Failed to save %s: %s\n", save_to, error->message);
exit (1);
}
g_bytes_unref (bytes);
if (save_to != save_file)
g_free (save_to);
g_object_unref (texture);
}
void
do_screenshot (int *argc,
const char ***argv)
{
GOptionContext *context;
char *id = NULL;
char *css = NULL;
char **filenames = NULL;
gboolean as_node = FALSE;
gboolean force = FALSE;
const GOptionEntry entries[] = {
{ "id", 0, 0, G_OPTION_ARG_STRING, &id, N_("Screenshot only the named object"), N_("ID") },
{ "css", 0, 0, G_OPTION_ARG_FILENAME, &css, N_("Use style from CSS file"), N_("FILE") },
{ "node", 0, 0, G_OPTION_ARG_NONE, &as_node, N_("Save as node file instead of png"), NULL },
{ "force", 0, 0, G_OPTION_ARG_NONE, &force, N_("Overwrite existing file"), NULL },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL, N_("FILE") },
{ NULL, }
};
GError *error = NULL;
if (gdk_display_get_default () == NULL)
{
g_printerr ("Could not initialize windowing system\n");
exit (1);
}
g_set_prgname ("gtk4-builder-tool screenshot");
context = g_option_context_new (NULL);
g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
g_option_context_add_main_entries (context, entries, NULL);
g_option_context_set_summary (context, _("Take a screenshot of the file."));
if (!g_option_context_parse (context, argc, (char ***)argv, &error))
{
g_printerr ("%s\n", error->message);
g_error_free (error);
exit (1);
}
g_option_context_free (context);
if (filenames == NULL)
{
g_printerr ("No .ui file specified\n");
exit (1);
}
if (g_strv_length (filenames) > 2)
{
g_printerr ("Can only screenshot a single .ui file and a single output file\n");
exit (1);
}
screenshot_file (filenames[0], id, css, filenames[1], as_node, force);
g_strfreev (filenames);
g_free (id);
g_free (css);
}

View File

@@ -17,6 +17,8 @@
* Author: Matthias Clasen
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
@@ -2351,28 +2353,30 @@ do_simplify (int *argc,
gboolean replace = FALSE;
gboolean convert3to4 = FALSE;
char **filenames = NULL;
GOptionContext *ctx;
GOptionContext *context;
const GOptionEntry entries[] = {
{ "replace", 0, 0, G_OPTION_ARG_NONE, &replace, NULL, NULL },
{ "3to4", 0, 0, G_OPTION_ARG_NONE, &convert3to4, NULL, NULL },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL, NULL },
{ "replace", 0, 0, G_OPTION_ARG_NONE, &replace, N_("Replace the file"), NULL },
{ "3to4", 0, 0, G_OPTION_ARG_NONE, &convert3to4, N_("Convert from GTK 3 to GTK 4"), NULL },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL, N_("FILE") },
{ NULL, }
};
GError *error = NULL;
int i;
ctx = g_option_context_new (NULL);
g_option_context_set_help_enabled (ctx, FALSE);
g_option_context_add_main_entries (ctx, entries, NULL);
g_set_prgname ("gtk4-builder-tool simplify");
context = g_option_context_new (NULL);
g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
g_option_context_add_main_entries (context, entries, NULL);
g_option_context_set_summary (context, _("Simplify the file."));
if (!g_option_context_parse (ctx, argc, (char ***)argv, &error))
if (!g_option_context_parse (context, argc, (char ***)argv, &error))
{
g_printerr ("%s\n", error->message);
g_error_free (error);
exit (1);
}
g_option_context_free (ctx);
g_option_context_free (context);
if (filenames == NULL)
{
@@ -2391,4 +2395,6 @@ do_simplify (int *argc,
if (!simplify_file (filenames[i], replace, convert3to4))
exit (1);
}
g_strfreev (filenames);
}

View File

@@ -17,6 +17,8 @@
* Author: Matthias Clasen
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
@@ -150,11 +152,35 @@ validate_file (const char *filename)
void
do_validate (int *argc, const char ***argv)
{
GError *error = NULL;
char **filenames = NULL;
GOptionContext *context;
const GOptionEntry entries[] = {
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL, N_("FILE") },
{ NULL, }
};
int i;
for (i = 1; i < *argc; i++)
g_set_prgname ("gtk4-builder-tool validate");
context = g_option_context_new (NULL);
g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
g_option_context_add_main_entries (context, entries, NULL);
g_option_context_set_summary (context, _("Validate the file."));
if (!g_option_context_parse (context, argc, (char ***)argv, &error))
{
if (!validate_file ((*argv)[i]))
g_printerr ("%s\n", error->message);
g_error_free (error);
exit (1);
}
g_option_context_free (context);
for (i = 0; filenames[i]; i++)
{
if (!validate_file (filenames[i]))
exit (1);
}
g_strfreev (filenames);
}

View File

@@ -17,6 +17,8 @@
* Author: Matthias Clasen
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
@@ -34,21 +36,15 @@ usage (void)
g_print (_("Usage:\n"
" gtk-builder-tool [COMMAND] [OPTION…] FILE\n"
"\n"
"Perform various tasks on GtkBuilder .ui files.\n"
"\n"
"Commands:\n"
" validate Validate the file\n"
" simplify Simplify the file\n"
" enumerate List all named objects\n"
" preview Preview the file\n"
"\n"
"Simplify Options:\n"
" --replace Replace the file\n"
" --3to4 Convert from GTK 3 to GTK 4\n"
"\n"
"Preview Options:\n"
" --id=ID Preview only the named object\n"
" --css=FILE Use style from CSS file\n"
"\n"
"Perform various tasks on GtkBuilder .ui files.\n"));
" screenshot Take a screenshot of the file\n"
"\n"));
exit (1);
}
@@ -109,20 +105,18 @@ log_writer_func (GLogLevelFlags level,
int
main (int argc, const char *argv[])
{
gboolean has_display;
g_set_prgname ("gtk-builder-tool");
g_log_set_writer_func (log_writer_func, NULL, NULL);
has_display = gtk_init_check ();
gtk_init_check ();
gtk_test_register_all_types ();
if (argc < 3)
if (argc < 2)
usage ();
if (strcmp (argv[2], "--help") == 0)
if (strcmp (argv[1], "--help") == 0)
usage ();
argv++;
@@ -135,15 +129,9 @@ main (int argc, const char *argv[])
else if (strcmp (argv[0], "enumerate") == 0)
do_enumerate (&argc, &argv);
else if (strcmp (argv[0], "preview") == 0)
{
if (!has_display)
{
g_printerr ("Could not initialize windowing system\n");
return 1;
}
do_preview (&argc, &argv);
}
do_preview (&argc, &argv);
else if (strcmp (argv[0], "screenshot") == 0)
do_screenshot (&argc, &argv);
else
usage ();

View File

@@ -2,9 +2,10 @@
#ifndef __GTK_BUILDER_TOOL_H__
#define __GTK_BUILDER_TOOL_H__
void do_simplify (int *argc, const char ***argv);
void do_validate (int *argc, const char ***argv);
void do_enumerate (int *argc, const char ***argv);
void do_preview (int *argc, const char ***argv);
void do_simplify (int *argc, const char ***argv);
void do_validate (int *argc, const char ***argv);
void do_enumerate (int *argc, const char ***argv);
void do_preview (int *argc, const char ***argv);
void do_screenshot (int *argc, const char ***argv);
#endif

View File

@@ -28,6 +28,7 @@ gtk_tools = [
'gtk-builder-tool-simplify.c',
'gtk-builder-tool-validate.c',
'gtk-builder-tool-enumerate.c',
'gtk-builder-tool-screenshot.c',
'gtk-builder-tool-preview.c'], [libgtk_dep] ],
['gtk4-update-icon-cache', ['updateiconcache.c'] + extra_update_icon_cache_objs, [ libgtk_static_dep ] ],
['gtk4-encode-symbolic-svg', ['encodesymbolic.c'], [ libgtk_static_dep ] ],