Merge with Dieterbe/experimental
authoruranther <jwheaton@purdue.edu>
Mon, 13 Jul 2009 12:45:15 +0000 (08:45 -0400)
committeruranther <jwheaton@purdue.edu>
Mon, 13 Jul 2009 12:45:15 +0000 (08:45 -0400)
1  2 
README
uzbl.c
uzbl.h

diff --cc README
--- 1/README
--- 2/README
+++ b/README
@@@ -307,5 -309,14 +309,8 @@@ Custom, userdefined scripts (`spawn fo
      --help                   Help
  
  
  ### BUGS
 -known bugs:
 -
 -* Segfaults when using zoom commands (happens when max zoom already reached?).
 -
  Please report new issues @ uzbl.org/bugs
 -
 -
diff --cc uzbl.c
--- 1/uzbl.c
--- 2/uzbl.c
+++ b/uzbl.c
@@@ -436,10 -439,9 +439,10 @@@ clean_up(void) 
      g_string_free(uzbl.state.keycmd, TRUE);
      g_hash_table_destroy(uzbl.bindings);
      g_hash_table_destroy(uzbl.behave.commands);
 +    g_scanner_destroy(uzbl.scan);
  }
  
- /* used for html_mode_timeout 
+ /* used for html_mode_timeout
   * be sure to extend this function to use
   * more timers if needed in other places
  */
@@@ -489,11 -491,11 +492,11 @@@ new_window_cb (WebKitWebView *web_view
      const gchar* uri = webkit_network_request_get_uri (request);
      if (uzbl.state.verbose)
          printf("New window requested -> %s \n", uri);
-     new_window_load_uri(uri);
-     return (FALSE);
+     webkit_web_policy_decision_use(policy_decision);
+     return TRUE;
  }
  
 -static gboolean
 +gboolean
  mime_policy_cb(WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, gchar *mime_type,  WebKitWebPolicyDecision *policy_decision, gpointer user_data) {
      (void) frame;
      (void) request;
@@@ -1047,8 -1048,14 +1050,14 @@@ dehilight (WebKitWebView *page, GArray 
  }
  
  
 -static void
 +void
  new_window_load_uri (const gchar * uri) {
+     if (uzbl.behave.new_window) {
+         GString *s = g_string_new ("");
+         g_string_printf(s, "'%s'", uri);
+         run_handler(uzbl.behave.new_window, s->str);
+         return;
+     }
      GString* to_execute = g_string_new ("");
      g_string_append_printf (to_execute, "%s --uri '%s'", uzbl.state.executable_path, uri);
      int i;
@@@ -1071,11 -1078,10 +1080,11 @@@ chain (WebKitWebView *page, GArray *arg
      (void) page; (void) result;
      gchar *a = NULL;
      gchar **parts = NULL;
-     guint i = 0;    
+     guint i = 0;
      while ((a = argv_idx(argv, i++))) {
          parts = g_strsplit (a, " ", 2);
 -        parse_command(parts[0], parts[1], result);
 +        if (parts[0])
 +          parse_command(parts[0], parts[1], result);
          g_strfreev (parts);
      }
  }
@@@ -1456,10 -1458,10 +1465,10 @@@ spawn(WebKitWebView *web_view, GArray *
          run_command(argv_idx(argv, 0), 0, ((const gchar **) (argv->data + sizeof(gchar*))), FALSE, NULL);
  }
  
 -static void
 +void
  spawn_sync(WebKitWebView *web_view, GArray *argv, GString *result) {
      (void)web_view; (void)result;
-     
      if (argv_idx(argv, 0))
          run_command(argv_idx(argv, 0), 0, ((const gchar **) (argv->data + sizeof(gchar*))),
                      TRUE, &uzbl.comm.sync_stdout);
@@@ -1636,9 -1638,9 +1645,9 @@@ cmd_zoom_level() 
      webkit_web_view_set_zoom_level (uzbl.gui.web_view, uzbl.behave.zoom_level);
  }
  
 -static void
 +void
  cmd_disable_plugins() {
-     g_object_set (G_OBJECT(view_settings()), "enable-plugins", 
+     g_object_set (G_OBJECT(view_settings()), "enable-plugins",
              !uzbl.behave.disable_plugins, NULL);
  }
  
@@@ -1728,7 -1730,20 +1737,20 @@@ cmd_cookie_handler() 
      g_strfreev (split);
  }
  
 -static void
 +void
+ cmd_new_window() {
+     gchar **split = g_strsplit(uzbl.behave.new_window, " ", 2);
+     /* pitfall: doesn't handle chain actions; must the sync_ action manually */
+     if ((g_strcmp0(split[0], "sh") == 0) ||
+         (g_strcmp0(split[0], "spawn") == 0)) {
+         g_free (uzbl.behave.new_window);
+         uzbl.behave.new_window =
+             g_strdup_printf("%s %s", split[0], split[1]);
+     }
+     g_strfreev (split);
+ }
 -static void
++void
  cmd_fifo_dir() {
      uzbl.behave.fifo_dir = init_fifo(uzbl.behave.fifo_dir);
  }
diff --cc uzbl.h
--- 1/uzbl.h
--- 2/uzbl.h
+++ b/uzbl.h
@@@ -479,34 -479,37 +481,37 @@@ typedef struct 
  } CommandInfo;
  
  /* Command callbacks */
 -static void
 +void
  cmd_load_uri();
  
 -static void
 +void
  cmd_set_status();
  
 -static void
 +void
  set_proxy_url();
  
 -static void
 +void
  set_icon();
  
 -static void
 +void
  cmd_cookie_handler();
  
 -static void
 +void
+ cmd_new_window();
 -static void
++void
  move_statusbar();
  
 -static void
 +void
  cmd_always_insert_mode();
  
 -static void
 +void
  cmd_http_debug();
  
 -static void
 +void
  cmd_max_conns();
  
 -static void
 +void
  cmd_max_conns_host();
  
  /* exported WebKitWebSettings properties */