Commit Graph

614 Commits

Author SHA1 Message Date
Benjamin Otte
182f9a7f39 notebook: Remove "active-page" class
Instead, just use the "tab:active" selector
2015-10-22 16:42:48 +02:00
Benjamin Otte
2720d97db3 notebook: Remove funciton by folding it into callers 2015-10-22 16:42:48 +02:00
Benjamin Otte
acd63a6019 notebook: Refactor internal function
Don't return the state anymore as the function doesn't even look at the
state. Instead, make the callers that need the state query it manually.
2015-10-22 16:42:48 +02:00
Benjamin Otte
7b9844288a notebook: Make tab positions permanent
... on the tab CssNodes.
2015-10-22 16:42:48 +02:00
Benjamin Otte
dd3f2ec987 notebook: Remove last traces of regions
Now that we don't use regions anymore, there's no need to update
anything when the regions change.
2015-10-22 16:42:47 +02:00
Benjamin Otte
f713bcd742 notebook: Set reorderable-page style class properly
Set it when the reorderable state changes, not just when rendering.
2015-10-22 16:42:47 +02:00
Benjamin Otte
a4e86341e4 notebook: Set active state properly
Don't update it on save/restore, actually set it when it changes.
2015-10-22 16:42:47 +02:00
Benjamin Otte
541926089a notebook: Set prelight state properly
Don't update it on save/restore, actually set it when it changes.
2015-10-22 16:42:47 +02:00
Benjamin Otte
3392d53f61 notebook: Use CssNodes instead of regions
This almost makes CSS work again with notebooks.
2015-10-22 16:42:47 +02:00
Benjamin Otte
01f7711307 notebook: Move style_context_save() into function
This is for future changes.
2015-10-22 16:42:47 +02:00
Alexander Larsson
d5f1754981 gtk: Stop setting GDK_EXPOSURE_MASK on random widgets
These days exposure happens only on the native windows (generally the
toplevel window) and is propagated down recursively. The expose event
is only useful for backwards compat, and in fact, for double buffered
widgets we totally ignore the event (and non-double buffering breaks
on wayland).

So, by not setting the mask we avoid emitting these events and then
later ignoring them.

We still keep it on eventbox, fixed and layout as these are used
in weird ways that want backwards compat.
2015-09-14 11:01:13 +02:00
Matthias Clasen
f4b53d4b0c notebook: Drop use of G_DISABLE_CHECKS
Rewrite the one check that the G_DISABLE_CHECKS macro was used for
in terms of g_return_if_fail.
2015-09-09 06:32:46 -04:00
Matthias Clasen
838d5beff7 notebook: Convert to g_object_notify_by_pspec 2015-09-08 08:07:33 -04:00
Benjamin Otte
4daac59941 notebook: Don't needlessly cast in macros
That way we disable typechecks done by the compiler and won't notice
when we pass the wrong values to the macro. And that's bad.
2015-09-07 14:33:50 +02:00
Benjamin Otte
f138efa59a notebook: Remove unused macros 2015-09-07 14:33:40 +02:00
Carlos Garnacho
3e60650fa8 notebook: Fix assert in ::drag-motion
The drag destination might be empty, we shouldn't be checking whether
it contains pages at all. Instead, check the source notebook, which
ought to have a selected page if you're dragging something from there.

https://bugzilla.gnome.org/show_bug.cgi?id=749893
2015-05-26 18:05:36 +02:00
Benjamin Otte
0529e15d61 notebook: Protect against invalid allocations
A widget can be mapped but not have a size allocated yet. In that case
avoid computing a broken rectangle.

https://bugzilla.gnome.org/show_bug.cgi?id=746301
2015-03-18 15:14:47 +01:00
Matthias Clasen
c7672699e9 Don't pass invalid rectangles to cairo
This causes pixman warnings, or worse.
Clearly, something is not quite right here, if we end up
redrawing tabs at a time when the allocation is set to (1, 1).
For now, avoid straining the error handling in the lower layers.

