示例#1
0
MessageView *messageview_create(void)
{
	MessageView *messageview;
	GtkWidget *vbox;
	GtkWidget *notebook;
	HeaderView *headerview;
	TextView *textview;
	MimeView *mimeview;

	debug_print(_("Creating message view...\n"));
	messageview = g_new0(MessageView, 1);

	messageview->type = MVIEW_TEXT;

	headerview = headerview_create();

	textview = textview_create();
	textview->messageview = messageview;

	mimeview = mimeview_create();
	mimeview->textview = textview_create();
	mimeview->textview->messageview = messageview;
	mimeview->imageview = imageview_create();
	mimeview->imageview->messageview = messageview;
	mimeview->messageview = messageview;

	notebook = gtk_notebook_new();
	gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE);
	gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
	gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook), TRUE);
	gtk_widget_show(notebook);

	gtk_container_add(GTK_CONTAINER(notebook), GTK_WIDGET_PTR(textview));
	gtk_notebook_set_tab_label_text
		(GTK_NOTEBOOK(notebook), GTK_WIDGET_PTR(textview), _("Text"));

	gtk_container_add(GTK_CONTAINER(notebook), GTK_WIDGET_PTR(mimeview));
	gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(notebook),
					GTK_WIDGET_PTR(mimeview),
					_("Attachments"));

	gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
	gtk_widget_show_all(notebook);

	vbox = gtk_vbox_new(FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET_PTR(headerview),
			   FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
	gtk_widget_show(vbox);

	/* to remove without destroyed */
	gtk_widget_ref(GTK_WIDGET_PTR(mimeview->textview));
	gtk_widget_ref(GTK_WIDGET_PTR(mimeview->imageview));

	g_signal_connect(G_OBJECT(notebook), "switch_page",
			 G_CALLBACK(messageview_switch_page_cb), messageview);

	messageview->vbox        = vbox;
	messageview->notebook    = notebook;

	messageview->new_window  = FALSE;
	messageview->window      = NULL;
	messageview->window_vbox = NULL;
	messageview->body_vbox   = NULL;

	messageview->headerview  = headerview;
	messageview->textview    = textview;
	messageview->mimeview    = mimeview;

	messageview->statusbar     = NULL;
	messageview->statusbar_cid = 0;

	messageview->current_page = 0;

	return messageview;
}
示例#2
0
文件: browser.c 项目: gentoo/pornview
void
browser_create (void)
{
    GtkWidget *vbox;
    GdkPixmap *icon_pix;
    GdkBitmap *icon_mask;
    GtkAccelGroup *accel;
    GtkWidget *menu;
    GtkWidget *toolbar;
    GtkWidget *hpaned;
    GtkWidget *vpaned;
    GtkWidget *iconw;
    GtkWidget *hbox;
    GtkWidget *label;

    browser = g_new (Browser, 1);

    browser->current_path = g_string_new (conf.startup_dir);
    browser->last_path = g_string_new ("");
    browser->filelist = (FileList *) file_list_init ();

    browser->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title (GTK_WINDOW (browser->window), "PornView");
    gtk_widget_realize (browser->window);

    icon_pix =
	gdk_pixmap_create_from_xpm_d (G_WINDOW (browser->window), &icon_mask,
				      NULL, pornview_xpm);
    gdk_window_set_icon (G_WINDOW (browser->window), NULL, icon_pix,
			 icon_mask);

    gtk_signal_connect (GTK_OBJECT (browser->window), "delete_event",
			GTK_SIGNAL_FUNC (browser_destroy), NULL);

    gtk_window_set_default_size (GTK_WINDOW (browser->window),
				 conf.window_width, conf.window_height);

    vbox = gtk_vbox_new (FALSE, 0);
    gtk_widget_show (vbox);
    gtk_container_add (GTK_CONTAINER (browser->window), vbox);

    /*
     * main menu 
     */
    accel = gtk_accel_group_new ();
    browser->menu =
	gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<browser_menu>", accel);

#ifdef ENABLE_NLS
    gtk_item_factory_set_translate_func (browser->menu,
					 (GtkTranslateFunc) menu_translate,
					 NULL, NULL);
#endif

    gtk_item_factory_create_items (browser->menu, browser_menu_factory_count,
				   browser_menu_factory, NULL);
    menu = gtk_item_factory_get_widget (browser->menu, "<browser_menu>");

    gtk_box_pack_start (GTK_BOX (vbox), menu, FALSE, FALSE, 0);
    gtk_widget_show (menu);

#ifndef USE_GTK2
    gtk_accel_group_attach (accel, GTK_OBJECT (browser->window));
#endif

    /*
     * toolbar 
     */
#ifdef USE_GTK2
    toolbar = gtk_toolbar_new ();
#else
    toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS);
#endif

    gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, TRUE, 0);
    gtk_widget_show (toolbar);

    iconw = pixbuf_create_pixmap_from_xpm_data (exit_xpm);
    gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), NULL, _("Exit"), NULL,
			     iconw, (GtkSignalFunc) browser_destroy, NULL);

#ifndef USE_GTK2
    gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
#endif

    gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));

    iconw = pixbuf_create_pixmap_from_xpm_data (options_xpm);
    gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), NULL, _("Preference"),
			     NULL, iconw, (GtkSignalFunc) browser_prefs,
			     NULL);

    hpaned = gedo_hpaned_new ();
    gtk_container_add (GTK_CONTAINER (vbox), hpaned);
    gtk_widget_show (hpaned);

    vpaned = gedo_vpaned_new ();
    gtk_widget_show (vpaned);
    gedo_paned_add1 (GEDO_PANED (hpaned), vpaned);

    /*
     * dirtree 
     */
    dirview_create (conf.startup_dir, browser->window);

    gedo_paned_add1 (GEDO_PANED (vpaned), DIRVIEW_CONTAINER);

    commentview = comment_view_create ();

    browser->notebook = commentview->notebook;

    /*
     * videoplay 
     */
#ifdef ENABLE_MOVIE
    videoplay_create ();
    label = gtk_label_new (_(" Preview "));
    gtk_notebook_prepend_page (GTK_NOTEBOOK (browser->notebook),
			       VIDEOPLAY_CONTAINER, label);

    gtk_notebook_set_page (GTK_NOTEBOOK (browser->notebook), 0);

#endif

    /*
     * imageview
     */
    imageview_create ();
    label = gtk_label_new (_(" Preview "));
    gtk_notebook_prepend_page (GTK_NOTEBOOK (browser->notebook),
			       IMAGEVIEW_CONTAINER, label);

#ifndef ENABLE_MOVIE
    gtk_notebook_set_page (GTK_NOTEBOOK (browser->notebook), 0);
#endif

    gedo_paned_add2 (GEDO_PANED (hpaned), commentview->main_vbox);

    /*
     * thumbview 
     */
    thumbview_create (browser->window);
    gedo_paned_add2 (GEDO_PANED (vpaned), THUMBVIEW_CONTAINER);

    /*
     * statusbar 
     */
    hbox = gtk_hbox_new (FALSE, 0);
    gtk_widget_set_name (hbox, "StatusBarContainer");
    gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
    gtk_widget_show (hbox);

    browser->status_dir = gtk_statusbar_new ();
    gtk_widget_set_name (browser->status_dir, "StatusBar1");
    gtk_container_border_width (GTK_CONTAINER (browser->status_dir), 1);
    gtk_widget_set_usize (browser->status_dir, 80, 15);
    gtk_box_pack_start (GTK_BOX (hbox), browser->status_dir, FALSE, FALSE, 0);
    gtk_widget_show (browser->status_dir);

    browser->status_name = gtk_statusbar_new ();
    gtk_widget_set_name (browser->status_name, "StatusBar2");
    gtk_container_border_width (GTK_CONTAINER (browser->status_name), 1);
    gtk_widget_set_usize (browser->status_name, 150, -1);
    gtk_box_pack_start (GTK_BOX (hbox), browser->status_name, TRUE, TRUE, 0);
    gtk_widget_show (browser->status_name);

    browser->status_image = gtk_statusbar_new ();
    gtk_widget_set_name (browser->status_image, "StatusBar3");
    gtk_container_border_width (GTK_CONTAINER (browser->status_image), 1);
    gtk_widget_set_usize (browser->status_image, 150, -1);
    gtk_box_pack_start (GTK_BOX (hbox), browser->status_image, TRUE, TRUE, 0);
    gtk_widget_show (browser->status_image);

    browser->progress = gtk_progress_bar_new ();
    gtk_widget_set_name (browser->progress, "ProgressBar");
    gtk_box_pack_end (GTK_BOX (hbox), browser->progress, FALSE, FALSE, 0);
    gtk_widget_show (browser->progress);

    gtk_widget_show (browser->window);

#ifdef ENABLE_MOVIE
    gtk_widget_hide (gtk_notebook_get_nth_page
		     (GTK_NOTEBOOK (browser->notebook), 1));
    gtk_notebook_set_page (GTK_NOTEBOOK (browser->notebook), 0);
#endif

    dirview_scroll_center ();
    timer_id = gtk_timeout_add (100, cb_browser_select_dir, conf.startup_dir);
}