Commit Graph

815 Commits

Author SHA1 Message Date
Matthias Clasen
3ae31b0e79 notebook: Document new apis
This silences gi build warnings.
2019-02-23 23:26:59 -05:00
Matthias Clasen
0961fe7a55 notebook: Fix up issues with property notification 2019-02-21 00:31:17 -05:00
Matthias Clasen
f64b0a705e Implement position property somewhat 2019-02-21 00:31:17 -05:00
Matthias Clasen
c1ad7217b5 notebook: Fix up ref counting
We need to keep a ref to the page objects.
2019-02-21 00:31:17 -05:00
Matthias Clasen
f11d0118a3 notebook: Add a pages model
Just like GtkStack and GtkAssistant, provide
a list model with the page objects.
2019-02-21 00:31:17 -05:00
Matthias Clasen
7f8ba95db5 Allow builder to add notebook pages 2019-02-21 00:31:17 -05:00
Matthias Clasen
ff4b3f1170 Turn labels into page properties 2019-02-21 00:31:17 -05:00
Matthias Clasen
78c54b27d7 Add GtkNotebookPage properties 2019-02-21 00:31:17 -05:00
Matthias Clasen
85fb368834 Make GtkNotebookPage an object 2019-02-21 00:31:17 -05:00
Matthias Clasen
0e29408215 notebook: Rename an internal macro
Avoid a clash between GObject boilerplate and the
GTK_NOTEBOOK_PAGE() macro, by renaming it.
2019-02-21 00:31:17 -05:00
Benjamin Otte
01f7f255b5 gtk: Check return value of compute_bounds()
Half of these calls will completely break if anybody ever uses CSS
transforms with them, but hey...
2019-02-20 05:26:31 +01:00
Emmanuele Bassi
25fd230327 gtk: Drop the "plus"
Source names should use "[gtk]" without the plus.
2019-02-05 11:26:20 +01:00
Matthias Clasen
f3f5a896de box: Avoid position in the reorder api
Change the reorder api to insert after a sibling,
so that moving to first place becomes reorder (... NULL).

And add a insert_after api that can replace the common
container_add / reorder_after (... NULL) combination.

Update all callers.
2019-01-23 19:30:47 -05:00
Timm Bäder
c49cc977fa gizmo: return void from snapshot func
This boolean return was from the old gadget code and we weren't using it
in the new gizmo code.
2019-01-18 19:43:50 +01:00
Timm Bäder
359d874ddb Use g_clear_pointer to unparent widgets 2018-11-13 20:53:14 +01:00
Timm Bäder
ade171a2ed widget: Don't pass a position to ->size_allocate
The values have been 0/0 for a long time now, so just drop the
GtkAllocation argument and replace it with width and height.
2018-11-13 16:28:54 +01:00
Matthias Clasen
a3ac3b61ef Merge branch '1397-gtknotebook-built-in-popup-menu-listing-tabs-doesn-t-use-tab-label-text-for-the-last-tab-4' into 'master'
Notebook: Ensure menu label updates with tab_label

Closes #1397

See merge request GNOME/gtk!386
2018-10-16 20:49:42 +00:00
Daniel Boles
4e884b6056 Notebook: Ensure menu_label updates with tab_label
This was noticed in Firefox and demonstrated using a GtkBuilder ui file.
buildable_add_child() calls set_tab_label(), but the latter did nothing
to update the menu_label corresponding to that tab with the new text.
Using Builder to populate the tab child, only tabs other than last got
the right non-default labels, and even that was mostly coincidental, as
adding the main child called update_labels() via real_insert_page(), so
it took effect when the 2nd last main child is added, updating the rest
but leaving the last with the default label, not that given in Builder.

Fix by factoring out the code from child_reordered() to a new helper
menu_item_recreate() and calling that in set_tab_label(), so that
whenever the tab_label is updated, so is its corresponding menu_label.

This fixes the reported case and presumably others that we could write.

fixes https://gitlab.gnome.org/GNOME/gtk/issues/1397
2018-10-12 23:50:12 +01:00
Daniel Boles
f252bbc02c Notebook: Don't notify 2x from set_tab_label_text
It calls set_tab_label(), which already does that.
2018-10-12 23:40:16 +01:00
Matthias Clasen
b94c3166bf dnd: Rename gtk_drag_begin_with_coordinates
Now that the coordiate-less variant is gone,
rename this back to the shorter gtk_drag_begin.
2018-07-12 13:02:42 +02:00
Matthias Clasen
7733f646d6 gdk: Rename GdkDragContext to GdkDrag
This is to go along with the newly introduced GdkDrop.

This commit includes the necessary updates to the X11, Wayland
and Broadway backends. Other backends have to be updated separately.
2018-07-02 14:59:26 +02:00
Timm Bäder
99099a1053 Remove some unnecessary snapshot implementations 2018-06-20 20:47:18 +02:00
Benjamin Otte
9a91d3739d widget: Remove time argument from drag_data_get() vfunc 2018-06-18 23:49:53 +02:00
Benjamin Otte
b00609c21c dnd: Make drag-motion and drag-drop signals use GdkDrop 2018-06-18 23:49:52 +02:00
Benjamin Otte
6d7cb2b781 dnd: Make drag-data-received use a GdkDrop 2018-06-18 23:49:52 +02:00
Benjamin Otte
314eaf7d10 widget: Make GtkWidgetClass::drag_leave() take a GdkDrop
Drag Contexts are on their way out!
2018-06-18 23:49:20 +02:00
Benjamin Otte
5b0a6a52c1 dnd: Get rid of gtk_drag_finish()
It's just a wrapper around gdk_drag_finish(), so use that one instead.
2018-06-18 23:49:20 +02:00
Timm Bäder
fffb3161bc notebook: Stop reversing tabs based on text direction 2018-06-18 17:35:02 +02:00
Timm Bäder
5ff4ef14e6 widget: Directly notify gestures of grab
Since each widget has a list of event controllers now, we don't need to
connect to ::grab-notify of the widget for every controller.
2018-05-19 10:18:50 +02:00
Benjamin Otte
4f3058f195 eventcontrollermotion: Port to new API model 2018-04-26 17:59:42 +02:00
Benjamin Otte
4ddc94b293 multipressgesture: Port to new API model 2018-04-26 17:59:42 +02:00
Benjamin Otte
9c0acf62b4 widget: Allow adding event controllers in ui files 2018-04-26 17:59:41 +02:00
Carlos Garnacho
aeda2ad049 notebook: Fetch directly current event state/device
gtk_get_current_event() returns a new reference to the event, it should
be freed across various return branches to avoid the event leak, or we
just fetch the little stuff we're interested in.
2018-04-25 02:17:39 +02:00
Timm Bäder
3ce6355bf4 widget: Remove _get_own_allocation
Replace all usages of it with _compute_bounds
2018-04-10 09:43:47 +02:00
Timm Bäder
b29ee2dc46 notebook: Use compute_bounds 2018-04-10 09:43:47 +02:00
Benjamin Otte
169203951b widget: Remove clip from size-allocate vfunc
As the clip is no longer needed, get rid of it.
2018-04-05 14:56:38 +02:00
Alexander Larsson
63e060a21d GtkWidget: Start renaming widget->window
This is an automated change doing these command:

git sed -f g gtk_widget_set_has_window gtk_widget_set_has_surface
git sed -f g gtk_widget_get_has_window gtk_widget_get_has_surface
git sed -f g gtk_widget_set_parent_window gtk_widget_set_parent_surface
git sed -f g gtk_widget_get_parent_window gtk_widget_get_parent_surface
git sed -f g gtk_widget_set_window gtk_widget_set_surface
git sed -f g gtk_widget_get_window gtk_widget_get_surface
git sed -f g gtk_widget_register_window gtk_widget_register_surface
git sed -f g gtk_widget_unregister_window gtk_widget_unregister_surface

git checkout NEWS*
2018-03-20 15:21:12 +01:00
Alexander Larsson
9a7e721181 GdkSurface: Rename various functions and variables
This is an automatic rename of various things related
to the window->surface rename.

