gint main(gint argc,gchar* argv[])
{	
    int res;
    
    /*---GTK��ʼ��----*/
    gtk_init(&argc, &argv);	
    g_thread_init(NULL);
    gdk_threads_init();

    struct wcam_win *c = calloc(1, sizeof(struct wcam_win));

    c->entry_win = login_create();
    
    res = login_run(c->entry_win);
    if (res == -1) {
        goto err_win;
    }
    
    login_hide(c->entry_win);
  
    main_create(c);
    
    main_run();

err_win:
    free(c->entry_win);
    free(c);

    return 0;
}
示例#2
0
文件: login.c 项目: nightmorph/LogJam
static void
update_cb(GtkWidget *w, login_dlg *ldlg) {
	JamAccount *acc;
	acc = get_selected_account(ldlg);
	/* we know the account is an lj account because the update
	 * button is disabled for non-lj. */
	if (acc)
		login_run(GTK_WINDOW(ldlg->win), JAM_ACCOUNT_LJ(acc));
}
示例#3
0
文件: login.c 项目: nightmorph/LogJam
gboolean
login_check_lastupdate(GtkWindow *parent, JamAccountLJ *acclj) {
	time_t deltat;
	GtkWidget *dlg;
	char *msg;
	gboolean ret = TRUE;
	JamAccount *acc = JAM_ACCOUNT(acclj);

	if (!conf.options.showloginhistory)
		return login_run(NULL, acclj);

	deltat = time(NULL) - acclj->lastupdate;
	if (deltat < 2 * 7 * 24 * 60 * 60) /* two weeks. */
		return TRUE;

	if (acclj->lastupdate == 0) {
		msg = g_strdup_printf(_("Account '%s' hasn't ever logged in.  "
								"Log in now?"), jam_account_get_username(acc)); 
	} else {
		msg = g_strdup_printf(_("Account '%s' hasn't logged in "
								"in at least %lu days.  Log in now?"),
		                        jam_account_get_username(acc),
		                        (unsigned long) deltat/(24*60*60));
	}
	dlg = gtk_message_dialog_new(parent, GTK_DIALOG_DESTROY_WITH_PARENT,
			GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
			msg);
	g_free(msg);
	if (gtk_dialog_run(GTK_DIALOG(dlg)) == GTK_RESPONSE_YES)
		ret = login_run(GTK_WINDOW(dlg), acclj);
	gtk_widget_destroy(dlg);

	/* no matter what they answered, we shouldn't bug them again
	 * next time if they said no.  the only case to bug them again
	 * is if login failed. */
	if (ret)
		acclj->lastupdate = time(NULL);

	return ret;
}