[maemo-commits] [maemo-commits] r8609 - projects/haf/trunk/osso-application-installer/src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Mon Dec 4 18:08:11 EET 2006
- Previous message: [maemo-commits] r8608 - projects/haf/trunk/libosso/src
- Next message: [maemo-commits] r8610 - in projects/haf/trunk/osso-application-installer: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: marivoll
Date: 2006-12-04 18:08:09 +0200 (Mon, 04 Dec 2006)
New Revision: 8609
Modified:
projects/haf/trunk/osso-application-installer/src/details.cc
projects/haf/trunk/osso-application-installer/src/details.h
projects/haf/trunk/osso-application-installer/src/log.cc
projects/haf/trunk/osso-application-installer/src/main.cc
projects/haf/trunk/osso-application-installer/src/repo.cc
projects/haf/trunk/osso-application-installer/src/search.cc
projects/haf/trunk/osso-application-installer/src/settings.cc
projects/haf/trunk/osso-application-installer/src/util.cc
projects/haf/trunk/osso-application-installer/src/util.h
Log:
Keep track of dialog stacking order in a general way. (N48797)
* src/details.cc, src/details.h, src/log.cc, src/main.cc,
src/repo.cc, src/search.cc, src/settings.cc, src/util.cc,
src/util.h
(push_dialog_parent, pop_dialog_parent, get_dialog_parent): New,
Use them for all dialogs by pushing nerwly created ones and
popping when they are destroyed.
* src/main.cc (main): Push the main window as the default dialog
parent.
* src/details.h, src/details.cc (show_package_details): Removed
'parent' parameter. Updated all callers. Don't pass parent
around via closure etc.
* src/repo.cc (show_repo_edit_dialog): Removed 'parent' parameter.
Updated all callers. Don't pass parent around via closure etc.
Modified: projects/haf/trunk/osso-application-installer/src/details.cc
===================================================================
--- projects/haf/trunk/osso-application-installer/src/details.cc 2006-12-04 15:39:00 UTC (rev 8608)
+++ projects/haf/trunk/osso-application-installer/src/details.cc 2006-12-04 16:08:09 UTC (rev 8609)
@@ -35,7 +35,6 @@
#define _(x) gettext (x)
struct spd_closure {
- GtkWindow *parent;
package_info *pi;
detail_kind kind;
bool show_problems;
@@ -252,12 +251,12 @@
static void
details_response (GtkDialog *dialog, gint response, gpointer clos)
{
+ pop_dialog_parent ();
gtk_widget_destroy (GTK_WIDGET (dialog));
}
static void
-show_with_details (GtkWindow *parent,
- package_info *pi, bool show_problems)
+show_with_details (package_info *pi, bool show_problems)
{
GtkWidget *dialog, *notebook;
GtkWidget *table, *common;
@@ -415,11 +414,12 @@
GTK_POLICY_AUTOMATIC);
dialog = gtk_dialog_new_with_buttons (_("ai_ti_details"),
- parent,
+ get_dialog_parent (),
GTK_DIALOG_MODAL,
_("ai_bd_details_close"),
GTK_RESPONSE_OK,
NULL);
+ push_dialog_parent (dialog);
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
set_dialog_help (dialog, AI_TOPIC ("packagedetailsview"));
@@ -500,7 +500,6 @@
get_package_details_reply (int cmd, apt_proto_decoder *dec, void *clos)
{
spd_closure *c = (spd_closure *)clos;
- GtkWindow *parent = c->parent;
package_info *pi = c->pi;
detail_kind kind = c->kind;
bool show_problems = c->show_problems;
@@ -532,7 +531,7 @@
pi->have_detail_kind = kind;
- show_with_details (parent, pi, show_problems);
+ show_with_details (pi, show_problems);
}
void
@@ -549,21 +548,18 @@
data);
else
{
- GtkWindow *parent = c->parent;
bool show_problems = c->show_problems;
delete c;
- show_with_details (parent, pi, show_problems);
+ show_with_details (pi, show_problems);
}
}
void
-show_package_details (GtkWindow *parent,
- package_info *pi, detail_kind kind,
+show_package_details (package_info *pi, detail_kind kind,
bool show_problems)
{
spd_closure *c = new spd_closure;
- c->parent = parent;
c->pi = pi;
c->kind = kind;
c->show_problems = show_problems;
Modified: projects/haf/trunk/osso-application-installer/src/details.h
===================================================================
--- projects/haf/trunk/osso-application-installer/src/details.h 2006-12-04 15:39:00 UTC (rev 8608)
+++ projects/haf/trunk/osso-application-installer/src/details.h 2006-12-04 16:08:09 UTC (rev 8609)
@@ -26,8 +26,7 @@
#include "main.h"
-void show_package_details (GtkWindow *parent,
- package_info *p, detail_kind kind,
+void show_package_details (package_info *p, detail_kind kind,
bool show_problems);
void decode_summary (apt_proto_decoder *dec,
Modified: projects/haf/trunk/osso-application-installer/src/log.cc
===================================================================
--- projects/haf/trunk/osso-application-installer/src/log.cc 2006-12-04 15:39:00 UTC (rev 8608)
+++ projects/haf/trunk/osso-application-installer/src/log.cc 2006-12-04 16:08:09 UTC (rev 8609)
@@ -151,17 +151,19 @@
save_log, NULL);
if (response == GTK_RESPONSE_CLOSE)
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ {
+ pop_dialog_parent ();
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ }
}
-
void
show_log ()
{
GtkWidget *dialog, *text_view;
dialog = gtk_dialog_new_with_buttons (_("ai_ti_log"),
- get_main_window (),
+ get_dialog_parent (),
GTK_DIALOG_MODAL,
_("ai_bd_log_save_as"),
RESPONSE_SAVE,
@@ -170,6 +172,7 @@
_("ai_bd_log_close"),
GTK_RESPONSE_CLOSE,
NULL);
+ push_dialog_parent (dialog);
respond_on_escape (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
Modified: projects/haf/trunk/osso-application-installer/src/main.cc
===================================================================
--- projects/haf/trunk/osso-application-installer/src/main.cc 2006-12-04 15:39:00 UTC (rev 8608)
+++ projects/haf/trunk/osso-application-installer/src/main.cc 2006-12-04 16:08:09 UTC (rev 8609)
@@ -1494,7 +1494,7 @@
available_package_details (gpointer data)
{
package_info *pi = (package_info *)data;
- show_package_details (get_main_window (), pi, install_details, false);
+ show_package_details (pi, install_details, false);
}
void
@@ -1517,7 +1517,7 @@
installed_package_details (gpointer data)
{
package_info *pi = (package_info *)data;
- show_package_details (get_main_window (), pi, remove_details, false);
+ show_package_details (pi, remove_details, false);
}
static void uninstall_package (package_info *);
@@ -2772,6 +2772,7 @@
window = hildon_window_new ();
gtk_window_set_title (GTK_WINDOW (window), _("ai_ap_application_installer"));
+ push_dialog_parent (window);
main_window = GTK_WINDOW (window);
Modified: projects/haf/trunk/osso-application-installer/src/repo.cc
===================================================================
--- projects/haf/trunk/osso-application-installer/src/repo.cc 2006-12-04 15:39:00 UTC (rev 8608)
+++ projects/haf/trunk/osso-application-installer/src/repo.cc 2006-12-04 16:08:09 UTC (rev 8609)
@@ -69,7 +69,6 @@
GtkTreeView *tree;
GtkListStore *store;
- GtkWindow *dialog;
GtkWidget *edit_button;
GtkWidget *delete_button;
@@ -300,6 +299,7 @@
delete c;
+ pop_dialog_parent ();
gtk_widget_destroy (GTK_WIDGET (dialog));
}
@@ -345,8 +345,7 @@
}
static void
-show_repo_edit_dialog (GtkWindow *parent,
- repo_line *r, bool isnew, bool readonly)
+show_repo_edit_dialog (repo_line *r, bool isnew, bool readonly)
{
GtkWidget *dialog, *vbox, *caption;
GtkSizeGroup *group;
@@ -370,7 +369,7 @@
{
GtkWidget *button;
- dialog = gtk_dialog_new_with_buttons (title, parent,
+ dialog = gtk_dialog_new_with_buttons (title, get_dialog_parent (),
GTK_DIALOG_MODAL,
NULL);
@@ -382,7 +381,7 @@
gtk_widget_grab_focus (button);
}
else
- dialog = gtk_dialog_new_with_buttons (title, parent,
+ dialog = gtk_dialog_new_with_buttons (title, get_dialog_parent (),
GTK_DIALOG_MODAL,
_("ai_bd_new_repository_ok"),
GTK_RESPONSE_OK,
@@ -390,6 +389,8 @@
GTK_RESPONSE_CANCEL,
NULL);
+ push_dialog_parent (dialog);
+
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
// XXX - there is no help for the "edit" version of this dialog.
@@ -477,7 +478,7 @@
*c->lastp = r;
c->lastp = &r->next;
- show_repo_edit_dialog (c->dialog, r, true, false);
+ show_repo_edit_dialog (r, true, false);
}
static void
@@ -576,7 +577,7 @@
if (r->essential)
irritate_user (_("ai_ib_unable_edit"));
- show_repo_edit_dialog (c->dialog, r, false, r->essential);
+ show_repo_edit_dialog (r, false, r->essential);
return;
}
@@ -606,6 +607,7 @@
}
delete c;
+ pop_dialog_parent ();
gtk_widget_destroy (GTK_WIDGET (dialog));
}
}
@@ -663,7 +665,6 @@
GtkTreeViewColumn *column,
gpointer data)
{
- repo_closure *c = (repo_closure *)data;
GtkTreeModel *model = gtk_tree_view_get_model (treeview);
GtkTreeIter iter;
@@ -676,7 +677,7 @@
if (r->essential)
irritate_user (_("ai_ib_unable_edit"));
- show_repo_edit_dialog (c->dialog, r, false, r->essential);
+ show_repo_edit_dialog (r, false, r->essential);
}
}
@@ -810,8 +811,7 @@
{
repo_add_closure *ac = (repo_add_closure *)data;
- show_repo_edit_dialog (get_main_window (),
- ac->new_repo, true, true);
+ show_repo_edit_dialog (ac->new_repo, true, true);
}
static void
@@ -907,12 +907,11 @@
{
GtkWidget *dialog = gtk_dialog_new ();
- c->dialog = GTK_WINDOW (dialog);
-
gtk_window_set_title (GTK_WINDOW (dialog), _("ai_ti_repository"));
- gtk_window_set_transient_for (GTK_WINDOW (dialog), get_main_window ());
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), get_dialog_parent ());
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
-
+ push_dialog_parent (dialog);
+
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_dialog_add_button (GTK_DIALOG (dialog),
_("ai_bd_repository_new"), REPO_RESPONSE_NEW);
Modified: projects/haf/trunk/osso-application-installer/src/search.cc
===================================================================
--- projects/haf/trunk/osso-application-installer/src/search.cc 2006-12-04 15:39:00 UTC (rev 8608)
+++ projects/haf/trunk/osso-application-installer/src/search.cc 2006-12-04 16:08:09 UTC (rev 8609)
@@ -108,6 +108,7 @@
search_packages (pattern, in_descriptions);
}
+ pop_dialog_parent ();
gtk_widget_destroy (GTK_WIDGET (dialog));
delete c;
}
@@ -131,13 +132,14 @@
search_dialog_closure *c = new search_dialog_closure;
dialog = gtk_dialog_new_with_buttons (_("ai_ti_search"),
- get_main_window (),
+ get_dialog_parent (),
GTK_DIALOG_MODAL,
_("ai_bd_search_ok"),
GTK_RESPONSE_OK,
_("ai_bd_search_cancel"),
GTK_RESPONSE_CANCEL,
NULL);
+ push_dialog_parent (dialog);
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
set_dialog_help (dialog, AI_TOPIC ("search"));
//gtk_widget_set_usize (dialog, 400, -1);
Modified: projects/haf/trunk/osso-application-installer/src/settings.cc
===================================================================
--- projects/haf/trunk/osso-application-installer/src/settings.cc 2006-12-04 15:39:00 UTC (rev 8608)
+++ projects/haf/trunk/osso-application-installer/src/settings.cc 2006-12-04 16:08:09 UTC (rev 8609)
@@ -275,13 +275,14 @@
settings_closure *c = new settings_closure;
dialog = gtk_dialog_new_with_buttons (_("ai_ti_settings"),
- get_main_window (),
+ get_dialog_parent (),
GTK_DIALOG_MODAL,
_("ai_bd_settings_ok"),
GTK_RESPONSE_OK,
_("ai_bd_settings_cancel"),
GTK_RESPONSE_CANCEL,
NULL);
+ push_dialog_parent (dialog);
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
set_dialog_help (dialog, AI_TOPIC ("settings"));
@@ -311,6 +312,7 @@
sort_all_packages ();
}
+ pop_dialog_parent ();
gtk_widget_destroy (GTK_WIDGET (dialog));
}
@@ -319,7 +321,8 @@
{
GtkWidget *dialog;
- dialog = hildon_sort_dialog_new (get_main_window ());
+ dialog = hildon_sort_dialog_new (get_dialog_parent ());
+ push_dialog_parent (dialog);
hildon_sort_dialog_add_sort_key (HILDON_SORT_DIALOG (dialog),
_("ai_va_sort_name"));
Modified: projects/haf/trunk/osso-application-installer/src/util.cc
===================================================================
--- projects/haf/trunk/osso-application-installer/src/util.cc 2006-12-04 15:39:00 UTC (rev 8608)
+++ projects/haf/trunk/osso-application-installer/src/util.cc 2006-12-04 16:08:09 UTC (rev 8609)
@@ -72,6 +72,34 @@
#define BTNAME_MATCH_RULE "type='signal',interface='" BTNAME_SIGNAL_IF \
"',member='" BTNAME_SIG_CHANGED "'"
+static GSList *dialog_parents = NULL;
+
+GtkWindow *
+get_dialog_parent ()
+{
+ if (dialog_parents)
+ return GTK_WINDOW (dialog_parents->data);
+ else
+ return NULL;
+}
+
+void
+push_dialog_parent (GtkWidget *w)
+{
+ dialog_parents = g_slist_prepend (dialog_parents, w);
+}
+
+void
+pop_dialog_parent ()
+{
+ if (dialog_parents)
+ {
+ GSList *old = dialog_parents;
+ dialog_parents = dialog_parents->next;
+ g_slist_free_1 (old);
+ }
+}
+
struct ayn_closure {
package_info *pi;
detail_kind kind;
@@ -88,7 +116,7 @@
if (response == 1)
{
if (c->pi)
- show_package_details (GTK_WINDOW (dialog), c->pi, c->kind, false);
+ show_package_details (c->pi, c->kind, false);
else if (c->details)
c->details (c->data);
return;
@@ -100,6 +128,7 @@
c->pi->unref ();
delete c;
+ pop_dialog_parent ();
gtk_widget_destroy (GTK_WIDGET (dialog));
cont (response == GTK_RESPONSE_OK, data);
}
@@ -166,12 +195,13 @@
dialog = gtk_dialog_new_with_buttons
(title,
- get_main_window (),
+ get_dialog_parent (),
GTK_DIALOG_MODAL,
_("ai_bd_confirm_ok"), GTK_RESPONSE_OK,
_("ai_bd_confirm_details"), 1,
_("ai_bd_confirm_cancel"), GTK_RESPONSE_CANCEL,
NULL);
+ push_dialog_parent (dialog);
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
@@ -198,12 +228,13 @@
dialog = gtk_dialog_new_with_buttons
(title,
- get_main_window (),
+ get_dialog_parent (),
GTK_DIALOG_MODAL,
_("ai_bd_confirm_ok"), GTK_RESPONSE_OK,
_("ai_bd_confirm_details"), 1,
_("ai_bd_confirm_cancel"), GTK_RESPONSE_CANCEL,
NULL);
+ push_dialog_parent (dialog);
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
GtkWidget *label = gtk_label_new (question);
@@ -253,7 +284,7 @@
if (response == 1)
{
- show_package_details (GTK_WINDOW (dialog), c->pi, c->kind, true);
+ show_package_details (c->pi, c->kind, true);
}
else
{
@@ -399,11 +430,12 @@
dialog = gtk_dialog_new_with_buttons
(_("ai_ti_notice"),
- get_main_window (),
+ get_dialog_parent (),
GTK_DIALOG_MODAL,
_("ai_bd_notice_ok"), GTK_RESPONSE_OK,
_("ai_bd_notice_cancel"), GTK_RESPONSE_CANCEL,
NULL);
+ push_dialog_parent (dialog);
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
const char *text = (sure
@@ -1423,6 +1455,7 @@
char *uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
+ pop_dialog_parent ();
gtk_widget_destroy (GTK_WIDGET (dialog));
if (response == GTK_RESPONSE_OK)
@@ -1443,13 +1476,14 @@
GtkFileFilter *filter;
fcd = hildon_file_chooser_dialog_new_with_properties
- (get_main_window (),
+ (get_dialog_parent (),
"action", GTK_FILE_CHOOSER_ACTION_OPEN,
"title", _("ai_ti_select_package"),
"empty_text", _("ai_ia_select_package_no_packages"),
"open_button_text", _("ai_bd_select_package"),
NULL);
gtk_window_set_modal (GTK_WINDOW (fcd), TRUE);
+ push_dialog_parent (fcd);
filter = gtk_file_filter_new ();
gtk_file_filter_add_mime_type (filter, "application/x-deb");
@@ -1478,10 +1512,11 @@
GtkWidget *fcd;
fcd = hildon_file_chooser_dialog_new_with_properties
- (parent,
+ (get_dialog_parent (),
"action", GTK_FILE_CHOOSER_ACTION_SAVE,
"title", title,
NULL);
+ push_dialog_parent (fcd);
gtk_window_set_modal (GTK_WINDOW (fcd), TRUE);
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fcd), default_filename);
Modified: projects/haf/trunk/osso-application-installer/src/util.h
===================================================================
--- projects/haf/trunk/osso-application-installer/src/util.h 2006-12-04 15:39:00 UTC (rev 8608)
+++ projects/haf/trunk/osso-application-installer/src/util.h 2006-12-04 16:08:09 UTC (rev 8609)
@@ -40,6 +40,10 @@
The dialogs are application modal.
+ PUSH_DIALOG_PARENT and POP_DIALOG_PARENT are used to keep track of
+ the top-most window to be used as the parent for new dialogs.
+ GET_DIALOG_PARENT returns that window.
+
ASK_YES_NO shows QUESTION in a confirmation note. The result RES
passed to the continuation CONT is true when the user clicks "Ok",
of course, and false otherwise.
@@ -86,6 +90,10 @@
*/
+void push_dialog_parent (GtkWidget *window);
+void pop_dialog_parent ();
+GtkWindow *get_dialog_parent ();
+
void ask_yes_no (const gchar *question,
void (*cont) (bool res, void *data), void *data);
- Previous message: [maemo-commits] r8608 - projects/haf/trunk/libosso/src
- Next message: [maemo-commits] r8610 - in projects/haf/trunk/osso-application-installer: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
