gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog gui/gtk.cpp gui/gtksup.h


From: Bastiaan Jacques
Subject: [Gnash-commit] gnash ChangeLog gui/gtk.cpp gui/gtksup.h
Date: Wed, 10 Jan 2007 14:17:34 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Bastiaan Jacques <bjacques>     07/01/10 14:17:34

Modified files:
        .              : ChangeLog 
        gui            : gtk.cpp gtksup.h 

Log message:
        Reimplement the open file dialog, and this time include support for 
legacy
        GTK versions. It doesn't yet actually open the selected file.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2072&r2=1.2073
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gtk.cpp?cvsroot=gnash&r1=1.59&r2=1.60
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gtksup.h?cvsroot=gnash&r1=1.32&r2=1.33

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2072
retrieving revision 1.2073
diff -u -b -r1.2072 -r1.2073
--- ChangeLog   10 Jan 2007 11:26:18 -0000      1.2072
+++ ChangeLog   10 Jan 2007 14:17:34 -0000      1.2073
@@ -1,3 +1,9 @@
+2007-01-10 Bastiaan Jacques <address@hidden>
+
+       * gui/gtk{.cpp, sup.h}: Reimplement the open file dialog, and
+       this time include support for legacy GTK versions. It doesn't
+       yet actually open the selected file.
+
 2007-01-10 Sandro Santilli <address@hidden>
 
        * testsuite/actionscript.all/Video.as: xcheck => check

Index: gui/gtk.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gtk.cpp,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- gui/gtk.cpp 5 Jan 2007 23:55:59 -0000       1.59
+++ gui/gtk.cpp 10 Jan 2007 14:17:34 -0000      1.60
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: gtk.cpp,v 1.59 2007/01/05 23:55:59 nihilus Exp $ */
+/* $Id: gtk.cpp,v 1.60 2007/01/10 14:17:34 bjacques Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -38,12 +38,13 @@
 #include <gtk/gtk.h>
 #include <gdk/gdkx.h>
 #include <gdk/gdkkeysyms.h>
+#include <string>
 
 
 using namespace std;
 
-namespace {
-gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
+namespace gnash {
+LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
 }
 
 namespace gnash 
@@ -348,22 +349,50 @@
     return true;
 }
 
-void
-GtkGui::menuitem_openfile_callback(GtkMenuItem* /*menuitem*/, gpointer 
/*data*/)
+
+
+/// This method is called when the "OK" button is clicked in the open file
+/// dialog. For GTK <= 2.4.0, this is a callback called by GTK itself.
+void GtkGui::open_file (GtkWidget *widget, gpointer /* user_data */)
 {
 #if 0
-    /*
-     * There are two problems with this code:
-     * 1) It doesn't actually make Gnash open the file.
-     * 2) It requires GTK >= 2.4, and we want to preserve compatibility
-     *    with GTK 2.2 for embedded, old and thin systems.
-     */
+    // We'll need this when implementing file opening.
+    GtkGui* gui = static_cast<GtkGui*>(user_data);
+#endif
+
+   
+#if GTK_CHECK_VERSION(2,4,0)
+    char* filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
+#else   
+    GtkWidget* file_selector = gtk_widget_get_ancestor(widget,
+                                 g_type_from_name("GtkFileSelection"));
+
+    GtkFileSelection* filesel = GTK_FILE_SELECTION (file_selector);
+    const char* filename = gtk_file_selection_get_filename (filesel);
+#endif
+
+    // FIXME: we want to do something like calling gtk_main_quit here, so
+    // run() will return. If run() is then changed to return a pointer to the
+    // next file to be played, then the Player class can play the next file,
+    // unless run() returns NULL.
+    dbglogfile << "Attempting to open file " << filename << "." << endl
+               << "NOTE: the file open functionality is not yet implemented!"
+               << endl;
 
 
-    GtkWidget *dialog;
+#if GTK_CHECK_VERSION(2,4,0)
+    g_free(filename);
+#endif
+}
     
-    dbglogfile << "Executant fileselectiondialog! " << endl;
-    dialog = gtk_file_chooser_dialog_new ("Open File",
+void
+GtkGui::menuitem_openfile_callback(GtkMenuItem* /*menuitem*/, gpointer data)
+{
+    GtkWidget* dialog;
+    GtkGui* gui = static_cast<GtkGui*>(data);
+
+#if GTK_CHECK_VERSION(2,4,0)
+    dialog = gtk_file_chooser_dialog_new ("Open file",
                                           NULL,
                                           GTK_FILE_CHOOSER_ACTION_OPEN,
                                           GTK_STOCK_CANCEL, 
GTK_RESPONSE_CANCEL,
@@ -371,18 +400,26 @@
                                           NULL);
     
     if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
-        char *filename;
-        
-        filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
-        dbglogfile << "File to open: " << filename << endl;
-        //Player.run(filename);
-        g_free (filename);
+        open_file(dialog, gui);
     }
     
     gtk_widget_destroy (dialog);
+#else
+    dialog = gtk_file_selection_new ("Open file");
     
-//  return filechooserdialog1;
-#endif
+    GtkFileSelection* selector = GTK_FILE_SELECTION(dialog);
+
+    g_signal_connect (selector->ok_button, "clicked", G_CALLBACK (open_file),
+                      gui);
+
+    g_signal_connect_swapped (selector->ok_button, "clicked", 
+                              G_CALLBACK (gtk_widget_destroy), dialog);
+
+    g_signal_connect_swapped (selector->cancel_button, "clicked",
+                              G_CALLBACK (gtk_widget_destroy), dialog); 
+   
+    gtk_widget_show (dialog);
+#endif // GTK_CHECK_VERSION(2,4,0)
 }
 
 /// \brief Show gnash preferences window
@@ -1348,6 +1385,4 @@
     gtk_widget_show(GTK_WIDGET(menuitem_jump_backward));
 }
 
-
-// end of namespace gnash
-}
+} // end of namespace gnash

Index: gui/gtksup.h
===================================================================
RCS file: /sources/gnash/gnash/gui/gtksup.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- gui/gtksup.h        18 Dec 2006 20:51:02 -0000      1.32
+++ gui/gtksup.h        10 Jan 2007 14:17:34 -0000      1.33
@@ -143,7 +143,7 @@
     GtkWidget   *_menubar;
     GtkWidget   *_vbox;
     geometry::Range2d<int> _drawbounds;
-    int valid_coord(int coord, int max);
+
 #ifdef RENDERER_CAIRO
     cairo_t     *_cairo_handle;
     GtkCairoGlue glue;
@@ -153,7 +153,11 @@
 #elif defined(RENDERER_AGG)
     GtkAggGlue  glue;
 #endif
+
     static gnash::key::code gdk_to_gnash_key(guint key);
+    static void             open_file(GtkWidget* dialog, gpointer data);
+
+    int    valid_coord(int coord, int max);
 };
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]