2 * Drivers acquiring installation utility
3 * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; exactly version 2 of June 1991 is required
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "ui-gnome.h" /* self */
23 #include <glib/gmessages.h>
24 #include "moduriload.h"
26 #include <gtk/gtkmain.h>
27 #include <gtk/gtktreeviewcolumn.h>
28 #include <gtk/gtkbox.h>
30 #include <libgnomeui/gnome-app.h>
31 #include <gtk/gtktreestore.h>
32 #include <gtk/gtkframe.h>
33 #include <gtk/gtkentry.h>
34 #include <libgnomeui/gnome-druid.h>
35 #include <libgnomeui/gnome-app-util.h>
36 #include <libgnomeui/gnome-druid-page-edge.h>
38 #include <libgnomevfs/gnome-vfs-utils.h>
40 #include <captive/macros.h>
44 #define PROGRESS_UPDATE_USEC 200000
45 /* Although proper GTK+ locking is provided below there are some
46 * bugs with compatibility of GTK+/Gnome-VFS/GConf.
47 * The main thread executes gtk_main()->g_main_loop_run()
48 * while the working thread initializes Gnome-VFS by GConf and
49 * executes also g_main_loop_run() while sharing some poll() fds.
51 /* #define UI_GNOME_THREADS 1 */
55 static GtkTreeStore *DriversTreeStore;
56 static GtkFrame *DriversFrame;
57 static GtkFrame *ProgressFrame;
58 static GtkEntry *ProgressEntry;
59 static GnomeDruid *Druid;
60 static GtkButton *DruidButtonSkip;
61 static GtkButton *DruidButtonOK;
62 static GtkTreeView *DriversTreeView;
63 static GnomeDruidPage *PageStart;
64 static GnomeDruidPage *ScanDiskPage;
65 static GnomeDruidPage *ScanPathPage;
66 static GnomeDruidPage *MicrosoftComPage;
67 static GnomeDruidPage *PageFinish;
68 static GtkEntry *ScanPathLocationComboEntry;
69 static GtkButton *MicrosoftComConfirmButton;
70 static GtkProgressBar *MicrosoftComProgress;
72 DRIVERS_TREE_STORE_COLUMN_TYPE,
73 DRIVERS_TREE_STORE_COLUMN_ID,
74 DRIVERS_TREE_STORE_COLUMN_NUM, /* total # */
76 #define DRIVERS_TREE_STORE_COLUMN_TYPE_LIST G_TYPE_STRING,G_TYPE_STRING
79 /* map: (gchar *)type-> (GtkTreeIter *) */
80 static GHashTable *DriversTreeStore_Iter_hash;
82 static void DriversTreeStore_Iter_hash_key_destroy_func(gchar *type)
84 g_return_if_fail(type!=NULL);
89 static void DriversTreeStore_Iter_hash_init(void)
91 if (DriversTreeStore_Iter_hash)
93 DriversTreeStore_Iter_hash=g_hash_table_new_full(g_str_hash,g_str_equal,
94 (GDestroyNotify)DriversTreeStore_Iter_hash_key_destroy_func,
95 NULL); /* value_destroy_func */
98 static GtkTreeIter *DriversTreeStore_Iter_hash_get_iter(const gchar *type)
102 g_return_val_if_fail(type!=NULL,NULL);
104 DriversTreeStore_Iter_hash_init();
105 if (!(r=g_hash_table_lookup(DriversTreeStore_Iter_hash,type))) {
107 gtk_tree_store_append(DriversTreeStore,
110 g_hash_table_insert(DriversTreeStore_Iter_hash,g_strdup(type),r);
116 static gboolean some_modules_found=FALSE;
117 static gboolean in_progress=FALSE;
118 static GnomeDruidPage *page_active;
120 static void state_changed(void)
122 /* Not yet initialized? */
126 gtk_widget_set_sensitive(GTK_WIDGET(DruidButtonSkip),
127 (page_active!=PageStart && page_active!=PageFinish));
128 gtk_widget_set_sensitive(GTK_WIDGET(DruidButtonOK),some_modules_found);
131 gtk_widget_set_sensitive(Druid->next,FALSE);
132 gtk_widget_set_sensitive(GTK_WIDGET(DruidButtonOK),some_modules_found);
133 gtk_widget_set_sensitive(GTK_WIDGET(MicrosoftComConfirmButton),FALSE);
136 /* It is checked by GTK+ whether the text changed: */
137 gtk_entry_set_text(ProgressEntry,"");
138 gtk_widget_set_sensitive(Druid->next,
139 (page_active!=PageFinish && page_active!=MicrosoftComPage));
140 gtk_widget_set_sensitive(GTK_WIDGET(MicrosoftComConfirmButton),
141 (page_active==MicrosoftComPage));
142 gtk_progress_bar_set_fraction(MicrosoftComProgress,(gdouble)0);
143 gtk_progress_bar_set_text(MicrosoftComProgress,"");
147 static void ui_gnome_module_best_priority_notify(const gchar *module_type)
151 g_return_if_fail(module_type!=NULL);
155 iter=DriversTreeStore_Iter_hash_get_iter(module_type);
156 gtk_tree_store_set(DriversTreeStore,iter,
157 DRIVERS_TREE_STORE_COLUMN_TYPE,module_type,
158 DRIVERS_TREE_STORE_COLUMN_ID ,
160 || !strcmp(module_type,"ntoskrnl.exe")
161 || !strcmp(module_type,"ntfs.sys"))
162 ? _("NOT FOUND; essential module for NTFS disks access")
163 : _("not found; optional module")),
170 static void ui_gnome_module_available_notify(struct module_available *module_available)
173 static gboolean some_module_ntoskrnl_exe_found=FALSE;
174 static gboolean some_module_ntfs_sys_found=FALSE;
176 g_return_if_fail(module_available!=NULL);
177 g_return_if_fail(module_available->module!=NULL);
181 iter=DriversTreeStore_Iter_hash_get_iter(module_available->module->type);
182 gtk_tree_store_set(DriversTreeStore,iter,
183 DRIVERS_TREE_STORE_COLUMN_TYPE,module_available->module->type,
184 DRIVERS_TREE_STORE_COLUMN_ID ,module_available->module->id,
187 if (!strcmp(module_available->module->type,"ntoskrnl.exe"))
188 some_module_ntoskrnl_exe_found=TRUE;
189 if (!strcmp(module_available->module->type,"ntfs.sys"))
190 some_module_ntfs_sys_found=TRUE;
192 some_modules_found=some_module_ntoskrnl_exe_found && some_module_ntfs_sys_found;
199 static gboolean all_modules_found=FALSE;
201 static void ui_gnome_all_modules_found_notify(void)
205 all_modules_found=TRUE;
212 static gboolean aborted=FALSE;
213 static gboolean aborted_back=FALSE; /* 'Back' button was clicked. */
214 static struct timeval ProgressEntry_updated_timeval;
215 static struct timeval ProgressBar_updated_timeval;
217 static void progress_start(void)
222 CAPTIVE_MEMZERO(&ProgressEntry_updated_timeval);
223 CAPTIVE_MEMZERO(&ProgressBar_updated_timeval);
227 static void progress_end(void)
233 static gboolean want_progress_update(struct timeval *timeval)
235 struct timeval now_timeval;
236 struct timeval diff_timeval;
238 g_return_val_if_fail(timeval!=NULL,FALSE);
240 gettimeofday( /* FIXME: errors ignored */
241 &now_timeval, /* tv */
243 timersub(&now_timeval,timeval,&diff_timeval);
244 if (!timeval->tv_sec || diff_timeval.tv_sec>0 || diff_timeval.tv_usec>=PROGRESS_UPDATE_USEC) {
245 *timeval=now_timeval;
251 static gboolean ui_gnome_progress(GnomeVFSURI *uri)
253 /* 'uri' may be NULL */
258 static gchar *uri_text=NULL;
260 /* Store 'uri' on each call (not just if 'diff_timeval' permits)
261 * as we may get into long cabinet extraction phase with 'uri==NULL' calls
262 * where we want to display the currently processed 'uri'.
266 uri_text=gnome_vfs_uri_to_string(uri,GNOME_VFS_URI_HIDE_PASSWORD);
270 if (want_progress_update(&ProgressEntry_updated_timeval))
271 gtk_entry_set_text(ProgressEntry,
272 uri_text+(strncmp(uri_text,"file://",strlen("file://")) ? 0 : strlen("file://")));
276 #ifndef UI_GNOME_THREADS
277 while (g_main_context_pending(NULL))
278 g_main_context_iteration(
280 FALSE); /* may_block */
281 #endif /* UI_GNOME_THREADS */
286 /* Do not: g_thread_yield();
287 * as it is TOO much expensive and we are multithreaded anyway.
292 if (all_modules_found)
298 static void ui_gnome_progress_bar(gint done,gint length)
300 g_return_if_fail(done>=0);
301 g_return_if_fail(length>=0);
303 if (!want_progress_update(&ProgressBar_updated_timeval))
309 gtk_progress_bar_pulse(MicrosoftComProgress);
310 gtk_progress_bar_set_text(MicrosoftComProgress,"");
313 gchar *length_display;
315 /* Do not format 'done' by gnome_vfs_format_file_size_for_display()
316 * as the progress would not be visible for large 'done' sizes.
318 gtk_progress_bar_set_fraction(MicrosoftComProgress,((gdouble)done)/length);
319 length_display=gnome_vfs_format_file_size_for_display(length);
320 gtk_progress_bar_set_text(MicrosoftComProgress,
321 captive_printf_alloca("%d B / %s",(int)done,length_display));
322 g_free(length_display);
329 /* FIXME: Change it to "prepare" signal. */
330 void on_Page_map(GtkWidget *vbox_widget,GtkWidget *page_widget)
332 /* Handle non-object (NULL) signal with reversed parameters? */
333 if (GNOME_IS_DRUID_PAGE(vbox_widget) && page_widget==NULL) {
334 page_widget=vbox_widget;
337 g_return_if_fail(vbox_widget==NULL || GTK_IS_VBOX(vbox_widget));
338 g_return_if_fail(GNOME_IS_DRUID_PAGE(page_widget));
340 page_active=GNOME_DRUID_PAGE(page_widget);
341 if (page_active==PageFinish) {
342 gnome_druid_set_show_finish(Druid,FALSE); /* set it each time */
343 /**/ if (!some_modules_found)
344 gnome_druid_page_edge_set_text(GNOME_DRUID_PAGE_EDGE(PageFinish),_(
345 "We need at least some version of drivers essential for this project:"
346 " ntoskrnl.exe and ntfs.sys. Please click 'Back' button to obtain them"
347 " by several methods offered by this installer."));
351 text=final_text(all_modules_found);
352 gnome_druid_page_edge_set_text(GNOME_DRUID_PAGE_EDGE(PageFinish),text);
356 if (page_active==ScanPathPage)
357 gtk_widget_grab_focus(GTK_WIDGET(ScanPathLocationComboEntry));
363 /* FIXME: 'freeze' apparently does not help 'repositioning' of
364 * 'DriversTreeView' during first 'map' of each 'Page'.
366 gtk_widget_freeze_child_notify(vbox_widget);
368 gtk_widget_reparent(GTK_WIDGET(DriversFrame),vbox_widget);
369 gtk_widget_reparent(GTK_WIDGET(ProgressFrame),vbox_widget);
371 gtk_box_reorder_child(GTK_BOX(vbox_widget),GTK_WIDGET(DriversFrame),
374 gtk_box_set_child_packing(GTK_BOX(vbox_widget),GTK_WIDGET(DriversFrame),
379 gtk_box_set_child_packing(GTK_BOX(vbox_widget),GTK_WIDGET(ProgressFrame),
385 /* FIXME: Needed to fix (0,0)-position inside parent GdkWindow. */
386 gtk_widget_queue_resize(GTK_WIDGET(DriversTreeView));
387 gtk_widget_queue_resize(GTK_WIDGET(ProgressEntry));
389 gtk_widget_thaw_child_notify(vbox_widget);
392 typedef void (*process_t)(void);
394 #ifdef UI_GNOME_THREADS
395 /* 'GThreadFunc' type. */
396 gpointer execute_process_func(process_t process /* data */)
402 gtk_main_quit(); /* Abort gtk_main() of execute_process(). */
409 #endif /* UI_GNOME_THREADS */
411 /* We are called inside gdk_threads_enter(). */
412 static void execute_process(process_t process)
414 #ifdef UI_GNOME_THREADS
416 #endif /* UI_GNOME_THREADS */
419 #ifdef UI_GNOME_THREADS
420 gthread=g_thread_create_full(
421 (GThreadFunc)execute_process_func, /* func */
423 0, /* stack_size; 0 means the default size */
425 TRUE, /* bound; use system thread */
426 G_THREAD_PRIORITY_LOW, /* priority; G_THREAD_PRIORITY_LOW is the lowest one */
428 gtk_main(); /* We are already called inside gdk_threads_enter(). */
429 /* I hope some other gtk_main_quit() did not occur as we would
430 * locked if the 'process' func did not finish yet.
432 g_thread_join(gthread);
433 #else /* UI_GNOME_THREADS */
435 #endif /* UI_GNOME_THREADS */
439 /* 'process_t' typed. */
440 static void process_scan_disk(void)
446 static GnomeVFSURI *process_scan_path_scan_path_uri;
448 /* 'process_t' typed. */
449 static void process_scan_path(void)
451 mod_uri_load_base_reporting(process_scan_path_scan_path_uri);
454 /* 'process_t' typed. */
455 static void process_microsoft_com(void)
460 gboolean on_Page_next(GnomeDruidPage *gnomedruidpage,GtkWidget *widget,gpointer user_data /* unused */)
462 g_return_val_if_fail(GNOME_IS_DRUID_PAGE(gnomedruidpage),FALSE);
464 if (in_progress) /* bogus callback - we should be non-sensitive */
465 return TRUE; /* ignore button press */
467 /**/ if (page_active==PageStart) {
468 if (all_modules_found) {
469 gnome_druid_set_page(Druid,PageFinish);
470 return TRUE; /* ignore button press */
473 else if (page_active==ScanDiskPage) {
474 execute_process(process_scan_disk);
476 gnome_druid_set_page(Druid,PageStart);
477 return TRUE; /* ignore button press */
479 if (all_modules_found) {
480 gnome_druid_set_page(Druid,PageFinish);
481 return TRUE; /* ignore button press */
483 return FALSE; /* proceed to next page */
485 else if (page_active==ScanPathPage) {
486 const gchar *scan_path_uri_text=gtk_entry_get_text(ScanPathLocationComboEntry);
488 if (scan_path_uri_text && *scan_path_uri_text) {
489 GnomeVFSURI *scan_path_uri;
491 if ((scan_path_uri=gnome_vfs_uri_new(scan_path_uri_text))) {
492 process_scan_path_scan_path_uri=scan_path_uri;
493 execute_process(process_scan_path);
494 gnome_vfs_uri_unref(scan_path_uri);
496 gnome_druid_set_page(Druid,(all_modules_found ? PageStart : ScanDiskPage));
497 return TRUE; /* ignore button press */
499 if (all_modules_found) {
500 gnome_druid_set_page(Druid,PageFinish);
501 return TRUE; /* ignore button press */
503 gtk_entry_set_text(ScanPathLocationComboEntry,"");
506 g_warning(_("Invalid URI: %s"),scan_path_uri_text);
507 gtk_widget_grab_focus(GTK_WIDGET(ScanPathLocationComboEntry));
508 return TRUE; /* ignore button press; we cleared the URI entry */
510 return FALSE; /* proceed to next page */
513 return FALSE; /* proceed to next page */
516 void on_MicrosoftComConfirmButton_clicked(GtkButton *button,gpointer user_data)
518 g_return_if_fail(GTK_IS_BUTTON(button));
520 if (in_progress) /* bogus callback */
522 if (page_active!=MicrosoftComPage) /* bogus callback */
525 execute_process(process_microsoft_com);
527 gnome_druid_set_page(Druid,(all_modules_found ? PageStart : ScanPathPage));
530 if (all_modules_found) {
531 gnome_druid_set_page(Druid,PageFinish);
535 gnome_druid_set_page(Druid,PageFinish);
538 void on_DruidButtonSkip_clicked(GtkButton *button,gpointer user_data /* unused */)
540 g_return_if_fail(GTK_IS_BUTTON(button));
547 if (all_modules_found)
548 gnome_druid_set_page(Druid,PageFinish);
549 else if (page_active==ScanDiskPage)
550 gnome_druid_set_page(Druid,ScanPathPage);
551 else if (page_active==ScanPathPage)
552 gnome_druid_set_page(Druid,MicrosoftComPage);
553 else if (page_active==MicrosoftComPage)
554 gnome_druid_set_page(Druid,PageFinish);
557 gboolean on_Page_back(GnomeDruidPage *gnomedruidpage,GtkWidget *widget,gpointer user_data)
559 g_return_val_if_fail(GNOME_IS_DRUID_PAGE(gnomedruidpage),FALSE);
562 if (all_modules_found) {
563 gnome_druid_set_page(Druid,PageStart);
564 return TRUE; /* ignore button press */
566 return FALSE; /* proceed to previous page */
573 return TRUE; /* ignore button press now; we will respect 'aborted_back' */
576 void on_Druid_cancel(GnomeDruid *gnomedruid,gpointer user_data /* unused */)
578 g_return_if_fail(GNOME_IS_DRUID(gnomedruid));
580 /* gtk_main_quit() would not abort the current operation. */
584 static void on_DruidButtonOK_clicked_dialog_callback(gint reply,gint *replyp /* data */)
586 g_return_if_fail(reply>=0);
587 g_return_if_fail(replyp!=NULL);
592 void on_DruidButtonOK_clicked(GtkButton *button,gpointer user_data /* unused */)
597 g_return_if_fail(GTK_IS_BUTTON(button));
599 if (all_modules_found)
602 /* TODO: Avoid dialog if already on Finish page. */
604 dialog=gnome_app_ok_cancel_modal(App,_(
605 "Although essential modules (\"ntoskrnl.exe\" and \"ntfs.sys\") are available "
606 "you may still want to get their better version and/or more modules. "
608 (GnomeReplyCallback)on_DruidButtonOK_clicked_dialog_callback,
610 g_signal_connect((gpointer)dialog,"close",G_CALLBACK(gtk_main_quit),NULL);
611 /* Never call gtk_main() from other thread than the initial one.
612 * We would have to switch GTK+ context (g_main_context()?).
615 /* 'dialog' gets destroyed automatically */
616 if (reply==0) /* 0 for 'OK', 1 for 'Cancel', left -1 for dialog close. */
620 static void button_stock_set_label(GtkWidget *widget,const gchar *label_text_new /* callback_data */)
622 g_return_if_fail(GTK_IS_WIDGET(widget));
623 g_return_if_fail(label_text_new!=NULL);
625 /**/ if (GTK_IS_CONTAINER(widget))
626 gtk_container_foreach(GTK_CONTAINER(widget),
627 (GtkCallback)button_stock_set_label, /* callback */
628 (/* de-conts */ gchar *)label_text_new); /* callback_data */
629 else if (GTK_IS_LABEL(widget))
630 gtk_label_set_text_with_mnemonic(GTK_LABEL(widget),label_text_new);
633 static void PageFinish_set_label_attr(GtkWidget *widget,gpointer callback_data /* unused */)
635 g_return_if_fail(GTK_IS_WIDGET(widget));
637 /**/ if (GTK_IS_CONTAINER(widget))
638 gtk_container_foreach(GTK_CONTAINER(widget),
639 (GtkCallback)PageFinish_set_label_attr, /* callback */
640 callback_data); /* callback_data; unused */
641 else if (GTK_IS_LABEL(widget) && gtk_label_get_line_wrap(GTK_LABEL(widget)))
642 gtk_label_set_selectable(GTK_LABEL(widget),TRUE);
645 /* of "ui-gnome-interface.h": */
646 GtkWidget *create_App(void);
647 /* of "ui-gnome-support.h": */
648 GtkWidget *lookup_widget(GtkWidget *widget,const gchar *widget_name);
650 static void App_init(void)
652 GtkTreeViewColumn *column;
653 GtkCellRenderer *cell;
654 GtkBox *druid_button_box;
658 App=GNOME_APP(create_App());
660 DriversTreeView=GTK_TREE_VIEW(lookup_widget(GTK_WIDGET(App),"DriversTreeView"));
661 DriversFrame=GTK_FRAME(lookup_widget(GTK_WIDGET(App),"DriversFrame"));
662 ProgressFrame=GTK_FRAME(lookup_widget(GTK_WIDGET(App),"ProgressFrame"));
663 Druid=GNOME_DRUID(lookup_widget(GTK_WIDGET(App),"Druid"));
664 PageStart=GNOME_DRUID_PAGE(lookup_widget(GTK_WIDGET(App),"PageStart"));
665 ScanDiskPage=GNOME_DRUID_PAGE(lookup_widget(GTK_WIDGET(App),"ScanDiskPage"));
666 ScanPathPage=GNOME_DRUID_PAGE(lookup_widget(GTK_WIDGET(App),"ScanPathPage"));
667 MicrosoftComPage=GNOME_DRUID_PAGE(lookup_widget(GTK_WIDGET(App),"MicrosoftComPage"));
668 PageFinish=GNOME_DRUID_PAGE(lookup_widget(GTK_WIDGET(App),"PageFinish"));
669 ScanPathLocationComboEntry=GTK_ENTRY(lookup_widget(GTK_WIDGET(App),"ScanPathLocationComboEntry"));
670 MicrosoftComConfirmButton=GTK_BUTTON(lookup_widget(GTK_WIDGET(App),"MicrosoftComConfirmButton"));
671 MicrosoftComProgress=GTK_PROGRESS_BAR(lookup_widget(GTK_WIDGET(App),"MicrosoftComProgress"));
672 ProgressEntry=GTK_ENTRY(lookup_widget(GTK_WIDGET(App),"ProgressEntry"));
674 druid_button_box=GTK_BOX(gtk_widget_get_parent(Druid->next));
676 DriversTreeStore=gtk_tree_store_new(DRIVERS_TREE_STORE_COLUMN_NUM,DRIVERS_TREE_STORE_COLUMN_TYPE_LIST);
677 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(DriversTreeStore),
678 DRIVERS_TREE_STORE_COLUMN_TYPE,GTK_SORT_ASCENDING);
679 gtk_tree_view_set_model(DriversTreeView,GTK_TREE_MODEL(DriversTreeStore));
681 column=gtk_tree_view_column_new();
682 cell=gtk_cell_renderer_text_new();
683 gtk_tree_view_column_pack_start(column,cell,
685 gtk_tree_view_column_set_attributes(column,cell,
686 "text",DRIVERS_TREE_STORE_COLUMN_TYPE,
688 gtk_tree_view_append_column(DriversTreeView,column);
690 column=gtk_tree_view_column_new();
691 cell=gtk_cell_renderer_text_new();
692 gtk_tree_view_column_pack_start(column,cell,
694 gtk_tree_view_column_set_attributes(column,cell,
695 "text",DRIVERS_TREE_STORE_COLUMN_ID,
697 gtk_tree_view_append_column(DriversTreeView,column);
699 /* gnome_druid_set_show_finish() just replaces Next<->Finish buttons displayed. */
700 gtk_widget_hide(GTK_WIDGET(Druid->finish));
702 DruidButtonSkip=GTK_BUTTON(gtk_button_new_from_stock(GTK_STOCK_REDO));
703 button_stock_set_label(
704 GTK_WIDGET(DruidButtonSkip), /* widget */
705 _("_Skip")); /* label_text_new */
706 gtk_box_pack_end(druid_button_box,GTK_WIDGET(DruidButtonSkip),FALSE,TRUE,0);
707 gtk_widget_show(GTK_WIDGET(DruidButtonSkip));
708 g_signal_connect((gpointer)DruidButtonSkip,"clicked",G_CALLBACK(on_DruidButtonSkip_clicked),NULL);
710 DruidButtonOK=GTK_BUTTON(gtk_button_new_from_stock(GTK_STOCK_OK));
711 gtk_box_pack_end(druid_button_box,GTK_WIDGET(DruidButtonOK),FALSE,TRUE,0);
712 gtk_widget_show(GTK_WIDGET(DruidButtonOK));
713 g_signal_connect((gpointer)DruidButtonOK,"clicked",G_CALLBACK(on_DruidButtonOK_clicked),NULL);
715 PageFinish_set_label_attr(
716 GTK_WIDGET(PageFinish), /* widget */
717 NULL); /* callback_data; unused */
724 static void ui_gnome_g_log_handler(const gchar *log_domain,GLogLevelFlags log_level,const gchar *message,gpointer user_data)
728 /* Ignore arrors by cabextract during its abortion. */
729 if (in_progress && aborted)
734 /**/ if (log_level & G_LOG_LEVEL_ERROR)
735 dialog=gnome_app_error(App,message);
736 else if (log_level & (G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING))
737 dialog=gnome_app_warning(App,message);
739 dialog=gnome_app_message(App,message);
741 gtk_window_set_modal(GTK_WINDOW(dialog),TRUE);
742 g_signal_connect((gpointer)dialog,"close",G_CALLBACK(gtk_main_quit),NULL);
744 /* 'dialog' gets destroyed automatically */
750 static void ui_gnome_interactive(void)
754 /* Postpone gtk_widget_show_all() from App_init() here
755 * to have already passed all ui_gnome_module_available_notify().
757 gnome_druid_set_page(Druid,MicrosoftComPage);
758 gtk_widget_show_all(GTK_WIDGET(App));
760 /* gnome_druid_set_page(Druid,PageStart); */
761 gnome_druid_set_page(Druid,ScanDiskPage);
762 gnome_druid_set_page(Druid,ScanPathPage);
763 /* gnome_druid_set_page(Druid,MicrosoftComPage); */
764 gnome_druid_set_page(Druid,PageFinish);
766 gnome_druid_set_page(Druid,PageStart);
775 gboolean ui_gnome_init(void)
777 acquire_module_available_notify=ui_gnome_module_available_notify;
778 acquire_module_all_modules_found_notify=ui_gnome_all_modules_found_notify;
779 ui_progress=ui_gnome_progress;
780 ui_progress_bar=ui_gnome_progress_bar;
781 ui_interactive=ui_gnome_interactive;
782 captivemodid_module_best_priority_notify=ui_gnome_module_best_priority_notify;
784 #ifdef UI_GNOME_THREADS
785 /* gdk_threads_init() must be called before gtk_init()!
786 * gtk_init() gets called by create_App() here.
788 if (!g_thread_supported())
790 if (!gdk_threads_mutex)
792 #endif /* UI_GNOME_THREADS */
794 /* Graphic widgets will all be hidden yet. */
796 /* ui_gnome_g_log_handler() needs 'App'. */
798 G_LOG_DOMAIN, /* log_domain; "Captive" */
799 G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL, /* log_levels */
800 ui_gnome_g_log_handler, /* log_func */
801 NULL); /* user_data */