static void remove_unlock_tooltip (GtkWidget *button) { setup_tooltip_with_embedded_icon (button, NULL, NULL, NULL); g_signal_handlers_disconnect_by_func (button, G_CALLBACK (show_tooltip_now), NULL); }
static void add_unlock_tooltip (GtkWidget *button) { gchar *names[3]; GIcon *icon; names[0] = "changes-allow-symbolic"; names[1] = "changes-allow"; names[2] = NULL; icon = (GIcon *)g_themed_icon_new_from_names (names, -1); /* Translator comments: * We split the line in 2 here to "make it look good", as there's * no good way to do this in GTK+ for tooltips. See: * https://bugzilla.gnome.org/show_bug.cgi?id=657168 */ setup_tooltip_with_embedded_icon (button, _("To make changes,\nclick the * icon first"), "*", icon); g_object_unref (icon); g_signal_connect (button, "button-release-event", G_CALLBACK (show_tooltip_now), NULL); }
static void on_permission_changed (GPermission *permission, GParamSpec *pspec, gpointer data) { UmUserPanelPrivate *d = data; gboolean is_authorized; gboolean self_selected; UmUser *user; GtkWidget *widget; user = get_selected_user (d); if (!user) { return; } is_authorized = g_permission_get_allowed (G_PERMISSION (d->permission)); self_selected = um_user_get_uid (user) == geteuid (); widget = get_widget (d, "add-user-toolbutton"); gtk_widget_set_sensitive (widget, is_authorized); if (is_authorized) { setup_tooltip_with_embedded_icon (widget, _("Create a user account"), NULL, NULL); } else { gchar *names[3]; GIcon *icon; names[0] = "changes-allow-symbolic"; names[1] = "changes-allow"; names[2] = NULL; icon = (GIcon *)g_themed_icon_new_from_names (names, -1); setup_tooltip_with_embedded_icon (widget, _("To create a user account,\nclick the * icon first"), "*", icon); g_object_unref (icon); } widget = get_widget (d, "remove-user-toolbutton"); gtk_widget_set_sensitive (widget, is_authorized && !self_selected); if (is_authorized) { setup_tooltip_with_embedded_icon (widget, _("Delete the selected user account"), NULL, NULL); } else { gchar *names[3]; GIcon *icon; names[0] = "changes-allow-symbolic"; names[1] = "changes-allow"; names[2] = NULL; icon = (GIcon *)g_themed_icon_new_from_names (names, -1); setup_tooltip_with_embedded_icon (widget, _("To delete the selected user account,\nclick the * icon first"), "*", icon); g_object_unref (icon); } if (!um_user_is_local_account (user)) { um_editable_combo_set_editable (UM_EDITABLE_COMBO (get_widget (d, "account-type-combo")), FALSE); remove_unlock_tooltip (get_widget (d, "account-type-combo")); } else if (is_authorized && um_user_is_local_account (user)) { um_editable_combo_set_editable (UM_EDITABLE_COMBO (get_widget (d, "account-type-combo")), TRUE); remove_unlock_tooltip (get_widget (d, "account-type-combo")); } else { um_editable_combo_set_editable (UM_EDITABLE_COMBO (get_widget (d, "account-type-combo")), FALSE); add_unlock_tooltip (get_widget (d, "account-type-combo")); } /* The full name entry: insensitive if remote or not authorized and not self */ widget = get_widget (d, "full-name-entry"); if (!um_user_is_local_account (user)) { cc_editable_entry_set_editable (CC_EDITABLE_ENTRY (widget), FALSE); remove_unlock_tooltip (widget); } else if (is_authorized || self_selected) { cc_editable_entry_set_editable (CC_EDITABLE_ENTRY (widget), TRUE); remove_unlock_tooltip (widget); } else { cc_editable_entry_set_editable (CC_EDITABLE_ENTRY (widget), FALSE); add_unlock_tooltip (widget); } if (is_authorized || self_selected) { gtk_widget_show (get_widget (d, "user-icon-button")); gtk_widget_hide (get_widget (d, "user-icon-nonbutton")); um_editable_combo_set_editable (UM_EDITABLE_COMBO (get_widget (d, "account-language-combo")), TRUE); remove_unlock_tooltip (get_widget (d, "account-language-combo")); um_editable_button_set_editable (UM_EDITABLE_BUTTON (get_widget (d, "account-password-button")), TRUE); remove_unlock_tooltip (get_widget (d, "account-password-button")); gtk_notebook_set_current_page (GTK_NOTEBOOK (get_widget (d, "account-fingerprint-notebook")), 1); } else { gtk_widget_hide (get_widget (d, "user-icon-button")); gtk_widget_show (get_widget (d, "user-icon-nonbutton")); um_editable_combo_set_editable (UM_EDITABLE_COMBO (get_widget (d, "account-language-combo")), FALSE); add_unlock_tooltip (get_widget (d, "account-language-combo")); um_editable_button_set_editable (UM_EDITABLE_BUTTON (get_widget (d, "account-password-button")), FALSE); add_unlock_tooltip (get_widget (d, "account-password-button")); gtk_notebook_set_current_page (GTK_NOTEBOOK (get_widget (d, "account-fingerprint-notebook")), 0); } um_password_dialog_set_privileged (d->password_dialog, is_authorized); g_object_unref (user); }
static void setup_main_window (UmUserPanelPrivate *d) { GtkWidget *userlist; GtkTreeModel *model; GtkListStore *store; GtkTreeViewColumn *column; GtkCellRenderer *cell; GtkTreeSelection *selection; GtkWidget *button; GtkTreeIter iter; gint expander_size; gchar *title; GIcon *icon; gchar *names[3]; userlist = get_widget (d, "list-treeview"); store = gtk_list_store_new (NUM_USER_LIST_COLS, UM_TYPE_USER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT, G_TYPE_BOOLEAN); model = (GtkTreeModel *)store; gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (model), sort_users, NULL, NULL); gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING); gtk_tree_view_set_model (GTK_TREE_VIEW (userlist), model); gtk_tree_view_set_search_column (GTK_TREE_VIEW (userlist), USER_COL); gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (userlist), match_user, NULL, NULL); g_object_unref (model); g_signal_connect (d->um, "users-loaded", G_CALLBACK (users_loaded), d); gtk_widget_style_get (userlist, "expander-size", &expander_size, NULL); gtk_tree_view_set_level_indentation (GTK_TREE_VIEW (userlist), - (expander_size + 6)); title = g_strdup_printf ("<small><span foreground=\"#555555\">%s</span></small>", _("My Account")); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, TITLE_COL, title, HEADING_ROW_COL, TRUE, SORT_KEY_COL, 0, AUTOLOGIN_COL, FALSE, -1); g_free (title); title = g_strdup_printf ("<small><span foreground=\"#555555\">%s</span></small>", _("Other Accounts")); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, TITLE_COL, title, HEADING_ROW_COL, TRUE, SORT_KEY_COL, 2, AUTOLOGIN_COL, FALSE, -1); g_free (title); column = gtk_tree_view_column_new (); cell = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (column), cell, FALSE); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), cell, "pixbuf", FACE_COL); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), cell, "visible", USER_ROW_COL); cell = gtk_cell_renderer_text_new (); g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (column), cell, TRUE); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), cell, "markup", NAME_COL); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), cell, "visible", USER_ROW_COL); cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (column), cell, TRUE); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), cell, "markup", TITLE_COL); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), cell, "visible", HEADING_ROW_COL); cell = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (column, cell, FALSE); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), cell, "visible", USER_ROW_COL); gtk_tree_view_column_set_cell_data_func (column, cell, (GtkTreeCellDataFunc) autologin_cell_data_func, d, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (userlist), column); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (userlist)); gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); g_signal_connect (selection, "changed", G_CALLBACK (selected_user_changed), d); gtk_tree_selection_set_select_function (selection, dont_select_headings, NULL, NULL); gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (get_widget (d, "list-scrolledwindow")), 300); gtk_widget_set_size_request (get_widget (d, "list-scrolledwindow"), 200, -1); button = get_widget (d, "add-user-toolbutton"); g_signal_connect (button, "clicked", G_CALLBACK (add_user), d); button = get_widget (d, "remove-user-toolbutton"); g_signal_connect (button, "clicked", G_CALLBACK (delete_user), d); button = get_widget (d, "user-icon-nonbutton"); add_unlock_tooltip (button); button = get_widget (d, "full-name-entry"); g_signal_connect (button, "editing-done", G_CALLBACK (change_name_done), d); button = get_widget (d, "account-type-combo"); g_signal_connect (button, "editing-done", G_CALLBACK (account_type_changed), d); button = get_widget (d, "account-password-button"); g_signal_connect (button, "start-editing", G_CALLBACK (change_password), d); button = get_widget (d, "account-language-combo"); g_signal_connect (button, "editing-done", G_CALLBACK (language_changed), d); button = get_widget (d, "autologin-switch"); g_signal_connect (button, "notify::active", G_CALLBACK (autologin_changed), d); button = get_widget (d, "account-fingerprint-button"); g_signal_connect (button, "clicked", G_CALLBACK (change_fingerprint), d); d->permission = (GPermission *)polkit_permission_new_sync ("org.freedesktop.accounts.user-administration", NULL, NULL, NULL); g_signal_connect (d->permission, "notify", G_CALLBACK (on_permission_changed), d); on_permission_changed (d->permission, NULL, d); button = get_widget (d, "add-user-toolbutton"); names[0] = "changes-allow-symbolic"; names[1] = "changes-allow"; names[2] = NULL; icon = (GIcon *)g_themed_icon_new_from_names (names, -1); setup_tooltip_with_embedded_icon (button, _("To create a user account,\nclick the * icon first"), "*", icon); button = get_widget (d, "remove-user-toolbutton"); setup_tooltip_with_embedded_icon (button, _("To delete the selected user account,\nclick the * icon first"), "*", icon); g_object_unref (icon); }