示例#1
0
文件: mime.c 项目: VoxOx/VoxOx
GaimMimeDocument *
gaim_mime_document_new()
{
	GaimMimeDocument *doc;

	doc = g_new0(GaimMimeDocument, 1);
	fields_init(&doc->fields);

	return doc;
}
示例#2
0
文件: mime.c 项目: VoxOx/VoxOx
static GaimMimePart *
part_new(GaimMimeDocument *doc)
{
	GaimMimePart *part;

	part = g_new0(GaimMimePart, 1);
	fields_init(&part->fields);
	part->doc = doc;
	part->data = g_string_new(NULL);

	doc->parts = g_list_prepend(doc->parts, part);

	return part;
}
示例#3
0
文件: gtetrinet.c 项目: nwf/gtetrinet
int main (int argc, char *argv[])
{
    GtkWidget *label;
    GdkPixbuf *icon_pixbuf;
    GError *err = NULL;
    
    bindtextdomain(PACKAGE, LOCALEDIR);
    bind_textdomain_codeset(PACKAGE, "UTF-8");
    textdomain(PACKAGE);

    srand (time(NULL));

    gnome_program_init (APPID, APPVERSION, LIBGNOMEUI_MODULE,
                        argc, argv, GNOME_PARAM_POPT_TABLE, options,
                        GNOME_PARAM_NONE);

    textbox_setup (); /* needs to be done before text boxes are created */
    
    /* Initialize the GConf library */
    if (!gconf_init (argc, argv, &err))
    {
      fprintf (stderr, _("Failed to init GConf: %s\n"), err->message);
      g_error_free (err); 
      err = NULL;
    }
  
    /* Start a GConf client */
    gconf_client = gconf_client_get_default ();
  
    /* Add the GTetrinet directories to the list of directories that GConf client must watch */
    gconf_client_add_dir (gconf_client, "/apps/gtetrinet/sound",
                          GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
    
    gconf_client_add_dir (gconf_client, "/apps/gtetrinet/themes",
                          GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
  
    gconf_client_add_dir (gconf_client, "/apps/gtetrinet/keys",
                          GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);

    gconf_client_add_dir (gconf_client, "/apps/gtetrinet/partyline",
                          GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);

    /* Request notification of change for these gconf keys */
    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/sound/midi_player",
                             (GConfClientNotifyFunc) sound_midi_player_changed,
			     NULL, NULL, NULL);
                             
    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/sound/enable_sound",
                             (GConfClientNotifyFunc) sound_enable_sound_changed,
			     NULL, NULL, NULL);
                             
    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/sound/enable_midi",
                             (GConfClientNotifyFunc) sound_enable_midi_changed,
			     NULL, NULL, NULL);
                             
    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/themes/theme_dir",
                             (GConfClientNotifyFunc) themes_theme_dir_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/down",
                             (GConfClientNotifyFunc) keys_down_changed, NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/left",
                             (GConfClientNotifyFunc) keys_left_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/right",
                             (GConfClientNotifyFunc) keys_right_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/rotate_left",
                             (GConfClientNotifyFunc) keys_rotate_left_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/rotate_right",
                             (GConfClientNotifyFunc) keys_rotate_right_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/drop",
                             (GConfClientNotifyFunc) keys_drop_changed, NULL,
			     NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/message",
			     (GConfClientNotifyFunc) keys_message_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/discard",
			     (GConfClientNotifyFunc) keys_discard_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special1",
                             (GConfClientNotifyFunc) keys_special1_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special2",
                             (GConfClientNotifyFunc) keys_special2_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special3",
                             (GConfClientNotifyFunc) keys_special3_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special4",
                             (GConfClientNotifyFunc) keys_special4_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special5",
                             (GConfClientNotifyFunc) keys_special5_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special6",
                             (GConfClientNotifyFunc) keys_special6_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special_self",
                             (GConfClientNotifyFunc) keys_special_self_changed,
                            NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/partyline/enable_timestamps",
                             (GConfClientNotifyFunc) partyline_enable_timestamps_changed,
			     NULL, NULL, NULL);
    
    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/partyline/enable_channel_list",
                             (GConfClientNotifyFunc) partyline_enable_channel_list_changed,
			     NULL, NULL, NULL);

    /* load settings */
    config_loadconfig ();

    /* initialise some stuff */
    fields_init ();
    if (!g_thread_supported()) g_thread_init (NULL);

    /* first set up the display */

    /* create the main window */
    app = gnome_app_new (APPID, APPNAME);

    g_signal_connect (G_OBJECT(app), "destroy",
                        GTK_SIGNAL_FUNC(destroymain), NULL);
    keypress_signal = g_signal_connect (G_OBJECT(app), "key-press-event",
                                        GTK_SIGNAL_FUNC(keypress), NULL);
    g_signal_connect (G_OBJECT(app), "key-release-event",
                        GTK_SIGNAL_FUNC(keyrelease), NULL);
    gtk_widget_set_events (app, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);

    gtk_window_set_resizable (GTK_WINDOW (app), TRUE);
    
    /* create and set the window icon */
    icon_pixbuf = gdk_pixbuf_new_from_file (PIXMAPSDIR "/gtetrinet.png", NULL);
    if (icon_pixbuf)
    {
      gtk_window_set_icon (GTK_WINDOW (app), icon_pixbuf);
      gdk_pixbuf_unref (icon_pixbuf);
    }

    /* create the notebook */
    notebook = gtk_notebook_new ();
    gtk_notebook_set_tab_pos (GTK_NOTEBOOK(notebook), GTK_POS_TOP);

    /* put it in the main window */
    gnome_app_set_contents (GNOME_APP(app), notebook);

    /* make menus + toolbar */
    make_menus (GNOME_APP(app));

    /* create the pages in the notebook */
    fieldswidget = fields_page_new ();
    gtk_widget_set_sensitive (fieldswidget, TRUE);
    gtk_widget_show (fieldswidget);
    pfields = gtk_hbox_new (FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER(pfields), 0);
    gtk_container_add (GTK_CONTAINER(pfields), fieldswidget);
    gtk_widget_show (pfields);
    g_object_set_data (G_OBJECT(fieldswidget), "title", "Playing Fields"); // FIXME
    label = pixmapdata_label (fields_xpm, _("Playing Fields"));
    gtk_widget_show (label);
    gtk_notebook_append_page (GTK_NOTEBOOK(notebook), pfields, label);

    partywidget = partyline_page_new ();
    gtk_widget_show (partywidget);
    pparty = gtk_hbox_new (FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER(pparty), 0);
    gtk_container_add (GTK_CONTAINER(pparty), partywidget);
    gtk_widget_show (pparty);
    g_object_set_data (G_OBJECT(partywidget), "title", "Partyline"); // FIXME
    label = pixmapdata_label (partyline_xpm, _("Partyline"));
    gtk_widget_show (label);
    gtk_notebook_append_page (GTK_NOTEBOOK(notebook), pparty, label);

    winlistwidget = winlist_page_new ();
    gtk_widget_show (winlistwidget);
    pwinlist = gtk_hbox_new (FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER(pwinlist), 0);
    gtk_container_add (GTK_CONTAINER(pwinlist), winlistwidget);
    gtk_widget_show (pwinlist);
    g_object_set_data (G_OBJECT(winlistwidget), "title", "Winlist"); // FIXME
    label = pixmapdata_label (winlist_xpm, _("Winlist"));
    gtk_widget_show (label);
    gtk_notebook_append_page (GTK_NOTEBOOK(notebook), pwinlist, label);

    /* add signal to focus the text entry when switching to the partyline page*/
    g_signal_connect_after(G_OBJECT (notebook), "switch-page",
		           GTK_SIGNAL_FUNC (switch_focus),
		           NULL);

    gtk_widget_show (notebook);
    g_object_set (G_OBJECT (notebook), "can-focus", FALSE, NULL);

    partyline_show_channel_list (list_enabled);
    gtk_widget_show (app);

//    gtk_widget_set_size_request (partywidget, 480, 360);
//    gtk_widget_set_size_request (winlistwidget, 480, 360);

    /* initialise some stuff */
    commands_checkstate ();

    /* check command line params */
#ifdef DEBUG
    printf ("option_connect: %s\n"
            "option_nick: %s\n"
            "option_team: %s\n"
            "option_pass: %s\n"
            "option_spec: %i\n",
            option_connect, option_nick, option_team,
            option_pass, option_spec);
#endif
    if (option_nick) GTET_O_STRCPY(nick, option_nick);
    if (option_team) GTET_O_STRCPY(team, option_team);
    if (option_pass) GTET_O_STRCPY(specpassword, option_pass);
    if (option_spec) spectating = TRUE;
    if (option_connect) {
        client_init (option_connect, nick);
    }

    /* Don't schedule if data is ready, glib should do this itself,
     * but welcome to anything that works... */
    g_main_context_set_poll_func(NULL, gtetrinet_poll_func);

    /* gtk_main() */
    gtk_main ();

    client_disconnect ();
    /* cleanup */
    fields_cleanup ();
    sound_stopmidi ();

    return 0;
}