https://bugzilla.gnome.org/show_bug.cgi?id=746301
2015-03-16 12:51:56 -04:00
Philip Withnall
d65ccf96ee gtknotebook: Add more non-NULL checks for cur_page
These were not spotted by scan-build, but from some brief mental
reasoning could potentially be problem areas.

https://bugzilla.gnome.org/show_bug.cgi?id=712760
2015-03-11 11:24:29 +00:00
Benjamin Otte
9e2cdce58e notebook: Fix boolean check
Commit c352093bde swapped the condition
when turning it into a return_if_fail().
2015-03-10 13:23:06 +01:00
Philip Withnall
c352093bde gtknotebook: Fix potential use of uninitialised variables
Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=712760
2015-03-10 07:32:19 +00:00
Philip Withnall
51971d56bc gtknotebook: Remove dead variable assignments
Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=712760
2015-03-09 13:41:37 +00:00
Philip Withnall
c7f5f10853 gtknotebook: Fix a potential NULL pointer dereference
Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=712760
2015-03-09 13:41:37 +00:00
Matthias Clasen
8d7a235a04 notebook: Add api to complete tab dnd from the outside
This is necessary to avoid unwanted drag cancel animations,
now that GtkNotebook is careful about cancelling a drag
when the dragged tab disappears unexpectedly.
2015-02-12 17:33:10 -05:00
Matthias Clasen
3fc21b4f3f notebook: Protect removal-from-within
When a tab is dropped, we have to remove it from the notebook to
insert it elsewhere. This is expected part of the tab dnd operation,
and we need to differentiate it from 'spontaneous' removals which
cause us to cancel the drag operation.
2015-01-30 10:13:28 -05:00
Matthias Clasen
63104944a3 notebook: Make dnd safe against tab disappearance
when the dragged tab is being removed during the drag operation,
we need to cancel the drag. To do so, we have to keep around
a reference to the drag context.

This should fix
https://bugzilla.gnome.org/show_bug.cgi?id=732051
2015-01-30 10:13:15 -05:00
Matthias Clasen
3a05d9b5a0 notebook: Make reordering safe for tab disappearance
If the dragged tab is removed during reordering, we need to
call gtk_notebook_stop_reorder(), to clean up and bring the
remaining tabs back in order.
2015-01-30 09:39:26 -05:00
Matthias Clasen
5127136723 GtkNotebook: Be a bit more safe against cur_page being NULL
https://bugzilla.gnome.org/show_bug.cgi?id=477454
2014-12-22 10:52:54 -05:00
Jasper St. Pierre
a78b18c565 Revert part of "gtknotebook: Optimize GtkStyleContext usage"
This reverts part of commit c71e213134.
This part was unfinished and was pushed simply to avoid the warnings.
2014-11-25 11:21:21 -08:00
Jasper St. Pierre
c71e213134 gtknotebook: Optimize GtkStyleContext usage 2014-11-25 11:05:49 -08:00
Benjamin Otte
cde81e169b notebook: Don't unset state flags on child removal
We don't set any state flags, so we shouldn't unset any either.
2014-07-19 23:48:06 +02:00
Benjamin Otte
93b3179042 widgetpath: Deprecate regions
This is a foolowup to d80bf0790d
2014-06-21 15:46:44 +02:00
Benjamin Otte
d80bf0790d stylecontext: Deprecate regions
Regions are done in a very non-css way. They don't fit the DOM in that
they don't integrate into the CSS tree and they have very weird matching
behavior in selectors.

So I'm deprecating them now. GtkNotebook and GtkTreeview will continue
to use them and as long as they do, we can't remove the code for it.
But once those are ported it might be safe to remove the code as it will
clean up lots of places in the code by quite a bit.
2014-06-19 22:26:51 +02:00
Matthias Clasen
f0f9c2aa37 Revert "gtkbin: replace internal api"
This reverts commit 0f4751c08e.

