Пример #1
0
void show_login()
{
	GtkWidget *image;
    GtkWidget *hbox_toplevel;
	GtkWidget *vbox;
	GtkWidget *button;
	GtkWidget *hbox;
	GtkWidget *label;
	GtkWidget *vbox2;
    GtkWidget *table;
#ifdef GAIM_SMALL_SCREEN    
#ifdef ENABLE_HILDON
    GtkWidget *hbox1;
    GtkWidget *vbox1;
#endif
    GtkWidget *hseparator;
#endif
	/* Do we already have a main window opened? If so, bring it back, baby... ribs... yeah */

#ifdef ENABLE_HILDON
    if (login_app_view) {
            hildon_app_set_appview(HILDON_APP(app), HILDON_APPVIEW(login_app_view));
	    g_object_unref(login_app_view);
            return;
    }
    mainwindow = current_app_view = login_app_view = hildon_appview_new(_("Login"));
    hildon_app_set_appview(HILDON_APP(app), HILDON_APPVIEW(login_app_view));
    
    hbox_toplevel = gtk_hbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(login_app_view), hbox_toplevel);
    g_signal_connect(G_OBJECT(login_app_view), "delete_event",
                     G_CALLBACK(login_window_closed), login_app_view);
                     
                 
#else
    if (mainwindow) {
            gtk_window_present(GTK_WINDOW(mainwindow));
            return;
    }
    #ifdef GAIM_SMALL_SCREEN
        mainwindow = gtk_dialog_new();
        gtk_window_set_modal(GTK_WINDOW(mainwindow), TRUE);
        gtk_dialog_set_has_separator(mainwindow, FALSE);
    #else
        mainwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    #endif
        gtk_window_set_role(GTK_WINDOW(mainwindow), "login");
        gtk_window_set_resizable(GTK_WINDOW(mainwindow), FALSE);
        gtk_window_set_title(GTK_WINDOW(mainwindow), _("Login"));
        gtk_container_set_border_width(GTK_CONTAINER(mainwindow), 5);
        g_signal_connect(G_OBJECT(mainwindow), "delete_event",
                        G_CALLBACK(login_window_closed), mainwindow);
        hbox_toplevel = gtk_hbox_new(FALSE, 0);
    #ifdef GAIM_SMALL_SCREEN
        gtk_container_add(GTK_CONTAINER(GTK_DIALOG(mainwindow)->vbox), hbox_toplevel);
    #else
        gtk_container_add(GTK_CONTAINER(mainwindow), hbox_toplevel);
    #endif
#endif

    

                     
    vbox_toplevel = vbox = gtk_vbox_new(FALSE, 0);

    gtk_box_pack_start(GTK_BOX(hbox_toplevel), vbox, FALSE, FALSE, BOX_SPACING);
#ifdef GAIM_SMALL_SCREEN	
    /* Now for the button box */
    hbox = gtk_hbox_new(FALSE, 0);
#ifdef ENABLE_HILDON
    hbox1 = gtk_hbox_new(FALSE, BOX_SPACING);
    vbox1 = gtk_vbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, FALSE, 0);
    gtk_box_pack_end(GTK_BOX(hbox1), vbox1, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox1), hbox, FALSE, FALSE, 0);
    vbox = vbox1;
#else
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
#endif    
    
    /* lets put the image also in the hbox */
    image = gtk_image_new_from_stock(GAIM_STOCK_LOGO, gtk_icon_size_from_name(GAIM_ICON_SIZE_LOGO));
#ifdef ENABLE_HILDON
    gtk_box_pack_start(GTK_BOX(hbox1), image, FALSE, FALSE, 0);
#else
    gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
#endif
    
    /* And now for the buttons */
    button = gaim_pixbuf_button_from_stock(_("A_ccounts"), GAIM_STOCK_ACCOUNTS, GAIM_BUTTON_VERTICAL);
    gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
    g_signal_connect(G_OBJECT(button), "clicked",
                     G_CALLBACK(gaim_gtk_accounts_window_show), mainwindow);
    gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);

    button = gaim_pixbuf_button_from_stock(_("P_references"), GTK_STOCK_PREFERENCES, GAIM_BUTTON_VERTICAL);
    gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
    g_signal_connect(G_OBJECT(button), "clicked",
                     G_CALLBACK(gaim_gtk_prefs_show), mainwindow);
    gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);

    button = gaim_pixbuf_button_from_stock(_("_Sign on"), GAIM_STOCK_SIGN_ON, GAIM_BUTTON_VERTICAL);
    gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
    g_signal_connect(G_OBJECT(button), "clicked",
                     G_CALLBACK(dologin), mainwindow);
    g_signal_connect(G_OBJECT(button), "button-press-event", G_CALLBACK(domiddleclick), NULL);
    gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);

    hseparator = gtk_hseparator_new ();
    gtk_widget_show (hseparator);
    gtk_box_pack_start (GTK_BOX (vbox), hseparator, FALSE, TRUE, 2);
        
