File: caja-python-property-page-provider.xml

package info (click to toggle)
python-caja 1.16.0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 660 kB
  • ctags: 141
  • sloc: xml: 1,701; ansic: 726; python: 212; makefile: 165; sh: 16
file content (129 lines) | stat: -rw-r--r-- 4,207 bytes parent folder | download | duplicates (6)
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
124
125
126
127
128
129
<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">

<refentry id="class-caja-python-property-page-provider">
  <refnamediv>
    <refname>Caja.PropertyPageProvider</refname>
    <refpurpose>Caja.PropertyPageProvider Reference</refpurpose>
  </refnamediv>

<!-- ******************************* -->
<!-- BEGIN OF SYNOPSIS -->
<!-- ******************************* -->

  <refsect1>
    <title>Synopsis</title>

    <classsynopsis language="python">
      <ooclass><classname>Caja.PropertyPageProvider</classname></ooclass>

      <methodsynopsis language="python">
        <methodname><link linkend="method-caja-property-page-provider--get-pages">get_pages</link></methodname>
        <methodparam><parameter role="keyword">files</parameter></methodparam>
      </methodsynopsis>
    </classsynopsis>
  </refsect1>

<!-- ********************************** -->
<!-- BEGIN OF DESCRIPTION -->
<!-- ********************************** -->

  <refsect1 id="description-property-page-provider">
    <title>Description</title>

      <para>
      If subclassed, Caja will request a list of custom property pages that should
      appear when a user opens the Properties dialog for a file or folder.
      </para>

<example>
    <title>Caja.PropertyPageProvider Example</title>
    <programlisting>
import hashlib
import urllib

from gi.repository import Caja, GObject, Gtk

class ColumnExtension(GObject.GObject, Caja.PropertyPageProvider):
    def __init__(self):
        pass
    
    def get_property_pages(self, files):
        if len(files) != 1:
            return
        
        file = files[0]
        if file.get_uri_scheme() != 'file':
            return

        if file.is_directory():
            return

        filename = urllib.unquote(file.get_uri()[7:])

        self.property_label = Gtk.Label('MD5Sum')
        self.property_label.show()

        self.hbox = Gtk.HBox(homogeneous=False, spacing=0)
        self.hbox.show()

        label = Gtk.Label('MD5Sum:')
        label.show()
        self.hbox.pack_start(label, False, False, 0)

        self.value_label = Gtk.Label()
        self.hbox.pack_start(self.value_label, False, False, 0)

        md5sum = hashlib.md5()
        with open(filename,'rb') as f: 
            for chunk in iter(lambda: f.read(8192), ''): 
                md5sum.update(chunk)
        f.close()       

        self.value_label.set_text(md5sum.hexdigest())
        self.value_label.show()
        
        return Caja.PropertyPage(name="CajaPython::md5_sum",
                                     label=self.property_label, 
                                     page=self.hbox),
    </programlisting>
</example>
        
  </refsect1>

<!-- ****************************** -->
<!-- BEGIN OF METHODS -->
<!-- ****************************** -->

  <refsect1>
        <title>Passive Methods</title>

        <refsect2 id="method-caja-property-page-provider--get-pages">
          <title>Caja.PropertyPageProvider.get_pages</title>

          <programlisting><methodsynopsis language="python">
            <methodname>get_pages</methodname>
              <methodparam></methodparam>
          </methodsynopsis></programlisting>

          <variablelist>
            <varlistentry>
	            <term><parameter role="keyword">files</parameter>&nbsp;:</term>
	            <listitem><simpara>a list of <link linkend="class-caja-python-file-info"><classname>Caja.FileInfo</classname></link> objects.</simpara></listitem>
            </varlistentry>
            <varlistentry>
              <term><emphasis>Returns</emphasis>&nbsp;:</term>
              <listitem><simpara>a list of <link linkend="class-caja-python-property-page"><classname>Caja.PropertyPage</classname></link> objects</simpara></listitem>
            </varlistentry>
          </variablelist>

          <para>
                This function is called by Caja when it wants property page items from the extension.  
                It is called in the main thread before a property page is shown, so it should return quickly.
          </para>
        </refsect2>
    </refsect1>

</refentry>