This causes warnings from the notebook and combobox code.
2014-06-16 17:31:56 -04:00
Paolo Borelli
c184458ab3 notebook: set tab position style class on the main frame
We want to have .top etc also on the notebook frame, not only on
the header frame.
The patch includes a reftest by Benjamin.
2014-06-14 21:37:07 +02:00
Stefan Sauer
0f4751c08e gtkbin: replace internal api 2014-06-14 08:10:46 +02:00
Matthias Clasen
c93355616f GtkNotebook: Use G_PARAM_EXPLICIT_NOTIFY 2014-06-09 13:31:06 -04:00
Matthias Clasen
4d1930cf74 Make notebook content redraw during drag
The extra condition here that caused the current child to
not redraw during reordering was introduced in f383e1f1
during the port to ::draw, but was not explained in the
commit message, and removing it has no obvious negative
effect.

https://bugzilla.gnome.org/show_bug.cgi?id=730767
2014-05-30 13:39:27 -04:00
Cosimo Cecchi
853dcc615d notebook: don't use focus-line-width 2014-05-09 11:02:45 -07:00
Cosimo Cecchi
9a811e2c94 notebook: don't use focus padding 2014-05-09 11:02:43 -07:00
William Jon McCann
469d333aa2 docs: use Returns: consistently
Instead of Return value:
2014-02-19 18:56:05 -05:00
William Jon McCann
37a8ee6e95 docs: fully break lines in examples
Try to do a better job of keeping example content
from being too wide. It is often rendered as <pre>
text so the only time we can wrap it is in the source.

It is best to full break lines at all punctuation and
to try to keep the width under 70 chars or so.
2014-02-12 18:42:50 -05:00
Matthias Clasen
7f6a964c47 Docs: Remove all entities and turn off sgml mode
With all element markup gone, it is time to turn off
sgml mode, and get rid of entities as well.
2014-02-09 17:58:07 -05:00
William Jon McCann
13998c55e7 docs: use proper quotations instead of '*' 2014-02-07 14:22:39 -05:00
William Jon McCann
2a45418b67 docs: use proper quotes 2014-02-05 15:08:42 -05:00
William Jon McCann
3b3d8ca456 docs: Use "#" for refsect2 instead of ## 2014-02-04 21:00:58 -05:00
Matthias Clasen
09d1b28249 docs: Convert to markdown
Specifically, switch to using markdown syntax for sections.
2014-02-02 00:30:27 -05:00
William Jon McCann
4c8bd8e7cf docs: Identify examples that are C code
https://bugzilla.gnome.org/show_bug.cgi?id=723119
2014-01-29 12:45:49 -05:00
William Jon McCann
768bc44081 docs: use |[ ]| instead of <programlisting></programlisting>
https://bugzilla.gnome.org/show_bug.cgi?id=723119
2014-01-29 12:45:49 -05:00
William Jon McCann
6fd7e547c5 notebook: don't use a null page 2014-01-24 18:41:22 -05:00
William Jon McCann
66f8026622 notebook: add a style class when the child tab is reorderable 2014-01-24 17:27:27 -05:00
William Jon McCann
3437f83ff3 notebook: add a style for prelighted labels 2014-01-24 13:15:44 -05:00
Paolo Borelli
609ddec1f8 Always return FALSE from the notebook leave_notify handler
As discussed on IRC with Benjamin, this should not make much
difference in practice, but it is more correct
2014-01-14 20:29:46 +01:00
Paolo Borelli
84b44dd2ac Readd line removed by mistake in the previous commit 2014-01-14 20:23:52 +01:00
Paolo Borelli
4a3f21b693 Prelight notebook tab
Set the prelight state when hovering a notebook tab with the mouse.

https://bugzilla.gnome.org/show_bug.cgi?id=711233
2014-01-14 20:18:54 +01:00
Matthias Clasen
64855f1295 GtkNotebook: Fix a problem with tab states
When replacing the tab label, we were not adding the
active-page style class. Fix that.
2014-01-04 13:01:49 -05:00
Bastien Nocera
438cd857c4 all: Add names to timeouts
Add names to every timeout we setup, so it's easier to track their
usage, and debug possible misbehaviour.

