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