summaryrefslogtreecommitdiff
path: root/gui.ml
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-12-08 18:05:55 +0100
committerYorhel <git@yorhel.nl>2010-12-08 18:05:55 +0100
commit2fec430001eee2a6c803876f643286080b10d6fd (patch)
tree6e9021b8e5af875a74633632ee2d65f155f4cf95 /gui.ml
parent3a1c620f279d6df1fd5c89d5e02c08b8e9b888de (diff)
Added menu bar to main window
With a connect, disconnect and quit button.
Diffstat (limited to 'gui.ml')
-rw-r--r--gui.ml30
1 files changed, 26 insertions, 4 deletions
diff --git a/gui.ml b/gui.ml
index 5cf2fab..6923db0 100644
--- a/gui.ml
+++ b/gui.ml
@@ -108,6 +108,8 @@ class loginwin mainwin =
method show =
if not g_win#misc#visible then (
self#statusmsg `DIALOG_WARNING "Note: The application might hang while connecting. Feel free to kill it when it takes too long.";
+ g_but_con#misc#set_sensitive true;
+ g_frm#misc#set_sensitive true;
if String.length g_frm_usr#text = 0 then
g_frm_usr#misc#grab_focus ()
else
@@ -150,11 +152,20 @@ class loginwin mainwin =
class mainwin () =
(* main window layout *)
let g_win = GWindow.window ~title:"Serika" ~position:`CENTER () in
- let _ = g_win#connect#destroy GMain.Main.quit in
let _ = g_win#set_default_width 640 and _ = g_win#set_default_height 480 in
let g_vbox = GPack.vbox ~packing:g_win#add () in
+ let g_menu = GMenu.menu_bar ~packing:(g_vbox#pack ~expand:false) () in
let g_tabs = GPack.notebook ~packing:g_vbox#add () in
-
+ let g_status = GMisc.statusbar ~packing:(g_vbox#pack ~expand:false) () in
+
+ (* menu bar *)
+ let g_menu_file = GMenu.menu_item ~label:"_File" ~use_mnemonic:true ~packing:g_menu#append () in
+ let g_menu_file_m = GMenu.menu ~packing:g_menu_file#set_submenu () in
+ let g_menu_file_con = GMenu.image_menu_item ~stock:`CONNECT ~label:"Co_nnect" ~use_mnemonic:true ~packing:g_menu_file_m#append () in
+ let g_menu_file_discon = GMenu.image_menu_item ~stock:`DISCONNECT ~label:"_Disconnect" ~use_mnemonic:true ~packing:g_menu_file_m#append () in
+ let _ = GMenu.separator_item ~packing:g_menu_file_m#append () in
+ let g_menu_file_quit = GMenu.image_menu_item ~stock:`QUIT ~label:"_Close" ~use_mnemonic:true ~packing:g_menu_file_m#append () in
+
(* debug tab *)
let g_debug_tbl = GPack.table ~rows:2 ~columns:2 () in
let g_debug_scroll = GBin.scrolled_window ~vpolicy:`ALWAYS ~hpolicy:`AUTOMATIC ~packing:(g_debug_tbl#attach ~left:0 ~top:0 ~right:2 ~expand:`BOTH) () in
@@ -165,7 +176,6 @@ class mainwin () =
let _ = g_debug_cmd#connect#activate (fun () -> ignore (g_debug_send#misc#activate ())) in
(* status bar *)
- let g_status = GMisc.statusbar ~packing:(g_vbox#pack ~expand:false) () in
let g_statuscontext = g_status#new_context ~name:"Meh" in
let g_bandwidth = GMisc.label ~packing:(g_status#pack ~from:`END ~expand:false) ~xalign:1.0 ~width:80 ~text:"0.0 kB" () in
let g_cmd_count = GMisc.label ~packing:(g_status#pack ~from:`END ~expand:false) ~xalign:1.0 ~width:30 ~text:"0" () in
@@ -180,17 +190,26 @@ class mainwin () =
(* login window *)
let login = new loginwin g_win#as_window in
+ (* connect events *)
+ let _ = g_win#connect#destroy GMain.Main.quit in
+ let _ = g_menu_file_quit#connect#activate GMain.Main.quit in
+
(* the object *)
object (self)
val mutable bandwidth = 0
val mutable cmd_count = 0
val mutable laststatusmsg = g_statuscontext#push "Not connected."
+ val ugly_init =
+ g_menu_file_con#connect#activate (fun () -> login#show)
+
method show =
self#set_sensitive false;
g_win#show ();
login#show
+ method set_on_disconnect f = ignore (g_menu_file_discon#connect#activate f)
+
method set_on_debug_cmd f =
ignore (g_debug_send#connect#clicked (fun () ->
f (g_debug_cmd#text)
@@ -198,8 +217,11 @@ class mainwin () =
method login = login
+ (* updates widget sensitivity according to whether we're connected or not *)
method set_sensitive b =
- g_debug_send#misc#set_sensitive b
+ g_debug_send#misc#set_sensitive b;
+ g_menu_file_discon#misc#set_sensitive b;
+ g_menu_file_con#misc#set_sensitive (not b)
method set_loggedin user =
login#hide;