]> git.saurik.com Git - wxWidgets.git/commitdiff
Added wxFileName::GetModificationTime()
authorRobert Roebling <robert@roebling.de>
Mon, 9 Apr 2001 17:16:09 +0000 (17:16 +0000)
committerRobert Roebling <robert@roebling.de>
Mon, 9 Apr 2001 17:16:09 +0000 (17:16 +0000)
    for Unix.
  Don't send events when constructing a text ctrl.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9691 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/filename.h
src/common/filename.cpp
src/gtk/textctrl.cpp
src/gtk1/textctrl.cpp

index cf6cd1d18e74fb6a43d84019d1a7ae83c1babe05..367ad81cbfd7ae197683ff12d64c40c29c700e4a 100644 (file)
@@ -36,6 +36,7 @@
 
 // ridiculously enough, this will replace DirExists with wxDirExists etc
 #include "wx/filefn.h"
+#include "wx/datetime.h"
 
 // ----------------------------------------------------------------------------
 // constants
@@ -147,6 +148,9 @@ public:
     bool DirExists();
     static bool DirExists( const wxString &dir );
 
+        // Well, get modification time with sec resolution
+    wxDateTime GetModificationTime();
+    
         // VZ: also need: IsDirWritable(), IsFileExecutable() &c (TODO)
 
     // various file/dir operations
index cf4867b024d762fdacb04dc5164aad0fa9f0c936..041e24a1f45c0b24afe6f02f6a6f71a689208fab 100644 (file)
 #include "wx/msw/winundef.h"
 #endif
 
+// at least some of these are required for file mod time
+#ifdef __WXGTK__
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <pwd.h>
+#ifndef __VMS
+# include <grp.h>
+#endif
+# include <time.h>
+#include <unistd.h>
+#endif
+
 // ============================================================================
 // implementation
 // ============================================================================
@@ -152,6 +165,29 @@ bool wxFileName::DirExists( const wxString &dir )
     return ::wxDirExists( dir );
 }
 
+wxDateTime wxFileName::GetModificationTime()
+{
+#ifdef __WXGTK__
+    struct stat buff;
+    stat( GetFullName().fn_str(), &buff );
+
+#if !defined( __EMX__ ) && !defined(__VMS)
+    struct stat lbuff;
+    lstat( GetFullName().fn_str(), &lbuff );
+    struct tm *t = localtime( &lbuff.st_mtime );
+#else
+    struct tm *t = localtime( &buff.st_mtime );
+#endif
+
+    wxDateTime ret( t->tm_mday, (wxDateTime::Month)t->tm_mon, t->tm_year+1900, t->tm_hour, t->tm_min, t->tm_sec );
+#else
+    
+    wxDateTime ret = wxDateTime::Now();
+
+#endif
+    return ret;
+}
+
 // ----------------------------------------------------------------------------
 // CWD and HOME stuff
 // ----------------------------------------------------------------------------
index ee8855a367b89d9ab58c46b6e83dcfeea1639df5..c525be6c9c14d736179c88565927e77ede32238e 100644 (file)
@@ -327,10 +327,6 @@ bool wxTextCtrl::Create( wxWindow *parent,
     if (multi_line)
         gtk_widget_show(m_text);
 
-    /* we want to be notified about text changes */
-    gtk_signal_connect( GTK_OBJECT(m_text), "changed",
-      GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
-
     if (multi_line)
     {
         gtk_signal_connect(GTK_OBJECT(GTK_TEXT(m_text)->vadj), "changed",
@@ -393,6 +389,10 @@ bool wxTextCtrl::Create( wxWindow *parent,
             gtk_text_set_editable( GTK_TEXT(m_text), 1 );
     }
 
+    /* we want to be notified about text changes */
+    gtk_signal_connect( GTK_OBJECT(m_text), "changed",
+      GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
+
     SetBackgroundColour( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) );
     SetForegroundColour( parent->GetForegroundColour() );
 
index ee8855a367b89d9ab58c46b6e83dcfeea1639df5..c525be6c9c14d736179c88565927e77ede32238e 100644 (file)
@@ -327,10 +327,6 @@ bool wxTextCtrl::Create( wxWindow *parent,
     if (multi_line)
         gtk_widget_show(m_text);
 
-    /* we want to be notified about text changes */
-    gtk_signal_connect( GTK_OBJECT(m_text), "changed",
-      GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
-
     if (multi_line)
     {
         gtk_signal_connect(GTK_OBJECT(GTK_TEXT(m_text)->vadj), "changed",
@@ -393,6 +389,10 @@ bool wxTextCtrl::Create( wxWindow *parent,
             gtk_text_set_editable( GTK_TEXT(m_text), 1 );
     }
 
+    /* we want to be notified about text changes */
+    gtk_signal_connect( GTK_OBJECT(m_text), "changed",
+      GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
+
     SetBackgroundColour( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) );
     SetForegroundColour( parent->GetForegroundColour() );