Commit Graph

135 Commits

Author SHA1 Message Date
Timm Bäder
a08f8937c6 Revert "headerbar: Avoid allocating 0 visible children"
This reverts commit 8c0e5adaab.

This is actually needed since GtkHeaderBar will allocate and snapshot
widget that coun_visible_children does not consider.
2017-08-28 17:50:34 +02:00
Timm Bäder
8c0e5adaab headerbar: Avoid allocating 0 visible children
Ths avoids doing a bunch of work as well as passing 0 to g_alloca which
is undefined.
2017-08-28 11:17:47 +02:00
Timm Bäder
a8a755e5cd widget: Remove gtk_widget_set_redraw_on_alloc
Since gtk+ draws more than the widget and allocates more size to it than
it knows about, this flag doesn't work anymore. Removing it (or setting
it to TRUE for widgets that used to set it to FALSE) fixes drawing
invalidation when these widgets get allocated a new size.
2017-08-09 16:26:26 +02:00
Daniel Boles
be85c8b1fd HeaderBar: Use less clashing appmenu fallback icon
process-stop-symbolic is unintuitive if represented as a stop sign as in
Adwaita, and completely ambiguous if represented as a cross like the
window close button in other icon themes.

Instead, use application-x-executable, which is already used elsewhere
as a fallback if no specific icon can be found for the application.

https://bugzilla.gnome.org/show_bug.cgi?id=784624
2017-08-06 18:03:27 +01: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
a8561bcc99 headerbar: don't measure own size
This is fallout from an earlier commit, we should be checking the
child's size of course, not repeatedly the headerbar's.
2017-07-19 21:27:15 -04:00
Timm Bäder
2cd1a984cf set clip of more widgets 2017-07-19 21:27:11 -04:00
Timm Bäder
bced18b3c5 headerbar: Remove gadget
both drawing and sizing are done through GtkWidget now.
2017-07-19 21:27:11 -04:00
Timm Bäder
a9b1c04c3f headerbar: Remove css box drawing 2017-07-19 21:27:10 -04:00
Will Thompson
176bc32950
headerbar: fix "widow" typo in docs 2017-06-15 15:53:18 +01:00
Timm Bäder
2a0a87049e headerbar: Compute clip directly 2017-04-28 11:27:09 +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
c92b7d4224 box: Remove fill child property
GtkWidget:halign and GtkWidget:valign are sufficient
2017-04-25 20:30:37 +02:00
Timm Bäder
5729ea7744 box: Remove expand child property
GtkWidget already has hexpand/vexpand properties.
2017-04-25 20:30:37 +02:00
Alberts Muktupāvels
acf50005ab gtkheaderbar: add style classes to all title buttons
Commit b187773053 added CSS style
classes for minimize, maximize and close buttons. Add similar classes
also to icon and menu buttons.

https://bugzilla.gnome.org/show_bug.cgi?id=780944
2017-04-06 15:34:49 +03:00
Timm Bäder
c71c3954f4 headerbar: Fix size requisition variable mixup
Happened when porting to gtk_widget_measure.
2017-03-17 18:49:52 +01:00
Timm Bäder
56a58655fe Remove unnecessary gtk_widget_show calls 2017-01-22 14:38:21 +01:00
Timm Bäder
f4341ee9f7 widget: Remove show-all property
Doesn't make sense anymore now that gtk_widget_show_all is gone.
2017-01-20 21:37:07 +01:00
Timm Bäder
ea897c6df4 Remove gtk_widget_show_all 2017-01-20 21:37:04 +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
Timm Bäder
7f8d0acfd3 headerbar: measure children using gtk_widget_measure 2016-12-04 12:00:46 +01:00
Benjamin Otte
92e6b3a000 snapshot: Port GtkHeaderBar 2016-11-15 17:48:45 +01:00
Benjamin Otte
da207c9fdd snapshot: Add a snapshot function to GtkCssCustomGadget 2016-11-15 17:48:45 +01:00
Matthias Clasen
547970b0bc headerbar: Don't leak widgets
We were not properly freeing separators that we end up
not using.

https://bugzilla.gnome.org/show_bug.cgi?id=774066
2016-11-10 15:03:35 -05:00
Timm Bäder
9992a616ef widget: Use ::measure vfunc to measure size
Add a new ::measure vfunc similar to GtkCssGadget's that widget
implementations have to override instead of the old get_preferred_width,
get_preferred_height, get_preferred_width_for_height,
get_preferred_height_for_width and
get_preferred_height_and_baseline_for_width.
2016-10-22 19:05:47 +02:00
Emmanuele Bassi
e58965a3cc gtk: Port GtkHeaderBar to render nodes 2016-10-18 11:49:12 +01:00
Timm Bäder
301e1a4d55 window: Remove decoration-button-layout style property
GtkSettings has a gtk-decoration-layout property for this.
2016-10-18 00:29:20 +02:00
Benjamin Otte
4df6ddad54 API: container: Remove gtk_container_set_border_width() 2016-10-16 18:18:58 +02:00
Timm Bäder
f45dadadd0 box: Remove 'padding' child property 2016-10-16 18:17:21 +02:00
Alan Jenkins
982c4a70b6 headerbar: fix leak of label_sizing_box
Since the widget is not added to a container, we have the responsibility
to sink the initial floating reference, and ultimately to unref it.

https://bugzilla.gnome.org/show_bug.cgi?id=772859
2016-10-13 09:39:02 -04:00
Alan Jenkins
3731da14a0 headerbar: fix leak of separator
https://bugzilla.gnome.org/show_bug.cgi?id=772859
2016-10-13 09:39:02 -04:00
Alan Jenkins
8ef4f7fd74 headerbar: fix leak of start_box/end_box
gtk_widget_destroy() removes widgets from their container.  However
_internal_ widgets must be unref'ed using gtk_widget_unparent() instead.
This is symmetric with the fact that these widgets were ref'ed by direct
call to gtk_widget_set_parent().  It's also the method that was used in
gtk_headerbar_destroy().

https://bugzilla.gnome.org/show_bug.cgi?id=772859
2016-10-13 09:39:01 -04:00
Matthias Clasen
5fefc7a714 headerbar: Fix size allocation
The GtkHeaderBar gadget implementation was subtly broken: it called
gtk_widget_set_allocation both in gtk_header_bar_size_allocate (with
the actual allocation) and in gtk_header_bar_allocate_contents (with
the content allocation of the main gadget). Dropping the second call
fixes the render node conversion for GtkHeaderBar.
2016-08-07 15:08:44 -04:00
Ray Strode
386d17db6d headerbar: don't throw a warning if title widget is hidden
commit 0015ebc4a8 reworked
some of the titlebar size allocation code.  Those changes
inadvertently introduced a warning when the application sets
the headerbar title widget to be hidden.

This commit fixes that warning.

https://bugzilla.gnome.org/show_bug.cgi?id=768184
2016-06-29 09:27:33 -04:00
Ray Strode
0015ebc4a8 headerbar: support expand property for children
The header bar currently ignores the expand property on its
children. This commit changes the code to honor that property.

It divvies up any free space and distributes it equally to packed
children (with any left over space given out a pixel at a time
on a first come, first serve basis).

This commit also adds support for the title widget to be made
expandable.

It accomplishes this by using up the padding the title widget
is centered with.

https://bugzilla.gnome.org/show_bug.cgi?id=724332
2016-06-24 20:58:41 -04:00
Ray Strode
847a43c431 headerbar: compute nominal size of sides up front
In order to support the expand property on children, we're
going to need to look at the size of the packed children
on each side of the title widget, up front, before allocating
them (to compute how much extra allocation each expanded child
gets).

This commit lays the groundwork for that analysis by splitting
the size calculation of each side of the header bar outside
of the loop that allocates each child of the header bar.

https://bugzilla.gnome.org/show_bug.cgi?id=724332
2016-06-24 20:24:43 -04:00
Ray Strode
eccfce50d6 headerbar: simplify some size allocation code
With a headerbar, the widget in the center may be a label, constructed
internally, or a custom widget, constructed externally.  The size
allocation code needs to handle either case the same way for the most
part.  There's more than one place in the code that checks which of
the two widgets to use and does some operation on the selected one.

This commit simplifies the code by checking up front which one is the
center (title) widget and storing that in a temporary variable,
This allows reducing duplicated logic later on in the function.

https://bugzilla.gnome.org/show_bug.cgi?id=724332
2016-06-24 20:20:22 -04:00
Ray Strode
e0bebba470 headerbar: simplify calculation in size allocation code
There's some extraneous MIN() calls that have predetermined answers.

This commit drops them and then simplifies a few redudant checks into
one MIN call.

https://bugzilla.gnome.org/show_bug.cgi?id=724332
2016-06-24 20:19:32 -04:00
Ray Strode
78eccd0db9 headerbar: don't use GTK_PACK_* as indices into array
The size allocation code maintains an array of two elements,
to track the allocation of children packed into the two sides
of a header bar. Sometimes this array is indexed with 0 and 1,
and sometimes its indexed with GTK_PACK_START and GTK_PACK_END.
The latter happen to have the values 0 and 1, respectively, but
that's not really obvious.

For clarity, this commit changes the code to index those arrays
consistently, sticking to 0 and 1 across the board.
2016-06-23 14:32:33 -04:00
Ray Strode
01eda209e1 headerbar: don't allocate both label and custom title
It's only possible to have a label or a custom title, not both.
The size allocate code confusingly treats them as independent.

That is confusing, because, as the code is written, it makes it
look like the space for the custom title isn't getting accounted
for.

This commit else-ifies some parts of the size allocate code for
clarity.
2016-06-23 14:32:33 -04:00
Olivier Fourdan
7c397c621c headerbar: do not show buttons for modals/transients
GtkHeadeBar checks the window type hint to determine if the regular
buttons such as menu, maximize or iconify should be visible in the
header bar.

However, an application may very well use a "normal" toplevel window and
set it transient and modal afterwards. In such a case, the iconify
button would remain visible, and the user can hide the window, but being
a modal, the parent window would remain insensitive.

Check for the window type, modality and transient relationship to decide
whether or not the regular toplevel buttons should be visible in the
header bar.

https://bugzilla.gnome.org/show_bug.cgi?id=767052
2016-06-01 09:47:23 +02:00
Timm Bäder
58891c1fe5 headerbar: Don't underallocate the label box
We use a label_sizing_box to make sure the headerbar can always contain
both a title and a subtitle without resizing when showing/hiding either
of them, but we should only do that for the height; the min width of the
label_box can be larger than that of the label_sizing_box.
2016-04-02 17:03:52 +02:00
Lapo Calamandrei
6da0a0a106 gtkheaderbar: add titlebutton styleclass to the separator
...of the window control buttons
2016-01-09 19:27:15 +01:00
Alberto Ruiz
496f0892fc introspection: This patch fixes nullable return values fixes for the following symbols in gtk
gtk_accel_group_query
  gtk_accel_group_from_accel_closure
  gtk_accel_label_get_accel_widget
  gtk_accessible_get_widget
  gtk_actionable_get_action_name
  gtk_app_chooser_get_app_info
  gtk_app_chooser_button_get_heading
  gtk_app_chooser_dialog_get_heading
  gtk_application_get_window_by_id
  gtk_assistant_get_nth_page
  gtk_binding_set_find
  gtk_builder_get_object
  gtk_builder_lookup_callback_symbol
  gtk_builder_get_application
  gtk_button_get_image
  gtk_cell_area_get_focus_from_sibling
  gtk_cell_renderer_start_editing
  gtk_cell_view_get_model
  gtk_cell_view_get_displayed_row
  gtk_clipboard_get_owner
  gtk_container_get_focus_child
  gtk_container_get_focus_vadjustment
  gtk_container_get_focus_hadjustment
  gtk_dialog_get_widget_for_response
  gtk_drag_get_source_widget
  gtk_drag_dest_get_target_list
  gtk_drag_source_get_target_list
  gtk_entry_completion_get_model
  gtk_entry_completion_compute_prefix
  gtk_expander_get_label_widget
  gtk_file_chooser_get_filename
  gtk_file_chooser_get_current_folder
  gtk_file_chooser_get_uri
  gtk_file_chooser_get_current_folder_uri
  gtk_file_chooser_get_preview_widget
  gtk_file_chooser_get_preview_file
  gtk_file_chooser_get_preview_filename
  gtk_file_chooser_get_preview_uri
  gtk_file_chooser_get_extra_widget
  gtk_file_chooser_get_filter
  gtk_file_chooser_native_get_accept_label
  gtk_file_chooser_native_get_cancel_label
  gtk_file_filter_get_name
  gtk_font_chooser_get_font_family
  gtk_font_chooser_get_font_face
  gtk_font_chooser_get_font
  gtk_font_chooser_get_font_desc
  gtk_font_chooser_get_font_map
  gtk_frame_get_label
  gtk_gesture_get_device
  gtk_gesture_get_window
  gtk_gl_area_get_error
  gtk_header_bar_get_title
  gtk_header_bar_get_subtitle
  gtk_header_bar_get_custom_title
  gtk_icon_info_get_filename
  gtk_icon_view_get_path_at_pos
  gtk_icon_view_get_model
  gtk_image_get_pixbuf
  gtk_image_get_animation
  gtk_label_get_mnemonic_widget
  gtk_label_get_attributes
  gtk_check_version
  gtk_menu_button_get_popup
  gtk_menu_button_get_menu_model
  gtk_menu_button_get_align_widget
  gtk_menu_button_get_popover
  gtk_menu_item_get_submenu
  gtk_menu_item_get_accel_path
  gtk_native_dialog_get_title
  gtk_native_dialog_get_transient_for
  gtk_notebook_get_nth_page
  gtk_notebook_get_tab_label_text
  gtk_notebook_get_menu_label
  gtk_notebook_get_menu_label_text
  gtk_notebook_get_group_name
  gtk_notebook_get_action_widget
  gtk_offscreen_window_get_surface
  gtk_offscreen_window_get_pixbuf
  gtk_paned_get_child1
  gtk_paned_get_child2
  gtk_places_sidebar_get_location
  gtk_places_sidebar_get_nth_bookmark
  gtk_plug_get_socket_window
  gtk_popover_get_default_widget
  gtk_progress_bar_get_text
  gtk_recent_filter_get_name
  gtk_recent_manager_lookup_item
  gtk_settings_get_default
  gtk_socket_get_plug_window
  gtk_stack_sidebar_get_stack
  gtk_stack_switcher_get_stack
  gtk_style_context_get_section
  gtk_style_context_get_parent
  gtk_style_context_get_frame_clock
  gtk_test_find_widget
  gtk_text_buffer_get_mark
  gtk_text_tag_table_lookup
  gtk_text_view_get_tabs
  gtk_text_view_toggle_cursor_visible
  gtk_text_view_get_window
  gtk_toolbar_get_nth_item
  gtk_tool_button_get_label
  gtk_tool_button_get_icon_name
  gtk_tool_button_get_label_widget
  gtk_tool_button_get_icon_widget
  gtk_tool_palette_get_drop_item
  gtk_tool_palette_get_drop_group
  gtk_tree_model_filter_convert_child_path_to_path
  gtk_tree_model_filter_convert_path_to_child_path
  gtk_tree_model_sort_convert_child_path_to_path
  gtk_tree_model_sort_convert_path_to_child_path
  gtk_tree_view_get_column
  gtk_tree_view_get_bin_window
  gtk_tree_view_column_get_widget
  gtk_tree_view_column_get_tree_view
  gtk_widget_get_frame_clock
  gtk_window_group_get_current_device_grab
  GtkTextBufferSerializeFunc
