A good geek always keeps a terminal window running.
Long time haven’t blogged, you know
I don’t like writing too much
.
but recently I was playing with the python-twitter module, I learned how to use it, and I’ve coded a simple small twitter status updater script, I have used it in a cool trick “update twitter status by the now playing song”, I used the “song change” plug-in in audacious to execute a command that uses the script to update twitter status by this form”#NowPlaying <title> by <artist>”, And you can use it however you want!, Not just for audacious, that’s what I call “The coding Awesomeness
“, Now I’m going to write 2 posts, the first is about the module and how to use it (a quick tutorial) and how to use the twitter api the second one is about the status update script and how to integrate it with audacious!
Keep in touch!
See ya!
As if it could be any other way, the just-announced Samsung Galaxy S 4 is Samsung's, and perhaps even Android's, best phone yet. In fact, it very well may be the best smartphone on the market, period.
We've been through months of speculation, hype, rumors, and leaks, but the truth is out, and the Galaxy S 4 still has much more up its sleeve than the leaks suggested.
The clock clacked 11 times and I was sleepy. I just leaned back in my chair, one of the symptoms of me going to bed. Suddenly a notification swiped left from the top of my screen. That chirpy sound, it made, made me half-awake. The description in it made my eyes open wide. My eyebrows came closer and my vision got sharper.
Since I started making themes for Nokia C3, many people ask how do I make these themes. Most people find the same problem, they can not find an option for 320x240 screen in the software even carbide. It is not yet available plugins for 320 x 240 screen although in fact already available plugin for Nokia C3, ie Plugins Compact. This is probably because Nokia C3 runs on Series 40 Java operating systems sixth edition and the only phone with a 320 x 240 screen that runs on these operating systems.
Today, I’m going to show you how to code a simple and small Glade interface application in Vala using Gtk.builder.
Special thanks for my friend Ahmed Shams. He helps me a lot
Every Glade program consists of two files: the glade UI file and the program (the code) itself.
Glade uses a simple method to connect with the code while Glade uses signals to tell the code that the user interacted with a widget (clicked, hovered, selected etc…)
For example: when we create a button, In glade side we attach a signal to it, ex:”clicked”, in the code side we will use something like “when signal button_clicked received: do something” Got it?
First, we will use Glade to build our simple UI that will be used in our program.
If you haven’t installed glade yet, install it using:
sudo apt-get install glade
Then run it and start designing your UI, Firstly start with a top-level container.
In our case we will create a simple window that contains one button and a Text-Entry, We will make the button to return (when clicked) the text which typed in the text-entry widget.
Now, Open up glade and create your window:
Then, Edit the window’s destroy signal from signals tab in widgets properties section, type a name for signal that you can use in the code, in our case we will name our signal “on_window1_destroy”
Then, We are going to insert a box (container) to add widgets within it.
Then, We’ll insert our widgets:
You can change the properties of a widget through the widget proprieties section at right (change its label etc..)
Then, We are going to edit the “clicked” signal and name it “on_button1_clicked”
And we’re done!
now save the glade file in the project’s directory, name it “sample.ui”.
Now your glade file should be something looking like this:
http://paste.ubuntu.com/5574595/
Now, it’s the code’s time!, try to understand this code, then save it in the project’s directory as “example.vala” and compile it using:
valac --pkg gtk+-3.0 --pkg gmodule-2.0 example.vala
and here’s our code:
using Gtk;
/* When button click signal received */
public void on_button1_clicked (Button source) {
/* change button label to clicked! */
source.label = "Clicked!";
stderr.printf ("Clicked! --> ");
}
public void on_window1_destroy (Window source) {
/* When window close signal received */
Gtk.main_quit ();
}
int main (string[] args) {
Gtk.init (ref args);
var builder = new Builder ();
/* Getting the glade file */
builder.add_from_file ("sample.ui");
builder.connect_signals (null);
var window = builder.get_object ("window1") as Window;
var entry = builder.get_object ("entry1") as Entry;
var button = builder.get_object ("button1") as Button;
/* thats another way to do something when signal received */
button.clicked.connect (() => {
stderr.printf ("%s\n", entry.get_text ());
});
window.show_all ();
Gtk.main ();
return 0;
}
Now you are ready to try your first Vala/Glade app, just run it using
./example
Thanks! Hope this tutorial be helpful for you
Ubuntu Developer Week Starts Tomorrow | OMG! Ubuntu!.
I’m Very excited about it, Be sure to don’t miss it
I’ve been waiting for it long time ago, and here is it
I’ve created a reminder in my calendar to be sure to do not miss it
see ya at #ubuntu-classroom on irc.freenode.com