Gtk Perl Notebook get_current_page Problem and Solution

30 07 2008

I am working on something that uses Perl Gtk and Glade. Everything works fine except that when I want to get the currently selected page on the notebook using $notebook->get_current_page the currently selected page is not returned but the previous selected page.

My code looks like this:

#Get widget and assign to variable
$notebookMain = $gladexml->get_widget(‘notebookMain’);

#Bind signal to a subroutine in this case the switch-page signal of Notebook
on_notebookMain_switch_page=>\&on_notebookMain_switch_page

#The sub getting executed when user changes to another page
sub on_notebookMain_switch_page
{
$curr_page = $notebookMain->get_current_page;
}

From that I should get the current page of $notebookMain when the user clicks on a different page but like I said before this doesn’t work.

The big hint when searching Google for a answer came with this post. So I tried what Torsten suggested and changed my sub on_notebookMain_switch_page like this:

#The sub getting executed when user changes to another page
sub on_notebookMain_switch_page
{
$curr_page = $notebookMain->get_current_page;
warn join(“, “, @_);
}

This gave the following output when I changed pages:

Gtk2::Notebook=HASH(0x85ffff0), 141979504, 1, at /home/fredre/Desktop/WargenInterface/WIP.pl line 93.
Gtk2::Notebook=HASH(0x85ffff0), 141773512, 0, at /home/fredre/Desktop/WargenInterface/WIP.pl line 93.
Gtk2::Notebook=HASH(0x85ffff0), 141982680, 2, at /home/fredre/Desktop/WargenInterface/WIP.pl line 93.
Gtk2::Notebook=HASH(0x85ffff0), 141989048, 3, at /home/fredre/Desktop/WargenInterface/WIP.pl line 93.

From this I could gather that the correct current page is located in @_ and it is not the number get_current_page is returning.

So to get the correct currently selected page the subroutine should look like this:

#The sub getting executed when user changes to another page
sub on_notebookMain_switch_page
{
$curr_page = $_[2];
}

I don’t know if the problem occurs because I was using Glade or if I just missed something along the way.

I was using:

libGtk2-Perl 1:1.161-1
libGtk2-gladexml-perl 1.006-1
Glade 3.4.2
perl 5.8.8

all from the Ubuntu repositories .

Happy Hacking !!!!





Perl GTK: How to insert text at the end of a GTK TextView

28 07 2008

Just a quick note if you are working with Perl and GTK and you want to append the text or insert some text into a GTK TextView while keeping the original text. This code will add text to TextView at the bottom.

#First create your TextView
$textview_Main = Code to create TextView;

#Get the buffer of the newly created TextView
$textbuffer = $textview_Main->get_buffer;

#Get the end iter of the buffer
$textiter = $textbuffer->get_end_iter;

#Insert some text into the buffer
$textbuffer->insert($textiter,”Testing \n”);

#Set the buffer of the TextView to display new text
$textview_Main->set_buffer($textbuffer);

Enjoy programming with Perl and GTK !!!!





Afrikaans spell checker in Web-browser (Firefox)

23 07 2008

I have been using Facebook more and more recently to send messages to my friends. Because my first language is Afrikaans I write some of my messages in the language but unlike English there is no default spellchecker in Afrikaans that ships with Firefox.

To get a Afrikaans spellchecker for Firefox is easy just follow these simple steps:

1. Get Firefox
Firefox isn’t just a Web-browser it is THE Web-browser. Running on multiple systems like Linux, Windows and the Mac Firefox is a modern secure browser used by million’s around the world. I think it is hard to find a IT expert that wouldn’t recommend Firefox. But you get a lot more with Firefox like add-ons that can extend the browser in multiple ways. My favorite add-on is called Adblock Plus that blocks the adds on different pages using filters. Firefox is free to download and use.

So if you dont already use Firefox go here download and install Linux users will probably already be using Firefox since the browser comes standard with most distributions

firefox-web-browser-faster-more-secure-customizable

firefox-web-browser-faster-more-secure-customizable

2. Get the Afrikaans dictionary for Firefox
This is the easy part. Open your Firefox browser and hear over to https://addons.mozilla.org/en-US/firefox/addon/5127. This will lead you to the place were you can install the Afrikaans dictionary for Firefox. Click on the green button that says “Add to firefox”.

afrikaans-dictionary-firefox-add-ons-mozilla-firefox

afrikaans-dictionary-firefox-add-ons-mozilla-firefox

A window will pop up asking if you want to install. After waiting a few seconds click on the install button.

screenshot-software-installation

screenshot-software-installation

Wait a few seconds for the small download to complete (588 KB) and click the restart firefox button in the window.

screenshot-add-ons

screenshot-add-ons

And that is it the dictionary is installed. The dictionary is provided by Translate.org.za. Visit them for more South African languages like Zulu, Xhosa, Venda ect. for Firefox, Open Office (Word processing) and Thunderbird (Email client). Thank you Translate.org.za and all the people working on the project.

3. Select your language
The last thing to do is test our new Afrikaans spell checker. I tested mine in Facebook by writing a new message to one of my friends. To select the Afrikaans dictionary right-click in the box you are writing you message. In the popup window select Languages –> Afrikaans/South…

screenshot-facebook-compose-new-message

screenshot-facebook-compose-new-message

You are now using the Afrikaans dictionary. If according to the dictionary you didn’t spell the word correctly a red line will appear under the word. Right-click on the word and check the list for another word that is suggested.

screenshot-facebook-compose-new-message2

screenshot-facebook-compose-new-message2

Head over to https://addons.mozilla.org/en-US/firefox/browse/type:3 to find more language dictionaries.

Once again thank you to all the people working on free and open source software and people like the Translate.org.za group that help us get this software in the language of our choice.





Gears 0.3.24.3 is out and now works with Firefox 3.0.1

16 07 2008

Just a quick update on this.

I tried to install Gears (Linux) just now hoping that it is now compatible with Firefox 3.0.1 and it seems that everything is working fine.

Version 0.3.24.3 was installed and I can now try Gears with WordPress.





Google Gears 0.3.24.0 Not compatible with Firefox 3.0.1

15 07 2008

I noticed that WordPress now supports Google Gears but when I tried to install Gears to Firefox 3.0.1 I got a message saying “Google Gears 0.3.24.0 could not be installed because it is not compatible with Firefox 3.0.1″

I found this thread highlighting the problem.

The solution is to wait for Gears 0.3.24.3 according to Aaron Boodman:

“I released Gears 0.3.24.3, which is marked for compatibility with
Firefox 3.0.*, to 1% of public users Friday afternoon [Jul 11 ?]. I plan to
increase that to 10% then 100% over the next few days, in time for the
Wednesday afternoon schedules release of Firefox 3.0.1. ”

According to this tread there is a build out for debugging but I could not find any Gears test builds. Just have to wait I guess.

Cant wait to try WordPress with Google Gears.








Follow

Get every new post delivered to your Inbox.