ctb/src/main.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <gtk/gtk.h>
00032 #include <glib.h>
00033 #include <stdlib.h>
00034 #include <unistd.h>
00035
00036 #include "ctb_log.h"
00037 #include "fileview.h"
00038 #include "filemodel.h"
00039 #include "i18n.h"
00040 #include "ipc.h"
00041 #include "menu.h"
00042
00043
00044
00045
00046
00047 static const char *rc_filename = DATADIR "/" PACKAGE_NAME ".rc";
00048
00049 static const char *EMULATOR_HOSTNAME = "qemuarm";
00050
00051
00052 void main_set_locale (const char *locale)
00053 {
00054 LOGPRINTF("entry: locale [%s]", locale);
00055
00056 const char *old_locale = g_getenv("LANG");
00057
00058 if (!old_locale || (strcmp(old_locale, locale) != 0))
00059 {
00060 LOGPRINTF("Locale has changed to %s", locale);
00061
00062
00063 g_setenv("LANG", locale, TRUE);
00064 setlocale(LC_ALL, "");
00065
00066
00067 menu_set_text();
00068 fileview_update_screen_texts();
00069 }
00070 }
00071
00072
00073 void main_quit (void)
00074 {
00075 gtk_main_quit();
00076 }
00077
00078
00079 static gboolean on_startup_complete (gpointer data)
00080 {
00081 ipc_sys_startup_complete();
00082 return FALSE;
00083 }
00084
00085
00086 int main (int argc, char *argv[])
00087 {
00088 textdomain(GETTEXT_PACKAGE);
00089
00090 gtk_init(&argc, &argv);
00091 gchar** files = gtk_rc_get_default_files();
00092 while (*files)
00093 {
00094 LOGPRINTF("gtk_rc_get_default_files [%s]", *files);
00095 files++;
00096 }
00097
00098 ipc_init(main_quit, main_set_locale, fileview_media_mounted, fileview_media_unmounted);
00099 menu_init();
00100 fileview_init();
00101
00102 LOGPRINTF("gtk_rc_parse [%s]", rc_filename);
00103 gtk_rc_parse(rc_filename);
00104
00105 fileview_create();
00106
00107
00108 char hostname[100];
00109 int rc = gethostname(hostname, sizeof(hostname));
00110 if ( rc == 0
00111 && strcmp(hostname, EMULATOR_HOSTNAME) == 0 )
00112 {
00113 WARNPRINTF("Emulator mode: mounting fake card");
00114 storage_media_mounted(DIR_LIBRARY);
00115 }
00116
00117 g_idle_add(on_startup_complete, NULL);
00118 gdk_threads_enter();
00119 gtk_main();
00120 gdk_threads_leave();
00121
00122 filemodel_quit();
00123
00124 return 0;
00125 }
00126