Preferences for fonts in editor

Bug #1018255 reported by Izidor Matušov on 2012-06-27
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Getting Things GNOME!
Medium
Abhiram

Bug Description

Allow users to choose font they want for the editor.

This is a typical LOVE bug for new GTG contributors. Steps to solve it
  * add new configuration option in GTG config files by adding a new default value
    in GTG/config/__init__.py and DEFAULTS dict
  * add widget into Preferences dialog
     - edit GTG/gtk/preferences.glade file using GLADE and add a widget for selecting
       font
     - update configuration when the user changes the font widget, see the existing code
       in GTG/gtk/preferences.py
  * set font, you can find the code in this question:
    https://answers.launchpad.net/gtg/+question/166141
     - apply patch suggested from that question and instead of the literal value get
       the value from configuration object

Related branches

Izidor Matušov (izidor) on 2012-06-27
Changed in gtg:
importance: Undecided → Medium
Abhiram (abhiram-ampabathina) wrote :

Hello izidor,
                                I would like to try on this one. Although i have completed the earlier one you gave me(there are issues with uploading). Mean while i would like to try this bug. Please guide me how.

Best,
Abhiram

Izidor Matušov (izidor) wrote :

Hi Abhiram,

I've updated the description. It contains now all needed steps to solve this bug. If you have even further questions, feel free to ask - IRC is more interactive than mail/issue tracker. :)

description: updated
Abhiram (abhiram-ampabathina) wrote :

Hello izidor,
                                I would like to work on more bugs, to discover more about GTG. I choose this one. I am trying to make changes in the prefernces.glade file first. How shall the glade file look after changing. Do you want me to add another section called "Editor" (like "Startup" and "Task Browser"), and then give options to change the font size.

Tell me how shall it be.

Best,
Abhiram

Abhiram (abhiram-ampabathina) wrote :

Hello izidor,
                           Changed the combo box to font button. Here is the snapshot. http://imagebin.org/222731 . I hope that is ok now. Now shall i update the preferences.py file and add the font button action also?

Best,
Abhiram

Abhiram (abhiram-ampabathina) wrote :

Hello izidor,
                             I also have made some changes to preferences.py > please check them and tell me the adjustments. I have initialized it and called a method the "font-set" signal is called. And after that storing the font name in the config.

http://pastebin.com/raw.php?i=ge50Mpkm

Best,
Abhiram

Abhiram (abhiram-ampabathina) wrote :

Hello again,
                             By the by , there is no folder called "config" where can we find the config file ? In general what does the config file do to get the changes(general question) . I mean its interesting and also its time learn more about the architecture of GTG. If you have some time , i would like to few things(main core architecture of GTG). Things like how the data is stored and like that. Or else if there are is separate documentation for the entire GTG (or) video tutorials of them, anything please let me know. I would like improve my knowledge of GTG architecture.

Best,
Abhiram

Izidor Matušov (izidor) on 2012-07-31
Changed in gtg:
assignee: nobody → Abhiram (abhiram)
status: Triaged → In Progress
Izidor Matušov (izidor) wrote :

Hi Abhiram,

could you please push your branch on launchpad and then link to this bug? It would make things simplier.

Your screenshot looks good. Your patch seems to me quite good, I have some nitpicking :) The configuration is stored in GTG/core/__init__.py -> the file you worked with in your last patch. Unfortunately, there is no proper documentation for GTG. If you want, you can contribute page on our wiki: http://live.gnome.org/gtg

I am still at GUADEC conference, I should be back at home tomorrow evening or on Aug 2, you can catch me on IRC.

Izido

Abhiram (abhiram-ampabathina) wrote :

Hello izidor,
               I have linked the branch to the bug. The changes made are in GTG/gtgk/preferences.glade and GTG/gtgk/preferences.py . Have a look at the code and review it. If it is good i will add the line in editor.py to modify the font .

[Personal Interest] : What is the conference GUADEC all about ?

Best,

Abhiram

Izidor Matušov (izidor) on 2012-08-02
Changed in gtg:
assignee: Abhiram (abhiram) → nobody
assignee: nobody → Abhiram (abhiram-ampabathina)
Izidor Matušov (izidor) wrote :

Abhiram,

