make icon setting configurable
authorDieter Plaetinck <dieter@plaetinck.be>
Sun, 7 Jun 2009 18:28:35 +0000 (20:28 +0200)
committerDieter Plaetinck <dieter@plaetinck.be>
Sun, 7 Jun 2009 18:28:35 +0000 (20:28 +0200)
examples/configs/sampleconfig
examples/configs/sampleconfig-dev
uzbl.c
uzbl.h

index 5daa21c..736b49f 100644 (file)
@@ -119,6 +119,7 @@ bind    fl* = script /usr/share/uzbl/examples/scripts/follow_Numbers.js %s
 # using strings, not polished yet:
 bind    fL* = script /usr/share/uzbl/examples/scripts/follow_Numbers_Strings.js %s
 
+set icon = /usr/share/uzbl/uzbl.png
 
 # "home" page if you will
 set uri = uzbl.org
index 03310b4..0aa0985 100644 (file)
@@ -171,5 +171,7 @@ bind    fL* = script ./examples/scripts/follow_Numbers_Strings.js %s
 # you can use this to disable all plugins
 set disable_plugins = 0
 
+set icon = ./uzbl.png
+
 # "home" page if you will
 set uri = uzbl.org
diff --git a/uzbl.c b/uzbl.c
index 35a50fc..7b810dc 100644 (file)
--- a/uzbl.c
+++ b/uzbl.c
@@ -114,6 +114,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)},
@@ -1312,6 +1313,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);
@@ -2038,15 +2049,11 @@ create_mainbar () {
 static
 GtkWidget* create_window () {
     GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-    gchar* uzbl_icon = find_xdg_file(1, "/uzbl/uzbl.png");
     gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
     gtk_widget_set_name (window, "Uzbl browser");
-    gtk_window_set_icon_from_file (GTK_WINDOW (window), uzbl_icon, NULL);
     g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy_cb), NULL);
     g_signal_connect (G_OBJECT (window), "key-press-event", G_CALLBACK (key_press_cb), NULL);
 
-    g_free (uzbl_icon);
-
     return window;
 }
 
diff --git a/uzbl.h b/uzbl.h
index a6a3a6e..2e7ccf9 100644 (file)
--- a/uzbl.h
+++ b/uzbl.h
@@ -77,6 +77,7 @@ typedef struct {
     GtkAdjustment* bar_h; // and scrolling position
     WebKitWebView* web_view;
     gchar*         main_title;
+    gchar*         icon;
 
     /* WebInspector */
     GtkWidget *inspector_window;
@@ -461,6 +462,9 @@ static void
 set_proxy_url();
 
 static void
+set_icon();
+
+static void
 cmd_cookie_handler();
 
 static void