Merge GtkFileChooserWidget and GtkFileChooserDefault

It seems that alternate implementations of GtkFileChooserWidget
never materialized. The split between GtkFileChooserWidget and
GtkFileChooserDefault is awkward. The immediate problem is that
it makes it difficult to document the keybinding signals. So it
makes sense to drop the abstraction and just have one thing.

https://bugzilla.gnome.org/show_bug.cgi?id=723157
This commit is contained in:
William Jon McCann 2014-01-28 04:30:33 -05:00
parent eb0f1c63ba
commit d87ea4776a
11 changed files with 7496 additions and 7713 deletions

View File

@ -469,7 +469,6 @@ gtk_private_h_sources = \
gtkcustompaperunixdialog.h \
gtkdialogprivate.h \
gtkentryprivate.h \
gtkfilechooserdefault.h \
gtkfilechooserembed.h \
gtkfilechooserentry.h \
gtkfilechooserprivate.h \
@ -722,7 +721,6 @@ gtk_base_c_sources = \
gtkexpander.c \
gtkfilechooser.c \
gtkfilechooserbutton.c \
gtkfilechooserdefault.c \
gtkfilechooserdialog.c \
gtkfilechooserembed.c \
gtkfilechooserentry.c \
@ -1119,7 +1117,7 @@ COMPOSITE_TEMPLATES = \
resources/ui/gtkcoloreditor.ui \
resources/ui/gtkdialog.ui \
resources/ui/gtkfilechooserbutton.ui \
resources/ui/gtkfilechooserdefault.ui \
resources/ui/gtkfilechooserwidget.ui \
resources/ui/gtkfilechooserdialog.ui \
resources/ui/gtkfontbutton.ui \
resources/ui/gtkfontchooserdialog.ui \

View File

@ -196,7 +196,7 @@ GtkLabel {
gtk-key-bindings: gtk-mac-alt-arrows, gtk-mac-label;
}
GtkFileChooserDefault {
GtkFileChooserWidget {
gtk-key-bindings: gtk-mac-file-chooser;
}

View File

@ -19,7 +19,7 @@
<file compressed="true">ui/gtkcoloreditor.ui</file>
<file compressed="true">ui/gtkdialog.ui</file>
<file compressed="true">ui/gtkfilechooserbutton.ui</file>
<file compressed="true">ui/gtkfilechooserdefault.ui</file>
<file compressed="true">ui/gtkfilechooserwidget.ui</file>
<file compressed="true">ui/gtkfilechooserdialog.ui</file>
<file compressed="true">ui/gtkfontbutton.ui</file>
<file compressed="true">ui/gtkfontchooserdialog.ui</file>

View File

@ -662,7 +662,7 @@ get_selected_file (GtkFileChooserButton *button)
else if (gtk_file_chooser_get_action (GTK_FILE_CHOOSER (priv->dialog)) == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
{
/* If there is no "real" selection in SELECT_FOLDER mode, then we'll just return
* the current folder, since that is what GtkFileChooserDefault would do.
* the current folder, since that is what GtkFileChooserWidget would do.
*/
if (priv->current_folder_while_inactive)
retval = priv->current_folder_while_inactive;

File diff suppressed because it is too large Load Diff

View File

@ -1,38 +0,0 @@
/* GTK - The GIMP Toolkit
* gtkfilechooserdefault.h: Default implementation of GtkFileChooser
* Copyright (C) 2003, Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_FILE_CHOOSER_DEFAULT_H__
#define __GTK_FILE_CHOOSER_DEFAULT_H__
#include "gtkfilesystem.h"
#include <gtk/gtkwidget.h>
G_BEGIN_DECLS
#define GTK_TYPE_FILE_CHOOSER_DEFAULT (_gtk_file_chooser_default_get_type ())
#define GTK_FILE_CHOOSER_DEFAULT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_CHOOSER_DEFAULT, GtkFileChooserDefault))
#define GTK_IS_FILE_CHOOSER_DEFAULT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_CHOOSER_DEFAULT))
typedef struct _GtkFileChooserDefault GtkFileChooserDefault;
GType _gtk_file_chooser_default_get_type (void) G_GNUC_CONST;
GtkWidget *_gtk_file_chooser_default_new (void);
G_END_DECLS
#endif /* __GTK_FILE_CHOOSER_DEFAULT_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -126,7 +126,7 @@ binding "gtk-mac-file-chooser"
bind "<meta>Up" { "up-folder" () }
}
class "GtkFileChooserDefault" binding "gtk-mac-file-chooser"
class "GtkFileChooserWidget" binding "gtk-mac-file-chooser"
binding "gtk-mac-tree-view"

View File

@ -7,7 +7,7 @@
<property name="can_focus">False</property>
<property name="icon_name">gtk-edit</property>
</object>
<template class="GtkFileChooserDefault" parent="GtkBox">
<template class="GtkFileChooserWidget" parent="GtkBox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>

View File

@ -1891,14 +1891,13 @@ has_action (const GtkFileChooserAction *actions,
return FALSE;
}
static GtkFileChooserDefault *
get_impl_from_dialog (GtkWidget *dialog)
static GtkFileChooserWidgetPrivate *
get_widget_priv_from_dialog (GtkWidget *dialog)
{
GtkFileChooserDialog *d;
GtkFileChooserDialogPrivate *dialog_priv;
GtkFileChooserWidget *chooser_widget;
GtkFileChooserWidgetPrivate *widget_priv;
GtkFileChooserDefault *impl;
d = GTK_FILE_CHOOSER_DIALOG (dialog);
dialog_priv = d->priv;
@ -1907,59 +1906,56 @@ get_impl_from_dialog (GtkWidget *dialog)
g_error ("BUG: dialog_priv->widget is not a GtkFileChooserWidget");
widget_priv = chooser_widget->priv;
impl = (GtkFileChooserDefault *) (widget_priv->impl);
if (!impl)
g_error ("BUG: widget_priv->impl is not a GtkFileChooserDefault");
return impl;
return widget_priv;
}
static gboolean
test_widgets_for_current_action (GtkFileChooserDialog *dialog,
GtkFileChooserAction expected_action)
{
GtkFileChooserDefault *impl;
GtkFileChooserWidgetPrivate *priv;
gboolean passed;
if (gtk_file_chooser_get_action (GTK_FILE_CHOOSER (dialog)) != expected_action)
return FALSE;
impl = get_impl_from_dialog (GTK_WIDGET (dialog));
priv = get_widget_priv_from_dialog (GTK_WIDGET (dialog));
g_assert (impl->action == expected_action);
g_assert (priv->action == expected_action);
passed = TRUE;
/* OPEN implies that the "new folder" button is hidden; otherwise it is shown */
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN)
passed = passed && !gtk_widget_get_visible (impl->browse_new_folder_button);
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN)
passed = passed && !gtk_widget_get_visible (priv->browse_new_folder_button);
else
passed = passed && gtk_widget_get_visible (impl->browse_new_folder_button);
passed = passed && gtk_widget_get_visible (priv->browse_new_folder_button);
/* Check that the widgets are present/visible or not */
if (has_action (open_actions, G_N_ELEMENTS (open_actions), impl->action))
if (has_action (open_actions, G_N_ELEMENTS (open_actions), priv->action))
{
passed = passed && (impl->save_widgets == NULL
&& (impl->location_mode == LOCATION_MODE_PATH_BAR
? impl->location_entry == NULL
: impl->location_entry != NULL)
&& impl->save_folder_label == NULL
&& impl->save_folder_combo == NULL
&& impl->save_expander == NULL
&& GTK_IS_CONTAINER (impl->browse_widgets) && gtk_widget_is_drawable (impl->browse_widgets));
passed = passed && (priv->save_widgets == NULL
&& (priv->location_mode == LOCATION_MODE_PATH_BAR
? priv->location_entry == NULL
: priv->location_entry != NULL)
&& priv->save_folder_label == NULL
&& priv->save_folder_combo == NULL
&& priv->save_expander == NULL
&& GTK_IS_CONTAINER (priv->browse_widgets) && gtk_widget_is_drawable (priv->browse_widgets));
}
else if (has_action (save_actions, G_N_ELEMENTS (save_actions), impl->action))
else if (has_action (save_actions, G_N_ELEMENTS (save_actions), priv->action))
{
/* FIXME: we can't use GTK_IS_FILE_CHOOSER_ENTRY() because it uses
* _gtk_file_chooser_entry_get_type(), which is a non-exported symbol.
* So, we just test impl->location_entry for being non-NULL
* So, we just test priv->location_entry for being non-NULL
*/
passed = passed && (GTK_IS_CONTAINER (impl->save_widgets) && gtk_widget_is_drawable (impl->save_widgets)
&& impl->location_entry != NULL && gtk_widget_is_drawable (impl->location_entry)
&& GTK_IS_LABEL (impl->save_folder_label) && gtk_widget_is_drawable (impl->save_folder_label)
&& GTK_IS_COMBO_BOX (impl->save_folder_combo) && gtk_widget_is_drawable (impl->save_folder_combo)
&& GTK_IS_EXPANDER (impl->save_expander) && gtk_widget_is_drawable (impl->save_expander)
&& GTK_IS_CONTAINER (impl->browse_widgets));
passed = passed && (GTK_IS_CONTAINER (priv->save_widgets) && gtk_widget_is_drawable (priv->save_widgets)
&& priv->location_entry != NULL && gtk_widget_is_drawable (priv->location_entry)
&& GTK_IS_LABEL (priv->save_folder_label) && gtk_widget_is_drawable (priv->save_folder_label)
&& GTK_IS_COMBO_BOX (priv->save_folder_combo) && gtk_widget_is_drawable (priv->save_folder_combo)
&& GTK_IS_EXPANDER (priv->save_expander) && gtk_widget_is_drawable (priv->save_expander)
&& GTK_IS_CONTAINER (priv->browse_widgets));
/* FIXME: we are in a SAVE mode; test the visibility and sensitivity of
* the children that change depending on the state of the expander.
@ -1967,7 +1963,7 @@ test_widgets_for_current_action (GtkFileChooserDialog *dialog,
}
else
{
g_error ("BAD TEST: test_widgets_for_current_action() doesn't know about %s", get_action_name (impl->action));
g_error ("BAD TEST: test_widgets_for_current_action() doesn't know about %s", get_action_name (priv->action));
passed = FALSE;
}
@ -2085,7 +2081,7 @@ static gboolean
test_reload_sequence (gboolean set_folder_before_map)
{
GtkWidget *dialog;
GtkFileChooserDefault *impl;
GtkFileChooserWidgetPrivate *priv;
gboolean passed;
char *folder;
char *current_working_dir;
@ -2102,7 +2098,7 @@ test_reload_sequence (gboolean set_folder_before_map)
_("_OK"),
GTK_RESPONSE_ACCEPT,
NULL);
impl = get_impl_from_dialog (dialog);
priv = get_widget_priv_from_dialog (dialog);
if (set_folder_before_map)
{
@ -2110,13 +2106,13 @@ test_reload_sequence (gboolean set_folder_before_map)
wait_for_idle ();
passed = passed && (impl->current_folder != NULL
&& impl->browse_files_model != NULL
&& (impl->load_state == LOAD_PRELOAD || impl->load_state == LOAD_LOADING || impl->load_state == LOAD_FINISHED)
&& impl->reload_state == RELOAD_HAS_FOLDER
&& (impl->load_state == LOAD_PRELOAD ? (impl->load_timeout_id != 0) : TRUE)
&& ((impl->load_state == LOAD_LOADING || impl->load_state == LOAD_FINISHED)
? (impl->load_timeout_id == 0 && impl->sort_model != NULL)
passed = passed && (priv->current_folder != NULL
&& priv->browse_files_model != NULL
&& (priv->load_state == LOAD_PRELOAD || priv->load_state == LOAD_LOADING || priv->load_state == LOAD_FINISHED)
&& priv->reload_state == RELOAD_HAS_FOLDER
&& (priv->load_state == LOAD_PRELOAD ? (priv->load_timeout_id != 0) : TRUE)
&& ((priv->load_state == LOAD_LOADING || priv->load_state == LOAD_FINISHED)
? (priv->load_timeout_id == 0 && priv->sort_model != NULL)
: TRUE));
wait_for_idle ();
@ -2128,12 +2124,12 @@ test_reload_sequence (gboolean set_folder_before_map)
else
{
/* Initially, no folder is not loaded or pending */
passed = passed && (impl->current_folder == NULL
&& impl->sort_model == NULL
&& impl->browse_files_model == NULL
&& impl->load_state == LOAD_EMPTY
&& impl->reload_state == RELOAD_EMPTY
&& impl->load_timeout_id == 0);
passed = passed && (priv->current_folder == NULL
&& priv->sort_model == NULL
&& priv->browse_files_model == NULL
&& priv->load_state == LOAD_EMPTY
&& priv->reload_state == RELOAD_EMPTY
&& priv->load_timeout_id == 0);
wait_for_idle ();
@ -2149,13 +2145,13 @@ test_reload_sequence (gboolean set_folder_before_map)
wait_for_idle ();
passed = passed && (impl->current_folder != NULL
&& impl->browse_files_model != NULL
&& (impl->load_state == LOAD_PRELOAD || impl->load_state == LOAD_LOADING || impl->load_state == LOAD_FINISHED)
&& impl->reload_state == RELOAD_HAS_FOLDER
&& (impl->load_state == LOAD_PRELOAD ? (impl->load_timeout_id != 0) : TRUE)
&& ((impl->load_state == LOAD_LOADING || impl->load_state == LOAD_FINISHED)
? (impl->load_timeout_id == 0 && impl->sort_model != NULL)
passed = passed && (priv->current_folder != NULL
&& priv->browse_files_model != NULL
&& (priv->load_state == LOAD_PRELOAD || priv->load_state == LOAD_LOADING || priv->load_state == LOAD_FINISHED)
&& priv->reload_state == RELOAD_HAS_FOLDER
&& (priv->load_state == LOAD_PRELOAD ? (priv->load_timeout_id != 0) : TRUE)
&& ((priv->load_state == LOAD_LOADING || priv->load_state == LOAD_FINISHED)
? (priv->load_timeout_id == 0 && priv->sort_model != NULL)
: TRUE));
folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
@ -2174,12 +2170,12 @@ test_reload_sequence (gboolean set_folder_before_map)
wait_for_idle ();
passed = passed && (impl->current_folder != NULL
&& impl->browse_files_model != NULL
&& (impl->load_state == LOAD_PRELOAD || impl->load_state == LOAD_LOADING || impl->load_state == LOAD_FINISHED)
&& (impl->load_state == LOAD_PRELOAD ? (impl->load_timeout_id != 0) : TRUE)
&& ((impl->load_state == LOAD_LOADING || impl->load_state == LOAD_FINISHED)
? (impl->load_timeout_id == 0 && impl->sort_model != NULL)
passed = passed && (priv->current_folder != NULL
&& priv->browse_files_model != NULL
&& (priv->load_state == LOAD_PRELOAD || priv->load_state == LOAD_LOADING || priv->load_state == LOAD_FINISHED)
&& (priv->load_state == LOAD_PRELOAD ? (priv->load_timeout_id != 0) : TRUE)
&& ((priv->load_state == LOAD_LOADING || priv->load_state == LOAD_FINISHED)
? (priv->load_timeout_id == 0 && priv->sort_model != NULL)
: TRUE));
folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
@ -2198,13 +2194,13 @@ test_reload_sequence (gboolean set_folder_before_map)
wait_for_idle ();
passed = passed && (impl->current_folder != NULL
&& impl->browse_files_model != NULL
&& (impl->load_state == LOAD_PRELOAD || impl->load_state == LOAD_LOADING || impl->load_state == LOAD_FINISHED)
&& impl->reload_state == RELOAD_HAS_FOLDER
&& (impl->load_state == LOAD_PRELOAD ? (impl->load_timeout_id != 0) : TRUE)
&& ((impl->load_state == LOAD_LOADING || impl->load_state == LOAD_FINISHED)
? (impl->load_timeout_id == 0 && impl->sort_model != NULL)
passed = passed && (priv->current_folder != NULL
&& priv->browse_files_model != NULL
&& (priv->load_state == LOAD_PRELOAD || priv->load_state == LOAD_LOADING || priv->load_state == LOAD_FINISHED)
&& priv->reload_state == RELOAD_HAS_FOLDER
&& (priv->load_state == LOAD_PRELOAD ? (priv->load_timeout_id != 0) : TRUE)
&& ((priv->load_state == LOAD_LOADING || priv->load_state == LOAD_FINISHED)
? (priv->load_timeout_id == 0 && priv->sort_model != NULL)
: TRUE));
folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
@ -2390,7 +2386,7 @@ test_folder_switch_and_filters (void)
GtkWidget *dialog;
GtkFileFilter *all_filter;
GtkFileFilter *txt_filter;
GtkFileChooserDefault *impl;
GtkFileChooserWidgetPrivate *priv;
passed = TRUE;
@ -2401,7 +2397,7 @@ test_folder_switch_and_filters (void)
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_OK"), GTK_RESPONSE_ACCEPT,
NULL);
impl = get_impl_from_dialog (dialog);
priv = get_widget_priv_from_dialog (dialog);
cwd_file = g_file_new_for_path (cwd);
base_dir_file = g_file_new_for_path (base_dir);
@ -2445,7 +2441,7 @@ test_folder_switch_and_filters (void)
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), base_dir);
sleep_in_main_loop ();
g_signal_emit_by_name (impl->browse_path_bar, "path-clicked",
g_signal_emit_by_name (priv->browse_path_bar, "path-clicked",
cwd_file,
base_dir_file,
FALSE);

View File

@ -211,7 +211,7 @@ test_file_chooser_widget_basic (void)
/* XXX BUG:
*
* Spin the mainloop for a bit, this allows the file operations
* to complete, GtkFileChooserDefault has a bug where it leaks
* to complete, GtkFileChooserWidget has a bug where it leaks
* GtkTreeRowReferences to the internal shortcuts_model
*
* Since we assert all automated children are finalized we