Public symbols changed by this is:
 GDK_MODE_WINDOW
 gdk_device_get_window_at_position
 gdk_device_get_window_at_position_double
 gdk_device_get_last_event_window
 gdk_display_get_monitor_at_window
 gdk_drag_context_get_source_window
 gdk_drag_context_get_dest_window
 gdk_drag_context_get_drag_window
 gdk_draw_context_get_window
 gdk_drawing_context_get_window
 gdk_gl_context_get_window
 gdk_synthesize_window_state
 gdk_surface_get_window_type
 gdk_x11_display_set_window_scale
 gsk_renderer_new_for_window
 gsk_renderer_get_window
 gtk_text_view_buffer_to_window_coords
 gtk_tree_view_convert_widget_to_bin_window_coords
 gtk_tree_view_convert_tree_to_bin_window_coords

The commands that generated this are:

git sed -f g "GDK window" "GDK surface"
git sed -f g window_impl surface_impl
(cd gdk; git sed -f g impl_window impl_surface)
git sed -f g WINDOW_IMPL SURFACE_IMPL
git sed -f g GDK_MODE_WINDOW GDK_MODE_SURFACE
git sed -f g gdk_draw_context_get_window gdk_draw_context_get_surface
git sed -f g gdk_drawing_context_get_window gdk_drawing_context_get_surface
git sed -f g gdk_gl_context_get_window gdk_gl_context_get_surface
git sed -f g gsk_renderer_get_window gsk_renderer_get_surface
git sed -f g gsk_renderer_new_for_window gsk_renderer_new_for_surface

(cd gdk; git sed -f g window_type surface_type)
git sed -f g gdk_surface_get_window_type gdk_surface_get_surface_type

git sed -f g window_at_position surface_at_position
git sed -f g event_window event_surface
git sed -f g window_coord surface_coord
git sed -f g window_state surface_state
git sed -f g window_cursor surface_cursor
git sed -f g window_scale surface_scale
git sed -f g window_events surface_events
git sed -f g monitor_at_window monitor_at_surface
git sed -f g window_under_pointer surface_under_pointer
(cd gdk; git sed -f g for_window for_surface)
git sed -f g window_anchor surface_anchor
git sed -f g WINDOW_IS_TOPLEVEL SURFACE_IS_TOPLEVEL
git sed -f g native_window native_surface
git sed -f g source_window source_surface
git sed -f g dest_window dest_surface
git sed -f g drag_window drag_surface
git sed -f g input_window input_surface

git checkout NEWS* po-properties po docs/reference/gtk/migrating-3to4.xml
2018-03-20 12:05:26 +01:00
Daniel Boles
146082d464 Notebook: Don’t show raw underline/markup in popup
If @menu_label == NULL, we create a default page->menu_label. This took
@tab_label.get_label() and passed that to page->menu_label.set_text().
This is wrong because we set the plain text of the menu_label from the
rich text of @tab_label. So, if @tab_label used mnemonics or markup, our
menu_label got the raw underline or markup tags shown in it as raw text.

As we call set_text() on the menu Label, the fix is to be symmetric: use
@tab_label’s get_text() as source, as that strips underlines and markup.

It’s not worth making the default Label ‘inherit’ :use-underline/markup;
that’s a slippery slope, and users wanting such things can just create a
fully fledged GtkLabel to pass as @menu_label to suppress the default.

https://bugzilla.gnome.org/show_bug.cgi?id=705509
2018-03-16 22:34:05 +00:00
Benjamin Otte
3bb95a09bb a11y: Remove gtk.h include from container accessible 2018-02-09 00:42:38 +01:00
Timm Bäder
c73e22dadb notebook: Remove another event type check
Just like 3d65019e98, but for release
events.
2018-02-06 09:19:40 +01:00
Matthias Clasen
4c150d8eb5 The big versioning cleanup
Remove all the old 2.x and 3.x version annotations.
GTK+ 4 is a new start, and from the perspective of a
GTK+ 4 developer all these APIs have been around since
the beginning.
2018-02-06 01:16:32 -05:00
Timm Bäder
3d65019e98 notebook: Handle touch events for tabs
No need to check for the event type here.
2018-02-03 12:23:00 +01:00
Emmanuele Bassi
c655759cef Replace gdk_threads_add_timeout* with g_timeout_add()
The main GDK thread lock is not portable and deprecated.

