~ubuntu-branches/ubuntu/quantal/elinks/quantal

« back to all changes in this revision

Viewing changes to src/ecmascript/spidermonkey/unibar.c

  • Committer: Bazaar Package Importer
  • Author(s): Siegfried-Angel Gevatter Pujals (RainCT)
  • Date: 2008-02-01 16:29:06 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080201162906-xdourui5tyjva0al
Tags: 0.11.3-5ubuntu1
 
* Merge from Debian unstable (LP: #187936); remaining changes:
  - Add X-Ubuntu-Gettext-Domain to .desktop files.
  - debian/control: Maintainer field update.
* Improve the text in the .desktop file and add some translations.
 

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include "document/view.h"
24
24
#include "ecmascript/ecmascript.h"
25
25
#include "ecmascript/spidermonkey/unibar.h"
 
26
#include "ecmascript/spidermonkey/window.h"
26
27
#include "intl/gettext/libintl.h"
27
28
#include "main/select.h"
28
29
#include "osdep/newwin.h"
47
48
static JSBool unibar_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp);
48
49
static JSBool unibar_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp);
49
50
 
 
51
/* Each @menubar_class object must have a @window_class parent.  */
50
52
const JSClass menubar_class = {
51
53
        "menubar",
52
 
        JSCLASS_HAS_PRIVATE,
 
54
        JSCLASS_HAS_PRIVATE,    /* const char * "t" */
53
55
        JS_PropertyStub, JS_PropertyStub,
54
56
        unibar_get_property, unibar_set_property,
55
57
        JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
56
58
};
 
59
/* Each @statusbar_class object must have a @window_class parent.  */
57
60
const JSClass statusbar_class = {
58
61
        "statusbar",
59
 
        JSCLASS_HAS_PRIVATE,
 
62
        JSCLASS_HAS_PRIVATE,    /* const char * "s" */
60
63
        JS_PropertyStub, JS_PropertyStub,
61
64
        unibar_get_property, unibar_set_property,
62
65
        JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
69
72
};
70
73
 
71
74
 
 
75
/* @menubar_class.getProperty, @statusbar_class.getProperty */
72
76
static JSBool
73
77
unibar_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
74
78
{
75
 
        JSObject *parent = JS_GetParent(ctx, obj);
76
 
        struct view_state *vs = JS_GetPrivate(ctx, parent);
77
 
        struct document_view *doc_view = vs->doc_view;
78
 
        struct session_status *status = &doc_view->session->status;
79
 
        unsigned char *bar = JS_GetPrivate(ctx, obj);
 
79
        JSObject *parent_win;   /* instance of @window_class */
 
80
        struct view_state *vs;
 
81
        struct document_view *doc_view;
 
82
        struct session_status *status;
 
83
        unsigned char *bar;
 
84
 
 
85
        /* This can be called if @obj if not itself an instance of either
 
86
         * appropriate class but has one in its prototype chain.  Fail
 
87
         * such calls.  */
 
88
        if (!JS_InstanceOf(ctx, obj, (JSClass *) &menubar_class, NULL)
 
89
         && !JS_InstanceOf(ctx, obj, (JSClass *) &statusbar_class, NULL))
 
90
                return JS_FALSE;
 
91
        parent_win = JS_GetParent(ctx, obj);
 
92
        assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
 
93
        if_assert_failed return JS_FALSE;
 
94
 
 
95
        vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
 
96
        doc_view = vs->doc_view;
 
97
        status = &doc_view->session->status;
 
98
        bar = JS_GetPrivate(ctx, obj); /* from @menubar_class or @statusbar_class */
80
99
 
81
100
        if (!JSVAL_IS_INT(id))
82
101
                return JS_TRUE;
101
120
#undef unibar_fetch
102
121
                break;
103
122
        default:
104
 
                INTERNAL("Invalid ID %d in unibar_get_property().", JSVAL_TO_INT(id));
 
123
                /* Unrecognized property ID; someone is using the
 
124
                 * object as an array.  SMJS builtin classes (e.g.
 
125
                 * js_RegExpClass) just return JS_TRUE in this case
 
126
                 * and leave *@vp unchanged.  Do the same here.  */
105
127
                break;
106
128
        }
107
129
 
108
130
        return JS_TRUE;
109
131
}
110
132
 
 
133
/* @menubar_class.setProperty, @statusbar_class.setProperty */
111
134
static JSBool
112
135
unibar_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
113
136
{
114
 
        JSObject *parent = JS_GetParent(ctx, obj);
115
 
        struct view_state *vs = JS_GetPrivate(ctx, parent);
116
 
        struct document_view *doc_view = vs->doc_view;
117
 
        struct session_status *status = &doc_view->session->status;
118
 
        unsigned char *bar = JS_GetPrivate(ctx, obj);
 
137
        JSObject *parent_win;   /* instance of @window_class */
 
138
        struct view_state *vs;
 
139
        struct document_view *doc_view;
 
140
        struct session_status *status;
 
141
        unsigned char *bar;
 
142
 
 
143
        /* This can be called if @obj if not itself an instance of either
 
144
         * appropriate class but has one in its prototype chain.  Fail
 
145
         * such calls.  */
 
146
        if (!JS_InstanceOf(ctx, obj, (JSClass *) &menubar_class, NULL)
 
147
         && !JS_InstanceOf(ctx, obj, (JSClass *) &statusbar_class, NULL))
 
148
                return JS_FALSE;
 
149
        parent_win = JS_GetParent(ctx, obj);
 
150
        assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
 
151
        if_assert_failed return JS_FALSE;
 
152
 
 
153
        vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
 
154
        doc_view = vs->doc_view;
 
155
        status = &doc_view->session->status;
 
156
        bar = JS_GetPrivate(ctx, obj); /* from @menubar_class or @statusbar_class */
119
157
 
120
158
        if (!JSVAL_IS_INT(id))
121
159
                return JS_TRUE;
135
173
                register_bottom_half(update_status, NULL);
136
174
                break;
137
175
        default:
138
 
                INTERNAL("Invalid ID %d in unibar_set_property().", JSVAL_TO_INT(id));
 
176
                /* Unrecognized property ID; someone is using the
 
177
                 * object as an array.  SMJS builtin classes (e.g.
 
178
                 * js_RegExpClass) just return JS_TRUE in this case.
 
179
                 * Do the same here.  */
139
180
                return JS_TRUE;
140
181
        }
141
182