Example #1
0
    public static CPluginManager Instance()
    {
        IntPtr         cPtr = testPINVOKE.CPluginManager_Instance();
        CPluginManager ret  = (cPtr == IntPtr.Zero) ? null : new CPluginManager(cPtr, false);

        return(ret);
    }
Example #2
0
 private void PopulatePluginList()
 {
     try {
         pluginStore.Clear();
         foreach (string s in plugins.GetLoadedAssemblies())
         {
             Assembly a          = (Assembly)plugins[s];
             Type[]   mytypes    = a.GetTypes();
             string   identifier = "";
             string   path       = "";
             string   player     = "";
             // Parse all types and break at first
             // implementing identifier property
             Type selected_type = null;
             foreach (Type t in mytypes)
             {
                 try
                 {
                     identifier    = (string)CPluginManager.InvokeMember(t, "TypeIdentifier", Activator.CreateInstance(t), CPluginManager.Flags.Field);
                     player        = (string)CPluginManager.InvokeMember(t, "Player", Activator.CreateInstance(t), CPluginManager.Flags.Field);
                     selected_type = t;
                     break;
                 }
                 catch (Exception e)
                 { }
             }
             path = plugins.GetAssemblyPath(s);
             pluginStore.AppendValues(s, identifier, player, path);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("Exception raised during PopulatePluginList: " + e.Message);
     }
 }
Example #3
0
        public void OnPluginSelectedChanged(object o, RowActivatedArgs args)
        {
            TreeIter  iter;
            TreeModel model;

            TreeSelection selection = ((TreeView)o).Selection;

            if (selection.GetSelected(out model, out iter))
            {
                string val = (string)model.GetValue(iter, 0);
                buffer.Text = (string)CPluginManager.GetStatic(plugins.GetOwningType(val), "Description");
            }
        }
Example #4
0
 internal static HandleRef getCPtr(CPluginManager obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
Example #5
0
        private void ConfirmLoadAssembly(string [] selection)
        {
            Gtk.Entry     e_sPlugin          = null;
            string        l_sChoosenPlayer   = "";
            MessageDialog confirmationDialog = null;

            foreach (string s in selection)
            {
                confirmationDialog = new MessageDialog(this.Window,
                                                       DialogFlags.Modal |
                                                       DialogFlags.DestroyWithParent,
                                                       MessageType.Question,
                                                       ButtonsType.YesNo,
                                                       "What extension " + Path.GetFileName(s) + " should handle ?");
                VBox vbox = confirmationDialog.VBox;
                HBox hbox = new HBox(false, 4);
                vbox.PackStart(hbox, true, true, 0);

                e_sPlugin = new Gtk.Entry(".foobar");
                hbox.PackStart(e_sPlugin, false, false, 0);

                confirmationDialog.ShowAll();
                int res = confirmationDialog.Run();
                confirmationDialog.Hide();
                confirmationDialog.Dispose();

                if (res == (int)ResponseType.Yes)
                {
                    try
                    {
                        FileSelection fs = new FileSelection("Select your favorite player");
                        fs.HideFileopButtons();
                        CConfig config = CConfig.Instance;
                        fs.Complete((string)config["Interface/currentPath"]);
                        fs.Resizable = true;
                        fs.Modal     = true;
                        int r = fs.Run();
                        fs.Hide();
                        fs.Dispose();
                        if (r == (int)ResponseType.Ok)
                        {
                            l_sChoosenPlayer = fs.Selections[0];
                            plugins.LoadAssembly((string)((Gtk.Entry)e_sPlugin).Text, s);
                            try
                            {
                                CPluginManager.SetStatic(plugins.GetOwningType((string)((Gtk.Entry)e_sPlugin).Text), "Player", l_sChoosenPlayer);
                            }
                            catch (Exception e) { Console.WriteLine("Player not found"); }
                            PopulatePluginList();
                            ((Gtk.Button)m_xXML["applyButton"]).Sensitive = true;
                        }
                        else
                        {
                            throw new Exception("Loading aborted by user.");
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Plugin error: " + e.Message);
                    }
                }
            }
        }