~cahr-gr/gloobus-preview/monitors

« back to all changes in this revision

Viewing changes to src/gloobus-preview-main.cpp

  • Committer: Jordi Puigdellívol
  • Date: 2010-05-26 14:35:12 UTC
  • mfrom: (213.1.33 gloobus-preview)
  • Revision ID: jordi@badchoice-20100526143512-bhndzc2y7o8un30v
Merged, now its really good

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
**3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
 
3
**      10        20        30        40        50        60        70        80
 
4
**
 
5
** gloobus-preview
 
6
**
 
7
** gloobus-preview-main.cpp - 
 
8
**
 
9
** Copyright (c) 2009-2010 Gloobus Developers
 
10
**
 
11
** Authors:
 
12
**    Jordi Puigdellívol Hernández <guitarboy000@gmail.com>
 
13
**    Alexandr Grigorcea <cahr.gr@gmail.com>
 
14
**
 
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.
 
18
**
 
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.
 
23
**
 
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/>.
 
26
**
 
27
*******************************************************************************/
 
28
 
1
29
//Create the POT file
2
30
//xgettext -d gloobus-preview --keyword=_ -s -o gloobus-preview.pot gloobus-preview*.cpp
3
31
 
5
33
#include <config.h>
6
34
#endif
7
35
 
8
 
/*Translations*/
9
 
#include <libintl.h>
10
 
#include <locale.h>
11
 
#define _(String) gettext(String)
12
 
 
13
 
#include <cstdlib>
14
 
#include <gtk/gtk.h>
15
 
#include <gdk/gdkkeysyms.h>
16
 
//#include <cairo.h>
17
 
#include <string>
18
 
 
19
 
#include "gloobus-preview-interface-main.h"
20
 
//#include "iImage.h"
21
 
//#include "iText.h"
22
 
//#include "iMusic.h"
23
 
//#include "iDocument.h"
24
 
//#include "iMovie.h"
25
 
//#include "iList.h"
26
 
 
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"
31
37
 
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"
41
 
 
42
 
using namespace std;
43
 
 
44
 
//GLOBAL VARIABLES TO STORE PLUGINS INFORMATION
45
 
vector<plugin_filetype> pluginVector;                                                           //VECTOR TO STORE WICH FILETYPE READ EACH PLUGIN
46
 
 
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
49
 
 
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
52
 
 
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
55
 
 
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
58
 
 
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
61
 
 
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
64
 
 
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
67
 
 
68
 
 
69
 
void destroy    ( GtkWidget *widget, gpointer data );
70
 
void log_handler(const gchar *log_domain, GLogLevelFlags log_level,const gchar *message, gpointer user_data);
71
 
 
72
 
 
73
 
// ======================================= MAIN ===================================== //
74
38
int main (int argc, char *argv[])
75
39
{
 
40
        setlocale( LC_ALL, "" );
 
41
        bindtextdomain  ( "gloobus-preview", LOCALEDIR);
 
42
        textdomain              ( "gloobus-preview" );
 
43
 
76
44
        //g_thread_init(NULL);
77
45
        //gdk_threads_init();
78
 
 
79
 
        //GETTEXT Initialization
80
 
    setlocale( LC_ALL, "" );
81
 
    bindtextdomain      ( "gloobus-preview", LOCALEDIR);
82
 
    textdomain          ( "gloobus-preview" );
83
 
 
84
 
        // GTK INITIALIZATION   
85
46
        gtk_init (&argc, &argv);
86
 
 
87
 
        //Load Custom RC
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");
93
 
 
94
 
    gloobusConfig config;
95
 
    config.parse_args(argc, argv);
96
 
 
97
 
        bool debug = config.get_cli_debug();
98
 
 
99
 
        g_log_set_handler (NULL, (GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
100
 
                     | G_LOG_FLAG_RECURSION), log_handler, (void*)debug);
101
 
 
102
 
        if(debug) g_message(_("Debug mode: On"));
103
 
 
104
 
        switch(config.get_cli_action()) {
105
 
                case GP_ACTION_PREVIEW:
106
 
                        Gloobus::instance()->show_preview( config.get_cli_target() );
107
 
                        break;
108
 
                case GP_ACTION_FILETYPES:
109
 
                        Gloobus::instance()->show_supported_filetypes();
110
 
                        break;
111
 
                case GP_ACTION_HELP:
112
 
                        Gloobus::instance()->show_help();
113
 
                        break;
114
 
        }
115
 
 
116
 
        return 0;
117
 
}
118
 
 
119
 
// ===================================== DESTROY ===================================== //
120
 
// This function is called when a exit event is recived
121
 
void destroy ( GtkWidget *widget, gpointer data )
122
 
{
123
 
    gtk_main_quit ();
124
 
}
125
 
 
126
 
// =================================== LOG_HANDLER =================================== //
127
 
void log_handler  (const gchar *log_domain,
128
 
        GLogLevelFlags log_level,
129
 
        const gchar *message,
130
 
        gpointer debug)
131
 
{
132
 
        if(!(bool)debug && G_LOG_LEVEL_DEBUG == log_level) {
133
 
                /*do nothing */
134
 
        } else {
135
 
                char add[50]="";
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);
144
 
                }
145
 
                g_print("%s %s\n", add, message);
146
 
        }
147
 
}
148
 
 
149
 
 
 
47
        //gtk_rc_parse(PACKAGE_DATA_PATH "/gtkrc/customgtk.rc");
 
48
 
 
49
        return Gloobus::instance()->init( &argc , &argv );
 
50
}