LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-15-2017, 02:54 AM   #1
Michael Uplawski
Member
 
Registered: Dec 2015
Location: Outside, most of the time.
Posts: 933
Blog Entries: 26

Rep: Reputation: 547Reputation: 547Reputation: 547Reputation: 547Reputation: 547Reputation: 547
Ruby-Gtk3 anybody? Which API-reference do you use?


The API-reference for Ruby-Gtk that I can find on the web appears to be terribly outdated. So maybe there is one that I cannot find or something else, that I have missed.

Luckily, I have a few code-examples around and can try to apply the information from the old documentation to the current Gtk3 library and Ruby-Gem. But this is awfully inefficient.

Today, I get my hints by
1.) looking at the code, like in:
In deed, the option hash is named ‘options’ in Button::initialize()
2.) checking the available methods, like in:
Code:
irb(main):008:0> require 'gtk3'
=> true
irb(main):009:0> Gtk::Button.public_methods.sort

=> [:!, :!=, :!~, :<, :<=, :<=>, :==, :===, :=~, :>, :>=, :__id__, :__send__, 
:accessible_role=, :accessible_type=, :allocate, :ancestors, :append_features, 
:autoload, :autoload?, :bind_template_callback_full, :bind_template_child, 
:bind_template_child_full, :child_properties, :child_property, :class, 
:class_eval, :class_exec, :class_variable_defined?, :class_variable_get, 
:class_variable_set, :class_variables, :clone, (...)
3.) Calling ri because I am a believer:
Code:
:~$ ri Gtk::Button.new
= Gtk::Button.new
(from gem gtk3-3.1.8)
=== Implementation from Button
------------------------------------------------------------------------------
  new(options={})
