comparison src/main.c @ 1017:a8b874774b83

Move some code to new functions, to simplify main().
author zas_
date Sun, 31 Aug 2008 08:41:42 +0000
parents 2cdcf67e9300
children 7789dff37086
comparison
equal deleted inserted replaced
1016:9865e22d05f3 1017:a8b874774b83
563 } 563 }
564 } 564 }
565 g_free(buf); 565 g_free(buf);
566 } 566 }
567 567
568 568 static void accel_map_save(void)
569 static void exit_program_final(void)
570 { 569 {
571 gchar *path; 570 gchar *path;
572 gchar *pathl; 571 gchar *pathl;
573 LayoutWindow *lw = NULL;
574
575 remote_close(remote_connection);
576
577 collect_manager_flush();
578
579 sync_options_with_current_state(options);
580 save_options(options);
581 keys_save();
582 572
583 path = g_build_filename(homedir(), GQ_RC_DIR, "accels", NULL); 573 path = g_build_filename(homedir(), GQ_RC_DIR, "accels", NULL);
584 pathl = path_from_utf8(path); 574 pathl = path_from_utf8(path);
585 gtk_accel_map_save(pathl); 575 gtk_accel_map_save(pathl);
586 g_free(pathl); 576 g_free(pathl);
587 g_free(path); 577 g_free(path);
578 }
579
580 static void accel_map_load(void)
581 {
582 gchar *path;
583 gchar *pathl;
584
585 path = g_build_filename(homedir(), GQ_RC_DIR, "accels", NULL);
586 pathl = path_from_utf8(path);
587 gtk_accel_map_load(pathl);
588 g_free(pathl);
589 g_free(path);
590 }
591
592 static void gtkrc_load(void)
593 {
594 gchar *path;
595 gchar *pathl;
596
597 /* If a gtkrc file exists in the rc directory, add it to the
598 * list of files to be parsed at the end of gtk_init() */
599 path = g_build_filename(homedir(), GQ_RC_DIR, "gtkrc", NULL);
600 pathl = path_from_utf8(path);
601 if (access(pathl, R_OK) == 0)
602 gtk_rc_add_default_file(pathl);
603 g_free(pathl);
604 g_free(path);
605 }
606
607 static void exit_program_final(void)
608 {
609 LayoutWindow *lw = NULL;
610
611 remote_close(remote_connection);
612
613 collect_manager_flush();
614
615 sync_options_with_current_state(options);
616 save_options(options);
617 keys_save();
618 accel_map_save();
588 619
589 if (layout_valid(&lw)) 620 if (layout_valid(&lw))
590 { 621 {
591 layout_free(lw); 622 layout_free(lw);
592 } 623 }
664 GList *cmd_list = NULL; 695 GList *cmd_list = NULL;
665 GList *collection_list = NULL; 696 GList *collection_list = NULL;
666 CollectionData *first_collection = NULL; 697 CollectionData *first_collection = NULL;
667 gchar *geometry = NULL; 698 gchar *geometry = NULL;
668 gchar *buf; 699 gchar *buf;
669 gchar *bufl;
670 CollectionData *cd = NULL; 700 CollectionData *cd = NULL;
671 701
672 #ifdef HAVE_GTHREAD 702 #ifdef HAVE_GTHREAD
673 g_thread_init (NULL); 703 g_thread_init (NULL);
674 #endif 704 #endif
703 setup_default_options(options); 733 setup_default_options(options);
704 load_options(options); 734 load_options(options);
705 735
706 parse_command_line(argc, argv, &cmd_path, &cmd_file, &cmd_list, &collection_list, &geometry); 736 parse_command_line(argc, argv, &cmd_path, &cmd_file, &cmd_list, &collection_list, &geometry);
707 737
708 /* If a gtkrc file exists in the rc directory, add it to the 738 gtkrc_load();
709 * list of files to be parsed at the end of gtk_init() */
710 buf = g_build_filename(homedir(), GQ_RC_DIR, "gtkrc", NULL);
711 bufl = path_from_utf8(buf);
712 if (access(bufl, R_OK) == 0)
713 gtk_rc_add_default_file(bufl);
714 g_free(bufl);
715 g_free(buf);
716
717 gtk_init(&argc, &argv); 739 gtk_init(&argc, &argv);
718 740
719 if (gtk_major_version < GTK_MAJOR_VERSION || 741 if (gtk_major_version < GTK_MAJOR_VERSION ||
720 (gtk_major_version == GTK_MAJOR_VERSION && gtk_minor_version < GTK_MINOR_VERSION) ) 742 (gtk_major_version == GTK_MAJOR_VERSION && gtk_minor_version < GTK_MINOR_VERSION) )
721 { 743 {
733 755
734 keys_load(); 756 keys_load();
735 filter_add_defaults(); 757 filter_add_defaults();
736 filter_rebuild(); 758 filter_rebuild();
737 759
738 buf = g_build_filename(homedir(), GQ_RC_DIR, "accels", NULL); 760 accel_map_load();
739 bufl = path_from_utf8(buf);
740 gtk_accel_map_load(bufl);
741 g_free(bufl);
742 g_free(buf);
743 761
744 if (startup_blank) 762 if (startup_blank)
745 { 763 {
746 g_free(cmd_path); 764 g_free(cmd_path);
747 cmd_path = NULL; 765 cmd_path = NULL;