The only reason why gdk_threads_add_timeout() and
gdk_threads_add_timeout_full() exist is to allow invoking a callback
with the GDK lock held, in case 3rd party libraries still use the
deprecated gdk_threads_enter()/gdk_threads_leave() API.

Since we're removing the GDK lock, and we're releasing a new major API,
such code cannot exist any more; this means we can use the GLib API for
installing timeout callbacks.

https://bugzilla.gnome.org/show_bug.cgi?id=793124
2018-02-03 12:06:58 +01:00
Matthias Clasen
fa07fe2124 notebook: some cleanup 2018-01-16 14:14:10 -05:00
Matthias Clasen
af8bf498e9 notebook: Use a motion event controller
This lets us avoid the ::motion-notify-event handler.
2018-01-16 14:14:10 -05:00
Timm Bäder
7479e6cb50 notebook: Fix wrong tab widgets allocation
Since we allocate the tab widgets on demand, we have to queue an extra
resize here.
2018-01-04 21:41:35 +01:00
Timm Bäder
1c267398ef notebook: Make a code snippet compile 2018-01-03 17:11:32 +01:00
Matthias Clasen
54a6273191 Drop gdk_atom_intern
Atoms are just interned strings now, so we can just
use g_intern_string.
2017-12-13 23:39:03 -05:00
Benjamin Otte
04ac4c66ae dnd: Pass device, not event
You don't start a dnd operation with a device, you start it with an
event.
2017-12-12 00:31:49 +01:00
Benjamin Otte
756b276070 dnd: Remove button argument from drag_begin()
It was unused.
2017-12-12 00:29:51 +01:00
Benjamin Otte
7a17865b22 dnd: Remove "delete" argument from gtk_drag_finish()
The argument is ignored by anything but X11.
It's treated like suggested_action == MOVE.

So do that in gtk_drag_finish(), too.
2017-12-10 01:33:38 +01:00
Benjamin Otte
4658d7ea54 dnd: Remove x/y coordinates from drag-data-received
This is in preparation of using input streams to show that these
coordinates aren't needed most of the time and can otherwise be saved
during GtkWidget::drag-drop.
2017-12-05 05:29:00 +01:00
Benjamin Otte
9a6ec4e959 contentformats: Rename GtkTargetList
It's now called GdkContentsFormat
2017-11-20 23:12:33 +01:00
Benjamin Otte
c863ac0f90 dnd: Remove GtkTargetEntry and GtkTargetFlags
warning: We don't do any same-app checks anymore so you currently can
copy local data into external apps.

This will be fixed later.
2017-11-20 23:12:33 +01:00
Matthias Clasen
ffd6baec42 gtk: Intern css names
This avoids a bunch of strdups at startup.
2017-11-17 22:49:57 -05:00
Benjamin Otte
3f5178dc21 selection: Remove the info uint
Instead of allowing people to pass a uint user-data, insist on them
comparing mime types.

The user data was a uint instead of a pointer anyway, so uniqueness
could not be guaranteed and it caused more issues than it was worth.
And that's ignoring the fact that it basically wasn't used.
2017-11-16 22:59:43 +01:00
Benjamin Otte
5a1a11bcde dnd: Make GtkDragDest and GtkDragSource use GtkTargetList
This gets rid of GtkTargetEntry in the API and consistently uses
GtkTargetList.
2017-11-15 19:07:17 +01:00
Timm Bäder
11b8f27b76 notebook: Fix setting show-tabs
show-tabs=FALS means the notebook is not supposed to show tabs,
regardless of whether it has a current page or not.
2017-11-03 11:22:44 +01:00
Timm Bäder
2603fa0cc3 notebook: Remove useless call to gtk_widget_reset_style 2017-11-03 11:22:44 +01:00
Matthias Clasen
a3cffa5072 Drop GdkScreen from GdkDevice apis
Returning the screen does not add anything here and
GdkScreen is going away.
2017-10-31 12:30:38 -04:00
Matthias Clasen
9f8f3fc7ac notebook: Don't steal right-clicks from content
We only want to pop up the context menu in the tab strip.
2017-10-07 19:26:39 -04:00
Benjamin Otte
43c212ac28 build: Enable -Wswitch-enum and -Wswitch-default
This patch makes that work using 1 of 2 options:

