1 /******************************* LICENCE **************************************
2 * Any code in this file may be redistributed or modified under the terms of
3 * the GNU General Public Licence as published by the Free Software
4 * Foundation; version 2 of the licence.
5 ****************************** END LICENCE ***********************************/
6 
7 /******************************************************************************
8 * Author:
9 * Andrew Smith, http://littlesvr.ca/misc/contactandrew.php
10 *
11 * Contributors:
12 * David Johnson
13 * - open an iso file based on command-line parameter
14 * - print a help message when --help parameter given
15 ******************************************************************************/
16 
17 #include <gtk/gtk.h>
18 #include <stdlib.h>
19 #include <stdio.h>
20 #include <time.h>
21 #include <signal.h>
22 
23 #include "isomaster.h"
24 
25 GtkWidget* GBLmainWindow;
26 /* to be able to resize the two file browsers */
27 GtkWidget* GBLbrowserPaned;
28 
29 extern AppSettings GBLappSettings;
30 
main(int argc,char ** argv)31 int main(int argc, char** argv)
32 {
33     GdkPixbuf* appIcon;
34     GtkWidget* mainVBox;
35     GtkWidget* mainFrame; /* to put a border around the window contents */
36     GtkWidget* topPanedBox; /* to pack the top part of GBLbrowserPaned */
37     GtkWidget* bottomPanedBox; /* to pack the bottom part of GBLbrowserPaned */
38     GtkWidget* statusBar;
39 
40     /* if --help passed, return usage help and quit */
41     if (argv[1] != NULL)
42     {
43         if(strcmp(argv[1], "--help") == 0)
44         {
45             printf("Usage: isomaster [image.iso]\n");
46             return 0;
47         }
48     }
49 
50 #ifdef ENABLE_NLS
51     /* initialize gettext */
52     bindtextdomain("isomaster", LOCALEDIR);
53     bind_textdomain_codeset("isomaster", "UTF-8"); /* so that gettext() returns UTF-8 strings */
54     textdomain("isomaster");
55 #endif
56 
57     gtk_init(&argc, &argv);
58 
59     findHomeDir();
60 
61     loadSettings();
62 
63     loadAppIcon(&appIcon);
64 
65     loadIcons();
66 
67     /* set up the signal handler for exiting editors and viewers */
68     signal(SIGUSR1, sigusr1);
69     signal(SIGUSR2, sigusr2);
70 
71     /* make sure childrent don't become zombies */
72     signal(SIGCHLD, SIG_IGN);
73 
74     /* main window */
75     GBLmainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
76     gtk_window_set_default_size(GTK_WINDOW(GBLmainWindow),
77                                 GBLappSettings.windowWidth, GBLappSettings.windowHeight);
78     gtk_window_set_title(GTK_WINDOW(GBLmainWindow), "ISO Master");
79     gtk_window_set_icon(GTK_WINDOW(GBLmainWindow), appIcon); /* NULL is ok */
80     gtk_widget_show(GBLmainWindow);
81     g_signal_connect(G_OBJECT(GBLmainWindow), "delete_event",
82                      G_CALLBACK(closeMainWindowCbk), NULL);
83 
84     mainVBox = gtk_vbox_new(FALSE, 0);
85     gtk_container_add(GTK_CONTAINER(GBLmainWindow), mainVBox);
86     gtk_widget_show(mainVBox);
87 
88     buildMenu(mainVBox);
89 
90     buildMainToolbar(mainVBox);
91 
92     buildFsLocator(mainVBox);
93 
94     mainFrame = gtk_frame_new(NULL);
95     gtk_frame_set_shadow_type(GTK_FRAME(mainFrame), GTK_SHADOW_IN);
96     gtk_box_pack_start(GTK_BOX(mainVBox), mainFrame, TRUE, TRUE, 0);
97     gtk_widget_show(mainFrame);
98 
99     GBLbrowserPaned = gtk_vpaned_new();
100     gtk_container_add(GTK_CONTAINER(mainFrame), GBLbrowserPaned);
101     gtk_widget_show(GBLbrowserPaned);
102     gtk_paned_set_position(GTK_PANED(GBLbrowserPaned), GBLappSettings.topPaneHeight);
103 
104     topPanedBox = gtk_vbox_new(FALSE, 0);
105     gtk_paned_pack1(GTK_PANED(GBLbrowserPaned), topPanedBox, TRUE, FALSE);
106     gtk_widget_show(topPanedBox);
107 
108     buildFsBrowser(topPanedBox);
109 
110     bottomPanedBox = gtk_vbox_new(FALSE, 0);
111     gtk_paned_pack2(GTK_PANED(GBLbrowserPaned), bottomPanedBox, TRUE, FALSE);
112     gtk_widget_show(bottomPanedBox);
113 
114     buildMiddleToolbar(bottomPanedBox);
115 
116     buildIsoLocator(bottomPanedBox);
117 
118     buildIsoBrowser(bottomPanedBox);
119 
120     statusBar = gtk_statusbar_new();
121     gtk_widget_show(statusBar);
122     gtk_box_pack_start(GTK_BOX(mainVBox), statusBar, FALSE, FALSE, 0);
123 
124     if(argv[1] != NULL)
125         openIso(argv[1]);
126 
127 #ifndef HAVE_ARC4RANDOM
128     srandom((int)time(NULL));
129 #endif
130 
131     gtk_main();
132 
133     return 0;
134 }
135