2014-01-06 15:30:15 +00:00
|
|
|
#include <gtk/gtk.h>
|
2017-03-12 18:36:21 +00:00
|
|
|
#include <glib/gstdio.h>
|
2014-01-06 15:30:15 +00:00
|
|
|
|
|
|
|
static void
|
2014-01-07 01:35:01 +00:00
|
|
|
split_decorations (GtkSettings *settings,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GtkBuilder *builder)
|
2014-01-06 15:30:15 +00:00
|
|
|
{
|
|
|
|
GtkWidget *sheader, *mheader;
|
|
|
|
gchar *layout, *p1, *p2;
|
|
|
|
gchar **p;
|
|
|
|
|
2014-01-07 01:35:01 +00:00
|
|
|
sheader = (GtkWidget *)gtk_builder_get_object (builder, "sidebar-header");
|
|
|
|
mheader = (GtkWidget *)gtk_builder_get_object (builder, "main-header");
|
2014-01-06 15:30:15 +00:00
|
|
|
|
2014-01-07 01:35:01 +00:00
|
|
|
g_object_get (settings, "gtk-decoration-layout", &layout, NULL);
|
2014-01-06 15:30:15 +00:00
|
|
|
|
|
|
|
p = g_strsplit (layout, ":", -1);
|
|
|
|
|
2014-01-07 17:44:34 +00:00
|
|
|
p1 = g_strconcat ("", p[0], ":", NULL);
|
|
|
|
|
|
|
|
if (g_strv_length (p) >= 2)
|
|
|
|
p2 = g_strconcat (":", p[1], NULL);
|
|
|
|
else
|
|
|
|
p2 = g_strdup ("");
|
2014-01-06 15:30:15 +00:00
|
|
|
|
|
|
|
gtk_header_bar_set_decoration_layout (GTK_HEADER_BAR (sheader), p1);
|
|
|
|
gtk_header_bar_set_decoration_layout (GTK_HEADER_BAR (mheader), p2);
|
|
|
|
|
|
|
|
g_free (p1);
|
|
|
|
g_free (p2);
|
|
|
|
g_strfreev (p);
|
|
|
|
g_free (layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
|
|
|
GtkBuilder *builder;
|
|
|
|
GtkSettings *settings;
|
|
|
|
GtkWidget *win;
|
|
|
|
GtkWidget *entry;
|
|
|
|
GtkWidget *check;
|
|
|
|
GtkWidget *header;
|
|
|
|
|
2017-03-12 18:36:21 +00:00
|
|
|
#ifdef GTK_SRCDIR
|
|
|
|
g_chdir (GTK_SRCDIR);
|
|
|
|
#endif
|
|
|
|
|
2016-12-28 13:53:22 +00:00
|
|
|
gtk_init ();
|
2014-01-06 15:30:15 +00:00
|
|
|
|
|
|
|
builder = gtk_builder_new_from_file ("testsplitheaders.ui");
|
|
|
|
|
2014-01-07 01:35:01 +00:00
|
|
|
win = (GtkWidget *)gtk_builder_get_object (builder, "window");
|
2014-01-06 15:30:15 +00:00
|
|
|
settings = gtk_widget_get_settings (win);
|
|
|
|
|
|
|
|
g_signal_connect (settings, "notify::gtk-decoration-layout",
|
|
|
|
G_CALLBACK (split_decorations), builder);
|
|
|
|
split_decorations (settings, NULL, builder);
|
|
|
|
|
2014-01-07 01:35:01 +00:00
|
|
|
entry = (GtkWidget *)gtk_builder_get_object (builder, "layout-entry");
|
2014-01-06 15:30:15 +00:00
|
|
|
g_object_bind_property (settings, "gtk-decoration-layout",
|
|
|
|
entry, "text",
|
2017-12-08 16:29:14 +00:00
|
|
|
G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE);
|
2014-01-07 01:35:01 +00:00
|
|
|
check = (GtkWidget *)gtk_builder_get_object (builder, "decorations");
|
|
|
|
header = (GtkWidget *)gtk_builder_get_object (builder, "sidebar-header");
|
2017-12-08 16:29:14 +00:00
|
|
|
g_object_bind_property (check, "active",
|
|
|
|
header, "show-title-buttons",
|
|
|
|
G_BINDING_DEFAULT);
|
2014-01-07 01:35:01 +00:00
|
|
|
header = (GtkWidget *)gtk_builder_get_object (builder, "main-header");
|
2017-12-08 16:29:14 +00:00
|
|
|
g_object_bind_property (check, "active",
|
|
|
|
header, "show-title-buttons",
|
2014-01-06 15:30:15 +00:00
|
|
|
G_BINDING_DEFAULT);
|
|
|
|
gtk_window_present (GTK_WINDOW (win));
|
|
|
|
|
|
|
|
gtk_main ();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|