summaryrefslogtreecommitdiffstats
path: root/korundum/rubylib/tutorials/p9
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /korundum/rubylib/tutorials/p9
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'korundum/rubylib/tutorials/p9')
-rw-r--r--korundum/rubylib/tutorials/p9/p9.rb110
-rw-r--r--korundum/rubylib/tutorials/p9/p9ui.rc14
2 files changed, 124 insertions, 0 deletions
diff --git a/korundum/rubylib/tutorials/p9/p9.rb b/korundum/rubylib/tutorials/p9/p9.rb
new file mode 100644
index 00000000..98bb9d0e
--- /dev/null
+++ b/korundum/rubylib/tutorials/p9/p9.rb
@@ -0,0 +1,110 @@
+require 'Korundum'
+
+class Browser < KDE::MainWindow
+ k_dcop 'void setURL(QString)'
+
+ slots 'fileSetDefaultPage()',
+ 'changeLocation()',
+ 'bookLocation()',
+ 'gotoPreviousPage()',
+ 'openURLRequest(const KURL&, const KParts::URLArgs&)'
+
+ def initialize( name )
+ super(nil, name)
+ @history = []
+
+ KDE::StdAction.quit(self, SLOT('close()'), actionCollection())
+
+ KDE::Action.new(i18n("&Set default page"), "gohome", KDE::Shortcut.new(0), self,
+ SLOT('fileSetDefaultPage()'), actionCollection(), "set_default_page")
+
+ KDE::Action.new(i18n("Add to Bookmarks"), "reload", KDE::Shortcut.new(0), self,
+ SLOT('bookLocation()'), actionCollection(), "add_to_bookmarks")
+
+ KDE::Action.new(i18n("Back to previous page"), "back", KDE::Shortcut.new(0), self,
+ SLOT('gotoPreviousPage()'), actionCollection(), "back")
+
+ actionCollection().action("back").setEnabled(false)
+
+ createGUI(Dir.getwd + "/p9ui.rc")
+
+ vbox = Qt::VBox.new( self )
+
+ @location = Qt::LineEdit.new( vbox )
+
+ config = $kapp.config()
+ config.setGroup("Settings")
+ @location.text = config.readEntry( "defaultPage", "http://localhost")
+
+ connect( @location , SIGNAL( 'returnPressed()' ),
+ self, SLOT( 'changeLocation()' ) )
+
+ @browser = KDE::HTMLPart.new( vbox )
+ @browser.openURL( KDE::URL.new(@location.text()) )
+
+ connect( @browser.browserExtension(),
+ SIGNAL( 'openURLRequest( const KURL&, const KParts::URLArgs& )' ),
+ self, SLOT( 'openURLRequest(const KURL&, const KParts::URLArgs& )' ) )
+ setCentralWidget(vbox)
+ end
+
+
+ def changeLocation()
+ @history.push( @browser.url().url() );
+ actionCollection().action("back").setEnabled(true)
+ @browser.openURL( KDE::URL.new(@location.text()) )
+ end
+
+ def setURL( url )
+ @location.text = url
+ changeLocation()
+ end
+
+ def openURLRequest(url, part)
+ setURL( url.url() )
+ end
+
+ def gotoPreviousPage()
+ @location.text = @history.pop()
+ if @history.empty?
+ actionCollection().action("back").setEnabled(false)
+ end
+ @browser.openURL( KDE::URL.new(@location.text()) )
+ end
+
+ def bookLocation()
+ dcopRef = KDE::DCOPRef.new("p8", "BookMarkList")
+ if ! dcopRef.add(@location.text())
+ qWarning("Error with DCOP\n")
+ end
+ end
+
+ def fileSetDefaultPage()
+ config = $kapp.config()
+
+ config.group = "Settings"
+ config.writeEntry( "defaultPage", @browser.url().url() )
+ end
+end
+
+ aboutdata = KDE::AboutData.new("p9", "Tutorial - p9",
+ "1.0", "Step 9 of a simple tutorial", KDE::AboutData::License_GPL,
+ "(C) 2000, 2001 Antonio Larrosa Jimenez","",
+ "http://devel-home.kde.org/~larrosa/tutorial.html")
+ aboutdata.addAuthor("Antonio Larrosa Jimenez",
+ "Original Developer/Mantainer","larrosa@kde.org",
+ "http://devel-home.kde.org/~larrosa/index.html")
+ aboutdata.addAuthor("Richard Dale",
+ "Ruby port","Richard_Dale@tipitina.demon.co.uk",
+ "")
+ KDE::CmdLineArgs.init(ARGV, aboutdata)
+
+ a = KDE::UniqueApplication.new()
+
+ window = Browser.new( "Tutorial - p9" )
+ window.resize( 300, 200 )
+
+ a.mainWidget = window
+ window.show
+
+ a.exec
diff --git a/korundum/rubylib/tutorials/p9/p9ui.rc b/korundum/rubylib/tutorials/p9/p9ui.rc
new file mode 100644
index 00000000..9e194c20
--- /dev/null
+++ b/korundum/rubylib/tutorials/p9/p9ui.rc
@@ -0,0 +1,14 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" >
+<kpartgui name="p9" version="1">
+<MenuBar>
+ <Menu name="file"><text>&amp;File</text>
+ <Action name="set_default_page"/>
+ </Menu>
+</MenuBar>
+<ToolBar fullWidth="true" name="mainToolBar">
+ <Action name="add_to_bookmarks"/>
+ <Action name="back"/>
+ <Separator/>
+ <Action name="file_quit"/>
+</ToolBar>
+</kpartgui> \ No newline at end of file