commit d150466fdaa27a3b1a52ff4c1524ce04dd3f5ad5
Author: phantomjinx <[email protected]>
Date: Fri Dec 24 22:16:01 2010 +0000
Fix transient dialogs opening with incorrect parent
* misc.*
* Implement extra version of get_user_string that doesn't assume gtkpod_app
as the parent of dialogs.
* coverweb_preferences.c
* Specify correct parent of bookmarks dialog
* track_display_preferences.c
* Fix correct parent of notebook, which will be a GtkWindow not a GDKWinow
* ignore word clicked doesn't add if work is empty or if word already
exists
* Specify correct parent of ign_word using get_user_string_with_parent
libgtkpod/misc.c | 37 ++++++++++++++++-----
libgtkpod/misc.h | 4 +-
plugins/coverweb/coverweb_preferences.c | 10 +++++-
plugins/track_display/track_display_preferences.c | 28 ++++++++++++++-
4 files changed, 65 insertions(+), 14 deletions(-)
---
diff --git a/libgtkpod/misc.c b/libgtkpod/misc.c
index b322424..1c6ef9e 100644
--- a/libgtkpod/misc.c
+++ b/libgtkpod/misc.c
@@ -1701,15 +1701,34 @@ gboolean get_offline(iTunesDB *itdb) {
return eitdb->offline;
}
-/* Retrieves a string (and option) from the user using a dialog.
- @title: title of the dialogue (may be NULL)
- @message: text (question) to be displayed (may be NULL)
- @dflt: default string to be returned (may be NULL)
- @opt_msg: message for the option checkbox (or NULL)
- @opt_state: original state of the checkbox. Will be updated
- return value: the string entered by the user or NULL if the dialog
- was cancelled. */
+/*
+ * Retrieves a string (and option) from the user using a dialog.
+ *
+ * @title: title of the dialogue (may be NULL)
+ * @message: text (question) to be displayed (may be NULL)
+ * @dflt: default string to be returned (may be NULL)
+ * @opt_msg: message for the option checkbox (or NULL)
+ * @opt_state: original state of the checkbox. Will be updated
+ * return value: the string entered by the user or NULL if the dialog
+ * was cancelled.
+ */
gchar *get_user_string(gchar *title, gchar *message, gchar *dflt, gchar
*opt_msg, gboolean *opt_state, const gchar *accept_button) {
+ return get_user_string_with_parent(GTK_WINDOW(gtkpod_app), title, message,
dflt, opt_msg, opt_state, accept_button);
+}
+
+/*
+ * Retrieves a string (and option) from the user using a dialog.
+ *
+ * @parent: parent window for the dialog
+ * @title: title of the dialogue (may be NULL)
+ * @message: text (question) to be displayed (may be NULL)
+ * @dflt: default string to be returned (may be NULL)
+ * @opt_msg: message for the option checkbox (or NULL)
+ * @opt_state: original state of the checkbox. Will be updated
+ * return value: the string entered by the user or NULL if the dialog
+ * was cancelled.
+ */
+gchar *get_user_string_with_parent(GtkWindow *parent, gchar *title, gchar
*message, gchar *dflt, gchar *opt_msg, gboolean *opt_state, const gchar
*accept_button) {
GladeXML *xml = gtkpod_xml_new(gtkpod_get_glade_xml(), "input_box");
GtkWidget *dialog = gtkpod_xml_get_widget(xml, "input_box");
GtkWidget *label = gtkpod_xml_get_widget(xml, "input_box_label");
@@ -1741,7 +1760,7 @@ gchar *get_user_string(gchar *title, gchar *message,
gchar *dflt, gchar *opt_msg
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (checkb), *opt_state);
}
- gtk_window_set_transient_for(GTK_WINDOW (dialog), GTK_WINDOW (gtkpod_app));
+ gtk_window_set_transient_for(GTK_WINDOW (dialog), parent);
response = gtk_dialog_run(GTK_DIALOG (dialog));
if (response == GTK_RESPONSE_OK) {
diff --git a/libgtkpod/misc.h b/libgtkpod/misc.h
index d671fe5..d2a9078 100644
--- a/libgtkpod/misc.h
+++ b/libgtkpod/misc.h
@@ -75,8 +75,8 @@ extern gboolean widgets_blocked;
gchar *utf8_strcasestr (const gchar *haystack, const gchar *needle);
-gchar *get_user_string (gchar *title, gchar *message, gchar *dflt,
- gchar *opt_msg, gboolean *opt_state, const gchar
*accept_button);
+gchar *get_user_string_with_parent (GtkWindow *parent, gchar *title, gchar
*message, gchar *dflt, gchar *opt_msg, gboolean *opt_state, const gchar
*accept_button);
+gchar *get_user_string (gchar *title, gchar *message, gchar *dflt, gchar
*opt_msg, gboolean *opt_state, const gchar *accept_button);
Playlist *add_new_pl_user_name (iTunesDB *itdb, gchar *dflt, gint32 pos);
void add_new_pl_or_spl_user_name (iTunesDB *itdb, gchar *dflt, gint32 pos);
void create_add_files_fileselector (void);
diff --git a/plugins/coverweb/coverweb_preferences.c
b/plugins/coverweb/coverweb_preferences.c
index ba3897c..c0a1369 100644
--- a/plugins/coverweb/coverweb_preferences.c
+++ b/plugins/coverweb/coverweb_preferences.c
@@ -118,6 +118,14 @@ static void save_bookmarks_preferences() {
update_bookmark_menu();
}
+static GtkWindow *bookmarks_view_get_parent_window() {
+ if (! bookmarks_view) {
+ return NULL;
+ }
+
+ return GTK_WINDOW(gtk_widget_get_toplevel(bookmarks_view));
+}
+
/*
glade callback
*/
@@ -131,7 +139,7 @@ G_MODULE_EXPORT void on_bookmark_add_clicked (GtkButton
*sender, gpointer e)
GtkTreeIter iter;
bookmark
- = get_user_string(_("Bookmark Url"), _("Please enter the full
url of the bookmark"), NULL, NULL, NULL, GTK_STOCK_ADD);
+ =
get_user_string_with_parent(bookmarks_view_get_parent_window(), _("Bookmark
Url"), _("Please enter the full url of the bookmark"), NULL, NULL, NULL,
GTK_STOCK_ADD);
if (!bookmark)
return;
diff --git a/plugins/track_display/track_display_preferences.c
b/plugins/track_display/track_display_preferences.c
index 19cc9b7..8b39109 100644
--- a/plugins/track_display/track_display_preferences.c
+++ b/plugins/track_display/track_display_preferences.c
@@ -49,7 +49,7 @@ static GtkWindow *notebook_get_parent_window() {
return NULL;
}
- return GTK_WINDOW(gtk_widget_get_parent(notebook));
+ return GTK_WINDOW(gtk_widget_get_toplevel(notebook));
}
static gint column_tree_sort (GtkTreeModel *model,
@@ -226,16 +226,40 @@ void on_ign_field_toggled (GtkToggleButton *togglebutton,
gpointer data) {
/*
glade callback
*/
+
G_MODULE_EXPORT void on_ign_word_add_clicked (GtkButton *sender, gpointer e) {
g_return_if_fail(ign_words_view);
GtkTreeModel *model;
GtkTreeIter iter;
+ gboolean valid_iter;
- gchar *word = get_user_string(_("New Word to Ignore"), _("Please enter a
word for sorting functions to ignore"), NULL, NULL, NULL, GTK_STOCK_ADD);
+ gchar *word = get_user_string_with_parent(notebook_get_parent_window(),
_("New Word to Ignore"), _("Please enter a word for sorting functions to
ignore"), NULL, NULL, NULL, GTK_STOCK_ADD);
if (! word)
return;
+ if (strlen(word) == 0)
+ return;
+
model = gtk_tree_view_get_model (GTK_TREE_VIEW(ign_words_view));
+
+ /* Check if the value is already in the list store */
+ valid_iter = gtk_tree_model_get_iter_first (model, &iter);
+ while (valid_iter) {
+ gchar *curr_ign;
+ gint comparison;
+ gtk_tree_model_get (model, &iter, 0, &curr_ign, -1);
+
+ comparison = compare_string_case_insensitive(word, curr_ign);
+ g_free (curr_ign);
+ if (comparison == 0) {
+ gtkpod_statusbar_message("The word %s is already in the \"Ignored
Frequent Word\" list", word);
+ return;
+ }
+
+ valid_iter = gtk_tree_model_iter_next (model, &iter);
+ }
+
+
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set(GTK_LIST_STORE (model), &iter, 0, word, -1);
apply_ign_strings();
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2