OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [native/] [jni/] [gtk-peer/] [gnu_java_awt_peer_gtk_GtkMenuItemPeer.c] - Blame information for rev 774

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 774 jeremybenn
/* gtkmenuitempeer.c -- Native implementation of GtkMenuItemPeer
2
   Copyright (C) 1999 Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
 
39
#include "gtkpeer.h"
40
#include "gnu_java_awt_peer_gtk_GtkMenuItemPeer.h"
41
#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h"
42
 
43
static jmethodID postMenuActionEventID;
44
 
45
void
46
cp_gtk_menuitem_init_jni (void)
47
{
48
  jclass gtkmenuitempeer;
49
 
50
  gtkmenuitempeer = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
51
                                      "gnu/java/awt/peer/gtk/GtkMenuItemPeer");
52
 
53
  postMenuActionEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(),
54
                                                     gtkmenuitempeer,
55
                                                     "postMenuActionEvent",
56
                                                     "()V");
57
}
58
 
59
static void item_activate_cb (GtkMenuItem *item __attribute__((unused)),
60
                              jobject peer_obj);
61
 
62
JNIEXPORT void JNICALL
63
Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_create
64
  (JNIEnv *env, jobject obj, jstring label)
65
{
66
  GtkWidget *widget;
67
  const char *str;
68
 
69
  gdk_threads_enter ();
70
 
71
  gtkpeer_set_global_ref (env, obj);
72
 
73
  str = (*env)->GetStringUTFChars (env, label, NULL);
74
 
75
  /* "-" signals that we need a separator. */
76
  if (strcmp (str, "-") == 0)
77
    widget = gtk_menu_item_new ();
78
  else
79
    widget = gtk_menu_item_new_with_label (str);
80
 
81
  gtk_widget_show (widget);
82
 
83
  (*env)->ReleaseStringUTFChars (env, label, str);
84
 
85
  gtkpeer_set_widget (env, obj, widget);
86
 
87
  gdk_threads_leave ();
88
}
89
 
90
JNIEXPORT void JNICALL
91
Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_connectSignals
92
  (JNIEnv *env, jobject obj)
93
{
94
  void *ptr;
95
  jobject gref;
96
 
97
  gdk_threads_enter ();
98
 
99
  ptr = gtkpeer_get_widget (env, obj);
100
  gref = gtkpeer_get_global_ref (env, obj);
101
 
102
  g_signal_connect (G_OBJECT (ptr), "activate",
103
                    G_CALLBACK (item_activate_cb), gref);
104
 
105
  gdk_threads_leave ();
106
}
107
 
108
JNIEXPORT void JNICALL
109
Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_gtkWidgetModifyFont
110
  (JNIEnv *env, jobject obj, jstring name, jint style, jint size)
111
{
112
  const char *font_name;
113
  void *ptr;
114
  GtkWidget *label;
115
  PangoFontDescription *font_desc;
116
 
117
  gdk_threads_enter();
118
 
119
  ptr = gtkpeer_get_widget (env, obj);
120
 
121
  font_name = (*env)->GetStringUTFChars (env, name, NULL);
122
 
123
  label = gtk_bin_get_child (GTK_BIN (ptr));
124
 
125
  if (label)
126
    {
127
      font_desc = pango_font_description_from_string (font_name);
128
      pango_font_description_set_size (font_desc,
129
                                   size * cp_gtk_dpi_conversion_factor);
130
 
131
      if (style & AWT_STYLE_BOLD)
132
        pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
133
 
134
      if (style & AWT_STYLE_ITALIC)
135
        pango_font_description_set_style (font_desc, PANGO_STYLE_OBLIQUE);
136
 
137
      gtk_widget_modify_font (GTK_WIDGET(label), font_desc);
138
 
139
      pango_font_description_free (font_desc);
140
    }
141
 
142
  (*env)->ReleaseStringUTFChars (env, name, font_name);
143
 
144
  gdk_threads_leave();
145
}
146
 
147
JNIEXPORT void JNICALL
148
Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_setEnabled
149
  (JNIEnv *env, jobject obj, jboolean enabled)
150
{
151
  void *ptr;
152
 
153
  gdk_threads_enter ();
154
 
155
  ptr = gtkpeer_get_widget (env, obj);
156
 
157
  gtk_widget_set_sensitive (GTK_WIDGET (ptr), enabled);
158
 
159
  gdk_threads_leave ();
160
}
161
 
162
JNIEXPORT void JNICALL
163
Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_setLabel
164
  (JNIEnv *env, jobject obj, jstring label)
165
{
166
  void *ptr;
167
  const char *str;
168
  GtkAccelLabel *accel_label;
169
 
170
  gdk_threads_enter ();
171
 
172
  ptr = gtkpeer_get_widget (env, obj);
173
 
174
  str = (*env)->GetStringUTFChars (env, label, NULL);
175
 
176
  accel_label = GTK_ACCEL_LABEL (GTK_BIN (ptr)->child);
177
 
178
  gtk_label_set_text (GTK_LABEL (accel_label), str);
179
  gtk_accel_label_refetch (accel_label);
180
 
181
  (*env)->ReleaseStringUTFChars (env, label, str);
182
 
183
  gdk_threads_leave ();
184
}
185
 
186
static void
187
item_activate_cb (GtkMenuItem *item __attribute__((unused)), jobject peer_obj)
188
{
189
  (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer_obj,
190
                                       postMenuActionEventID);
191
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.