From: Robert Roebling <robert@roebling.de>
Date: Mon, 9 Apr 2001 17:16:09 +0000 (+0000)
Subject:   Added wxFileName::GetModificationTime()
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/ce16e5d78fad60b6bbc6ef8889a663fd1c9f23d2

  Added wxFileName::GetModificationTime()
    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
---

diff --git a/include/wx/filename.h b/include/wx/filename.h
index cf6cd1d18e..367ad81cbf 100644
--- a/include/wx/filename.h
+++ b/include/wx/filename.h
@@ -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
diff --git a/src/common/filename.cpp b/src/common/filename.cpp
index cf4867b024..041e24a1f4 100644
--- a/src/common/filename.cpp
+++ b/src/common/filename.cpp
@@ -48,6 +48,19 @@
 #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
 // ----------------------------------------------------------------------------
diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp
index ee8855a367..c525be6c9c 100644
--- a/src/gtk/textctrl.cpp
+++ b/src/gtk/textctrl.cpp
@@ -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() );
 
diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp
index ee8855a367..c525be6c9c 100644
--- a/src/gtk1/textctrl.cpp
+++ b/src/gtk1/textctrl.cpp
@@ -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() );