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