Author Topic: Lets create a PCLinuxOS webkit browser (python)  (Read 29539 times)

uncleV

  • Guest
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #165 on: April 05, 2011, 03:29:31 AM »
Am I doing something wrong ???

pclinuxos-hammer.py is working (LXDE here) and I am posting now from it.

P.S. I took it from post #99 as Neal suggested earlier.
« Last Edit: April 05, 2011, 03:33:39 AM by uncleV »

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15829
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #166 on: April 05, 2011, 03:48:38 AM »
Am I doing something wrong ???

pclinuxos-hammer.py is working (LXDE here) and I am posting now from it.

P.S. I took it from post #99 as Neal suggested earlier.

You're fine, uncleV. The problems we are having are in using hammer with features added. The one you have works but does not have tabs, bookmarks, history and other such. We're trying to add them.

uncleV

  • Guest
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #167 on: April 05, 2011, 03:50:27 AM »
OK.
I'll wait for the more polished alpha. Wish you luck :)

Offline Taco.22

  • Sr. Member
  • ****
  • Posts: 481
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #168 on: April 05, 2011, 04:05:03 AM »
Well, getting close.  Took ongotos advice on coding.  Fitted in with what I thought - signals, buttons and event handlers all worked together.
Script is here http://dl.dropbox.com/u/18945176/tabbed_browser.py

So, allow me to present (drum roll) a back button that doesn't crash the browser.  A great step forward you may say, and you would be right.  Now, it doesn't actually do anything else either, but you can't have everything :D  At least it doesn't break anything.  It maybe as simple as a comma out of place, or extra stuff to do with page loading.

So have a look - it's got to be so close; I hope! 
Linux Registered User # 529407


Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15829
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #169 on: April 05, 2011, 04:19:13 AM »
Taco.22,
Back button doesn't work, but the add tab button does! Woohoo! Progress!

ongoto

  • Guest
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #170 on: April 05, 2011, 04:35:25 AM »
Made some modifications:
http://nbrks.com/hammer/hammertest2.py.tar.xz

Now a different error:
Code: [Select]
line 367, in __init__
    toolbar.connect("load-requested", load_requested_cb, content_tabs)
TypeError: <gtk.Toolbar object at 0x91797d4 (GtkToolbar at 0x9212800)>: unknown signal name: load-requested


Three places to look.  Make sure the words are separated with a dash - and not an underline _
Code: [Select]
class WebToolbar(gtk.Toolbar):

    __gsignals__ = {
        "load-requested": (gobject.SIGNAL_RUN_FIRST,
                           gobject.TYPE_NONE,
                           (gobject.TYPE_STRING,)),

Further down:
Code: [Select]
   def _entry_activate_cb(self, entry):
        self.emit("load-requested", entry.props.text)

Code: [Select]
class WebBrowser(gtk.Window):

    def __init__(self):
        gtk.Window.__init__(self)

        toolbar = WebToolbar()
        content_tabs = ContentPane()
        content_tabs.connect("focus-view-title-changed", self._title_changed_cb, toolbar)
        content_tabs.connect("new-window-requested", self._new_window_requested_cb)
        toolbar.connect("load-requested", load_requested_cb, content_tabs)
« Last Edit: April 05, 2011, 04:39:38 AM by ongoto »

Offline Taco.22

  • Sr. Member
  • ****
  • Posts: 481
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #171 on: April 05, 2011, 06:09:02 AM »
Taco.22,
Back button doesn't work, but the add tab button does! Woohoo! Progress!

I thought the back button was a bit of a breakthrough - not only doesn't work, but doesn't crash the browser as well :D.  I'm still trying to work out whats missing/malformed.  There seems to be some deeper instruction missing, something about where the browser has been so it can then return to or from there.  Simpler python browsers have web_view as part of the button commands.  All seems a bit more obscure/complicated in this script.  Here's an example from one, category "Class Browser" and button functions.

Code: [Select]
        #webkit.WebView allows us to embed a webkit browser
        #it takes care of going backwards/fowards/reloading
        #it even handles flash
        self.web_view = webkit.WebView()
        self.web_view.open(self.default_site)

then   #create the back button and connect the action to
        #allow us to go backwards using webkit
        self.back_button = gtk.ToolButton(gtk.STOCK_GO_BACK)
        self.back_button.connect("clicked", self.go_back)

then   def go_back(self, widget, data=None):
        '''Webkit will remember the links and this will allow us to go
           backwards.'''
        self.web_view.go_back()



Not sure where to go from here.  Keep on plugging away. 




 
Linux Registered User # 529407


Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15829
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #172 on: April 05, 2011, 06:27:36 AM »
ongoto,
Got dashes, not underscores.

Taco.22,
Which line numbers are you adding that to?

AndrzejL

  • Guest
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #173 on: April 05, 2011, 06:39:33 AM »
OK. I'll wait for the more polished alpha. Wish you luck :)

Ekhem... WUT? Are You taking a biscuit? I never touched the Hammer  and if I would touch it I would break it... :P.

Andy
« Last Edit: April 05, 2011, 06:41:49 AM by AndrzejL »

uncleV

  • Guest
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #174 on: April 05, 2011, 06:42:13 AM »
Should I say Polished? ::)
 ;D

AndrzejL

  • Guest
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #175 on: April 05, 2011, 06:53:16 AM »
Should I say Polished? ::) ;D

Huehue :P

Andy

Offline Taco.22

  • Sr. Member
  • ****
  • Posts: 481
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #176 on: April 05, 2011, 06:55:26 AM »
Sorry Neal, not actually adding those - just an example of simple code.  Hootiegibbon's example in reply No.30 has it in place.  Just trying to work out how it's been extrapolated in the tabbed browser.       
Linux Registered User # 529407


Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15829
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #177 on: April 05, 2011, 07:08:20 AM »
Sorry Neal, not actually adding those - just an example of simple code.  Hootiegibbon's example in reply No.30 has it in place.  Just trying to work out how it's been extrapolated in the tabbed browser.       

Okay. Thanks.

Offline Taco.22

  • Sr. Member
  • ****
  • Posts: 481
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #178 on: April 05, 2011, 08:07:18 AM »
http://dl.dropbox.com/u/18945176/tabbed_browser2.py

This is my final effort for the night.  I have mirrored the tab button with the back button all the way through the script.  

Line 275 - gsignals
  "   291 - add back button
  "   343 - def _go_back_cb(self, button):
  "   376 -  toolbar.connect
  "   420 - event handlers

The script launches, loads home page: open a link, then hit back button gets -
"TypeError: go_back_requested_cb() takes exactly 1 argument (2 given)"

I hope someone can make sense of that.  I'm not sure if there is a double up of "self" as an argument, or where that might be.  How close is close?!?      

EDIT - not quite my last effort: some people just don't know when to stop!  Believe it or not, the right-click menu in the browser operates the back and forward commands!!  It was just on a whim as I was about to log off that I tried it.  Maybe we could just eliminate the buttons :D.  Anyway, I need some sleep.  I think I have fried my brain.  Hard work reinventing the wheel!  Oh, maybe that's the 2 arguments error.
« Last Edit: April 05, 2011, 08:41:17 AM by Taco.22 »
Linux Registered User # 529407


Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15829
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #179 on: April 05, 2011, 09:01:21 AM »
Looks like you're almost there, Taco.22! :D