Partitally implemented search feature.
[mediadatabase.git] / gtk / main.c
blob4888ba220710a2fea78c43d14c77e45d25dbcc34
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*****************************************************************************
4 * $Id: main.c,v 1.3 2004/05/21 23:43:38 nedko Exp $
6 * DESCRIPTION:
7 *
9 * NOTES:
12 *****************************************************************************/
14 #include <stdlib.h>
15 #include <string.h>
16 #include <gtk/gtk.h>
17 #include <cfl.h>
19 #include "../result.h"
20 #include "../libdb/libdb.h"
21 #include "../libfrontend/conf.h"
22 #include "../libfrontend/db.h"
23 #include "../libfrontend/disk.h"
24 #include "../libfrontend/error.h"
25 #include "medias.h"
27 const char *pszPathToExecutable;
28 GtkWidget *pMainWindow = NULL;
30 void
31 SetDefaults()
33 db_set_defaults();
35 disk_set_defaults();
38 void
39 mediadb_error_callback(
40 unsigned int nCritical,
41 const char *pszErrorDescription
44 GtkWidget *pDialog;
46 g_warning("%s\n", pszErrorDescription);
48 pDialog = gtk_message_dialog_new(
49 GTK_WINDOW(pMainWindow),
50 GTK_DIALOG_DESTROY_WITH_PARENT,
51 GTK_MESSAGE_ERROR,
52 GTK_BUTTONS_CLOSE,
53 "%s",
54 pszErrorDescription);
55 gtk_dialog_run(GTK_DIALOG(pDialog));
56 gtk_widget_destroy(pDialog);
58 if (nCritical == MEDIADB_ERROR_CRITICAL)
60 exit(1);
64 int
65 main(
66 int argc,
67 char ** argv
70 char *pszExecutable;
72 gtk_init(&argc, &argv);
74 /* FIXME: pszPathToExecutable calculation is ugly workaround */
75 pszExecutable = strrchr(argv[0], '/');
77 if (pszExecutable == NULL)
79 pszExecutable = argv[0];
80 pszPathToExecutable = "";
82 else
84 *pszExecutable = 0;
85 pszExecutable++;
86 pszPathToExecutable = argv[0];
89 /* Look into configuration file */
91 conf_parse();
93 SetDefaults();
95 db_open();
97 pMainWindow = CreateMediasWindow();
99 gtk_main();
101 db_close();
103 db_uninit();
105 return 0;
108 /*****************************************************************************
110 * Modifications log:
112 * !!! WARNING !!! Following lines are automatically updated by the CVS system.
114 * $Log: main.c,v $
115 * Revision 1.3 2004/05/21 23:43:38 nedko
116 * Implement media window.
118 * Revision 1.2 2004/05/16 20:19:08 nedko
119 * Display MessageDialog on error.
120 * Detect row activation within media list.
121 * Set sane default windows size.
123 * Revision 1.1 2004/05/16 19:05:38 nedko
124 * Initial revision of the gtk frontend.
126 *****************************************************************************/