merge in uranthers zoomlevel thingie. doesnt work yet because of strof not recognized...
authorDieter Plaetinck <dieter@plaetinck.be>
Tue, 2 Jun 2009 20:52:12 +0000 (22:52 +0200)
committerDieter Plaetinck <dieter@plaetinck.be>
Tue, 2 Jun 2009 20:52:12 +0000 (22:52 +0200)
1  2 
AUTHORS
examples/configs/sampleconfig
examples/configs/sampleconfig-dev
uzbl.c
uzbl.h

diff --combined AUTHORS
+++ b/AUTHORS
@@@ -18,7 -18,6 +18,8 @@@ Contributors
      Sylvester Johansson (scj) - form filler script & different take on link follower 
      (mxf) - uzblcat
      Mark Nevill - misc patches
 +    Uli Schlachter (psychon) - basic mime_policy_cb & Makefile patch
++    (uranther) - zoom level
  
  Originaly based on http://trac.webkit.org/browser/trunk/WebKitTools/GtkLauncher/main.c
  Which is  copyrighted:
@@@ -11,7 -11,7 +11,7 @@@
  # You can use any command in place of spawn
  set history_handler  = spawn /usr/share/uzbl/examples/scripts/history.sh
  set download_handler = spawn /usr/share/uzbl/examples/scripts/download.sh
 -#set cookie_handler   = spawn /usr/share/uzbl/examples/scripts/cookies.sh
 +set cookie_handler   = spawn /usr/share/uzbl/examples/scripts/cookies.sh
  
  set minimum_font_size = 6
  set font_size = 11
@@@ -69,6 -69,7 +69,7 @@@ bind    r         = reloa
  bind    R         = reload_ign_cache
  bind    +         = zoom_in
  bind    -         = zoom_out
+ bind    0         = sh "echo set zoom_level = 1.0 > $4"
  bind    t         = toggle_status
  # Hilight matches. Notice the * after the slash - it makes the command incremental, i.e. gets called
  # on every character you type.  You can do `bind /_ = search %s' if you want it less interactive.
@@@ -11,7 -11,7 +11,7 @@@
  # Usually you want to spawn a script to handle things, but any command (such as sh) can be used
  set history_handler  = spawn ./examples/scripts/history.sh
  set download_handler = spawn ./examples/scripts/download.sh
 -#set cookie_handler   = spawn ./examples/scripts/cookies.sh
 +set cookie_handler   = spawn ./examples/scripts/cookies.sh
  
  set minimum_font_size = 6
  set font_size = 11
@@@ -104,6 -104,6 +104,7 @@@ bind    r         = reloa
  bind    R         = reload_ign_cache
  bind    +         = zoom_in
  bind    -         = zoom_out
++bind    0         = sh "echo set zoom_level = 1.0 > $4"
  bind    t         = toggle_status
  # Hilight matches. Notice the * after the slash - it makes the command incremental, i.e. gets called
  # on every character you type.  You can do `bind /_ = search %s' if you want it less interactive.
diff --combined uzbl.c
--- 1/uzbl.c
--- 2/uzbl.c
+++ b/uzbl.c
@@@ -1,6 -1,6 +1,6 @@@
  /* -*- c-basic-offset: 4; -*- */
 -/* Original code taken from the example webkit-gtk+ application. see notice below. */
 -/* Modified code is licensed under the GPL 3.  See LICENSE file. */
 +// Original code taken from the example webkit-gtk+ application. see notice below.
 +// Modified code is licensed under the GPL 3.  See LICENSE file.
  
  
  /*
  #include <gtk/gtk.h>
  #include <gdk/gdkx.h>
  #include <gdk/gdkkeysyms.h>
 -
 -#include <sys/types.h>
  #include <sys/socket.h>
  #include <sys/stat.h>
 +#include <sys/types.h>
 +#include <sys/un.h>
  #include <sys/utsname.h>
  #include <sys/time.h>
 -#include <sys/un.h>
 -
  #include <webkit/webkit.h>
+ #include <libsoup/soup.h>
  #include <stdio.h>
  #include <string.h>
  #include <unistd.h>
  #include <stdlib.h>
  #include <errno.h>
- #include <string.h>
  #include <fcntl.h>
- #include <sys/socket.h>
- #include <sys/un.h>
- #include <libsoup/soup.h>
  #include <signal.h>
  #include "uzbl.h"
  #include "config.h"
@@@ -85,7 -85,7 +83,7 @@@ typedef const struct 
      void (*func)(void);
  } uzbl_cmdprop;
  
- enum {TYPE_INT, TYPE_STR};
+ enum {TYPE_INT, TYPE_STR, TYPE_FLOAT};
  
  /* an abbreviation to help keep the table's width humane */
  #define PTR(var, t, d, fun) { .ptr = (void*)&(var), .type = TYPE_##t, .dump = d, .func = fun }
