aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--uzbl.c41
-rw-r--r--uzbl.h7
2 files changed, 38 insertions, 10 deletions
diff --git a/uzbl.c b/uzbl.c
index 7b810dc..a18c7d5 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -73,6 +73,8 @@ GOptionEntry entries[] =
"Name of the current instance (defaults to Xorg window id)", "NAME" },
{ "config", 'c', 0, G_OPTION_ARG_STRING, &uzbl.state.config_file,
"Config file (this is pretty much equivalent to uzbl < FILE )", "FILE" },
+ { "socket", 's', 0, G_OPTION_ARG_INT, &uzbl.state.socket_id,
+ "Socket ID", "SOCKET" },
{ NULL, 0, 0, 0, NULL, NULL, NULL }
};
@@ -1865,7 +1867,8 @@ update_title (void) {
if (b->show_status) {
if (b->title_format_short) {
parsed = expand_template(b->title_format_short, FALSE);
- gtk_window_set_title (GTK_WINDOW(uzbl.gui.main_window), parsed);
+ if (uzbl.gui.main_window)
+ gtk_window_set_title (GTK_WINDOW(uzbl.gui.main_window), parsed);
g_free(parsed);
}
if (b->status_format) {
@@ -1877,12 +1880,14 @@ update_title (void) {
GdkColor color;
gdk_color_parse (b->status_background, &color);
//labels and hboxes do not draw their own background. applying this on the window is ok as we the statusbar is the only affected widget. (if not, we could also use GtkEventBox)
- gtk_widget_modify_bg (uzbl.gui.main_window, GTK_STATE_NORMAL, &color);
+ if (uzbl.gui.main_window)
+ gtk_widget_modify_bg (uzbl.gui.main_window, GTK_STATE_NORMAL, &color);
}
} else {
if (b->title_format_long) {
parsed = expand_template(b->title_format_long, FALSE);
- gtk_window_set_title (GTK_WINDOW(uzbl.gui.main_window), parsed);
+ if (uzbl.gui.main_window)
+ gtk_window_set_title (GTK_WINDOW(uzbl.gui.main_window), parsed);
g_free(parsed);
}
}
@@ -2057,6 +2062,16 @@ GtkWidget* create_window () {
return window;
}
+static
+GtkPlug* create_plug () {
+ GtkPlug* plug = GTK_PLUG (gtk_plug_new (uzbl.state.socket_id));
+ g_signal_connect (G_OBJECT (plug), "destroy", G_CALLBACK (destroy_cb), NULL);
+ g_signal_connect (G_OBJECT (plug), "key-press-event", G_CALLBACK (key_press_cb), NULL);
+
+ return plug;
+}
+
+
static gchar**
inject_handler_args(const gchar *actname, const gchar *origargs, const gchar *newargs) {
/*
@@ -2485,17 +2500,25 @@ main (int argc, char* argv[]) {
gtk_box_pack_start (GTK_BOX (uzbl.gui.vbox), uzbl.gui.scrolled_win, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (uzbl.gui.vbox), uzbl.gui.mainbar, FALSE, TRUE, 0);
- uzbl.gui.main_window = create_window ();
- gtk_container_add (GTK_CONTAINER (uzbl.gui.main_window), uzbl.gui.vbox);
-
+ if (uzbl.state.socket_id) {
+ uzbl.gui.plug = create_plug ();
+ gtk_container_add (GTK_CONTAINER (uzbl.gui.plug), uzbl.gui.vbox);
+ gtk_widget_show_all (GTK_WIDGET (uzbl.gui.plug));
+ } else {
+ uzbl.gui.main_window = create_window ();
+ gtk_container_add (GTK_CONTAINER (uzbl.gui.main_window), uzbl.gui.vbox);
+ gtk_widget_show_all (uzbl.gui.main_window);
+ uzbl.xwin = GDK_WINDOW_XID (GTK_WIDGET (uzbl.gui.main_window)->window);
+ }
gtk_widget_grab_focus (GTK_WIDGET (uzbl.gui.web_view));
- gtk_widget_show_all (uzbl.gui.main_window);
- uzbl.xwin = GDK_WINDOW_XID (GTK_WIDGET (uzbl.gui.main_window)->window);
if (uzbl.state.verbose) {
printf("Uzbl start location: %s\n", argv[0]);
- printf("window_id %i\n",(int) uzbl.xwin);
+ if (uzbl.state.socket_id)
+ printf("plug_id %i\n", gtk_plug_get_id(uzbl.gui.plug));
+ else
+ printf("window_id %i\n",(int) uzbl.xwin);
printf("pid %i\n", getpid ());
printf("name: %s\n", uzbl.state.instance_name);
}
diff --git a/uzbl.h b/uzbl.h
index 2e7ccf9..27293f9 100644
--- a/uzbl.h
+++ b/uzbl.h
@@ -67,6 +67,7 @@ typedef struct {
/* gui elements */
typedef struct {
GtkWidget* main_window;
+ GtkPlug* plug;
GtkWidget* scrolled_win;
GtkWidget* vbox;
GtkWidget* mainbar;
@@ -102,7 +103,8 @@ typedef struct {
typedef struct {
gchar *uri;
gchar *config_file;
- char *instance_name;
+ int socket_id;
+ char *instance_name;
gchar *selected_url;
gchar *executable_path;
GString* keycmd;
@@ -386,6 +388,9 @@ create_mainbar ();
static
GtkWidget* create_window ();
+static
+GtkPlug* create_plug ();
+
static void
run_handler (const gchar *act, const gchar *args);