00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "heraia_types.h"
00026
00027 static gboolean delete_plw_window_event(GtkWidget *widget, GdkEvent *event, gpointer data);
00028 static void destroy_plw_window(GtkWidget *widget, GdkEvent *event, gpointer data);
00029 static void plw_close_clicked(GtkWidget *widget, gpointer data);
00030 static void plw_refresh_clicked(GtkWidget *widget, gpointer data);
00031 static void mw_cmi_plw_toggle(GtkWidget *widget, gpointer data);
00032 static void pn_treeview_selection_changed_cb(GtkTreeSelection *selection, gpointer data);
00033
00034 static void plugin_list_window_connect_signals(heraia_window_t *main_window);
00035
00036 static void init_plugin_name_tv(heraia_window_t *main_window);
00037 static void print_plugin_basics(GtkTextView *textview, heraia_plugin_t *plugin);
00038 static void print_plugin_interface(GtkTextView *textview, heraia_plugin_t *plugin);
00039 static void print_plugin_filter_structure(GtkTextView *textview, heraia_plugin_t *plugin);
00040 static void print_plugin_functions(GtkTextView *textview, heraia_plugin_t *plugin);
00041 static void print_plugin_info_structure(GtkTextView *textview, heraia_plugin_t *plugin);
00042 static void print_plugin_extra_structure(GtkTextView *textview, heraia_plugin_t *plugin);
00043 static void print_plugin_state(GtkTextView *textview, heraia_plugin_t *plugin);
00044
00045
00048 static gboolean delete_plw_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
00049 {
00050 plw_close_clicked(widget, data);
00051
00052 return TRUE;
00053 }
00054
00055 static void destroy_plw_window(GtkWidget *widget, GdkEvent *event, gpointer data)
00056 {
00057 plw_close_clicked(widget, data);
00058 }
00059
00063 static void plw_close_clicked(GtkWidget *widget, gpointer data)
00064 {
00065 heraia_window_t *main_window = (heraia_window_t *) data;
00066 GtkCheckMenuItem *cmi = GTK_CHECK_MENU_ITEM(heraia_get_widget(main_window->xmls->main, "mw_cmi_plugin_list"));
00067
00068 record_and_hide_dialog_box(GTK_WIDGET(heraia_get_widget(main_window->xmls->main, "plugin_list_window")), main_window->win_prop->plugin_list);
00069 gtk_check_menu_item_set_active(cmi, FALSE);
00070 }
00071
00072
00076 static void plw_refresh_clicked(GtkWidget *widget, gpointer data)
00077 {
00078 heraia_window_t *main_window = (heraia_window_t *) data;
00079 GtkTextView *textview = GTK_TEXT_VIEW(heraia_get_widget(main_window->xmls->main, "plugin_info_textview"));
00080
00081 init_plugin_name_tv(main_window);
00082 kill_text_from_textview(textview);
00083 }
00084
00085
00089 static void mw_cmi_plw_toggle(GtkWidget *widget, gpointer data)
00090 {
00091 heraia_window_t *main_window = (heraia_window_t *) data;
00092 GtkCheckMenuItem *cmi = GTK_CHECK_MENU_ITEM(heraia_get_widget(main_window->xmls->main, "mw_cmi_plugin_list"));
00093 GtkPaned *paned = GTK_PANED(heraia_get_widget(main_window->xmls->main, "plw_hpaned"));
00094 gint pos = 0;
00095
00096 if (gtk_check_menu_item_get_active(cmi) == TRUE)
00097 {
00098 pos = gtk_paned_get_position(paned);
00099 if (pos < 15)
00100 {
00101 pos = 100;
00102 gtk_paned_set_position(paned, pos);
00103 }
00104 move_and_show_dialog_box(heraia_get_widget(main_window->xmls->main, "plugin_list_window"), main_window->win_prop->plugin_list);
00105 }
00106 else
00107 {
00108 record_and_hide_dialog_box(GTK_WIDGET(heraia_get_widget(main_window->xmls->main, "plugin_list_window")), main_window->win_prop->plugin_list);
00109 }
00110
00111
00112
00113 }
00114
00115
00119 static void print_plugin_info_structure(GtkTextView *textview, heraia_plugin_t *plugin)
00120 {
00121 if (plugin->info != NULL)
00122 {
00123 switch (plugin->info->type)
00124 {
00125 case HERAIA_PLUGIN_UNKNOWN:
00126 add_text_to_textview(textview, "Type : Unknown\n");
00127 break;
00128
00129 case HERAIA_PLUGIN_FILTER:
00130 add_text_to_textview(textview, "Type : Filter\n");
00131 break;
00132
00133 case HERAIA_PLUGIN_ACTION:
00134 add_text_to_textview(textview, "Type : Action\n");
00135 break;
00136
00137 default:
00138 add_text_to_textview(textview, "Type : Unknown\n");
00139 }
00140
00141 add_text_to_textview(textview, "Priority : %d\n", plugin->info->priority);
00142 add_text_to_textview(textview, "Id : %d\n", plugin->info->id);
00143
00144 if (plugin->info->name != NULL)
00145 {
00146 add_text_to_textview(textview, "Name : %s\n", plugin->info->name);
00147 }
00148
00149 if (plugin->info->version != NULL)
00150 {
00151 add_text_to_textview(textview, "Version : %s\n", plugin->info->version);
00152 }
00153
00154 if (plugin->info->summary != NULL)
00155 {
00156 add_text_to_textview(textview, "Summary : %s\n", plugin->info->summary);
00157 }
00158
00159 if (plugin->info->description != NULL)
00160 {
00161 add_text_to_textview(textview, "Description : %s\n", plugin->info->description);
00162 }
00163
00164 if (plugin->info->author != NULL)
00165 {
00166 add_text_to_textview(textview, "Author : %s\n", plugin->info->author);
00167 }
00168
00169 if (plugin->info->homepage != NULL)
00170 {
00171 add_text_to_textview(textview, "Web site : %s\n", plugin->info->homepage);
00172 }
00173 }
00174 else
00175 {
00176 add_text_to_textview(textview, "The 'info' structure is not initialized !\n");
00177 }
00178 }
00179
00183 static void print_plugin_functions(GtkTextView *textview, heraia_plugin_t *plugin)
00184 {
00185
00186 if (plugin->init_proc != NULL ||
00187 plugin->run_proc != NULL ||
00188 plugin->quit_proc != NULL ||
00189 plugin->refresh_proc != NULL)
00190 {
00191 add_text_to_textview(textview, "\nPlugin's defined functions :\n");
00192
00193 if (plugin->init_proc != NULL)
00194 {
00195 add_text_to_textview(textview, " - Initialization function : %p\n", plugin->init_proc);
00196 }
00197
00198 if (plugin->run_proc != NULL)
00199 {
00200 add_text_to_textview(textview, " - Main function : %p\n", plugin->run_proc);
00201 }
00202
00203 if (plugin->quit_proc != NULL)
00204 {
00205 add_text_to_textview(textview, " - Exit function : %p\n", plugin->quit_proc);
00206 }
00207
00208 if (plugin->refresh_proc != NULL)
00209 {
00210 add_text_to_textview(textview, " - Refresh function : %p\n", plugin->refresh_proc);
00211 }
00212 }
00213 else
00214 {
00215 add_text_to_textview(textview, "\nThis plugin does not provide any function !!\n");
00216 }
00217 }
00218
00222 static void print_plugin_filter_structure(GtkTextView *textview, heraia_plugin_t *plugin)
00223 {
00224 if (plugin->filter != NULL)
00225 {
00226 if (plugin->filter->import != NULL ||
00227 plugin->filter->export != NULL)
00228 {
00229 add_text_to_textview(textview, "\nFilter functions :\n");
00230
00231 if (plugin->filter->import != NULL)
00232 {
00233 add_text_to_textview(textview, " - Import function : %p\n", plugin->filter->import);
00234 }
00235
00236 if (plugin->filter->export != NULL)
00237 {
00238 add_text_to_textview(textview, " - Export function : %p\n", plugin->filter->export);
00239 }
00240 }
00241 else
00242 {
00243 add_text_to_textview(textview, "\nThis plugin does not provide any filter function\n");
00244 }
00245 }
00246 else
00247 {
00248 add_text_to_textview(textview, "\nThe structure 'filter' is not initialized !");
00249 }
00250 }
00251
00255 static void print_plugin_interface(GtkTextView *textview, heraia_plugin_t *plugin)
00256 {
00257 add_text_to_textview(textview, "\nThis plugin provides :\n");
00258
00259 if (plugin->cmi_entry != NULL)
00260 {
00261 add_text_to_textview(textview, " - a menu entry in the plugins menu.\n");
00262 }
00263 else
00264 {
00265 add_text_to_textview(textview, " - no menu entry.\n");
00266 }
00267
00268 if (plugin->xml != NULL)
00269 {
00270 add_text_to_textview(textview, " - an xml interface.\n");
00271 }
00272 else
00273 {
00274 add_text_to_textview(textview, " - no xml interface.\n");
00275 }
00276 }
00277
00281 static void print_plugin_basics(GtkTextView *textview, heraia_plugin_t *plugin)
00282 {
00283 if (plugin->info != NULL)
00284 {
00285 add_text_to_textview(textview, "API version : %d\n", plugin->info->api_version);
00286 }
00287
00288 if (plugin->filename != NULL)
00289 {
00290 add_text_to_textview(textview, "File : %s\n", plugin->filename);
00291 }
00292
00293 if (plugin->path != NULL)
00294 {
00295 add_text_to_textview(textview, "Directory : %s\n", plugin->path);
00296 }
00297
00298 if (plugin->handle != NULL)
00299 {
00300 add_text_to_textview(textview, "Handle : %p\n", plugin->handle);
00301 }
00302 else
00303 {
00304 add_text_to_textview(textview, "Handle : NONE <-- Is there anything normal ?\n");
00305 }
00306 }
00307
00311 static void print_plugin_extra_structure(GtkTextView *textview, heraia_plugin_t *plugin)
00312 {
00313
00314 if (plugin->extra != NULL)
00315 {
00316 add_text_to_textview(textview, "\nThis plugin has an additionnal 'extra' structure (%p) sized %d bytes.\n",
00317 plugin->extra, sizeof(*(plugin->extra)));
00318 }
00319 else
00320 {
00321 add_text_to_textview(textview, "\nThis plugin does not have any additionnal structure.\n");
00322 }
00323
00324 }
00325
00329 static void print_plugin_state(GtkTextView *textview, heraia_plugin_t *plugin)
00330 {
00331
00332 add_text_to_textview(textview, "Plugin's state : ");
00333 switch (plugin->state)
00334 {
00335 case PLUGIN_STATE_RUNNING:
00336 add_text_to_textview(textview, "Running\n");
00337 break;
00338
00339 case PLUGIN_STATE_INITIALIZING:
00340 add_text_to_textview(textview, "Initialiazing or initialized\n");
00341 break;
00342 case PLUGIN_STATE_LOADED:
00343 add_text_to_textview(textview, "Loaded\n");
00344 break;
00345
00346 case PLUGIN_STATE_NEW:
00347 add_text_to_textview(textview, "Creating itself\n");
00348 break;
00349
00350 case PLUGIN_STATE_EXITING:
00351 add_text_to_textview(textview, "Exiting\n");
00352 break;
00353
00354 case PLUGIN_STATE_NONE:
00355 add_text_to_textview(textview, "Waiting\n");
00356 break;
00357
00358 default:
00359 add_text_to_textview(textview, "Unknown\n");
00360 }
00361 }
00362
00367 static void pn_treeview_selection_changed_cb(GtkTreeSelection *selection, gpointer data)
00368 {
00369 GtkTreeIter iter;
00370 GtkTreeModel *model = NULL;
00371 heraia_window_t *main_window = (heraia_window_t *) data;
00372 gchar *name = NULL;
00373 heraia_plugin_t *plugin = NULL;
00374 GtkTextView *textview = GTK_TEXT_VIEW(heraia_get_widget(main_window->xmls->main, "plugin_info_textview"));
00375
00376 if (gtk_tree_selection_get_selected(selection, &model, &iter))
00377 {
00378 gtk_tree_model_get(model, &iter, PNTV_COLUMN_NAME, &name, -1);
00379 plugin = find_plugin_by_name(main_window->plugins_list, name);
00380
00381 if (plugin != NULL)
00382 {
00383 kill_text_from_textview(textview);
00384
00385 print_plugin_basics(textview, plugin);
00386
00387 print_plugin_info_structure(textview, plugin);
00388
00389 print_plugin_functions(textview, plugin);
00390
00391 print_plugin_filter_structure(textview, plugin);
00392
00393 print_plugin_interface(textview, plugin);
00394
00395 print_plugin_extra_structure(textview, plugin);
00396
00397 print_plugin_state(textview, plugin);
00398 }
00399 }
00400 }
00401
00402
00403
00404 static void plugin_list_window_connect_signals(heraia_window_t *main_window)
00405 {
00406 GtkTreeSelection *select = NULL;
00407
00408 if (main_window != NULL)
00409 {
00410
00411 g_signal_connect(G_OBJECT(heraia_get_widget(main_window->xmls->main, "plugin_list_window")), "delete_event",
00412 G_CALLBACK(delete_plw_window_event), main_window);
00413
00414 g_signal_connect(G_OBJECT(heraia_get_widget(main_window->xmls->main, "plugin_list_window")), "destroy",
00415 G_CALLBACK(destroy_plw_window), main_window);
00416
00417
00418 g_signal_connect(G_OBJECT(heraia_get_widget(main_window->xmls->main, "plw_close_b")), "clicked",
00419 G_CALLBACK(plw_close_clicked), main_window);
00420
00421
00422 g_signal_connect(G_OBJECT(heraia_get_widget(main_window->xmls->main, "mw_cmi_plugin_list")), "toggled",
00423 G_CALLBACK(mw_cmi_plw_toggle), main_window);
00424
00425
00426 select = gtk_tree_view_get_selection(GTK_TREE_VIEW(heraia_get_widget(main_window->xmls->main, "pn_treeview")));
00427 gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
00428 g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK (pn_treeview_selection_changed_cb), main_window);
00429
00430
00431 g_signal_connect(G_OBJECT(heraia_get_widget(main_window->xmls->main, "plw_refresh_b")), "clicked",
00432 G_CALLBACK(plw_refresh_clicked), main_window);
00433 }
00434 }
00435
00439 static void init_plugin_name_tv(heraia_window_t *main_window)
00440 {
00441 GtkListStore *list_store = NULL;
00442 GtkTreeIter iter;
00443 GtkCellRenderer *renderer = NULL;
00444
00445 GtkTreeViewColumn *column = NULL;
00446 heraia_plugin_t *plugin = NULL;
00447 GList *p_list = NULL;
00448 GtkTreeView *treeview = NULL;
00449
00450 if (main_window != NULL)
00451 {
00452 treeview = GTK_TREE_VIEW(heraia_get_widget(main_window->xmls->main, "pn_treeview"));
00453
00454 p_list = g_list_first(main_window->plugins_list);
00455
00456 list_store = gtk_list_store_new(PNTV_N_COLUMNS, G_TYPE_STRING);
00457
00458 while (p_list != NULL)
00459 {
00460 plugin = (heraia_plugin_t *) p_list->data;
00461 log_message(main_window, G_LOG_LEVEL_INFO, "%s", plugin->info->name);
00462
00463 gtk_list_store_append(list_store, &iter);
00464 gtk_list_store_set(list_store, &iter, PNTV_COLUMN_NAME, plugin->info->name, -1);
00465
00466 p_list = p_list->next;
00467 }
00468
00469 gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(list_store));
00470
00471 column = gtk_tree_view_get_column(treeview, PNTV_COLUMN_NAME);
00472
00473 if (column != NULL)
00474 {
00475 gtk_tree_view_remove_column(treeview, column);
00476 }
00477
00478 renderer = gtk_cell_renderer_text_new();
00479 column = gtk_tree_view_column_new_with_attributes("Name", renderer, "text", PNTV_COLUMN_NAME, NULL);
00480 gtk_tree_view_append_column(treeview, column);
00481 }
00482 }
00483
00484
00488 void plugin_list_window_init_interface(heraia_window_t *main_window)
00489 {
00490
00491 plugin_list_window_connect_signals(main_window);
00492
00493 init_plugin_name_tv(main_window);
00494 }
00495
00496
00497
00498
00499
00500