Merge commit 'Dieterbe/experimental' into experimental
authorTom Adams <tom@holizz.com>
Sun, 7 Jun 2009 18:54:23 +0000 (19:54 +0100)
committerTom Adams <tom@holizz.com>
Sun, 7 Jun 2009 18:54:23 +0000 (19:54 +0100)
Conflicts:
uzbl.c

1  2 
uzbl.c
uzbl.h

diff --combined uzbl.c
--- 1/uzbl.c
--- 2/uzbl.c
+++ b/uzbl.c
@@@ -73,8 -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 }
  };
  
@@@ -116,6 -114,7 +116,7 @@@ const struct 
      { "command_indicator",   PTR(uzbl.behave.cmd_indicator,       STR,  1,   update_title)},
      { "title_format_long",   PTR(uzbl.behave.title_format_long,   STR,  1,   update_title)},
      { "title_format_short",  PTR(uzbl.behave.title_format_short,  STR,  1,   update_title)},
+     { "icon",                PTR(uzbl.gui.icon,                   STR,  1,   set_icon)},
      { "insert_mode",         PTR(uzbl.behave.insert_mode,         INT,  1,   NULL)},
      { "always_insert_mode",  PTR(uzbl.behave.always_insert_mode,  INT,  1,   cmd_always_insert_mode)},
      { "reset_command_mode",  PTR(uzbl.behave.reset_command_mode,  INT,  1,   NULL)},
@@@ -1314,6 -1313,16 +1315,16 @@@ set_proxy_url() 
  }
  
  static void
+ set_icon() {
+     if(file_exists(uzbl.gui.icon)) {
+         gtk_window_set_icon_from_file (GTK_WINDOW (uzbl.gui.main_window), uzbl.gui.icon, NULL);
+     } else {
+         g_printerr ("Icon \"%s\" not found. ignoring.\n", uzbl.gui.icon);
+     }
+     g_free (uzbl.gui.icon);
+ }
+ static void
  cmd_load_uri() {
      GArray *a = g_array_new (TRUE, FALSE, sizeof(gchar*));
      g_array_append_val (a, uzbl.state.uri);
@@@ -1856,8 -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) {
              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);
          }
      }
@@@ -2051,16 -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) {
      /*
@@@ -2185,8 -2181,7 +2196,7 @@@ static gchar
  get_xdg_var (XDG_Var xdg) {
      const gchar* actual_value = getenv (xdg.environmental);
      const gchar* home         = getenv ("HOME");
-     gchar* return_value = str_replace ("~", home, actual_value);
+     gchar* return_value;
  
      if (! actual_value || strcmp (actual_value, "") == 0) {
          if (xdg.default_value) {
          } else {
              return_value = NULL;
          }
+     } else {
+         return_value = str_replace("~", home, actual_value);
      }
      return return_value;
  }
  
@@@ -2361,7 -2359,7 +2374,7 @@@ inspector_attach_window_cb (WebKitWebIn
  }
  
  static gboolean
- inspector_dettach_window_cb (WebKitWebInspector* inspector){
+ inspector_detach_window_cb (WebKitWebInspector* inspector){
      (void) inspector;
      return FALSE;
  }
@@@ -2389,10 -2387,8 +2402,8 @@@ set_up_inspector() 
      g_signal_connect (G_OBJECT (g->inspector), "show-window", G_CALLBACK (inspector_show_window_cb), NULL);
      g_signal_connect (G_OBJECT (g->inspector), "close-window", G_CALLBACK (inspector_close_window_cb), NULL);
      g_signal_connect (G_OBJECT (g->inspector), "attach-window", G_CALLBACK (inspector_attach_window_cb), NULL);
-     if (uzbl.gui.main_window) {
-         g_signal_connect (G_OBJECT (g->inspector), "dettach-window", G_CALLBACK (inspector_dettach_window_cb), NULL);
-         g_signal_connect (G_OBJECT (g->inspector), "destroy", G_CALLBACK (inspector_inspector_destroyed_cb), NULL);
-     }
+     g_signal_connect (G_OBJECT (g->inspector), "detach-window", G_CALLBACK (inspector_detach_window_cb), NULL);
+     g_signal_connect (G_OBJECT (g->inspector), "finished", G_CALLBACK (inspector_inspector_destroyed_cb), NULL);
  
      g_signal_connect (G_OBJECT (g->inspector), "notify::inspected-uri", G_CALLBACK (inspector_uri_changed_cb), NULL);
  }
@@@ -2489,25 -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));
  
      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 --combined uzbl.h
--- 1/uzbl.h
--- 2/uzbl.h
+++ b/uzbl.h
@@@ -67,7 -67,6 +67,7 @@@ typedef struct 
  /* gui elements */
  typedef struct {
      GtkWidget*     main_window;
 +    GtkPlug*       plug;
      GtkWidget*     scrolled_win;
      GtkWidget*     vbox;
      GtkWidget*     mainbar;
@@@ -78,6 -77,7 +78,7 @@@
      GtkAdjustment* bar_h; // and scrolling position
      WebKitWebView* web_view;
      gchar*         main_title;
+     gchar*         icon;
  
      /* WebInspector */
      GtkWidget *inspector_window;
@@@ -102,8 -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;
@@@ -387,9 -386,6 +388,9 @@@ create_mainbar ()
  static
  GtkWidget* create_window ();
  
 +static
 +GtkPlug* create_plug ();
 +
  static void
  run_handler (const gchar *act, const gchar *args);
  
@@@ -466,6 -462,9 +467,9 @@@ static voi
  set_proxy_url();
  
  static void
+ set_icon();
+ static void
  cmd_cookie_handler();
  
  static void