summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hofmann <scm@uninformativ.de>2017-01-29 08:30:33 +0100
committerPeter Hofmann <scm@uninformativ.de>2017-01-29 09:20:27 +0100
commit6a745e09a86de6e9bd8abc3b8364e9e3f3ab52b7 (patch)
tree594847ede23d342f50b6ee566f90a4422624a577
parent364efc6f229f0fb5d743ed24a6617af4499347f8 (diff)
downloadlariza-6a745e09a86de6e9bd8abc3b8364e9e3f3ab52b7.tar.gz
Wait for "ready-to-show" signal after a "create" signal
CC #28.
-rw-r--r--browser.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/browser.c b/browser.c
index 05e74e2..c32f5fb 100644
--- a/browser.c
+++ b/browser.c
@@ -15,7 +15,7 @@
static void client_destroy(GtkWidget *, gpointer);
static gboolean client_destroy_request(WebKitWebView *, gpointer);
-static WebKitWebView *client_new(const gchar *);
+static WebKitWebView *client_new(const gchar *, gboolean);
static WebKitWebView *client_new_request(WebKitWebView *, WebKitNavigationAction *,
gpointer);
static void cooperation_setup(void);
@@ -44,6 +44,7 @@ static gboolean menu_web_view(WebKitWebView *, WebKitContextMenu *, GdkEvent *,
WebKitHitTestResult *, gpointer);
static gboolean remote_msg(GIOChannel *, GIOCondition, gpointer);
static void search(gpointer, gint);
+static void show_web_view(WebKitWebView *, gpointer);
static Window tabbed_launch(void);
static void trust_user_certs(WebKitWebContext *);
@@ -112,7 +113,7 @@ client_destroy_request(WebKitWebView *web_view, gpointer data)
}
WebKitWebView *
-client_new(const gchar *uri)
+client_new(const gchar *uri, gboolean show)
{
struct Client *c;
WebKitWebContext *wc;
@@ -217,8 +218,11 @@ client_new(const gchar *uri)
gtk_container_add(GTK_CONTAINER(c->win), c->vbox);
- gtk_widget_grab_focus(c->web_view);
- gtk_widget_show_all(c->win);
+ if (show)
+ show_web_view(NULL, c);
+ else
+ g_signal_connect(G_OBJECT(c->web_view), "ready-to-show",
+ G_CALLBACK(show_web_view), c);
if (uri != NULL)
{
@@ -236,7 +240,7 @@ WebKitWebView *
client_new_request(WebKitWebView *web_view,
WebKitNavigationAction *navigation_action, gpointer data)
{
- return client_new(NULL);
+ return client_new(NULL, FALSE);
}
void
@@ -725,7 +729,7 @@ key_web_view(GtkWidget *widget, GdkEvent *event, gpointer data)
return TRUE;
case GDK_KEY_e: /* new tab (left hand) */
f = ensure_uri_scheme(home_uri);
- client_new(f);
+ client_new(f, TRUE);
g_free(f);
return TRUE;
case GDK_KEY_r: /* reload (left hand) */
@@ -787,7 +791,7 @@ key_web_view(GtkWidget *widget, GdkEvent *event, gpointer data)
case 2:
if (c->hover_uri != NULL)
{
- client_new(c->hover_uri);
+ client_new(c->hover_uri, TRUE);
return TRUE;
}
break;
@@ -920,7 +924,7 @@ remote_msg(GIOChannel *channel, GIOCondition condition, gpointer data)
if (uri)
{
g_strstrip(uri);
- client_new(uri);
+ client_new(uri, TRUE);
g_free(uri);
}
return TRUE;
@@ -953,6 +957,17 @@ search(gpointer data, gint direction)
}
}
+void
+show_web_view(WebKitWebView *web_view, gpointer data)
+{
+ struct Client *c = (struct Client *)data;
+
+ (void)web_view;
+
+ gtk_widget_grab_focus(c->web_view);
+ gtk_widget_show_all(c->win);
+}
+
Window
tabbed_launch(void)
{
@@ -1069,11 +1084,11 @@ main(int argc, char **argv)
}
if (optind >= argc)
- client_new(home_uri);
+ client_new(home_uri, TRUE);
else
{
for (i = optind; i < argc; i++)
- client_new(argv[i]);
+ client_new(argv[i], TRUE);
}
if (!cooperative_instances || cooperative_alone)