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
00026
00027
00028 #include <libheraia.h>
00029
00030 static gboolean delete_plw_window_event(GtkWidget *widget, GdkEvent *event, gpointer data);
00031 static void destroy_plw_window(GtkWidget *widget, GdkEvent *event, gpointer data);
00032 static void plw_close_clicked(GtkWidget *widget, gpointer data);
00033 static void plw_refresh_clicked(GtkWidget *widget, gpointer data);
00034 static void mw_cmi_plw_toggle(GtkWidget *widget, gpointer data);
00035 static void pn_treeview_selection_changed_cb(GtkTreeSelection *selection, gpointer data);
00036 static void pn_treeview_double_click(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data);
00037
00038 static void plugin_list_window_connect_signals(heraia_struct_t *main_struct);
00039
00040 static void init_plugin_name_tv(heraia_struct_t *main_struct);
00041 static void print_plugin_basics(GtkTextView *textview, heraia_plugin_t *plugin);
00042 static void print_plugin_interface(GtkTextView *textview, heraia_plugin_t *plugin);
00043 static void print_plugin_filter_structure(GtkTextView *textview, heraia_plugin_t *plugin);
00044 static void print_plugin_functions(GtkTextView *textview, heraia_plugin_t *plugin);
00045 static void print_plugin_info_structure(GtkTextView *textview, heraia_plugin_t *plugin);
00046 static void print_plugin_extra_structure(GtkTextView *textview, heraia_plugin_t *plugin);
00047 static void print_plugin_state(GtkTextView *textview, heraia_plugin_t *plugin);
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 static gboolean delete_plw_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
00060 {
00061 plw_close_clicked(widget, data);
00062
00063 return TRUE;
00064 }
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 static void destroy_plw_window(GtkWidget *widget, GdkEvent *event, gpointer data)
00075 {
00076 plw_close_clicked(widget, data);
00077 }
00078
00079
00080
00081
00082
00083
00084
00085
00086 static void plw_close_clicked(GtkWidget *widget, gpointer data)
00087 {
00088 heraia_struct_t *main_struct = (heraia_struct_t *) data;
00089 GtkCheckMenuItem *cmi = GTK_CHECK_MENU_ITEM(heraia_get_widget(main_struct->xmls->main, "mw_cmi_plugin_list"));
00090
00091 record_and_hide_dialog_box(GTK_WIDGET(heraia_get_widget(main_struct->xmls->main, "plugin_list_window")), main_struct->win_prop->plugin_list);
00092 gtk_check_menu_item_set_active(cmi, FALSE);
00093 }
00094
00095
00096
00097
00098
00099
00100
00101
00102 static void plw_refresh_clicked(GtkWidget *widget, gpointer data)
00103 {
00104 heraia_struct_t *main_struct = (heraia_struct_t *) data;
00105 GtkTextView *textview = GTK_TEXT_VIEW(heraia_get_widget(main_struct->xmls->main, "plugin_info_textview"));
00106
00107 init_plugin_name_tv(main_struct);
00108 kill_text_from_textview(textview);
00109 }
00110
00111
00112
00113
00114
00115
00116
00117
00118 static void mw_cmi_plw_toggle(GtkWidget *widget, gpointer data)
00119 {
00120 heraia_struct_t *main_struct = (heraia_struct_t *) data;
00121 GtkCheckMenuItem *cmi = GTK_CHECK_MENU_ITEM(heraia_get_widget(main_struct->xmls->main, "mw_cmi_plugin_list"));
00122 GtkPaned *paned = GTK_PANED(heraia_get_widget(main_struct->xmls->main, "plw_hpaned"));
00123 gint pos = 0;
00124
00125 if (gtk_check_menu_item_get_active(cmi) == TRUE)
00126 {
00127 pos = gtk_paned_get_position(paned);
00128 if (pos < 15)
00129 {
00130 pos = 100;
00131 gtk_paned_set_position(paned, pos);
00132 }
00133 move_and_show_dialog_box(heraia_get_widget(main_struct->xmls->main, "plugin_list_window"), main_struct->win_prop->plugin_list);
00134 }
00135 else
00136 {
00137 record_and_hide_dialog_box(GTK_WIDGET(heraia_get_widget(main_struct->xmls->main, "plugin_list_window")), main_struct->win_prop->plugin_list);
00138 }
00139 }
00140
00141
00142
00143
00144
00145
00146
00147
00148 static void print_plugin_info_structure(GtkTextView *textview, heraia_plugin_t *plugin)
00149 {
00150 if (plugin->info != NULL)
00151 {
00152 switch (plugin->info->type)
00153 {
00154 case HERAIA_PLUGIN_UNKNOWN:
00155 add_text_to_textview(textview, Q_("Type : Unknown\n"));
00156 break;
00157
00158 case HERAIA_PLUGIN_FILTER:
00159 add_text_to_textview(textview, Q_("Type : Filter\n"));
00160 break;
00161
00162 case HERAIA_PLUGIN_ACTION:
00163 add_text_to_textview(textview, Q_("Type : Action\n"));
00164 break;
00165
00166 default:
00167 add_text_to_textview(textview, Q_("Type : Unknown\n"));
00168 }
00169
00170 add_text_to_textview(textview, Q_("Priority : %d\n"), plugin->info->priority);
00171 add_text_to_textview(textview, Q_("Id : %d\n"), plugin->info->id);
00172
00173 if (plugin->info->name != NULL)
00174 {
00175 add_text_to_textview(textview, Q_("Name : %s\n"), plugin->info->name);
00176 }
00177
00178 if (plugin->info->version != NULL)
00179 {
00180 add_text_to_textview(textview, Q_("Version : %s\n"), plugin->info->version);
00181 }
00182
00183 if (plugin->info->summary != NULL)
00184 {
00185 add_text_to_textview(textview, Q_("Summary : %s\n"), plugin->info->summary);
00186 }
00187
00188 if (plugin->info->description != NULL)
00189 {
00190 add_text_to_textview(textview, Q_("Description : %s\n"), plugin->info->description);
00191 }
00192
00193 if (plugin->info->author != NULL)
00194 {
00195 add_text_to_textview(textview, Q_("Author : %s\n"), plugin->info->author);
00196 }
00197
00198 if (plugin->info->homepage != NULL)
00199 {
00200 add_text_to_textview(textview, Q_("Web site : %s\n"), plugin->info->homepage);
00201 }
00202 }
00203 else
00204 {
00205 add_text_to_textview(textview, Q_("The 'info' structure is not initialized !\n"));
00206 }
00207 }
00208
00209
00210
00211
00212
00213
00214
00215
00216 static void print_plugin_functions(GtkTextView *textview, heraia_plugin_t *plugin)
00217 {
00218
00219 if (plugin->init_proc != NULL ||
00220 plugin->run_proc != NULL ||
00221 plugin->quit_proc != NULL ||
00222 plugin->refresh_proc != NULL)
00223 {
00224 add_text_to_textview(textview, Q_("\nPlugin's defined functions :\n"));
00225
00226 if (plugin->init_proc != NULL)
00227 {
00228 add_text_to_textview(textview, Q_(" - Initialization function : %p\n"), plugin->init_proc);
00229 }
00230
00231 if (plugin->run_proc != NULL)
00232 {
00233 add_text_to_textview(textview, Q_(" - Main function : %p\n"), plugin->run_proc);
00234 }
00235
00236 if (plugin->quit_proc != NULL)
00237 {
00238 add_text_to_textview(textview, Q_(" - Exit function : %p\n"), plugin->quit_proc);
00239 }
00240
00241 if (plugin->refresh_proc != NULL)
00242 {
00243 add_text_to_textview(textview, Q_(" - Refresh function : %p\n"), plugin->refresh_proc);
00244 }
00245 }
00246 else
00247 {
00248 add_text_to_textview(textview, Q_("\nThis plugin does not provide any function !!\n"));
00249 }
00250 }
00251
00252
00253
00254
00255
00256
00257
00258
00259 static void print_plugin_filter_structure(GtkTextView *textview, heraia_plugin_t *plugin)
00260 {
00261 if (plugin->filter != NULL)
00262 {
00263 if (plugin->filter->import != NULL ||
00264 plugin->filter->export != NULL)
00265 {
00266 add_text_to_textview(textview, Q_("\nFilter functions :\n"));
00267
00268 if (plugin->filter->import != NULL)
00269 {
00270 add_text_to_textview(textview, Q_(" - Import function : %p\n"), plugin->filter->import);
00271 }
00272
00273 if (plugin->filter->export != NULL)
00274 {
00275 add_text_to_textview(textview, Q_(" - Export function : %p\n"), plugin->filter->export);
00276 }
00277 }
00278 else
00279 {
00280 add_text_to_textview(textview, Q_("\nThis plugin does not provide any filter function\n"));
00281 }
00282 }
00283 else
00284 {
00285 add_text_to_textview(textview, Q_("\nThe structure 'filter' is not initialized !"));
00286 }
00287 }
00288
00289
00290
00291
00292
00293
00294
00295
00296 static void print_plugin_interface(GtkTextView *textview, heraia_plugin_t *plugin)
00297 {
00298 add_text_to_textview(textview, Q_("\nThis plugin provides :\n"));
00299
00300 if (plugin->cmi_entry != NULL)
00301 {
00302 add_text_to_textview(textview, Q_(" - a menu entry in the plugins menu.\n"));
00303 }
00304 else
00305 {
00306 add_text_to_textview(textview, Q_(" - no menu entry.\n"));
00307 }
00308
00309 if (plugin->xml != NULL)
00310 {
00311 add_text_to_textview(textview, Q_(" - an xml interface.\n"));
00312 }
00313 else
00314 {
00315 add_text_to_textview(textview, Q_(" - no xml interface.\n"));
00316 }
00317 }
00318
00319
00320
00321
00322
00323
00324
00325
00326 static void print_plugin_basics(GtkTextView *textview, heraia_plugin_t *plugin)
00327 {
00328 if (plugin->info != NULL)
00329 {
00330 add_text_to_textview(textview, Q_("API version : %d\n"), plugin->info->api_version);
00331 }
00332
00333 if (plugin->filename != NULL)
00334 {
00335 add_text_to_textview(textview, Q_("File : %s\n"), plugin->filename);
00336 }
00337
00338 if (plugin->path != NULL)
00339 {
00340 add_text_to_textview(textview, Q_("Directory : %s\n"), plugin->path);
00341 }
00342
00343 if (plugin->handle != NULL)
00344 {
00345 add_text_to_textview(textview, Q_("Handle : %p\n"), plugin->handle);
00346 }
00347 else
00348 {
00349 add_text_to_textview(textview, Q_("Handle : NONE <-- Is there anything normal ?\n"));
00350 }
00351 }
00352
00353
00354
00355
00356
00357
00358
00359
00360 static void print_plugin_extra_structure(GtkTextView *textview, heraia_plugin_t *plugin)
00361 {
00362
00363 if (plugin->extra != NULL)
00364 {
00365 add_text_to_textview(textview, Q_("\nThis plugin has an additionnal 'extra' structure (%p) sized %d bytes.\n"),
00366 plugin->extra, sizeof(*(plugin->extra)));
00367 }
00368 else
00369 {
00370 add_text_to_textview(textview, Q_("\nThis plugin does not have any additionnal structure.\n"));
00371 }
00372
00373 }
00374
00375
00376
00377
00378
00379
00380
00381
00382 static void print_plugin_state(GtkTextView *textview, heraia_plugin_t *plugin)
00383 {
00384
00385 add_text_to_textview(textview, Q_("Plugin's state : "));
00386 switch (plugin->state)
00387 {
00388 case PLUGIN_STATE_RUNNING:
00389 add_text_to_textview(textview, Q_("Running\n"));
00390 break;
00391
00392 case PLUGIN_STATE_INITIALIZING:
00393 add_text_to_textview(textview, Q_("Initialiazing or initialized\n"));
00394 break;
00395 case PLUGIN_STATE_LOADED:
00396 add_text_to_textview(textview, Q_("Loaded\n"));
00397 break;
00398
00399 case PLUGIN_STATE_NEW:
00400 add_text_to_textview(textview, Q_("Creating itself\n"));
00401 break;
00402
00403 case PLUGIN_STATE_EXITING:
00404 add_text_to_textview(textview, Q_("Exiting\n"));
00405 break;
00406
00407 case PLUGIN_STATE_NONE:
00408 add_text_to_textview(textview, Q_("Waiting\n"));
00409 break;
00410
00411 default:
00412 add_text_to_textview(textview, Q_("Unknown\n"));
00413 }
00414 }
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424 static void pn_treeview_selection_changed_cb(GtkTreeSelection *selection, gpointer data)
00425 {
00426 GtkTreeIter iter;
00427 GtkTreeModel *model = NULL;
00428 heraia_struct_t *main_struct = (heraia_struct_t *) data;
00429 gchar *name = NULL;
00430 heraia_plugin_t *plugin = NULL;
00431 GtkTextView *textview = GTK_TEXT_VIEW(heraia_get_widget(main_struct->xmls->main, "plugin_info_textview"));
00432
00433 if (gtk_tree_selection_get_selected(selection, &model, &iter))
00434 {
00435 gtk_tree_model_get(model, &iter, PNTV_COLUMN_NAME, &name, -1);
00436 plugin = find_plugin_by_name(main_struct->plugins_list, name);
00437
00438 if (plugin != NULL)
00439 {
00440 kill_text_from_textview(textview);
00441
00442 print_plugin_basics(textview, plugin);
00443
00444 print_plugin_info_structure(textview, plugin);
00445
00446 print_plugin_functions(textview, plugin);
00447
00448 print_plugin_filter_structure(textview, plugin);
00449
00450 print_plugin_interface(textview, plugin);
00451
00452 print_plugin_extra_structure(textview, plugin);
00453
00454 print_plugin_state(textview, plugin);
00455 }
00456 }
00457 }
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467 static void pn_treeview_double_click(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
00468 {
00469 GtkTreeModel *model;
00470 GtkTreeIter iter;
00471 gchar *plugin_name;
00472 heraia_struct_t *main_struct = (heraia_struct_t *) data;
00473 heraia_plugin_t *plugin = NULL;
00474 gboolean active = FALSE;
00475
00476
00477 model = gtk_tree_view_get_model(treeview);
00478
00479 if (gtk_tree_model_get_iter(model, &iter, path))
00480 {
00481 gtk_tree_model_get(model, &iter, PNTV_COLUMN_NAME, &plugin_name, -1);
00482 plugin = find_plugin_by_name(main_struct->plugins_list, plugin_name);
00483
00484 if (plugin != NULL)
00485 {
00486 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(plugin->cmi_entry));
00487
00488 if (active == FALSE)
00489 {
00490 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(plugin->cmi_entry), TRUE);
00491 plugin->run_proc(GTK_WIDGET(treeview), main_struct);
00492 }
00493 }
00494 }
00495 }
00496
00497
00498
00499
00500
00501
00502
00503
00504 static void plugin_list_window_connect_signals(heraia_struct_t *main_struct)
00505 {
00506 GtkTreeSelection *select = NULL;
00507
00508 if (main_struct != NULL)
00509 {
00510
00511 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "plugin_list_window")), "delete_event",
00512 G_CALLBACK(delete_plw_window_event), main_struct);
00513
00514 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "plugin_list_window")), "destroy",
00515 G_CALLBACK(destroy_plw_window), main_struct);
00516
00517
00518 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "plw_close_b")), "clicked",
00519 G_CALLBACK(plw_close_clicked), main_struct);
00520
00521
00522 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "mw_cmi_plugin_list")), "toggled",
00523 G_CALLBACK(mw_cmi_plw_toggle), main_struct);
00524
00525
00526 select = gtk_tree_view_get_selection(GTK_TREE_VIEW(heraia_get_widget(main_struct->xmls->main, "pn_treeview")));
00527 gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
00528 g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK (pn_treeview_selection_changed_cb), main_struct);
00529
00530
00531 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "pn_treeview")), "row-activated",
00532 G_CALLBACK(pn_treeview_double_click), main_struct);
00533
00534
00535 g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "plw_refresh_b")), "clicked",
00536 G_CALLBACK(plw_refresh_clicked), main_struct);
00537 }
00538 }
00539
00540
00541
00542
00543
00544
00545
00546 static void init_plugin_name_tv(heraia_struct_t *main_struct)
00547 {
00548 GtkListStore *list_store = NULL;
00549 GtkTreeIter iter;
00550 GtkCellRenderer *renderer = NULL;
00551
00552 GtkTreeViewColumn *column = NULL;
00553 heraia_plugin_t *plugin = NULL;
00554 GList *p_list = NULL;
00555 GtkTreeView *treeview = NULL;
00556
00557 if (main_struct != NULL)
00558 {
00559 treeview = GTK_TREE_VIEW(heraia_get_widget(main_struct->xmls->main, "pn_treeview"));
00560
00561 p_list = g_list_first(main_struct->plugins_list);
00562
00563 list_store = gtk_list_store_new(PNTV_N_COLUMNS, G_TYPE_STRING);
00564
00565 while (p_list != NULL)
00566 {
00567 plugin = (heraia_plugin_t *) p_list->data;
00568 log_message(main_struct, G_LOG_LEVEL_INFO, "%s", plugin->info->name);
00569
00570 gtk_list_store_append(list_store, &iter);
00571 gtk_list_store_set(list_store, &iter, PNTV_COLUMN_NAME, plugin->info->name, -1);
00572
00573 p_list = p_list->next;
00574 }
00575
00576 gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(list_store));
00577
00578 column = gtk_tree_view_get_column(treeview, PNTV_COLUMN_NAME);
00579
00580 if (column != NULL)
00581 {
00582 gtk_tree_view_remove_column(treeview, column);
00583 }
00584
00585 renderer = gtk_cell_renderer_text_new();
00586 column = gtk_tree_view_column_new_with_attributes("Name", renderer, "text", PNTV_COLUMN_NAME, NULL);
00587 gtk_tree_view_append_column(treeview, column);
00588 }
00589 }
00590
00591
00592
00593
00594
00595
00596
00597 void plugin_list_window_init_interface(heraia_struct_t *main_struct)
00598 {
00599
00600 plugin_list_window_connect_signals(main_struct);
00601
00602 init_plugin_name_tv(main_struct);
00603 }
00604
00605
00606
00607
00608
00609