mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 13:11:13 +00:00
gtk: Remove GtkFileChooserButton
... as discussed in the meeting.
This commit is contained in:
parent
a51f11999a
commit
eb9c204535
@ -142,16 +142,42 @@ load_file (GtkStringList *list,
|
||||
}
|
||||
|
||||
static void
|
||||
file_selected_cb (GtkWidget *button,
|
||||
open_response_cb (GtkWidget *dialog,
|
||||
int response,
|
||||
GtkStringList *stringlist)
|
||||
{
|
||||
GFile *file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (button));
|
||||
gtk_widget_hide (dialog);
|
||||
|
||||
if (file)
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
load_file (stringlist, file);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
static void
|
||||
file_open_cb (GtkWidget *button,
|
||||
GtkStringList *stringlist)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new ("Open file",
|
||||
GTK_WINDOW (gtk_widget_get_root (button)),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Cancel", GTK_RESPONSE_CANCEL,
|
||||
"_Load", GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), stringlist);
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
@ -189,8 +215,8 @@ do_listview_words (GtkWidget *do_widget)
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
|
||||
open_button = gtk_file_chooser_button_new ("_Open", GTK_FILE_CHOOSER_ACTION_OPEN);
|
||||
g_signal_connect (open_button, "file-set", G_CALLBACK (file_selected_cb), stringlist);
|
||||
open_button = gtk_button_new_with_mnemonic ("_Open");
|
||||
g_signal_connect (open_button, "clicked", G_CALLBACK (file_open_cb), stringlist);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), open_button);
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
|
||||
|
@ -13,19 +13,50 @@
|
||||
|
||||
|
||||
static void
|
||||
file_set (GtkFileChooserButton *button,
|
||||
GtkWidget *picture)
|
||||
open_response_cb (GtkWidget *dialog,
|
||||
int response,
|
||||
GtkPicture *picture)
|
||||
{
|
||||
GFile *file;
|
||||
GdkPaintable *paintable;
|
||||
gtk_widget_hide (dialog);
|
||||
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (button));
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
GFile *file;
|
||||
GdkPaintable *paintable;
|
||||
|
||||
paintable = svg_paintable_new (file);
|
||||
gtk_picture_set_paintable (GTK_PICTURE (picture), paintable);
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
paintable = svg_paintable_new (file);
|
||||
gtk_picture_set_paintable (GTK_PICTURE (picture), paintable);
|
||||
g_object_unref (paintable);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
g_object_unref (paintable);
|
||||
g_object_unref (file);
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
static void
|
||||
show_file_open (GtkWidget *button,
|
||||
GtkPicture *picture)
|
||||
{
|
||||
GtkFileFilter *filter;
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new ("Open node file",
|
||||
GTK_WINDOW (gtk_widget_get_root (button)),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Cancel", GTK_RESPONSE_CANCEL,
|
||||
"_Load", GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
|
||||
filter = gtk_file_filter_new ();
|
||||
gtk_file_filter_add_mime_type (filter, "image/svg+xml");
|
||||
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
|
||||
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), picture);
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
static GtkWidget *window;
|
||||
@ -35,7 +66,6 @@ do_paintable_svg (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *header;
|
||||
GtkWidget *picture;
|
||||
GtkFileFilter *filter;
|
||||
GtkWidget *button;
|
||||
GFile *file;
|
||||
GdkPaintable *paintable;
|
||||
@ -49,17 +79,14 @@ do_paintable_svg (GtkWidget *do_widget)
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Paintable — SVG");
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
button = gtk_file_chooser_button_new ("Select an SVG file", GTK_FILE_CHOOSER_ACTION_OPEN);
|
||||
filter = gtk_file_filter_new ();
|
||||
gtk_file_filter_add_mime_type (filter, "image/svg+xml");
|
||||
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (button), filter);
|
||||
button = gtk_button_new_with_mnemonic ("_Open");
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button);
|
||||
|
||||
picture = gtk_picture_new ();
|
||||
gtk_picture_set_can_shrink (GTK_PICTURE (picture), TRUE);
|
||||
gtk_widget_set_size_request (picture, 16, 16);
|
||||
|
||||
g_signal_connect (button, "file-set", G_CALLBACK (file_set), picture);
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (show_file_open), picture);
|
||||
|
||||
gtk_window_set_child (GTK_WINDOW (window), picture);
|
||||
|
||||
|
@ -63,9 +63,6 @@ do_pickers (GtkWidget *do_widget)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
char *dir;
|
||||
GFile *file;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
@ -129,41 +126,6 @@ do_pickers (GtkWidget *do_widget)
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 2, 1, 1);
|
||||
|
||||
picker = gtk_file_chooser_button_new ("Pick a File",
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN);
|
||||
gtk_grid_attach (GTK_GRID (table), picker, 1, 2, 1, 1);
|
||||
|
||||
picker = gtk_file_chooser_button_new ("Pick a File",
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN);
|
||||
|
||||
dir = g_get_current_dir ();
|
||||
file = g_file_new_for_path (dir);
|
||||
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (picker), file, NULL);
|
||||
g_object_unref (file);
|
||||
g_free (dir);
|
||||
|
||||
gtk_file_chooser_add_choice (GTK_FILE_CHOOSER (picker),
|
||||
"choice",
|
||||
"Encoding",
|
||||
(const char *[]) { "option1", "option2", NULL },
|
||||
(const char *[]) { "UTF-8", "Other Encoding", NULL });
|
||||
gtk_file_chooser_set_choice (GTK_FILE_CHOOSER (picker), "choice", "option1");
|
||||
gtk_file_chooser_add_choice (GTK_FILE_CHOOSER (picker),
|
||||
"check",
|
||||
"Read backwards",
|
||||
NULL, NULL);
|
||||
gtk_file_chooser_set_choice (GTK_FILE_CHOOSER (picker), "check", "false");
|
||||
|
||||
gtk_grid_attach (GTK_GRID (table), picker, 2, 2, 1, 1);
|
||||
|
||||
label = gtk_label_new ("Folder:");
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
|
||||
picker = gtk_file_chooser_button_new ("Pick a Folder",
|
||||
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 3, 1, 1);
|
||||
gtk_grid_attach (GTK_GRID (table), picker, 1, 3, 1, 1);
|
||||
|
||||
label = gtk_label_new ("Mail:");
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
|
||||
|
@ -878,9 +878,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
<property name="use-alpha">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFileChooserButton" id="filechooserbutton1"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLinkButton" id="linkbutton1">
|
||||
<property name="label" translatable="yes">link button</property>
|
||||
|
@ -283,7 +283,6 @@
|
||||
<xi:include href="xml/gtkcolorchooserwidget.xml" />
|
||||
<xi:include href="xml/gtkcolorchooserdialog.xml" />
|
||||
<xi:include href="xml/gtkfilechooser.xml" />
|
||||
<xi:include href="xml/gtkfilechooserbutton.xml" />
|
||||
<xi:include href="xml/gtkfilechoosernative.xml" />
|
||||
<xi:include href="xml/gtkfilechooserdialog.xml" />
|
||||
<xi:include href="xml/gtkfilechooserwidget.xml" />
|
||||
|
@ -1339,31 +1339,6 @@ gtk_file_chooser_widget_get_type
|
||||
GtkFileChooserWidgetPrivate
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkfilechooserbutton</FILE>
|
||||
<TITLE>GtkFileChooserButton</TITLE>
|
||||
GtkFileChooserButton
|
||||
gtk_file_chooser_button_new
|
||||
gtk_file_chooser_button_new_with_dialog
|
||||
gtk_file_chooser_button_get_title
|
||||
gtk_file_chooser_button_set_title
|
||||
gtk_file_chooser_button_get_width_chars
|
||||
gtk_file_chooser_button_set_width_chars
|
||||
gtk_file_chooser_button_get_modal
|
||||
gtk_file_chooser_button_set_modal
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_FILE_CHOOSER_BUTTON
|
||||
GTK_IS_FILE_CHOOSER_BUTTON
|
||||
GTK_TYPE_FILE_CHOOSER_BUTTON
|
||||
GTK_FILE_CHOOSER_BUTTON_CLASS
|
||||
GTK_IS_FILE_CHOOSER_BUTTON_CLASS
|
||||
GTK_FILE_CHOOSER_BUTTON_GET_CLASS
|
||||
<SUBSECTION Private>
|
||||
gtk_file_chooser_button_get_type
|
||||
GtkFileChooserButtonPrivate
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkfilefilter</FILE>
|
||||
GtkFileFilter
|
||||
|
@ -87,7 +87,6 @@ gtk_event_controller_motion_get_type
|
||||
gtk_event_controller_scroll_get_type
|
||||
gtk_every_filter_get_type
|
||||
gtk_expander_get_type
|
||||
gtk_file_chooser_button_get_type
|
||||
gtk_file_chooser_dialog_get_type
|
||||
gtk_file_chooser_get_type
|
||||
gtk_file_chooser_native_get_type
|
||||
|
@ -615,51 +615,6 @@ create_font_button (void)
|
||||
return new_widget_info ("font-button", vbox, SMALL);
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
create_file_button (void)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *vbox2;
|
||||
GtkWidget *picker;
|
||||
char *path;
|
||||
GFile *file;
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
|
||||
picker = gtk_file_chooser_button_new ("File Chooser Button",
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN);
|
||||
gtk_widget_set_size_request (picker, 150, -1);
|
||||
gtk_widget_set_halign (picker, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (picker, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (vbox2), picker);
|
||||
gtk_box_append (GTK_BOX (vbox2),
|
||||
gtk_label_new ("File Button (Files)"));
|
||||
|
||||
gtk_box_append (GTK_BOX (vbox),
|
||||
vbox2);
|
||||
gtk_box_append (GTK_BOX (vbox),
|
||||
gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
|
||||
|
||||
vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
|
||||
picker = gtk_file_chooser_button_new ("File Chooser Button",
|
||||
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
|
||||
gtk_widget_set_size_request (picker, 150, -1);
|
||||
path = g_build_filename (g_get_home_dir (), "Documents", NULL);
|
||||
file = g_file_new_for_path (path);
|
||||
gtk_file_chooser_set_file (GTK_FILE_CHOOSER (picker), file, NULL);
|
||||
g_free (path);
|
||||
g_object_unref (file);
|
||||
gtk_widget_set_halign (picker, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (picker, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (vbox2), picker);
|
||||
gtk_box_append (GTK_BOX (vbox2), gtk_label_new ("File Button (Select Folder)"));
|
||||
gtk_box_append (GTK_BOX (vbox), vbox2);
|
||||
|
||||
add_margin (vbox);
|
||||
|
||||
return new_widget_info ("file-button", vbox, MEDIUM);
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
create_editable_label (void)
|
||||
{
|
||||
@ -2144,7 +2099,6 @@ get_all_widgets (void)
|
||||
retval = g_list_prepend (retval, create_combo_box_entry ());
|
||||
retval = g_list_prepend (retval, create_combo_box_text ());
|
||||
retval = g_list_prepend (retval, create_entry ());
|
||||
retval = g_list_prepend (retval, create_file_button ());
|
||||
retval = g_list_prepend (retval, create_font_button ());
|
||||
retval = g_list_prepend (retval, create_frame ());
|
||||
retval = g_list_prepend (retval, create_icon_view ());
|
||||
|
@ -66,7 +66,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkEntry, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkEntryCompletion, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkEventController, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkExpander, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFileChooserButton, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFileChooserDialog, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFileChooserWidget, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFileFilter, g_object_unref)
|
||||
|
@ -119,7 +119,6 @@
|
||||
#include <gtk/gtkfixed.h>
|
||||
#include <gtk/gtkfixedlayout.h>
|
||||
#include <gtk/gtkfilechooser.h>
|
||||
#include <gtk/gtkfilechooserbutton.h>
|
||||
#include <gtk/gtkfilechooserdialog.h>
|
||||
#include <gtk/gtkfilechoosernative.h>
|
||||
#include <gtk/gtkfilechooserwidget.h>
|
||||
|
@ -29,15 +29,14 @@
|
||||
* SECTION:gtkfilechooser
|
||||
* @Short_description: File chooser interface used by GtkFileChooserWidget and GtkFileChooserDialog
|
||||
* @Title: GtkFileChooser
|
||||
* @See_also: #GtkFileChooserDialog, #GtkFileChooserWidget, #GtkFileChooserButton
|
||||
* @See_also: #GtkFileChooserDialog, #GtkFileChooserWidget
|
||||
*
|
||||
* #GtkFileChooser is an interface that can be implemented by file
|
||||
* selection widgets. In GTK, the main objects that implement this
|
||||
* interface are #GtkFileChooserWidget, #GtkFileChooserDialog, and
|
||||
* #GtkFileChooserButton. You do not need to write an object that
|
||||
* implements the #GtkFileChooser interface unless you are trying to
|
||||
* adapt an existing file selector to expose a standard programming
|
||||
* interface.
|
||||
* interface are #GtkFileChooserWidget and #GtkFileChooserDialog. You do not
|
||||
* need to write an object that implements the #GtkFileChooser interface
|
||||
* unless you are trying to adapt an existing file selector to expose a
|
||||
* standard programming interface.
|
||||
*
|
||||
* #GtkFileChooser allows for shortcuts to various places in the filesystem.
|
||||
* In the default implementation these are displayed in the left pane. It
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,62 +0,0 @@
|
||||
/* gtkfilechooserbutton.h
|
||||
*
|
||||
* Copyright (c) 2004 James M. Cape <jcape@ignore-your.tv>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_FILE_CHOOSER_BUTTON_H__
|
||||
#define __GTK_FILE_CHOOSER_BUTTON_H__
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gtk/gtkbox.h>
|
||||
#include <gtk/gtkfilechooser.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_FILE_CHOOSER_BUTTON (gtk_file_chooser_button_get_type ())
|
||||
#define GTK_FILE_CHOOSER_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_CHOOSER_BUTTON, GtkFileChooserButton))
|
||||
#define GTK_IS_FILE_CHOOSER_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_CHOOSER_BUTTON))
|
||||
|
||||
typedef struct _GtkFileChooserButton GtkFileChooserButton;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_file_chooser_button_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget * gtk_file_chooser_button_new (const char *title,
|
||||
GtkFileChooserAction action);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget * gtk_file_chooser_button_new_with_dialog (GtkWidget *dialog);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const char * gtk_file_chooser_button_get_title (GtkFileChooserButton *button);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_file_chooser_button_set_title (GtkFileChooserButton *button,
|
||||
const char *title);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
int gtk_file_chooser_button_get_width_chars (GtkFileChooserButton *button);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_file_chooser_button_set_width_chars (GtkFileChooserButton *button,
|
||||
int n_chars);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_file_chooser_button_get_modal (GtkFileChooserButton *button);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_file_chooser_button_set_modal (GtkFileChooserButton *button,
|
||||
gboolean modal);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* !__GTK_FILE_CHOOSER_BUTTON_H__ */
|
@ -241,7 +241,6 @@ gtk_public_sources = files([
|
||||
'gtkexpander.c',
|
||||
'gtkexpression.c',
|
||||
'gtkfilechooser.c',
|
||||
'gtkfilechooserbutton.c',
|
||||
'gtkfilechooserdialog.c',
|
||||
'gtkfilechoosernative.c',
|
||||
'gtkfilechooserwidget.c',
|
||||
@ -529,7 +528,6 @@ gtk_public_headers = files([
|
||||
'gtkexpander.h',
|
||||
'gtkexpression.h',
|
||||
'gtkfilechooser.h',
|
||||
'gtkfilechooserbutton.h',
|
||||
'gtkfilechooserdialog.h',
|
||||
'gtkfilechoosernative.h',
|
||||
'gtkfilechooserwidget.h',
|
||||
|
@ -33,7 +33,6 @@ gtk_tests = [
|
||||
['testentrycompletion'],
|
||||
['testentryicons'],
|
||||
['testfilechooser'],
|
||||
['testfilechooserbutton'],
|
||||
['testflowbox'],
|
||||
['testfontoptions'],
|
||||
['testframe'],
|
||||
|
@ -1,283 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2 -*- */
|
||||
|
||||
/* GTK+: gtkfilechooserbutton.c
|
||||
*
|
||||
* Copyright (c) 2004 James M. Cape <jcape@ignore-your.tv>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static const char *backend = "gtk+";
|
||||
static gboolean rtl = FALSE;
|
||||
static GOptionEntry entries[] = {
|
||||
{ "backend", 'b', 0, G_OPTION_ARG_STRING, &backend, "The filesystem backend to use.", "gtk+" },
|
||||
{ "right-to-left", 'r', 0, G_OPTION_ARG_NONE, &rtl, "Force right-to-left layout.", NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static char *gtk_src_dir = NULL;
|
||||
|
||||
static void
|
||||
print_selected_path_clicked_cb (GtkWidget *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
GFile *folder, *filename;
|
||||
char *folder_uri, *filename_uri;
|
||||
|
||||
folder = gtk_file_chooser_get_current_folder (user_data);
|
||||
filename = gtk_file_chooser_get_file (user_data);
|
||||
|
||||
folder_uri = g_file_get_uri (folder);
|
||||
filename_uri = g_file_get_uri (filename);
|
||||
g_message ("Currently Selected:\n\tFolder: `%s'\n\tFilename: `%s'\nDone.\n",
|
||||
folder_uri, filename_uri);
|
||||
g_free (folder_uri);
|
||||
g_free (filename_uri);
|
||||
|
||||
g_object_unref (folder);
|
||||
g_object_unref (filename);
|
||||
}
|
||||
|
||||
static void
|
||||
add_pwds_parent_as_shortcut_clicked_cb (GtkWidget *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
GFile *path = g_file_new_for_path (gtk_src_dir);
|
||||
GError *err = NULL;
|
||||
|
||||
if (!gtk_file_chooser_add_shortcut_folder (user_data, path, &err))
|
||||
{
|
||||
g_message ("Couldn't add `%s' as shortcut folder: %s", gtk_src_dir,
|
||||
err->message);
|
||||
g_error_free (err);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_message ("Added `%s' as shortcut folder.", gtk_src_dir);
|
||||
}
|
||||
|
||||
g_object_unref (path);
|
||||
}
|
||||
|
||||
static void
|
||||
del_pwds_parent_as_shortcut_clicked_cb (GtkWidget *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
GFile *path = g_file_new_for_path (gtk_src_dir);
|
||||
GError *err = NULL;
|
||||
|
||||
if (!gtk_file_chooser_remove_shortcut_folder (user_data, path, &err))
|
||||
{
|
||||
g_message ("Couldn't remove `%s' as shortcut folder: %s", gtk_src_dir,
|
||||
err->message);
|
||||
g_error_free (err);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_message ("Removed `%s' as shortcut folder.", gtk_src_dir);
|
||||
}
|
||||
|
||||
g_object_unref (path);
|
||||
}
|
||||
|
||||
static void
|
||||
tests_button_clicked_cb (GtkButton *real_button,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *tests;
|
||||
|
||||
tests = g_object_get_data (user_data, "tests-dialog");
|
||||
|
||||
if (tests == NULL)
|
||||
{
|
||||
GtkWidget *box, *button;
|
||||
|
||||
tests = gtk_window_new ();
|
||||
gtk_window_set_hide_on_close (GTK_WINDOW (tests), TRUE);
|
||||
gtk_window_set_title (GTK_WINDOW (tests),
|
||||
"Tests - TestFileChooserButton");
|
||||
gtk_window_set_transient_for (GTK_WINDOW (tests),
|
||||
GTK_WINDOW (gtk_widget_get_root (user_data)));
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_box_append (GTK_BOX (tests), box);
|
||||
|
||||
button = gtk_button_new_with_label ("Print Selected Path");
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (print_selected_path_clicked_cb), user_data);
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
button = gtk_button_new_with_label ("Add $PWD's Parent as Shortcut");
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (add_pwds_parent_as_shortcut_clicked_cb), user_data);
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
button = gtk_button_new_with_label ("Remove $PWD's Parent as Shortcut");
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (del_pwds_parent_as_shortcut_clicked_cb), user_data);
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
g_object_set_data (user_data, "tests-dialog", tests);
|
||||
}
|
||||
|
||||
gtk_window_present (GTK_WINDOW (tests));
|
||||
}
|
||||
|
||||
static void
|
||||
chooser_selection_changed_cb (GtkFileChooser *chooser,
|
||||
gpointer user_data)
|
||||
{
|
||||
GFile *filename;
|
||||
char *uri;
|
||||
|
||||
filename = gtk_file_chooser_get_file (chooser);
|
||||
|
||||
uri = g_file_get_uri (filename);
|
||||
g_message ("%s::selection-changed\n\tSelection:`%s'\nDone.\n",
|
||||
G_OBJECT_TYPE_NAME (chooser), uri);
|
||||
g_free (uri);
|
||||
|
||||
g_object_unref (filename);
|
||||
}
|
||||
|
||||
static void
|
||||
add_new_filechooser_button (const char *mnemonic,
|
||||
const char *chooser_title,
|
||||
GtkFileChooserAction action,
|
||||
GtkWidget *group_box,
|
||||
GtkSizeGroup *label_group)
|
||||
{
|
||||
GtkWidget *hbox, *label, *chooser, *button;
|
||||
GFile *path;
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
||||
gtk_box_append (GTK_BOX (group_box), hbox);
|
||||
|
||||
label = gtk_label_new_with_mnemonic (mnemonic);
|
||||
gtk_size_group_add_widget (GTK_SIZE_GROUP (label_group), label);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
gtk_box_append (GTK_BOX (hbox), label);
|
||||
|
||||
chooser = gtk_file_chooser_button_new (g_strconcat(chooser_title,
|
||||
" - testfilechooserbutton", NULL),
|
||||
action);
|
||||
gtk_widget_set_hexpand (chooser, TRUE);
|
||||
|
||||
path = g_file_new_for_path (gtk_src_dir);
|
||||
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (chooser), path, NULL);
|
||||
gtk_file_chooser_remove_shortcut_folder (GTK_FILE_CHOOSER (chooser), path, NULL);
|
||||
g_object_unref (path);
|
||||
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser);
|
||||
g_signal_connect (chooser, "selection-changed", G_CALLBACK (chooser_selection_changed_cb), NULL);
|
||||
gtk_box_append (GTK_BOX (hbox), chooser);
|
||||
|
||||
button = gtk_button_new_with_label ("Tests");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (tests_button_clicked_cb), chooser);
|
||||
gtk_box_append (GTK_BOX (hbox), button);
|
||||
}
|
||||
|
||||
static void
|
||||
quit_cb (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gboolean *done = data;
|
||||
|
||||
*done = TRUE;
|
||||
|
||||
g_main_context_wakeup (NULL);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
GtkWidget *win, *vbox, *frame, *group_box;
|
||||
GtkSizeGroup *label_group;
|
||||
GOptionContext *context;
|
||||
char *cwd;
|
||||
gboolean done = FALSE;
|
||||
|
||||
context = g_option_context_new ("- test GtkFileChooserButton widget");
|
||||
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
|
||||
g_option_context_parse (context, &argc, &argv, NULL);
|
||||
g_option_context_free (context);
|
||||
|
||||
gtk_init ();
|
||||
|
||||
/* to test rtl layout, use "--right-to-left" */
|
||||
if (rtl)
|
||||
gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
|
||||
|
||||
cwd = g_get_current_dir();
|
||||
gtk_src_dir = g_path_get_dirname (cwd);
|
||||
g_free (cwd);
|
||||
|
||||
win = gtk_dialog_new_with_buttons ("TestFileChooserButton", NULL, 0,
|
||||
"_Quit", GTK_RESPONSE_CLOSE, NULL);
|
||||
g_signal_connect (win, "response", G_CALLBACK (quit_cb), &done);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
|
||||
gtk_widget_set_margin_start (vbox, 6);
|
||||
gtk_widget_set_margin_end (vbox, 6);
|
||||
gtk_widget_set_margin_top (vbox, 6);
|
||||
gtk_widget_set_margin_bottom (vbox, 6);
|
||||
gtk_box_append (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (win))), vbox);
|
||||
|
||||
frame = gtk_frame_new ("<b>GtkFileChooserButton</b>");
|
||||
gtk_label_set_use_markup (GTK_LABEL (gtk_frame_get_label_widget (GTK_FRAME (frame))), TRUE);
|
||||
gtk_box_append (GTK_BOX (vbox), frame);
|
||||
|
||||
gtk_widget_set_halign (frame, GTK_ALIGN_FILL);
|
||||
gtk_widget_set_valign (frame, GTK_ALIGN_FILL);
|
||||
g_object_set (frame, "margin-top", 6, "margin-start", 12, NULL);
|
||||
|
||||
label_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||
|
||||
group_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
||||
gtk_frame_set_child (GTK_FRAME (frame), group_box);
|
||||
|
||||
/* OPEN */
|
||||
add_new_filechooser_button ("_Open:", "Select A File",
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
group_box, label_group);
|
||||
|
||||
/* SELECT_FOLDER */
|
||||
add_new_filechooser_button ("Select _Folder:", "Select A Folder",
|
||||
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
||||
group_box, label_group);
|
||||
|
||||
g_object_unref (label_group);
|
||||
|
||||
gtk_widget_show (win);
|
||||
gtk_window_present (GTK_WINDOW (win));
|
||||
|
||||
while (!done)
|
||||
g_main_context_iteration (NULL, TRUE);
|
||||
|
||||
return 0;
|
||||
}
|
@ -94,8 +94,7 @@ test_type (gconstpointer data)
|
||||
return;
|
||||
|
||||
/* These leak their GDBusConnections */
|
||||
if (g_type_is_a (type, GTK_TYPE_FILE_CHOOSER_BUTTON) ||
|
||||
g_type_is_a (type, GTK_TYPE_FILE_CHOOSER_DIALOG) ||
|
||||
if (g_type_is_a (type, GTK_TYPE_FILE_CHOOSER_DIALOG) ||
|
||||
g_type_is_a (type, GTK_TYPE_FILE_CHOOSER_WIDGET) ||
|
||||
g_str_equal (g_type_name (type), "GtkPlacesSidebar"))
|
||||
return;
|
||||
|
@ -16,7 +16,6 @@ GtkToggleButton
|
||||
GtkToggleButton
|
||||
GtkButton
|
||||
GtkButton
|
||||
GtkButton
|
||||
GtkLinkButton
|
||||
GtkSwitch
|
||||
GtkScale
|
||||
|
@ -12,7 +12,6 @@ GtkSwitch
|
||||
GtkLinkButton
|
||||
GtkButton
|
||||
GtkButton
|
||||
GtkButton
|
||||
GtkToggleButton
|
||||
GtkToggleButton
|
||||
GtkToggleButton
|
||||
|
@ -854,9 +854,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
<property name="use-alpha">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFileChooserButton" id="filechooserbutton1"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLinkButton" id="linkbutton1">
|
||||
<property name="label" translatable="yes">link button</property>
|
||||
|
@ -855,9 +855,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
<property name="use-alpha">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFileChooserButton" id="filechooserbutton1"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLinkButton" id="linkbutton1">
|
||||
<property name="label" translatable="yes">link button</property>
|
||||
|
@ -855,9 +855,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
<property name="use-alpha">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFileChooserButton" id="filechooserbutton1"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLinkButton" id="linkbutton1">
|
||||
<property name="label" translatable="yes">link button</property>
|
||||
|
@ -401,8 +401,7 @@ test_type (gconstpointer data)
|
||||
return;
|
||||
|
||||
/* These leak their GDBusConnections */
|
||||
if (g_type_is_a (type, GTK_TYPE_FILE_CHOOSER_BUTTON) ||
|
||||
g_type_is_a (type, GTK_TYPE_FILE_CHOOSER_DIALOG) ||
|
||||
if (g_type_is_a (type, GTK_TYPE_FILE_CHOOSER_DIALOG) ||
|
||||
g_type_is_a (type, GTK_TYPE_FILE_CHOOSER_WIDGET) ||
|
||||
g_type_is_a (type, GTK_TYPE_FILE_CHOOSER_NATIVE))
|
||||
return;
|
||||
|
@ -57,8 +57,6 @@ list_ignore_properties (gboolean buglist)
|
||||
{ "GtkWidget", "has-default", (void*) TRUE, }, /* conflicts with toplevel-less widgets */
|
||||
{ "GtkWidget", "display", (void*) MATCH_ANY_VALUE },
|
||||
{ "GtkCellView", "background", (void*) "", }, /* "" is not a valid background color */
|
||||
{ "GtkFileChooserButton", "select-multiple", (void*) MATCH_ANY_VALUE }, /* property disabled */
|
||||
{ "GtkFileChooserButton", "action", (void*) GTK_FILE_CHOOSER_ACTION_SAVE },
|
||||
{ "GtkFileChooserWidget", "select-multiple", (void*) 0x1 }, /* property conflicts */
|
||||
{ "GtkFileChooserDialog", "select-multiple", (void*) MATCH_ANY_VALUE }, /* property disabled */
|
||||
{ "GtkTextView", "overwrite", (void*) MATCH_ANY_VALUE }, /* needs text buffer */
|
||||
|
@ -330,23 +330,6 @@ test_file_chooser_dialog_show (void)
|
||||
gtk_window_destroy (GTK_WINDOW (widget));
|
||||
}
|
||||
|
||||
static void
|
||||
test_file_chooser_button_basic (void)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
gboolean done = FALSE;
|
||||
|
||||
g_test_log_set_fatal_handler (ignore_gvfs_warning, NULL);
|
||||
|
||||
widget = gtk_file_chooser_button_new ("Choose a file !", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
|
||||
g_assert (GTK_IS_FILE_CHOOSER_BUTTON (widget));
|
||||
g_timeout_add (100, main_loop_quit_cb, &done);
|
||||
while (!done)
|
||||
g_main_context_iteration (NULL, TRUE);
|
||||
|
||||
g_object_unref (g_object_ref_sink (widget));
|
||||
}
|
||||
|
||||
static void
|
||||
test_font_button_basic (void)
|
||||
{
|
||||
@ -469,7 +452,6 @@ main (int argc, char **argv)
|
||||
g_test_add_func ("/template/GtkFileChooserWidget/basic", test_file_chooser_widget_basic);
|
||||
g_test_add_func ("/template/GtkFileChooserDialog/basic", test_file_chooser_dialog_basic);
|
||||
g_test_add_func ("/template/GtkFileChooserDialog/show", test_file_chooser_dialog_show);
|
||||
g_test_add_func ("/template/GtkFileChooserButton/basic", test_file_chooser_button_basic);
|
||||
g_test_add_func ("/template/GtkFontButton/basic", test_font_button_basic);
|
||||
g_test_add_func ("/template/GtkFontChooserWidget/basic", test_font_chooser_widget_basic);
|
||||
g_test_add_func ("/template/GtkFontChooserDialog/basic", test_font_chooser_dialog_basic);
|
||||
|
Loading…
Reference in New Issue
Block a user