------------------------------------------------------------------------------
4.) trying what I consider possibly correct usage of a method, like in:
Code:
irb(main):010:0> require 'gtk3'
=> true
irb(main):011:0> bt = Gtk::Button.new('Whatever')
(irb):11:in `new': 'Gtk::Button#initialize(label_or_stock_id, use_underline = 
nil)' style has been deprecated. Use 'Gtk::Button#initialize(:label => nil, 
:use_underline => nil, :stock_id => nil)' style.
=> #<Gtk::Button:0x5605842187b8 ptr=0x560584674180>
(oh, cool. They use an option-hash, now)
Code:
irb(main):004:0> require 'gtk3'
=> true
irb(main):005:0> bt = Gtk::Button.new(:my_option => 'now what?')
irb(main):007:0> bt.to_s
=> "#<Gtk::Button:0x000055cd0b6870d0>"
irb(main):008:0> bt.inspect
=> "#<Gtk::Button:0x55cd0b6870d0 ptr=0x55cd0b688180>"
irb(main):009:0> bt.my_option
NoMethodError: undefined method `my_option' for #<Gtk::Button:0x55cd0b6870d0 ptr=0x55cd0b688180>
	from (irb):9
	from /usr/bin/irb:11:in `<main>'
irb(main):010:0> bt.options
NoMethodError: undefined method `options' for #<Gtk::Button:0x55cd0b6870d0 ptr=0x55cd0b688180>
	from (irb):10
	from /usr/bin/irb:11:in `<main>'
irb(main):010:0> drop dead!
NoMethodError: undefined method `dead!' for main:Object
	from (irb):11
	from /usr/bin/irb:11:in `<main>'
There must be a way ...
PSE note (just in case): I know how to create buttons (and derive/overwrite or use meta-classes) in Gtk3. This was an example. The question is in the subject!

Last edited by Michael Uplawski; 08-15-2017 at 04:45 AM. Reason: Be explicit.
 
Old 08-17-2017, 02:15 AM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_12{.0|.1}
Posts: 5,434
Blog Entries: 11

Rep: Reputation: 3398Reputation: 3398Reputation: 3398Reputation: 3398Reputation: 3398Reputation: 3398Reputation: 3398Reputation: 3398Reputation: 3398Reputation: 3398Reputation: 3398
Apparently there are not many active Ruby, or Ruby-Gtk programmers here at this time, myself included!

As no one else has stepped in I can only offer the results of my own online searches, hopefully there will be something different from yours.

Here is the most current Ruby-Gtk3 API I found. The most recent updates look like 25 days ago, then 4 and 5 months ago, but not a lot of activity.

I found this Ruby-Gtk Tutorial, dated 2014.

Then there is thi ruby-gtk3-tutorial. It is 2 years old and does not look to have much depth, but has quite a few examples. You might stumble across something relevant and not totally ancient there.


And this very old site, Programming Ruby/GTK, but it has several complete examples (of unknown applicability to current Ruby and Gtk). Perhaps it can lead to other references.

I bought the Pick Axe book long ago, intending to learn Ruby, but choked on the Preface and lost interest early as I recall! I had no actual use for it at the time and could not find its compelling "reason for being". Maybe I should dust it off.

Last edited by astrogeek; 08-17-2017 at 02:18 AM.
 
Old 08-17-2017, 10:53 AM   #3
Michael Uplawski
Member
 
Registered: Dec 2015
Location: Outside, most of the time.
Posts: 933

Original Poster
Blog Entries: 26

Rep: Reputation: 547Reputation: 547Reputation: 547Reputation: 547Reputation: 547Reputation: 547
Thank you astrogeek for all the effort...

Quote:
Originally Posted by astrogeek View Post
Here is the most current Ruby-Gtk3 API I found. The most recent updates look like 25 days ago, then 4 and 5 months ago, but not a lot of activity.
As I installed the Gtk3-Gem and need the Gtk-development libraries anyway, the source-code of both, the library and the Ruby-bindings, is accessible on my machine, all the time.

Quote:
I found this Ruby-Gtk Tutorial, dated 2014.
A tutorial is more for newbies who need a complete overview over the library's and the gem's potential. I already program Ruby/Gtk and just need a reliable documentation on classes and methods. Normally RDoc and ri are there for exactly this purpose.
But when you try that on Gtk, ... oh my. All you get is the Gnu-GPL three or four times in a row and a list of constants and class-method names. Felicitations!

The classes aren't any better:
Code:
:~$ ri Gtk::ToggleButton
= Gtk::ToggleButton < Object

------------------------------------------------------------------------------
= Extended by:
GLib::Deprecatable (from gem gtk3-3.1.8)

(from gem gtk3-3.1.8)
------------------------------------------------------------------------------

------------------------------------------------------------------------------
= Class methods:

  new

= Instance methods:

  initialize_raw
The heck with it.

The Ruby/Gtk-documentation is a mess. The best you can do, is consult the API-docs of the C-Library. At least it is complete and explains... stuff. Unfortunately, though, the ruby-bindings make heavy use of Ruby-mechanisms, such as symbols and variable argument-lists. Only trial&error get you from a documented C-method to running Ruby-code, if there is nobody to explain the difference. Of course, you can *ALWAYS* read the code.

Quote:
I bought the Pick Axe book long ago, intending to learn Ruby, but choked on the Preface and lost interest early as I recall! I had no actual use for it at the time and could not find its compelling "reason for being". Maybe I should dust it off.
I never bought the book. This is probably an error on my side, but after attending the 2nd. Rubylearning.org online-course (and tutoring some later courses), the books on Metaprogramming and, of course, “Design-Patterns in Ruby” were more interesting. If you want quick results, buy a pocket-reference and the Ruby-Cookbook.

Thanks again.

Michael
P.S.: I see that RubyLearning.org has not been updated and that Moodle had not been awful enough. The site and the courses are probably obsolete, now. Pity.

Last edited by Michael Uplawski; 08-17-2017 at 02:12 PM. Reason: Kraut2English. Precision on Rubylearning.org
 
Old 09-06-2020, 08:50 AM   #4
shevegen
Member
 
Registered: May 2004
Distribution: Slackware / GoboLinux / LFS / VoidLinux
Posts: 127

Rep: Reputation: 26
It is indeed quite messy, but not totally dead; kou still maintains the ruby bindings to gtk here:

https://github.com/ruby-gnome/ruby-gnome

I am trying to collect lots of examples into this project here:

https://rubygems.org/gems/gtk_paradise

But it will be beta for years, simply due to my own lack of time. :\

My aim with gtk_paradise is to make everything nicer to use, simpler to use
too, in the long run. And to document a LOT - but sadly, writing documentation
is horribly boring so .......

I also have noticed that information is slowly vanishing. This is really bad. Most of my code
still is in gtk2; it seems as if the transition from gtk2 to gtk3 really took a big toll. I
can not say why ... perhaps it was the mobile area that also had to pay a toll? These days
I would honestly consider just using the www-stack. At the least that one is very active.
 
Old 09-06-2020, 12:26 PM   #5
EdGr
Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 482

Rep: Reputation: 234Reputation: 234Reputation: 234
I use GTK 3 with C++. A big problem with GTK 3 was that the API remained a moving target right up until the developers called GTK 3.24 "done" and moved on to GTK 4.

I suggest using the latest 3.24 with the native C API. A version from even two years ago is obsolete.
Ed
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ruby - Need to select individual properties from objects in spacewalk api Thaidog Programming 3 08-14-2015 09:14 AM
Installation of Linux-API --> userspace cannot reference .... CBM200 Linux From Scratch 2 02-03-2014 08:15 PM
[SOLVED] Undefined reference error when using Lua API MTK358 Programming 8 07-20-2011 07:14 PM
Linux API Reference [urgent] hosseinyounesi Programming 14 08-27-2008 04:05 AM
Ruby SDL/ Ruby OpenGL tutorials/reference? LinuxNoob75 Programming 0 12-30-2007 12:47 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration