Archive for ubuntu

GUI programming glade ubuntu 1

Posted in linux, programming with tags , , , on June 15, 2008 by coolarm

If you are a Linux newbie, you may want to read about Wubi (installation) of Ubuntu

https://coolarm.wordpress.com/2008/06/02/linux-for-windows-users-wubi-installation/

———————————————————————————>

I am trying to learn GUI programming in Ubuntu using glade-2.

There are some tutorials that I have referred to

http://wingtk.sourceforge.net/ishan/glade.html – by Ishan Chattopadhyaya is a good source and is referred to in other places too.

Though glade-3 is recent version, I had a horrible time using it in my earlier attempt at programming a window. Now, I have reverted to Galde-2. If I am right the problem I faced was due to the developers attempt to keep C source code generation out of glade http://glade.gnome.org/

Here, we will try to create a small window that will have a text box with a default text and a button. When the button is clicked, the text in the text box changes.

On execution before clicking

Window after clicking the button

First install glade

sudo apt-get install glade-2

There are few other packages I needed to install while trying to compile the GUI program we are going to create

sudo apt-get install autoconf automake libglib2.0-dev libc6-dev libgtk2.0-dev

Now, launch glade Applications->Programming->Glade Interface Designer

Glade UI fresh

Observe the main, palette and Properties window that opens up. GUI programming in glade is based on the concepts of widgets that you can see on the palette window. You add widgets depending on what you need. We will be using Fixed Position, Text entry and Button widgets. Now click the Window button in the palette window. You should observe a “window1” screen in the main window and a new window should open up

A new window program

Click on the Fixed positions button in the Palette window  and then on the window1 screen to see something like this

Fixed position in window screen

Now click on the text entry button in Palette window and then double click on the window1 screen to drop a text entry on it. In a similar fashion, click on the “Button” button and double click on the window1 screen below the text entry to see something like below

window1 with text entry and button

Now modify the default text on the text entry and the label on the button.

Default text in text entry

Label on OK button

Now click on the empty place in window1 screen (i.e. other than the text entry and button) to select fixed1. Now in the properties, select signals tab and then the button next to the “signal” text entry. It will display a list of signals that fixed1 emits. Select destroy under GtkObject signals and click OK.

destroy signal for window

Click add in the properties window and you should find “destroy” under signal and “on_window1_destroy” under handler. This is needed to make the window exit properly.

Now, select the button and in the signals tab of the properties window, and in the signals list, select clicked and Ok. Click add and you should find something like below

clicked signal for the button

This is signal is used to perform the task of changing the text in the text entry when the user clicks, though we have not added the code needed for the latter half.

Save the project to its default location ~/Projects/project1/ and click Build in the main window. We now have the source code written

Stage 2:

Goto ~/Projects/project1 and browse through the listing

The autogen.sh script is used to create the makefiles which will compile your source code. The src directory contains yoru source code. cd to src directory

main.c contains code to create the window1 and then wait for events (click of button or exit) in an endless loop within gtk_main(). Though, it creates the window1 interface, the code defining window1 exists in the file interface.c

interface.c defines the appearance of your window. The create_window1() called in main.c is defined here. You can find the declaration for window1, fixed1, entry1, button1. Two important instructions defined in this code are the two g_signal_connect(). In event driven programming, which is what GUI programming is, events such as clicking a mouse button, changing the state of a radio button are assosciated with particular functions or callbacks which wil perform the corresponding task. As noted at the start of this file, we shouldnt be modifying this file since, it will overwritten by Glade when you change options are rebuild it.

Coming back to the g_signal_connect functions,

g_signal_connect ((gpointer) window1, “destroy”,
G_CALLBACK (on_window1_destroy),
NULL);

means that the destroy signal of window1 will execute the callback function on_window1_destroy()

Similarily, g_signal_connect ((gpointer) button1, “clicked”,
G_CALLBACK (on_button1_clicked),
NULL);

means that the clicked signal of button1 is connected to the callback function on_button1_clicked()

callbacks.c is the file containing the definitions for the callbacks associated with signals. This is the file which we will need to modify to make our window respond to user generated events. However, to modify the properties of other widgets ( change text in the entry), we will need to know the variables (pointers) representing those widgets, which is done using the name of the widget and lookup_widget(). For this look into the last few lines of interface.c. You will find the names of the widgets.

Add the code for on_window1_destroy() –

gtk_main_quit();

Add the code for on_button1_clicked() –

GtkWidget *text1 = lookup_widget(GTK_WIDGET(button), “entry1″);
gtk_entry_set_text(GTK_WIDGET(text1),”Hi. I am fine”);

Stage 3:

Having completed the coding, let us compile and run the program.

goto ~/Projects/project1 and run ./autogen.sh

then run make

After make of the program

Now run src/project1 to run the program

Executed program

And you have your first GUI program on Linux.

Extras:

I would suggest that you try changing various properties like, altering the position of the window, changing the name of the window, name of the project, introduce a toglling effect when you click the button. This will give you a better understanding of the functionality.

The code that you wrote in callbacks.c is essentially GTK code and its homepage here

http://www.gtk.org/

You will need the functions that you can use within callbacks in order to modify the properties of other widgets. A much more elaborate example is in Ishan’s page http://wingtk.sourceforge.net/ishan/glade.html.

When you make a modification to the UI, you will need to save the project and build it again so that the effect is observed in the source code. Also, when you make a change to callbacks.c, you only need to run the make command and then run the program. Keep tweaking the properties of this working program and you will learn lot more.

Enjoy……

Advertisements

viewing flash and mms in firefox

Posted in linux, tweak with tags , on June 15, 2008 by coolarm

f you are a Linux newbie, you may want to read about Wubi (installation) of Ubuntu

