File: gtkselectiondata.pre

package info (click to toggle)
pigtk 1.1.3-3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,248 kB
  • ctags: 104
  • sloc: ansic: 1,087; sh: 152; makefile: 121
file content (73 lines) | stat: -rw-r--r-- 1,853 bytes parent folder | download
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
PROGRAM(selection_data);
/* do not... INHERIT(data); */

FUNCTION(data, "function(void:string)");
{
  int length = ((GtkSelectionData *)THIS->obj)->length;
  pop_n_elems( args );
  if(length < 0)
  {
    push_int(0);
    return;
  }
  switch( ((GtkSelectionData *)THIS->obj)->format )
  {
   case 8:
     push_string( make_shared_binary_string((void *)((GtkSelectionData *)THIS->obj)
                                            ->data, length ) );
     break;
   case 16:
     length /= 2;
     push_string( make_shared_binary_string1((void *)((GtkSelectionData *)THIS->obj)
                                             ->data, length ) );
     break;
   case 32:
     length /= 4;
     push_string( make_shared_binary_string2((void *)((GtkSelectionData *)THIS->obj)
                                             ->data, length ) );
     break;
  }
}

FUNCTION(format, "function(void:int)");
{
  pop_n_elems( args );
  push_int( ((GtkSelectionData *)THIS->obj)->format );
}

FUNCTION(length, "function(void:int)");
{
  pop_n_elems( args );
  push_int( ((GtkSelectionData *)THIS->obj)->length );
}

FUNCTION(set, "function(string:object)");
{
  struct pike_string *s;
  get_all_args( "set", args, "%W", &s );
  gtk_selection_data_set( ((GtkSelectionData *)THIS->obj),
                          ((GtkSelectionData *)THIS->obj)->target,
                          8<<s->size_shift,
                          s->str,
                          (s->len * 1<<s->size_shift) );
  RETURN_THIS();
}


#define RETURN_GDKATOM(X) pop_n_elems(args); push_pgdkobject( ((void *)((GtkSelectionData *)THIS->obj)->X), pgtk_Gdk_Atom_program );


FUNCTION(target, "function(void:object)");
{
  RETURN_GDKATOM( target );
}

FUNCTION(type, "function(void:object)");
{
  RETURN_GDKATOM( type );
}

FUNCTION(selection, "function(void:object)");
{
  RETURN_GDKATOM( selection );
}