https://bugzilla.gnome.org/show_bug.cgi?id=710651
2013-10-23 13:31:18 +02:00
William Jon McCann
05b1ea84b4 notebook: inform the theme whether show-borders was set
So that it can draw a border or not. If show-borders=true then
the notebook will have GTK_STYLE_CLASS_FRAME.
2013-10-16 12:03:33 -04:00
William Jon McCann
6f17c408e6 notebook: inform the theme to draw borders when requested
When the show-border property is TRUE ask the theme to draw
borders on the notebook header.
2013-10-04 18:14:25 -04:00
William Jon McCann
053433010b notebook: add style classes for orientation to the header 2013-10-04 18:14:25 -04:00
William Jon McCann
db60046af4 notebook: correctly define the header region
Correctly define the header region to only be the area under the
tabs.
2013-10-04 18:14:25 -04:00
William Jon McCann
e9b9fd20b9 notebook: Add a style property for whether to draw a tab gap
Add a has-tab-gap style property to GtkNotebook so that we can
disable drawing the gap between tabs and the page in the Adwaita
theme without breaking existing themes.

https://bugzilla.gnome.org/show_bug.cgi?id=707920
2013-10-02 10:51:16 -04:00
William Jon McCann
b609377e3e notebook: Fix rounding error in vertical alignment of arrow
https://bugzilla.gnome.org/show_bug.cgi?id=707920
2013-10-02 10:51:16 -04:00
William Jon McCann
e07fec3e83 notebook: Make notebook scroll arrows honor initial gap setting
So that they can be styled so they are not right on the edge.

https://bugzilla.gnome.org/show_bug.cgi?id=707920
2013-10-02 10:51:16 -04:00
William Jon McCann
81b0808849 notebook: Use initial-gap on both edges of the tab header
https://bugzilla.gnome.org/show_bug.cgi?id=707920
2013-10-02 10:51:15 -04:00
Cosimo Cecchi
71ad9a8fdd notebook: render a frame and background in the header
And use the "header" style class to do that.
This allows themes to set e.g. the background of the tab header
differently.

Themes will need slight adjustment to make things appear
as before.

https://bugzilla.gnome.org/show_bug.cgi?id=643914
2013-09-26 19:27:54 -04:00
Cosimo Cecchi
a2ed88b3ee Allow active tab children to be styled
This allows one to style the children of an active
tab label from CSS.

https://bugzilla.gnome.org/show_bug.cgi?id=691163
2013-09-26 19:19:53 -04:00
Matthias Clasen
bd1df33798 Trivial: correct vfunc signatures
Harmless confusion between gint and gboolean
https://bugzilla.gnome.org/show_bug.cgi?id=697031
2013-09-26 19:16:14 -04:00
Matthias Clasen
624ec0fb7d Add a style class for context menus
Attached widgets inherit from the style of the widget they are
attached to. This can sometimes have unintended consequences,
like a context menu in the main view of gedit inheriting the font
that is configured for documents, or the context menu of the preview
in the font chooser coming up with humongous font size.

To fix this problem, we introduce a context menu style class
and use it for all menus that are used like that. The theme
can then set a font for this style class.

https://bugzilla.gnome.org/show_bug.cgi?id=697127
2013-08-18 13:46:48 -04:00
Jasper St. Pierre
030b62d122 gtkdnd: Introduce a new API for more accurate drag origin data
When trying to drag, we currently the position of the first motion
event to determine where the drag came from. This might be alright
in the case of the old animation, but the data will be inaccurate
if the user has moved the pointer quite a bit since pressing the
cursor to start dragging. While we could monkey patch the GdkEvent
at the widget layer, this is unintuitive and strange.

Add a new API that takes a set of pointer coordinates describing
the origin of the drag. Additionally, adapt most widgets to use
it and use it with correct coordinates.

