~petesavage/gisomount/devel

« back to all changes in this revision

Viewing changes to gisomount

  • Committer: Pete Savage
  • Date: 2006-06-22 15:25:59 UTC
  • Revision ID: petesavage@ubuntu.com-20060622152559-a59b076892bec8f4
Moved message dialog function to a seperate function to streamline code 
a little more

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
       self.on_info(x)
74
74
      self.wTree.signal_autoconnect(dic)
75
75
      self.win.connect("delete_event", self.delete_event)
76
 
      #self.tabs.connect("delete_event", self.close_info)
77
76
      self.reconnect()
78
77
 
79
78
   def reconnect(self):
129
128
        tabswin=self.wTree.get_widget("window1")
130
129
        tabs=self.wTree.get_widget("treeview"+str(index))
131
130
        tabswin.show_all()
132
 
        #tabsnote=self.wTree.get_widget("notebook1")
133
 
        #tabsnote.set_current_page(1)
134
131
        if not tabs.get_model():
135
132
        #Create the model if it doesn't already exist
136
133
                self.treestore[index]=gtk.TreeStore(str,str)
180
177
          self.progress.hide_all()
181
178
          md5info=self.md5proc.stdout.read()
182
179
          md5split=md5info.split(" ")
183
 
          dialog = gtk.MessageDialog(self.win,
184
 
          gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
185
 
          gtk.MESSAGE_INFO, gtk.BUTTONS_OK, None)
186
 
          dialog.set_markup('md5sum is: <big><b>'+md5split[0]+'</b></big>')
187
 
          dialog.connect("destroy", lambda w: self.win.set_sensitive(True))
188
 
          resp = dialog.run()
189
 
          if resp:
190
 
            dialog.destroy()
 
180
          displayMessage(self,'md5sum is: <big><b>'+md5split[0]+'</b></big>',gtk.MESSAGE_INFO)
191
181
          return False
192
182
 
193
183
   def progress_update(self):
294
284
          mount=self.ac_mount(entry.get_text(),fileMount)
295
285
 
296
286
          if mount==True:
297
 
           dialog = gtk.MessageDialog(self.win,
298
 
                gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
299
 
                gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, None)
300
 
           dialog.set_markup("<big><b>Mounted:</b></big>"+str(self.isos[index].info.vollabel)+"\n<big><b>Creation date:</b></big>"+str(self.isos[index].info.volcreate))
301
 
           dialog.connect("destroy", lambda w: self.win.set_sensitive(True))
302
 
           resp = dialog.run()
303
 
           if resp:
304
 
                dialog.destroy()
305
287
           info=os.stat(entry.get_text())
306
288
           icon=self.wTree.get_widget("icon"+str(index))
307
289
           if info.st_size<729217000:
348
330
        #Locks a mount slot on the gui
349
331
        entry=self.wTree.get_widget("entry"+str(slot))
350
332
        entry.set_sensitive(False)
351
 
        #mount=self.wTree.get_widget("mount"+str(slot))
352
 
        #mount.set_sensitive(False)
353
 
        #umount=self.wTree.get_widget("umount"+str(slot))
354
 
        #umount.set_sensitive(True)
355
333
        browse=self.wTree.get_widget("browse"+str(slot))
356
334
        browse.set_sensitive(False)
357
335
 
359
337
        #Unlocks a mount slot on the gui
360
338
        entry=self.wTree.get_widget("entry"+str(slot))
361
339
        entry.set_sensitive(True)
362
 
        #mount=self.wTree.get_widget("mount"+str(slot))
363
 
        #mount.set_sensitive(True)
364
 
        #umount=self.wTree.get_widget("umount"+str(slot))
365
 
        #umount.set_sensitive(False)
366
340
        browse=self.wTree.get_widget("browse"+str(slot))
367
341
        browse.set_sensitive(True)
368
342
 
370
344
        mountproc=subprocess.Popen("mount -o loop,ro -t iso9660 "+filename+" \""+mountpoint+"\"", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
371
345
        mountoutput=mountproc.stderr.read()
372
346
        if mountoutput != "":
373
 
          self.win.set_sensitive(False)
374
 
          dialog = gtk.MessageDialog(self.win,
375
 
          gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
376
 
          gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, None)
377
 
          dialog.set_markup('<big><b>'+mountoutput+'</b></big>')
378
 
          dialog.connect("destroy", lambda w: self.win.set_sensitive(True))
379
 
          resp = dialog.run()
380
 
          if resp:
381
 
            dialog.destroy()
 
347
          displayMessage(self,'<big><b>'+mountoutput+'</b></big>',gtk.MESSAGE_ERROR)
382
348
          return False
383
349
        else:
384
350
          return True
387
353
      mountproc=subprocess.Popen("umount \""+mountpoint+"\"", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
388
354
      mountoutput=mountproc.stderr.read()
389
355
      if mountoutput != "":
390
 
          self.win.set_sensitive(False)
391
 
          dialog = gtk.MessageDialog(self.win,
392
 
          gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
393
 
          gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, None)
394
 
          dialog.set_markup('<big><b>'+mountoutput+'</b></big>')
395
 
          dialog.connect("destroy", lambda w: self.win.set_sensitive(True))
396
 
          resp = dialog.run()
397
 
          if resp:
398
 
            dialog.destroy()
 
356
          displayMessage(self,'<big><b>'+mountoutput+'</b></big>',gtk.MESSAGE_ERROR)
399
357
          return False
400
358
      else:
401
359
        return True
429
387
        #Checks to see if an iso is valid
430
388
      if filename == "":
431
389
        #Dude, select a file first you idiot
432
 
        self.win.set_sensitive(False)
433
 
        dialog = gtk.MessageDialog(self.win,
434
 
        gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
435
 
        gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, None)
436
 
        dialog.set_markup('<big><b>You must input an iso image</b></big>')
437
 
        dialog.connect("destroy", lambda w: self.win.set_sensitive(True))
438
 
        resp = dialog.run()
439
 
        if resp:
440
 
          dialog.destroy()
 
390
        displayMessage(self,'<big><b>You must input an iso image</b></big>',gtk.MESSAGE_ERROR)
441
391
        return False
442
392
      process=subprocess.Popen("file "+filename, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
443
393
      output=process.stdout.read()
444
394
      if output.find("ISO") == -1:
445
395
          #File is clearly not an iso, dummy :p
446
 
          self.win.set_sensitive(False)
447
 
          dialog = gtk.MessageDialog(self.win,
448
 
          gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
449
 
          gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, None)
450
 
          dialog.set_markup('<big><b>File selected is not an ISO</b></big>')
451
 
          dialog.connect("destroy", lambda w: self.win.set_sensitive(True))
452
 
          resp = dialog.run()
453
 
          if resp:
454
 
            dialog.destroy()
 
396
          displayMessage(self,'<big><b>File selected is not an ISO</b></big>',gtk.MESSAGE_ERROR)
455
397
          return False
456
398
      return True
457
399
 
522
464
                        self.datprepareid=""
523
465
                        self.applicid=""
524
466
 
 
467
def displayMessage(mclass,mtext,mtype):
 
468
  mclass.win.set_sensitive(False)
 
469
  dialog = gtk.MessageDialog(mclass.win,
 
470
  gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
 
471
  mtype, gtk.BUTTONS_OK, None)
 
472
  dialog.set_markup(mtext)
 
473
  dialog.connect("destroy", lambda w: mclass.win.set_sensitive(True))
 
474
  resp = dialog.run()
 
475
  if resp:
 
476
    dialog.destroy()
 
477
 
 
478
 
525
479
app=gui()
526
480
gtk.main()
527
481