Commit Graph

119 Commits

Author SHA1 Message Date
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
Matthias Clasen
8c0c0f9c07 headerbar: Use an element name instead of a style class
Use the element name headerbar.
2015-10-30 01:07:58 -04:00
Matthias Clasen
84c7f6c747 header bar: Show a non-pixellated app icon
Load a hi-dpi icon when we are running with scale=2.

https://bugzilla.gnome.org/show_bug.cgi?id=751787
2015-09-30 18:42:20 -04:00
Matthias Clasen
565677a22c header bar: Don't leave a dangling pointer
This might be the cause for some crashes, like
https://bugzilla.redhat.com/show_bug.cgi?id=1264558
2015-09-29 15:15:06 -04:00
Matthias Clasen
661e51a8e2 header bar: Use g_object_notify_by_pspec
This avoids pspec lookup overhead in g_object_notify.
2015-09-06 17:11:35 -04:00
Matthias Clasen
f881f37789 Fix csd decorations
By accident, commit b9b17c3c2a removed one line
that wasn't unused, but important for hiding close buttons on
dialogs. Bring it back.
2015-07-19 09:59:18 -04:00
Benjamin Otte
dbb1830728 headerbar: Switch css positions on direction change 2015-07-17 19:13:09 +02:00
Benjamin Otte
3d2ead0fce headerbar: Get rid of get_path_for_child()
Instead, reorder CSS nodes.
2015-07-16 06:15:13 +02:00
Benjamin Otte
a039fd1699 headerbar: Finish widget setup before showing it. 2015-07-16 06:15:13 +02:00
Benjamin Otte
792076e09b headerbar: forall() the button boxes in the right order 2015-07-16 06:15:13 +02:00
Benjamin Otte
b9b17c3c2a headerbar: Remove unused variables in private struct 2015-07-16 06:15:13 +02:00
Christoph Reiter
335c070f9b GtkHeaderBar: reduce minimum title width
The minimum title width affects the minimum window width
for CSD windows. To allow smaller windows like without
CSD reduce it a bit (276px vs 156px min width)

https://bugzilla.gnome.org/show_bug.cgi?id=751341
2015-06-23 21:16:37 +02:00
Matthias Clasen
c8d6231c3c Fix window button updates in split headers
We were only updating window buttons when the headerbar was
a direct child of the window. That is not the case in more
complicated situations, such as the split headers in gedit
or polari. To fix such cases, make the headerbar itself listen
for state changes on its toplevel.

https://bugzilla.gnome.org/show_bug.cgi?id=747805
2015-04-14 17:05:34 -04:00
Matthias Clasen
b187773053 Add style classes to the title buttons
This will let themes treat close/min/max buttons differently,
if they so desire.

https://bugzilla.gnome.org/show_bug.cgi?id=744400
2015-02-15 13:03:29 -05:00
Benjamin Otte
3fcb892831 headerbar: Implement clipping 2015-01-22 16:25:24 +01:00
Matthias Clasen
5a01208f55 GtkHeaderBar: Queue a resize when pack-type is changed
Otherwise, buttons appear to stick to the wrong side in glade.
2014-11-06 01:05:51 -05:00
Matthias Clasen
e2882e4845 GtkHeaderBar: Make the position child property writable
Glade asssumes that it is, and without this, rearranging children
in glade is very cumbersome.
2014-11-04 16:56:25 -05:00