Make modules more flexible (builtin or loaded are identical). Add a test module
[lttv.git] / ltt / branches / poly / lttv / modules / gui / statistics / statistics.c
index 9bd4b8d6f1ded28fbd42554e3f7d51010aca6e70..101f83e942a51148640f3bae8d89da599d3e3a66 100644 (file)
@@ -17,7 +17,6 @@
  */
 
 #include <glib.h>
-#include <gmodule.h>
 #include <gtk/gtk.h>
 #include <gdk/gdk.h>
 
@@ -116,59 +115,6 @@ struct _StatisticViewerData{
 };
 
 
-/**
- * plugin's init function
- *
- * This function initializes the Statistic Viewer functionnality through the
- * gtkTraceSet API.
- */
-G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) {
-
-  statistic_main_win_module = lttv_module_require(self, "mainwin", argc, argv);
-  
-  if(statistic_main_win_module == NULL){
-      g_critical("Can't load Statistic Viewer : missing mainwin\n");
-      return;
-  }
-
-  statistic_traceset = g_ptr_array_new ();
-
-  /* Register the toolbar insert button */
-  toolbar_item_reg(hGuiStatisticInsert_xpm, "Insert Statistic Viewer", h_gui_statistic);
-  
-  /* Register the menu item insert entry */
-  menu_item_reg("/", "Insert Statistic Viewer", h_gui_statistic);
-  
-}
-
-void statistic_destroy_walk(gpointer data, gpointer user_data)
-{
-  gui_statistic_destructor((StatisticViewerData*)data);
-}
-
-/**
- * plugin's destroy function
- *
- * This function releases the memory reserved by the module and unregisters
- * everything that has been registered in the gtkTraceSet API.
- */
-G_MODULE_EXPORT void destroy() {
-  int i;
-  
-  if(g_statistic_viewer_data_list){
-    g_slist_foreach(g_statistic_viewer_data_list, statistic_destroy_walk, NULL );    
-    g_slist_free(g_statistic_viewer_data_list);
-  }
-  g_ptr_array_free (statistic_traceset, TRUE);
-
-  /* Unregister the toolbar insert button */
-  toolbar_item_unreg(h_gui_statistic);
-  
-  /* Unregister the menu item insert entry */
-  menu_item_unreg(h_gui_statistic);
-}
-
-
 void
 gui_statistic_free(StatisticViewerData *statistic_viewer_data)
 { 
@@ -693,3 +639,53 @@ void statistic_remove_context_hooks(StatisticViewerData * statistic_viewer_data,
 }
 
 
+/**
+ * plugin's init function
+ *
+ * This function initializes the Statistic Viewer functionnality through the
+ * gtkTraceSet API.
+ */
+static void init() {
+
+  statistic_traceset = g_ptr_array_new ();
+
+  /* Register the toolbar insert button */
+  toolbar_item_reg(hGuiStatisticInsert_xpm, "Insert Statistic Viewer", h_gui_statistic);
+  
+  /* Register the menu item insert entry */
+  menu_item_reg("/", "Insert Statistic Viewer", h_gui_statistic);
+  
+}
+
+void statistic_destroy_walk(gpointer data, gpointer user_data)
+{
+  gui_statistic_destructor((StatisticViewerData*)data);
+}
+
+/**
+ * plugin's destroy function
+ *
+ * This function releases the memory reserved by the module and unregisters
+ * everything that has been registered in the gtkTraceSet API.
+ */
+static void destroy() {
+  int i;
+  
+  if(g_statistic_viewer_data_list){
+    g_slist_foreach(g_statistic_viewer_data_list, statistic_destroy_walk, NULL );    
+    g_slist_free(g_statistic_viewer_data_list);
+  }
+  g_ptr_array_free (statistic_traceset, TRUE);
+
+  /* Unregister the toolbar insert button */
+  toolbar_item_unreg(h_gui_statistic);
+  
+  /* Unregister the menu item insert entry */
+  menu_item_unreg(h_gui_statistic);
+}
+
+
+LTTV_MODULE("guistatistics", "Statistics viewer", \
+    "Graphical module to view statistics about processes, CPUs and systems", \
+    init, destroy, "mainwin")
+
This page took 0.031997 seconds and 4 git commands to generate.