GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Oct 13, 2015 7:16 am

All times are UTC

Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: GTK+3 , Python, Vte, gpointer, 'decrease-font-size'
PostPosted: Wed Jun 12, 2013 12:41 pm 

Joined: Tue Jun 11, 2013 11:37 pm
Posts: 2
I want to change the font size of a terminal with Vte. The doc says something like:
terminal.connect('decrease-font-size', gpointer user data)
Whats a gpointer? How can I use this correctly?

Here is the code:

from gi.repository import Gtk, Vte, Gdk
from gi.repository import GLib
import os

class TableWindow(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self, title="shells")
        self.resize(600, 400)

        table = Gtk.Table(2, 2, True)
        palette = [Gdk.color_parse('red')] * 16
        terminal1 = Vte.Terminal()
        terminal2 = Vte.Terminal()
        terminal3 = Vte.Terminal()
        terminal4 = Vte.Terminal()
        scrolledwindow1 = Gtk.ScrolledWindow()
        scrolledwindow2 = Gtk.ScrolledWindow()
        scrolledwindow3 = Gtk.ScrolledWindow()
        scrolledwindow4 = Gtk.ScrolledWindow()
        terminal1.fork_command_full(Vte.PtyFlags.DEFAULT, os.environ['HOME'], ["/bin/sh"],
                                       [], GLib.SpawnFlags.DO_NOT_REAP_CHILD, None, None)
        terminal2.fork_command_full(Vte.PtyFlags.DEFAULT, os.environ['HOME'], ["/bin/sh"],
                                       [], GLib.SpawnFlags.DO_NOT_REAP_CHILD, None, None)
        terminal3.fork_command_full(Vte.PtyFlags.DEFAULT, os.environ['HOME'], ["/bin/sh"],
                                       [], GLib.SpawnFlags.DO_NOT_REAP_CHILD, None, None)
        terminal4.fork_command_full(Vte.PtyFlags.DEFAULT, os.environ['HOME'], ["/bin/sh"],
                                       [], GLib.SpawnFlags.DO_NOT_REAP_CHILD, None, None)
        terminal1.set_colors(Gdk.color_parse('red'), Gdk.color_parse('black'), palette)
        terminal2.set_colors(Gdk.color_parse('yellow'), Gdk.color_parse('black'), palette)
        terminal3.set_colors(Gdk.color_parse('green'), Gdk.color_parse('black'), palette)
        terminal4.set_colors(Gdk.color_parse('blue'), Gdk.color_parse('black'), palette)
        table.attach(scrolledwindow1, 0, 1, 0, 1)
        table.attach(scrolledwindow2, 1, 2, 0, 1)
        table.attach(scrolledwindow3, 0, 1, 1, 2)
        table.attach(scrolledwindow4, 1, 2, 1, 2)
win = TableWindow()
win.connect("delete-event", Gtk.main_quit)


 Post subject: Re: GTK+3 , Python, Vte, gpointer, 'decrease-font-size'
PostPosted: Wed Jun 12, 2013 4:34 pm 
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 915
Location: UK

A gpointer is just a general pointer and used in signal call-back functions to pass user data around. Under C it is defined as
typedef void * gpointer;

Under other language bindings the gpointer is generally not exposed to the API of the binding and the passing of extra parameters or class data is done by the binding often using the gpointer user_data.

The signal that you mentioned actually does not do the resizing of the text. All it does is call a call-back function when the user request the size to be made smaller. The C functions that you need is
void                vte_terminal_set_font               (VteTerminal *terminal,
                                                         const PangoFontDescription *font_desc);


 Post subject: Re: GTK+3 , Python, Vte, gpointer, 'decrease-font-size'
PostPosted: Wed Jun 12, 2013 7:30 pm 

Joined: Tue Jun 11, 2013 11:37 pm
Posts: 2
Hi errol, thx for reply :)

I did something like

import pango
font = pango.FontDescription()

But I get:

/usr/lib/python2.7/dist-packages/gobject/ Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  import gobject._gobject
Traceback (most recent call last):
  File "", line 57, in <module>
    win = MainWindow()
  File "", line 24, in __init__
  File "/usr/lib/python2.7/dist-packages/gi/", line 43, in function
    return info.invoke(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/gi/", line 76, in load_module
  File "/usr/lib/python2.7/dist-packages/gi/", line 224, in _load
    overrides_modules = __import__('gi.overrides', fromlist=[self._namespace])
  File "/usr/lib/python2.7/dist-packages/gi/overrides/", line 33, in <module>
    Context = override(Context)
  File "/usr/lib/python2.7/dist-packages/gi/overrides/", line 63, in override
  File "/usr/lib/python2.7/dist-packages/gi/overrides/", line 38, in register
    self[override_class] = override_class
  File "/usr/lib/python2.7/dist-packages/gi/overrides/", line 20, in __setitem__
    info = getattr(value, '__info__')
AttributeError: type object 'Context' has no attribute '__info__'

Hhhm, can you give me a hint what this means??

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group