Keep dialogs open and running even if clicking OK

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi list!

First of all, I have of course browsed the net for an answer to the question below, and while trying different approaches nothing worked as I wanted to, so the last resort was to join this list and I hope that all here who knows GTK better than me can help me out.

I'm using Glade and Ruby for my code, but I believe the question applies to general GTK, so if anyone can help me out in C, Python, or anything else it's fine.

The problem...

The application starts out by creating a Glade object, and then enters the Gtk.main-loop, presenting and handling the main dialog window.

In this main window I have a menu choice, to change a username and password. Selecting this creates another Glade object, with a dialog with two Gtk Entries for username and password, with Cancel and Apply buttons. The main object shows this dialog, and runs it.

In the user/password dialog there is a validation, when clicking Apply, that entered text has valid characters. If invalid characters are found a new Glade object is created in the Apply signal function, to present some error text. This dialog have an OK button. So the user/password dialog object shows the message object, and runs it. After OK is clicked the message run-loop is exited, coming back to the user/password object, in the Apply signal function, and this one exits too, taking me back to the main application.

What I would like is to stay in the user/password dialog, to let the user correct the input, and then click either Cancel, or Apply once again, to once again make the validity check and so on, and not get thrown back to the main application dialog.

I have read about catching the "delete-event", returning TRUE or FALSE from this function to either really delete/destroy the window, or to keep it running. I tried to add catch the "delete-event" in the user/password dialogs Apply signal function, but putting a printout there, I saw it was never even called.

Some pseudo/real-code maybe describes it better:

class MainApp
  def initialize()
    @glade = GladeXML.new(bla, bla, bla) {|handler| method(handler)}
  end

  def on_menuUserPassword_activate(widget)
    gUP = UserPasswordDlgGlade.new()
    dlg = gUP.get_widget("UPDlg")
    dlg.show()
    result = dlg.run()
    dlg.hide()
  end
end

// Get the main app up and running.
MainApp.new()
Gtk.main

class UserPasswordDlgGlade
  def initialize()
    @glade = GladeXML.new(bla, bla, bla) {|handler| method(handler)}
  end

  def on_btnApply_clicked(widget)
    Get the user and password from the widget entries
    If user and password were not valid
      gMsg = MessageDlgGlade.new()
      dlg = gMsg.get_widget("MsgDlg")
      dlg.show()
      dlg.run()
      dlg.close()
      If here the user clicked the message dialog's OK button, and we should disregard the Apply click on this UPDlg, and let the user correct the input.
    else
      The user and password was correct, so now we should actually return the Apply response code to the MainApp.
    end
  end

  def on_UPDlg_delete_event(a, b, c)
    Here was where I tried to keep the UPDlg still running, by returning either TRUE or FALSE, but it never seemed to  enter this function, even though I connected this signal in Glade.
  end
end

class MsgDlg
  def initialize()
    @glade = GladeXML.new(bla, bla, bla) {|handler| method(handler)}
  end
end

So how can I keep the user/password dialog running, showing an error message dialog if the user have entered invalid characters, and keep away from closing the u/p dialog until the user have entered a correct input, without getting thrown back to the main app dialog?

Thank you in advance for reading and helping me out, and have a nice day/evening!

Best regards,
Paul
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list


[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux