forked from AuroraMiddleware/gtk
New widget to go along with GtkFontButton and GtkColorButton for use in
2004-08-17 Matthias Clasen <mclasen@redhat.com> * gtk/gtkfilechooserbutton.[hc]: New widget to go along with GtkFontButton and GtkColorButton for use in preference dialogs. Replaces GnomeFileEntry. (#148108, James M. Cape) * gtk/gtk.h: Include gtkfilechooserbutton.h * gtk/Makefile.am (gtk_public_h_sources): Add gtkfilechooserbutton.h (gtk_c_sources): Add gtkfilechooserbutton.c * gtk/gtk.symbols: Add the GtkFileChooserButton symbols. * gtk/gtkfilechooserutils.[hc]: Make the delegate quark available. * gtk/gtkfilechooserentry.[hc] (_gtk_file_chooser_entry_new): Allow to suppress tab-eating using the new eat_tabs argument. Adjust all callers. * tests/testfilechooserbutton.c: Test for GtkFileChooserButton. * tests/Makefile.am (noinst_PROGRAMS): Add testfilechooserbutton
This commit is contained in:
parent
36dfdad411
commit
a3aa10e5a6
23
ChangeLog
23
ChangeLog
@ -1,3 +1,26 @@
|
||||
2004-08-17 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkfilechooserbutton.[hc]: New widget to go along with
|
||||
GtkFontButton and GtkColorButton for use in preference dialogs.
|
||||
Replaces GnomeFileEntry. (#148108, James M. Cape)
|
||||
|
||||
* gtk/gtk.h: Include gtkfilechooserbutton.h
|
||||
|
||||
* gtk/Makefile.am (gtk_public_h_sources): Add gtkfilechooserbutton.h
|
||||
(gtk_c_sources): Add gtkfilechooserbutton.c
|
||||
|
||||
* gtk/gtk.symbols: Add the GtkFileChooserButton symbols.
|
||||
|
||||
* gtk/gtkfilechooserutils.[hc]: Make the delegate quark available.
|
||||
|
||||
* gtk/gtkfilechooserentry.[hc] (_gtk_file_chooser_entry_new): Allow
|
||||
to suppress tab-eating using the new eat_tabs argument. Adjust all
|
||||
callers.
|
||||
|
||||
* tests/testfilechooserbutton.c: Test for GtkFileChooserButton.
|
||||
|
||||
* tests/Makefile.am (noinst_PROGRAMS): Add testfilechooserbutton
|
||||
|
||||
2004-08-16 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkwidget.c (gtk_widget_render_icon): Doc update.
|
||||
|
@ -1,3 +1,26 @@
|
||||
2004-08-17 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkfilechooserbutton.[hc]: New widget to go along with
|
||||
GtkFontButton and GtkColorButton for use in preference dialogs.
|
||||
Replaces GnomeFileEntry. (#148108, James M. Cape)
|
||||
|
||||
* gtk/gtk.h: Include gtkfilechooserbutton.h
|
||||
|
||||
* gtk/Makefile.am (gtk_public_h_sources): Add gtkfilechooserbutton.h
|
||||
(gtk_c_sources): Add gtkfilechooserbutton.c
|
||||
|
||||
* gtk/gtk.symbols: Add the GtkFileChooserButton symbols.
|
||||
|
||||
* gtk/gtkfilechooserutils.[hc]: Make the delegate quark available.
|
||||
|
||||
* gtk/gtkfilechooserentry.[hc] (_gtk_file_chooser_entry_new): Allow
|
||||
to suppress tab-eating using the new eat_tabs argument. Adjust all
|
||||
callers.
|
||||
|
||||
* tests/testfilechooserbutton.c: Test for GtkFileChooserButton.
|
||||
|
||||
* tests/Makefile.am (noinst_PROGRAMS): Add testfilechooserbutton
|
||||
|
||||
2004-08-16 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkwidget.c (gtk_widget_render_icon): Doc update.
|
||||
|
@ -1,3 +1,26 @@
|
||||
2004-08-17 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkfilechooserbutton.[hc]: New widget to go along with
|
||||
GtkFontButton and GtkColorButton for use in preference dialogs.
|
||||
Replaces GnomeFileEntry. (#148108, James M. Cape)
|
||||
|
||||
* gtk/gtk.h: Include gtkfilechooserbutton.h
|
||||
|
||||
* gtk/Makefile.am (gtk_public_h_sources): Add gtkfilechooserbutton.h
|
||||
(gtk_c_sources): Add gtkfilechooserbutton.c
|
||||
|
||||
* gtk/gtk.symbols: Add the GtkFileChooserButton symbols.
|
||||
|
||||
* gtk/gtkfilechooserutils.[hc]: Make the delegate quark available.
|
||||
|
||||
* gtk/gtkfilechooserentry.[hc] (_gtk_file_chooser_entry_new): Allow
|
||||
to suppress tab-eating using the new eat_tabs argument. Adjust all
|
||||
callers.
|
||||
|
||||
* tests/testfilechooserbutton.c: Test for GtkFileChooserButton.
|
||||
|
||||
* tests/Makefile.am (noinst_PROGRAMS): Add testfilechooserbutton
|
||||
|
||||
2004-08-16 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkwidget.c (gtk_widget_render_icon): Doc update.
|
||||
|
@ -1,3 +1,26 @@
|
||||
2004-08-17 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkfilechooserbutton.[hc]: New widget to go along with
|
||||
GtkFontButton and GtkColorButton for use in preference dialogs.
|
||||
Replaces GnomeFileEntry. (#148108, James M. Cape)
|
||||
|
||||
* gtk/gtk.h: Include gtkfilechooserbutton.h
|
||||
|
||||
* gtk/Makefile.am (gtk_public_h_sources): Add gtkfilechooserbutton.h
|
||||
(gtk_c_sources): Add gtkfilechooserbutton.c
|
||||
|
||||
* gtk/gtk.symbols: Add the GtkFileChooserButton symbols.
|
||||
|
||||
* gtk/gtkfilechooserutils.[hc]: Make the delegate quark available.
|
||||
|
||||
* gtk/gtkfilechooserentry.[hc] (_gtk_file_chooser_entry_new): Allow
|
||||
to suppress tab-eating using the new eat_tabs argument. Adjust all
|
||||
callers.
|
||||
|
||||
* tests/testfilechooserbutton.c: Test for GtkFileChooserButton.
|
||||
|
||||
* tests/Makefile.am (noinst_PROGRAMS): Add testfilechooserbutton
|
||||
|
||||
2004-08-16 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkwidget.c (gtk_widget_render_icon): Doc update.
|
||||
|
@ -159,6 +159,7 @@ gtk_public_h_sources = \
|
||||
gtkeventbox.h \
|
||||
gtkexpander.h \
|
||||
gtkfilechooser.h \
|
||||
gtkfilechooserbutton.h \
|
||||
gtkfilechooserdialog.h \
|
||||
gtkfilechooserwidget.h \
|
||||
gtkfilefilter.h \
|
||||
@ -363,6 +364,7 @@ gtk_c_sources = \
|
||||
gtkeventbox.c \
|
||||
gtkexpander.c \
|
||||
gtkfilechooser.c \
|
||||
gtkfilechooserbutton.c \
|
||||
gtkfilechooserdialog.c \
|
||||
gtkfilechooserembed.c \
|
||||
gtkfilechooserentry.c \
|
||||
@ -731,4 +733,3 @@ EXTRA_DIST += \
|
||||
abicheck.sh
|
||||
|
||||
install-data-local:
|
||||
|
||||
|
@ -78,6 +78,7 @@
|
||||
#include <gtk/gtkexpander.h>
|
||||
#include <gtk/gtkfilesel.h>
|
||||
#include <gtk/gtkfixed.h>
|
||||
#include <gtk/gtkfilechooserbutton.h>
|
||||
#include <gtk/gtkfilechooserdialog.h>
|
||||
#include <gtk/gtkfilechooserwidget.h>
|
||||
#include <gtk/gtkfontbutton.h>
|
||||
|
@ -749,6 +749,14 @@ gtk_file_chooser_action_get_type
|
||||
gtk_file_chooser_add_filter
|
||||
gtk_file_chooser_add_shortcut_folder
|
||||
gtk_file_chooser_add_shortcut_folder_uri
|
||||
gtk_file_chooser_button_get_active
|
||||
gtk_file_chooser_button_get_type
|
||||
gtk_file_chooser_button_get_title
|
||||
gtk_file_chooser_button_new
|
||||
gtk_file_chooser_button_new_with_backend
|
||||
gtk_file_chooser_button_new_with_dialog
|
||||
gtk_file_chooser_button_set_active
|
||||
gtk_file_chooser_button_set_title
|
||||
gtk_file_chooser_dialog_get_type
|
||||
gtk_file_chooser_dialog_new
|
||||
gtk_file_chooser_dialog_new_with_backend
|
||||
|
1122
gtk/gtkfilechooserbutton.c
Normal file
1122
gtk/gtkfilechooserbutton.c
Normal file
File diff suppressed because it is too large
Load Diff
89
gtk/gtkfilechooserbutton.h
Normal file
89
gtk/gtkfilechooserbutton.h
Normal file
@ -0,0 +1,89 @@
|
||||
/* GTK+: 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, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_FILE_CHOOSER_BUTTON_H__
|
||||
#define __GTK_FILE_CHOOSER_BUTTON_H__ 1
|
||||
|
||||
#include "gtkhbox.h"
|
||||
#include "gtkfilechooser.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define GTK_TYPE_FILE_CHOOSER_BUTTON \
|
||||
(gtk_file_chooser_button_get_type ())
|
||||
#define GTK_FILE_CHOOSER_BUTTON(object) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_FILE_CHOOSER_BUTTON, GtkFileChooserButton))
|
||||
#define GTK_FILE_CHOOSER_BUTTON_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FILE_CHOOSER_BUTTON, GtkFileChooserButtonClass))
|
||||
#define GTK_IS_FILE_CHOOSER_BUTTON(object) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_FILE_CHOOSER_BUTTON))
|
||||
#define GTK_IS_FILE_CHOOSER_BUTTON_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FILE_CHOOSER_BUTTON))
|
||||
#define GTK_FILE_CHOOSER_BUTTON_GET_CLASS(object) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((object), GTK_TYPE_FILE_CHOOSER_BUTTON, GtkFileChooserButtonClass))
|
||||
|
||||
|
||||
typedef struct _GtkFileChooserButton GtkFileChooserButton;
|
||||
typedef struct _GtkFileChooserButtonPrivate GtkFileChooserButtonPrivate;
|
||||
typedef struct _GtkFileChooserButtonClass GtkFileChooserButtonClass;
|
||||
|
||||
struct _GtkFileChooserButton
|
||||
{
|
||||
/* <private> */
|
||||
GtkHBox parent;
|
||||
|
||||
GtkFileChooserButtonPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkFileChooserButtonClass
|
||||
{
|
||||
/* <private> */
|
||||
GtkHBoxClass parent_class;
|
||||
|
||||
void (*__gtk_reserved1);
|
||||
void (*__gtk_reserved2);
|
||||
void (*__gtk_reserved3);
|
||||
void (*__gtk_reserved4);
|
||||
void (*__gtk_reserved5);
|
||||
void (*__gtk_reserved6);
|
||||
void (*__gtk_reserved7);
|
||||
void (*__gtk_reserved8);
|
||||
};
|
||||
|
||||
|
||||
GType gtk_file_chooser_button_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget *gtk_file_chooser_button_new (const gchar *title);
|
||||
GtkWidget *gtk_file_chooser_button_new_with_backend (const gchar *title,
|
||||
const gchar *backend);
|
||||
GtkWidget *gtk_file_chooser_button_new_with_dialog (GtkWidget *dialog);
|
||||
|
||||
G_CONST_RETURN gchar *gtk_file_chooser_button_get_title (GtkFileChooserButton *button);
|
||||
void gtk_file_chooser_button_set_title (GtkFileChooserButton *button,
|
||||
const gchar *title);
|
||||
gboolean gtk_file_chooser_button_get_active (GtkFileChooserButton *button);
|
||||
void gtk_file_chooser_button_set_active (GtkFileChooserButton *button,
|
||||
gboolean is_active);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* !__GTK_FILE_CHOOSER_BUTTON_H__ */
|
@ -3172,7 +3172,7 @@ save_widgets_create (GtkFileChooserDefault *impl)
|
||||
0, 0);
|
||||
gtk_widget_show (widget);
|
||||
|
||||
impl->save_file_name_entry = _gtk_file_chooser_entry_new ();
|
||||
impl->save_file_name_entry = _gtk_file_chooser_entry_new (TRUE);
|
||||
_gtk_file_chooser_entry_set_file_system (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry),
|
||||
impl->file_system);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (impl->save_file_name_entry), 45);
|
||||
@ -5467,7 +5467,7 @@ location_entry_create (GtkFileChooserDefault *impl)
|
||||
{
|
||||
GtkWidget *entry;
|
||||
|
||||
entry = _gtk_file_chooser_entry_new ();
|
||||
entry = _gtk_file_chooser_entry_new (TRUE);
|
||||
/* Pick a good width for the entry */
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (entry), 30);
|
||||
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
|
||||
|
@ -57,6 +57,7 @@ struct _GtkFileChooserEntry
|
||||
|
||||
guint has_completion : 1;
|
||||
guint in_change : 1;
|
||||
guint eat_tabs : 1;
|
||||
};
|
||||
|
||||
enum
|
||||
@ -633,6 +634,9 @@ gtk_file_chooser_entry_focus (GtkWidget *widget,
|
||||
GdkModifierType state;
|
||||
gboolean control_pressed = FALSE;
|
||||
|
||||
if (!chooser_entry->eat_tabs)
|
||||
return GTK_WIDGET_CLASS (parent_class)->focus (widget, direction);
|
||||
|
||||
if (gtk_get_current_event_state (&state))
|
||||
{
|
||||
if ((state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
|
||||
@ -789,6 +793,7 @@ clear_completion_callback (GtkFileChooserEntry *chooser_entry,
|
||||
|
||||
/**
|
||||
* _gtk_file_chooser_entry_new:
|
||||
* @eat_tabs: If %FALSE, allow focus navigation with the tab key.
|
||||
*
|
||||
* Creates a new #GtkFileChooserEntry object. #GtkFileChooserEntry
|
||||
* is an internal implementation widget for the GTK+ file chooser
|
||||
@ -798,9 +803,14 @@ clear_completion_callback (GtkFileChooserEntry *chooser_entry,
|
||||
* Return value: the newly created #GtkFileChooserEntry
|
||||
**/
|
||||
GtkWidget *
|
||||
_gtk_file_chooser_entry_new (void)
|
||||
_gtk_file_chooser_entry_new (gboolean eat_tabs)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_FILE_CHOOSER_ENTRY, NULL);
|
||||
GtkFileChooserEntry *chooser_entry;
|
||||
|
||||
chooser_entry = g_object_new (GTK_TYPE_FILE_CHOOSER_ENTRY, NULL);
|
||||
chooser_entry->eat_tabs = (eat_tabs != FALSE);
|
||||
|
||||
return GTK_WIDGET (chooser_entry);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@ G_BEGIN_DECLS
|
||||
typedef struct _GtkFileChooserEntry GtkFileChooserEntry;
|
||||
|
||||
GType _gtk_file_chooser_entry_get_type (void);
|
||||
GtkWidget * _gtk_file_chooser_entry_new (void);
|
||||
GtkWidget * _gtk_file_chooser_entry_new (gboolean eat_tab);
|
||||
void _gtk_file_chooser_entry_set_file_system (GtkFileChooserEntry *chooser_entry,
|
||||
GtkFileSystem *file_system);
|
||||
void _gtk_file_chooser_entry_set_base_folder (GtkFileChooserEntry *chooser_entry,
|
||||
|
@ -175,10 +175,22 @@ _gtk_file_chooser_set_delegate (GtkFileChooser *receiver,
|
||||
G_CALLBACK (delegate_file_activated), receiver);
|
||||
}
|
||||
|
||||
GQuark
|
||||
_gtk_file_chooser_delegate_get_quark (void)
|
||||
{
|
||||
static GQuark quark = 0;
|
||||
|
||||
if (G_UNLIKELY (quark == 0))
|
||||
quark = g_quark_from_static_string ("gtk-file-chooser-delegate");
|
||||
|
||||
return quark;
|
||||
}
|
||||
|
||||
static GtkFileChooser *
|
||||
get_delegate (GtkFileChooser *receiver)
|
||||
{
|
||||
return g_object_get_data (G_OBJECT (receiver), "gtk-file-chooser-delegate");
|
||||
return g_object_get_qdata (G_OBJECT (receiver),
|
||||
GTK_FILE_CHOOSER_DELEGATE_QUARK);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -26,6 +26,8 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_FILE_CHOOSER_DELEGATE_QUARK (_gtk_file_chooser_delegate_get_quark ())
|
||||
|
||||
typedef enum {
|
||||
GTK_FILE_CHOOSER_PROP_FIRST = 0x1000,
|
||||
GTK_FILE_CHOOSER_PROP_ACTION = GTK_FILE_CHOOSER_PROP_FIRST,
|
||||
@ -47,6 +49,8 @@ void _gtk_file_chooser_delegate_iface_init (GtkFileChooserIface *iface);
|
||||
void _gtk_file_chooser_set_delegate (GtkFileChooser *receiver,
|
||||
GtkFileChooser *delegate);
|
||||
|
||||
GQuark _gtk_file_chooser_delegate_get_quark (void) G_GNUC_CONST;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_FILE_CHOOSER_UTILS_H__ */
|
||||
|
@ -35,6 +35,7 @@ noinst_PROGRAMS = \
|
||||
testellipsise \
|
||||
testentrycompletion \
|
||||
testfilechooser \
|
||||
testfilechooserbutton \
|
||||
testgtk \
|
||||
testiconview \
|
||||
testicontheme \
|
||||
@ -76,6 +77,7 @@ testdnd_DEPENDENCIES = $(TEST_DEPS)
|
||||
testellipsise_DEPENDENCIES = $(TEST_DEPS)
|
||||
testentrycompletion_DEPENDENCIES = $(TEST_DEPS)
|
||||
testfilechooser_DEPENDENCIES = $(TEST_DEPS)
|
||||
testfilechooserbutton_DEPENDENCIES = $(TEST_DEPS)
|
||||
testgtk_DEPENDENCIES = $(TEST_DEPS)
|
||||
testinput_DEPENDENCIES = $(TEST_DEPS)
|
||||
testmenus_DEPENDENCIES = $(TEST_DEPS)
|
||||
@ -108,6 +110,7 @@ testdnd_LDADD = $(LDADDS)
|
||||
testellipsise_LDADD = $(LDADDS)
|
||||
testentrycompletion_LDADD = $(LDADDS)
|
||||
testfilechooser_LDADD = $(LDADDS)
|
||||
testfilechooserbutton_LDADD = $(LDADDS)
|
||||
testgtk_LDADD = $(LDADDS)
|
||||
testicontheme_LDADD = $(LDADDS)
|
||||
testiconview_LDADD = $(LDADDS)
|
||||
@ -144,6 +147,10 @@ testfilechooser_SOURCES = \
|
||||
prop-editor.c \
|
||||
testfilechooser.c
|
||||
|
||||
testfilechooserbutton_SOURCES = \
|
||||
prop-editor.c \
|
||||
testfilechooserbutton.c
|
||||
|
||||
testgtk_SOURCES = \
|
||||
prop-editor.c \
|
||||
testgtk.c
|
||||
|
167
tests/testfilechooserbutton.c
Normal file
167
tests/testfilechooserbutton.c
Normal file
@ -0,0 +1,167 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "prop-editor.h"
|
||||
|
||||
|
||||
static void
|
||||
win_style_set_cb (GtkWidget *win)
|
||||
{
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (win)->vbox), 12);
|
||||
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (win)->vbox), 24);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (win)->action_area), 0);
|
||||
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (win)->action_area), 6);
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
editor_delete_event_cb (GtkWidget *editor, gint response, gpointer user_data)
|
||||
{
|
||||
gtk_widget_hide (editor);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
properties_button_clicked_cb (GtkWidget *button, GObject *entry)
|
||||
{
|
||||
GtkWidget *editor;
|
||||
|
||||
editor = g_object_get_data (entry, "properties-dialog");
|
||||
|
||||
if (editor == NULL)
|
||||
{
|
||||
editor = create_prop_editor (G_OBJECT (entry), G_TYPE_INVALID);
|
||||
gtk_window_set_transient_for (GTK_WINDOW (editor),
|
||||
GTK_WINDOW (gtk_widget_get_toplevel (button)));
|
||||
g_signal_connect (editor, "delete-event", G_CALLBACK (editor_delete_event_cb), NULL);
|
||||
g_object_set_data (entry, "properties-dialog", editor);
|
||||
}
|
||||
|
||||
gtk_window_present (GTK_WINDOW (editor));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
chooser_current_folder_changed_cb (GtkFileChooser *chooser, gpointer user_data)
|
||||
{
|
||||
gchar *folder, *filename;
|
||||
|
||||
folder = gtk_file_chooser_get_current_folder (chooser);
|
||||
filename = gtk_file_chooser_get_filename (chooser);
|
||||
g_message ("%s:%s:\n`%s`\n\tFolder: `%s'\n\tFilename: `%s'", G_STRFUNC, G_STRLOC,
|
||||
G_OBJECT_TYPE_NAME (chooser), folder, filename);
|
||||
g_free (folder);
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
chooser_selection_changed_cb (GtkFileChooser *chooser, gpointer user_data)
|
||||
{
|
||||
GSList *selection;
|
||||
|
||||
g_warning ("%s:%s:\n`%s` Selection:", G_STRFUNC, G_STRLOC, G_OBJECT_TYPE_NAME (chooser));
|
||||
for (selection = gtk_file_chooser_get_filenames (chooser); selection != NULL;
|
||||
selection = g_slist_remove_link (selection, selection))
|
||||
{
|
||||
g_print ("`%s'\n", (const gchar *) selection->data);
|
||||
g_free (selection->data);
|
||||
}
|
||||
g_print ("Done.\n");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
chooser_file_activated_cb (GtkFileChooser *chooser, gpointer user_data)
|
||||
{
|
||||
gchar *folder, *filename;
|
||||
|
||||
folder = gtk_file_chooser_get_current_folder (chooser);
|
||||
filename = gtk_file_chooser_get_filename (chooser);
|
||||
g_warning ("%s:%s:\n`%s`\nFolder: `%s'\nFilename: `%s'", G_STRFUNC, G_STRLOC, G_OBJECT_TYPE_NAME (chooser), folder, filename);
|
||||
g_free (folder);
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
chooser_update_preview_cb (GtkFileChooser *chooser, gpointer user_data)
|
||||
{
|
||||
gchar *filename;
|
||||
|
||||
filename = gtk_file_chooser_get_preview_filename (chooser);
|
||||
g_warning ("%s:%s:\n`%s`\nPreview Filename: `%s'", G_STRFUNC, G_STRLOC, G_OBJECT_TYPE_NAME (chooser), filename);
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *win, *vbox, *frame, *alignment, *group_box, *hbox, *label, *chooser, *button;
|
||||
GtkSizeGroup *label_group;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
win = gtk_dialog_new_with_buttons ("TestFileChooserButton", NULL, GTK_DIALOG_NO_SEPARATOR,
|
||||
GTK_STOCK_QUIT, GTK_RESPONSE_CLOSE, NULL);
|
||||
g_signal_connect (win, "style-set", G_CALLBACK (win_style_set_cb), NULL);
|
||||
g_signal_connect (win, "response", G_CALLBACK (gtk_main_quit), NULL);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 18);
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (win)->vbox), vbox);
|
||||
|
||||
frame = gtk_frame_new ("<b>GtkFileChooserButton</b>");
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
|
||||
gtk_label_set_use_markup (GTK_LABEL (gtk_frame_get_label_widget (GTK_FRAME (frame))), TRUE);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
|
||||
alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
|
||||
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
|
||||
gtk_container_add (GTK_CONTAINER (frame), alignment);
|
||||
|
||||
label_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||
|
||||
group_box = gtk_vbox_new (FALSE, 6);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), group_box);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 12);
|
||||
gtk_container_add (GTK_CONTAINER (group_box), hbox);
|
||||
|
||||
label = gtk_label_new ("Open:");
|
||||
gtk_size_group_add_widget (GTK_SIZE_GROUP (label_group), label);
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
||||
|
||||
chooser = gtk_file_chooser_button_new_with_backend ("Select A File - testfilechooserbutton",
|
||||
"gtk+");
|
||||
g_signal_connect (chooser, "current-folder-changed",
|
||||
G_CALLBACK (chooser_current_folder_changed_cb), NULL);
|
||||
g_signal_connect (chooser, "selection-changed", G_CALLBACK (chooser_selection_changed_cb), NULL);
|
||||
g_signal_connect (chooser, "file-activated", G_CALLBACK (chooser_file_activated_cb), NULL);
|
||||
g_signal_connect (chooser, "update-preview", G_CALLBACK (chooser_update_preview_cb), NULL);
|
||||
gtk_container_add (GTK_CONTAINER (hbox), chooser);
|
||||
|
||||
button = gtk_button_new_with_label ("Properties...");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (properties_button_clicked_cb), chooser);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||
|
||||
g_object_unref (label_group);
|
||||
|
||||
gtk_widget_show_all (win);
|
||||
gtk_window_present (GTK_WINDOW (win));
|
||||
|
||||
gtk_main ();
|
||||
|
||||
gtk_widget_destroy (win);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user