~ubuntu-branches/ubuntu/trusty/gnome-shell/trusty-proposed

« back to all changes in this revision

Viewing changes to src/shell-util.c

Tags: upstream-3.3.90
ImportĀ upstreamĀ versionĀ 3.3.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
#include "config.h"
4
4
 
 
5
#include <sys/types.h>
 
6
#include <sys/wait.h>
 
7
 
5
8
#include "shell-util.h"
6
9
#include <glib/gi18n-lib.h>
7
10
#include <gtk/gtk.h>
14
17
#include <libxml/tree.h>
15
18
#include <libxml/xmlmemory.h>
16
19
 
 
20
#ifdef WITH_SYSTEMD
 
21
#include <systemd/sd-daemon.h>
 
22
#include <systemd/sd-login.h>
 
23
#endif
 
24
 
17
25
/* Some code in this file adapted under the GPLv2+ from:
18
26
 *
19
27
 * GNOME panel utils: gnome-panel/gnome-panel/panel-util.c
75
83
  return ret;
76
84
}
77
85
 
78
 
#define HOME_NAME_SCHEMA        "org.gnome.nautilus.desktop"
79
 
#define HOME_NAME_KEY           "home-icon-name"
80
86
static char *
81
87
shell_util_get_file_display_for_common_files (GFile *file)
82
88
{
85
91
  compare = g_file_new_for_path (g_get_home_dir ());
86
92
  if (g_file_equal (file, compare))
87
93
    {
88
 
      GSettings *settings;
89
 
      char *name;
90
 
 
91
94
      g_object_unref (compare);
92
 
 
93
 
      settings = g_settings_new (HOME_NAME_SCHEMA);
94
 
      name = g_settings_get_string (settings, HOME_NAME_KEY);
95
 
      g_object_unref (settings);
96
 
 
97
 
      if (!(name && name[0]))
98
 
        {
99
 
          g_free (name);
100
 
          return g_strdup (_("Home Folder"));
101
 
        }
102
 
      else
103
 
        {
104
 
          return name;
105
 
        }
 
95
      /* Translators: this is the same string as the one found in
 
96
       * nautilus */
 
97
      return g_strdup (_("Home"));
106
98
    }
107
 
  g_object_unref (compare);
108
99
 
109
100
  compare = g_file_new_for_path ("/");
110
101
  if (g_file_equal (file, compare))
696
687
}
697
688
 
698
689
/**
699
 
 * shell_breakpoint:
700
 
 *
701
 
 * Using G_BREAKPOINT(), interrupt the current process.  This is useful
702
 
 * in conjunction with a debugger such as gdb.
703
 
 */
704
 
void
705
 
shell_breakpoint (void)
706
 
{
707
 
  G_BREAKPOINT ();
708
 
}
709
 
 
710
 
/**
711
690
 * shell_parse_search_provider:
712
691
 * @data: description of provider
713
692
 * @name: (out): location to store a display name
862
841
                                           name,
863
842
                                           &gvalue);
864
843
}
 
844
 
 
845
/**
 
846
 * shell_session_is_active_for_systemd:
 
847
 *
 
848
 * Checks whether the session we are running in is currently active,
 
849
 * i.e. in the foreground and ready for user input.
 
850
 *
 
851
 * Returns: TRUE if session is active
 
852
 */
 
853
gboolean
 
854
shell_session_is_active_for_systemd (void)
 
855
{
 
856
  /* If this isn't systemd, let's assume the session is active. */
 
857
 
 
858
#ifdef WITH_SYSTEMD
 
859
  if (sd_booted () <= 0)
 
860
    return TRUE;
 
861
 
 
862
  return sd_session_is_active (NULL) != 0;
 
863
#else
 
864
  return TRUE;
 
865
#endif
 
866
}
 
867
 
 
868
/**
 
869
 * shell_util_wifexited:
 
870
 * @status: the status returned by wait() or waitpid()
 
871
 * @exit: (out): the actual exit status of the process
 
872
 *
 
873
 * Implements libc standard WIFEXITED, that cannot be used JS
 
874
 * code.
 
875
 * Returns: TRUE if the process exited normally, FALSE otherwise
 
876
 */
 
877
gboolean
 
878
shell_util_wifexited (int  status,
 
879
                      int *exit)
 
880
{
 
881
  gboolean ret;
 
882
 
 
883
  ret = WIFEXITED(status);
 
884
 
 
885
  if (ret)
 
886
    *exit = WEXITSTATUS(status);
 
887
 
 
888
  return ret;
 
889
}