~ubuntu-branches/ubuntu/saucy/geary/saucy-updates

« back to all changes in this revision

Viewing changes to src/client/geary-controller.vala

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2013-10-10 17:40:37 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20131010174037-5p5o4dlsoewek2kg
Tags: 0.4.0-0ubuntu1
New stable version

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
    private uint search_timeout_id = 0;
97
97
    private LoginDialog? login_dialog = null;
98
98
    private UpgradeDialog upgrade_dialog;
 
99
    private Gee.List<string> pending_mailtos = new Gee.ArrayList<string>();
99
100
    
100
101
    // List of windows we're waiting to close before Geary closes.
101
102
    private Gee.List<ComposerWindow> waiting_to_close = new Gee.ArrayList<ComposerWindow>();
942
943
        if (current_account != folder.account) {
943
944
            current_account = folder.account;
944
945
            account_selected(current_account);
 
946
            
 
947
            // If we were waiting for an account to be selected before issuing mailtos, do that now.
 
948
            if (pending_mailtos.size > 0) {
 
949
                foreach(string mailto in pending_mailtos)
 
950
                    compose_mailto(mailto);
 
951
                
 
952
                pending_mailtos.clear();
 
953
            }
945
954
        }
946
955
        
947
956
        folder_selected(current_folder);
1484
1493
            GearyApplication.instance.config.ask_open_attachment = !ask_to_open.is_checked;
1485
1494
        }
1486
1495
        
1487
 
        open_uri(attachment.file.get_uri());
 
1496
        // Open the attachment if we know what to do with it.
 
1497
        if (!open_uri(attachment.file.get_uri())) {
 
1498
            // Failing that, trigger a save dialog.
 
1499
            Gee.List<Geary.Attachment> attachment_list = new Gee.ArrayList<Geary.Attachment>();
 
1500
            attachment_list.add(attachment);
 
1501
            on_save_attachments(attachment_list);
 
1502
        }
1488
1503
    }
1489
1504
    
1490
1505
    private bool do_overwrite_confirmation(File to_overwrite) {
1526
1541
        dialog.set_local_only(false);
1527
1542
        
1528
1543
        bool accepted = (dialog.run() == Gtk.ResponseType.ACCEPT);
1529
 
        File destination = File.new_for_path(dialog.get_filename());
 
1544
        string? filename = dialog.get_filename();
1530
1545
        
1531
1546
        dialog.destroy();
1532
1547
        
1533
 
        if (!accepted)
 
1548
        if (!accepted || Geary.String.is_empty(filename))
1534
1549
            return;
1535
1550
        
 
1551
        File destination = File.new_for_path(filename);
 
1552
        
1536
1553
        // Proceeding, save this as last destination directory
1537
1554
        last_save_directory = (attachments.size == 1) ? destination.get_parent() : destination;
1538
1555
        
1610
1627
    }
1611
1628
    
1612
1629
    // Opens a link in an external browser.
1613
 
    private void open_uri(string _link) {
 
1630
    private bool open_uri(string _link) {
1614
1631
        string link = _link;
1615
1632
        
1616
1633
        // Support web URLs that ommit the protocol.
1617
1634
        if (!link.contains(":"))
1618
1635
            link = "http://" + link;
1619
1636
        
 
1637
        bool ret = false;
1620
1638
        try {
1621
 
            Gtk.show_uri(main_window.get_screen(), link, Gdk.CURRENT_TIME);
 
1639
            ret = Gtk.show_uri(main_window.get_screen(), link, Gdk.CURRENT_TIME);
1622
1640
        } catch (Error err) {
1623
1641
            debug("Unable to open URL. %s", err.message);
1624
1642
        }
 
1643
        
 
1644
        return ret;
1625
1645
    }
1626
1646
    
1627
1647
    private bool close_composition_windows() {
1889
1909
        Gee.MultiMap<Geary.EmailIdentifier, Type>? selected_operations = null;
1890
1910
        try {
1891
1911
            if (current_folder != null) {
1892
 
                selected_operations = yield email_stores.get(current_folder.account)
1893
 
                    .get_supported_operations_async(get_selected_email_ids(false), cancellable);
 
1912
                Geary.App.EmailStore? store = email_stores.get(current_folder.account);
 
1913
                if (store != null) {
 
1914
                    selected_operations = yield store
 
1915
                        .get_supported_operations_async(get_selected_email_ids(false), cancellable);
 
1916
                }
1894
1917
            }
1895
1918
        } catch (Error e) {
1896
1919
            debug("Error checking for what operations are supported in the selected conversations: %s",
1932
1955
    }
1933
1956
    
1934
1957
    public void compose_mailto(string mailto) {
 
1958
        if (current_account == null) {
 
1959
            // Schedule the send for after we have an account open.
 
1960
            pending_mailtos.add(mailto);
 
1961
            
 
1962
            return;
 
1963
        }
 
1964
        
1935
1965
        create_compose_window(ComposerWindow.ComposeType.NEW_MESSAGE, null, mailto);
1936
1966
    }
1937
1967