summary refs log blame commit diff stats
path: root/src/common/cfgfiles.h
blob: c460ce60be65ada7aed75bbca906d993034a06c3 (plain) (tree)
generated by cgit-pink 1.4.1 (git 2.36.1) at 2025-03-15 21:30:15 +0000
ass="p">, #ifdef WIN32 sub_dir, "*.dll;*.lua;*.pl;*.py;*.tcl;*.js", FRF_FILTERISINITIAL|FRF_EXTENSIONS); #else sub_dir, "*.so;*.lua;*.pl;*.py;*.tcl;*.js", FRF_FILTERISINITIAL|FRF_EXTENSIONS); #endif g_free (sub_dir); } static void plugingui_loadbutton_cb (GtkWidget * wid, gpointer unused) { plugingui_load (); } static void plugingui_unload (GtkWidget * wid, gpointer unused) { int len; char *modname, *file, *buf; GtkTreeView *view; GtkTreeIter iter; view = g_object_get_data (G_OBJECT (plugin_window), "view"); if (!gtkutil_treeview_get_selected (view, &iter, NAME_COLUMN, &modname, FILE_COLUMN, &file, -1)) return; len = strlen (file); #ifdef WIN32 if (len > 4 && g_ascii_strcasecmp (file + len - 4, ".dll") == 0) #else #if defined(__hpux) if (len > 3 && g_ascii_strcasecmp (file + len - 3, ".sl") == 0) #else if (len > 3 && g_ascii_strcasecmp (file + len - 3, ".so") == 0) #endif #endif { if (plugin_kill (modname, FALSE) == 2) fe_message (_("That plugin is refusing to unload.\n"), FE_MSG_ERROR); } else { /* let python.so or perl.so handle it */ buf = malloc (strlen (file) + 10); if (strchr (file, ' ')) sprintf (buf, "UNLOAD \"%s\"", file); else sprintf (buf, "UNLOAD %s", file); handle_command (current_sess, buf, FALSE); free (buf); } g_free (modname); g_free (file); } static void plugingui_reloadbutton_cb (GtkWidget *wid, GtkTreeView *view) { char *file = plugingui_getfilename(view); if (file) { char *buf = malloc (strlen (file) + 9); if (strchr (file, ' ')) sprintf (buf, "RELOAD \"%s\"", file); else sprintf (buf, "RELOAD %s", file); handle_command (current_sess, buf, FALSE); free (buf); g_free (file); } } void plugingui_open (void) { GtkWidget *view; GtkWidget *vbox, *hbox; if (plugin_window) { mg_bring_tofront (plugin_window); return; } plugin_window = mg_create_generic_tab ("Addons", _(DISPLAY_NAME": Plugins and Scripts"), FALSE, TRUE, plugingui_close, NULL, 500, 250, &vbox, 0); gtkutil_destroy_on_esc (plugin_window); view = plugingui_treeview_new (vbox); g_object_set_data (G_OBJECT (plugin_window), "view", view); hbox = gtk_hbutton_box_new (); gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_SPREAD); gtk_container_set_border_width (GTK_CONTAINER (hbox), 5); gtk_box_pack_end (GTK_BOX (vbox), hbox, 0, 0, 0); gtkutil_button (hbox, GTK_STOCK_REVERT_TO_SAVED, NULL, plugingui_loadbutton_cb, NULL, _("_Load...")); gtkutil_button (hbox, GTK_STOCK_DELETE, NULL, plugingui_unload, NULL, _("_Unload")); gtkutil_button (hbox, GTK_STOCK_REFRESH, NULL, plugingui_reloadbutton_cb, view, _("_Reload")); fe_pluginlist_update (); gtk_widget_show_all (plugin_window); }