#else
    image = gtk_image_new_from_stock(GAIM_STOCK_LOGO, gtk_icon_size_from_name(GAIM_ICON_SIZE_LOGO));
    gtk_box_pack_start(GTK_BOX(vbox), image, FALSE, FALSE, 0);
#endif    
    
    table = gtk_table_new (2, 2, FALSE);
    gtk_widget_show (table);
    gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0);
    gtk_table_set_row_spacings (GTK_TABLE (table), 2);
    gtk_table_set_col_spacings (GTK_TABLE (table), 2);
    
	/* why isn't there a gtk_label_new_with_markup? */
	label = gtk_label_new(NULL);
	gtk_widget_show (label);
    gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("<b>_Account:</b>"));
	gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
                        (GtkAttachOptions) (GTK_FILL),
                        (GtkAttachOptions) (0), 0, 0);
    gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
    
    
	name = gaim_gtk_account_option_menu_new(NULL, TRUE, G_CALLBACK(combo_changed), NULL, NULL);
	gtk_label_set_mnemonic_widget(GTK_LABEL(label), name);
    gtk_widget_show (name);
    gtk_table_attach (GTK_TABLE (table), name, 1, 2, 0, 1,
                        (GtkAttachOptions) (GTK_FILL),
                        (GtkAttachOptions) (0), 0, 0);

    
	label = gtk_label_new(NULL);
    gtk_widget_show (label);
	gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("<b>_Password:</b>"));
    gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
                        (GtkAttachOptions) (GTK_FILL),
                        (GtkAttachOptions) (0), 0, 0);
    gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);

	pass = gtk_entry_new();
	gtk_label_set_mnemonic_widget(GTK_LABEL(label), pass);
	gtk_entry_set_visibility(GTK_ENTRY(pass), FALSE);
    gtk_table_attach (GTK_TABLE (table), pass, 1, 2, 1, 2,
                (GtkAttachOptions) (GTK_FILL),
                (GtkAttachOptions) (0), 0, 0);
    
    
#ifndef GAIM_SMALL_SCREEN
    g_signal_connect(G_OBJECT(pass), "activate",
                     G_CALLBACK(dologin), mainwindow);
    /*
    gtk_box_pack_start(GTK_BOX(vbox2), pass, FALSE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, TRUE, 0);
    */
    /* Now for the button box */
    hbox = gtk_hbox_new(TRUE, 0);
    /*
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 5);
    */
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);

    /* And now for the buttons */
    button = gaim_pixbuf_button_from_stock(_("A_ccounts"), GAIM_STOCK_ACCOUNTS, GAIM_BUTTON_VERTICAL);
    gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
    g_signal_connect(G_OBJECT(button), "clicked",
                     G_CALLBACK(gaim_gtk_accounts_window_show), mainwindow);
    gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);

    button = gaim_pixbuf_button_from_stock(_("P_references"), GTK_STOCK_PREFERENCES, GAIM_BUTTON_VERTICAL);
    gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
    g_signal_connect(G_OBJECT(button), "clicked",
                     G_CALLBACK(gaim_gtk_prefs_show), mainwindow);
    gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);

    button = gaim_pixbuf_button_from_stock(_("_Sign on"), GAIM_STOCK_SIGN_ON, GAIM_BUTTON_VERTICAL);
    gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
    g_signal_connect(G_OBJECT(button), "clicked",
                     G_CALLBACK(dologin), mainwindow);
    g_signal_connect(G_OBJECT(button), "button-press-event", G_CALLBACK(domiddleclick), NULL);
    gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
#endif
	/* Now grab the focus that we need */
	if (gaim_accounts_get_all()) {
		GaimAccount *account = gaim_accounts_get_all()->data;

		if (gaim_account_get_remember_password(account)) {
			combo_changed(NULL, account, NULL);
			gtk_widget_grab_focus(button);
		} else {
			gtk_widget_grab_focus(pass);
		}
	} else {
		gaim_gtk_accounts_window_show();
		gtk_widget_grab_focus(button);
	}
    
#ifndef ENABLE_HILDON
	/* And raise the curtain! */
	gtk_widget_show_all(mainwindow);
#else
    gtk_widget_show_all(login_app_view);
#endif
}
Пример #2
0
void do_away_message(GtkWidget *w, struct away_message *a)
{
	GtkWidget *back;
	GtkWidget *edit;
	GtkWidget *awaytext;
	GtkWidget *sw;
	GtkWidget *vbox;
	GtkWidget *hbox;
	GtkTreeViewColumn *column;
	GtkCellRenderer *renderer;
	char *buf;

	if (!a)
		return;

	if(imaway)
		gtk_widget_destroy(imaway);

	GAIM_DIALOG(imaway);
	gtk_window_set_role(GTK_WINDOW(imaway), "imaway");
	if (strlen(a->name))
		gtk_window_set_title(GTK_WINDOW(imaway), a->name);
	else
		gtk_window_set_title(GTK_WINDOW(imaway), _("Away!"));
	g_signal_connect(G_OBJECT(imaway), "destroy",
			G_CALLBACK(do_im_back), imaway);

	vbox = gtk_vbox_new(FALSE, 5);
	gtk_container_add(GTK_CONTAINER(imaway), vbox);
	gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
	gtk_widget_show(vbox);

	hbox = gtk_hbox_new(FALSE, 5);
	gtk_container_set_border_width(GTK_CONTAINER(hbox), 0);
	gtk_widget_show(hbox);

	sw = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER,
			GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN);
	gtk_widget_set_size_request(sw, 245, 120);
	gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
	gtk_widget_show(sw);

	awaytext = gtk_imhtml_new(NULL, NULL);
	gtk_container_add(GTK_CONTAINER(sw), awaytext);
	gaim_setup_imhtml(awaytext);
	gtk_widget_show(awaytext);
	buf = stylize(a->message, BUF_LONG);
	gtk_imhtml_append_text(GTK_IMHTML(awaytext), buf, GTK_IMHTML_NO_TITLE |
			GTK_IMHTML_NO_COMMENTS | GTK_IMHTML_NO_SCROLL);
	g_free(buf);
	gtk_imhtml_append_text(GTK_IMHTML(awaytext), "<BR>",
			GTK_IMHTML_NO_TITLE | GTK_IMHTML_NO_COMMENTS |
			GTK_IMHTML_NO_SCROLL);

	awayqueuesw = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(awayqueuesw),
			GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(awayqueuesw),
			GTK_SHADOW_IN);
	gtk_box_pack_start(GTK_BOX(vbox), awayqueuesw, TRUE, TRUE, 0);

	awayqueuestore = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
	awayqueue = gtk_tree_view_new_with_model(GTK_TREE_MODEL(awayqueuestore));
	renderer = gtk_cell_renderer_text_new();

	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(awayqueue), FALSE);
	column = gtk_tree_view_column_new_with_attributes (NULL, renderer,
			"text", 0,
			NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(awayqueue), column);
	column = gtk_tree_view_column_new_with_attributes(NULL, renderer,
			"text", 1,
			NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(awayqueue), column);
	column = gtk_tree_view_column_new_with_attributes(NULL, renderer,
			"text", 2,
			NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(awayqueue), column);

	gtk_container_add(GTK_CONTAINER(awayqueuesw), awayqueue);

	g_signal_connect(G_OBJECT(awayqueue), "button_press_event", G_CALLBACK(dequeue_cb), NULL);


	if (gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) {
		gtk_widget_show(awayqueuesw);
		gtk_widget_show(awayqueue);
	}

	awaymessage = a;

	edit = gaim_pixbuf_button_from_stock(_("Edit This Message"), GTK_STOCK_CONVERT, GAIM_BUTTON_HORIZONTAL);
	gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 0);
	g_signal_connect(G_OBJECT(edit), "clicked", G_CALLBACK(create_away_mess), awaymessage);
	gtk_widget_show(edit);

	back = gaim_pixbuf_button_from_stock(_("I'm Back!"), GTK_STOCK_JUMP_TO, GAIM_BUTTON_HORIZONTAL);
	gtk_box_pack_start(GTK_BOX(hbox), back, TRUE, TRUE, 0);
	g_signal_connect(G_OBJECT(back), "clicked", G_CALLBACK(do_im_back), imaway);
	gtk_window_set_focus(GTK_WINDOW(imaway), back);
	gtk_widget_show(back);

	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

	gtk_widget_show(imaway);
	serv_set_away_all(awaymessage->message);
}