1. Add all missing enums to the switch statement
  or
2. Cast the switch argument to a uint to avoid having to do that (mostly
   for GdkEventType).

I even found a bug while doing that: clearing a GtkImage with a surface
did not notify thae surface property.

The reason for enabling this flag even though it is tedious at times is
that it is very useful when adding values to an enum, because it makes
GTK immediately warn about all the switch statements where this enum is
relevant.
And I expect changes to enums to be frequent during the GTK4 development
cycle.
2017-10-06 21:23:39 +02:00
Carlos Garnacho
b9db1a5410 notebook: Update to using GdkEvent API 2017-09-19 18:39:02 +02:00
Philip Withnall
69102ac8df gtknotebook: Simplify some if-conditions
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=787303
2017-09-12 15:22:13 +01:00
Timm Bäder
9f3f640c0d widget: Remove gtk_widget_get_border_allocation 2017-08-14 12:22:39 +02:00
Timm Bäder
9c7e089fc2 widget: Remove gtk_widget_get_margin_allocation
It's not needed anymore with get_outer_allocation (which will be
replaced by something more appropriately named).
2017-08-14 12:22:39 +02:00
Daniel Boles
fc619706b7 Notebook: Remove null check after dereference
This function clearly assumes the parameter children cannot be NULL, and
the call sites seem to perform enough checks to confirm this.