https://coolarm.wordpress.com/2008/06/02/linux-for-windows-users-wubi-installation/

———————————————————————————>

Certain things I do to get my Ubuntu into a good shape is to install Flash and MMS plugins for Firefox

Flash – Youtube is a good place to test if the plugin is working fine. It is the easiest of installations. When you attempt to view a video in Youtube, Ubuntu displays a information bar on top. Click to install the missing plugins and you can select the Adobe Flash Player plugin and install the same. When prompted you will need to enter your user password again to perform installation of the software. One way to verify that Shockwave Flash is present in the Plugins tab when you goto Tools->Addons in Firefox. Alternatively you shoudl also be able to perform sudo apt-get install flashplugin-nonfree.

MMS – You could use the streaming video on ibnlive.com to verify the installation. You will need to disable the “VLC Multimedia Plugin” and “Totem Web Brower Plugin” in the Plugins tab of Tools-> Addons in Firefox. I use the mplayer plugin for Mozilla by performing

sudo apt-get install mozilla-mplayer

When you restart Firefox after installing mplayer plugin, you should be able to view the video. To verify this, you should be able to right click on the video area and click Configure to view the mplayer-plugin configuration. If you are seeing anything else, say Totem etc, you will need to uninstall those for Mplayer to show the video.

Enjoy….

keyboard volume control ubuntu not working

Posted in linux, tips with tags , on June 15, 2008 by coolarm

If you are a Linux newbie, you may want to read about Wubi (installation) of Ubuntu

https://coolarm.wordpress.com/2008/06/02/linux-for-windows-users-wubi-installation/

—————————————————————————————————————–

If at all you find the keyboard shortcut to volume control – Fn+Pg Up and Fn+Pg Dn – responding to the key press but not altering the sound level, it most probably that you have tweaked something not knowing what its result would be.

TO restore to normalcy, goto System -> Preferences -> Sounds

Under Default Mixer Tracks select Playback and Master under this and select OK and the key press should now alter the sound level.

If you want to make sure that Playback-Master is the control rightclick on the volume control icon next to the sate and time display and select Open Volume Control. Now modify the controlled stream by selecting in File-> Change Device. You should select the one which alters the sound level.

Windowss like fonts linux

Posted in linux, tips with tags , on June 15, 2008 by coolarm

If you ever thought, the font on your Firefox, Openoffice etc. werent similar to Windowss, here is what you should do

sudo apt-get install msttcorefonts

This will add Times New Roman and likes to your Linux OS. For Firefox, goto Edit-> Preferences

Select Content Tab and then the font as Times New Roman. This will change the appearance on your webpage.

voip and video with gtalk users from linux

Posted in linux, tweak with tags , , on June 15, 2008 by coolarm

If you are a Linux newbie, you may want to read about Wubi (installation) of Ubuntu

https://coolarm.wordpress.com/2008/06/02/linux-for-windows-users-wubi-installation/

—————————————————————————————————————–>

I had been searchign for a solution for the above problem. I came across a bunch of solutions like Landell, Ereseva, Kopete with plugin, TapiocaUI. For one or the other reason, I just couldnt get it working on my system.

Landell, after a number of tries – compilation from source – I would land up in the same problem with some “argument: Null”. I then tried this Ereseva. Poor thing, wouldnt even fire up. Kopete with plugin, is still under build, i guess and TapiocaUI (package) is not available for my amd64 hardy arch. Landell and Ereseva dont seem to have enough support too, from the developers.

Today, I got the solution for the same. EMPATHY(Emphatic atlast) solves your worries.

I am yet to test the voice quality, though it establishes the connection. Also it has a video transmission facility, though I am yet to test it. The advantage is that, packages are available. I got to know of the location from a webpage on UbuntuForums

The instructions are as follows:

Step 1:Add the line

deb http://ppa.launchpad.net/telepathy/ubuntu hardy main

at the end of the file /etc/apt/sources.list       –        This ensures that the above website location is searched for hardy compatible packages when a apt command is issued to install or search for a package

Now run,  sudo apt-get update

Step 2: Now to install the necessary packages

sudo apt-get install empathy
sudo apt-get install telepathy-gabble
sudo apt-get install telepathy-mission-control
sudo apt-get install telepathy-stream-engine

If you dont find any of these packages, you have most likely not added the source properly into the sources

Now goto Applications->Internet-> Empathy Instant Messenger

You should find it open up with the accounts dialog box or it should be minimized to the panel, in which case click on it to restore it. If you are not seeing the Accounts dialog box, goto Edit->Accounts

Provide your complete gmail id, xyz@gmail.com, Password, Enable by checking the Enable box and close. Restart the program and you shoudl see your Buddies. Time to chat

Extra Info:

The following dependencies are automatically installed by apt:

empathy :libempathy-common libempathy-gtk-common libempathy-gtk12 libempathy12
libmissioncontrol-client0 libmissioncontrol-server1 libtelepathy-glib0
libtelepathy2 telepathy-mission-control

telepathy-gabble:  libloudmouth1-0

telepathy-mission-control : is installed in Hardy-Wubi-AMD64-Desktop installation.

telepathy-stream-engine :gstreamer0.10-plugins-farsight libfarsight0.1-3 libgsm1 libjinglebase0.3-0
libjinglep2p0.3-0 libjinglexmllite0.3-0 libjinglexmpp0.3-0
The following packages will be upgraded:
gstreamer0.10-plugins-good

http://live.gnome.org/Empathy is the homepage of Empathy.  The debug isntructions in the webpage, http://live.gnome.org/Empathy/Debugging is also useful. I did use it to understand that “@gmail.com” is essential in the login ID field.

http://ubuntuforums.org/showthread.php?t=819046. This is a thread from where I got to know about the launchpad repository.

Enjoy GTalking….