fix conditional xembed compilation
authorRaphael Gosselin <raphgoss69@gmail.com>
Wed, 12 Feb 2020 23:01:38 +0000 (18:01 -0500)
committerRaphael Gosselin <raphgoss69@gmail.com>
Wed, 12 Feb 2020 23:01:38 +0000 (18:01 -0500)
doc/vimb.1
src/config.def.h
src/main.c
src/main.h

index 5d70b0f..9305f45 100644 (file)
@@ -960,7 +960,7 @@ Contains the pid of the running Vimb instance.
 .TP
 .B VIMB_XID
 Holds the X-Window id of the Vimb window or of the embedding window if Vimb is
-started with the -e option.
+compiled with XEMBED and started with the -e option.
 .EE
 .RE
 .TP
index 5d36c4b..3cfe23a 100644 (file)
@@ -26,6 +26,8 @@
 #define FEATURE_TITLE_IN_COMPLETION
 /* enable the read it later queue */
 #define FEATURE_QUEUE
+/* disable X window embedding */
+//#define FEATURE_NO_XEMBED
 
 #ifdef FEATURE_WGET_PROGRESS_BAR
 /* chars to use for the progressbar */
index e0313a1..9fdae1a 100644 (file)
  * along with this program. If not, see http://www.gnu.org/licenses/.
  */
 
-#include <gdk/gdkx.h>
+#include "config.h"
 #include <gtk/gtk.h>
+#ifndef FEATURE_NO_XEMBED
+#include <gdk/gdkx.h>
 #include <gtk/gtkx.h>
+#endif
 #include <libsoup/soup.h>
 #include <limits.h>
 #include <stdlib.h>
@@ -32,7 +35,6 @@
 #include "ascii.h"
 #include "command.h"
 #include "completion.h"
-#include "config.h"
 #include "ex.h"
 #include "ext-proxy.h"
 #include "handler.h"
@@ -767,7 +769,9 @@ static Client *client_new(WebKitWebView *webview)
 static void client_show(WebKitWebView *webview, Client *c)
 {
     GtkWidget *box;
+#ifndef FEATURE_NO_XEMBED
     char *xid;
+#endif
 
     c->window = create_window(c);
 
@@ -817,6 +821,7 @@ static void client_show(WebKitWebView *webview, Client *c)
     setting_init(c);
 
     gtk_widget_show_all(c->window);
+#ifndef FEATURE_NO_XEMBED
     if (vb.embed) {
         xid = g_strdup_printf("%d", (int)vb.embed);
     } else {
@@ -826,6 +831,7 @@ static void client_show(WebKitWebView *webview, Client *c)
     /* set the x window id to env */
     g_setenv("VIMB_XID", xid, TRUE);
     g_free(xid);
+#endif
 
     /* start client in normal mode */
     vb_enter(c, 'n');
@@ -840,16 +846,20 @@ static GtkWidget *create_window(Client *c)
 {
     GtkWidget *window;
 
+#ifndef FEATURE_NO_XEMBED
     if (vb.embed) {
         window = gtk_plug_new(vb.embed);
     } else {
+#endif
         window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
         gtk_window_set_role(GTK_WINDOW(window), PROJECT_UCFIRST);
         gtk_window_set_default_size(GTK_WINDOW(window), WIN_WIDTH, WIN_HEIGHT);
         if (!vb.no_maximize) {
             gtk_window_maximize(GTK_WINDOW(window));
         }
+#ifndef FEATURE_NO_XEMBED
     }
+#endif
 
     g_object_connect(
             G_OBJECT(window),
@@ -2105,13 +2115,18 @@ int main(int argc, char* argv[])
 {
     Client *c;
     GError *err = NULL;
-    char *pidstr, *winid = NULL;
+    char *pidstr;
+#ifndef FEATURE_NO_XEMBED
+    char *winid = NULL;
+#endif
     gboolean ver = FALSE, buginfo = FALSE;
 
     GOptionEntry opts[] = {
         {"cmd", 'C', 0, G_OPTION_ARG_CALLBACK, (GOptionArgFunc*)autocmdOptionArgFunc, "Ex command run before first page is loaded", NULL},
         {"config", 'c', 0, G_OPTION_ARG_FILENAME, &vb.configfile, "Custom configuration file", NULL},
+#ifndef FEATURE_NO_XEMBED
         {"embed", 'e', 0, G_OPTION_ARG_STRING, &winid, "Reparents to window specified by xid", NULL},
+#endif
         {"incognito", 'i', 0, G_OPTION_ARG_NONE, &vb.incognito, "Run with user data read-only", NULL},
         {"profile", 'p', 0, G_OPTION_ARG_CALLBACK, (GOptionArgFunc*)profileOptionArgFunc, "Profile name", NULL},
         {"version", 'v', 0, G_OPTION_ARG_NONE, &ver, "Print version", NULL},
@@ -2175,9 +2190,11 @@ int main(int argc, char* argv[])
 
     vimb_setup();
 
+#ifndef FEATURE_NO_XEMBED
     if (winid) {
         vb.embed = strtol(winid, NULL, 0);
     }
+#endif
 
     c = client_new(NULL);
     client_show(NULL, c);
index dee3f77..1c04e3a 100644 (file)
 #define _MAIN_H
 
 #include <fcntl.h>
+#include "config.h"
+#ifndef FEATURE_NO_XEMBED
 #include <gtk/gtkx.h>
+#endif
 #include <stdio.h>
 #include <webkit2/webkit2.h>
 #include "shortcut.h"
 #include "handler.h"
 #include "file-storage.h"
 
-#include "config.h"
 
 #define LENGTH(x) (sizeof x / sizeof x[0])
 #define OVERWRITE_STRING(t, s) {if (t) g_free(t); t = g_strdup(s);}
@@ -271,7 +273,9 @@ struct Client {
 struct Vimb {
     char        *argv0;
     Client      *clients;
+#ifndef FEATURE_NO_XEMBED
     Window      embed;
+#endif
     GHashTable  *modes;             /* all available browser main modes */
     char        *configfile;        /* config file given as option on startup */
     char        *files[FILES_LAST];