Commit 7b6226ae authored by Christian Persch's avatar Christian Persch

window: Add headerbar infrastructure

https://bugzilla.gnome.org/show_bug.cgi?id=756798
parent 4b9f6d39
......@@ -13,6 +13,8 @@ src/terminal-accels.c
src/terminal-app.c
src/terminal.c
src/terminal-encoding.c
[type: gettext/glade]src/terminal-headerbar.ui
src/terminal-headerbar.c
src/terminal-mdi-container.c
[type: gettext/glade]src/terminal-menubar.ui.in
src/terminal-menu-button.c
......
......@@ -53,6 +53,8 @@ gnome_terminal_server_SOURCES = \
terminal-encoding.h \
terminal-gdbus.c \
terminal-gdbus.h \
terminal-headerbar.c \
terminal-headerbar.h \
terminal-icon-button.h \
terminal-icon-button.c \
terminal-info-bar.c \
......@@ -325,6 +327,7 @@ CLEANFILES = \
EXTRA_DIST = \
terminal.about \
terminal-headerbar.ui \
terminal-menubar.ui.in \
terminal-notebook-menu.ui \
terminal-window.ui \
......
......@@ -736,6 +736,14 @@
<summary>Which theme variant to use</summary>
</key>
<!-- Note that changing the following settings will only take effect
when gnome-terminal-server is restarted.
-->
<key name="headerbar" type="b">
<default>false</default>
</key>
<key name="unified-menu" type="b">
<default>true</default>
</key>
......
......@@ -115,6 +115,7 @@ struct _TerminalApp
int n_clipboard_targets;
gboolean unified_menu;
gboolean use_headerbar;
};
enum
......@@ -700,10 +701,11 @@ terminal_app_init (TerminalApp *app)
GTK_DEBUG_ENABLE_INSPECTOR_KEY,
GTK_DEBUG_ENABLE_INSPECTOR_TYPE);
/* This is an internal setting that exists only for distributions
* to override, so we cache it on startup and don't react to changes.
/* These are internal settings that exists only for distributions
* to override, so we cache them on startup and don't react to changes.
*/
app->unified_menu = g_settings_get_boolean (app->global_settings, TERMINAL_SETTING_UNIFIED_MENU);
app->unified_menu = g_settings_get_boolean (app->global_settings, TERMINAL_SETTING_UNIFIED_MENU_KEY);
app->use_headerbar = g_settings_get_boolean (app->global_settings, TERMINAL_SETTING_HEADERBAR_KEY);
#if GTK_CHECK_VERSION (3, 19, 0)
GtkSettings *gtk_settings = gtk_settings_get_default ();
......@@ -1162,3 +1164,11 @@ terminal_app_get_menu_unified (TerminalApp *app)
return app->unified_menu;
}
gboolean
terminal_app_get_use_headerbar (TerminalApp *app)
{
g_return_val_if_fail (TERMINAL_IS_APP (app), FALSE);
return app->use_headerbar;
}
......@@ -105,6 +105,8 @@ GMenuModel *terminal_app_get_profile_section (TerminalApp *app);
gboolean terminal_app_get_menu_unified (TerminalApp *app);
gboolean terminal_app_get_use_headerbar (TerminalApp *app);
/* GSettings */
GSettings *terminal_app_get_global_settings (TerminalApp *app);
......
/*
* Copyright © 2018 Christian Persch
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <glib/gi18n.h>
#include "terminal-headerbar.h"
#include "terminal-libgsystem.h"
typedef struct _TerminalHeaderbarPrivate TerminalHeaderbarPrivate;
struct _TerminalHeaderbar
{
GtkHeaderBar parent_instance;
};
struct _TerminalHeaderbarClass
{
GtkHeaderBarClass parent_class;
};
struct _TerminalHeaderbarPrivate
{
gpointer dummy;
};
enum {
PROP_0,
LAST_PROP
};
enum {
LAST_SIGNAL
};
/* static guint signals[LAST_SIGNAL]; */
/* static GParamSpec *pspecs[LAST_PROP]; */
G_DEFINE_TYPE_WITH_PRIVATE (TerminalHeaderbar, terminal_headerbar, GTK_TYPE_HEADER_BAR)
#define PRIV(obj) ((TerminalHeaderbarPrivate *) terminal_headerbar_get_instance_private ((TerminalHeaderbar *)(obj)))
/* Class implementation */
static void
terminal_headerbar_init (TerminalHeaderbar *headerbar)
{
// TerminalHeaderbarPrivate *priv = PRIV (headerbar);
GtkWidget *widget = GTK_WIDGET (headerbar);
gtk_widget_init_template (widget);
}
static void
terminal_headerbar_finalize (GObject *object)
{
#if 0
TerminalHeaderbar *headerbar = TERMINAL_HEADERBAR (object);
TerminalHeaderbarPrivate *priv = PRIV (headerbar);
#endif
G_OBJECT_CLASS (terminal_headerbar_parent_class)->finalize (object);
}
static void
terminal_headerbar_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
// TerminalHeaderbar *headerbar = TERMINAL_HEADERBAR (object);
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
terminal_headerbar_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
terminal_headerbar_class_init (TerminalHeaderbarClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gobject_class->finalize = terminal_headerbar_finalize;
gobject_class->get_property = terminal_headerbar_get_property;
gobject_class->set_property = terminal_headerbar_set_property;
/* g_object_class_install_properties (gobject_class, G_N_ELEMENTS (pspecs), pspecs); */
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/terminal/ui/headerbar.ui");
}
/* public API */
/**
* terminal_headerbar_new:
*
* Returns: a new #TerminalHeaderbar
*/
GtkWidget *
terminal_headerbar_new (void)
{
return g_object_new (TERMINAL_TYPE_HEADERBAR,
NULL);
}
/*
* Copyright © 2018 Christian Persch
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <gtk/gtk.h>
#include "terminal-screen.h"
G_BEGIN_DECLS
#define TERMINAL_TYPE_HEADERBAR (terminal_headerbar_get_type ())
#define TERMINAL_HEADERBAR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TERMINAL_TYPE_HEADERBAR, TerminalHeaderbar))
#define TERMINAL_HEADERBAR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), TERMINAL_TYPE_HEADERBAR, TerminalHeaderbarClass))
#define TERMINAL_IS_HEADERBAR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TERMINAL_TYPE_HEADERBAR))
#define TERMINAL_IS_HEADERBAR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TERMINAL_TYPE_HEADERBAR))
#define TERMINAL_HEADERBAR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TERMINAL_TYPE_HEADERBAR, TerminalHeaderbarClass))
typedef struct _TerminalHeaderbar TerminalHeaderbar;
typedef struct _TerminalHeaderbarClass TerminalHeaderbarClass;
GType terminal_headerbar_get_type (void);
GtkWidget *terminal_headerbar_new (void);
G_END_DECLS
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright © 2018 Christian Persch
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope conf it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<interface>
<template class="TerminalHeaderbar" parent="GtkHeaderBar">
<property name="can-focus">False</property>
<property name="visible">True</property>
<property name="show-close-button">True</property>
</template>
</interface>
......@@ -78,13 +78,14 @@ G_BEGIN_DECLS
#define TERMINAL_SETTING_ENABLE_MENU_BAR_ACCEL_KEY "menu-accelerator-enabled"
#define TERMINAL_SETTING_ENABLE_MNEMONICS_KEY "mnemonics-enabled"
#define TERMINAL_SETTING_ENABLE_SHORTCUTS_KEY "shortcuts-enabled"
#define TERMINAL_SETTING_HEADERBAR_KEY "headerbar"
#define TERMINAL_SETTING_NEW_TERMINAL_MODE_KEY "new-terminal-mode"
#define TERMINAL_SETTING_SCHEMA_VERSION "schema-version"
#define TERMINAL_SETTING_SHELL_INTEGRATION_KEY "shell-integration-enabled"
#define TERMINAL_SETTING_TAB_POLICY_KEY "tab-policy"
#define TERMINAL_SETTING_TAB_POSITION_KEY "tab-position"
#define TERMINAL_SETTING_THEME_VARIANT_KEY "theme-variant"
#define TERMINAL_SETTING_UNIFIED_MENU "unified-menu"
#define TERMINAL_SETTING_UNIFIED_MENU_KEY "unified-menu"
#define TERMINAL_SETTINGS_LIST_LIST_KEY "list"
#define TERMINAL_SETTINGS_LIST_DEFAULT_KEY "default"
......
......@@ -32,6 +32,7 @@
#include "terminal-debug.h"
#include "terminal-enums.h"
#include "terminal-encoding.h"
#include "terminal-headerbar.h"
#include "terminal-icon-button.h"
#include "terminal-intl.h"
#include "terminal-mdi-container.h"
......@@ -2094,6 +2095,7 @@ terminal_window_init (TerminalWindow *window)
uuid_t u;
char uuidstr[37], role[64];
gboolean shell_shows_menubar;
gboolean use_headerbar;
GSimpleAction *action;
app = terminal_app_get ();
......@@ -2117,6 +2119,14 @@ terminal_window_init (TerminalWindow *window)
}
#endif
use_headerbar = terminal_app_get_use_headerbar (app);
if (use_headerbar) {
GtkWidget *headerbar;
headerbar = terminal_headerbar_new ();
gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);
}
gtk_window_set_title (GTK_WINDOW (window), _("Terminal"));
priv->active_screen = NULL;
......@@ -2191,8 +2201,8 @@ terminal_window_init (TerminalWindow *window)
priv->menubar,
FALSE, FALSE, 0);
terminal_window_set_menubar_visible (window, TRUE);
priv->use_default_menubar_visibility = TRUE;
terminal_window_set_menubar_visible (window, !use_headerbar);
priv->use_default_menubar_visibility = !use_headerbar;
}
/* Maybe make Inspector available */
......
......@@ -18,6 +18,7 @@
<gresources>
<gresource prefix="/org/gnome/terminal">
<file alias="css/terminal.css" compressed="true">terminal.common.css</file>
<file alias="ui/headerbar.ui" compressed="true" preprocess="xml-stripblanks">terminal-headerbar.ui</file>
<file alias="ui/menubar-with-mnemonics.ui" compressed="true" preprocess="xml-stripblanks">terminal-menubar-with-mnemonics.ui</file>
<file alias="ui/menubar-without-mnemonics.ui" compressed="true" preprocess="xml-stripblanks">terminal-menubar-without-mnemonics.ui</file>
<file alias="ui/notebook-menu.ui" compressed="true" preprocess="xml-stripblanks">terminal-notebook-menu.ui</file>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment