Book Image

GNOME 3 Application Development Beginner's Guide

By : Mohammad Anwari
Book Image

GNOME 3 Application Development Beginner's Guide

By: Mohammad Anwari

Overview of this book

<p>GNOME is a desktop environment and graphical user interface that runs on top of a computer operating system. GNOME 3 provides both modern desktops and development platforms with more than 50 supported languages of the world. Since 1999, it has been evolving into a very nice desktop to use and an interesting platform to develop on. <br /><br />"GNOME 3 Application Development Beginner's Guide" is about developing GNOME 3 application with Vala and JavaScript programming languages. It guides the reader to build Gtk+, Clutter, and HTML5 applications on the GNOME 3 platform. It covers GNOME 3 specific subsystems such as data access, multimedia, networking, and filesystem. It also covers good software engineering practices such as localization and testing.<br /><br />This book is full of step-by-step tutorials and ready to run codes. The examples are written in a simple and straightforward way&nbsp; to make it easier for the reader to get a thorough understanding of the topics.<br /><br />The book starts with the installation of GNOME 3 and ends with building two exciting projects, a web browser and a Twitter client. The book starts from the basics and gradually talks about more advanced topics.<br /><br />It then guides the readers in using the development environment starts from Anjuta IDE, Glade, and DevHelp. The essential GNOME 3 subsystems like GStreamer, GLib, GIO, GSettings, Evolutions Data Server, WebKit, and GNOME desktop are then uncovered one by one. Then the internationalization, localization, and unit testing techniques are brought up.<br /><br />"GNOME 3 Application Development Beginner's Guide" is really a guide that a novice GNOME 3 application developer must not miss.</p>
Table of Contents (21 chapters)
GNOME 3 Application Development Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – overriding the set_title function


Now let's subclass GtkWindow and imagine that we want to change the behavior of the set_title function of GtkWindow. The function is used to set the window's title with the specified string passed in the argument. The new behavior that we want to introduce here is to always add a special word into the window's title whenever we set the set_title function.

  1. Create a new Vala project called custom-overriding.

  2. In the src/custom_overriding.vala file, use the following code:

    using GLib;
    using Gtk;
    
    public class CustomWindow : Window
    {
      public CustomWindow ()
      {
      }
    
      public new void set_title(string newTitle)
      {
        title = "Custom: " + newTitle;
      }
      
      static int main (string[] args)
      {
        Gtk.init (ref args);
        var window = new CustomWindow ();
        window.set_title ("My window");
        window.show_all ();    
        window.destroy.connect(Gtk.main_quit);      
    
        Gtk.main ();
        
        return 0;
      }
    }
  3. Our JavaScript equivalent code looks...