https://bugzilla.gnome.org/show_bug.cgi?id=705605
2013-08-14 07:12:52 -04:00
William Jon McCann
57fc8763e9 Deprecate and ignore the timeout-initial and timeout-repeat settings 2013-07-11 17:08:15 -04:00
Emmanuele Bassi
0899ef7cc9 gtk: Use new macros for defining private data
https://bugzilla.gnome.org/show_bug.cgi?id=702996
2013-07-09 09:30:02 +01:00
William Jon McCann
b101d465be Deprecate and ignore gtk-keynav-cursor-only and gtk-keynav-wrap-around 2013-06-26 15:33:10 -04:00
Matthias Clasen
3b4804bbf1 Always use gint for border_width
This avoids an evil trap when doing MAX (..., ... - 2 * border_width)
and the expression on the right gets promoted to unsigned, instead
of going negative as you would expect.
https://bugzilla.gnome.org/show_bug.cgi?id=699633
2013-05-04 19:21:56 -04:00
Benjamin Otte
1349292e47 widget: Adapt _gtk_widget_get_preferred_size_for_size()
... for baseline support byu taking two extra (possible NULL) arguments.
2013-05-01 16:41:11 +02:00
Matthias Clasen
af49dd33cf GtkNotebook: Consistent boolean handling
Normalize boolean parameters in gtk_notebook_set_tab_reorderable and
gtk_notebook_set_tab_detachable before comparing them. Pointed out in
https://bugzilla.gnome.org/show_bug.cgi?id=697196
2013-04-24 19:58:22 -04:00
Benjamin Otte
3450388ff0 sizerequest: Split out a common function 2013-04-22 18:29:01 -04:00
Alexander Larsson
3d4cd4db3e Add gtk_widget_(un)register_window
This replaces the previously hardcoded calls to gdk_window_set_user_data,
and also lets us track which windows are a part of a widget. Old code
should continue working as is, but new features that require the
windows may not work perfectly.

We need this for the transparent widget support to work, as we need
to specially mark the windows of child widgets.

https://bugzilla.gnome.org/show_bug.cgi?id=687842
2013-02-07 11:11:37 +01:00
Matthias Clasen
52af9aede6 GtkNotebook: Clarify a switch statement
We were intentionally falling through here, this commit
just adds comments to make that explicit.
2012-11-29 23:10:34 -05:00
Cosimo Cecchi
852d4d618c notebook: return TRUE for drag-motion event when over tabs
The GtkNotebook drag-motion event handler may install a timeout when
hovering over a tab, in order to switch to it.
On the other hand it's desirable for applications to use the empty tab
area as a drop target, so the drag-motion handler returns FALSE
(also in case it installs the switch tab timeout), as explained in
https://bugzilla.gnome.org/show_bug.cgi?id=350665.

Unfortunately, applications can use the tab label widget (or a child
of it) as a different drop target area, and install their own
drag-motion handler there.
In this scenario, the timeout will still be installed by GtkNotebook's
handler, but since it returns FALSE, it will never get the matching
drag-leave event, causing it to trigger also when the mouse pointer
moved elsewhere before it expired.

Fix this by returning TRUE from drag-motion when the event is over a
tab. Note that this makes automatic tab switching not work anymore when
drag and drop is handled in the tab label widget; applications are
expected to also handle tab switching if desired in such a case.

https://bugzilla.gnome.org/show_bug.cgi?id=684415
2012-10-22 18:39:37 -04:00
Cosimo Cecchi
42da600eb1 notebook: consolidate code to remove the switch tab timer
https://bugzilla.gnome.org/show_bug.cgi?id=684415
2012-10-22 18:37:47 -04:00
Cosimo Cecchi
c1218f964a notebook: restore previous behaviour wrt. unparenting of tab labels
When the tab label gets removed from the notebook on widget
desctruction, we should still unconditionally unparent it from the
notebook, since failing to do so will keep a stray reference alive.

