]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-chat-text-view.c
individual_view_drag_end: remove the auto scroll
[empathy.git] / libempathy-gtk / empathy-chat-text-view.c
index b58fbc23934e16365285151db142ddd1b293730b..60d642ccb7bb84c9e7c1f0175980023f4eb3f978 100644 (file)
@@ -48,7 +48,7 @@
 #include <libempathy/empathy-debug.h>
 
 /* Number of seconds between timestamps when using normal mode, 5 minutes. */
-#define TIMESTAMP_INTERVAL 300
+#define TIMESTAMP_INTERVAL (5 * G_TIME_SPAN_MINUTE)
 
 #define MAX_LINES 800
 #define MAX_SCROLL_TIME 0.4 /* seconds */
@@ -65,7 +65,7 @@ typedef struct {
        gboolean              find_wrapped;
        gboolean              find_last_direction;
        EmpathyContact       *last_contact;
-       time_t                last_timestamp;
+       gint64                last_timestamp;
        gboolean              allow_scrolling;
        guint                 notify_system_fonts_id;
        GSettings            *gsettings_desktop;
@@ -151,7 +151,7 @@ chat_text_view_event_cb (EmpathyChatTextView *view,
                return FALSE;
        }
 
-       gdk_window_get_pointer (win, &x, &y, NULL);
+       gdk_window_get_device_position (win, event->device, &x, &y, NULL);
 
        /* Get the iter where the cursor is at */
        gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (view), type,
@@ -286,7 +286,9 @@ chat_text_view_populate_popup (EmpathyChatTextView *view,
        table = gtk_text_buffer_get_tag_table (priv->buffer);
        tag = gtk_text_tag_table_lookup (table, EMPATHY_CHAT_TEXT_VIEW_TAG_LINK);
 
-       gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y);
+       gdk_window_get_device_position (gtk_widget_get_window (GTK_WIDGET (view)),
+               gdk_device_manager_get_client_pointer (gdk_display_get_device_manager (
+                       gtk_widget_get_display (GTK_WIDGET (view)))), &x, &y, NULL);
 
        gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (view),
                                               GTK_TEXT_WINDOW_WIDGET,
@@ -398,7 +400,7 @@ chat_text_view_maybe_trim_buffer (EmpathyChatTextView *view)
 
 static void
 chat_text_view_append_timestamp (EmpathyChatTextView *view,
-                                time_t               timestamp,
+                                gint64               timestamp,
                                 gboolean             show_date)
 {
        EmpathyChatTextViewPriv *priv = GET_PRIV (view);
@@ -410,17 +412,12 @@ chat_text_view_append_timestamp (EmpathyChatTextView *view,
 
        /* Append date if needed */
        if (show_date) {
-               GDate *date;
-               gchar  buf[256];
-
-               date = g_date_new ();
-               g_date_set_time_t (date, timestamp);
                /* Translators: timestamp displayed between conversations in
                 * chat windows (strftime format string) */
-               g_date_strftime (buf, 256, _("%A %B %d %Y"), date);
-               g_string_append (str, buf);
+               tmp = empathy_time_to_string_utc (timestamp, _("%A %B %d %Y"));
+               g_string_append (str, tmp);
                g_string_append (str, ", ");
-               g_date_free (date);
+               g_free (tmp);
        }
 
        /* Append time */
@@ -444,32 +441,32 @@ chat_text_view_append_timestamp (EmpathyChatTextView *view,
 
 static void
 chat_text_maybe_append_date_and_time (EmpathyChatTextView *view,
-                                     time_t               timestamp)
+                                     gint64               timestamp)
 {
        EmpathyChatTextViewPriv *priv = GET_PRIV (view);
-       GDate                   *date, *last_date;
+       GDateTime               *date, *last_date;
        gboolean                 append_date = FALSE;
        gboolean                 append_time = FALSE;
+       GTimeSpan                delta;
 
        /* Get the date from last message */
-       last_date = g_date_new ();
-       g_date_set_time_t (last_date, priv->last_timestamp);
+       last_date = g_date_time_new_from_unix_utc (priv->last_timestamp);
 
        /* Get the date of the message we are appending */
-       date = g_date_new ();
-       g_date_set_time_t (date, timestamp);
+       date = g_date_time_new_from_unix_utc (timestamp);
 
+       delta = g_date_time_difference (date, last_date);
        /* If last message was from another day we append date and time */
-       if (g_date_compare (date, last_date) > 0) {
+       if (delta >= G_TIME_SPAN_DAY) {
                append_date = TRUE;
                append_time = TRUE;
        }
 
-       g_date_free (last_date);
-       g_date_free (date);
+       g_date_time_unref (last_date);
+       g_date_time_unref (date);
 
        /* If last message is 'old' append the time */
-       if (timestamp - priv->last_timestamp >= TIMESTAMP_INTERVAL) {
+       if (delta >= TIMESTAMP_INTERVAL) {
                append_time = TRUE;
        }
 
@@ -720,12 +717,13 @@ chat_text_view_scroll_down (EmpathyChatView *view)
 
 static void
 chat_text_view_append_message (EmpathyChatView *view,
-                              EmpathyMessage  *msg)
+                              EmpathyMessage  *msg,
+                              gboolean         should_highlight)
 {
        EmpathyChatTextView     *text_view = EMPATHY_CHAT_TEXT_VIEW (view);
        EmpathyChatTextViewPriv *priv = GET_PRIV (text_view);
        gboolean                 bottom;
-       time_t                   timestamp;
+       gint64                   timestamp;
 
        g_return_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view));
        g_return_if_fail (EMPATHY_IS_MESSAGE (msg));
@@ -742,7 +740,8 @@ chat_text_view_append_message (EmpathyChatView *view,
        chat_text_maybe_append_date_and_time (text_view, timestamp);
        if (EMPATHY_CHAT_TEXT_VIEW_GET_CLASS (view)->append_message) {
                EMPATHY_CHAT_TEXT_VIEW_GET_CLASS (view)->append_message (text_view,
-                                                                        msg);
+                                                                        msg,
+                                                                        should_highlight);
        }
 
        if (bottom) {
@@ -1320,7 +1319,7 @@ empathy_chat_text_view_get_last_contact (EmpathyChatTextView *view)
        return priv->last_contact;
 }
 
-time_t
+gint64
 empathy_chat_text_view_get_last_timestamp (EmpathyChatTextView *view)
 {
        EmpathyChatTextViewPriv *priv = GET_PRIV (view);