Browse Source

Prepare to initialize application events.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Slava Zanko 14 years ago
parent
commit
d512649b33
7 changed files with 128 additions and 1 deletions
  1. 1 1
      lib/Makefile.am
  2. 23 0
      lib/event-types.h
  3. 2 0
      lib/event.h
  4. 1 0
      src/Makefile.am
  5. 64 0
      src/events_init.c
  6. 19 0
      src/events_init.h
  7. 18 0
      src/main.c

+ 1 - 1
lib/Makefile.am

@@ -3,7 +3,7 @@ SUBDIRS = event filehighlight mcconfig search skin tty vfs strutil widget
 noinst_LTLIBRARIES = libmc.la
 
 SUBLIB_includes = \
-	event.h \
+	event.h event-types.h \
 	filehighlight.h \
 	mcconfig.h \
 	search.h \

+ 23 - 0
lib/event-types.h

@@ -0,0 +1,23 @@
+#ifndef MC__EVENT_TYPES_H
+#define MC__EVENT_TYPES_H
+
+/*** typedefs(not structures) and defined constants **********************************************/
+
+/* Event groups for main modules */
+#define MCEVENT_GROUP_CORE "Core"
+#define MCEVENT_GROUP_DIFFVIEWER "DiffViewer"
+#define MCEVENT_GROUP_EDITOR "Editor"
+#define MCEVENT_GROUP_FILEMANAGER "FileManager"
+#define MCEVENT_GROUP_VIEWER "Viewer"
+
+/*** enums ***************************************************************************************/
+
+/*** structures declarations (and typedefs of structures)*****************************************/
+
+/*** global variables defined in .c file *********************************************************/
+
+/*** declarations of public functions ************************************************************/
+
+/*** inline functions ****************************************************************************/
+
+#endif /* MC__EVENT_TYPES_H */

+ 2 - 0
lib/event.h

@@ -1,6 +1,8 @@
 #ifndef MC__EVENT_H
 #define MC__EVENT_H
 
+#include "event-types.h"
+
 /*** typedefs(not structures) and defined constants **********************************************/
 
 typedef gboolean (*mc_event_callback_func_t) (const gchar *, const gchar *, gpointer, gpointer);

+ 1 - 0
src/Makefile.am

@@ -62,6 +62,7 @@ mc_SOURCES = \
 	args.c args.h \
 	background.c background.h \
 	clipboard.c clipboard.h \
+	events_init.c events_init.h \
 	execute.c execute.h \
 	help.c help.h \
 	history.h \

+ 64 - 0
src/events_init.c

@@ -0,0 +1,64 @@
+/* Event callbacks initialization
+
+   Copyright (C)  2011 Free Software Foundation, Inc.
+
+   Written by:
+   Slava Zanko <slavazanko@gmail.com>, 2011.
+
+   This file is part of the Midnight Commander.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+
+#include "lib/global.h"
+
+#include "lib/event.h"
+
+#include "events_init.h"
+
+/*** global variables ****************************************************************************/
+
+/*** file scope macro definitions ****************************************************************/
+
+/*** file scope type declarations ****************************************************************/
+
+/*** file scope variables ************************************************************************/
+
+
+/*** file scope functions ************************************************************************/
+/* --------------------------------------------------------------------------------------------- */
+
+/* --------------------------------------------------------------------------------------------- */
+/*** public functions ****************************************************************************/
+/* --------------------------------------------------------------------------------------------- */
+
+gboolean
+events_init (GError ** error)
+{
+    /* *INDENT-OFF* */
+    event_init_t standard_events[] =
+    {
+        {NULL, NULL, NULL, NULL}
+    };
+    /* *INDENT-ON* */
+
+    if (!mc_event_init (error))
+        return FALSE;
+
+    return mc_event_mass_add (standard_events, error);
+}
+
+/* --------------------------------------------------------------------------------------------- */

+ 19 - 0
src/events_init.h

@@ -0,0 +1,19 @@
+#ifndef MC__EVENTS_INIT_H
+#define MC__EVENTS_INIT_H
+
+/*** typedefs(not structures) and defined constants **********************************************/
+
+/*** enums ***************************************************************************************/
+
+/*** structures declarations (and typedefs of structures)*****************************************/
+
+/*** global variables defined in .c file *********************************************************/
+
+
+/*** declarations of public functions ************************************************************/
+
+gboolean events_init (GError **);
+
+/*** inline functions ****************************************************************************/
+
+#endif /* MC__EVENTS_INIT_H */

+ 18 - 0
src/main.c

@@ -41,6 +41,7 @@
 
 #include "lib/global.h"
 
+#include "lib/event.h"
 #include "lib/tty/tty.h"
 #include "lib/tty/key.h"        /* For init_key() */
 #include "lib/tty/win.h"        /* xterm_flag */
@@ -57,6 +58,7 @@
 #include "filemanager/ext.h"    /* flush_extension_file() */
 #include "filemanager/command.h"        /* cmdline */
 
+#include "events_init.h"
 #include "args.h"
 #include "subshell.h"
 #include "setup.h"              /* load_setup() */
@@ -427,6 +429,13 @@ main (int argc, char *argv[])
     bindtextdomain ("mc", LOCALEDIR);
     textdomain ("mc");
 
+    if (!events_init (&error))
+    {
+        fprintf (stderr, _("Failed to run:\n%s\n"), error->message);
+        g_error_free (error);
+        (void) mc_event_deinit (NULL);
+        exit (EXIT_FAILURE);
+    }
 
     /* Set up temporary directory */
     mc_tmpdir ();
@@ -612,8 +621,17 @@ main (int argc, char *argv[])
     g_free (mc_run_param0);
     g_free (mc_run_param1);
 
+    mc_event_deinit (&error);
+
     mc_config_deinit_config_paths ();
 
+    if (error != NULL)
+    {
+        fprintf (stderr, _("\nFailed while close:\n%s\n"), error->message);
+        g_error_free (error);
+        exit (EXIT_FAILURE);
+    }
+
     putchar ('\n');             /* Hack to make shell's prompt start at left of screen */
 
     return 0;