Compare commits

...

33 Commits

Author SHA1 Message Date
Matthias Clasen
02af9b37ff GtkHeaderBar: drop drag handling
GtkWindow already does this, and having it in here interferes
with reusing the headerbar in other contexts.
2013-03-16 13:42:07 -04:00
Matthias Clasen
562476ca18 Pimp up the css for the client-side decorations 2013-03-15 19:10:04 -04:00
Matthias Clasen
ee100f16c3 Avoid deprecated api 2013-03-10 22:01:34 -04:00
Matthias Clasen
c15a76c6e1 Fix a crash when getting header bar child properties
The find_child_link call will return NULL if the child is
the label.
2013-03-10 21:59:27 -04:00
Matthias Clasen
af14695875 Fix some issues when changing decorated
We forgot to show the titlebar again when a window is turned
from decorated to undecorated and back again. Also, we were drawing
the titlebar background even when the window is undecorated.
2013-03-10 21:52:41 -04:00
Matthias Clasen
55e90683a6 Allow putting the window icon in the titlebar 2013-03-10 21:01:40 -04:00
Matthias Clasen
2ee63a5c01 Fix forall to actually be in visual order
Pack end children were coming out in reverse order.
2013-03-10 19:04:29 -04:00
Matthias Clasen
e94191beb3 Add sibling paths for GtkHeaderBar
This is necessary to make :first-child and similar selectors work.
2013-03-10 18:19:50 -04:00
Matthias Clasen
c55966e0fd Redo window button layout parsing
We now allow buttons at the left and right side, they can be specified
like this: menu,close:minimize,maximize.
Also, change the default button layout back to have just a close
button on the right.
2013-03-10 17:06:54 -04:00
Matthias Clasen
91abc52311 Use GtkHeaderBar in client-side decorations
This separates titlebar layout from the GtkWindow code, and gets
the title properly centered. It also paves the way for allowing
ttle buttons on the left.
2013-03-10 15:17:05 -04:00
Matthias Clasen
88263b9357 Add GtkHeaderBar
This has been developed as GdHeaderBar in libgd. The copy here has
been renamed and changed to use GTK+ internals. It also properly
takes the label size into account.
2013-03-10 15:15:45 -04:00
Matthias Clasen
5c672650ea Update buttons when the window state changes 2013-03-10 13:51:11 -04:00
Matthias Clasen
16a89d3cee Render inner and outer border separately 2013-03-10 13:46:59 -04:00
Matthias Clasen
1ce4b79edc Split the border into inner and outer
For now, nothing changes, we're using their sum everywhere.
In the future, we will make the inner border the visible window
frame, and the outer border the shadow/resize border.
2013-03-10 13:29:56 -04:00
Matthias Clasen
acc912755e Hardcode no border when maximized
It doesn't seem worth an extra style class, having a border
when maximized basically makes not sense.
2013-03-10 11:51:57 -04:00
Matthias Clasen
3c3d91fbc8 Add a separate window-border class for maximized windows
This is useful to hide a the window border for maximized
windows. Dragging them from the border is not useful when maximized.
2013-03-10 03:30:26 -04:00
Matthias Clasen
c3c86140ee Disable window menu items when appropriate 2013-03-10 03:09:44 -04:00
Matthias Clasen
c6a832009e Avoid warnings for menus
Menus are undecorated. The client-side decoration code must
be careful to not use non-existing decoration parts for menus.
2013-03-10 03:03:27 -04:00
Matthias Clasen
fa1b2018cf Add a window menu
The menu can be triggered by right-click on the title or
with the menu key.
2013-03-10 01:39:19 -05:00
Matthias Clasen
adc0db0139 Make it possible to resize by clicking on the border
We also change cursors to indicate this. Double clicking
on the titlebar maximizes the window.
2013-03-10 01:11:18 -05:00
Matthias Clasen
d93f3c9b74 Allow theme control over window buttons
Add a style property to control the presence and order of
window buttons.
2013-03-09 23:03:38 -05:00
Matthias Clasen
6ca5b8a770 Make title buttons unfocusable
It is pretty unexpected to have the focus up in the decorations
after clicking on maximize, so avoid that but making the buttons
unfocusable.
2013-03-09 22:37:20 -05:00
Matthias Clasen
14db43c68b Ellipsize long titles 2013-03-09 22:34:29 -05:00
Matthias Clasen
74cd6de409 Hide buttons when appropriate
Hide the close button if the window is not deletable, hide the
maximize button if the window is not resizable, and hide all
buttons if the window is a dialog.
2013-03-09 22:28:39 -05:00
Matthias Clasen
ca849344f1 Add min and max buttons 2013-03-09 22:02:52 -05:00
Rob Bradford
059c3704c9 window: Don't require get_preferred_height/width to be run before allocate
gtk_window_get_preferred_width/height were retrieving the border and title
height and then saving that into the private structure of the window. This was
then used inside the _gtk_window_set_allocation and gtk_window_draw methods.

If a subclass did not chain up for get_preferred_height / get_preferred_width
(like Nautilus) then these values would not be saved and the allocation and
drawing would not work correctly.

This resolves this by spinning out the retrieval of that information into a
separate function and using that every time the data is required.
2013-02-26 20:02:18 +00:00
Rob Bradford
dc35f16aa9 window: Add support for enabling client decorations on non-Wayland
Client side decorations can be enabled on non-Wayland platforms by setting the
GTK_CSD="1" environment variable.

We must ensure we have a GdkVisual that has an alpha channel since the
decorations rely on transparency. If we cannot get a visual with an alpha
channel then we do not enable client side decorations.
2013-02-26 20:02:18 +00:00
Rob Bradford
5a41fcf2b4 window: Use same title fallback mechanism as X backend
This looks at the application name or program name and uses that as the title
if gtk_window_set_title has not been called.
2013-02-26 20:02:18 +00:00
Rob Bradford
cde87b4106 window: Hide the decorations on fullscreen 2013-02-26 20:02:18 +00:00
Rob Bradford
97c57f9359 window: Don't set a background pattern/colour when client decorated
Otherwise we'll potentially get some background sticking through our rounded
corners in our decorations. The actual background will get drawn as part of
the decoration drawing.
2013-02-26 20:02:18 +00:00
Rob Bradford
0331c16af9 css: Add style entries for client side decorations to default CSS 2013-02-26 20:02:18 +00:00
Kristian Høgsberg
5cf4353a6f window: Add initial support for client-side decorations under Wayland
This change comprises four main parts:
 * the creation of the widgets that form the decorations,
 * implementation of get_preferred_height/width, and the for_width/for_height
   variants,
 * taking the decorations into account when allocating,
 * and drawing the decorations themselves.

Kristian did the bulk of the original work on this but any bugs are almost
certainly mine through the many refactorings and rebasings.
2013-02-26 20:02:03 +00:00
Rob Bradford
1b2b351e2d window: Allow _gtk_window_set_allocation to return a modified allocation
Update the documentation and users of this function to handle
the future case that that we have some internal decorations to the window and
useable allocation is thus smaller.

By having a separate out parameter there is no need to have an in/out function
and allows for greater robustness.

The current implementation simply returns the allocation provided.
2013-02-26 19:33:04 +00:00
8 changed files with 2711 additions and 44 deletions

View File

@@ -257,6 +257,7 @@ gtk_public_h_sources = \
gtkfontchooserwidget.h \
gtkframe.h \
gtkgrid.h \
gtkheaderbar.h \
gtkiconfactory.h \
gtkicontheme.h \
gtkiconview.h \
@@ -729,6 +730,7 @@ gtk_base_c_sources = \
gtkfontchooserwidget.c \
gtkframe.c \
gtkgrid.c \
gtkheaderbar.c \
gtkhsla.c \
gtkiconcache.c \
gtkiconcachevalidator.c \

View File

