From: Braden M. <br...@us...> - 2007-02-09 05:18:37
|
Update of /cvsroot/openvrml/openvrml/src/openvrml-player In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv27483/src/openvrml-player Modified Files: Tag: OpenVRML-0_16-BRANCH Makefile.am player.cpp Added Files: Tag: OpenVRML-0_16-BRANCH filechooserdialog.cpp filechooserdialog.h Log Message: Moved file chooser dialog into its own widget implementation. Index: player.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/openvrml-player/player.cpp,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -C2 -d -r1.1.2.7 -r1.1.2.8 *** player.cpp 8 Feb 2007 05:53:19 -0000 1.1.2.7 --- player.cpp 9 Feb 2007 05:18:36 -0000 1.1.2.8 *************** *** 33,36 **** --- 33,38 ---- # include <glade/glade.h> + # include "filechooserdialog.h" + # ifdef HAVE_CONFIG_H # include <config.h> *************** *** 761,791 **** if (!file_chooser_dialog) { file_chooser_dialog = ! gtk_file_chooser_dialog_new("Open File", ! parent, ! GTK_FILE_CHOOSER_ACTION_OPEN, ! GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, ! GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, ! NULL); ! ! gtk_dialog_set_default_response(GTK_DIALOG(file_chooser_dialog), ! GTK_RESPONSE_ACCEPT); ! ! GtkFileFilter * const world_filter = gtk_file_filter_new(); ! g_return_if_fail(world_filter); ! gtk_file_filter_set_name(world_filter, "VRML/X3D worlds"); ! gtk_file_filter_add_mime_type(world_filter, "x-world/x-vrml"); ! gtk_file_filter_add_mime_type(world_filter, "model/vrml"); ! gtk_file_filter_add_mime_type(world_filter, "model/x3d+vrml"); ! ! gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(file_chooser_dialog), ! world_filter); ! ! GtkFileFilter * const all_filter = gtk_file_filter_new(); ! g_return_if_fail(all_filter); ! gtk_file_filter_set_name(all_filter, "All files"); ! gtk_file_filter_add_pattern(all_filter, "*"); ! ! gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(file_chooser_dialog), ! all_filter); } --- 763,767 ---- if (!file_chooser_dialog) { file_chooser_dialog = ! openvrml_player_file_chooser_dialog_new(parent); } --- NEW FILE: filechooserdialog.cpp --- // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*- // // Copyright 2007 Braden McDaniel // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // # include <gtk/gtk.h> # include <boost/concept_check.hpp> # include <boost/multi_index/detail/scope_guard.hpp> # include "filechooserdialog.h" using namespace boost::multi_index::detail; // for scope_guard namespace { G_GNUC_INTERNAL void class_init(gpointer g_class, gpointer class_data); G_GNUC_INTERNAL void init(GTypeInstance * instance, gpointer g_class); } GtkType openvrml_player_file_chooser_dialog_get_type() { static GtkType type = 0; if (G_UNLIKELY(!type)) { type = g_type_register_static_simple( GTK_TYPE_FILE_CHOOSER_DIALOG, "OpenvrmlPlayerFileChooserDialog", sizeof (OpenvrmlPlayerFileChooserDialogClass), class_init, sizeof (OpenvrmlPlayerFileChooserDialog), init, GTypeFlags(0)); } return type; } GtkWidget * openvrml_player_file_chooser_dialog_new(GtkWindow * parent) { GtkWidget * const dialog = static_cast<GtkWidget *>( g_object_new(OPENVRML_PLAYER_TYPE_FILE_CHOOSER_DIALOG, "title", "Open", "action", GTK_FILE_CHOOSER_ACTION_OPEN, NULL)); scope_guard dialog_guard = make_guard(g_object_unref, dialog); boost::ignore_unused_variable_warning(dialog_guard); if (parent) { gtk_window_set_transient_for(GTK_WINDOW(dialog), parent); } gtk_dialog_add_buttons(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); GtkFileFilter * const world_filter = gtk_file_filter_new(); g_return_val_if_fail(world_filter, 0); scope_guard world_filter_guard = make_guard(g_object_unref, world_filter); boost::ignore_unused_variable_warning(world_filter_guard); gtk_file_filter_set_name(world_filter, "VRML/X3D worlds"); gtk_file_filter_add_mime_type(world_filter, "x-world/x-vrml"); gtk_file_filter_add_mime_type(world_filter, "model/vrml"); gtk_file_filter_add_mime_type(world_filter, "model/x3d+vrml"); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), world_filter); world_filter_guard.dismiss(); GtkFileFilter * const all_filter = gtk_file_filter_new(); g_return_val_if_fail(all_filter, 0); scope_guard all_filter_guard = make_guard(g_object_unref, all_filter); boost::ignore_unused_variable_warning(all_filter_guard); gtk_file_filter_set_name(all_filter, "All files"); gtk_file_filter_add_pattern(all_filter, "*"); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), all_filter); all_filter_guard.dismiss(); dialog_guard.dismiss(); return dialog; } namespace { G_GNUC_INTERNAL GtkWidgetClass * parent_class; void class_init(const gpointer g_class, gpointer /* class_data */) { ::parent_class = static_cast<GtkWidgetClass *>( g_type_class_peek_parent(G_OBJECT_CLASS(g_class))); } void init(GTypeInstance * const instance, gpointer /* g_class */) {} } Index: Makefile.am =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/openvrml-player/Makefile.am,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** Makefile.am 24 Jan 2007 00:06:34 -0000 1.1.2.2 --- Makefile.am 9 Feb 2007 05:18:32 -0000 1.1.2.3 *************** *** 15,19 **** endif ! openvrml_player_SOURCES = player.cpp EXTRA_DIST = \ --- 15,21 ---- endif ! openvrml_player_SOURCES = filechooserdialog.cpp player.cpp ! ! noinst_HEADERS = filechooserdialog.h EXTRA_DIST = \ --- NEW FILE: filechooserdialog.h --- // -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*- // // Copyright 2007 Braden McDaniel // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // # ifndef OPENVRML_PLAYER_FILE_CHOOSER_DIALOG_H # define OPENVRML_PLAYER_FILE_CHOOSER_DIALOG_H # include <gtk/gtkfilechooserdialog.h> G_BEGIN_DECLS # define OPENVRML_PLAYER_TYPE_FILE_CHOOSER_DIALOG (openvrml_player_file_chooser_dialog_get_type()) # define OPENVRML_PLAYER_FILE_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), OPENVRML_PLAYER_TYPE_FILE_CHOOSER_DIALOG, OpenvrmlPlayerFileChooserDialog)) # define OPENVRML_PLAYER_FILE_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), OPENVRML_PLAYER_TYPE_FILE_CHOOSER_DIALOG, OpenvrmlPlayerFileChooserDialogClass)) # define OPENVRML_PLAYER_IS_FILE_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OPENVRML_PLAYER_TYPE_FILE_CHOOSER_DIALOG)) # define OPENVRML_PLAYER_IS_FILE_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OPENVRML_PLAYER_TYPE_FILE_CHOOSER_DIALOG)) # define OPENVRML_PLAYER_FILE_CHOOSER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OPENVRML_PLAYER_TYPE_FILE_CHOOSER_DIALOG, OpenvrmlPlayerFileChooserDialogClass)) typedef struct OpenvrmlPlayerFileChooserDialog_ OpenvrmlPlayerFileChooserDialog; typedef struct OpenvrmlPlayerFileChooserDialogClass_ OpenvrmlPlayerFileChooserDialogClass; struct OpenvrmlPlayerFileChooserDialogClass_ { GtkFileChooserDialogClass parent_class; }; struct OpenvrmlPlayerFileChooserDialog_ { GtkFileChooserDialog parent_instance; }; GType openvrml_player_file_chooser_dialog_get_type() G_GNUC_CONST; GtkWidget * openvrml_player_file_chooser_dialog_new(GtkWindow * parent); G_END_DECLS # endif // ifndef OPENVRML_PLAYER_FILE_CHOOSER_DIALOG_H |