Chris Howie-3 wrote:
> 
> On Jan 21, 2008 1:26 PM, hellboy195 <[EMAIL PROTECTED]> wrote:
>> Hi,
>> thank you very much for your help. I tried both of you methods and it's
>> working really great but there is one thing left I that should work. With
>> my
>> old (buggy) version the Files from the Treeview were removed
>> automatically
>> when the encoding was finshed. That means. I have a treeview with let's
>> say
>> 3 titels and after the first title is finished with encoding it should be
>> removed to only 2 are remaining and so on ...
>> Any chance that I can manage it like in the past with?
>>
>>                 this.menuListStore.GetIterFirst(out iter);
>>                 this.menuListStore.Remove(ref iter);
> 
> You still can, you just need to do this from the GUI thread.  We will
> need more information about the circumstances you are doing this under
> to help.  Can you paste your code?
> 
> -- 
> Chris Howie
> http://www.chrishowie.com
> http://en.wikipedia.org/wiki/User:Crazycomputers
> _______________________________________________
> Gtk-sharp-list maillist  -  [email protected]
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
> 
> 

Sure, no problem. Though I don't know if I should post the whole one ore not
^^. anyway. here it is :

        protected virtual void OnCovertClicked (object sender, System.EventArgs 
e)
        {
                try
                {
                this.SelectFolder.Sensitive = false;
                this.FileAdd.Sensitive = false;
            this.RemoveFile.Sensitive = false;
                this.ClearAll.Sensitive = false;
                this.entry1.Sensitive = false;
                this.combobox1.Sensitive = false;
                this.combobox2.Sensitive = false;
                this.menubar1.Sensitive = false;
                        
                selectedFile = String.Empty;
                newselectedFile = String.Empty;
                oldselectedFile = String.Empty;

                while(this.menuListStore.GetIterFirst(out iter) != false) 
                {
                format = this.combobox1.ActiveText;
                quality = this.combobox2.ActiveText;
                iter = new TreeIter();
                
                menuListStore.GetIterFirst(out iter);
                selectedFile = (string)menuListStore.GetValue(iter, 0);
                
                if(selectedFile.Substring(selectedFile.Length -4) == "flac") 
number+=1;
                                
                oldselectedFile =
selectedFile.Replace(selectedFile.Substring(selectedFile.Length - number),
format);
                selectedFile = selectedFile.Replace(" ", "\\ ");
                newselectedFile =
selectedFile.Replace(selectedFile.Substring(selectedFile.Length - number),
format);
                                
                if(selectedFile.Substring(selectedFile.Length -4) == "flac") 
number-=1;
                
                string command = "ffmpeg -y -i " + selectedFile + " -ab " +
quality.Replace("b/s", " ") + newselectedFile;          
                                        
                if (System.IO.File.Exists(oldselectedFile))
            {
                        MessageDialog md = new MessageDialog (this,
                                                      
DialogFlags.DestroyWithParent,
                                   MessageType.Question, 
                                      ButtonsType.YesNo, newselectedFile + "
already exits. Overwrite it?");
                        
                        ResponseType result = (ResponseType)md.Run ();
                        
                        if (result == ResponseType.Yes)
                        {
                        md.Destroy();
                        this.Convert.Sensitive = false;
                        proc = Process.Start(command);
                        }       
                        else
                        {
                        this.FileAdd.Sensitive = true;
                        this.Convert.Sensitive = false;
                        md.Destroy();           
                        }
                }
                else
                {
                this.Convert.Sensitive = false;
                proc = Process.Start(command);
                }
                this.menuListStore.GetIterFirst(out iter);
                this.menuListStore.Remove(ref iter);

                }
//              GLib.Idle.Add(delegate {
//              if (proc.HasExited) {
//                              
//              MessageDialog mdg = new MessageDialog(this,
DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Ok, "Encoding
finished");
//              mdg.Run();
//              mdg.Destroy();
//        
//        return false; // Remove this delegate from the idle list.
//    }
//
//    return true; // Run this delegate again when idle.
//}); 
                proc.EnableRaisingEvents = true;
                        proc.Exited += delegate {
                                Application.Invoke(delegate {
                        MessageDialog mdg = new MessageDialog(this,
DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Ok, "Encoding
finished");
                mdg.Run();
                mdg.Destroy();
    });
}; 

                        
                this.FileAdd.Sensitive = true;
                this.Convert.Sensitive = false; 
                this.SelectFolder.Sensitive = true;
                this.entry1.Sensitive = true;
                this.combobox1.Sensitive = true;
                this.combobox2.Sensitive = true;
                this.menubar1.Sensitive = true;
                        
        }
                catch(Exception ee)
                {
                        Console.WriteLine(ee);
                }
        }


In my eyes it's very ugly code and beside my problem here I would appreciate
any suggestions ;)
Thx :D

-- 
View this message in context: 
http://www.nabble.com/Check-Process-state-in-an-GUI-app-tp14982013p15004614.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.

_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Reply via email to