|
Packit Service |
3bdf47 |
/*
|
|
Packit Service |
3bdf47 |
* Copyright © 2001, 2002 Havoc Pennington
|
|
Packit Service |
3bdf47 |
* Copyright © 2002 Red Hat, Inc.
|
|
Packit Service |
3bdf47 |
* Copyright © 2002 Sun Microsystems
|
|
Packit Service |
3bdf47 |
* Copyright © 2003 Mariano Suarez-Alvarez
|
|
Packit Service |
3bdf47 |
* Copyright © 2008, 2010, 2011, 2015, 2017 Christian Persch
|
|
Packit Service |
3bdf47 |
*
|
|
Packit Service |
3bdf47 |
* This program is free software: you can redistribute it and/or modify
|
|
Packit Service |
3bdf47 |
* it under the terms of the GNU General Public License as published by
|
|
Packit Service |
3bdf47 |
* the Free Software Foundation, either version 3 of the License, or
|
|
Packit Service |
3bdf47 |
* (at your option) any later version.
|
|
Packit Service |
3bdf47 |
*
|
|
Packit Service |
3bdf47 |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
3bdf47 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
3bdf47 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
3bdf47 |
* GNU General Public License for more details.
|
|
Packit Service |
3bdf47 |
*
|
|
Packit Service |
3bdf47 |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
3bdf47 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
Packit Service |
3bdf47 |
*/
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
#include "config.h"
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
#include <glib.h>
|
|
Packit Service |
3bdf47 |
#include <glib/gi18n.h>
|
|
Packit Service |
3bdf47 |
#include <gio/gio.h>
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
#define G_SETTINGS_ENABLE_BACKEND
|
|
Packit Service |
3bdf47 |
#include <gio/gsettingsbackend.h>
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
#include "terminal-intl.h"
|
|
Packit Service |
3bdf47 |
#include "terminal-debug.h"
|
|
Packit Service |
3bdf47 |
#include "terminal-app.h"
|
|
Packit Service |
3bdf47 |
#include "terminal-accels.h"
|
|
Packit Service |
3bdf47 |
#include "terminal-screen.h"
|
|
Packit Service |
3bdf47 |
#include "terminal-screen-container.h"
|
|
Packit Service |
3bdf47 |
#include "terminal-window.h"
|
|
Packit Service |
3bdf47 |
#include "terminal-profiles-list.h"
|
|
Packit Service |
3bdf47 |
#include "terminal-util.h"
|
|
Packit Service |
3bdf47 |
#include "profile-editor.h"
|
|
Packit Service |
3bdf47 |
#include "terminal-encoding.h"
|
|
Packit Service |
3bdf47 |
#include "terminal-schemas.h"
|
|
Packit Service |
3bdf47 |
#include "terminal-gdbus.h"
|
|
Packit Service |
3bdf47 |
#include "terminal-defines.h"
|
|
Packit Service |
3bdf47 |
#include "terminal-prefs.h"
|
|
Packit Service |
3bdf47 |
#include "terminal-libgsystem.h"
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
#ifdef ENABLE_SEARCH_PROVIDER
|
|
Packit Service |
3bdf47 |
#include "terminal-search-provider.h"
|
|
Packit Service |
3bdf47 |
#endif /* ENABLE_SEARCH_PROVIDER */
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
#include <sys/wait.h>
|
|
Packit Service |
3bdf47 |
#include <errno.h>
|
|
Packit Service |
3bdf47 |
#include <string.h>
|
|
Packit Service |
3bdf47 |
#include <stdlib.h>
|
|
Packit Service |
3bdf47 |
#include <time.h>
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
#define DESKTOP_INTERFACE_SETTINGS_SCHEMA "org.gnome.desktop.interface"
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
#define SYSTEM_PROXY_SETTINGS_SCHEMA "org.gnome.system.proxy"
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
#define GTK_SETTING_PREFER_DARK_THEME "gtk-application-prefer-dark-theme"
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
#define GTK_DEBUG_SETTING_SCHEMA "org.gtk.Settings.Debug"
|
|
Packit Service |
3bdf47 |
#define GTK_DEBUG_ENABLE_INSPECTOR_KEY "enable-inspector-keybinding"
|
|
Packit Service |
3bdf47 |
#define GTK_DEBUG_ENABLE_INSPECTOR_TYPE G_VARIANT_TYPE_BOOLEAN
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/*
|
|
Packit Service |
3bdf47 |
* Session state is stored entirely in the RestartCommand command line.
|
|
Packit Service |
3bdf47 |
*
|
|
Packit Service |
3bdf47 |
* The number one rule: all stored information is EITHER per-session,
|
|
Packit Service |
3bdf47 |
* per-profile, or set from a command line option. THERE CAN BE NO
|
|
Packit Service |
3bdf47 |
* OVERLAP. The UI and implementation totally break if you overlap
|
|
Packit Service |
3bdf47 |
* these categories. See gnome-terminal 1.x for why.
|
|
Packit Service |
3bdf47 |
*/
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
struct _TerminalAppClass {
|
|
Packit Service |
3bdf47 |
GtkApplicationClass parent_class;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
void (* clipboard_targets_changed) (TerminalApp *app,
|
|
Packit Service |
3bdf47 |
GtkClipboard *clipboard);
|
|
Packit Service |
3bdf47 |
};
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
struct _TerminalApp
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
GtkApplication parent_instance;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
GDBusObjectManagerServer *object_manager;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
TerminalSettingsList *profiles_list;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
GHashTable *screen_map;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
GSettings *global_settings;
|
|
Packit Service |
3bdf47 |
GSettings *desktop_interface_settings;
|
|
Packit Service |
3bdf47 |
GSettings *system_proxy_settings;
|
|
Packit Service |
3bdf47 |
GSettings *gtk_debug_settings;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
#ifdef ENABLE_SEARCH_PROVIDER
|
|
Packit Service |
3bdf47 |
TerminalSearchProvider *search_provider;
|
|
Packit Service |
3bdf47 |
#endif /* ENABLE_SEARCH_PROVIDER */
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
GMenuModel *menubar;
|
|
Packit Service |
3bdf47 |
GMenu *menubar_new_terminal_section;
|
|
Packit Service |
3bdf47 |
GMenu *menubar_set_profile_section;
|
|
Packit Service |
3bdf47 |
GMenu *menubar_set_encoding_submenu;
|
|
Packit Service |
3bdf47 |
GMenu *set_profile_menu;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
GtkClipboard *clipboard;
|
|
Packit Service |
3bdf47 |
GdkAtom *clipboard_targets;
|
|
Packit Service |
3bdf47 |
int n_clipboard_targets;
|
|
Packit Service |
3bdf47 |
};
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
enum
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
CLIPBOARD_TARGETS_CHANGED,
|
|
Packit Service |
3bdf47 |
LAST_SIGNAL
|
|
Packit Service |
3bdf47 |
};
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static guint signals[LAST_SIGNAL];
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Debugging helper */
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
terminal_app_init_debug (void)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
#ifdef ENABLE_DEBUG
|
|
Packit Service |
3bdf47 |
const char *env = g_getenv ("GTK_TEXT_DIR");
|
|
Packit Service |
3bdf47 |
if (env != NULL) {
|
|
Packit Service |
3bdf47 |
if (g_str_equal (env, "help")) {
|
|
Packit Service |
3bdf47 |
g_printerr ("Usage: GTK_TEXT_DIR=ltr|rtl\n");
|
|
Packit Service |
3bdf47 |
} else {
|
|
Packit Service |
3bdf47 |
GtkTextDirection dir;
|
|
Packit Service |
3bdf47 |
if (g_str_equal (env, "rtl"))
|
|
Packit Service |
3bdf47 |
dir = GTK_TEXT_DIR_RTL;
|
|
Packit Service |
3bdf47 |
else
|
|
Packit Service |
3bdf47 |
dir = GTK_TEXT_DIR_LTR;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
gtk_widget_set_default_direction (dir);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
env = g_getenv ("GTK_SETTINGS");
|
|
Packit Service |
3bdf47 |
if (env == NULL)
|
|
Packit Service |
3bdf47 |
return;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
GObject *settings = G_OBJECT (gtk_settings_get_default ());
|
|
Packit Service |
3bdf47 |
GObjectClass *settings_class = G_OBJECT_GET_CLASS (settings);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
if (g_str_equal (env, "help")) {
|
|
Packit Service |
3bdf47 |
g_printerr ("Usage: GTK_SETTINGS=setting[,setting…] where 'setting' is one of these:\n");
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
guint n_props;
|
|
Packit Service |
3bdf47 |
GParamSpec **props = g_object_class_list_properties (settings_class, &n_props);
|
|
Packit Service |
3bdf47 |
for (guint i = 0; i < n_props; i++) {
|
|
Packit Service |
3bdf47 |
if (G_PARAM_SPEC_VALUE_TYPE (props[i]) != G_TYPE_BOOLEAN)
|
|
Packit Service |
3bdf47 |
continue;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
GValue value = { 0, };
|
|
Packit Service |
3bdf47 |
g_value_init (&value, G_TYPE_BOOLEAN);
|
|
Packit Service |
3bdf47 |
g_object_get_property (settings, props[i]->name, &value);
|
|
Packit Service |
3bdf47 |
g_printerr (" %s (%s)\n", props[i]->name, g_value_get_boolean (&value) ? "true" : "false");
|
|
Packit Service |
3bdf47 |
g_value_unset (&value);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
g_printerr (" Use 'setting' to set to true, "
|
|
Packit Service |
3bdf47 |
"'~setting' to set to false, "
|
|
Packit Service |
3bdf47 |
"and '!setting' to invert.\n");
|
|
Packit Service |
3bdf47 |
} else {
|
|
Packit Service |
3bdf47 |
gs_strfreev char **tokens = g_strsplit (env, ",", -1);
|
|
Packit Service |
3bdf47 |
for (guint i = 0; tokens[i] != NULL; i++) {
|
|
Packit Service |
3bdf47 |
const char *prop = tokens[i];
|
|
Packit Service |
3bdf47 |
char c = prop[0];
|
|
Packit Service |
3bdf47 |
if (c == '~' || c == '!')
|
|
Packit Service |
3bdf47 |
prop++;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
GParamSpec *pspec = g_object_class_find_property (settings_class, prop);
|
|
Packit Service |
3bdf47 |
if (pspec == NULL) {
|
|
Packit Service |
3bdf47 |
g_printerr ("Setting \"%s\" does not exist.\n", prop);
|
|
Packit Service |
3bdf47 |
} else if (G_PARAM_SPEC_VALUE_TYPE (pspec) != G_TYPE_BOOLEAN) {
|
|
Packit Service |
3bdf47 |
g_printerr ("Setting \"%s\" is not boolean.\n", prop);
|
|
Packit Service |
3bdf47 |
} else {
|
|
Packit Service |
3bdf47 |
GValue value = { 0, };
|
|
Packit Service |
3bdf47 |
g_value_init (&value, G_TYPE_BOOLEAN);
|
|
Packit Service |
3bdf47 |
if (c == '!') {
|
|
Packit Service |
3bdf47 |
g_object_get_property (settings, pspec->name, &value);
|
|
Packit Service |
3bdf47 |
g_value_set_boolean (&value, !g_value_get_boolean (&value));
|
|
Packit Service |
3bdf47 |
} else if (c == '~') {
|
|
Packit Service |
3bdf47 |
g_value_set_boolean (&value, FALSE);
|
|
Packit Service |
3bdf47 |
} else {
|
|
Packit Service |
3bdf47 |
g_value_set_boolean (&value, TRUE);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
g_object_set_property (settings, pspec->name, &value);
|
|
Packit Service |
3bdf47 |
g_value_unset (&value);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
#endif
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Helper functions */
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
maybe_migrate_settings (TerminalApp *app)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
#ifdef ENABLE_MIGRATION
|
|
Packit Service |
3bdf47 |
const char * const argv[] = {
|
|
Packit Service |
3bdf47 |
TERM_LIBEXECDIR "/gnome-terminal-migration",
|
|
Packit Service |
3bdf47 |
#ifdef ENABLE_DEBUG
|
|
Packit Service |
3bdf47 |
"--verbose",
|
|
Packit Service |
3bdf47 |
#endif
|
|
Packit Service |
3bdf47 |
NULL
|
|
Packit Service |
3bdf47 |
};
|
|
Packit Service |
3bdf47 |
int status;
|
|
Packit Service |
3bdf47 |
gs_free_error GError *error = NULL;
|
|
Packit Service |
3bdf47 |
#endif /* ENABLE_MIGRATION */
|
|
Packit Service |
3bdf47 |
guint version;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
version = g_settings_get_uint (terminal_app_get_global_settings (app), TERMINAL_SETTING_SCHEMA_VERSION);
|
|
Packit Service |
3bdf47 |
if (version >= TERMINAL_SCHEMA_VERSION) {
|
|
Packit Service |
3bdf47 |
_terminal_debug_print (TERMINAL_DEBUG_SERVER | TERMINAL_DEBUG_PROFILE,
|
|
Packit Service |
3bdf47 |
"Schema version is %u, already migrated.\n", version);
|
|
Packit Service |
3bdf47 |
return;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
#ifdef ENABLE_MIGRATION
|
|
Packit Service |
3bdf47 |
/* Only do migration if the settings backend is dconf */
|
|
Packit Service |
3bdf47 |
GType type = G_OBJECT_TYPE (g_settings_backend_get_default ());
|
|
Packit Service |
3bdf47 |
if (!g_type_is_a (type, g_type_from_name ("DConfSettingsBackend"))) {
|
|
Packit Service |
3bdf47 |
_terminal_debug_print (TERMINAL_DEBUG_SERVER | TERMINAL_DEBUG_PROFILE,
|
|
Packit Service |
3bdf47 |
"Not migration settings to %s\n", g_type_name (type));
|
|
Packit Service |
3bdf47 |
goto done;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
if (!g_spawn_sync (NULL /* our home directory */,
|
|
Packit Service |
3bdf47 |
(char **) argv,
|
|
Packit Service |
3bdf47 |
NULL /* envv */,
|
|
Packit Service |
3bdf47 |
0,
|
|
Packit Service |
3bdf47 |
NULL, NULL,
|
|
Packit Service |
3bdf47 |
NULL, NULL,
|
|
Packit Service |
3bdf47 |
&status,
|
|
Packit Service |
3bdf47 |
&error)) {
|
|
Packit Service |
3bdf47 |
g_printerr ("Failed to migrate settings: %s\n", error->message);
|
|
Packit Service |
3bdf47 |
return;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
if (WIFEXITED (status)) {
|
|
Packit Service |
3bdf47 |
if (WEXITSTATUS (status) != 0)
|
|
Packit Service |
3bdf47 |
g_printerr ("Profile migrator exited with status %d\n", WEXITSTATUS (status));
|
|
Packit Service |
3bdf47 |
} else {
|
|
Packit Service |
3bdf47 |
g_printerr ("Profile migrator exited abnormally.\n");
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
done:
|
|
Packit Service |
3bdf47 |
#endif /* ENABLE_MIGRATION */
|
|
Packit Service |
3bdf47 |
g_settings_set_uint (terminal_app_get_global_settings (app),
|
|
Packit Service |
3bdf47 |
TERMINAL_SETTING_SCHEMA_VERSION,
|
|
Packit Service |
3bdf47 |
TERMINAL_SCHEMA_VERSION);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static gboolean
|
|
Packit Service |
3bdf47 |
load_css_from_resource (GApplication *application,
|
|
Packit Service |
3bdf47 |
GtkCssProvider *provider,
|
|
Packit Service |
3bdf47 |
gboolean theme)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
const char *base_path;
|
|
Packit Service |
3bdf47 |
gs_free char *uri;
|
|
Packit Service |
3bdf47 |
gs_unref_object GFile *file;
|
|
Packit Service |
3bdf47 |
gs_free_error GError *error = NULL;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
base_path = g_application_get_resource_base_path (application);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
if (theme) {
|
|
Packit Service |
3bdf47 |
gs_free char *str, *theme_name;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
g_object_get (gtk_settings_get_default (), "gtk-theme-name", &str, NULL);
|
|
Packit Service |
3bdf47 |
theme_name = g_ascii_strdown (str, -1);
|
|
Packit Service |
3bdf47 |
uri = g_strdup_printf ("resource://%s/css/%s/terminal.css", base_path, theme_name);
|
|
Packit Service |
3bdf47 |
} else {
|
|
Packit Service |
3bdf47 |
uri = g_strdup_printf ("resource://%s/css/terminal.css", base_path);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
file = g_file_new_for_uri (uri);
|
|
Packit Service |
3bdf47 |
if (!g_file_query_exists (file, NULL /* cancellable */))
|
|
Packit Service |
3bdf47 |
return FALSE;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
if (!gtk_css_provider_load_from_file (provider, file, &error))
|
|
Packit Service |
3bdf47 |
g_assert_no_error (error);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
return TRUE;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
add_css_provider (GApplication *application,
|
|
Packit Service |
3bdf47 |
gboolean theme)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
gs_unref_object GtkCssProvider *provider;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
provider = gtk_css_provider_new ();
|
|
Packit Service |
3bdf47 |
if (!load_css_from_resource (application, provider, theme))
|
|
Packit Service |
3bdf47 |
return;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
|
Packit Service |
3bdf47 |
GTK_STYLE_PROVIDER (provider),
|
|
Packit Service |
3bdf47 |
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
app_load_css (GApplication *application)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
add_css_provider (application, FALSE);
|
|
Packit Service |
3bdf47 |
add_css_provider (application, TRUE);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
char *
|
|
Packit Service |
3bdf47 |
terminal_app_new_profile (TerminalApp *app,
|
|
Packit Service |
3bdf47 |
GSettings *base_profile,
|
|
Packit Service |
3bdf47 |
const char *name)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
char *uuid;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
if (base_profile) {
|
|
Packit Service |
3bdf47 |
gs_free char *base_uuid;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
base_uuid = terminal_settings_list_dup_uuid_from_child (app->profiles_list, base_profile);
|
|
Packit Service |
3bdf47 |
uuid = terminal_settings_list_clone_child (app->profiles_list, base_uuid, name);
|
|
Packit Service |
3bdf47 |
} else {
|
|
Packit Service |
3bdf47 |
uuid = terminal_settings_list_add_child (app->profiles_list, name);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
return uuid;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
void
|
|
Packit Service |
3bdf47 |
terminal_app_remove_profile (TerminalApp *app,
|
|
Packit Service |
3bdf47 |
GSettings *profile)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
g_return_if_fail (TERMINAL_IS_APP (app));
|
|
Packit Service |
3bdf47 |
g_return_if_fail (G_IS_SETTINGS (profile));
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
gs_unref_object GSettings *default_profile = terminal_settings_list_ref_default_child (app->profiles_list);
|
|
Packit Service |
3bdf47 |
if (default_profile == profile)
|
|
Packit Service |
3bdf47 |
return;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* First, we need to switch any screen using this profile to the default profile */
|
|
Packit Service |
3bdf47 |
gs_free_list GList *screens = g_hash_table_get_values (app->screen_map);
|
|
Packit Service |
3bdf47 |
for (GList *l = screens; l != NULL; l = l->next) {
|
|
Packit Service |
3bdf47 |
TerminalScreen *screen = TERMINAL_SCREEN (l->data);
|
|
Packit Service |
3bdf47 |
if (terminal_screen_get_profile (screen) != profile)
|
|
Packit Service |
3bdf47 |
continue;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
terminal_screen_set_profile (screen, default_profile);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Now we can safely remove the profile */
|
|
Packit Service |
3bdf47 |
gs_free char *uuid = terminal_settings_list_dup_uuid_from_child (app->profiles_list, profile);
|
|
Packit Service |
3bdf47 |
terminal_settings_list_remove_child (app->profiles_list, uuid);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
#if GTK_CHECK_VERSION (3, 19, 0)
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
terminal_app_theme_variant_changed_cb (GSettings *settings,
|
|
Packit Service |
3bdf47 |
const char *key,
|
|
Packit Service |
3bdf47 |
GtkSettings *gtk_settings)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
TerminalThemeVariant theme;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
theme = g_settings_get_enum (settings, key);
|
|
Packit Service |
3bdf47 |
if (theme == TERMINAL_THEME_VARIANT_SYSTEM)
|
|
Packit Service |
3bdf47 |
gtk_settings_reset_property (gtk_settings, GTK_SETTING_PREFER_DARK_THEME);
|
|
Packit Service |
3bdf47 |
else
|
|
Packit Service |
3bdf47 |
g_object_set (gtk_settings,
|
|
Packit Service |
3bdf47 |
GTK_SETTING_PREFER_DARK_THEME,
|
|
Packit Service |
3bdf47 |
theme == TERMINAL_THEME_VARIANT_DARK,
|
|
Packit Service |
3bdf47 |
NULL);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
#endif /* GTK+ 3.19 */
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Submenus for New Terminal per profile, and to change profiles */
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void terminal_app_update_profile_menus (TerminalApp *app);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
typedef struct {
|
|
Packit Service |
3bdf47 |
char *uuid;
|
|
Packit Service |
3bdf47 |
char *label;
|
|
Packit Service |
3bdf47 |
} ProfileData;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
profile_data_clear (ProfileData *data)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
g_free (data->uuid);
|
|
Packit Service |
3bdf47 |
g_free (data->label);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
typedef struct {
|
|
Packit Service |
3bdf47 |
GArray *array;
|
|
Packit Service |
3bdf47 |
TerminalApp *app;
|
|
Packit Service |
3bdf47 |
} ProfilesForeachData;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
foreach_profile_cb (TerminalSettingsList *list,
|
|
Packit Service |
3bdf47 |
const char *uuid,
|
|
Packit Service |
3bdf47 |
GSettings *profile,
|
|
Packit Service |
3bdf47 |
ProfilesForeachData *user_data)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
ProfileData data;
|
|
Packit Service |
3bdf47 |
data.uuid = g_strdup (uuid);
|
|
Packit Service |
3bdf47 |
data.label = g_settings_get_string (profile, TERMINAL_PROFILE_VISIBLE_NAME_KEY);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
g_array_append_val (user_data->array, data);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* only connect if we haven't seen this profile before */
|
|
Packit Service |
3bdf47 |
if (g_signal_handler_find (profile, G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
|
|
Packit Service |
3bdf47 |
0, 0, NULL, terminal_app_update_profile_menus, user_data->app) == 0)
|
|
Packit Service |
3bdf47 |
g_signal_connect_swapped (profile, "changed::" TERMINAL_PROFILE_VISIBLE_NAME_KEY,
|
|
Packit Service |
3bdf47 |
G_CALLBACK (terminal_app_update_profile_menus), user_data->app);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static int
|
|
Packit Service |
3bdf47 |
compare_profile_label_cb (gconstpointer ap,
|
|
Packit Service |
3bdf47 |
gconstpointer bp)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
const ProfileData *a = ap;
|
|
Packit Service |
3bdf47 |
const ProfileData *b = bp;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
return g_utf8_collate (a->label, b->label);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
menu_append_numbered (GMenu *menu,
|
|
Packit Service |
3bdf47 |
const char *label,
|
|
Packit Service |
3bdf47 |
int num,
|
|
Packit Service |
3bdf47 |
const char *action_name,
|
|
Packit Service |
3bdf47 |
GVariant *target /* floating, consumed */)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
gs_free_gstring GString *str;
|
|
Packit Service |
3bdf47 |
gs_unref_object GMenuItem *item;
|
|
Packit Service |
3bdf47 |
const char *p;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Who'd use more that 4 underscores in a profile name... */
|
|
Packit Service |
3bdf47 |
str = g_string_sized_new (strlen (label) + 4 + 1 + 8);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
if (num < 10)
|
|
Packit Service |
3bdf47 |
g_string_append_printf (str, "_%Id. ", num);
|
|
Packit Service |
3bdf47 |
else if (num < 36)
|
|
Packit Service |
3bdf47 |
g_string_append_printf (str, "_%c. ", (char)('A' + num - 10));
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Append the label with underscores elided */
|
|
Packit Service |
3bdf47 |
for (p = label; *p; p++) {
|
|
Packit Service |
3bdf47 |
if (*p == '_')
|
|
Packit Service |
3bdf47 |
g_string_append (str, "__");
|
|
Packit Service |
3bdf47 |
else
|
|
Packit Service |
3bdf47 |
g_string_append_c (str, *p);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
item = g_menu_item_new (str->str, NULL);
|
|
Packit Service |
3bdf47 |
g_menu_item_set_action_and_target_value (item, action_name, target);
|
|
Packit Service |
3bdf47 |
g_menu_append_item (menu, item);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
append_new_terminal_item (GMenu *section,
|
|
Packit Service |
3bdf47 |
const char *label,
|
|
Packit Service |
3bdf47 |
const char *target,
|
|
Packit Service |
3bdf47 |
ProfileData *data,
|
|
Packit Service |
3bdf47 |
guint n_profiles)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
gs_unref_object GMenuItem *item = g_menu_item_new (label, NULL);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
if (n_profiles > 1) {
|
|
Packit Service |
3bdf47 |
gs_unref_object GMenu *submenu = g_menu_new ();
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
for (guint i = 0; i < n_profiles; i++) {
|
|
Packit Service |
3bdf47 |
menu_append_numbered (submenu, data[i].label, i + 1,
|
|
Packit Service |
3bdf47 |
"win.new-terminal",
|
|
Packit Service |
3bdf47 |
g_variant_new ("(ss)", target, data[i].uuid));
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
g_menu_item_set_link (item, G_MENU_LINK_SUBMENU, G_MENU_MODEL (submenu));
|
|
Packit Service |
3bdf47 |
} else {
|
|
Packit Service |
3bdf47 |
g_menu_item_set_action_and_target (item, "win.new-terminal",
|
|
Packit Service |
3bdf47 |
"(ss)", target, "current");
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
g_menu_append_item (section, item);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
fill_new_terminal_section (GMenu *section,
|
|
Packit Service |
3bdf47 |
ProfileData *profiles,
|
|
Packit Service |
3bdf47 |
guint n_profiles)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
#ifndef DISUNIFY_NEW_TERMINAL_SECTION
|
|
Packit Service |
3bdf47 |
append_new_terminal_item (section, _("New _Terminal"), "default", profiles, n_profiles);
|
|
Packit Service |
3bdf47 |
#else
|
|
Packit Service |
3bdf47 |
append_new_terminal_item (section, _("New _Tab"), "tab", profiles, n_profiles);
|
|
Packit Service |
3bdf47 |
append_new_terminal_item (section, _("New _Window"), "window", profiles, n_profiles);
|
|
Packit Service |
3bdf47 |
#endif
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static GMenu *
|
|
Packit Service |
3bdf47 |
set_profile_submenu_new (ProfileData *data,
|
|
Packit Service |
3bdf47 |
guint n_profiles)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
/* No submenu if there's only one profile */
|
|
Packit Service |
3bdf47 |
if (n_profiles <= 1)
|
|
Packit Service |
3bdf47 |
return NULL;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
GMenu *menu = g_menu_new ();
|
|
Packit Service |
3bdf47 |
for (guint i = 0; i < n_profiles; i++) {
|
|
Packit Service |
3bdf47 |
menu_append_numbered (menu, data[i].label, i + 1,
|
|
Packit Service |
3bdf47 |
"win.profile",
|
|
Packit Service |
3bdf47 |
g_variant_new_string (data[i].uuid));
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
return menu;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
terminal_app_update_profile_menus (TerminalApp *app)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
g_menu_remove_all (G_MENU (app->menubar_new_terminal_section));
|
|
Packit Service |
3bdf47 |
g_menu_remove_all (G_MENU (app->menubar_set_profile_section));
|
|
Packit Service |
3bdf47 |
g_clear_object (&app->set_profile_menu);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Get profiles list and sort by label */
|
|
Packit Service |
3bdf47 |
gs_unref_array GArray *array = g_array_sized_new (FALSE, TRUE, sizeof (ProfileData),
|
|
Packit Service |
3bdf47 |
terminal_settings_list_get_n_children (app->profiles_list));
|
|
Packit Service |
3bdf47 |
g_array_set_clear_func (array, (GDestroyNotify) profile_data_clear);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
ProfilesForeachData data = { array, app };
|
|
Packit Service |
3bdf47 |
terminal_settings_list_foreach_child (app->profiles_list,
|
|
Packit Service |
3bdf47 |
(TerminalSettingsListForeachFunc) foreach_profile_cb,
|
|
Packit Service |
3bdf47 |
&data);
|
|
Packit Service |
3bdf47 |
g_array_sort (array, compare_profile_label_cb);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
ProfileData *profiles = (ProfileData*) array->data;
|
|
Packit Service |
3bdf47 |
guint n_profiles = array->len;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
fill_new_terminal_section (app->menubar_new_terminal_section, profiles, n_profiles);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
app->set_profile_menu = set_profile_submenu_new (profiles, n_profiles);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
if (app->set_profile_menu != NULL) {
|
|
Packit Service |
3bdf47 |
g_menu_append_submenu (app->menubar_set_profile_section, _("Change _Profile"),
|
|
Packit Service |
3bdf47 |
G_MENU_MODEL (app->set_profile_menu));
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Clipboard */
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
free_clipboard_targets (TerminalApp *app)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
g_free (app->clipboard_targets);
|
|
Packit Service |
3bdf47 |
app->clipboard_targets = NULL;
|
|
Packit Service |
3bdf47 |
app->n_clipboard_targets = 0;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
update_clipboard_targets (TerminalApp *app,
|
|
Packit Service |
3bdf47 |
GdkAtom *targets,
|
|
Packit Service |
3bdf47 |
int n_targets)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
free_clipboard_targets (app);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Sometimes we receive targets == NULL but n_targets == -1 */
|
|
Packit Service |
3bdf47 |
if (targets != NULL) {
|
|
Packit Service |
3bdf47 |
app->clipboard_targets = g_memdup (targets, sizeof (targets[0]) * n_targets);
|
|
Packit Service |
3bdf47 |
app->n_clipboard_targets = n_targets;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
clipboard_targets_received_cb (GtkClipboard *clipboard,
|
|
Packit Service |
3bdf47 |
GdkAtom *targets,
|
|
Packit Service |
3bdf47 |
int n_targets,
|
|
Packit Service |
3bdf47 |
TerminalApp *app)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
update_clipboard_targets (app, targets, n_targets);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
_TERMINAL_DEBUG_IF (TERMINAL_DEBUG_CLIPBOARD) {
|
|
Packit Service |
3bdf47 |
g_printerr ("Clipboard has %d targets:", app->n_clipboard_targets);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
int i;
|
|
Packit Service |
3bdf47 |
for (i = 0; i < app->n_clipboard_targets; i++) {
|
|
Packit Service |
3bdf47 |
gs_free char *atom_name = gdk_atom_name (app->clipboard_targets[i]);
|
|
Packit Service |
3bdf47 |
g_printerr (" %s", atom_name);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
g_printerr ("\n");
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
g_signal_emit (app, signals[CLIPBOARD_TARGETS_CHANGED], 0, clipboard);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
clipboard_owner_change_cb (GtkClipboard *clipboard,
|
|
Packit Service |
3bdf47 |
GdkEvent *event G_GNUC_UNUSED,
|
|
Packit Service |
3bdf47 |
TerminalApp *app)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
_terminal_debug_print (TERMINAL_DEBUG_CLIPBOARD,
|
|
Packit Service |
3bdf47 |
"Clipboard owner changed\n");
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
clipboard_targets_received_cb (clipboard, NULL, 0, app); /* clear */
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* We can do this without holding a reference to @app since
|
|
Packit Service |
3bdf47 |
* the app lives as long as the process.
|
|
Packit Service |
3bdf47 |
*/
|
|
Packit Service |
3bdf47 |
gtk_clipboard_request_targets (clipboard,
|
|
Packit Service |
3bdf47 |
(GtkClipboardTargetsReceivedFunc) clipboard_targets_received_cb,
|
|
Packit Service |
3bdf47 |
app);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* App menu callbacks */
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
app_menu_preferences_cb (GSimpleAction *action,
|
|
Packit Service |
3bdf47 |
GVariant *parameter,
|
|
Packit Service |
3bdf47 |
gpointer user_data)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
TerminalApp *app = user_data;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
terminal_app_edit_preferences (app, NULL, NULL);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
app_menu_help_cb (GSimpleAction *action,
|
|
Packit Service |
3bdf47 |
GVariant *parameter,
|
|
Packit Service |
3bdf47 |
gpointer user_data)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
terminal_util_show_help (NULL);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
app_menu_about_cb (GSimpleAction *action,
|
|
Packit Service |
3bdf47 |
GVariant *parameter,
|
|
Packit Service |
3bdf47 |
gpointer user_data)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
terminal_util_show_about ();
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
app_menu_quit_cb (GSimpleAction *action,
|
|
Packit Service |
3bdf47 |
GVariant *parameter,
|
|
Packit Service |
3bdf47 |
gpointer user_data)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
GtkApplication *application = user_data;
|
|
Packit Service |
3bdf47 |
GtkWindow *window;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
window = gtk_application_get_active_window (application);
|
|
Packit Service |
3bdf47 |
if (TERMINAL_IS_WINDOW (window))
|
|
Packit Service |
3bdf47 |
terminal_window_request_close (TERMINAL_WINDOW (window));
|
|
Packit Service |
3bdf47 |
else /* a dialogue */
|
|
Packit Service |
3bdf47 |
gtk_widget_destroy (GTK_WIDGET (window));
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Class implementation */
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
G_DEFINE_TYPE (TerminalApp, terminal_app, GTK_TYPE_APPLICATION)
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* GApplicationClass impl */
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
terminal_app_activate (GApplication *application)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
/* No-op required because GApplication is stupid */
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
terminal_app_startup (GApplication *application)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
TerminalApp *app = TERMINAL_APP (application);
|
|
Packit Service |
3bdf47 |
GtkApplication *gtk_application = GTK_APPLICATION (application);
|
|
Packit Service |
3bdf47 |
const GActionEntry action_entries[] = {
|
|
Packit Service |
3bdf47 |
{ "preferences", app_menu_preferences_cb, NULL, NULL, NULL },
|
|
Packit Service |
3bdf47 |
{ "help", app_menu_help_cb, NULL, NULL, NULL },
|
|
Packit Service |
3bdf47 |
{ "about", app_menu_about_cb, NULL, NULL, NULL },
|
|
Packit Service |
3bdf47 |
{ "quit", app_menu_quit_cb, NULL, NULL, NULL }
|
|
Packit Service |
3bdf47 |
};
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
g_application_set_resource_base_path (application, TERMINAL_RESOURCES_PATH_PREFIX);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
G_APPLICATION_CLASS (terminal_app_parent_class)->startup (application);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Need to set the WM class (bug #685742) */
|
|
Packit Service |
3bdf47 |
gdk_set_program_class("Gnome-terminal");
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
g_action_map_add_action_entries (G_ACTION_MAP (application),
|
|
Packit Service |
3bdf47 |
action_entries, G_N_ELEMENTS (action_entries),
|
|
Packit Service |
3bdf47 |
application);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
app_load_css (application);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Figure out whether the shell shows appmenu/menubar */
|
|
Packit Service |
3bdf47 |
gboolean shell_shows_appmenu, shell_shows_menubar;
|
|
Packit Service |
3bdf47 |
g_object_get (gtk_settings_get_default (),
|
|
Packit Service |
3bdf47 |
"gtk-shell-shows-app-menu", &shell_shows_appmenu,
|
|
Packit Service |
3bdf47 |
"gtk-shell-shows-menubar", &shell_shows_menubar,
|
|
Packit Service |
3bdf47 |
NULL);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* App menu */
|
|
Packit Service |
3bdf47 |
GMenu *appmenu_new_terminal_section = gtk_application_get_menu_by_id (gtk_application,
|
|
Packit Service |
3bdf47 |
"new-terminal-section");
|
|
Packit Service |
3bdf47 |
fill_new_terminal_section (appmenu_new_terminal_section, NULL, 0); /* no submenu */
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Menubar */
|
|
Packit Service |
3bdf47 |
/* If the menubar is shown by the shell, omit mnemonics for the submenus. This is because Alt+F etc.
|
|
Packit Service |
3bdf47 |
* are more important to be usable in the terminal, the menu cannot be replaced runtime (to toggle
|
|
Packit Service |
3bdf47 |
* between mnemonic and non-mnemonic versions), gtk-enable-mnemonics or gtk_window_set_mnemonic_modifier()
|
|
Packit Service |
3bdf47 |
* don't effect the menubar either, so there wouldn't be a way to disable Alt+F for File etc. otherwise.
|
|
Packit Service |
3bdf47 |
* Furthermore, the menu would even grab mnemonics from the File and Preferences windows.
|
|
Packit Service |
3bdf47 |
* In Unity, Alt+F10 opens the menubar, this should be good enough for keyboard navigation.
|
|
Packit Service |
3bdf47 |
* If the menubar is shown by the app, toggling mnemonics is handled in terminal-window.c using
|
|
Packit Service |
3bdf47 |
* gtk_window_set_mnemonic_modifier().
|
|
Packit Service |
3bdf47 |
* See bug 792978 for details. */
|
|
Packit Service |
3bdf47 |
terminal_util_load_objects_resource (shell_shows_menubar ? "/org/gnome/terminal/ui/menubar-without-mnemonics.ui"
|
|
Packit Service |
3bdf47 |
: "/org/gnome/terminal/ui/menubar-with-mnemonics.ui",
|
|
Packit Service |
3bdf47 |
"menubar", &app->menubar,
|
|
Packit Service |
3bdf47 |
"new-terminal-section", &app->menubar_new_terminal_section,
|
|
Packit Service |
3bdf47 |
"set-profile-section", &app->menubar_set_profile_section,
|
|
Packit Service |
3bdf47 |
"set-encoding-submenu", &app->menubar_set_encoding_submenu,
|
|
Packit Service |
3bdf47 |
NULL);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Create dynamic menus and keep them updated */
|
|
Packit Service |
3bdf47 |
terminal_app_update_profile_menus (app);
|
|
Packit Service |
3bdf47 |
g_signal_connect_swapped (app->profiles_list, "children-changed",
|
|
Packit Service |
3bdf47 |
G_CALLBACK (terminal_app_update_profile_menus), app);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Install the encodings submenu */
|
|
Packit Service |
3bdf47 |
terminal_encodings_append_menu (app->menubar_set_encoding_submenu);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Show/hide the appmenu/menubar as appropriate:
|
|
Packit Service |
3bdf47 |
* If the shell wants to show the menubar, make it available.
|
|
Packit Service |
3bdf47 |
* If the shell wants to show both the appmenu and the menubar, there's no need for the appmenu. */
|
|
Packit Service |
3bdf47 |
if (shell_shows_appmenu && shell_shows_menubar)
|
|
Packit Service |
3bdf47 |
gtk_application_set_app_menu (GTK_APPLICATION (app), NULL);
|
|
Packit Service |
3bdf47 |
if (shell_shows_menubar)
|
|
Packit Service |
3bdf47 |
gtk_application_set_menubar (GTK_APPLICATION (app), app->menubar);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
_terminal_debug_print (TERMINAL_DEBUG_SERVER, "Startup complete\n");
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* GObjectClass impl */
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
terminal_app_init (TerminalApp *app)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
terminal_app_init_debug ();
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
gtk_window_set_default_icon_name (GNOME_TERMINAL_ICON_NAME);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Desktop proxy settings */
|
|
Packit Service |
3bdf47 |
app->system_proxy_settings = g_settings_new (SYSTEM_PROXY_SETTINGS_SCHEMA);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Desktop Interface settings */
|
|
Packit Service |
3bdf47 |
app->desktop_interface_settings = g_settings_new (DESKTOP_INTERFACE_SETTINGS_SCHEMA);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Terminal global settings */
|
|
Packit Service |
3bdf47 |
app->global_settings = g_settings_new (TERMINAL_SETTING_SCHEMA);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Gtk debug settings */
|
|
Packit Service |
3bdf47 |
app->gtk_debug_settings = terminal_g_settings_new (GTK_DEBUG_SETTING_SCHEMA,
|
|
Packit Service |
3bdf47 |
GTK_DEBUG_ENABLE_INSPECTOR_KEY,
|
|
Packit Service |
3bdf47 |
GTK_DEBUG_ENABLE_INSPECTOR_TYPE);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
#if GTK_CHECK_VERSION (3, 19, 0)
|
|
Packit Service |
3bdf47 |
GtkSettings *gtk_settings = gtk_settings_get_default ();
|
|
Packit Service |
3bdf47 |
terminal_app_theme_variant_changed_cb (app->global_settings,
|
|
Packit Service |
3bdf47 |
TERMINAL_SETTING_THEME_VARIANT_KEY, gtk_settings);
|
|
Packit Service |
3bdf47 |
g_signal_connect (app->global_settings,
|
|
Packit Service |
3bdf47 |
"changed::" TERMINAL_SETTING_THEME_VARIANT_KEY,
|
|
Packit Service |
3bdf47 |
G_CALLBACK (terminal_app_theme_variant_changed_cb),
|
|
Packit Service |
3bdf47 |
gtk_settings);
|
|
Packit Service |
3bdf47 |
#endif /* GTK+ 3.19 */
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Clipboard targets */
|
|
Packit Service |
3bdf47 |
GdkDisplay *display = gdk_display_get_default ();
|
|
Packit Service |
3bdf47 |
app->clipboard = gtk_clipboard_get_for_display (display, GDK_SELECTION_CLIPBOARD);
|
|
Packit Service |
3bdf47 |
clipboard_owner_change_cb (app->clipboard, NULL, app);
|
|
Packit Service |
3bdf47 |
g_signal_connect (app->clipboard, "owner-change",
|
|
Packit Service |
3bdf47 |
G_CALLBACK (clipboard_owner_change_cb), app);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
if (!gdk_display_supports_selection_notification (display))
|
|
Packit Service |
3bdf47 |
g_printerr ("Display does not support owner-change; copy/paste will be broken!\n");
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Check if we need to migrate from gconf to dconf */
|
|
Packit Service |
3bdf47 |
maybe_migrate_settings (app);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Get the profiles */
|
|
Packit Service |
3bdf47 |
app->profiles_list = terminal_profiles_list_new ();
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
app->screen_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
gs_unref_object GSettings *settings = g_settings_get_child (app->global_settings, "keybindings");
|
|
Packit Service |
3bdf47 |
terminal_accels_init (G_APPLICATION (app), settings);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
terminal_app_finalize (GObject *object)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
TerminalApp *app = TERMINAL_APP (object);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
g_signal_handlers_disconnect_by_func (app->clipboard,
|
|
Packit Service |
3bdf47 |
G_CALLBACK (clipboard_owner_change_cb),
|
|
Packit Service |
3bdf47 |
app);
|
|
Packit Service |
3bdf47 |
free_clipboard_targets (app);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
g_signal_handlers_disconnect_by_func (app->profiles_list,
|
|
Packit Service |
3bdf47 |
G_CALLBACK (terminal_app_update_profile_menus),
|
|
Packit Service |
3bdf47 |
app);
|
|
Packit Service |
3bdf47 |
g_hash_table_destroy (app->screen_map);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
g_object_unref (app->global_settings);
|
|
Packit Service |
3bdf47 |
g_object_unref (app->desktop_interface_settings);
|
|
Packit Service |
3bdf47 |
g_object_unref (app->system_proxy_settings);
|
|
Packit Service |
3bdf47 |
g_clear_object (&app->gtk_debug_settings);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
g_clear_object (&app->menubar);
|
|
Packit Service |
3bdf47 |
g_clear_object (&app->menubar_new_terminal_section);
|
|
Packit Service |
3bdf47 |
g_clear_object (&app->menubar_set_profile_section);
|
|
Packit Service |
3bdf47 |
g_clear_object (&app->menubar_set_encoding_submenu);
|
|
Packit Service |
3bdf47 |
g_clear_object (&app->set_profile_menu);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
terminal_accels_shutdown ();
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
G_OBJECT_CLASS (terminal_app_parent_class)->finalize (object);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static gboolean
|
|
Packit Service |
3bdf47 |
terminal_app_dbus_register (GApplication *application,
|
|
Packit Service |
3bdf47 |
GDBusConnection *connection,
|
|
Packit Service |
3bdf47 |
const gchar *object_path,
|
|
Packit Service |
3bdf47 |
GError **error)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
TerminalApp *app = TERMINAL_APP (application);
|
|
Packit Service |
3bdf47 |
gs_unref_object TerminalObjectSkeleton *object = NULL;
|
|
Packit Service |
3bdf47 |
gs_unref_object TerminalFactory *factory = NULL;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
if (!G_APPLICATION_CLASS (terminal_app_parent_class)->dbus_register (application,
|
|
Packit Service |
3bdf47 |
connection,
|
|
Packit Service |
3bdf47 |
object_path,
|
|
Packit Service |
3bdf47 |
error))
|
|
Packit Service |
3bdf47 |
return FALSE;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
#ifdef ENABLE_SEARCH_PROVIDER
|
|
Packit Service |
3bdf47 |
if (g_settings_get_boolean (app->global_settings, TERMINAL_SETTING_SHELL_INTEGRATION_KEY)) {
|
|
Packit Service |
3bdf47 |
gs_unref_object TerminalSearchProvider *search_provider;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
search_provider = terminal_search_provider_new ();
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
if (!terminal_search_provider_dbus_register (search_provider,
|
|
Packit Service |
3bdf47 |
connection,
|
|
Packit Service |
3bdf47 |
TERMINAL_SEARCH_PROVIDER_PATH,
|
|
Packit Service |
3bdf47 |
error))
|
|
Packit Service |
3bdf47 |
return FALSE;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
gs_transfer_out_value (&app->search_provider, &search_provider);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
#endif /* ENABLE_SEARCH_PROVIDER */
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
object = terminal_object_skeleton_new (TERMINAL_FACTORY_OBJECT_PATH);
|
|
Packit Service |
3bdf47 |
factory = terminal_factory_impl_new ();
|
|
Packit Service |
3bdf47 |
terminal_object_skeleton_set_factory (object, factory);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
app->object_manager = g_dbus_object_manager_server_new (TERMINAL_OBJECT_PATH_PREFIX);
|
|
Packit Service |
3bdf47 |
g_dbus_object_manager_server_export (app->object_manager, G_DBUS_OBJECT_SKELETON (object));
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* And export the object */
|
|
Packit Service |
3bdf47 |
g_dbus_object_manager_server_set_connection (app->object_manager, connection);
|
|
Packit Service |
3bdf47 |
return TRUE;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
terminal_app_dbus_unregister (GApplication *application,
|
|
Packit Service |
3bdf47 |
GDBusConnection *connection,
|
|
Packit Service |
3bdf47 |
const gchar *object_path)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
TerminalApp *app = TERMINAL_APP (application);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
if (app->object_manager) {
|
|
Packit Service |
3bdf47 |
g_dbus_object_manager_server_unexport (app->object_manager, TERMINAL_FACTORY_OBJECT_PATH);
|
|
Packit Service |
3bdf47 |
g_object_unref (app->object_manager);
|
|
Packit Service |
3bdf47 |
app->object_manager = NULL;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
#ifdef ENABLE_SEARCH_PROVIDER
|
|
Packit Service |
3bdf47 |
if (app->search_provider) {
|
|
Packit Service |
3bdf47 |
terminal_search_provider_dbus_unregister (app->search_provider, connection, TERMINAL_SEARCH_PROVIDER_PATH);
|
|
Packit Service |
3bdf47 |
g_object_unref (app->search_provider);
|
|
Packit Service |
3bdf47 |
app->search_provider = NULL;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
#endif /* ENABLE_SEARCH_PROVIDER */
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
G_APPLICATION_CLASS (terminal_app_parent_class)->dbus_unregister (application,
|
|
Packit Service |
3bdf47 |
connection,
|
|
Packit Service |
3bdf47 |
object_path);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
static void
|
|
Packit Service |
3bdf47 |
terminal_app_class_init (TerminalAppClass *klass)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
Packit Service |
3bdf47 |
GApplicationClass *g_application_class = G_APPLICATION_CLASS (klass);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
object_class->finalize = terminal_app_finalize;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
g_application_class->activate = terminal_app_activate;
|
|
Packit Service |
3bdf47 |
g_application_class->startup = terminal_app_startup;
|
|
Packit Service |
3bdf47 |
g_application_class->dbus_register = terminal_app_dbus_register;
|
|
Packit Service |
3bdf47 |
g_application_class->dbus_unregister = terminal_app_dbus_unregister;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
signals[CLIPBOARD_TARGETS_CHANGED] =
|
|
Packit Service |
3bdf47 |
g_signal_new (I_("clipboard-targets-changed"),
|
|
Packit Service |
3bdf47 |
G_OBJECT_CLASS_TYPE (object_class),
|
|
Packit Service |
3bdf47 |
G_SIGNAL_RUN_LAST,
|
|
Packit Service |
3bdf47 |
G_STRUCT_OFFSET (TerminalAppClass, clipboard_targets_changed),
|
|
Packit Service |
3bdf47 |
NULL, NULL,
|
|
Packit Service |
3bdf47 |
g_cclosure_marshal_VOID__OBJECT,
|
|
Packit Service |
3bdf47 |
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Public API */
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
GApplication *
|
|
Packit Service |
3bdf47 |
terminal_app_new (const char *app_id)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
const GApplicationFlags flags = G_APPLICATION_IS_SERVICE;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
return g_object_new (TERMINAL_TYPE_APP,
|
|
Packit Service |
3bdf47 |
"application-id", app_id ? app_id : TERMINAL_APPLICATION_ID,
|
|
Packit Service |
3bdf47 |
"flags", flags,
|
|
Packit Service |
3bdf47 |
NULL);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/**
|
|
Packit Service |
3bdf47 |
* terminal_app_new_window:
|
|
Packit Service |
3bdf47 |
* @app:
|
|
Packit Service |
3bdf47 |
* @monitor:
|
|
Packit Service |
3bdf47 |
*
|
|
Packit Service |
3bdf47 |
* Creates a new #TerminalWindow on the default display.
|
|
Packit Service |
3bdf47 |
*/
|
|
Packit Service |
3bdf47 |
TerminalWindow *
|
|
Packit Service |
3bdf47 |
terminal_app_new_window (TerminalApp *app,
|
|
Packit Service |
3bdf47 |
int monitor)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
TerminalWindow *window;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
window = terminal_window_new (G_APPLICATION (app));
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
return window;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
TerminalScreen *
|
|
Packit Service |
3bdf47 |
terminal_app_new_terminal (TerminalApp *app,
|
|
Packit Service |
3bdf47 |
TerminalWindow *window,
|
|
Packit Service |
3bdf47 |
GSettings *profile,
|
|
Packit Service |
3bdf47 |
const char *charset,
|
|
Packit Service |
3bdf47 |
char **override_command,
|
|
Packit Service |
3bdf47 |
const char *title,
|
|
Packit Service |
3bdf47 |
const char *working_dir,
|
|
Packit Service |
3bdf47 |
char **child_env,
|
|
Packit Service |
3bdf47 |
double zoom)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
TerminalScreen *screen;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
g_return_val_if_fail (TERMINAL_IS_APP (app), NULL);
|
|
Packit Service |
3bdf47 |
g_return_val_if_fail (TERMINAL_IS_WINDOW (window), NULL);
|
|
Packit Service |
3bdf47 |
g_return_val_if_fail (charset == NULL || terminal_encodings_is_known_charset (charset), NULL);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
screen = terminal_screen_new (profile, charset, override_command, title,
|
|
Packit Service |
3bdf47 |
working_dir, child_env, zoom);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
terminal_window_add_screen (window, screen, -1);
|
|
Packit Service |
3bdf47 |
terminal_window_switch_screen (window, screen);
|
|
Packit Service |
3bdf47 |
gtk_widget_grab_focus (GTK_WIDGET (screen));
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/* Launch the child on idle */
|
|
Packit Service |
3bdf47 |
_terminal_screen_launch_child_on_idle (screen);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
return screen;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
TerminalScreen *
|
|
Packit Service |
3bdf47 |
terminal_app_get_screen_by_uuid (TerminalApp *app,
|
|
Packit Service |
3bdf47 |
const char *uuid)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
g_return_val_if_fail (TERMINAL_IS_APP (app), NULL);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
return g_hash_table_lookup (app->screen_map, uuid);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
char *
|
|
Packit Service |
3bdf47 |
terminal_app_dup_screen_object_path (TerminalApp *app,
|
|
Packit Service |
3bdf47 |
TerminalScreen *screen)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
char *object_path = g_strdup_printf (TERMINAL_RECEIVER_OBJECT_PATH_FORMAT,
|
|
Packit Service |
3bdf47 |
terminal_screen_get_uuid (screen));
|
|
Packit Service |
3bdf47 |
object_path = g_strdelimit (object_path, "-", '_');
|
|
Packit Service |
3bdf47 |
g_assert (g_variant_is_object_path (object_path));
|
|
Packit Service |
3bdf47 |
return object_path;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/**
|
|
Packit Service |
3bdf47 |
* terminal_app_get_receiver_impl_by_object_path:
|
|
Packit Service |
3bdf47 |
* @app:
|
|
Packit Service |
3bdf47 |
* @object_path:
|
|
Packit Service |
3bdf47 |
*
|
|
Packit Service |
3bdf47 |
* Returns: (transfer full): the #TerminalReceiverImpl for @object_path, or %NULL
|
|
Packit Service |
3bdf47 |
*/
|
|
Packit Service |
3bdf47 |
static TerminalReceiverImpl *
|
|
Packit Service |
3bdf47 |
terminal_app_get_receiver_impl_by_object_path (TerminalApp *app,
|
|
Packit Service |
3bdf47 |
const char *object_path)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
gs_unref_object GDBusObject *skeleton =
|
|
Packit Service |
3bdf47 |
g_dbus_object_manager_get_object (G_DBUS_OBJECT_MANAGER (app->object_manager),
|
|
Packit Service |
3bdf47 |
object_path);
|
|
Packit Service |
3bdf47 |
if (skeleton == NULL || !TERMINAL_IS_OBJECT_SKELETON (skeleton))
|
|
Packit Service |
3bdf47 |
return NULL;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
TerminalReceiverImpl *impl = NULL;
|
|
Packit Service |
3bdf47 |
g_object_get (skeleton, "receiver", &impl, NULL);
|
|
Packit Service |
3bdf47 |
if (impl == NULL)
|
|
Packit Service |
3bdf47 |
return NULL;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
g_assert (TERMINAL_IS_RECEIVER_IMPL (impl));
|
|
Packit Service |
3bdf47 |
return impl;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/**
|
|
Packit Service |
3bdf47 |
* terminal_app_get_screen_by_object_path:
|
|
Packit Service |
3bdf47 |
* @app:
|
|
Packit Service |
3bdf47 |
* @object_path:
|
|
Packit Service |
3bdf47 |
*
|
|
Packit Service |
3bdf47 |
* Returns: (transfer full): the #TerminalScreen for @object_path, or %NULL
|
|
Packit Service |
3bdf47 |
*/
|
|
Packit Service |
3bdf47 |
TerminalScreen *
|
|
Packit Service |
3bdf47 |
terminal_app_get_screen_by_object_path (TerminalApp *app,
|
|
Packit Service |
3bdf47 |
const char *object_path)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
gs_unref_object TerminalReceiverImpl *impl =
|
|
Packit Service |
3bdf47 |
terminal_app_get_receiver_impl_by_object_path (app, object_path);
|
|
Packit Service |
3bdf47 |
if (impl == NULL)
|
|
Packit Service |
3bdf47 |
return NULL;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
return terminal_receiver_impl_get_screen (impl);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
void
|
|
Packit Service |
3bdf47 |
terminal_app_register_screen (TerminalApp *app,
|
|
Packit Service |
3bdf47 |
TerminalScreen *screen)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
const char *uuid = terminal_screen_get_uuid (screen);
|
|
Packit Service |
3bdf47 |
g_hash_table_insert (app->screen_map, g_strdup (uuid), screen);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
gs_free char *object_path = terminal_app_dup_screen_object_path (app, screen);
|
|
Packit Service |
3bdf47 |
TerminalObjectSkeleton *skeleton = terminal_object_skeleton_new (object_path);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
TerminalReceiverImpl *impl = terminal_receiver_impl_new (screen);
|
|
Packit Service |
3bdf47 |
terminal_object_skeleton_set_receiver (skeleton, TERMINAL_RECEIVER (impl));
|
|
Packit Service |
3bdf47 |
g_object_unref (impl);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
g_dbus_object_manager_server_export (app->object_manager,
|
|
Packit Service |
3bdf47 |
G_DBUS_OBJECT_SKELETON (skeleton));
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
void
|
|
Packit Service |
3bdf47 |
terminal_app_unregister_screen (TerminalApp *app,
|
|
Packit Service |
3bdf47 |
TerminalScreen *screen)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
const char *uuid = terminal_screen_get_uuid (screen);
|
|
Packit Service |
3bdf47 |
gboolean found = g_hash_table_remove (app->screen_map, uuid);
|
|
Packit Service |
3bdf47 |
g_warn_if_fail (found);
|
|
Packit Service |
3bdf47 |
if (!found)
|
|
Packit Service |
3bdf47 |
return; /* repeat unregistering */
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
gs_free char *object_path = terminal_app_dup_screen_object_path (app, screen);
|
|
Packit Service |
3bdf47 |
gs_unref_object TerminalReceiverImpl *impl =
|
|
Packit Service |
3bdf47 |
terminal_app_get_receiver_impl_by_object_path (app, object_path);
|
|
Packit Service |
3bdf47 |
g_warn_if_fail (impl != NULL);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
if (impl != NULL)
|
|
Packit Service |
3bdf47 |
terminal_receiver_impl_unset_screen (impl);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
g_dbus_object_manager_server_unexport (app->object_manager, object_path);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
GdkAtom *
|
|
Packit Service |
3bdf47 |
terminal_app_get_clipboard_targets (TerminalApp *app,
|
|
Packit Service |
3bdf47 |
GtkClipboard *clipboard,
|
|
Packit Service |
3bdf47 |
int *n_targets)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
g_return_val_if_fail (TERMINAL_IS_APP (app), NULL);
|
|
Packit Service |
3bdf47 |
g_return_val_if_fail (n_targets != NULL, NULL);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
if (clipboard != app->clipboard) {
|
|
Packit Service |
3bdf47 |
*n_targets = 0;
|
|
Packit Service |
3bdf47 |
return NULL;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
*n_targets = app->n_clipboard_targets;
|
|
Packit Service |
3bdf47 |
return app->clipboard_targets;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
void
|
|
Packit Service |
3bdf47 |
terminal_app_edit_preferences (TerminalApp *app,
|
|
Packit Service |
3bdf47 |
GSettings *profile,
|
|
Packit Service |
3bdf47 |
const char *widget_name)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
terminal_prefs_show_preferences (profile, widget_name);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/**
|
|
Packit Service |
3bdf47 |
* terminal_app_get_profiles_list:
|
|
Packit Service |
3bdf47 |
*
|
|
Packit Service |
3bdf47 |
* Returns: (transfer none): returns the singleton profiles list #TerminalSettingsList
|
|
Packit Service |
3bdf47 |
*/
|
|
Packit Service |
3bdf47 |
TerminalSettingsList *
|
|
Packit Service |
3bdf47 |
terminal_app_get_profiles_list (TerminalApp *app)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
return app->profiles_list;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/**
|
|
Packit Service |
3bdf47 |
* terminal_app_get_menubar:
|
|
Packit Service |
3bdf47 |
* @app: a #TerminalApp
|
|
Packit Service |
3bdf47 |
*
|
|
Packit Service |
3bdf47 |
* Returns: (tranfer none): the main window menu bar as a #GMenuModel
|
|
Packit Service |
3bdf47 |
*/
|
|
Packit Service |
3bdf47 |
GMenuModel *
|
|
Packit Service |
3bdf47 |
terminal_app_get_menubar (TerminalApp *app)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
return app->menubar;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/**
|
|
Packit Service |
3bdf47 |
* terminal_app_get_profile_section:
|
|
Packit Service |
3bdf47 |
* @app: a #TerminalApp
|
|
Packit Service |
3bdf47 |
*
|
|
Packit Service |
3bdf47 |
* Returns: (tranfer none): the main window's menubar's profiles section as a #GMenuModel
|
|
Packit Service |
3bdf47 |
*/
|
|
Packit Service |
3bdf47 |
GMenuModel *
|
|
Packit Service |
3bdf47 |
terminal_app_get_profile_section (TerminalApp *app)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
return G_MENU_MODEL (app->set_profile_menu);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/**
|
|
Packit Service |
3bdf47 |
* terminal_app_get_global_settings:
|
|
Packit Service |
3bdf47 |
* @app: a #TerminalApp
|
|
Packit Service |
3bdf47 |
*
|
|
Packit Service |
3bdf47 |
* Returns: (tranfer none): the cached #GSettings object for the org.gnome.Terminal.Preferences schema
|
|
Packit Service |
3bdf47 |
*/
|
|
Packit Service |
3bdf47 |
GSettings *
|
|
Packit Service |
3bdf47 |
terminal_app_get_global_settings (TerminalApp *app)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
return app->global_settings;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/**
|
|
Packit Service |
3bdf47 |
* terminal_app_get_desktop_interface_settings:
|
|
Packit Service |
3bdf47 |
* @app: a #TerminalApp
|
|
Packit Service |
3bdf47 |
*
|
|
Packit Service |
3bdf47 |
* Returns: (tranfer none): the cached #GSettings object for the org.gnome.interface schema
|
|
Packit Service |
3bdf47 |
*/
|
|
Packit Service |
3bdf47 |
GSettings *
|
|
Packit Service |
3bdf47 |
terminal_app_get_desktop_interface_settings (TerminalApp *app)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
return app->desktop_interface_settings;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/**
|
|
Packit Service |
3bdf47 |
* terminal_app_get_proxy_settings:
|
|
Packit Service |
3bdf47 |
* @app: a #TerminalApp
|
|
Packit Service |
3bdf47 |
*
|
|
Packit Service |
3bdf47 |
* Returns: (tranfer none): the cached #GSettings object for the org.gnome.system.proxy schema
|
|
Packit Service |
3bdf47 |
*/
|
|
Packit Service |
3bdf47 |
GSettings *
|
|
Packit Service |
3bdf47 |
terminal_app_get_proxy_settings (TerminalApp *app)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
return app->system_proxy_settings;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
GSettings *
|
|
Packit Service |
3bdf47 |
terminal_app_get_gtk_debug_settings (TerminalApp *app)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
return app->gtk_debug_settings;
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/**
|
|
Packit Service |
3bdf47 |
* terminal_app_get_system_font:
|
|
Packit Service |
3bdf47 |
* @app:
|
|
Packit Service |
3bdf47 |
*
|
|
Packit Service |
3bdf47 |
* Creates a #PangoFontDescription for the system monospace font.
|
|
Packit Service |
3bdf47 |
*
|
|
Packit Service |
3bdf47 |
* Returns: (transfer full): a new #PangoFontDescription
|
|
Packit Service |
3bdf47 |
*/
|
|
Packit Service |
3bdf47 |
PangoFontDescription *
|
|
Packit Service |
3bdf47 |
terminal_app_get_system_font (TerminalApp *app)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
gs_free char *font = NULL;
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
g_return_val_if_fail (TERMINAL_IS_APP (app), NULL);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
font = g_settings_get_string (app->desktop_interface_settings, MONOSPACE_FONT_KEY_NAME);
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
return pango_font_description_from_string (font);
|
|
Packit Service |
3bdf47 |
}
|
|
Packit Service |
3bdf47 |
|
|
Packit Service |
3bdf47 |
/**
|
|
Packit Service |
3bdf47 |
* FIXME
|
|
Packit Service |
3bdf47 |
*/
|
|
Packit Service |
3bdf47 |
GDBusObjectManagerServer *
|
|
Packit Service |
3bdf47 |
terminal_app_get_object_manager (TerminalApp *app)
|
|
Packit Service |
3bdf47 |
{
|
|
Packit Service |
3bdf47 |
g_warn_if_fail (app->object_manager != NULL);
|
|
Packit Service |
3bdf47 |
return app->object_manager;
|
|
Packit Service |
3bdf47 |
}
|