~ubuntu-branches/ubuntu/raring/gedit/raring

« back to all changes in this revision

Viewing changes to gedit/gedit-document.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2010-04-29 10:16:12 UTC
  • mfrom: (1.1.79 upstream)
  • Revision ID: james.westby@ubuntu.com-20100429101612-cawm9u2kja132bpc
Tags: 2.30.2-0ubuntu1
* New upstream release:
  - Fix cut and paste typo that broke syntax detection

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
#include "gedit-enum-types.h"
53
53
#include "gedittextregion.h"
54
54
 
55
 
#ifdef G_OS_WIN32
 
55
#ifndef ENABLE_GVFS_METADATA
56
56
#include "gedit-metadata-manager.h"
57
57
#else
58
58
#define METADATA_QUERY "metadata::*"
745
745
                GParamSpec    *pspec,
746
746
                gpointer       useless)
747
747
{
748
 
#ifndef G_OS_WIN32
 
748
#ifdef ENABLE_GVFS_METADATA
749
749
        GFile *location;
750
750
 
751
751
        location = gedit_document_get_location (doc);
1127
1127
}
1128
1128
 
1129
1129
/* Note: do not emit the notify::read-only signal */
1130
 
static void
 
1130
static gboolean
1131
1131
set_readonly (GeditDocument *doc,
1132
1132
              gboolean       readonly)
1133
1133
{
1134
1134
        gedit_debug (DEBUG_DOCUMENT);
1135
 
        
 
1135
 
1136
1136
        readonly = (readonly != FALSE);
1137
1137
 
1138
1138
        if (doc->priv->readonly == readonly) 
1139
 
                return;
 
1139
                return FALSE;
1140
1140
 
1141
1141
        doc->priv->readonly = readonly;
 
1142
 
 
1143
        return TRUE;
1142
1144
}
1143
1145
 
1144
1146
/**
1156
1158
 
1157
1159
        g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
1158
1160
 
1159
 
        set_readonly (doc, readonly);
1160
 
 
1161
 
        g_object_notify (G_OBJECT (doc), "read-only");
 
1161
        if (set_readonly (doc, readonly))
 
1162
        {
 
1163
                g_object_notify (G_OBJECT (doc), "read-only");
 
1164
        }
1162
1165
}
1163
1166
 
1164
1167
gboolean
1174
1177
{
1175
1178
        GFile *gfile;
1176
1179
        GFileInfo *info;
1177
 
        GTimeVal timeval;
1178
1180
 
1179
1181
        g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), FALSE);
1180
1182
 
1185
1187
 
1186
1188
        gfile = g_file_new_for_uri (doc->priv->uri);
1187
1189
        info = g_file_query_info (gfile,
1188
 
                                  G_FILE_ATTRIBUTE_TIME_MODIFIED,
 
1190
                                  G_FILE_ATTRIBUTE_TIME_MODIFIED "," \
 
1191
                                  G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
1189
1192
                                  G_FILE_QUERY_INFO_NONE,
1190
1193
                                  NULL, NULL);
1191
1194
        g_object_unref (gfile);
1192
1195
 
1193
 
        if (info == NULL ||
1194
 
            !g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
 
1196
        if (info != NULL)
1195
1197
        {
1196
 
                return FALSE;
 
1198
                /* While at it also check if permissions changed */
 
1199
                if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE))
 
1200
                {
 
1201
                        gboolean read_only;
 
1202
 
 
1203
                        read_only = !g_file_info_get_attribute_boolean (info,
 
1204
                                                                        G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
 
1205
 
 
1206
                        _gedit_document_set_readonly (doc, read_only);
 
1207
                }
 
1208
 
 
1209
                if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
 
1210
                {
 
1211
                        GTimeVal timeval;
 
1212
 
 
1213
                        g_file_info_get_modification_time (info, &timeval);
 
1214
                        g_object_unref (info);
 
1215
        
 
1216
                        return (timeval.tv_sec > doc->priv->mtime.tv_sec) ||
 
1217
                               (timeval.tv_sec == doc->priv->mtime.tv_sec && 
 
1218
                               timeval.tv_usec > doc->priv->mtime.tv_usec);
 
1219
                }
1197
1220
        }
1198
1221
 
1199
 
        g_file_info_get_modification_time (info, &timeval);
1200
 
        g_object_unref (info);
1201
 
        
1202
 
        return (timeval.tv_sec > doc->priv->mtime.tv_sec) ||
1203
 
               (timeval.tv_sec == doc->priv->mtime.tv_sec && 
1204
 
               timeval.tv_usec > doc->priv->mtime.tv_usec);
 
1222
        return FALSE;
1205
1223
}
1206
1224
 
1207
1225
static void
2553
2571
                                                           doc->priv->mount_operation_userdata);
2554
2572
}
2555
2573
 
2556
 
#ifdef G_OS_WIN32
 
2574
#ifndef ENABLE_GVFS_METADATA
2557
2575
gchar *
2558
2576
gedit_document_get_metadata (GeditDocument *doc,
2559
2577
                             const gchar   *key)
2563
2581
        g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), NULL);
2564
2582
        g_return_val_if_fail (key != NULL, NULL);
2565
2583
 
2566
 
        if (doc->priv->uri != NULL)
 
2584
        if (!gedit_document_is_untitled (doc))
 
2585
        {
2567
2586
                value = gedit_metadata_manager_get (doc->priv->uri, key);
 
2587
        }
2568
2588
 
2569
2589
        return value;
2570
2590
}
2581
2601
        g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
2582
2602
        g_return_if_fail (first_key != NULL);
2583
2603
 
 
2604
        if (gedit_document_is_untitled (doc))
 
2605
        {
 
2606
                /* Can't set metadata for untitled documents */
 
2607
                return;
 
2608
        }
 
2609
 
2584
2610
        va_start (var_args, first_key);
2585
2611
 
2586
2612
        for (key = first_key; key; key = va_arg (var_args, const gchar *))