In case applications rely on the tab label being destroyed to release
other references (e.g. because the tab label is a custom object, or
another object's lifecycle is tied to it using g_object_set_data_full()),
this will also possibly cause other references to get leaked.
In Nautilus, the result was we were failing to release the reference to
a NautilusWindowSlot, and other parts of the application relied
on it being destroyed at a specific time instead, causing the
application to crash when closing a window.

This is a regression from commit
325cf071d1.

This commit restores the previous unparenting behavior in case we're not
in a DnD operation.

https://bugzilla.gnome.org/show_bug.cgi?id=680349
2012-07-31 20:17:54 +02:00
Cosimo Cecchi
f70fc49ebc docs: fix a number of typos and obsolete references 2012-07-02 10:41:11 -04:00
Matthias Clasen
cea4b80096 Fix a compiler warning
This was introduced in the previous commit.
2012-06-23 13:07:47 -04:00
Matthias Clasen
3056324570 GtkNotebook: Fix reverse tab order
When using Shift-Tab to move the focus out of page content onto
the tab label, we end up in a situation where both Tab and Shift-Tab
move focus back into the page, which is not really what is expected
when the notebook is part of a dialog.

Instead, arrange things so that using Shift-Tab with focus on a
tab label moves the focus out of the notebook.

http://bugzilla.gnome.org/show_bug.cgi?id=669986
2012-06-23 12:37:20 -04:00
Matthias Clasen
325cf071d1 GtkNotebook: Maintain invariants during tab dnd
It turns out that we can end up removing a notebook child while
the tab is still 'detached'. Child removal causes
gtk_notebook_remove_tab_label() to be called on the tab label,
but that function did not deal with the eventuality that the tab
label may be a child of the dnd window.

http://bugzilla.gnome.org/show_bug.cgi?id=677943
2012-06-23 10:04:14 -04:00
Cosimo Cecchi
10a4771ae3 notebook: fix size requisition for the initial_gap style property
This is probably going to be replaced by something different soon, but
in the meantime, fix this annoying bug, visible e.g. in widget-factory
for left/right tab examples.
2012-05-30 18:02:42 -04:00
Matthias Clasen
d44edc1f7d Revert "WIP: make GtkNotebook window-draggable"
This reverts commit b3a66c59ad.
2012-04-28 02:06:37 -04:00
Diego Escalante Urrelo
b3a66c59ad WIP: make GtkNotebook window-draggable
https://bugzilla.gnome.org/show_bug.cgi?id=672427

https://bugzilla.gnome.org/show_bug.cgi?id=674587
2012-04-28 02:01:16 -04:00
Benjamin Otte
ece9d2fd92 gtk: Make widget only invalidate widget positions
Instead of resetting them completely
2012-04-17 08:59:10 +02:00
Benjamin Otte
461803e407 gtk: Get gtkwidgetpath.h includes out of the public headers
and include them in the C files instead.
2012-03-19 02:26:16 +01:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Claudio Saavedra
cfe65a0d6c GtkNotebook: and another fix
https://bugzilla.gnome.org/show_bug.cgi?id=669116
2012-02-16 12:33:26 +02:00
Claudio Saavedra
ccf7867c35 GtkNotebook: fix one child-notify emission
Forgot to increase the counter in the for loop, doing it now.

https://bugzilla.gnome.org/show_bug.cgi?id=669116
2012-02-16 12:28:46 +02:00
Claudio Saavedra
347328adb0 GtkNotebook: emit child-notify::position on drag 'n drop reorder
https://bugzilla.gnome.org/show_bug.cgi?id=669116
2012-02-15 01:05:12 +02:00
Claudio Saavedra
cb775a6a6d GtkNotebook: emit child-notify::position on page add/removal
For each page added/removed, notify all the other children changing
position.

https://bugzilla.gnome.org/show_bug.cgi?id=669116
2012-02-15 01:05:12 +02:00
Claudio Saavedra
e2339f5ebd GtkNotebook: emit child-notify::position a few more times
When moving a page around, all children changing their position
need to be notified.

There are still other places where proper notification is missing
(drag 'n drop, etc.)

https://bugzilla.gnome.org/show_bug.cgi?id=669116
2012-02-10 16:39:44 +02:00
Carlos Garcia Campos
594903ecde gtknotebook: Use symbolic names for button numbers 2012-01-27 09:47:43 +01:00
Cosimo Cecchi
637e6688da notebook: fixup previous commit
Oops, I hit push too early.
2012-01-18 16:14:31 -05:00
Cosimo Cecchi
70cf23a729 notebook: don't force ACTIVE state flag on the label for active tab
This is just wrong, since it's not the tab label being active, but the
tab itself.
2012-01-18 16:13:25 -05:00