+ d#destroy ()
+ ) in
+
+ let destroy_dialog () =
+ tree#disconnect sigid;
+ d#destroy ()
+ in
+
+ (* Add a close button. *)
+ let close_button = GButton.button ~label:"Close"
+ ~packing:d#action_area#add () in
+ ignore (close_button#connect#clicked ~callback:destroy_dialog);
+
+ (* Destroy dialog when WM close button is pressed. *)
+ ignore (d#connect#destroy ~callback:destroy_dialog);
+
+ d#show ()
+
+(* Helper functions. *)
+and frame ?label ?packing () =
+ let frame = GBin.frame ?label ?packing () in
+ GPack.vbox ~border_width:8 ~packing:frame#add ()
+
+and simple tbl top left label text =
+ let markup = sprintf "<b>%s</b>" (markup_escape text) in
+ ignore (GMisc.label ~xalign:1. ~text:label
+ ~packing:(tbl#attach ~top ~left) ());
+ let left = left + 1 in
+ ignore (GMisc.label ~xalign:0. ~markup ~packing:(tbl#attach ~top ~left) ());
+
+and wide tbl top label text =
+ let markup = sprintf "<b>%s</b>" (markup_escape text) in
+ ignore (GMisc.label ~xalign:1.
+ ~text:label ~packing:(tbl#attach ~top ~left:0) ());
+ ignore (GMisc.label ~xalign:0.
+ ~markup ~packing:(tbl#attach ~top ~left:1 ~right:4) ());
+
+and one_column_view ~title ?packing data =
+ let model, c1 = GTree.store_of_list Gobject.Data.string data in
+
+ let sw =
+ GBin.scrolled_window ?packing ~hpolicy:`AUTOMATIC ~vpolicy:`AUTOMATIC () in
+
+ let view = GTree.view ~model ~packing:sw#add () in
+ view#selection#set_mode `NONE;
+
+ let renderer = GTree.cell_renderer_text [], ["text", c1] in
+ let vc = GTree.view_column ~title ~renderer () in
+ vc#set_resizable true;
+ ignore (view#append_column vc)
+
+and two_column_view ~title1 ~title2 ?packing data =
+ let cols = new GTree.column_list in
+ let c1 = cols#add Gobject.Data.string in
+ let c2 = cols#add Gobject.Data.string in
+
+ let model = GTree.list_store cols in
+ List.iter (
+ fun (d1, d2) ->
+ let row = model#append () in
+ model#set ~row ~column:c1 d1;
+ model#set ~row ~column:c2 d2
+ ) data;
+
+ let sw =
+ GBin.scrolled_window ?packing ~hpolicy:`AUTOMATIC ~vpolicy:`AUTOMATIC () in
+
+ let view = GTree.view ~model ~packing:sw#add () in
+ view#selection#set_mode `NONE;
+
+ let renderer = GTree.cell_renderer_text [], ["text", c1] in
+ let vc = GTree.view_column ~title:title1 ~renderer () in
+ vc#set_resizable true;
+ ignore (view#append_column vc);
+ let renderer = GTree.cell_renderer_text [], ["text", c2] in
+ let vc = GTree.view_column ~title:title2 ~renderer () in
+ vc#set_resizable true;
+ ignore (view#append_column vc)
+
+(* Applications view: populated after a round-trip to the slave thread. *)
+and applications_view ?packing os =
+ let cols = new GTree.column_list in
+ let name_col = cols#add Gobject.Data.string in
+ let version_col = cols#add Gobject.Data.string in
+
+ let model = GTree.list_store cols in
+
+ let sw =
+ GBin.scrolled_window ?packing ~hpolicy:`AUTOMATIC ~vpolicy:`ALWAYS () in
+
+ let view = GTree.view ~model ~height:150 ~packing:sw#add () in
+ view#selection#set_mode `NONE;
+
+ let renderer = GTree.cell_renderer_text [], ["text", name_col] in
+ let vc = GTree.view_column ~title:"Name" ~renderer () in
+ vc#set_resizable true;
+ ignore (view#append_column vc);
+ let renderer = GTree.cell_renderer_text [], ["text", version_col] in
+ let vc = GTree.view_column ~title:"Version" ~renderer () in
+ vc#set_resizable true;
+ ignore (view#append_column vc);
+
+ Slave.list_applications os
+ (when_applications_loaded model name_col version_col)
+
+and when_applications_loaded model name_col version_col apps =
+ Array.iter (
+ fun { G.app_name = name; app_display_name = display_name;
+ app_version = version; app_release = release } ->
+ let name = if display_name <> "" then display_name else name in
+ let version = version ^ if release <> "" then "-"^release else "" in
+ let row = model#append () in
+ model#set ~row ~column:name_col name;
+ model#set ~row ~column:version_col version
+ ) apps