CID 1388869 (#1 of 1): Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking children suggests that it may be null,
but it has already been dereferenced on all paths leading to the check.
2017-08-01 20:15:14 +01:00
Timm Bäder
343f2d8c08 notebook: Set tabs child visible before allocating a size
Otherwise we might skip them here, then set child-visible to TRUE and
then later snapshot them even though they have no valid size.
2017-07-22 19:36:05 +02:00
Timm Bäder
36ab70ddf5 widget: Add baseline and out_clip parameters to size-allocate
Since setting a clip is mandatory for almost all widgets, we can as well
change the size-allocate signature to include a out_clip parameter, just
like GtkCssGadget did. And since we now always propagate baselines, we
might as well pass that one on to size-allocate.

This way we can also make sure to transform the clip returned from
size-allocate to parent-coordinates, i.e. the same coordinate space
priv->allocation is in.
2017-07-19 21:27:16 -04:00
Timm Bäder
831bcc5e0d notebook: Allocate unmapped tabs 2017-07-19 21:27:15 -04:00
Timm Bäder
45c0439dd4 notebook: Fix css node ordering
Aaand all the unit tests pass again.
2017-07-19 21:27:14 -04:00
Timm Bäder
8dc5e13e8c iconview: Remove bin_window 2017-07-19 21:27:14 -04:00
Timm Bäder
07063d82aa notebook: Remove style properties
Hardcode the default values until someone comes up with a proposal for a
better way.
2017-07-19 21:27:14 -04:00
Timm Bäder
4f0140fa6c Remove GtkBuiltinIcon
Now unused.
2017-07-19 21:27:13 -04:00
Timm Bäder
6f2145be00 notebook: Replace all gadgets with widgets 2017-07-19 21:27:13 -04:00
Timm Bäder
0c0a402433 notebook: Replace tab gadget with GtkGizmo 2017-07-19 21:27:12 -04:00
Timm Bäder
8edf10103e notebook: Replace tabs gadget with GtkGizmo 2017-07-19 21:27:12 -04:00
Timm Bäder
195ca06c2c notebook: Replace arrow gadgets with GtkIcons 2017-07-19 21:27:12 -04:00
Timm Bäder
ede6f2ab59 Slightly rework clip handling
always initialize clips to the (content) allocation, don't walk up the
widget hierarchy in gtk_widget_set_clip, implement
gtk_widget_size_allocate in GtkSeparator. This way we don't end up using
uninitialized clip values.

The entire clip handling is up for major rework since we can't and don't
want to force every single widget to call _set_clip in size-allocate
implementations.
2017-07-19 21:27:12 -04:00
Timm Bäder
8aefa09765 notebook: Fix crash when dragging a tab
gtk_gesture_get_last_event can return NULL, so guard against that.
2017-07-19 21:27:11 -04:00
Iñaki García Etxebarria
59a22b3d7e Add nullable return annotation to gtk_notebook_get_tab_label
https://bugzilla.gnome.org/show_bug.cgi?id=781935
2017-07-18 15:07:49 -04:00
Carlos Garnacho
f9924b7e3e gtknotebook: Drop drag_window
It is not necessary anymore to implement tab DnD, since we just render
it on top.
2017-05-25 16:25:59 +02:00
Carlos Garnacho
3dd8a4191a gtknotebook: Remove event window on top of tabs
No longer needed.
2017-05-25 16:25:59 +02:00
Carlos Garnacho
a72404dd5a gtk: Mass delete all GtkWidget event mask API
We now rely on toplevels receiving and forwarding all the events
the windowing should be able to handle. Event masks are no longer a
way to determine whether an event is deliverable ot a widget.

Events will always be delivered in the three captured/target/bubbled
phases, widgets can now just attach GtkEventControllers and let those
handle the events.
2017-05-25 16:25:58 +02:00
Carlos Garnacho
99e200aa98 gtknotebook: Fix coordinate translation to happen on widget-relative coordinates
This makes notebooks happy again after changing event coordinates to always come in
the widget coordinate system.
2017-05-25 16:25:58 +02:00
Timm Bäder
f053a63d74 container: Remove include_internals parameter from forall
with include_internals=TRUE, this is the same as the (still private)
gtk_widget_forall, or just using the children/sibling accessors in a
loop.
2017-04-25 20:30:37 +02:00
Timm Bäder
43cdeee3c4 widget: Save pointer to focus child
Do the same thing GtkContainer does.
2017-03-31 09:50:39 +02:00
Timm Bäder
58f3202e4f notebook: Remove dead assignment 2017-03-19 17:05:34 +01:00
Timm Bäder
e1f8d5a647 notebook: Use gtk_widget_measure 2017-02-18 19:01:28 +01:00
Michael Catanzaro
3905726627 notebook: redraw arrows after closing a tab
Thanks to Daniel Boles for helping with a crash in an earlier version of
this patch.

https://bugzilla.gnome.org/show_bug.cgi?id=777547
2017-02-04 12:57:08 -06:00
Michael Catanzaro
03c026e6b6 Revert "notebook: redraw arrows after closing a tab"
This reverts commit 218beb2ef4.
2017-01-27 08:54:24 -06:00
Michael Catanzaro
218beb2ef4 notebook: redraw arrows after closing a tab
https://bugzilla.gnome.org/show_bug.cgi?id=777547
2017-01-24 08:33:35 -06:00
Timm Bäder
47d4ad71fb Remove gtk_container_snapshot_child
Replace it with the already existing gtk_widget_snapshot_child.
2017-01-07 17:19:30 +01:00
Benjamin Otte
c4065b9ee0 API: Export gtk_container_snapshot_child()
It's equivalent to gtk_container_propagate_draw() and then one is
public, too.
2016-12-20 19:26:40 +01:00
Benjamin Otte
0dbdf0c428 gadget: Remove gtk_css_gadget_draw()
And with it, remove the draw func from custom gadgets, that has been
NULL everywhere.

All gadgets are snapshot now.
2016-12-20 18:01:12 +01:00
Piotr Drąg
a2da4ddceb Use Unicode in translatable strings
See https://developer.gnome.org/hig/stable/typography.html

https://bugzilla.gnome.org/show_bug.cgi?id=772371
2016-12-19 15:08:10 -05:00
Benjamin Otte
e755d9357d notebook: Implement snapshot 2016-12-19 05:36:06 +01:00
Matthias Clasen
1dded6d633 notebook: Don't leak arrow gadgets
This was pointed out in
https://bugzilla.gnome.org/show_bug.cgi?id=774743
2016-11-23 14:44:37 -05:00
Benjamin Otte
4850271ae8 API: Remove gtk_cairo_should_draw_window()
The answer is: Yes.
2016-11-23 18:48:38 +01:00