Merge lp:~nomad-p/midori/fix-bug1182603 into lp:midori

Proposed by Stephan Haller
Status: Merged
Approved by: André Stösel
Approved revision: 6190
Merged at revision: 6211
Proposed branch: lp:~nomad-p/midori/fix-bug1182603
Merge into: lp:midori
Diff against target: 162 lines (+80/-55)
1 file modified
extensions/toolbar-editor.c (+80/-55)
To merge this branch: bzr merge lp:~nomad-p/midori/fix-bug1182603
Reviewer Review Type Date Requested Status
André Stösel Approve
Review via email: mp+166957@code.launchpad.net

Commit message

Do not run toolbar editor's GtkDialog in its own main loop by prevent calling gtk_dialog_run(). Instead just set the GtkDialog modal and show it.

Description of the change

Fixes bug #1182603:
midori becomes inresponsive when cookie bar pops up whilewhile the toolbar editor is open

To post a comment you must log in.
Revision history for this message
André Stösel (ivaldi) wrote :

Works fine now, thank you!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'extensions/toolbar-editor.c'
2--- extensions/toolbar-editor.c 2013-03-26 08:01:24 +0000
3+++ extensions/toolbar-editor.c 2013-06-02 02:34:25 +0000
4@@ -32,6 +32,12 @@
5 MidoriBrowser *browser;
6 } TBEditorWidget;
7
8+typedef struct
9+{
10+ GSList *used_items, *all_items;
11+ TBEditorWidget *tbw;
12+} TBEditorWindow;
13+
14 enum
15 {
16 TB_EDITOR_COL_ACTION,
17@@ -40,6 +46,8 @@
18 TB_EDITOR_COLS_MAX
19 };
20
21+static TBEditorWindow *tbe_window=NULL;
22+
23 static const GtkTargetEntry tb_editor_dnd_targets[] =
24 {
25 { "MIDORI_TB_EDITOR_ROW", 0, 0 }
26@@ -514,64 +522,81 @@
27 return tbw;
28 }
29
30+static void tb_editor_response_cb(GtkWidget* inDialog,
31+ gint inResponse,
32+ gpointer inUserData)
33+{
34+ gtk_widget_destroy(tbe_window->tbw->dialog);
35+
36+ g_slist_foreach(tbe_window->used_items, (GFunc) g_free, NULL);
37+ g_slist_foreach(tbe_window->all_items, (GFunc) g_free, NULL);
38+ g_slist_free(tbe_window->used_items);
39+ g_slist_free(tbe_window->all_items);
40+ tb_editor_free_path(tbe_window->tbw);
41+ g_free(tbe_window->tbw);
42+
43+ g_free(tbe_window);
44+ tbe_window=NULL;
45+}
46
47 static void tb_editor_menu_configure_toolbar_activate_cb(GtkWidget *menuitem, MidoriBrowser *browser)
48 {
49- GSList *node, *used_items, *all_items;
50- GtkTreeIter iter;
51- GtkTreePath *path;
52- TBEditorWidget *tbw;
53-
54- /* read the current active toolbar items */
55- used_items = tb_editor_parse_active_items(browser);
56-
57- /* get all available actions */
58- all_items = tb_editor_get_available_actions(browser);
59-
60- /* create the GUI */
61- tbw = tb_editor_create_dialog(browser);
62-
63- /* cache some pointers, this is safe enough since the dialog is run modally */
64- tbw->action_group = midori_browser_get_action_group(browser);
65- tbw->browser = browser;
66-
67- /* fill the stores */
68- for (node = all_items; node != NULL; node = node->next)
69- {
70- if (strcmp(node->data, "Separator") == 0 ||
71- g_slist_find_custom(used_items, node->data, (GCompareFunc) strcmp) == NULL)
72- {
73- gtk_list_store_append(tbw->store_available, &iter);
74- tb_editor_set_item_values(tbw, node->data, tbw->store_available, &iter);
75- }
76- }
77- for (node = used_items; node != NULL; node = node->next)
78- {
79- gtk_list_store_append(tbw->store_used, &iter);
80- tb_editor_set_item_values(tbw, node->data, tbw->store_used, &iter);
81- }
82- /* select first item */
83- path = gtk_tree_path_new_from_string("0");
84- gtk_tree_selection_select_path(gtk_tree_view_get_selection(tbw->tree_used), path);
85- gtk_tree_path_free(path);
86-
87- /* connect the changed signals after populating the store */
88- g_signal_connect(tbw->store_used, "row-changed",
89- G_CALLBACK(tb_editor_available_items_changed_cb), tbw);
90- g_signal_connect(tbw->store_used, "row-deleted",
91- G_CALLBACK(tb_editor_available_items_deleted_cb), tbw);
92-
93- /* run it */
94- gtk_dialog_run(GTK_DIALOG(tbw->dialog));
95-
96- gtk_widget_destroy(tbw->dialog);
97-
98- g_slist_foreach(used_items, (GFunc) g_free, NULL);
99- g_slist_foreach(all_items, (GFunc) g_free, NULL);
100- g_slist_free(used_items);
101- g_slist_free(all_items);
102- tb_editor_free_path(tbw);
103- g_free(tbw);
104+ /* create toolbar-editor window if not available */
105+ if(tbe_window==NULL)
106+ {
107+ GSList *node;
108+ GtkTreeIter iter;
109+ GtkTreePath *path;
110+
111+ /* create storage for window data */
112+ tbe_window=g_new0(TBEditorWindow, 1);
113+
114+ /* read the current active toolbar items */
115+ tbe_window->used_items = tb_editor_parse_active_items(browser);
116+
117+ /* get all available actions */
118+ tbe_window->all_items = tb_editor_get_available_actions(browser);
119+
120+ /* create the GUI */
121+ tbe_window->tbw = tb_editor_create_dialog(browser);
122+
123+ /* cache some pointers, this is safe enough since the dialog is run modally */
124+ tbe_window->tbw->action_group = midori_browser_get_action_group(browser);
125+ tbe_window->tbw->browser = browser;
126+
127+ /* fill the stores */
128+ for (node = tbe_window->all_items; node != NULL; node = node->next)
129+ {
130+ if (strcmp(node->data, "Separator") == 0 ||
131+ g_slist_find_custom(tbe_window->used_items, node->data, (GCompareFunc) strcmp) == NULL)
132+ {
133+ gtk_list_store_append(tbe_window->tbw->store_available, &iter);
134+ tb_editor_set_item_values(tbe_window->tbw, node->data, tbe_window->tbw->store_available, &iter);
135+ }
136+ }
137+ for (node = tbe_window->used_items; node != NULL; node = node->next)
138+ {
139+ gtk_list_store_append(tbe_window->tbw->store_used, &iter);
140+ tb_editor_set_item_values(tbe_window->tbw, node->data, tbe_window->tbw->store_used, &iter);
141+ }
142+ /* select first item */
143+ path = gtk_tree_path_new_from_string("0");
144+ gtk_tree_selection_select_path(gtk_tree_view_get_selection(tbe_window->tbw->tree_used), path);
145+ gtk_tree_path_free(path);
146+
147+ /* connect the changed signals after populating the store */
148+ g_signal_connect(tbe_window->tbw->store_used, "row-changed",
149+ G_CALLBACK(tb_editor_available_items_changed_cb), tbe_window->tbw);
150+ g_signal_connect(tbe_window->tbw->store_used, "row-deleted",
151+ G_CALLBACK(tb_editor_available_items_deleted_cb), tbe_window->tbw);
152+
153+ /* connect signal for detecting window close */
154+ g_signal_connect(tbe_window->tbw->dialog, "response", G_CALLBACK (tb_editor_response_cb), NULL);
155+ }
156+
157+ /* show dialog and make it modal */
158+ gtk_window_set_modal(GTK_WINDOW(tbe_window->tbw->dialog), TRUE);
159+ gtk_widget_show_all(tbe_window->tbw->dialog);
160 }
161
162 static void tb_editor_browser_populate_toolbar_menu_cb(MidoriBrowser *browser, GtkWidget *menu,

Subscribers

People subscribed via source and target branches

to all changes: