1
/*******************************************************************************
2
**3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
3
** 10 20 30 40 50 60 70 80
7
** gloobus-preview-main.cpp -
9
** Copyright (c) 2009-2010 Gloobus Developers
12
** Jordi Puigdellívol Hernández <guitarboy000@gmail.com>
13
** Alexandr Grigorcea <cahr.gr@gmail.com>
15
** This program is free software: you can redistribute it and/or modify it
16
** under the terms of the GNU General Public License version 3, as published
17
** by the Free Software Foundation.
19
** This program is distributed in the hope that it will be useful, but
20
** WITHOUT ANY WARRANTY; without even the implied warranties of
21
** MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
22
** PURPOSE. See the GNU General Public License for more details.
24
** You should have received a copy of the GNU General Public License along
25
** with this program. If not, see <http://www.gnu.org/licenses/>.
27
*******************************************************************************/
1
29
//Create the POT file
2
30
//xgettext -d gloobus-preview --keyword=_ -s -o gloobus-preview.pot gloobus-preview*.cpp
11
#define _(String) gettext(String)
15
#include <gdk/gdkkeysyms.h>
19
#include "gloobus-preview-interface-main.h"
23
//#include "iDocument.h"
27
#include "gloobus-preview-config.h"
28
#include "gloobus-preview-window.h"
29
#include "gloobus-preview-defines.h"
30
36
#include "gloobus-preview-singleton.h"
32
#include "gloobus-preview-interface-main.h"
33
#include "gloobus-preview-interface-image.h"
34
#include "gloobus-preview-interface-text.h"
35
#include "gloobus-preview-interface-music.h"
36
#include "gloobus-preview-interface-document.h"
37
#include "gloobus-preview-interface-video.h"
38
#include "gloobus-preview-interface-list.h"
39
#include "gloobus-preview-interface-free.h"
40
#include "gloobus-preview-interface-default.h"
44
//GLOBAL VARIABLES TO STORE PLUGINS INFORMATION
45
vector<plugin_filetype> pluginVector; //VECTOR TO STORE WICH FILETYPE READ EACH PLUGIN
47
map <string, create_t_image *, less<string> > factory_image; //Global variable that plugin uses to register
48
map <string, destroy_t_image *, less<string> > factoryDestroy_image; //MAP WITH NAME AND DESTRUCTOR
50
map <string, create_t_music *, less<string> > factory_music; //Global variable that plugin uses to register
51
map <string, destroy_t_music *, less<string> > factoryDestroy_music; //MAP WITH NAME AND DESTRUCTOR
53
map <string, create_t_movie *, less<string> > factory_movie; //Global variable that plugin uses to register
54
map <string, destroy_t_movie *, less<string> > factoryDestroy_movie; //MAP WITH NAME AND DESTRUCTOR
56
map <string, create_t_text *, less<string> > factory_text; //Global variable that plugin uses to register
57
map <string, destroy_t_text *, less<string> > factoryDestroy_text; //MAP WITH NAME AND DESTRUCTOR
59
map <string, create_t_document *, less<string> > factory_document; //Global variable that plugin uses to register
60
map <string, destroy_t_document *, less<string> > factoryDestroy_document; //MAP WITH NAME AND DESTRUCTOR
62
map <string, create_t_list *, less<string> > factory_list; //Global variable that plugin uses to register
63
map <string, destroy_t_list *, less<string> > factoryDestroy_list; //MAP WITH NAME AND DESTRUCTOR
65
map <string, create_t_free *, less<string> > factory_free; //Global variable that plugin uses to register
66
map <string, destroy_t_free *, less<string> > factoryDestroy_free; //MAP WITH NAME AND DESTRUCTOR
69
void destroy ( GtkWidget *widget, gpointer data );
70
void log_handler(const gchar *log_domain, GLogLevelFlags log_level,const gchar *message, gpointer user_data);
73
// ======================================= MAIN ===================================== //
74
38
int main (int argc, char *argv[])
40
setlocale( LC_ALL, "" );
41
bindtextdomain ( "gloobus-preview", LOCALEDIR);
42
textdomain ( "gloobus-preview" );
76
44
//g_thread_init(NULL);
77
45
//gdk_threads_init();
79
//GETTEXT Initialization
80
setlocale( LC_ALL, "" );
81
bindtextdomain ( "gloobus-preview", LOCALEDIR);
82
textdomain ( "gloobus-preview" );
85
46
gtk_init (&argc, &argv);
88
//string gtkstr = (string)PACKAGE_DATA_PATH + "/gtkrc/customgtk.rc";
89
//string pixmap_source = "pixmap_path = \"" + (string)PACKAGE_DATA_PATH + "/gtkrc\"";
90
//gtk_rc_parse (gtkstr.c_str());
91
//gtk_rc_parse_string (pixmap_source.c_str());
92
gtk_rc_parse(PACKAGE_DATA_PATH "/gtkrc/customgtk.rc");
95
config.parse_args(argc, argv);
97
bool debug = config.get_cli_debug();
99
g_log_set_handler (NULL, (GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
100
| G_LOG_FLAG_RECURSION), log_handler, (void*)debug);
102
if(debug) g_message(_("Debug mode: On"));
104
switch(config.get_cli_action()) {
105
case GP_ACTION_PREVIEW:
106
Gloobus::instance()->show_preview( config.get_cli_target() );
108
case GP_ACTION_FILETYPES:
109
Gloobus::instance()->show_supported_filetypes();
112
Gloobus::instance()->show_help();
119
// ===================================== DESTROY ===================================== //
120
// This function is called when a exit event is recived
121
void destroy ( GtkWidget *widget, gpointer data )
126
// =================================== LOG_HANDLER =================================== //
127
void log_handler (const gchar *log_domain,
128
GLogLevelFlags log_level,
129
const gchar *message,
132
if(!(bool)debug && G_LOG_LEVEL_DEBUG == log_level) {
136
if (log_level== G_LOG_LEVEL_MESSAGE) {
137
strcpy(add, CLI_COLOR_BOLD "[INFO]" CLI_COLOR_RESET);
138
} else if (log_level == G_LOG_LEVEL_DEBUG) {
139
strcpy(add, CLI_COLOR_BLUE "[DEBUG]" CLI_COLOR_RESET);
140
} else if (log_level== G_LOG_LEVEL_WARNING) {
141
strcpy(add, CLI_COLOR_RED "[WARNING]" CLI_COLOR_RESET);
142
} else if (log_level== G_LOG_LEVEL_CRITICAL) {
143
strcpy(add, CLI_COLOR_DARKRED "[CRITICAL]" CLI_COLOR_RESET);
145
g_print("%s %s\n", add, message);
47
//gtk_rc_parse(PACKAGE_DATA_PATH "/gtkrc/customgtk.rc");
49
return Gloobus::instance()->init( &argc , &argv );