aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/interface-gtk
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2021-10-13 23:36:58 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2021-10-13 23:36:58 +0300
commitfdb89d9b0744b98dcc8ceacd53fcdd255fbc0b1e (patch)
tree69ac2e950692f1c5b4f3b25d9b25865a15ced968 /src/interface-gtk
parentcc929087f90da5479152e26829e10af2c1c3b937 (diff)
downloadsciteco-fdb89d9b0744b98dcc8ceacd53fcdd255fbc0b1e.tar.gz
GTK: Support for Xembed protocol via --xembed
* This was surprisingly easy to implement as Gtk+ 3 already supports it via GtkPlug. * Allows embedding SciTECO into other Xembed-aware applications. * Unfortunately there are very few generic Xembed hosts. tabbed (https://tools.suckless.org/tabbed/) would be one of them. It could be used to add tabs to SciTECO even on non-tiling window managers: $ tabbed sciteco --xembed * Unfortunately, it does not seem to be possible to use this feature to let SciTECO replace the contents of a terminal window even though many terminal emulators provide $WINDOWID.
Diffstat (limited to 'src/interface-gtk')
-rw-r--r--src/interface-gtk/interface.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/interface-gtk/interface.c b/src/interface-gtk/interface.c
index 58656b8..d8cc7cd 100644
--- a/src/interface-gtk/interface.c
+++ b/src/interface-gtk/interface.c
@@ -36,6 +36,10 @@
#include <gtk/gtk.h>
+#ifdef GDK_WINDOWING_X11
+#include <gtk/gtkx.h>
+#endif
+
#include <gio/gio.h>
#include <Scintilla.h>
@@ -173,6 +177,8 @@ static struct {
teco_string_t info_current;
gboolean no_csd;
+ gint xembed_id;
+
GtkWidget *info_bar_widget;
GtkWidget *info_image;
GtkWidget *info_type_widget;
@@ -217,7 +223,13 @@ teco_interface_init(void)
teco_interface.event_queue = g_queue_new();
+#ifdef GDK_WINDOWING_X11
+ teco_interface.window = teco_interface.xembed_id ? gtk_plug_new(teco_interface.xembed_id)
+ : gtk_window_new(GTK_WINDOW_TOPLEVEL);
+#else
teco_interface.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+#endif
+
g_signal_connect(teco_interface.window, "delete-event",
G_CALLBACK(teco_interface_window_delete_cb), NULL);
@@ -262,7 +274,7 @@ teco_interface_init(void)
"type-label");
gtk_header_bar_pack_start(GTK_HEADER_BAR(teco_interface.info_bar_widget),
teco_interface.info_type_widget);
- if (teco_interface.no_csd) {
+ if (teco_interface.xembed_id || teco_interface.no_csd) {
/* fall back to adding the info bar as an ordinary widget */
gtk_box_pack_start(GTK_BOX(vbox), teco_interface.info_bar_widget,
FALSE, FALSE, 0);
@@ -369,6 +381,11 @@ teco_interface_get_options(void)
{"no-csd", 0, G_OPTION_FLAG_IN_MAIN,
G_OPTION_ARG_NONE, &teco_interface.no_csd,
"Disable client-side decorations.", NULL},
+#ifdef GDK_WINDOWING_X11
+ {"xembed", 0, G_OPTION_FLAG_IN_MAIN,
+ G_OPTION_ARG_INT, &teco_interface.xembed_id,
+ "Embed into an existing X11 Window.", "ID"},
+#endif
{NULL}
};