[nautilus] search-popover: Stop using blocking dialog functions
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] search-popover: Stop using blocking dialog functions
- Date: Tue, 7 Dec 2021 02:08:29 +0000 (UTC)
commit e295cac225f167ce020f1b2e97519d76d085c5c2
Author: Matthew Jakeman <mjakeman26 outlook co nz>
Date: Tue Dec 7 00:38:07 2021 +1300
search-popover: Stop using blocking dialog functions
Replaces usage of gtk_dialog_run() with the "response" signal in
preparation for GTK 4 port.
Part of #1992
src/nautilus-search-popover.c | 58 +++++++++++++++++++++++++++----------------
1 file changed, 37 insertions(+), 21 deletions(-)
---
diff --git a/src/nautilus-search-popover.c b/src/nautilus-search-popover.c
index c8d6a5b6b..48d248191 100644
--- a/src/nautilus-search-popover.c
+++ b/src/nautilus-search-popover.c
@@ -51,6 +51,7 @@ struct _NautilusSearchPopover
GtkWidget *filename_search_button;
NautilusQuery *query;
+ GtkTreeView *treeview;
gboolean fts_enabled;
};
@@ -544,6 +545,39 @@ show_date_selection_widgets (NautilusSearchPopover *popover,
gtk_revealer_set_reveal_child (GTK_REVEALER (popover->around_revealer), visible);
}
+static void
+on_other_types_dialog_response (GtkDialog *dialog,
+ gint response_id,
+ NautilusSearchPopover *popover)
+{
+ if (response_id == GTK_RESPONSE_OK)
+ {
+ GtkTreeIter iter;
+ GtkTreeSelection *selection;
+ GtkTreeModel *store;
+ char *mimetype;
+ char *description;
+
+ store = gtk_tree_view_get_model (popover->treeview);
+ selection = gtk_tree_view_get_selection (popover->treeview);
+
+ gtk_tree_selection_get_selected (selection, NULL, &iter);
+ gtk_tree_model_get (store, &iter,
+ 0, &description,
+ 1, &mimetype,
+ -1);
+
+ gtk_label_set_label (GTK_LABEL (popover->type_label), description);
+
+ g_signal_emit_by_name (popover, "mime-type", -1, mimetype);
+
+ gtk_stack_set_visible_child_name (GTK_STACK (popover->type_stack), "type-button");
+ }
+
+ g_clear_object (&popover->treeview);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
static void
show_other_types_dialog (NautilusSearchPopover *popover)
{
@@ -607,7 +641,6 @@ show_other_types_dialog (NautilusSearchPopover *popover)
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
-
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("Name",
renderer,
@@ -619,27 +652,10 @@ show_other_types_dialog (NautilusSearchPopover *popover)
gtk_widget_show (treeview);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolled), treeview);
+ popover->treeview = GTK_TREE_VIEW (g_object_ref (treeview));
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
- {
- GtkTreeIter iter;
- char *mimetype;
- char *description;
-
- gtk_tree_selection_get_selected (selection, NULL, &iter);
- gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
- 0, &description,
- 1, &mimetype,
- -1);
-
- gtk_label_set_label (GTK_LABEL (popover->type_label), description);
-
- g_signal_emit_by_name (popover, "mime-type", -1, mimetype);
-
- gtk_stack_set_visible_child_name (GTK_STACK (popover->type_stack), "type-button");
- }
-
- gtk_widget_destroy (dialog);
+ g_signal_connect (dialog, "response", G_CALLBACK (on_other_types_dialog_response), popover);
+ gtk_widget_show_all (dialog);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]