You can drop "self._refresh_task_browser()" - you can drop this line. Also method/variable get_font_name is not defined, you should replace it with an actual code. I'll be available at IRC during next days.

GUADEC is a conference of advanced users and developers of GNOME. You can meet people in person, talk to them, attend talks and hackfests, and of course, enjoy summer weather.

Abhiram (abhiram-ampabathina) wrote :

Hello izidor,
              The method det_font_name() is from pygtk. We call the method for getting the selected font name. I have imported the pygtk and called from that one. Is it ok? I think by this method we should get the selected font .

Best

Abhiram (abhiram-ampabathina) wrote :

Hello izidor,
                I did the same thing you described above. I changed the preferences.glade file. I updated the preferences.py file . I updated the editor.py . And i added a default value to the core/init.py > Instead of the literal in the "self.textview.modify_font(pango.FontDescription('sans bold 15'))" . I added as "self.textview.modify_font(pango.FontDescription(self.config.get(font_name)))" , where as the problem lies here. It say that no global variable font_name is existing. My question is how do we get the config variable font_name from which we have set it in preferences.py

Error :

  File "/home/abhi/mygtg/gtg/GTG/gtk/editor/editor.py", line 106, in __init__
    self.textview.modify_font(self.config.get(font_name))
NameError: global name 'font_name' is not defined

Best

Abhiram (abhiram-ampabathina) wrote :

Hello izidor,
                   I do not know why, but it do not get the modified font. Please once check my code and the changes in preferences.py, editor.py and init.py . I am can say that the code in editor.py and init.py is correct. But i am not sure in preferences.py . I am really not sure that the code in preferences.py is correct to update the fontbutton widget. If have a idea, please have a look at it.

Best

Abhiram (abhiram-ampabathina) wrote :

Hello izidor,
              Do you have time for new contributers (like me) to explain the main architecture of GTG. As it would help us a lot more. Like a small hangout in google + for a while. Purely for knowledge.

Best,
Abhiram

Izidor Matušov (izidor) wrote :

Hello Abhiram,

your event font_button1_font_set is not defined in GLADE file and it also means your callback changing the configuration is not run. Please, define it.

Also, I got following warning:
"GtkWarning: Unknown property: GtkFontButton.preview-text"

You should setup the preview text in the glade file.

We can talk about GTG architecture, but you don't need that now. You are doing just few small changes and you know which files to touch.

Abhiram (abhiram-ampabathina) wrote :

Hello izidor,
                     I have defined the event font_button1_font_set in the glade file. It seems that it is working untill the signal. That is when we change the font a signal gets and event is called. But is get the type error.

TypeError: on_font_change() takes exactly 1 argument (2 given)

This is the method that i have called after getting a successful signal. But it says 2 arguments are given where as i have given none.

What could be the reason ? Any ideas please let me know.

I have updated the preferences.glade file too.

Best

Abhiram (abhiram-ampabathina) wrote :

Hello izidor,
                             Never mind. I got my mistake. I fixed everything. And also the font is now showing up for the editor. You can test my code . The files updated are

preferences.py : http://bazaar.launchpad.net/~abhiram-ampabathina/gtg/gtg/view/head:/GTG/gtk/preferences.py
preferences.glade : http://bazaar.launchpad.net/~abhiram-ampabathina/gtg/gtg/view/head:/GTG/gtk/preferences.glade
editor.py : http://bazaar.launchpad.net/~abhiram-ampabathina/gtg/gtg/view/head:/GTG/gtk/editor/editor.py
init.py : http://bazaar.launchpad.net/~abhiram-ampabathina/gtg/gtg/view/head:/GTG/core/__init__.py

The code can be branched from this command.
bzr branch lp:~abhiram-ampabathina/gtg/gtg

This time i made the code neat. If you still have got some nitpicking let me know , i will full fill them too.

Best

Abhiram (abhiram-ampabathina) wrote :

Hello izidor,
                    Sorry to disturb you. I just want to know whether you are getting my messages or not.

Best

Izidor Matušov (izidor) on 2012-08-08
Changed in gtg:
status: In Progress → Confirmed
status: Confirmed → Fix Committed
milestone: 0.4 → 0.3
Changed in gtg:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers