~darkxst/ubuntu/saucy/gnome-shell/upstart_log

« back to all changes in this revision

Viewing changes to src/shell-util.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-05-31 12:01:12 UTC
  • mfrom: (1.1.49) (19.1.36 experimental)
  • Revision ID: package-import@ubuntu.com-20130531120112-ew91khxf051x9i2r
Tags: 3.8.2-1ubuntu1
* Merge with Debian (LP: #1185869, #1185721). Remaining changes:
  - debian/control.in:
    + Build-depend on libsystemd-login-dev & libsystemd-daemon-dev
    + Depend on gdm instead of gdm3
    + Don't recommend gnome-session-fallback
  - debian/patches/40_change-pam-name-to-match-gdm.patch:
  - debian/patches/revert-suspend-break.patch:
    + Disabled, not needed on Ubuntu
  - debian/patches/ubuntu-lightdm-user-switching.patch:
    + Allow user switching when using LightDM. Thanks Gerhard Stein
      for rebasing against gnome-shell 3.8!
  - debian/patches/ubuntu_lock_on_suspend.patch
    + Respect Ubuntu's lock-on-suspend setting.
      Disabled until it can be rewritten.
  - debian/patches/git_relock_screen_after_crash.patch:
    + Add Upstream fix for unlocked session after crash (LP: #1064584)
* Note that the new GNOME Classic mode (which requires installing
  gnome-shell-extensions) won't work until gnome-session 3.8 is
  available in Ubuntu

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
#include <langinfo.h>
15
15
#endif
16
16
 
17
 
#ifdef WITH_SYSTEMD
18
 
#include <systemd/sd-daemon.h>
19
 
#include <systemd/sd-login.h>
20
 
#endif
21
 
 
22
17
static void
23
18
stop_pick (ClutterActor       *actor,
24
19
           const ClutterColor *color)
122
117
  if (str == NULL)
123
118
    return NULL;
124
119
 
 
120
  /* NOTE: 'ALL' is equivalent to 'NFKD'. If this is ever updated, please
 
121
   * update the unaccenting mechanism as well. */
125
122
  normalized = g_utf8_normalize (str, -1, G_NORMALIZE_ALL);
126
123
  result = g_utf8_casefold (normalized, -1);
127
124
  g_free (normalized);
128
125
  return result;
129
126
}
130
127
 
 
128
/* Combining diacritical mark?
 
129
 *  Basic range: [0x0300,0x036F]
 
130
 *  Supplement:  [0x1DC0,0x1DFF]
 
131
 *  For Symbols: [0x20D0,0x20FF]
 
132
 *  Half marks:  [0xFE20,0xFE2F]
 
133
 */
 
134
#define IS_CDM_UCS4(c) (((c) >= 0x0300 && (c) <= 0x036F)  || \
 
135
                        ((c) >= 0x1DC0 && (c) <= 0x1DFF)  || \
 
136
                        ((c) >= 0x20D0 && (c) <= 0x20FF)  || \
 
137
                        ((c) >= 0xFE20 && (c) <= 0xFE2F))
 
138
 
 
139
/* Copied from tracker/src/libtracker-fts/tracker-parser-glib.c under the GPL
 
140
 * Originally written by Aleksander Morgado <aleksander@gnu.org>
 
141
 */
 
142
char *
 
143
shell_util_normalize_casefold_and_unaccent (const char *str)
 
144
{
 
145
  char *tmp;
 
146
  gsize i = 0, j = 0, ilen;
 
147
 
 
148
  if (str == NULL)
 
149
    return NULL;
 
150
 
 
151
  /* Get the NFKD-normalized and casefolded string */
 
152
  tmp = shell_util_normalize_and_casefold (str);
 
153
  ilen = strlen (tmp);
 
154
 
 
155
  while (i < ilen)
 
156
    {
 
157
      gunichar unichar;
 
158
      gchar *next_utf8;
 
159
      gint utf8_len;
 
160
 
 
161
      /* Get next character of the word as UCS4 */
 
162
      unichar = g_utf8_get_char_validated (&tmp[i], -1);
 
163
 
 
164
      /* Invalid UTF-8 character or end of original string. */
 
165
      if (unichar == (gunichar) -1 ||
 
166
          unichar == (gunichar) -2)
 
167
        {
 
168
          break;
 
169
        }
 
170
 
 
171
      /* Find next UTF-8 character */
 
172
      next_utf8 = g_utf8_next_char (&tmp[i]);
 
173
      utf8_len = next_utf8 - &tmp[i];
 
174
 
 
175
      if (IS_CDM_UCS4 ((guint32) unichar))
 
176
        {
 
177
          /* If the given unichar is a combining diacritical mark,
 
178
           * just update the original index, not the output one */
 
179
          i += utf8_len;
 
180
          continue;
 
181
        }
 
182
 
 
183
      /* If already found a previous combining
 
184
       * diacritical mark, indexes are different so
 
185
       * need to copy characters. As output and input
 
186
       * buffers may overlap, need to use memmove
 
187
       * instead of memcpy */
 
188
      if (i != j)
 
189
        {
 
190
          memmove (&tmp[j], &tmp[i], utf8_len);
 
191
        }
 
192
 
 
193
      /* Update both indexes */
 
194
      i += utf8_len;
 
195
      j += utf8_len;
 
196
    }
 
197
 
 
198
  /* Force proper string end */
 
199
  tmp[j] = '\0';
 
200
 
 
201
  return tmp;
 
202
}
 
203
 
131
204
/**
132
205
 * shell_util_format_date:
133
206
 * @format: a strftime-style string format, as parsed by
278
351
}
279
352
 
280
353
/**
281
 
 * shell_session_is_active_for_systemd:
282
 
 *
283
 
 * Checks whether the session we are running in is currently active,
284
 
 * i.e. in the foreground and ready for user input.
285
 
 *
286
 
 * Returns: TRUE if session is active
287
 
 */
288
 
gboolean
289
 
shell_session_is_active_for_systemd (void)
290
 
{
291
 
  /* If this isn't systemd, let's assume the session is active. */
292
 
 
293
 
#ifdef WITH_SYSTEMD
294
 
  if (sd_booted () <= 0)
295
 
    return TRUE;
296
 
 
297
 
  return sd_session_is_active (NULL) != 0;
298
 
#else
299
 
  return TRUE;
300
 
#endif
301
 
}
302
 
 
303
 
/**
304
354
 * shell_util_wifexited:
305
355
 * @status: the status returned by wait() or waitpid()
306
356
 * @exit: (out): the actual exit status of the process