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

« back to all changes in this revision

Viewing changes to src/cc-credentials-account-details-page.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:
30
30
    private Gtk.Notebook action_notebook;
31
31
    private Gtk.Switch enabled_switch;
32
32
    private Gtk.Button grant_button;
33
 
    private Gtk.Label applications_tree_description;
34
 
    private Gtk.TreeView applications_tree;
35
 
    private AccountApplicationsModel applications_store;
 
33
    private Gtk.Label applications_grid_description;
 
34
    private Gtk.ScrolledWindow applications_scroll;
 
35
    private Gtk.Grid applications_grid;
 
36
    private AccountApplicationsModel applications_model;
36
37
    private Ag.Account current_account;
37
38
    private bool needs_attention = false;
38
39
 
116
117
                action_notebook.page = ActionPage.ENABLED_SWITCH;
117
118
            }
118
119
 
119
 
            applications_tree_description.label = _("The following applications integrate with your %s account:").printf
 
120
            applications_grid_description.label = _("The following applications integrate with your %s account:").printf
120
121
                                                  (provider_display_name);
121
122
 
122
123
            // Update the applications model.
123
 
            var applications_model = applications_tree.model as AccountApplicationsModel;
124
124
            applications_model.account = value;
 
125
 
 
126
            populate_applications_grid ();
125
127
        }
126
128
    }
127
129
 
139
141
        expand = true;
140
142
 
141
143
        this.add (create_infobar ());
142
 
        this.add (create_applications_tree_description ());
143
 
        this.add (create_applications_tree ());
 
144
        this.add (create_applications_grid_description ());
 
145
        this.add (create_applications_grid ());
144
146
        this.add (create_remove_account_box ());
145
147
 
146
148
        show ();
180
182
    }
181
183
 
182
184
    /**
183
 
     * Create a description to place above the applications treeview.
184
 
     *
185
 
     * @return a Gtk.Label for a description of the applications treeview
186
 
     */
187
 
    private Gtk.Widget create_applications_tree_description ()
188
 
    {
189
 
        applications_tree_description = new Gtk.Label (null);
190
 
 
191
 
        applications_tree_description.xalign = 0.0f;
192
 
        applications_tree_description.show ();
193
 
 
194
 
        return applications_tree_description;
195
 
    }
196
 
 
197
 
    /**
198
 
     * Create the notebook with a page for adding providers.
199
 
     *
200
 
     * @return a Gtk.Notebook containing a provider selection tree view
201
 
     */
202
 
    private Gtk.Widget create_applications_tree ()
203
 
    {
204
 
        applications_store = new AccountApplicationsModel ();
205
 
 
206
 
        var scrolled_window = new Gtk.ScrolledWindow (null, null);
207
 
        applications_tree = new Gtk.TreeView.with_model (applications_store);
208
 
 
209
 
        // TODO: Add spacing between rows. vertical-separator style property.
210
 
        applications_tree.headers_visible = false;
211
 
 
212
 
        var icon_renderer = new Gtk.CellRendererPixbuf ();
213
 
        icon_renderer.stock_size = Gtk.IconSize.DIALOG;
214
 
        icon_renderer.set_padding (6, 6);
215
 
 
216
 
        var description_renderer = new Gtk.CellRendererText ();
217
 
        var tree_column = new Gtk.TreeViewColumn ();
218
 
        tree_column.pack_start (icon_renderer, false);
219
 
        tree_column.add_attribute (icon_renderer,
220
 
                                   "gicon",
221
 
                                   AccountApplicationsModel.ModelColumns.APPLICATION_ICON);
222
 
        tree_column.pack_start (description_renderer, true);
223
 
        tree_column.add_attribute (description_renderer,
224
 
                                   "markup",
225
 
                                   AccountApplicationsModel.ModelColumns.APPLICATION_DESCRIPTION);
226
 
        applications_tree.append_column (tree_column);
227
 
 
228
 
        scrolled_window.expand = true;
229
 
        scrolled_window.shadow_type = Gtk.ShadowType.ETCHED_IN;
230
 
        scrolled_window.add (applications_tree);
231
 
 
232
 
        scrolled_window.show_all ();
233
 
 
234
 
        return scrolled_window;
235
 
    }
236
 
 
237
 
    /**
238
 
     * Show an appropriate page in the notebook, depending on which row was
239
 
     * selected in the accounts treeview.
240
 
     *
241
 
     * @return selection the selection of the accounts treeview
 
185
     * Create a description to place above the applications grid.
 
186
     *
 
187
     * @return a Gtk.Label for a description of the applications grid
 
188
     */
 
189
    private Gtk.Widget create_applications_grid_description ()
 
190
    {
 
191
        applications_grid_description = new Gtk.Label (null);
 
192
 
 
193
        applications_grid_description.xalign = 0.0f;
 
194
        applications_grid_description.show ();
 
195
 
 
196
        return applications_grid_description;
 
197
    }
 
198
 
 
199
    /**
 
200
     * Create the grid with a list of applications using the current account.
 
201
     *
 
202
     * @return a Gtk.Grid containing a list of applications
 
203
     */
 
204
    private Gtk.Widget create_applications_grid ()
 
205
    {
 
206
        applications_model = new AccountApplicationsModel ();
 
207
 
 
208
        applications_scroll = new Gtk.ScrolledWindow (null, null);
 
209
 
 
210
        // Instantiates applications_grid.
 
211
        populate_applications_grid ();
 
212
 
 
213
        applications_scroll.shadow_type = Gtk.ShadowType.ETCHED_IN;
 
214
        applications_scroll.window_placement_set = true;
 
215
 
 
216
        return applications_scroll;
 
217
    }
 
218
 
 
219
    /**
 
220
     * Create a button box for the account editing buttons.
 
221
     *
 
222
     * @return a Gtk.ButtonBox for the remove or edit account buttons
242
223
     */
243
224
    private Gtk.Widget create_remove_account_box ()
244
225
    {
 
226
        var buttonbox = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL);
 
227
        buttonbox.set_layout (Gtk.ButtonBoxStyle.END);
 
228
 
245
229
        var remove_button = new Gtk.Button.with_label (_("Remove account"));
246
230
 
247
231
        remove_button.clicked.connect (on_remove_account_clicked);
248
232
 
249
 
        remove_button.halign = Gtk.Align.END;
250
 
        remove_button.show ();
251
 
 
252
 
        return remove_button;
 
233
        buttonbox.add (remove_button);
 
234
        buttonbox.show_all ();
 
235
 
 
236
        return buttonbox;
 
237
    }
 
238
 
 
239
    /**
 
240
     * Populate the grid of applications from the model. Instantiates
 
241
     * applications_grid.
 
242
     */
 
243
    private void populate_applications_grid ()
 
244
    {
 
245
        if (applications_grid != null)
 
246
        {
 
247
            applications_grid.destroy ();
 
248
        }
 
249
 
 
250
        applications_grid = new Gtk.Grid ();
 
251
        applications_grid.orientation = Gtk.Orientation.VERTICAL;
 
252
        applications_grid.row_spacing = 6;
 
253
        applications_grid.expand = true;
 
254
 
 
255
        unowned List<AccountApplicationRow?> applications = applications_model.application_rows;
 
256
 
 
257
        applications.foreach (add_application);
 
258
 
 
259
        applications_scroll.add_with_viewport (applications_grid);
 
260
 
 
261
        applications_scroll.show_all ();
 
262
    }
 
263
 
 
264
    /**
 
265
     * Add an individual application from the model to the applications grid.
 
266
     *
 
267
     * @param application the description of the application
 
268
     */
 
269
    private void add_application (AccountApplicationRow? application)
 
270
    {
 
271
        var grid = new Gtk.Grid ();
 
272
        grid.border_width = 6;
 
273
        grid.column_spacing = 6;
 
274
        grid.orientation = Gtk.Orientation.HORIZONTAL;
 
275
 
 
276
        grid.add (new Gtk.Image.from_gicon (application.icon,
 
277
                                            Gtk.IconSize.DIALOG));
 
278
        var label = new Gtk.Label (application.description);
 
279
        label.hexpand = true;
 
280
        label.use_markup = true;
 
281
        label.xalign = 0.0f;
 
282
        grid.add (label);
 
283
 
 
284
        // TODO: Add options button here, if there is one.
 
285
 
 
286
        applications_grid.add (grid);
253
287
    }
254
288
 
255
289
    /**