~ubuntu-branches/ubuntu/natty/lua-gtk/natty

« back to all changes in this revision

Viewing changes to src/pango/override.c

  • Committer: Bazaar Package Importer
  • Author(s): Enrico Tassi
  • Date: 2009-05-17 18:16:21 UTC
  • mfrom: (1.2.1 upstream) (4.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090517181621-9kmdd82nxg54jsio
* new upstream snapshot comprising many more GNOME libraries:
    Gtk, GDK, GLib, Pango, Atk, Libxml2, Cairo, Clutter, Gtkhtml, 
    GtkSourceView, Gio, Gtkspell and GConf. 
* new upstream release includes a new configure script written in Lua,
  no more bashisms there (Closes: #507205)
* renamed binary packages to liblua5.1-gnome-*
* updated standards-version to 3.8.1, no changes needed
* patch to load .so.* version of libraries and not .so (that was requiring
  -dev packages) (Closes: #522087)
* removed redundant Architecture line from the source stanza of control
  (Closes: #498120)
* updated copyright file, Wolfgang Oertl holds it for 2009 too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// vim:sw=4:sts=4
 
2
 
 
3
#include <pango/pango.h>
 
4
#include "module.h"
 
5
#include "override.h"
 
6
#include <string.h>         // strcmp
 
7
#include <errno.h>          // errno
 
8
 
 
9
// the output array size isn't easily determined.
 
10
static int l_pango_tab_array_get_tabs(lua_State *L)
 
11
{
 
12
    OBJECT_ARG(tab_array, PangoTabArray, *, 1);
 
13
    int t2, t3, i, n;
 
14
 
 
15
    PangoTabAlign *alignments = NULL;
 
16
    gint *locations = NULL;
 
17
 
 
18
    t2 = lua_type(L, 2);
 
19
    luaL_argcheck(L, t2 == LUA_TNIL || t2 == LUA_TTABLE, 2, "nil or table");
 
20
 
 
21
    t3 = lua_type(L, 3);
 
22
    luaL_argcheck(L, t3 == LUA_TNIL || t3 == LUA_TTABLE, 3, "nil or table");
 
23
 
 
24
    n = pango_tab_array_get_size(tab_array);
 
25
 
 
26
    pango_tab_array_get_tabs(tab_array, t2 == LUA_TNIL ? NULL : &alignments,
 
27
        t3 == LUA_TNIL ? NULL : &locations);
 
28
 
 
29
    // copy the values to the table
 
30
    if (alignments) {
 
31
        api->empty_table(L, 2);
 
32
        typespec_t ts = api->find_struct(L, "PangoTabAlign", 0);
 
33
        for (i=0; i<n; i++) {
 
34
            api->push_constant(L, ts, alignments[i]);
 
35
            lua_rawseti(L, 2, i + 1);
 
36
        }
 
37
        g_free(alignments);
 
38
    }
 
39
 
 
40
    if (locations) {
 
41
        api->empty_table(L, 3);
 
42
        for (i=0; i<n; i++) {
 
43
            lua_pushnumber(L, locations[i]);
 
44
            lua_rawseti(L, 3, i + 1);
 
45
        }
 
46
        g_free(locations);
 
47
    }
 
48
 
 
49
    return 0;
 
50
}
 
51
 
 
52
FSO(pango_attr_iterator_get_attrs, GSLIST_FREE_PANGO_ATTR);
 
53
FSO(pango_glyph_item_apply_attrs, GSLIST_FREE_PANGO_GLYPH);
 
54
 
 
55
 
 
56
#if 0
 
57
static int l_pango_attr_iterator_get_font(lua_State *L)
 
58
{
 
59
    int rc = api->call_byname(L, "pango_attr_iterator_get_font");
 
60
    // XXX this is an optional return value... where is it on the stack?
 
61
    struct object *w = (struct object*) lua_touserdata(L, WHATEVER);
 
62
    w->flags = GSLIST_FREE_PANGO_ATTR;
 
63
    return rc;
 
64
}
 
65
#endif
 
66
 
 
67
// strangely enough, these functions are actually defined in GDK
 
68
static int l_pango_layout_get_clip_region(lua_State *L)
 
69
{
 
70
    return api->call_function(L, "gdk", "gdk_pango_layout_get_clip_region");
 
71
}
 
72
 
 
73
// strangely enough, these functions are actually defined in GDK
 
74
static int l_pango_layout_line_get_clip_region(lua_State *L)
 
75
{
 
76
    return api->call_function(L, "gdk",
 
77
        "gdk_pango_layout_line_get_clip_region");
 
78
}
 
79
 
 
80
const luaL_reg pango_overrides[] = {
 
81
    OVERRIDE(pango_tab_array_get_tabs),
 
82
    OVERRIDE(pango_attr_iterator_get_attrs),
 
83
    OVERRIDE(pango_glyph_item_apply_attrs),
 
84
    OVERRIDE(pango_layout_get_clip_region),
 
85
    OVERRIDE(pango_layout_line_get_clip_region),
 
86
    { NULL, NULL }
 
87
};
 
88
 
 
89