gitkMail.c

Go to the documentation of this file.
00001 
00012 #include "config.h"
00013 
00014 #include <glib.h>
00015 #include <stdio.h>
00016 
00017 #include <libgitk/gitk.h>
00018 
00022 static gchar *dialog1_desc=\
00023 "<?xml version=\"1.0\" ?>"\
00024 "<!DOCTYPE giml SYSTEM \"http://gitk.sourceforge.net/giml.dtd\">"\
00025 "<giml xmlns=\""GITK_NS_URL"\""\
00026 " xmlns:dc=\"http://purl.org/dc/elements/1.1/\""\
00027 " xmlns:i18n=\""I18N_NS_URL"\""\
00028 " >"\
00029 "  <dialog>"\
00030 "    <meta>"\
00031 "      <dc:title><i18n:text>dialog 1</i18n:text></dc:title>"\
00032 "    </meta>"\
00033 "  </dialog>"\
00034 "</giml>";
00035 
00039 static gchar *dialog2_desc=\
00040 "<?xml version=\"1.0\" ?>"\
00041 "<!DOCTYPE giml SYSTEM \"http://gitk.sourceforge.net/giml.dtd\">"\
00042 "<giml xmlns=\""GITK_NS_URL"\""\
00043 " xmlns:dc=\"http://purl.org/dc/elements/1.1/\""\
00044 " xmlns:i18n=\""I18N_NS_URL"\""\
00045 " >"\
00046 "  <dialog>"\
00047 "    <meta>"\
00048 "      <dc:title><i18n:text>dialog 2</i18n:text></dc:title>"\
00049 "    </meta>"\
00050 "  </dialog>"\
00051 "</giml>";
00052 
00055 int main(int argc, char **argv) {
00056   guint logger_id;
00057   guint i;
00058   gboolean info_only=FALSE;
00059   gboolean info_help=FALSE, info_version=FALSE;
00060 
00061   logger_id=g_log_set_handler(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG|G_LOG_LEVEL_MESSAGE|G_LOG_LEVEL_WARNING|G_LOG_LEVEL_ERROR, gitk_log_handler, NULL);
00062   gitk_log("-- beg -----------------------");
00063   gitk_log1("prog : %s",argv[0]);
00064 
00065 #ifdef ENABLE_NLS
00066   {
00067     gchar *_locale;
00068     //-- at programm startup locale will be set to "C", this initialises it to the env-var
00069     //_locale=setlocale(LC_ALL, "de");
00070     _locale=setlocale(LC_ALL,"");
00071     bindtextdomain(PACKAGE,LOCALEDIR);
00072     bind_textdomain_codeset(PACKAGE,"UTF-8");
00073     textdomain(PACKAGE);
00074     gitk_log3("\"%s\" NLS enabled for domain \"%s\" in dir \"%s\"",(_locale?_locale:"-"),PACKAGE,LOCALEDIR);
00075   }
00076 #endif
00077 
00078   //-- process commandline args
00079   for(i=1;i<(guint)argc;i++) {
00080     if(!strcmp("--help", argv[i]) || !strcmp("-h", argv[i])) {
00081       info_only=info_help=TRUE;
00082     }
00083     else if(!strcmp("--version", argv[i])) {
00084       info_only=info_version=TRUE;
00085     }
00086   }
00087   if(info_help) {
00088     gitk_printf(_("Usage: %s [OPTION...]\n\n"),argv[0]);
00089     gitk_puts(_("  -h, --help\t\t\tthis help screen"));
00090     gitk_puts(_("      --version\t\t\tshow program version"));
00091     putchar('\n');
00092   }
00093   if(info_version) printf(PACKAGE_NAME"::%s: version "PACKAGE_VERSION" by "PACKAGE_BUGREPORT"\n",argv[0]); 
00094 
00095   //-- init gitk
00096   gitk_init((guint *)&argc,&argv,PACKAGE,LOCALEDIR);
00097   gitk_log("init ok");
00098   if(!info_only) {
00099     gpointer dialog1,dialog2=NULL;
00100     
00101     if((dialog1=gitk_dialog_new_from_string(dialog1_desc))
00102        && (dialog2=gitk_dialog_new_from_string(dialog2_desc))) {
00103       gitk_log("dialogs parsed");
00104       gitk_dialog_show(dialog1,FALSE);
00105       gitk_dialog_show(dialog2,FALSE);
00106       gitk_log("run ...");
00107       gitk_event_loop_start();
00108       gitk_dialog_hide(dialog2);
00109       gitk_dialog_hide(dialog1);
00110     }
00111     else {
00112       gitk_printf(_("error parsing dialog => %d : %s\n"),gitk_get_error_code(),gitk_get_error_str());
00113     }
00114     if(dialog1) gitk_dialog_free(dialog1);
00115     if(dialog2) gitk_dialog_free(dialog2);
00116   }
00117   //-- done gitk
00118   gitk_done();
00119 
00120   gitk_log("-- end -----------------------");
00121   g_log_remove_handler(G_LOG_DOMAIN,logger_id);
00122   return(EXIT_SUCCESS);
00123 }

Generated on Thu Oct 28 10:59:09 2004 for gitk by doxygen 1.3.6