@@ -23,6 +23,9 @@
color: @fg_color;
border-color: shade (@bg_color, 0.6);
padding: 2px;
-GtkWindow-resize-grip-width: 0;
-GtkWindow-resize-grip-height: 0;
-GtkWindow-decoration-button-layout: 'icon:minimize,maximize,close';
}
GtkWindow, .button, .slider {
@@ -729,3 +732,73 @@ GtkCalendar.button:hover {
-gtk-gradient(radial, center center, 0, center center, 0.5, to(currentColor), to(transparent));
animation: spinner 1s infinite linear;
}
/* Client side decorations */
.titlebar > GtkLabel:backdrop {
color: darker (@bg_color);
text-shadow: none;
}
.titlebar GtkLabel {
font: Sans Bold 10;
text-shadow: 1px 1px lighter (@bg_color);
}
.titlebar GtkButton:backdrop {
border-image: none;
background-image: none;
}
.titlebar GtkButton GtkLabel:backdrop {
text-shadow: none;
color: darker (@bg_color);
}
.titlebar GtkButton GtkLabel {
font: Sans Bold 12;
color: white;
text-shadow: 0px 1px darker (darker (@bg_color));
}
.titlebar GtkButton {
border-style: none;
border-color: darker (@bg_color);
background-image: -gtk-gradient (linear, center top, center bottom,
from (@bg_color),
color-stop (0.5, darker (@bg_color)),
to (@bg_color));
}
.titlebar GtkButton:first-child {
border-radius: 10px 0px 0px 0px;
}
.titlebar GtkButton:last-child {
border-radius: 0px 10px 0px 0px;
}
.titlebar:backdrop {
background-image: none;
}
.titlebar {
background-image: -gtk-gradient (linear, center top, center bottom,
from (white),
to (@bg_color));
border-radius: 5px 5px 0px 0px;
}
.window-border {
border-color: darker (@bg_color);
border-radius: 10px;
border-width: 0;
border-style: solid;
}
.window-outer-border {
border-color: transparent;
border-radius: 10px;
border-width: 10px 10px 10px 10px;
border-style: solid;
}

View File

@@ -108,6 +108,7 @@
#include <gtk/gtkfontchooserwidget.h>
#include <gtk/gtkframe.h>
#include <gtk/gtkgrid.h>
#include <gtk/gtkheaderbar.h>
#include <gtk/gtkiconfactory.h>
#include <gtk/gtkicontheme.h>
#include <gtk/gtkiconview.h>

View File

@@ -703,13 +703,17 @@ gtk_application_window_real_size_allocate (GtkWidget *widget,
if (window->priv->menubar != NULL)
{
GtkAllocation menubar_allocation = *allocation;
GtkAllocation menubar_allocation;
GtkAllocation child_allocation;
gint menubar_height;
GtkWidget *child;
_gtk_window_set_allocation (GTK_WINDOW (widget), allocation);
_gtk_window_set_allocation (GTK_WINDOW (widget), allocation, &child_allocation);
menubar_allocation = child_allocation;
gtk_widget_get_preferred_height_for_width (window->priv->menubar, allocation->width, &menubar_height, NULL);
gtk_widget_get_preferred_height_for_width (window->priv->menubar,
menubar_allocation.width,
&menubar_height, NULL);
menubar_allocation.height = menubar_height;
gtk_widget_size_allocate (window->priv->menubar, &menubar_allocation);
@@ -717,7 +721,6 @@ gtk_application_window_real_size_allocate (GtkWidget *widget,
child = gtk_bin_get_child (GTK_BIN (window));
if (child != NULL && gtk_widget_get_visible (child))
{
GtkAllocation child_allocation = *allocation;
gint border_width;
border_width = gtk_container_get_border_width (GTK_CONTAINER (window));

1154
gtk/gtkheaderbar.c Normal file

File diff suppressed because it is too large Load Diff

76
gtk/gtkheaderbar.h Normal file
View File

@@ -0,0 +1,76 @@
/*
* Copyright (c) 2013 Red Hat, Inc.
*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef __GTK_HEADER_BAR_H__
#define __GTK_HEADER_BAR_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/gtkcontainer.h>
G_BEGIN_DECLS
#define GTK_TYPE_HEADER_BAR (gtk_header_bar_get_type ())
#define GTK_HEADER_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_HEADER_BAR, GtkHeaderBar))
#define GTK_HEADER_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_HEADER_BAR, GtkHeaderBarClass))
#define GTK_IS_HEADER_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_HEADER_BAR))
#define GTK_IS_HEADER_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_HEADER_BAR))
#define GTK_HEADER_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_HEADER_BAR, GtkHeaderBarClass))
typedef struct _GtkHeaderBar GtkHeaderBar;
typedef struct _GtkHeaderBarPrivate GtkHeaderBarPrivate;
typedef struct _GtkHeaderBarClass GtkHeaderBarClass;
struct _GtkHeaderBar
{
GtkContainer container;
/*< private >*/
GtkHeaderBarPrivate *priv;
};
struct _GtkHeaderBarClass
{
GtkContainerClass parent_class;
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
GType gtk_header_bar_get_type (void) G_GNUC_CONST;
GtkWidget *gtk_header_bar_new (void);
void gtk_header_bar_set_title (GtkHeaderBar *bar,
const gchar *title);
const gchar *gtk_header_bar_get_title (GtkHeaderBar *bar);
void gtk_header_bar_set_custom_title (GtkHeaderBar *bar,
GtkWidget *title_widget);
GtkWidget *gtk_header_bar_get_custom_title (GtkHeaderBar *bar);
void gtk_header_bar_pack_start (GtkHeaderBar *bar,
GtkWidget *child);
void gtk_header_bar_pack_end (GtkHeaderBar *bar,
GtkWidget *child);
G_END_DECLS
#endif /* __GTK_HEADER_BAR_H__ */

File diff suppressed because it is too large Load Diff

View File

@@ -66,8 +66,9 @@ void _gtk_window_get_wmclass (GtkWindow *window,
gchar **wmclass_name,
gchar **wmclass_class);
void _gtk_window_set_allocation (GtkWindow *window,
GtkAllocation *allocation);
void _gtk_window_set_allocation (GtkWindow *window,
const GtkAllocation *allocation,
GtkAllocation *allocation_out);
typedef void (*GtkWindowKeysForeachFunc) (GtkWindow *window,
guint keyval,