You are not logged in.

#51 2009-04-23 15:29:16

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,000
Website

Re: uzbl. A browser that adheres to the unix philosophy.

dusanx wrote:

Keyboard link following: we all probably have slightly different ideas how following should work. Instead trying to implement them all I would prefer that wrapper can get list of visible links (in text-url pairs) so I can do whatever I want with them from my own wrapper. Let me know if I should explain this.

hmm I understand what you mean.  I like "offloading" where appropriate, but I think following links is not one of them. as human eyes go over a page (eg your reading text or just scanning briefly) you can see a link and want to follow it. Imho it would be bothersome to need to look carefully what the name says, go with your eyes to a different place then, and retype the name you just saw (potentially even needing to go back and forth).  I think the vimperator/konqueror-alike approach would be better here.  Also, for things like history/bookmarks/downloads etc there is some added value by handling it in an extra tool, but I don't see such advantage when doing this with following hyperlinks, which is an process that is only relevant inside the "flow" of browsing.


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#52 2009-04-23 15:35:48

dusanx
Member
Registered: 2008-11-28
Posts: 132

Re: uzbl. A browser that adheres to the unix philosophy.

Dieter@be wrote:
dusanx wrote:

Keyboard link following: we all probably have slightly different ideas how following should work. Instead trying to implement them all I would prefer that wrapper can get list of visible links (in text-url pairs) so I can do whatever I want with them from my own wrapper. Let me know if I should explain this.

hmm I understand what you mean.  I like "offloading" where appropriate, but I think following links is not one of them. as human eyes go over a page (eg your reading text or just scanning briefly) you can see a link and want to follow it. Imho it would be bothersome to need to look carefully what the name says, go with your eyes to a different place then, and retype the name you just saw (potentially even needing to go back and forth).  I think the vimperator/konqueror-alike approach would be better here.  Also, for things like history/bookmarks/downloads etc there is some added value by handling it in an extra tool, but I don't see such advantage when doing this with following hyperlinks, which is an process that is only relevant inside the "flow" of browsing.

I know, I am still considering what would be better. Both vimperator and conkeror have similar approach so that is probably way to go.


Gnome -> Openbox -> Awesome -> XMonad -> dwm .
http://github.com/dusanx/uzbl/

Offline

#53 2009-04-23 15:42:34

yasen
Member
From: Bulgaria
Registered: 2009-03-05
Posts: 39

Re: uzbl. A browser that adheres to the unix philosophy.

