~elementary-apps/pantheon-files/trunk

« back to all changes in this revision

Viewing changes to filechooser-module/Plugin.vala

  • Committer: donadigo
  • Date: 2015-04-30 22:07:48 UTC
  • mto: This revision was merged to the branch mainline in revision 1842.
  • Revision ID: donadigos159@gmail.com-20150430220748-kay2fc7qf1sn30bf
Initial commit; filechooser gtk module

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
 
2
/*-
 
3
 * Copyright (c) 2013 Pantheon Developers (http://launchpad.net/elementary)
 
4
 *
 
5
 * This library is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU Library General Public
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 2 of the License, or (at your option) any later version.
 
9
 *
 
10
 * This library is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 * Library General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Library General Public
 
16
 * License along with this library; if not, write to the
 
17
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
18
 * Boston, MA 02111-1307, USA.
 
19
 *
 
20
 * Authored by: Corentin Noël <tintou@mailoo.org>
 
21
 */
 
22
 
 
23
public class PantheonModule.FileChooserDialog : GLib.Object {
 
24
    /* CATCHING DIALOGS SECTION BY: tintou (https://launchpad.net/~tintou) */
 
25
    Gee.TreeSet<Gtk.FileChooserDialog> tree_set;
 
26
    public FileChooserDialog () {
 
27
        tree_set = new Gee.TreeSet<Gtk.FileChooserDialog> ();
 
28
        /* It's the only way to get every new window */
 
29
        var map_id = GLib.Signal.lookup ("window-state-event", typeof (Gtk.Dialog));
 
30
        GLib.Signal.add_emission_hook (map_id, 0, (ihint, param_values) => {
 
31
            if (param_values [0].type () == typeof (Gtk.FileChooserDialog)) {
 
32
                var dialog = (Gtk.FileChooserDialog)param_values [0].dup_object ();
 
33
                if (tree_set.contains (dialog) == false) {
 
34
                    tree_set.add (dialog);
 
35
                    new CustomFileChooserDialog (dialog);  
 
36
                    dialog.destroy.connect (() => {
 
37
                        tree_set.remove (dialog);
 
38
                    });
 
39
                }
 
40
            }
 
41
 
 
42
            return true;
 
43
        }, null);
 
44
    }
 
45
}
 
46
 
 
47
public static PantheonModule.FileChooserDialog filechooser_module = null;
 
48
public void gtk_module_init ([CCode (array_length_cname = "argc", array_length_pos = 0.5)] ref unowned string[]? argv) {
 
49
    Gtk.init (ref argv);
 
50
    filechooser_module = new PantheonModule.FileChooserDialog ();
 
51
}