[Kde-bindings] KDE/kdebindings/ruby/korundum
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Sun Jun 22 17:08:40 UTC 2008
SVN commit 823155 by rdale:
* Add more ruby friendly versions of KDE::ConfigGroup.readEntry() and
writeEntry(). Update the tutorial examples to match.
CCMAIL: kde-bindings at kde.org
M +5 -0 ChangeLog
M +4 -4 src/kdehandlers.cpp
M +16 -0 src/lib/KDE/korundum4.rb
M +4 -22 tutorials/p7/p7.rb
M +13 -13 tutorials/p8/p8.rb
M +4 -6 tutorials/p9/p9.rb
--- trunk/KDE/kdebindings/ruby/korundum/ChangeLog #823154:823155
@@ -1,3 +1,8 @@
+2008-06-22 Richard Dale <richard.j.dale at gmail.com>
+
+ * Add more ruby friendly versions of KDE::ConfigGroup.readEntry() and
+ writeEntry(). Update the tutorial examples to match.
+
2008-06-04 Richard Dale <richard.j.dale at gmail.com>
* The rbkconfig_compiler wasn't being built as the CMakeLists.txt
--- trunk/KDE/kdebindings/ruby/korundum/src/kdehandlers.cpp #823154:823155
@@ -126,10 +126,10 @@
case Marshall::ToVALUE:
{
KSharedPtr<KSharedConfig> *ptr = new KSharedPtr<KSharedConfig>(*(KSharedPtr<KSharedConfig>*)m->item().s_voidp);
- if(ptr == 0) {
- *(m->var()) = Qnil;
- break;
- }
+ if (ptr == 0) {
+ *(m->var()) = Qnil;
+ break;
+ }
KSharedConfig * config = ptr->data();
VALUE obj = getPointerObject(config);
--- trunk/KDE/kdebindings/ruby/korundum/src/lib/KDE/korundum4.rb #823154:823155
@@ -284,6 +284,22 @@
def name(*args)
method_missing(:name, *args)
end
+
+ def readEntry(key, default)
+ if default.kind_of?(String) || default.kind_of?(Qt::Variant)
+ return super(key, default)
+ else
+ return super(key, Qt::Variant.new(default)).value
+ end
+ end
+
+ def writeEntry(key, value, pFlags = KDE::ConfigBase::Normal)
+ if value.kind_of?(String) || value.kind_of?(Qt::Variant)
+ super(key, value, pFlags)
+ else
+ super(key, Qt::Variant.new(value), pFlags)
+ end
+ end
end
class DoubleNumInput < Qt::Base
--- trunk/KDE/kdebindings/ruby/korundum/tutorials/p7/p7.rb #823154:823155
@@ -42,23 +42,7 @@
menu.addMenu(filemenu)
menu.addSeparator()
menu.addMenu(helpmenu)
-
-=begin
- toolbar = KDE::ToolBar.new(self)
- icons = KDE::IconLoader.new()
- toolbar.insertButton(icons.loadIcon("reload", KDE::Icon::Toolbar), TOOLBAR_ID_ADDBOOKMARK,
- SIGNAL('clicked(int)'),self,SLOT('bookLocation()'),true,
- i18n("Add to Bookmarks"))
- toolbar.insertButton(icons.loadIcon("back", KDE::Icon::Toolbar), TOOLBAR_ID_BACK,
- SIGNAL('clicked(int)'),self,SLOT('gotoPreviousPage()'),
- false, i18n("Back to previous page"))
- toolbar.insertButton(icons.loadIcon("exit", KDE::Icon::Toolbar), TOOLBAR_ID_QUIT,
- SIGNAL('clicked(int)'),$kapp,SLOT('quit()'),true,
- i18n("Quit the application"))
- addToolBar(toolbar)
-
-=end
toolBar.addAction(@quitAction)
toolBar.addAction(@addBookmarkAction)
toolBar.addAction(@backAction)
@@ -67,8 +51,8 @@
@location = Qt::LineEdit.new
@location.text = "http://localhost"
- config = $kapp.sessionConfig
- @location.text = config.group("Settings").readEntry("defaultPage", Qt::Variant.new("http://localhost")).value
+ @config = KDE::ConfigGroup.new(KDE::Global.config, "Settings")
+ @location.text = @config.readEntry("defaultPage", "http://localhost")
connect( @location , SIGNAL( 'returnPressed()' ),
self, SLOT( 'changeLocation()' ) )
@@ -126,10 +110,8 @@
end
def fileSetDefaultPage()
- config = $kapp.config()
-
- config.group = "Settings"
- config.writeEntry("defaultPage", @browser.url.url)
+ @config.writeEntry("defaultPage", @browser.url.url)
+ @config.sync
end
end
--- trunk/KDE/kdebindings/ruby/korundum/tutorials/p8/p8.rb #823154:823155
@@ -10,7 +10,7 @@
self.horizontalHeaderLabels = [i18n("My Bookmarks")]
horizontalHeader().resizeSection(0, 250)
connect( self, SIGNAL('itemClicked(QTableWidgetItem*)'),
- self, SLOT('setUrlInBrowser(QTableWidgetItem*)'))
+ self, SLOT('setUrlInBrowser(QTableWidgetItem*)'))
end
def add(s)
@@ -19,12 +19,12 @@
end
def setUrlInBrowser(item)
- iface = Qt::DBusInterface.new("org.kde.Browser", "/", "", Qt::DBusConnection.sessionBus)
- if iface.valid?
- iface.setUrl(item.text)
- else
+ iface = Qt::DBusInterface.new("org.kde.Browser", "/", "", Qt::DBusConnection.sessionBus)
+ if iface.valid?
+ iface.setUrl(item.text)
+ else
qWarning("Error with DBUS\n")
- end
+ end
end
end
@@ -33,15 +33,15 @@
a = KDE::UniqueApplication.new
if !Qt::DBusConnection::sessionBus.connected?
- $stderr.puts("Cannot connect to the D-BUS session bus.\n" \
- "To start it, run:\n" \
- "\teval `dbus-launch --auto-syntax`\n")
- exit(1)
+ $stderr.puts("Cannot connect to the D-BUS session bus.\n" \
+ "To start it, run:\n" \
+ "\teval `dbus-launch --auto-syntax`\n")
+ exit(1)
end
-
+
if !Qt::DBusConnection.sessionBus.registerService("org.kde.BookMarkList")
- $stderr.puts("%s\n" % Qt::DBusConnection.sessionBus.lastError.message)
- exit(1)
+ $stderr.puts("%s\n" % Qt::DBusConnection.sessionBus.lastError.message)
+ exit(1)
end
mylist = BookMarkList.new
--- trunk/KDE/kdebindings/ruby/korundum/tutorials/p9/p9.rb #823154:823155
@@ -51,8 +51,8 @@
@location = Qt::LineEdit.new
@location.text = "http://localhost"
- config = $kapp.sessionConfig
- @location.text = config.group("Settings").readEntry("defaultPage", Qt::Variant.new("http://localhost")).value
+ @config = KDE::ConfigGroup.new(KDE::Global.config, "Settings")
+ @location.text = @config.readEntry("defaultPage", "http://localhost")
connect( @location , SIGNAL( 'returnPressed()' ),
self, SLOT( 'changeLocation()' ) )
@@ -110,10 +110,8 @@
end
def fileSetDefaultPage()
- config = $kapp.config()
-
- config.group = "Settings"
- config.writeEntry("defaultPage", @browser.url.url)
+ @config.writeEntry("defaultPage", @browser.url.url)
+ @config.sync
end
end
More information about the Kde-bindings
mailing list