Wednesday, 18 July 2012

Update on Beginner C Tutorials

If there is one thing to know about programming when you're first starting out, is that you can't truly learn how to program through just memorizing or reading about it from a book. You must practice it, and then continue to practice it...(*cough* forever)...until it sticks in your brain. Seek to understand, not to just memorize the answers.
I'm hoping that the C samples/tutorials I've been working on will be able to benefit newcomers as well as seasoned programmers by giving them that practice.

It has been more than a month since the start of my internship (wow, time flies!). With every sample, comes a new challenge, and something new is always learned. One instance that immediately comes to mind is when, a while back when I worked on the button.c sample, there was an issue involving object ownership. Specifically within this section of code:

  const char *old_label;
  char *new_label; 
  old_label = gtk_button_get_label (button);
  new_label = g_utf8_strreverse (old_label, -1); 
  gtk_button_set_label (button, new_label);
  g_free (new_label);
In this case I created a new char variable named "new_label" in which belongs to me, not the button I had created, and essentially duplicated the button's label and then proceeded to reverse it/replace it. Making sure to "free" the memory afterwards (since the function g_utf8_strreverse returns newly allocated memory). Originally I hadn't created a new label, and had somehow modified the label belonging to the button, in which put my program in risk of crashing. There is always a question of who should "own" a return value of a function in C-based gtk programming, and it is important to keep track of memory to avoid crashes. As Ryan (desrt) put it when he first introduced me to the concept, the rules are as follows (more or less):
- When passing something to a function as an argument, you almost always have to retain ownership of it, it's very rare to have it taken from you.
- Return values from functions can go either way, either you will own the value returned or the function will continue to own it (and you can't modify it).
Furthermore, here is a good blog post (a random resource really) I found that helped explain most of this for me at the time.

I'm hoping to actually create a tutorial within C Beginner Tutorials on this concept, along with examples and lots of goodies. Let me know what you think! Of course suggestions are always welcome.

Now with my test last Monday out of the way, my next goal is to go into overdrive with more C samples! :) 18 down, 23 to go! (I also wish everyone to have a wonderful time at GUADEC!)


Friday, 1 June 2012

Having trouble getting Chrome to work on Fedora 17?

Not sure if this is just me, but I panicked just a bit when I couldn't get my beloved chrome to work on the Fedora partition of my computer. Since it has all of my bookmarks, account information, automatic sign-ins, and all those other luxuries we're used to on the internet all saved into it.

So anyway, here is a bit of code you can type in the terminal that worked for me, I'm sure there are still some loose ends to tie up, but I'm afraid I'm not too experienced to really fill in the gaps. Overall it does open up Chrome and it works just fine so far.

Have fun!


  • wget https://dl-ssl.google.com/linux/linux_signing_key.pub
  • sudo rpm --import linux_signing_key.pub
  • sudo sh -c 'echo "[google] name=Google Chrome 32-bit baseurl=http://dl.google.com/linux/chrome/rpm/stable/i386" >> /etc/yum.repos.d/google.repo'
  • sudo yum install google-chrome-stable
  • sudo yum install libXrender.i686
  • sudo yum install libgtk*
  • sudo yum -y install gtk2.i686 libXScrnSaver.i686
  • sudo yum install libstdc++.i686
  • sudo yum install xulrunner.i686

Thursday, 24 May 2012

Gnome Resources

This is just going to be a blog post for myself that will help me navigate and setup my work environment each time I code. It will be edited with new information as I go along and can be a good source for beginners. 


Table of Contents

1. Compiler Codes
2. Important Resources
3. File Locations
4. Terminal Shortcuts
5. Gnome Shortcuts


Compiler Codes

For C:
gcc filename.c `pkg-config --cflags --libs gtk+-3.0` -o filename
./filename
For Vala:
valac --pkg gtk+-3.0 filename.vala 
./filename
For Python:
python filename.py


Important Resources

Developer Documentation Wiki

Includes: tutorials, checkboard


Simple Git Tutorial

http://spheredev.org/wiki/Git_for_the_lazy


Html, CSS, XML Tutorials

http://www.w3schools.com/html/html_css.asp


Devhelp online

http://developer.gnome.org/gtk3/stable/


Location of Certain Files

Pages

/gnome-devel-docs/platform-demos/C/

Samples

/gnome-devel-docs/platform-demos/C/samples/

Media/Images

/gnome-devel-docs/platform-demos/C/media/


Terminal Shortcuts


sudo yum update -- updates linux

yelp <page file>--shows page
gedit <filename>--shows file in gedit ("notepad program")

cd .. --goes back to previous directory
cd <directory item> --change directory
ls -- shows everything in current directory
pwd --present working directory
ctrl + c --cancel current action in terminal
tab -- completes the rest of the command
mkdir <folder name> -- creates a new folder

fpaste <filename> -- pastes your code to fpaste

Gnome Shortcuts


ctrl + alt +shift + down/up -- moves current window to the workspace below or above
ctrl + alt + down/up -- navigates to the workspace below or above
clicking on name in top right + later holding alt -- shows the shut off option!

Wednesday, 16 May 2012

The Beginning

Hello there, my name is Monica Kochofar, and I'm a new intern for the GNOME Outreach Program for Women!

I cannot express my level of excitement for this tidbit. Sure I'm a little late to the blogging party, but I'm finally getting the time to explore more and start this blog on my endeavours. Everyone is really nice and willing to help, I can tell that this is going to be a great summer :) 

So far I've been learning about my project from the wonderfully awesome Tiffany Antopolski, my mentor. My internship is going to be working on Developer Documentation for C. I'm going to be creating tutorials and code samples in gtk 3 for the community's reference. My work in preparation has involved (including my work for the initial contribution):
I have to admit that I may have felt overwhelmed when trying to get adjusted to this entirely new area (for me anyway). Luckily, it's a lot easier than it looks, and I have to say my mentor does a great job in allowing me to learn step-by-step.
 
Until next time !