2016-01-08 12:18:23 +00:00
Alberts Muktupāvels
a90926c7f0 gtkheaderbar: update window buttons also on realize
After bb34db6 _gtk_header_bar_update_window_buttons function is
called before application menu is set. This caused regression -
app menu button is initially hidden.

https://bugzilla.gnome.org/show_bug.cgi?id=756618
2016-01-01 15:55:37 +02:00
Matthias Clasen
e237c947c7 headerbar: Convert to gadgets 2015-12-15 08:41:16 -05:00
Kalev Lember
9103707922 headerbar: Don't leak internal widgets
Make sure to clean up internal widgets in destroy, as these aren't
cleaned up when GtkContainer walks the childrens list in
gtk_container_destroy().

This also fixes a gedit crash as reported in
https://bugzilla.redhat.com/show_bug.cgi?id=1288669

https://bugzilla.gnome.org/show_bug.cgi?id=759132
2015-12-07 22:15:25 -05:00
Timm Bäder
2182fe7d9d Don't pass widget state flags to GtkStyleContext API 2015-11-22 17:11:35 +01:00
Christoph Reiter
bb34db6d35 gtkheaderbar: update the window buttons on ::hierarchy-changed instead of ::realize
The window button setup depends on properties of the toplevel window.
Instead of updating the setup on realize, do it when the toplevel
changes.

This makes sure that when a GtkHeaderBar is added to a window
all the widgets are present and get_preferred_height() will return
the height the widget will have when finally shown. This allows
the logic in gtkwindow to select the right window size so that
the content size will match the requested default size.

https://bugzilla.gnome.org/show_bug.cgi?id=756618
2015-11-19 21:42:53 +01:00
Christian Hergert
5f0a8cf136 headerbar: remove G_PARAM_CONSTRUCT from custom-title
This fixes the ability to sublcass GtkHeaderBar from a UI template which
contains a custom <child type="title"> element.

https://bugzilla.gnome.org/show_bug.cgi?id=757544
2015-11-03 14:50:56 -08:00