GNOME 3 Application Development Beginner's Guide Step-by-step practical guide to get to grips with GNOME application development Mohammad Anwari BIRMINGHAM - MUMBAI GNOME 3 Application Development Beginner's Guide Copyright © 2013 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: February 2013 Production Reference: 1080213 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-84951-942-7 www.packtpub.com Cover Image by Duraid Fatouhi ([email protected]) Credits Author Project Coordinator Mohammad Anwari Abhishek Kori Reviewers Proofreader Dhi Aurrahman Mario Cecere Joaquim Rocha Indexer Acquisition Editor Tejal Soni Mary Jasmine Graphics Lead Technical Editor Aditi Gajjar Ankita Shashi Production Coordinator Technical Editors Aparna Bhagat Charmaine Pereira Cover Work Dominic Pereira Aparna Bhagat Copy Editors Laxmi Subramanian Aditya Nair Alfida Paiva Ruta Waghmare Insiya Morbiwala About the Author Mohammad Anwari is a software hacker from Indonesia with more than 13 years of experience in software development. He has been working with Linux-based systems, applications in GNOME, and Qt platforms. The projects he has worked on range from the development of constrained devices and desktop applications, to high traffic server systems and applications. He worked for his own startup company during the dotcom era before moving to Finland to work for Nokia/MeeGo. Now he's back in Indonesia, regaining his entrepreneurship by establishing a new startup company that focuses on Node.js and Linux-based projects. In his free time, he serves as an executive director for BlankOn, one of the biggest open source projects in Indonesia. In the past, he has published a couple of books on Linux in the Indonesian language. This book would have been impossible to write without the great and continuous support from my family: Rini, Alif, and Abil. About the Reviewers Dhi Aurrahman is a Project Manager at Labtek Indie, where he leads the development of custom-tailored interactive applications for various installations and platforms. Prior to this, he worked on various projects based on real-time computer vision systems with Samsung Electronics in South Korea. He has proven skills in C++ programming; application development using Qt for various platforms, including desktop and mobile; and JavaScript programming. Dhi has done his B.Sc in Computational Physics from Bandung Institute of Technology, Indonesia, and his M.Eng in Computer Engineering, focused on computer vision and machine learning, from Chonnam National University, South Korea. Joaquim Rocha is a Portuguese software developer with an M.Sc. degree in Computer Science. He has over six years of experience in developing graphical user interfaces and has been involved in a number of Free Software projects. He is also a member of the GNOME Foundation and is the author of the most complete OCR application, OCRFeeder, which was developed for the GNOME desktop. As part of his work for the Free Software consultancy Igalia, Joaquim has created the world's first Free Software skeleton-tracking library, completely written with GNOME technologies. www.PacktPub.com Support files, eBooks, discount offers and more You might want to visit www.PacktPub.com for support files and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version atwww.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. TM http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. Why Subscribe? Fully searchable across every book published by Packt Copy and paste, print and bookmark content On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access. Table of Contents Preface 1 Chapter 1: Installing GNOME 3 and SDK 7 System requirements 8 The GNOME Shell 8 GNOME Panel/Fallback 8 Development requirements 9 GNOME 3 desktop architecture 9 GNOME and the SDK 12 Time for action – installing GNOME and SDK in Fedora 17 12 Marking packages to be installed 14 Ready to install the packages 15 Time for action – installing GNOME and SDK in openSUSE 12 15 Marking SDK packages 17 Starting the installation 18 Time for action – installing GNOME and SDK in Debian Testing 18 Marking SDK packages 19 Applying the installation 20 Time for action – installing GNOME and SDK in Ubuntu 12.04 20 Continue installing the SDK 21 Summary 21 Chapter 2: Preparing Our Weapons 23 Firing up Anjuta 24 Time for action – creating a new Vala project 24 The IDE layout 25 Bookmarks 26 Files 26 Project 26 Symbols 26 Watches 26 Table of Contents Breakpoints 26 Messages 26 Terminal 27 Navigation between tabs 27 Time for action – navigating between tabs 27 Comment block 28 Time for action – commenting/uncommenting a block 28 Time for action – running the program for the first time 29 Make an error and see how it works 32 Editing UI 33 Time for action – editing UI 33 Palette 34 Widgets 34 Time for action – adding a label and a button 35 Time for action – changing widget properties 36 A responsive button 37 Time for action – making the button responsive 37 Tracking symbols 40 Time for action – finding a symbol 40 Getting help 41 Summary 41 Chapter 3: Programming Languages 43 Programming GNOME with JavaScript 44 Time for action – saying hello to Seed 44 Time for action – running our program with Seed 45 Loosely typed language 47 Time for action – playing with data types 47 Controlling iteration 49 Time for action – controlling Iteration 49 Time for action – manipulating an array 51 Object-oriented programming (OOP) with JavaScript 52 Time for action – using the JavaScript object 52 With great power comes great responsibility 54 Constructing objects 54 Time for action – playing with constructors 55 Class and object 56 Using prototypes 56 Time for action – adding prototypes 57 Time for action – modifying the prototype of an object 59 Modularization 61 Time for action – modularizing our program 61 [ ii ] Table of Contents Getting to know Vala 63 Time for action – entry point to our program 64 Member access specifier 65 Time for action – defining member access 65 The access specifiers 68 Basic data types 68 Time for action – experiment with data types 68 Gee, what is it? 71 Time for action – adding the Gee library 71 Time for action – Gee in action 72 Initializing members when declaring 75 Time for action – watching for signals 75 Summary 78 Chapter 4: Using GNOME Core Libraries 79 Before we start 80 The GLib main loop 80 Time for action – playing with the GLib main loop 80 GObject signals 84 Time for action – handling GObject signals 84 GLib properties 86 Time for action – accessing properties 86 Configuration files 91 Time for action – reading configuration files 91 GIO, the input/output library 94 Time for action – accessing files 94 Network access with GIO 97 Time for action – accessing a network 98 Understanding GSettings 102 Time for action – learning GSettings 102 GSettings API 103 Time for action – accessing GSettings programmatically 104 Summary 106 Chapter 5: Building Graphical User Interface Applications 107 Before we start 107 Creating a basic GTK+ application 108 Time for action – implementing the mockup 109 Time for action – adding icons to the buttons 115 Porting the code without GtkBuilder 117 Time for action – programming with raw GTK+ 117 GUI programming with Clutter 121 [ iii ] Table of Contents Time for action – implementing the mockup with Clutter 121 Summary 129 Chapter 6: Creating Widgets 131 Before we take off 132 Overriding the widget's standard functions 132 Time for action – overriding the set_title function 132 Adding new functionalities 136 Time for action – making a composite widget 136 Maintaining compatibility 144 Implementing a GTK+ custom widget 144 Time for action – implementing the custom widget 145 Maintaining widgets in a library 151 Time for action – creating a library 152 Summary 157 Chapter 7: Having Fun with Multimedia 159 Packages required 159 Understanding the basic
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages366 Page
-
File Size-