Is it hard to access the Webkit JavaScript engine? Many of the higher level functionalities would be better off implemented in JavaScript (like link following, that's how Vimperator does it).

Think of it this way - a bare-bones browser, extensible through JavaScript. Kind of like Emacs+Lisp. Yeah, I know firefox already is extensible with JS, but it's heavy and cumbersome and writing extensions requires a lot of boilerplate code.

With JS you could make your own keyboard shortcuts for all sorts of actions - link following, speed dial, etc.

Edit: Seed? http://live.gnome.org/Seed

You gotta do this. Leave the browser with the absolute minimum functionality but put JS extensibility in it. It would rock people's socks off...

Edit2: OK, ignore me. There's already a browser done with Seed. http://svn.gnome.org/viewvc/seed/trunk/ … s/browser/
Don't reinvent the wheel, go your way smile I'll be sure to track your progress.

Last edited by yasen (2009-04-23 15:50:09)

Offline

#54 2009-04-23 18:44:05

btw0
Member
Registered: 2006-06-25
Posts: 9

Re: uzbl. A browser that adheres to the unix philosophy.

maybe you should consider resource saving daemon/client architecture like urxvtd/urxvtc

Offline

#55 2009-04-23 18:52:12

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: uzbl. A browser that adheres to the unix philosophy.

btw0 wrote:

maybe you should consider resource saving daemon/client architecture like urxvtd/urxvtc

I think this would be a great idea if tabs were not implemented.


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#56 2009-04-23 18:52:46

Wra!th
Member
Registered: 2009-03-31
Posts: 342

Re: uzbl. A browser that adheres to the unix philosophy.

I added argument checking ( a bit hackish but it works ok)
By default it runs with the UI I added (close, back, forward, address entry, load button)
You can pass --minimal as first arg to run without it.
Examples:
./bare http://bbs.archlinux.org
tMWtodw
./bare --minimal http://bbs.archlinux.org
tMWtoeA

Last edited by Wra!th (2009-04-23 18:54:50)


MacGregor DESPITE THEM!
7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00

Offline

#57 2009-04-23 19:16:37

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

Re: uzbl. A browser that adheres to the unix philosophy.

I've forked it so when I get a chance I may have a crack at a FIFO/socket control thingymajig.

Offline

#58 2009-04-23 19:21:49

dusanx
Member
Registered: 2008-11-28
Posts: 132

Re: uzbl. A browser that adheres to the unix philosophy.

Barrucadu wrote:

I've forked it so when I get a chance I may have a crack at a FIFO/socket control thingymajig.

I want to fork it but have no experience with git. Is there some simple manual how to do basic things?


Gnome -> Openbox -> Awesome -> XMonad -> dwm .
http://github.com/dusanx/uzbl/

Offline

#59 2009-04-23 19:24:59

haxit
Member
From: /home/haxit
Registered: 2008-03-04
Posts: 1,247
Website

Re: uzbl. A browser that adheres to the unix philosophy.

Where does the history go, if any?


Archi686 User | Old Screenshots | Old .Configs
Vi veri universum vivus vici.

Offline

#60 2009-04-23 19:28:11

fijam
Member
Registered: 2009-02-03
Posts: 244
Website

Re: uzbl. A browser that adheres to the unix philosophy.

http://book.git-scm.com/ is a good resource.

Offline

#61 2009-04-23 19:33:39

Shunpike
Member
From: France
Registered: 2009-01-28
Posts: 47

Re: uzbl. A browser that adheres to the unix philosophy.

fijam wrote:

http://book.git-scm.com/ is a good resource.

You'll find also a lot of things here : http://www-cs-students.stanford.edu/~bl … index.html
And some github specific info here : http://github.com/guides/git-cheat-sheet


edit :

haxit wrote:

Where does the history go, if any?

Dieter@be wrote:

- no bookmark management builtin.  make your own solution.  for pulling a bookmark a plaintxt-based program using dmenu
would work great here. combine with uzbltcrl and xbindkeys.
  uzblctrl should support an option to query the current page so you can script something to add to your bookmarks.  use
  zenity or something to add tags.
- similar story for history.

Last edited by Shunpike (2009-04-23 19:35:43)

Offline

#62 2009-04-23 19:44:29

dusanx
Member
Registered: 2008-11-28
Posts: 132

Re: uzbl. A browser that adheres to the unix philosophy.

Thanks, I will try to contribute wink


Gnome -> Openbox -> Awesome -> XMonad -> dwm .
http://github.com/dusanx/uzbl/

Offline

#63 2009-04-23 19:47:49

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

Re: uzbl. A browser that adheres to the unix philosophy.

Well, I've figured out how to make a FIFO, use fork, and get text from this FIFO whenever something is written there. Not bad for someone who started C last night tongue

Offline

#64 2009-04-23 20:12:31

Shunpike
Member
From: France
Registered: 2009-01-28
Posts: 47

Re: uzbl. A browser that adheres to the unix philosophy.

Wra!th wrote:

I added argument checking ( a bit hackish but it works ok)
By default it runs with the UI I added (close, back, forward, address entry, load button)
You can pass --minimal as first arg to run without it.
Examples:
./bare http://bbs.archlinux.org
http://omploader.org/tMWtodw
./bare --minimal http://bbs.archlinux.org
http://omploader.org/tMWtoeA

Having all those buttons is wrong :-) I really like the minimal stuff though : nothing gets in your way.
If there must be a statusbar, have a look at how vimperator (and vim, obvisously) work.

Offline

#65 2009-04-23 20:53:42

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,000
Website

Re: uzbl. A browser that adheres to the unix philosophy.

Shunpike wrote:
Wra!th wrote:

I added argument checking ( a bit hackish but it works ok)
By default it runs with the UI I added (close, back, forward, address entry, load button)
You can pass --minimal as first arg to run without it.
Examples:
./bare http://bbs.archlinux.org
http://omploader.org/tMWtodw
./bare --minimal http://bbs.archlinux.org
http://omploader.org/tMWtoeA

Having all those buttons is wrong :-) I really like the minimal stuff though : nothing gets in your way.
If there must be a statusbar, have a look at how vimperator (and vim, obvisously) work.

to avoid confusion: I (the author of uzbl) also don't like the buttons and stuff.

PS: I've decided to stick with gtk after all.  It looks like you cannot get "plain" webkit without gtk/qt/wxwidgets/... The reason must be that it *needs* some widgets (select tags, buttons etc) to render some elements on pages.  So I'll have live with that.  That said, I will stick to the interface plan we've discussed before cool

