Add gtk_native_dialog_destroy()
Its very easy to get extra references to the NativeDialog so that when you release your last reference any visible dialog is not hidden. We handle this by adding a destroy method similar to how you destroy regular toplevels.
This commit is contained in:
parent
402225a8e2
commit
51dc4873fd
@ -113,6 +113,7 @@ open_response_cb (GtkNativeDialog *dialog,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gtk_native_dialog_destroy (GTK_NATIVE_DIALOG (native));
|
||||||
g_object_unref (native);
|
g_object_unref (native);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2520,6 +2520,7 @@ GTK_TYPE_NATIVE_DIALOG
|
|||||||
GtkNativeDialogClass
|
GtkNativeDialogClass
|
||||||
gtk_native_dialog_show
|
gtk_native_dialog_show
|
||||||
gtk_native_dialog_hide
|
gtk_native_dialog_hide
|
||||||
|
gtk_native_dialog_destroy
|
||||||
gtk_native_dialog_get_visible
|
gtk_native_dialog_get_visible
|
||||||
gtk_native_dialog_set_modal
|
gtk_native_dialog_set_modal
|
||||||
gtk_native_dialog_get_modal
|
gtk_native_dialog_get_modal
|
||||||
|
@ -1008,7 +1008,11 @@ gtk_file_chooser_button_destroy (GtkWidget *widget)
|
|||||||
priv->dialog = NULL;
|
priv->dialog = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (priv->native)
|
||||||
|
{
|
||||||
|
gtk_native_dialog_destroy (GTK_NATIVE_DIALOG (priv->native));
|
||||||
g_clear_object (&priv->native);
|
g_clear_object (&priv->native);
|
||||||
|
}
|
||||||
|
|
||||||
priv->chooser = NULL;
|
priv->chooser = NULL;
|
||||||
|
|
||||||
|
@ -361,6 +361,30 @@ gtk_native_dialog_hide (GtkNativeDialog *self)
|
|||||||
g_object_notify_by_pspec (G_OBJECT (self), native_props[PROP_VISIBLE]);
|
g_object_notify_by_pspec (G_OBJECT (self), native_props[PROP_VISIBLE]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_native_dialog_destroy:
|
||||||
|
* @self: a #GtkNativeDialog
|
||||||
|
*
|
||||||
|
* Destroys a dialog.
|
||||||
|
*
|
||||||
|
* When a dialog is destroyed, it will break any references it holds
|
||||||
|
* to other objects. If it is visible it will be hidden and any underlying
|
||||||
|
* window system resources will be destroyed.
|
||||||
|
*
|
||||||
|
* Note that this does not release any reference to the object (as opposed to
|
||||||
|
* destroying a GtkWindow) because there is no reference from the windowing
|
||||||
|
* system to the #GtkNativeDialog.
|
||||||
|
*
|
||||||
|
* Since: 3.20
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gtk_native_dialog_destroy (GtkNativeDialog *self)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GTK_IS_NATIVE_DIALOG (self));
|
||||||
|
|
||||||
|
g_object_run_dispose (G_OBJECT (self));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_gtk_native_dialog_emit_response (GtkNativeDialog *self,
|
_gtk_native_dialog_emit_response (GtkNativeDialog *self,
|
||||||
int response_id)
|
int response_id)
|
||||||
|
@ -54,6 +54,8 @@ void gtk_native_dialog_show (GtkNativeDialog *self);
|
|||||||
GDK_AVAILABLE_IN_3_20
|
GDK_AVAILABLE_IN_3_20
|
||||||
void gtk_native_dialog_hide (GtkNativeDialog *self);
|
void gtk_native_dialog_hide (GtkNativeDialog *self);
|
||||||
GDK_AVAILABLE_IN_3_20
|
GDK_AVAILABLE_IN_3_20
|
||||||
|
void gtk_native_dialog_destroy (GtkNativeDialog *self);
|
||||||
|
GDK_AVAILABLE_IN_3_20
|
||||||
gboolean gtk_native_dialog_get_visible (GtkNativeDialog *self);
|
gboolean gtk_native_dialog_get_visible (GtkNativeDialog *self);
|
||||||
GDK_AVAILABLE_IN_3_20
|
GDK_AVAILABLE_IN_3_20
|
||||||
void gtk_native_dialog_set_modal (GtkNativeDialog *self,
|
void gtk_native_dialog_set_modal (GtkNativeDialog *self,
|
||||||
|
@ -9660,6 +9660,13 @@ native_filter_changed (GtkWidget *combo,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
destroy_native (GtkFileChooserNative *native)
|
||||||
|
{
|
||||||
|
gtk_native_dialog_destroy (GTK_NATIVE_DIALOG (native));
|
||||||
|
g_object_unref (native);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
create_native_dialogs (GtkWidget *widget)
|
create_native_dialogs (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
@ -9681,7 +9688,7 @@ create_native_dialogs (GtkWidget *widget)
|
|||||||
"_accept&native",
|
"_accept&native",
|
||||||
"_cancel__native");
|
"_cancel__native");
|
||||||
|
|
||||||
g_signal_connect_swapped (G_OBJECT (window), "destroy", G_CALLBACK (g_object_unref), native);
|
g_signal_connect_swapped (G_OBJECT (window), "destroy", G_CALLBACK (destroy_native), native);
|
||||||
|
|
||||||
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (native),
|
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (native),
|
||||||
g_get_current_dir (),
|
g_get_current_dir (),
|
||||||
|
Loading…
Reference in New Issue
Block a user