~vrruiz/gnome-control-center-signon/quantal-autoreconf

« back to all changes in this revision

Viewing changes to src/cc-credentials-account-applications-model.vala

  • Committer: Ken VanDine
  • Date: 2012-05-22 19:39:10 UTC
  • mfrom: (20.2.37 trunk)
  • Revision ID: ken.vandine@canonical.com-20120522193910-1u4cx73j3ttbnjc7
Tags: 0.0.2+r57-0precise1
releasing version 0.0.2+r57-0precise1

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *      David King <david.king@canonical.com>
18
18
 */
19
19
 
 
20
namespace Cc.Credentials
 
21
{
 
22
    /**
 
23
     * An individual application associated with an account.
 
24
     *
 
25
     * @param name the name, as supplied to Ag.Manager.get_provider ()
 
26
     * @param icon the icon of the application
 
27
     * @param description the description of the application
 
28
     */
 
29
    public struct AccountApplicationRow
 
30
    {
 
31
        public string name;
 
32
        public Icon icon;
 
33
        public string description;
 
34
    }
 
35
}
 
36
 
20
37
/**
21
38
 * Web credentials account applications model. Used to store details about
22
 
 * applications that can be integrated with an account, to be the model of a
23
 
 * tree view for display with other account details.
 
39
 * applications that can be integrated with an account, to be used in creating
 
40
 * widgets in a grid for describing the applications.
24
41
 */
25
 
public class Cc.Credentials.AccountApplicationsModel : Gtk.ListStore
 
42
public class Cc.Credentials.AccountApplicationsModel : Object
26
43
{
27
44
    private Ag.Manager manager;
28
45
    private Ag.Account current_account;
 
46
    public List<AccountApplicationRow?> application_rows;
29
47
 
30
48
    /**
31
49
     * Update the model when the current account changes.
48
66
 
49
67
            current_account = value;
50
68
 
51
 
            // Clear the model and repopulate it.
52
 
            clear ();
 
69
            // Empty the model and repopulate it.
 
70
            application_rows = new List <AccountApplicationRow?>();
53
71
            populate_model ();
54
72
        }
55
73
    }
56
74
 
57
75
    /**
58
 
     * Identifiers for columns in the model.
59
 
     *
60
 
     * @param APPLICATION_NAME the name, as supplied to
61
 
     * Ag.Manager.get_provider ()
62
 
     * @param APPLICATION_ICON the icon of the application
63
 
     * @param APPLICATION_DESCRIPTION the description of the application
64
 
     */
65
 
    private enum ModelColumns
66
 
    {
67
 
        APPLICATION_NAME = 0,
68
 
        APPLICATION_ICON = 1,
69
 
        APPLICATION_DESCRIPTION = 2
70
 
    }
71
 
 
72
 
    /**
73
76
     * Create a new model for storing applications that can be used with an
74
77
     * account.
75
78
     *
77
80
     */
78
81
    public AccountApplicationsModel ()
79
82
    {
80
 
        Type[] types = { typeof (string), typeof (Icon), typeof (string) };
81
 
        set_column_types (types);
82
 
 
83
83
        manager = new Ag.Manager ();
84
84
    }
85
85
 
102
102
        }
103
103
 
104
104
        service_application.foreach (add_application);
 
105
 
 
106
        // Reverse the list, as it was prended to for efficiency.
 
107
        application_rows.reverse ();
105
108
    }
106
109
 
107
110
    /**
122
125
        }
123
126
 
124
127
        // Load a themed application icon.
125
 
        var icon = desktop_info.get_icon ();
 
128
        var app_icon = desktop_info.get_icon ();
126
129
 
127
130
        var service = manager.get_service (service_name);
128
131
 
131
134
                                 + application.get_service_usage (service)
132
135
                                 + "</small>";
133
136
 
134
 
        insert_with_values (null, 0,
135
 
                            ModelColumns.APPLICATION_NAME, application.get_name (),
136
 
                            ModelColumns.APPLICATION_ICON, icon,
137
 
                            ModelColumns.APPLICATION_DESCRIPTION, description_markup,
138
 
                            -1);
 
137
        var application_row = AccountApplicationRow ()
 
138
        {
 
139
            name = application.get_name (),
 
140
            icon = app_icon,
 
141
            description = description_markup
 
142
        };
 
143
 
 
144
        application_rows.prepend (application_row);
139
145
    }
140
146
}