@@@ -133,7 -133,8 +131,8 @@@ const struct 
      { "max_conns",           PTR(uzbl.net.max_conns,              INT,  1,   cmd_max_conns)},
      { "max_conns_host",      PTR(uzbl.net.max_conns_host,         INT,  1,   cmd_max_conns_host)},
      { "useragent",           PTR(uzbl.net.useragent,              STR,  1,   cmd_useragent)},
-     /* exported WebKitWebSettings properties*/
+     /* exported WebKitWebSettings properties */
+     { "zoom_level",          PTR(uzbl.behave.zoom_level,          FLOAT,1,   cmd_zoom_level)},
      { "font_size",           PTR(uzbl.behave.font_size,           INT,  1,   cmd_font_size)},
      { "monospace_size",      PTR(uzbl.behave.monospace_size,      INT,  1,   cmd_font_size)},
      { "minimum_font_size",   PTR(uzbl.behave.minimum_font_size,   INT,  1,   cmd_minimum_font_size)},
@@@ -392,23 -393,6 +391,23 @@@ new_window_cb (WebKitWebView *web_view
      return (FALSE);
  }
  
 +static gboolean
 +mime_policy_cb(WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, gchar *mime_type,  WebKitWebPolicyDecision *policy_decision, gpointer user_data) {
 +    (void) frame;
 +    (void) request;
 +    (void) user_data;
 +
 +    /* If we can display it, let's display it... */
 +    if (webkit_web_view_can_show_mime_type (web_view, mime_type)) {
 +        webkit_web_policy_decision_use (policy_decision);
 +        return TRUE;
 +    }
 +
 +    /* ...everything we can't displayed is downloaded */
 +    webkit_web_policy_decision_download (policy_decision);
 +    return TRUE;
 +}
 +
  WebKitWebView*
  create_web_view_cb (WebKitWebView  *web_view, WebKitWebFrame *frame, gpointer user_data) {
      (void) web_view;
@@@ -599,7 -583,6 +598,6 @@@ VIEWFUNC(go_forward
  #undef VIEWFUNC
  
  /* -- command to callback/function map for things we cannot attach to any signals */
- // TODO: reload
  static struct {char *name; Command command[2];} cmdlist[] =
  {   /* key                   function      no_split      */
      { "back",               {view_go_back, 0}              },
@@@ -969,7 -952,7 +967,7 @@@ expand_template(const char *template, g
           token = g_scanner_get_next_token(uzbl.scan);
  
           if(token == G_TOKEN_SYMBOL) {
 -             sym = (int)g_scanner_cur_value(uzbl.scan).v_symbol;
 +             sym = GPOINTER_TO_INT(g_scanner_cur_value(uzbl.scan).v_symbol);
               switch(sym) {
                   case SYM_URI:
                       if(escape_markup) {
@@@ -1368,6 -1351,11 +1366,11 @@@ cmd_font_size() 
  }
  
  static void
+ cmd_zoom_level() {
+     webkit_web_view_set_zoom_level (uzbl.gui.web_view, uzbl.behave.zoom_level);
+ }
+ static void
  cmd_disable_plugins() {
      g_object_set (G_OBJECT(view_settings()), "enable-plugins", 
              !uzbl.behave.disable_plugins, NULL);
@@@ -1541,12 -1529,13 +1544,17 @@@ set_var_value(gchar *name, gchar *val) 
          if (c->type == TYPE_STR) {
              buf = expand_vars(val);
              g_free(*c->ptr);
 -            *c->ptr = g_strdup(val);
 -        } else if (c->type == TYPE_INT) {
 +            *c->ptr = buf;
 +        } else if(c->type == TYPE_INT) {
              int *ip = (int *)c->ptr;
 -            *ip = (int)strtoul(val, &endp, 10);
 +            buf = expand_vars(val);
 +            *ip = (int)strtoul(buf, &endp, 10);
 +            g_free(buf);
+         } else if (c->type == TYPE_FLOAT) {
+             float *fp = (float *)c->ptr;
 -            *fp = strtof(val, &endp);
++            buf = expand_vars(val);
++            *fp = strtof(buf, &endp);
++            g_free(buf);
          }
  
          /* invoke a command specific function */
@@@ -1997,7 -1986,6 +2005,7 @@@ create_browser () 
      g_signal_connect (G_OBJECT (g->web_view), "new-window-policy-decision-requested", G_CALLBACK (new_window_cb), g->web_view);
      g_signal_connect (G_OBJECT (g->web_view), "download-requested", G_CALLBACK (download_cb), g->web_view);
      g_signal_connect (G_OBJECT (g->web_view), "create-web-view", G_CALLBACK (create_web_view_cb), g->web_view);
 +    g_signal_connect (G_OBJECT (g->web_view), "mime-type-policy-decision-requested", G_CALLBACK (mime_policy_cb), g->web_view);
  
      return scrolled_window;
  }
@@@ -2145,8 -2133,6 +2153,8 @@@ add_binding (const gchar *key, const gc
          printf ("Binding %-10s : %s\n", key, act);
      action = new_action(parts[0], parts[1]);
  
 +    if (g_hash_table_remove (uzbl.bindings, key))
 +        g_warning ("Overwriting existing binding for \"%s\"", key);
      g_hash_table_replace(uzbl.bindings, g_strdup(key), action);
      g_strfreev(parts);
  }
diff --combined uzbl.h
--- 1/uzbl.h
--- 2/uzbl.h
+++ b/uzbl.h
@@@ -71,10 -71,10 +71,10 @@@ typedef struct 
      GtkWidget*     vbox;
      GtkWidget*     mainbar;
      GtkWidget*     mainbar_label;
 -    GtkScrollbar*  scbar_v;   /* Horizontal and Vertical Scrollbar */
 -    GtkScrollbar*  scbar_h;   /* (These are still hidden) */
 -    GtkAdjustment* bar_v; /* Information about document length */
 -    GtkAdjustment* bar_h; /* and scrolling position */
 +    GtkScrollbar*  scbar_v;   // Horizontal and Vertical Scrollbar
 +    GtkScrollbar*  scbar_h;   // (These are still hidden)
 +    GtkAdjustment* bar_v; // Information about document length
 +    GtkAdjustment* bar_h; // and scrolling position
      WebKitWebView* web_view;
      gchar*         main_title;
  
@@@ -149,6 -149,7 +149,7 @@@ typedef struct 
      guint    font_size;
      guint    monospace_size;
      guint    minimum_font_size;
+     gfloat   zoom_level;
      guint    disable_plugins;
      guint    disable_scripts;
      guint    autoload_img;    
@@@ -248,9 -249,6 +249,9 @@@ print(WebKitWebView *page, GArray *argv
  static gboolean
  new_window_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision, gpointer user_data);
  
 +static gboolean
 +mime_policy_cb(WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, gchar *mime_type,  WebKitWebPolicyDecision *policy_decision, gpointer user_data);
 +
  WebKitWebView*
  create_web_view_cb (WebKitWebView  *web_view, WebKitWebFrame *frame, gpointer user_data);
  
@@@ -477,10 -475,15 +478,15 @@@ cmd_max_conns()
  static void
  cmd_max_conns_host();
  
+ /* exported WebKitWebSettings properties */
  static void
  cmd_font_size();
  
  static void
+ cmd_zoom_level();
+ static void
  cmd_disable_plugins();
  
  static void