1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
115
  
116
  
117
  
118
  
119
  
120
  
121
  
122
  
123
  
/* -*- C -*- */ 
class GTK2.AccelGroup; 
inherit G.Object; 
 
//! An AccelGroup stores keybindings. 
//! A group is automatically created by W(MenuFactory) 
//! 
//! NOIMG 
 
signal accel_activate; 
signal accel_changed; 
 
void create() 
//! Create a new accelerator group 
{ 
  pgtk2_verify_setup(); 
  pgtk2_verify_not_inited(); 
  { 
    GtkAccelGroup *ga; 
    ga=gtk_accel_group_new(); 
    THIS->obj=G_OBJECT(ga); 
  } 
/* add_ref(fp->current_object);   one extra ref... No, not really */ 
  pgtk2_pop_n_elems(args); 
  pgtk2__init_this_object(); 
} 
 
%{ 
int pgtk2_accel_group_activate_key_callback(GtkAccelGroup *accel_group, 
                      GObject *acceleratable, 
                      guint accel_key, 
                      GdkModifierType accel_mods, 
                      struct signal_data *d) 
{ 
  int res; 
  push_svalue(&d->args); 
  push_gobject(accel_group); 
  push_gobject(acceleratable); 
  push_int(accel_key); 
  push_int(accel_mods); 
  safe_apply_svalue(&d->cb, 5, 1); 
  res=Pike_sp[-1].u.integer; 
  pop_stack(); 
  return res; 
} 
%} 
 
void connect(int accel_key, int accel_mods, int accel_flags, 
             function cb, mixed user_data) 
//! Installs an accelerator in this group. 
{ 
  pgtk2_verify_inited(); 
  { 
    gint accel_key; 
    GdkModifierType accel_mods; 
    GtkAccelFlags accel_flags; 
    GClosure *closure; 
    struct signal_data *sd; 
    if (args<5) 
      Pike_error("Too few arguments, 5 required, got %d\n",args); 
    accel_key=(gint)PGTK_GETINT(&Pike_sp[0-args]); 
    accel_mods=(GdkModifierType)PGTK_GETINT(&Pike_sp[1-args]); 
    accel_flags=(GtkAccelFlags)PGTK_GETINT(&Pike_sp[2-args]); 
    sd=(struct signal_data *)g_malloc(sizeof(struct signal_data)); 
    if (sd==NULL) 
      SIMPLE_OUT_OF_MEMORY_ERROR("connect",sizeof(struct signal_data)); 
    assign_svalue_no_free(&sd->cb,Pike_sp+3-args); 
    assign_svalue_no_free(&sd->args,Pike_sp+4-args); 
    closure=g_cclosure_new(G_CALLBACK(pgtk2_accel_group_activate_key_callback), 
                sd,(GClosureNotify)pgtk2_free_signal_data); 
    gtk_accel_group_connect(GTK_ACCEL_GROUP(THIS->obj),accel_key, 
                accel_mods,accel_flags,closure); 
  } 
  RETURN_THIS(); 
} 
 
void connect_by_path(string accel_path, function cb, mixed user_data) 
//! Installs an accelerator in this group, using an accelerator path to look 
//! up the appropriate key and modifiers. 
{ 
  pgtk2_verify_inited(); 
  { 
    const gchar *accel_path; 
    struct signal_data *sd; 
    GClosure *closure; 
    if (args<3) 
      Pike_error("Too few arguments, 3 required, got %d\n",args); 
    accel_path=PGTK_GETSTR(&Pike_sp[-args]); 
    sd=(struct signal_data *)g_malloc(sizeof(struct signal_data)); 
    if (sd==NULL) 
      SIMPLE_OUT_OF_MEMORY_ERROR("connect_by_path",sizeof(struct signal_data)); 
    assign_svalue_no_free(&sd->cb,Pike_sp+1-args); 
    assign_svalue_no_free(&sd->args,Pike_sp+2-args); 
    closure=g_cclosure_new(G_CALLBACK(pgtk2_signal_func_wrapper), 
                sd,(GClosureNotify)pgtk2_free_signal_data); 
    gtk_accel_group_connect_by_path(GTK_ACCEL_GROUP(THIS->obj),accel_path, 
                closure); 
  } 
  RETURN_THIS(); 
} 
 
void disconnect(int accel_key, int accel_mods) 
//! Removes an accelerator previously installed. 
{ 
  pgtk2_verify_inited(); 
  { 
    INT_TYPE accel_key; 
    INT_TYPE accel_mods; 
    get_all_args(NULL,args,"%i%i",&accel_key,&accel_mods); 
    gtk_accel_group_disconnect_key(GTK_ACCEL_GROUP(THIS->obj), 
                        accel_key,accel_mods); 
  } 
  RETURN_THIS(); 
} 
 
void lock(); 
//! Locks the group. 
 
void unlock(); 
//! Undoes the last call to lock().