mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 02:40:11 +00:00
filechooser: Drop the ::selection-changed signal
This signal does not work on native file choosers, and it exposes internals of the widget that should not be public. And it is just not very interesting.
This commit is contained in:
parent
e31bacf7be
commit
2746a2d929
@ -79,29 +79,6 @@ G_DEFINE_INTERFACE (GtkFileChooser, gtk_file_chooser, G_TYPE_OBJECT);
|
||||
static void
|
||||
gtk_file_chooser_default_init (GtkFileChooserInterface *iface)
|
||||
{
|
||||
GType iface_type = G_TYPE_FROM_INTERFACE (iface);
|
||||
|
||||
/**
|
||||
* GtkFileChooser::selection-changed:
|
||||
* @chooser: the object which received the signal.
|
||||
*
|
||||
* This signal is emitted when there is a change in the set of selected files
|
||||
* in a #GtkFileChooser. This can happen when the user modifies the selection
|
||||
* with the mouse or the keyboard, or when explicitly calling functions to
|
||||
* change the selection.
|
||||
*
|
||||
* Normally you do not need to connect to this signal, as it is easier to wait
|
||||
* for the file chooser to finish running, and then to get the list of
|
||||
* selected files using the functions mentioned below.
|
||||
*/
|
||||
g_signal_new (I_("selection-changed"),
|
||||
iface_type,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkFileChooserIface, selection_changed),
|
||||
NULL, NULL,
|
||||
NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
g_object_interface_install_property (iface,
|
||||
g_param_spec_enum ("action",
|
||||
P_("Action"),
|
||||
|
@ -627,7 +627,6 @@ emit_selection_changed_if_changing_selection (GtkFileChooserButton *button)
|
||||
if (button->is_changing_selection)
|
||||
{
|
||||
button->is_changing_selection = FALSE;
|
||||
g_signal_emit_by_name (button, "selection-changed");
|
||||
}
|
||||
}
|
||||
|
||||
@ -2516,8 +2515,6 @@ common_response_cb (GtkFileChooserButton *button,
|
||||
response == GTK_RESPONSE_OK)
|
||||
{
|
||||
save_inactive_state (button);
|
||||
|
||||
g_signal_emit_by_name (button, "selection-changed");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -267,8 +267,6 @@ static void gtk_file_chooser_dialog_size_allocate (GtkWidget *wid
|
||||
int baseline);
|
||||
static void file_chooser_widget_response_requested (GtkWidget *widget,
|
||||
GtkFileChooserDialog *dialog);
|
||||
static void file_chooser_widget_selection_changed (GtkWidget *widget,
|
||||
GtkFileChooserDialog *dialog);
|
||||
|
||||
static void response_cb (GtkDialog *dialog,
|
||||
gint response_id);
|
||||
@ -309,7 +307,6 @@ gtk_file_chooser_dialog_class_init (GtkFileChooserDialogClass *class)
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDialog, buttons);
|
||||
gtk_widget_class_bind_template_callback (widget_class, response_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, file_chooser_widget_response_requested);
|
||||
gtk_widget_class_bind_template_callback (widget_class, file_chooser_widget_selection_changed);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -364,26 +361,6 @@ is_accept_response_id (gint response_id)
|
||||
response_id == GTK_RESPONSE_APPLY);
|
||||
}
|
||||
|
||||
static void
|
||||
file_chooser_widget_selection_changed (GtkWidget *widget,
|
||||
GtkFileChooserDialog *dialog)
|
||||
{
|
||||
GtkFileChooserDialogPrivate *priv = gtk_file_chooser_dialog_get_instance_private (dialog);
|
||||
GtkWidget *button;
|
||||
GListModel *files;
|
||||
gboolean sensitive;
|
||||
|
||||
button = get_accept_action_widget (GTK_DIALOG (dialog), FALSE);
|
||||
if (button == NULL)
|
||||
return;
|
||||
|
||||
files = gtk_file_chooser_get_files (GTK_FILE_CHOOSER (priv->widget));
|
||||
sensitive = (g_list_model_get_n_items (files) > 0);
|
||||
gtk_widget_set_sensitive (button, sensitive);
|
||||
|
||||
g_object_unref (files);
|
||||
}
|
||||
|
||||
static void
|
||||
file_chooser_widget_response_requested (GtkWidget *widget,
|
||||
GtkFileChooserDialog *dialog)
|
||||
|
@ -158,12 +158,6 @@
|
||||
* possible to use with #GtkFileChooserNative, as such use would
|
||||
* prohibit the use of a native dialog.
|
||||
*
|
||||
* There is no support for the signals that are emitted when the user
|
||||
* navigates in the dialog, including:
|
||||
* * #GtkFileChooser::selection-changed
|
||||
*
|
||||
* If you need any of the above you will have to use #GtkFileChooserDialog directly.
|
||||
*
|
||||
* No operations that change the dialog work while the dialog is visible.
|
||||
* Set all the properties that are required before showing the dialog.
|
||||
*
|
||||
|
@ -56,8 +56,6 @@ static GListModel * delegate_get_shortcut_folders (GtkFileChooser *choose
|
||||
static void delegate_notify (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
gpointer data);
|
||||
static void delegate_selection_changed (GtkFileChooser *chooser,
|
||||
gpointer data);
|
||||
|
||||
static void delegate_add_choice (GtkFileChooser *chooser,
|
||||
const char *id,
|
||||
@ -164,8 +162,6 @@ _gtk_file_chooser_set_delegate (GtkFileChooser *receiver,
|
||||
g_object_set_data (G_OBJECT (receiver), I_("gtk-file-chooser-delegate"), delegate);
|
||||
g_signal_connect (delegate, "notify",
|
||||
G_CALLBACK (delegate_notify), receiver);
|
||||
g_signal_connect (delegate, "selection-changed",
|
||||
G_CALLBACK (delegate_selection_changed), receiver);
|
||||
}
|
||||
|
||||
GQuark
|
||||
@ -307,13 +303,6 @@ delegate_notify (GObject *object,
|
||||
g_object_notify (data, pspec->name);
|
||||
}
|
||||
|
||||
static void
|
||||
delegate_selection_changed (GtkFileChooser *chooser,
|
||||
gpointer data)
|
||||
{
|
||||
g_signal_emit_by_name (data, "selection-changed");
|
||||
}
|
||||
|
||||
GSettings *
|
||||
_gtk_file_chooser_get_settings_for_widget (GtkWidget *widget)
|
||||
{
|
||||
|
@ -2220,14 +2220,66 @@ set_icon_cell_renderer_fixed_size (GtkFileChooserWidget *impl)
|
||||
ypad * 2 + ICON_SIZE);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
get_accept_action_widget (GtkDialog *dialog,
|
||||
gboolean sensitive_only)
|
||||
{
|
||||
gint response[] = {
|
||||
GTK_RESPONSE_ACCEPT,
|
||||
GTK_RESPONSE_OK,
|
||||
GTK_RESPONSE_YES,
|
||||
GTK_RESPONSE_APPLY
|
||||
};
|
||||
gint i;
|
||||
GtkWidget *widget;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (response); i++)
|
||||
{
|
||||
widget = gtk_dialog_get_widget_for_response (dialog, response[i]);
|
||||
if (widget)
|
||||
{
|
||||
if (!sensitive_only)
|
||||
return widget;
|
||||
|
||||
if (gtk_widget_is_sensitive (widget))
|
||||
return widget;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
update_default (GtkFileChooserWidget *impl)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *button;
|
||||
GListModel *files;
|
||||
gboolean sensitive;
|
||||
|
||||
dialog = gtk_widget_get_ancestor (GTK_WIDGET (impl), GTK_TYPE_DIALOG);
|
||||
if (dialog == NULL)
|
||||
return;
|
||||
|
||||
button = get_accept_action_widget (GTK_DIALOG (dialog), FALSE);
|
||||
if (button == NULL)
|
||||
return;
|
||||
|
||||
files = gtk_file_chooser_get_files (GTK_FILE_CHOOSER (impl));
|
||||
sensitive = (g_list_model_get_n_items (files) > 0);
|
||||
gtk_widget_set_sensitive (button, sensitive);
|
||||
|
||||
g_object_unref (files);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
location_changed_timeout_cb (gpointer user_data)
|
||||
{
|
||||
GtkFileChooserWidget *impl = user_data;
|
||||
|
||||
gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (impl));
|
||||
g_signal_emit_by_name (impl, "selection-changed", 0);
|
||||
|
||||
update_default (impl);
|
||||
impl->location_changed_id = 0;
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
@ -5084,7 +5136,7 @@ update_current_folder_get_info_cb (GCancellable *cancellable,
|
||||
|
||||
g_object_notify (G_OBJECT (impl), "subtitle");
|
||||
|
||||
g_signal_emit_by_name (impl, "selection-changed", 0);
|
||||
update_default (impl);
|
||||
|
||||
out:
|
||||
g_object_unref (data->impl);
|
||||
@ -7004,8 +7056,7 @@ list_selection_changed (GtkTreeSelection *selection,
|
||||
update_chooser_entry (impl);
|
||||
|
||||
location_bar_update (impl);
|
||||
|
||||
g_signal_emit_by_name (impl, "selection-changed", 0);
|
||||
update_default (impl);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -21,7 +21,6 @@
|
||||
<property name="hexpand">1</property>
|
||||
<property name="vexpand">1</property>
|
||||
<signal name="response-requested" handler="file_chooser_widget_response_requested" swapped="no"/>
|
||||
<signal name="selection-changed" handler="file_chooser_widget_selection_changed" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
Loading…
Reference in New Issue
Block a user