Ejemplo n.º 1
0
int main(int argc, char **argv)
{
    DBusGConnection *connection;    
    GtkWidget *window, *vbox, *entry, *label, *button;
    GError *error = NULL;

    gtk_init(&argc, &argv);

    connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
    if (error) {
        printf("Failed to get bus: %s\n", error->message);
        return 1;
    }
    proxy = dbus_g_proxy_new_for_name(connection,
                                      "com.example.Mirror",
                                      "/com/example/Mirror",
                                      "com.example.Mirror");

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(gtk_main_quit), NULL);
    vbox = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(window), vbox);

    label = gtk_label_new("Text to send:");
    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 3);

    entry = gtk_entry_new();
    g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(mirror_cb), NULL);
    gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, TRUE, 3);

    error_label = gtk_label_new("");
    gtk_label_set_line_wrap(GTK_LABEL(error_label), TRUE);
    gtk_box_pack_start(GTK_BOX(vbox), error_label, FALSE, TRUE, 3);

    button = polkit_lock_button_new ("com.example.mirror.use");
    polkit_lock_button_set_unlock_text (POLKIT_LOCK_BUTTON (button), "sliff");
    polkit_lock_button_set_lock_text (POLKIT_LOCK_BUTTON (button), "sloff");
    polkit_lock_button_set_lock_down_text (POLKIT_LOCK_BUTTON (button), "foo");
    polkit_lock_button_set_not_authorized_text (POLKIT_LOCK_BUTTON (button), "bar");
    gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, TRUE, 3);

    g_signal_connect (button, "changed",
                      G_CALLBACK (authorized_changed), entry);

    g_print ("%s\n", polkit_lock_button_get_is_visible (POLKIT_LOCK_BUTTON (button)) ? "visible" : "invisible");

    gtk_widget_show_all(window);

    gtk_main();

    return 0;
}
UmLoginOptions *
um_login_options_new (GtkBuilder *builder)
{
        GtkWidget *widget;
        GtkWidget *box;
        GtkListStore *store;
        GtkTreeIter iter;
        GError *error;
        UmLoginOptions *um;

        /* TODO: get actual login screen options */

        um = g_new0 (UmLoginOptions, 1);

        um->manager = um_user_manager_ref_default ();
        g_signal_connect (um->manager, "users-loaded",
                          G_CALLBACK (users_loaded), um);

        widget = (GtkWidget *) gtk_builder_get_object (builder, "dm-automatic-login-combobox");
        um->autologin_combo = widget;

        store = gtk_list_store_new (2, G_TYPE_STRING, UM_TYPE_USER);
        gtk_combo_box_set_model (GTK_COMBO_BOX (widget), GTK_TREE_MODEL (store));
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            AUTOLOGIN_NAME_COL, _("Disabled"),
                            AUTOLOGIN_USER_COL, NULL,
                            -1);

        gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);

        gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (store), sort_login_users, NULL, NULL);
        gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING);

        g_signal_connect (widget, "changed",
                          G_CALLBACK (update_autologin), um);

        widget = (GtkWidget *) gtk_builder_get_object (builder, "dm-show-user-list-checkbutton");
        um->userlist_check = widget;
        g_signal_connect (widget, "toggled",
                          G_CALLBACK (update_login_options), um);
        g_object_set_data (G_OBJECT (widget), "gconf-key",
                           "/apps/gdm/simple-greeter/disable_user_list");
        update_boolean_from_gconf (widget, um);

        widget = (GtkWidget *) gtk_builder_get_object (builder, "dm-show-power-buttons-checkbutton");
        um->power_check = widget;
        g_signal_connect(widget, "toggled",
                         G_CALLBACK (update_login_options), um);
        g_object_set_data (G_OBJECT (widget), "gconf-key",
                           "/apps/gdm/simple-greeter/disable_restart_buttons");
        update_boolean_from_gconf (widget, um);

        widget = (GtkWidget *) gtk_builder_get_object (builder, "dm-show-password-hints-checkbutton");
        um->hints_check = widget;
        g_signal_connect (widget, "toggled",
                          G_CALLBACK (update_login_options), um);

        widget = (GtkWidget *) gtk_builder_get_object (builder, "dm-allow-guest-login-checkbutton");
        um->guest_check = widget;
        g_signal_connect (widget, "toggled",
                          G_CALLBACK (update_login_options), um);

        widget = polkit_lock_button_new ("org.freedesktop.accounts.set-login-option");
        gtk_widget_show (widget);
        box = (GtkWidget *)gtk_builder_get_object (builder, "lockbutton-alignment");
        gtk_container_add (GTK_CONTAINER (box), widget);
        g_signal_connect (widget, "changed",
                          G_CALLBACK (lockbutton_changed), um);
        lockbutton_changed (POLKIT_LOCK_BUTTON (widget), um);
        um->lock_button = widget;

        error = NULL;
        um->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
        if (error != NULL) {
                g_warning ("Failed to get system bus connection: %s", error->message);
                g_error_free (error);
        }

        um->proxy = dbus_g_proxy_new_for_name (um->connection,
                                               "org.gnome.GConf.Defaults",
                                               "/",
                                               "org.gnome.GConf.Defaults");

        if (um->proxy == NULL) {
                g_warning ("Cannot connect to GConf defaults mechanism");
        }

        return um;
}