Barrucadu that's great.  I've playing with fifo's myself too.   I found http://www.tldp.org/LDP/lpg/node18.html a pretty good resource.


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#66 2009-04-23 21:04:52

dusanx
Member
Registered: 2008-11-28
Posts: 132

Re: uzbl. A browser that adheres to the unix philosophy.

This is fun smile

I killed both statusbar and scrollbars. Changed update_title and link_hover_cb so when you hover over some link title shows ' -> hover_uri' at the end. This is what I always wanted smile

I can paste code here (quick) or can wait to figure out how git works (day or two delay).

Does anybody need this changes anyway?


Gnome -> Openbox -> Awesome -> XMonad -> dwm .
http://github.com/dusanx/uzbl/

Offline

#67 2009-04-23 21:05:23

Wra!th
Member
Registered: 2009-03-31
Posts: 342

Re: uzbl. A browser that adheres to the unix philosophy.

Meh no need to point out who the author is Dieter...After all the original was a slightly stripped down version of the webkit gtklauncher example... (http://trac.webkit.org/browser/trunk/We … her/main.c)
Here's all I've done on this..I'm starting to loose interest. Happy hacking

// Base code taken from the example webkit-gtk+ application. see notice below.

/*
 * Copyright (C) 2006, 2007 Apple Inc.
 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
#include <string.h>
#include <gtk/gtk.h>
#include <webkit/webkit.h>

static GtkWidget* main_window;
static GtkStatusbar* main_statusbar;
static WebKitWebView* web_view;
static gchar* main_title;
static gint load_progress;
static guint status_context_id;
GtkWidget* address_entry;
gchar* url_argument;

static void update_title (GtkWindow* window)
{
    GString* string = g_string_new (main_title);
    g_string_append (string, " - Bare Browser");
    if (load_progress < 100) g_string_append_printf (string, " (%d%%)", load_progress);
    gchar* title = g_string_free (string, FALSE);
    gtk_window_set_title (window, title);
    g_free (title);
}

static void link_hover_cb (WebKitWebView* page, const gchar* title, const gchar* link, gpointer data)
{
    gtk_statusbar_pop (main_statusbar, status_context_id);
    if (link) gtk_statusbar_push (main_statusbar, status_context_id, link);
}

static void title_change_cb (WebKitWebView* web_view, WebKitWebFrame* web_frame, const gchar* title, gpointer data)
{
    if (main_title) g_free (main_title);
    main_title = g_strdup (title);
    update_title (GTK_WINDOW (main_window));
}

static void progress_change_cb (WebKitWebView* page, gint progress, gpointer data)
{
    load_progress = progress;
    update_title (GTK_WINDOW (main_window));
}

static void destroy_cb (GtkWidget* widget, gpointer data)
{
    gtk_main_quit ();
}

static GtkWidget* create_browser ()
{
    GtkWidget* scrolled_window = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); //change _NEVER to _AUTOMATIC for scrollbars
    web_view = WEBKIT_WEB_VIEW (webkit_web_view_new ());
    gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (web_view));
    g_signal_connect (G_OBJECT (web_view), "title-changed", G_CALLBACK (title_change_cb), web_view);
    g_signal_connect (G_OBJECT (web_view), "load-progress-changed", G_CALLBACK (progress_change_cb), web_view);
    g_signal_connect (G_OBJECT (web_view), "hovering-over-link", G_CALLBACK (link_hover_cb), web_view);
    
    return scrolled_window;
}

static GtkWidget* create_statusbar ()
{
    main_statusbar = GTK_STATUSBAR (gtk_statusbar_new ());
    status_context_id = gtk_statusbar_get_context_id (main_statusbar, "Link Hover");
    gtk_statusbar_set_has_resize_grip(main_statusbar,FALSE);        

    return (GtkWidget*)main_statusbar;
}

static GtkWidget* create_window ()
{
    GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
    gtk_widget_set_name (window, "Bare Browser");
    g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy_cb), NULL);
    
    return window;
}
static void do_load (GtkWidget* widget, gpointer data)
{
    const gchar *url;
    url = gtk_entry_get_text (GTK_ENTRY (address_entry));
    webkit_web_view_load_uri (web_view, url);
}
static void do_back(GtkWidget* widget, gpointer data)
{
    webkit_web_view_go_back (web_view);
}
static void do_forward(GtkWidget* widget, gpointer data)
{
    webkit_web_view_go_forward (web_view);
}
int main (int argc, char* argv[])
{
    gtk_init (&argc, &argv);
    if (!g_thread_supported ()) g_thread_init (NULL);
    GtkWidget* vbox = gtk_vbox_new (FALSE, 0);
    int minimal = 0;
    if(argc > 1) {
        if(strncmp(argv[1], "--minimal", 9) == 0)
        {
            printf("Bare: Running on minimal UI\n");
            minimal = 1;
            if(argc > 2)
            {
                url_argument = (gchar*) argv[2];
            } else {
                url_argument = "http://www.google.com";                
            }
        } else {
            url_argument = (gchar*) argv[1];
        }
    } else {
        url_argument = "http://www.google.com";    
    }
    if(minimal == 0){
        address_entry = gtk_entry_new();
        gtk_entry_set_width_chars(GTK_ENTRY(address_entry), 40);
        gtk_entry_set_text(GTK_ENTRY(address_entry), "http://");
        gtk_entry_set_has_frame(GTK_ENTRY(address_entry),TRUE);
        gtk_box_pack_start (GTK_BOX (vbox), create_browser(), TRUE, TRUE, 0);
        GtkWidget* status_box = gtk_hbox_new(FALSE, 0);
        GtkWidget* go_button = gtk_button_new_with_label ("GO");
        GtkWidget* forward_button = gtk_button_new_with_label (" > ");
        GtkWidget* back_button = gtk_button_new_with_label (" < ");
        GtkWidget* quit_button = gtk_button_new_with_label (" X ");
        gtk_box_pack_start (GTK_BOX (status_box), quit_button, FALSE, TRUE, 0);
        gtk_box_pack_start (GTK_BOX (status_box), back_button, FALSE, TRUE, 0);
        gtk_box_pack_start (GTK_BOX (status_box), forward_button, FALSE, TRUE, 0);
        gtk_box_pack_start (GTK_BOX (status_box), address_entry, FALSE,TRUE , 0);
        gtk_box_pack_start (GTK_BOX (status_box), go_button, FALSE, TRUE, 0);
        gtk_box_pack_start (GTK_BOX (status_box), create_statusbar(), TRUE, TRUE, 0);
        gtk_signal_connect_object (GTK_OBJECT (quit_button), "clicked", GTK_SIGNAL_FUNC (destroy_cb), GTK_OBJECT (quit_button));
        gtk_signal_connect_object (GTK_OBJECT (back_button), "clicked", GTK_SIGNAL_FUNC (do_back), GTK_OBJECT (go_button));
        gtk_signal_connect_object (GTK_OBJECT (forward_button), "clicked", GTK_SIGNAL_FUNC (do_forward), GTK_OBJECT (go_button));
        gtk_signal_connect_object (GTK_OBJECT (go_button), "clicked", GTK_SIGNAL_FUNC (do_load), GTK_OBJECT (go_button));
        gtk_signal_connect_object (GTK_OBJECT (address_entry), "activate", GTK_SIGNAL_FUNC (do_load), GTK_OBJECT (address_entry));
        gtk_box_pack_end (GTK_BOX (vbox), status_box, FALSE, TRUE, 0);
    } else {
        gtk_box_pack_start (GTK_BOX (vbox), create_browser(), TRUE, TRUE, 0);
        gtk_box_pack_start (GTK_BOX (vbox), create_statusbar(), FALSE, TRUE, 0);
    }
    main_window = create_window ();
    gtk_container_add (GTK_CONTAINER (main_window), vbox);
    gtk_widget_grab_focus (GTK_WIDGET (web_view));
    gtk_widget_show_all (main_window);
    webkit_web_view_load_uri (web_view, url_argument);
    gtk_main ();
    
    return 0;
}

Last edited by Wra!th (2009-04-23 21:12:13)


MacGregor DESPITE THEM!
7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00

Offline

#68 2009-04-23 21:19:39

dusanx
Member
Registered: 2008-11-28
Posts: 132

Re: uzbl. A browser that adheres to the unix philosophy.

Shunpike wrote:

Having all those buttons is wrong :-) I really like the minimal stuff though : nothing gets in your way.
If there must be a statusbar, have a look at how vimperator (and vim, obvisously) work.

Agreed. I would like to have status (edit?) bar only visible when I need to type something in. We don't need status bar 99% of time. If we can create status bar that pops up only when needed that would be great. Don't know if and how gtk can support this yet.


Gnome -> Openbox -> Awesome -> XMonad -> dwm .
http://github.com/dusanx/uzbl/

Offline

#69 2009-04-23 21:49:52

insanum
Member
Registered: 2007-01-15
Posts: 26
Website

Re: uzbl. A browser that adheres to the unix philosophy.

Wra!th wrote:

Meh no need to point out who the author is Dieter...After all the original was a slightly stripped down version of the webkit gtklauncher example... (http://trac.webkit.org/browser/trunk/We … her/main.c)
Here's all I've done on this..I'm starting to loose interest. Happy hacking

Well Wra!th I really like what you did.  Just ran your latest code snapshot and love it.  Thanks.

Offline

#70 2009-04-23 21:57:14

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

Re: uzbl. A browser that adheres to the unix philosophy.

Dieter, I've found that the data sent to the FIFO sometimes doesn't end up in the program. I'm trying to figure out why, as it seems pretty random. Have you encountered this problem?
I've also found that if I use fork(), I can't do anything to the webkit instance (this probably should have been obvious), so clearly that's not the way to go about it. I'll investigate threading, and see if I can come up with anything. It'd be nice to have some basic commands working by the weekend big_smile

Last edited by Barrucadu (2009-04-23 22:07:26)

Offline

#71 2009-04-23 23:06:34

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: uzbl. A browser that adheres to the unix philosophy.

@Barrucadu, out of curiosity, why are you using fork when creating the fifo instead of just creating another thread and doing it there? Or are you trying to pass information between the forked processes?

Offline

#72 2009-04-23 23:08:32

dusanx
Member
Registered: 2008-11-28
Posts: 132

Re: uzbl. A browser that adheres to the unix philosophy.

OK, I have keys working smile

We can do everything we want now. Pasting here, learning git smile

// Original code taken from the example webkit-gtk+ application. see notice below.

/*
 * Copyright (C) 2006, 2007 Apple Inc.
 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include <gtk/gtk.h>
#include <webkit/webkit.h>
#include <string.h>
#include <gdk/gdkkeysyms.h>

static GtkWidget* main_window;
static GtkWidget* uri_entry;
static WebKitWebView* web_view;
static gchar* main_title;
static gchar selected_url[500];
static gint load_progress;



static gchar* uri = NULL;
static gboolean verbose = FALSE;

static GOptionEntry entries[] =
{
  { "uri", 'u', 0, G_OPTION_ARG_STRING, &uri, "Uri to load", NULL },
  { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Be verbose", NULL },
  { NULL }
};

static void
activate_uri_entry_cb (GtkWidget* entry, gpointer data)
{
    const gchar* uri = gtk_entry_get_text (GTK_ENTRY (entry));
    g_assert (uri);
    webkit_web_view_load_uri (web_view, uri);
}

static void update_title (GtkWindow* window)
{
    GString* string = g_string_new (main_title);
    g_string_append (string, " - Uzbl browser");
    if (load_progress < 100)
        g_string_append_printf (string, " (%d%%)", load_progress);

    if (selected_url[0]!=0) {
        g_string_append_printf (string, " -> (%s)", selected_url);
    }

    gchar* title = g_string_free (string, FALSE);
    gtk_window_set_title (window, title);
    g_free (title);
}

static void
link_hover_cb (WebKitWebView* page, const gchar* title, const gchar* link, gpointer data)
{
    selected_url[0]='\0';
    if (link) {
        strcpy (selected_url,link);
    }
    update_title (GTK_WINDOW (main_window));
}

static void
title_change_cb (WebKitWebView* web_view, WebKitWebFrame* web_frame, const gchar* title, gpointer data)
{
    if (main_title)
        g_free (main_title);
    main_title = g_strdup (title);
    update_title (GTK_WINDOW (main_window));
}

static void
progress_change_cb (WebKitWebView* page, gint progress, gpointer data)
{
    load_progress = progress;
    update_title (GTK_WINDOW (main_window));
}

static void
load_commit_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data)
{
    const gchar* uri = webkit_web_frame_get_uri(frame);
    if (uri)
        gtk_entry_set_text (GTK_ENTRY (uri_entry), uri);
}

static void
destroy_cb (GtkWidget* widget, gpointer data)
{
    gtk_main_quit ();
}

static void
go_back_cb (GtkWidget* widget, gpointer data)
{
    webkit_web_view_go_back (web_view);
}

static void
go_forward_cb (GtkWidget* widget, gpointer data)
{
    webkit_web_view_go_forward (web_view);
}

static void 
key_press_cb (WebKitWebView* page, GdkEventKey* event)
{
    if ((event->type == GDK_KEY_PRESS) && (event->keyval=GDK_Left) && ((event->state | GDK_MOD1_MASK)==event->state)) { 
    webkit_web_view_go_back (web_view);
    }
}


static GtkWidget*
create_browser ()
{
    GtkWidget* scrolled_window = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_NEVER);

    web_view = WEBKIT_WEB_VIEW (webkit_web_view_new ());
    gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (web_view));

    g_signal_connect (G_OBJECT (web_view), "title-changed", G_CALLBACK (title_change_cb), web_view);
    g_signal_connect (G_OBJECT (web_view), "load-progress-changed", G_CALLBACK (progress_change_cb), web_view);
    g_signal_connect (G_OBJECT (web_view), "load-committed", G_CALLBACK (load_commit_cb), web_view);
    g_signal_connect (G_OBJECT (web_view), "hovering-over-link", G_CALLBACK (link_hover_cb), web_view);
    g_signal_connect (G_OBJECT (web_view), "key-press", G_CALLBACK (link_hover_cb), web_view);

    g_signal_connect (G_OBJECT (web_view), "key-press-event", G_CALLBACK(key_press_cb), web_view);


    return scrolled_window;
}

static GtkWidget* create_window ()
{
    GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
    gtk_widget_set_name (window, "Uzbl browser");
    g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy_cb), NULL);

    return window;
}

int main (int argc, char* argv[])
{
    gtk_init (&argc, &argv);
    if (!g_thread_supported ())
        g_thread_init (NULL);

    GtkWidget* vbox = gtk_vbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox), create_browser (), TRUE, TRUE, 0);

    main_window = create_window ();
    gtk_container_add (GTK_CONTAINER (main_window), vbox);
  GError *error = NULL;

  GOptionContext* context = g_option_context_new ("- some stuff here maybe someday");
  g_option_context_add_main_entries (context, entries, NULL);
  g_option_context_add_group (context, gtk_get_option_group (TRUE));
  g_option_context_parse (context, &argc, &argv, &error);


    webkit_web_view_load_uri (web_view, uri);

    gtk_widget_grab_focus (GTK_WIDGET (web_view));
    gtk_widget_show_all (main_window);
    gtk_main ();

    return 0;
}

-No status or scroll bars.
-Hower link is part of window title. Had to use static string, app crashed with dynamic allocation -- happens too fast I guess.
-Alt+Left arrow navigates back. See key_press_cb. We can monitor all key combinations from here.

Edit:
oops, line with "key-press" is not needed (code works anyway but you can remove it).
Also messed edits but I will fix that tomorrow, should be easy thing to do...

Last edited by dusanx (2009-04-23 23:55:21)


Gnome -> Openbox -> Awesome -> XMonad -> dwm .
http://github.com/dusanx/uzbl/

Offline

#73 2009-04-23 23:34:33

Heller_Barde
Member
Registered: 2008-04-01
Posts: 245

Re: uzbl. A browser that adheres to the unix philosophy.

someone asked for git resources. I think this is teh most awesome git documentation/tutorial stuff:

http://www-cs-students.stanford.edu/~blynn/gitmagic/

cheers Barde

(i am starting to gain interest in that project ^^)

Offline

#74 2009-04-24 05:31:22

Wra!th
Member
Registered: 2009-03-31
Posts: 342

Re: uzbl. A browser that adheres to the unix philosophy.

insanum wrote:
Wra!th wrote:

Meh no need to point out who the author is Dieter...After all the original was a slightly stripped down version of the webkit gtklauncher example... (http://trac.webkit.org/browser/trunk/We … her/main.c)
Here's all I've done on this..I'm starting to loose interest. Happy hacking

Well Wra!th I really like what you did.  Just ran your latest code snapshot and love it.  Thanks.

Well there's nothing in my code that's not in the original(or coded as good as the original). Mightaswell use that smile


MacGregor DESPITE THEM!
7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00

Offline

#75 2009-04-24 07:00:15

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

Re: uzbl. A browser that adheres to the unix philosophy.

Aha, it works! I'm not sure why I was having so many problems with threading (probably because I was tired last night), but now I have a simple control interface working.

Offline

Board footer

Powered by FluxBB