mate-desktop 1.29.2
Library with common API for various MATE modules
Loading...
Searching...
No Matches
mate-desktop-item.c File Reference
View source
#include "config.h"
#include <limits.h>
#include <ctype.h>
#include <stdio.h>
#include <glib.h>
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
#include <time.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <locale.h>
#include <stdlib.h>
#include <gio/gio.h>
#include <mate-desktop-item.h>
#include <mate-desktop-utils.h>
#include "private.h"
Include dependency graph for mate-desktop-item.c:

Data Structures

struct  _MateDesktopItem
 
struct  Section
 
struct  ReadBuf
 

Macros

#define MATE_DESKTOP_USE_UNSTABLE_API
 
#define DONT_UPDATE_MTIME   ((gint64)-2)
 
#define READ_BUF_SIZE   (32 * 1024)
 
#define OVERFLOW   (next == &CharBuffer [sizeof(CharBuffer)-1])
 

Enumerations

enum  Encoding { ENCODING_UNKNOWN , ENCODING_UTF8 , ENCODING_LEGACY_MIXED }
 
enum  ConversionType { URI_TO_STRING , URI_TO_LOCAL_PATH , URI_TO_LOCAL_DIRNAME , URI_TO_LOCAL_BASENAME }
 
enum  AddedStatus { ADDED_NONE = 0 , ADDED_SINGLE , ADDED_ALL }
 
enum  {
  FirstBrace , OnSecHeader , IgnoreToEOL , IgnoreToEOLFirst ,
  KeyDef , KeyDefOnKey , KeyValue
}
 

Functions

static MateDesktopItem * ditem_load (ReadBuf *rb, gboolean no_translations, GError **error)
 
static gboolean ditem_save (MateDesktopItem *item, const char *uri, GError **error)
 
static void mate_desktop_item_set_location_gfile (MateDesktopItem *item, GFile *file)
 
static MateDesktopItem * mate_desktop_item_new_from_gfile (GFile *file, MateDesktopItemLoadFlags flags, GError **error)
 
static int readbuf_getc (ReadBuf *rb)
 
static char * readbuf_gets (char *buf, gsize bufsize, ReadBuf *rb)
 
static ReadBuf * readbuf_open (GFile *file, GError **error)
 
static ReadBuf * readbuf_new_from_string (const char *uri, const char *string, gssize length)
 
static gboolean readbuf_rewind (ReadBuf *rb, GError **error)
 
static void readbuf_close (ReadBuf *rb)
 
static MateDesktopItemType type_from_string (const char *type)
 
MateDesktopItem * mate_desktop_item_new (void)
 mate_desktop_item_new:
 
static Section * dup_section (Section *sec)
 
static void copy_string_hash (gpointer key, gpointer value, gpointer user_data)
 
MateDesktopItem * mate_desktop_item_copy (const MateDesktopItem *item)
 mate_desktop_item_copy: @item: The item to be copied
 
static void read_sort_order (MateDesktopItem *item, GFile *dir)
 
static MateDesktopItem * make_fake_directory (GFile *dir)
 
MateDesktopItem * mate_desktop_item_new_from_file (const char *file, MateDesktopItemLoadFlags flags, GError **error)
 
MateDesktopItem * mate_desktop_item_new_from_uri (const char *uri, MateDesktopItemLoadFlags flags, GError **error)
 mate_desktop_item_new_from_uri: @uri: URI to load the MateDesktopItem from @flags: Flags to influence the loading process
 
MateDesktopItem * mate_desktop_item_new_from_string (const char *uri, const char *string, gssize length, MateDesktopItemLoadFlags flags, GError **error)
 mate_desktop_item_new_from_string: @string: string to load the MateDesktopItem from @length: length of string, or -1 to use strlen @flags: Flags to influence the loading process @error: place to put errors
 
static char * lookup_desktop_file_in_data_dir (const char *desktop_file, const char *data_dir)
 
static char * file_from_basename (const char *basename)
 
MateDesktopItem * mate_desktop_item_new_from_basename (const char *basename, MateDesktopItemLoadFlags flags, GError **error)
 mate_desktop_item_new_from_basename: @basename: The basename of the MateDesktopItem to load.
 
gboolean mate_desktop_item_save (MateDesktopItem *item, const char *under, gboolean force, GError **error)
 mate_desktop_item_save: @item: A desktop item @under: A new uri (location) for this MateDesktopItem @force: Save even if it wasn't modified @error: #GError return
 
MateDesktopItem * mate_desktop_item_ref (MateDesktopItem *item)
 mate_desktop_item_ref: @item: A desktop item
 
static void free_section (gpointer data)
 
void mate_desktop_item_unref (MateDesktopItem *item)
 mate_desktop_item_unref: @item: A desktop item
 
static Section * find_section (MateDesktopItem *item, const char *section)
 
static Section * section_from_key (MateDesktopItem *item, const char *key)
 
static const char * key_basename (const char *key)
 
static const char * lookup (const MateDesktopItem *item, const char *key)
 
static const char * lookup_locale (const MateDesktopItem *item, const char *key, const char *locale)
 
static const char * lookup_best_locale (const MateDesktopItem *item, const char *key)
 
static void set (MateDesktopItem *item, const char *key, const char *value)
 
static void set_locale (MateDesktopItem *item, const char *key, const char *locale, const char *value)
 
static char ** list_to_vector (GSList *list)
 
static GSList * make_args (GList *files)
 
static void free_args (GSList *list)
 
static char * escape_single_quotes (const char *s, gboolean in_single_quotes, gboolean in_double_quotes)
 
static char * convert_uri (GFile *file, ConversionType conversion)
 
static AddedStatus append_all_converted (GString *str, ConversionType conversion, GSList *args, gboolean in_single_quotes, gboolean in_double_quotes, AddedStatus added_status)
 
static AddedStatus append_first_converted (GString *str, ConversionType conversion, GSList **arg_ptr, gboolean in_single_quotes, gboolean in_double_quotes, AddedStatus added_status)
 
static gboolean do_percent_subst (const MateDesktopItem *item, const char *arg, GString *str, gboolean in_single_quotes, gboolean in_double_quotes, GSList *args, GSList **arg_ptr, AddedStatus *added_status)
 
static char * expand_string (const MateDesktopItem *item, const char *s, GSList *args, GSList **arg_ptr, AddedStatus *added_status)
 
static char * stringify_uris (GSList *args)
 
static char * stringify_files (GSList *args)
 
static char ** make_environment_for_screen (GdkScreen *screen, char **envp)
 
static void dummy_child_watch (GPid pid, gint status, gpointer user_data)
 
static int ditem_execute (const MateDesktopItem *item, const char *exec, GList *file_list, GdkScreen *screen, int workspace, char **envp, gboolean launch_only_one, gboolean use_current_dir, gboolean append_uris, gboolean append_paths, gboolean do_not_reap_child, GError **error)
 
static gboolean strip_the_amp (char *exec)
 
static int mate_desktop_item_launch_on_screen_with_env (const MateDesktopItem *item, GList *file_list, MateDesktopItemLaunchFlags flags, GdkScreen *screen, int workspace, char **envp, GError **error)
 
int mate_desktop_item_launch (const MateDesktopItem *item, GList *file_list, MateDesktopItemLaunchFlags flags, GError **error)
 mate_desktop_item_launch: @item: A desktop item @file_list: Files/URIs to launch this item with, can be NULL @flags: FIXME @error: FIXME
 
int mate_desktop_item_launch_with_env (const MateDesktopItem *item, GList *file_list, MateDesktopItemLaunchFlags flags, char **envp, GError **error)
 mate_desktop_item_launch_with_env: @item: A desktop item @file_list: Files/URIs to launch this item with, can be NULL @flags: FIXME @envp: child's environment, or NULL to inherit parent's @error: FIXME
 
int mate_desktop_item_launch_on_screen (const MateDesktopItem *item, GList *file_list, MateDesktopItemLaunchFlags flags, GdkScreen *screen, int workspace, GError **error)
 mate_desktop_item_launch_on_screen: @item: A desktop item @file_list: Files/URIs to launch this item with, can be NULL @flags: FIXME @screen: the GdkScreen on which the application should be launched @workspace: the workspace on which the app should be launched (-1 for current) @error: FIXME
 
int mate_desktop_item_drop_uri_list (const MateDesktopItem *item, const char *uri_list, MateDesktopItemLaunchFlags flags, GError **error)
 mate_desktop_item_drop_uri_list: @item: A desktop item @uri_list: text as gotten from a text/uri-list @flags: FIXME @error: FIXME
 
int mate_desktop_item_drop_uri_list_with_env (const MateDesktopItem *item, const char *uri_list, MateDesktopItemLaunchFlags flags, char **envp, GError **error)
 mate_desktop_item_drop_uri_list_with_env: @item: A desktop item @uri_list: text as gotten from a text/uri-list @flags: FIXME @envp: child's environment @error: FIXME
 
static gboolean exec_exists (const char *exec)
 
gboolean mate_desktop_item_exists (const MateDesktopItem *item)
 mate_desktop_item_exists: @item: A desktop item
 
MateDesktopItemType mate_desktop_item_get_entry_type (const MateDesktopItem *item)
 mate_desktop_item_get_entry_type: @item: A desktop item
 
void mate_desktop_item_set_entry_type (MateDesktopItem *item, MateDesktopItemType type)
 
MateDesktopItemStatus mate_desktop_item_get_file_status (const MateDesktopItem *item)
 mate_desktop_item_get_file_status: @item: A desktop item
 
char * mate_desktop_item_find_icon (GtkIconTheme *icon_theme, const char *icon, int desired_size, int flags)
 mate_desktop_item_find_icon: @icon_theme: a #GtkIconTheme @icon: icon name, something you'd get out of the Icon key @desired_size: FIXME @flags: FIXME
 
char * mate_desktop_item_get_icon (const MateDesktopItem *item, GtkIconTheme *icon_theme)
 mate_desktop_item_get_icon: @icon_theme: a #GtkIconTheme @item: A desktop item
 
const char * mate_desktop_item_get_location (const MateDesktopItem *item)
 mate_desktop_item_get_location: @item: A desktop item
 
void mate_desktop_item_set_location (MateDesktopItem *item, const char *location)
 mate_desktop_item_set_location: @item: A desktop item @location: A uri string specifying the file location of this particular item.
 
void mate_desktop_item_set_location_file (MateDesktopItem *item, const char *file)
 
gboolean mate_desktop_item_attr_exists (const MateDesktopItem *item, const char *attr)
 
const char * mate_desktop_item_get_string (const MateDesktopItem *item, const char *attr)
 
void mate_desktop_item_set_string (MateDesktopItem *item, const char *attr, const char *value)
 
const char * mate_desktop_item_get_localestring (const MateDesktopItem *item, const char *attr)
 
const char * mate_desktop_item_get_localestring_lang (const MateDesktopItem *item, const char *attr, const char *language)
 
const char * mate_desktop_item_get_attr_locale (const MateDesktopItem *item, const char *attr)
 mate_desktop_item_get_string_locale: @item: A desktop item @attr: An attribute name
 
GList * mate_desktop_item_get_languages (const MateDesktopItem *item, const char *attr)
 
static const char * get_language (void)
 
void mate_desktop_item_set_localestring (MateDesktopItem *item, const char *attr, const char *value)
 
void mate_desktop_item_set_localestring_lang (MateDesktopItem *item, const char *attr, const char *language, const char *value)
 
void mate_desktop_item_clear_localestring (MateDesktopItem *item, const char *attr)
 
char ** mate_desktop_item_get_strings (const MateDesktopItem *item, const char *attr)
 
void mate_desktop_item_set_strings (MateDesktopItem *item, const char *attr, char **strings)
 
gboolean mate_desktop_item_get_boolean (const MateDesktopItem *item, const char *attr)
 
void mate_desktop_item_set_boolean (MateDesktopItem *item, const char *attr, gboolean value)
 
void mate_desktop_item_set_launch_time (MateDesktopItem *item, guint32 timestamp)
 
void mate_desktop_item_clear_section (MateDesktopItem *item, const char *section)
 
static gboolean standard_is_boolean (const char *key)
 
static gboolean standard_is_strings (const char *key)
 
static char * cannonize (const char *key, const char *value)
 
static char * decode_string_and_dup (const char *s)
 
static char * escape_string_and_dup (const char *s)
 
static gboolean check_locale (const char *locale)
 
static void insert_locales (GHashTable *encodings, char *enc,...)
 
static GHashTable * init_encodings (void)
 
static const char * get_encoding_from_locale (const char *locale)
 
static Encoding get_encoding (ReadBuf *rb)
 
static char * decode_string (const char *value, Encoding encoding, const char *locale)
 
static char * snarf_locale_from_key (const char *key)
 
static void insert_key (MateDesktopItem *item, Section *cur_section, Encoding encoding, const char *key, const char *value, gboolean old_kde, gboolean no_translations)
 
static void setup_type (MateDesktopItem *item, const char *uri)
 
static char * try_english_key (MateDesktopItem *item, const char *key)
 
static void sanitize (MateDesktopItem *item, const char *uri)
 
static void stream_printf (GFileOutputStream *stream, const char *format,...)
 
static void dump_section (MateDesktopItem *item, GFileOutputStream *stream, Section *section)
 
static gpointer _mate_desktop_item_copy (gpointer boxed)
 
static void _mate_desktop_item_free (gpointer boxed)
 
GType mate_desktop_item_get_type (void)
 
GQuark mate_desktop_item_error_quark (void)
 

Macro Definition Documentation

◆ DONT_UPDATE_MTIME

#define DONT_UPDATE_MTIME   ((gint64)-2)

◆ MATE_DESKTOP_USE_UNSTABLE_API

#define MATE_DESKTOP_USE_UNSTABLE_API

◆ OVERFLOW

#define OVERFLOW   (next == &CharBuffer [sizeof(CharBuffer)-1])

◆ READ_BUF_SIZE

#define READ_BUF_SIZE   (32 * 1024)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
FirstBrace 
OnSecHeader 
IgnoreToEOL 
IgnoreToEOLFirst 
KeyDef 
KeyDefOnKey 
KeyValue 

◆ AddedStatus

Enumerator
ADDED_NONE 
ADDED_SINGLE 
ADDED_ALL 

◆ ConversionType

Enumerator
URI_TO_STRING 
URI_TO_LOCAL_PATH 
URI_TO_LOCAL_DIRNAME 
URI_TO_LOCAL_BASENAME 

◆ Encoding

enum Encoding
Enumerator
ENCODING_UNKNOWN 
ENCODING_UTF8 
ENCODING_LEGACY_MIXED 

Function Documentation

◆ _mate_desktop_item_copy()

static gpointer _mate_desktop_item_copy ( gpointer  boxed)
static

References mate_desktop_item_copy().

Referenced by mate_desktop_item_get_type().

Here is the call graph for this function:

◆ _mate_desktop_item_free()

static void _mate_desktop_item_free ( gpointer  boxed)
static

References mate_desktop_item_unref().

Referenced by mate_desktop_item_get_type().

Here is the call graph for this function:

◆ append_all_converted()

static AddedStatus append_all_converted ( GString *  str,
ConversionType  conversion,
GSList *  args,
gboolean  in_single_quotes,
gboolean  in_double_quotes,
AddedStatus  added_status 
)
static

References ADDED_ALL, convert_uri(), and escape_single_quotes().

Referenced by do_percent_subst(), stringify_files(), and stringify_uris().

Here is the call graph for this function:

◆ append_first_converted()

static AddedStatus append_first_converted ( GString *  str,
ConversionType  conversion,
GSList **  arg_ptr,
gboolean  in_single_quotes,
gboolean  in_double_quotes,
AddedStatus  added_status 
)
static

References ADDED_ALL, ADDED_SINGLE, convert_uri(), and escape_single_quotes().

Referenced by do_percent_subst().

Here is the call graph for this function:

◆ cannonize()

static char * cannonize ( const char *  key,
const char *  value 
)
static

References standard_is_boolean(), and standard_is_strings().

Referenced by insert_key().

Here is the call graph for this function:

◆ check_locale()

static gboolean check_locale ( const char *  locale)
static

Referenced by init_encodings().

◆ convert_uri()

static char * convert_uri ( GFile *  file,
ConversionType  conversion 
)
static

◆ copy_string_hash()

static void copy_string_hash ( gpointer  key,
gpointer  value,
gpointer  user_data 
)
static

Referenced by mate_desktop_item_copy().

◆ decode_string()

static char * decode_string ( const char *  value,
Encoding  encoding,
const char *  locale 
)
static

References decode_string_and_dup(), ENCODING_LEGACY_MIXED, ENCODING_UTF8, and get_encoding_from_locale().

Referenced by insert_key().

Here is the call graph for this function:

◆ decode_string_and_dup()

static char * decode_string_and_dup ( const char *  s)
static

Referenced by decode_string().

◆ ditem_execute()

static int ditem_execute ( const MateDesktopItem *  item,
const char *  exec,
GList *  file_list,
GdkScreen *  screen,
int  workspace,
char **  envp,
gboolean  launch_only_one,
gboolean  use_current_dir,
gboolean  append_uris,
gboolean  append_paths,
gboolean  do_not_reap_child,
GError **  error 
)
static

◆ ditem_load()

◆ ditem_save()

static gboolean ditem_save ( MateDesktopItem *  item,
const char *  uri,
GError **  error 
)
static

References dump_section(), escape_string_and_dup(), _MateDesktopItem::keys, Section::keys, _MateDesktopItem::main_hash, _MateDesktopItem::sections, and stream_printf().

Referenced by mate_desktop_item_save().

Here is the call graph for this function:

◆ do_percent_subst()

static gboolean do_percent_subst ( const MateDesktopItem *  item,
const char *  arg,
GString *  str,
gboolean  in_single_quotes,
gboolean  in_double_quotes,
GSList *  args,
GSList **  arg_ptr,
AddedStatus *  added_status 
)
static

◆ dummy_child_watch()

static void dummy_child_watch ( GPid  pid,
gint  status,
gpointer  user_data 
)
static

Referenced by ditem_execute().

◆ dump_section()

static void dump_section ( MateDesktopItem *  item,
GFileOutputStream *  stream,
Section *  section 
)
static

References escape_string_and_dup(), Section::keys, _MateDesktopItem::main_hash, Section::name, and stream_printf().

Referenced by ditem_save().

Here is the call graph for this function:

◆ dup_section()

static Section * dup_section ( Section *  sec)
static

References Section::keys, and Section::name.

Referenced by mate_desktop_item_copy().

◆ escape_single_quotes()

static char * escape_single_quotes ( const char *  s,
gboolean  in_single_quotes,
gboolean  in_double_quotes 
)
static

◆ escape_string_and_dup()

static char * escape_string_and_dup ( const char *  s)
static

Referenced by ditem_save(), and dump_section().

◆ exec_exists()

static gboolean exec_exists ( const char *  exec)
static

◆ expand_string()

static char * expand_string ( const MateDesktopItem *  item,
const char *  s,
GSList *  args,
GSList **  arg_ptr,
AddedStatus *  added_status 
)
static

References do_percent_subst().

Referenced by ditem_execute().

Here is the call graph for this function:

◆ file_from_basename()

static char * file_from_basename ( const char *  basename)
static

References lookup_desktop_file_in_data_dir().

Referenced by mate_desktop_item_new_from_basename().

Here is the call graph for this function:

◆ find_section()

static Section * find_section ( MateDesktopItem *  item,
const char *  section 
)
static

◆ free_args()

static void free_args ( GSList *  list)
static

Referenced by ditem_execute().

◆ free_section()

static void free_section ( gpointer  data)
static

References Section::keys, and Section::name.

Referenced by mate_desktop_item_unref().

◆ get_encoding()

static Encoding get_encoding ( ReadBuf *  rb)
static

References ENCODING_LEGACY_MIXED, ENCODING_UNKNOWN, ENCODING_UTF8, MATE_DESKTOP_ITEM_ENCODING, readbuf_gets(), and ReadBuf::uri.

Referenced by ditem_load().

Here is the call graph for this function:

◆ get_encoding_from_locale()

static const char * get_encoding_from_locale ( const char *  locale)
static

References init_encodings().

Referenced by decode_string().

Here is the call graph for this function:

◆ get_language()

static const char * get_language ( void  )
static

◆ init_encodings()

static GHashTable * init_encodings ( void  )
static

References check_locale(), and insert_locales().

Referenced by get_encoding_from_locale().

Here is the call graph for this function:

◆ insert_key()

static void insert_key ( MateDesktopItem *  item,
Section *  cur_section,
Encoding  encoding,
const char *  key,
const char *  value,
gboolean  old_kde,
gboolean  no_translations 
)
static

References cannonize(), decode_string(), _MateDesktopItem::keys, Section::keys, _MateDesktopItem::languages, _MateDesktopItem::main_hash, MATE_DESKTOP_ITEM_ENCODING, MATE_DESKTOP_ITEM_SORT_ORDER, Section::name, and snarf_locale_from_key().

Referenced by ditem_load().

Here is the call graph for this function:

◆ insert_locales()

static void insert_locales ( GHashTable *  encodings,
char *  enc,
  ... 
)
static

Referenced by init_encodings().

◆ key_basename()

static const char * key_basename ( const char *  key)
static

Referenced by set().

◆ list_to_vector()

static char ** list_to_vector ( GSList *  list)
static

Referenced by ditem_execute().

◆ lookup()

◆ lookup_best_locale()

static const char * lookup_best_locale ( const MateDesktopItem *  item,
const char *  key 
)
static

References lookup_locale().

Referenced by mate_desktop_item_get_localestring().

Here is the call graph for this function:

◆ lookup_desktop_file_in_data_dir()

static char * lookup_desktop_file_in_data_dir ( const char *  desktop_file,
const char *  data_dir 
)
static

Referenced by file_from_basename().

◆ lookup_locale()

static const char * lookup_locale ( const MateDesktopItem *  item,
const char *  key,
const char *  locale 
)
static

References lookup().

Referenced by lookup_best_locale(), mate_desktop_item_get_attr_locale(), mate_desktop_item_get_languages(), mate_desktop_item_get_localestring_lang(), and try_english_key().

Here is the call graph for this function:

◆ make_args()

static GSList * make_args ( GList *  files)
static

Referenced by ditem_execute().

◆ make_environment_for_screen()

static char ** make_environment_for_screen ( GdkScreen *  screen,
char **  envp 
)
static

Referenced by ditem_execute().

◆ make_fake_directory()

static MateDesktopItem * make_fake_directory ( GFile *  dir)
static

References DONT_UPDATE_MTIME, mate_desktop_item_new(), mate_desktop_item_set_entry_type(), mate_desktop_item_set_location_gfile(), MATE_DESKTOP_ITEM_TYPE_DIRECTORY, _MateDesktopItem::mtime, and read_sort_order().

Referenced by mate_desktop_item_new_from_gfile().

Here is the call graph for this function:

◆ mate_desktop_item_attr_exists()

gboolean mate_desktop_item_attr_exists ( const MateDesktopItem *  item,
const char *  attr 
)

References lookup(), and _MateDesktopItem::refcount.

Here is the call graph for this function:

◆ mate_desktop_item_clear_localestring()

void mate_desktop_item_clear_localestring ( MateDesktopItem *  item,
const char *  attr 
)

References _MateDesktopItem::languages, _MateDesktopItem::refcount, set(), and set_locale().

Here is the call graph for this function:

◆ mate_desktop_item_clear_section()

void mate_desktop_item_clear_section ( MateDesktopItem *  item,
const char *  section 
)

References find_section(), _MateDesktopItem::keys, Section::keys, _MateDesktopItem::main_hash, _MateDesktopItem::modified, Section::name, and _MateDesktopItem::refcount.

Here is the call graph for this function:

◆ mate_desktop_item_copy()

MateDesktopItem * mate_desktop_item_copy ( const MateDesktopItem *  item)

mate_desktop_item_copy: @item: The item to be copied

Creates a copy of a MateDesktopItem. The new copy has a refcount of 1. Note: Section stack is NOT copied.

Returns: The new copy

References copy_string_hash(), dup_section(), _MateDesktopItem::keys, _MateDesktopItem::languages, _MateDesktopItem::launch_time, _MateDesktopItem::location, _MateDesktopItem::main_hash, mate_desktop_item_new(), _MateDesktopItem::modified, _MateDesktopItem::mtime, _MateDesktopItem::refcount, _MateDesktopItem::sections, and _MateDesktopItem::type.

Referenced by _mate_desktop_item_copy().

Here is the call graph for this function:

◆ mate_desktop_item_drop_uri_list()

int mate_desktop_item_drop_uri_list ( const MateDesktopItem *  item,
const char *  uri_list,
MateDesktopItemLaunchFlags  flags,
GError **  error 
)

mate_desktop_item_drop_uri_list: @item: A desktop item @uri_list: text as gotten from a text/uri-list @flags: FIXME @error: FIXME

A list of files or urls dropped onto an icon, the proper (Url or File) exec is run you can pass directly string that you got as the text/uri-list. This just parses the list and calls

Returns: The value returned by #mate_execute_async() upon execution of the specified item or -1 on error. If multiple instances are run, the return of the last one is returned.

References mate_desktop_item_drop_uri_list_with_env().

Here is the call graph for this function:

◆ mate_desktop_item_drop_uri_list_with_env()

int mate_desktop_item_drop_uri_list_with_env ( const MateDesktopItem *  item,
const char *  uri_list,
MateDesktopItemLaunchFlags  flags,
char **  envp,
GError **  error 
)

mate_desktop_item_drop_uri_list_with_env: @item: A desktop item @uri_list: text as gotten from a text/uri-list @flags: FIXME @envp: child's environment @error: FIXME

See mate_desktop_item_drop_uri_list for a full description. This function additionally passes an environment vector for the child process which is to be launched.

Returns: The value returned by #mate_execute_async() upon execution of the specified item or -1 on error. If multiple instances are run, the return of the last one is returned.

References mate_desktop_item_launch_with_env().

Referenced by mate_desktop_item_drop_uri_list().

Here is the call graph for this function:

◆ mate_desktop_item_error_quark()

GQuark mate_desktop_item_error_quark ( void  )

◆ mate_desktop_item_exists()

gboolean mate_desktop_item_exists ( const MateDesktopItem *  item)

mate_desktop_item_exists: @item: A desktop item

Attempt to figure out if the program that can be executed by this item actually exists. First it tries the TryExec attribute to see if that contains a program that is in the path. Then if there is no such attribute, it tries the first word of the Exec attribute.

Returns: A boolean, TRUE if it exists, FALSE otherwise.

References exec_exists(), lookup(), MATE_DESKTOP_ITEM_EXEC, MATE_DESKTOP_ITEM_TRY_EXEC, MATE_DESKTOP_ITEM_TYPE_APPLICATION, and _MateDesktopItem::type.

Referenced by mate_desktop_item_new_from_gfile().

Here is the call graph for this function:

◆ mate_desktop_item_find_icon()

char * mate_desktop_item_find_icon ( GtkIconTheme *  icon_theme,
const char *  icon,
int  desired_size,
int  flags 
)

mate_desktop_item_find_icon: @icon_theme: a #GtkIconTheme @icon: icon name, something you'd get out of the Icon key @desired_size: FIXME @flags: FIXME

Description: This function goes and looks for the icon file. If the icon is not an absolute filename, this will look for it in the standard places. If it can't find the icon, it will return NULL

Returns: A newly allocated string

Referenced by mate_desktop_item_get_icon().

◆ mate_desktop_item_get_attr_locale()

const char * mate_desktop_item_get_attr_locale ( const MateDesktopItem *  item,
const char *  attr 
)

mate_desktop_item_get_string_locale: @item: A desktop item @attr: An attribute name

Returns the current locale that is used for the given attribute. This might not be the same for all attributes. For example, if your locale is "en_US.ISO8859-1" but attribute FOO only has "en_US" then that would be returned for attr = "FOO". If attribute BAR has "en_US.ISO8859-1" then that would be returned for "BAR".

Returns: a string equal to the current locale or NULL if the attribute is invalid or there is no matching locale.

References lookup_locale().

Here is the call graph for this function:

◆ mate_desktop_item_get_boolean()

gboolean mate_desktop_item_get_boolean ( const MateDesktopItem *  item,
const char *  attr 
)

References lookup(), and _MateDesktopItem::refcount.

Referenced by ditem_execute().

Here is the call graph for this function:

◆ mate_desktop_item_get_entry_type()

MateDesktopItemType mate_desktop_item_get_entry_type ( const MateDesktopItem *  item)

mate_desktop_item_get_entry_type: @item: A desktop item

Gets the type attribute (the 'Type' field) of the item. This should usually be 'Application' for an application, but it can be 'Directory' for a directory description. There are other types available as well. The type usually indicates how the desktop item should be handeled and how the 'Exec' field should be handeled.

Returns: The type of the specified 'item'. The returned memory remains owned by the MateDesktopItem and should not be freed.

References _MateDesktopItem::refcount, and _MateDesktopItem::type.

Referenced by test_ditem().

◆ mate_desktop_item_get_file_status()

MateDesktopItemStatus mate_desktop_item_get_file_status ( const MateDesktopItem *  item)

mate_desktop_item_get_file_status: @item: A desktop item

This function checks the modification time of the on-disk file to see if it is more recent than the in-memory data.

Returns: An enum value that specifies whether the item has changed since being loaded.

References _MateDesktopItem::location, MATE_DESKTOP_ITEM_CHANGED, MATE_DESKTOP_ITEM_DISAPPEARED, MATE_DESKTOP_ITEM_UNCHANGED, _MateDesktopItem::mtime, and _MateDesktopItem::refcount.

◆ mate_desktop_item_get_icon()

char * mate_desktop_item_get_icon ( const MateDesktopItem *  item,
GtkIconTheme *  icon_theme 
)

mate_desktop_item_get_icon: @icon_theme: a #GtkIconTheme @item: A desktop item

Description: This function goes and looks for the icon file. If the icon is not set as an absolute filename, this will look for it in the standard places. If it can't find the icon, it will return NULL

Returns: A newly allocated string

References mate_desktop_item_find_icon(), mate_desktop_item_get_string(), MATE_DESKTOP_ITEM_ICON, and _MateDesktopItem::refcount.

Here is the call graph for this function:

◆ mate_desktop_item_get_languages()

GList * mate_desktop_item_get_languages ( const MateDesktopItem *  item,
const char *  attr 
)

References _MateDesktopItem::languages, lookup_locale(), and _MateDesktopItem::refcount.

Here is the call graph for this function:

◆ mate_desktop_item_get_localestring()

const char * mate_desktop_item_get_localestring ( const MateDesktopItem *  item,
const char *  attr 
)

References lookup_best_locale(), and _MateDesktopItem::refcount.

Referenced by ditem_execute(), do_percent_subst(), and test_ditem().

Here is the call graph for this function:

◆ mate_desktop_item_get_localestring_lang()

const char * mate_desktop_item_get_localestring_lang ( const MateDesktopItem *  item,
const char *  attr,
const char *  language 
)

References lookup_locale(), and _MateDesktopItem::refcount.

Referenced by test_ditem().

Here is the call graph for this function:

◆ mate_desktop_item_get_location()

const char * mate_desktop_item_get_location ( const MateDesktopItem *  item)

mate_desktop_item_get_location: @item: A desktop item

Returns: The file location associated with 'item'.

References _MateDesktopItem::location, and _MateDesktopItem::refcount.

Referenced by test_ditem().

◆ mate_desktop_item_get_string()

const char * mate_desktop_item_get_string ( const MateDesktopItem *  item,
const char *  attr 
)

References lookup(), and _MateDesktopItem::refcount.

Referenced by ditem_execute(), do_percent_subst(), mate_desktop_item_get_icon(), mate_desktop_item_launch_on_screen_with_env(), and test_ditem().

Here is the call graph for this function:

◆ mate_desktop_item_get_strings()

char ** mate_desktop_item_get_strings ( const MateDesktopItem *  item,
const char *  attr 
)

References lookup(), and _MateDesktopItem::refcount.

Here is the call graph for this function:

◆ mate_desktop_item_get_type()

GType mate_desktop_item_get_type ( void  )

References _mate_desktop_item_copy(), and _mate_desktop_item_free().

Here is the call graph for this function:

◆ mate_desktop_item_launch()

int mate_desktop_item_launch ( const MateDesktopItem *  item,
GList *  file_list,
MateDesktopItemLaunchFlags  flags,
GError **  error 
)

mate_desktop_item_launch: @item: A desktop item @file_list: Files/URIs to launch this item with, can be NULL @flags: FIXME @error: FIXME

This function runs the program listed in the specified 'item', optionally appending additional arguments to its command line. It uses #g_shell_parse_argv to parse the the exec string into a vector which is then passed to #g_spawn_async for execution. This can return all the errors from MateURL, #g_shell_parse_argv and #g_spawn_async, in addition to it's own. The files are only added if the entry defines one of the standard % strings in it's Exec field.

Returns: The the pid of the process spawned. If more then one process was spawned the last pid is returned. On error -1 is returned and @error is set.

References mate_desktop_item_launch_on_screen_with_env().

Referenced by launch_item().

Here is the call graph for this function:

◆ mate_desktop_item_launch_on_screen()

int mate_desktop_item_launch_on_screen ( const MateDesktopItem *  item,
GList *  file_list,
MateDesktopItemLaunchFlags  flags,
GdkScreen *  screen,
int  workspace,
GError **  error 
)

mate_desktop_item_launch_on_screen: @item: A desktop item @file_list: Files/URIs to launch this item with, can be NULL @flags: FIXME @screen: the GdkScreen on which the application should be launched @workspace: the workspace on which the app should be launched (-1 for current) @error: FIXME

See mate_desktop_item_launch for a full description. This function additionally attempts to launch the application on a given screen and workspace.

Returns: The the pid of the process spawned. If more then one process was spawned the last pid is returned. On error -1 is returned and @error is set.

References mate_desktop_item_launch_on_screen_with_env().

Here is the call graph for this function:

◆ mate_desktop_item_launch_on_screen_with_env()

◆ mate_desktop_item_launch_with_env()

int mate_desktop_item_launch_with_env ( const MateDesktopItem *  item,
GList *  file_list,
MateDesktopItemLaunchFlags  flags,
char **  envp,
GError **  error 
)

mate_desktop_item_launch_with_env: @item: A desktop item @file_list: Files/URIs to launch this item with, can be NULL @flags: FIXME @envp: child's environment, or NULL to inherit parent's @error: FIXME

See mate_desktop_item_launch for a full description. This function additionally passes an environment vector for the child process which is to be launched.

Returns: The the pid of the process spawned. If more then one process was spawned the last pid is returned. On error -1 is returned and @error is set.

References mate_desktop_item_launch_on_screen_with_env().

Referenced by mate_desktop_item_drop_uri_list_with_env().

Here is the call graph for this function:

◆ mate_desktop_item_new()

MateDesktopItem * mate_desktop_item_new ( void  )

mate_desktop_item_new:

Creates a MateDesktopItem object. The reference count on the returned value is set to '1'.

Returns: The new MateDesktopItem

References _mate_desktop_init_i18n(), _MateDesktopItem::launch_time, _MateDesktopItem::main_hash, MATE_DESKTOP_ITEM_ENCODING, MATE_DESKTOP_ITEM_NAME, mate_desktop_item_set_string(), MATE_DESKTOP_ITEM_VERSION, and _MateDesktopItem::refcount.

Referenced by ditem_load(), make_fake_directory(), and mate_desktop_item_copy().

Here is the call graph for this function:

◆ mate_desktop_item_new_from_basename()

MateDesktopItem * mate_desktop_item_new_from_basename ( const char *  basename,
MateDesktopItemLoadFlags  flags,
GError **  error 
)

mate_desktop_item_new_from_basename: @basename: The basename of the MateDesktopItem to load.

@flags: Flags to influence the loading process

This function loads 'basename' from a system data directory and returns its MateDesktopItem.

Returns: The newly loaded item.

References file_from_basename(), MATE_DESKTOP_ITEM_ERROR, MATE_DESKTOP_ITEM_ERROR_CANNOT_OPEN, and mate_desktop_item_new_from_file().

Here is the call graph for this function:

◆ mate_desktop_item_new_from_file()

MateDesktopItem * mate_desktop_item_new_from_file ( const char *  file,
MateDesktopItemLoadFlags  flags,
GError **  error 
)

References mate_desktop_item_new_from_gfile().

Referenced by launch_item(), mate_desktop_item_new_from_basename(), and test_ditem().

Here is the call graph for this function:

◆ mate_desktop_item_new_from_gfile()

static MateDesktopItem * mate_desktop_item_new_from_gfile ( GFile *  file,
MateDesktopItemLoadFlags  flags,
GError **  error 
)
static

◆ mate_desktop_item_new_from_string()

MateDesktopItem * mate_desktop_item_new_from_string ( const char *  uri,
const char *  string,
gssize  length,
MateDesktopItemLoadFlags  flags,
GError **  error 
)

mate_desktop_item_new_from_string: @string: string to load the MateDesktopItem from @length: length of string, or -1 to use strlen @flags: Flags to influence the loading process @error: place to put errors

This function turns the contents of the string into a MateDesktopItem.

Returns: The newly loaded item.

References ditem_load(), MATE_DESKTOP_ITEM_LOAD_NO_TRANSLATIONS, and readbuf_new_from_string().

Here is the call graph for this function:

◆ mate_desktop_item_new_from_uri()

MateDesktopItem * mate_desktop_item_new_from_uri ( const char *  uri,
MateDesktopItemLoadFlags  flags,
GError **  error 
)

mate_desktop_item_new_from_uri: @uri: URI to load the MateDesktopItem from @flags: Flags to influence the loading process

This function loads 'uri' and turns it into a MateDesktopItem.

Returns: The newly loaded item.

References mate_desktop_item_new_from_gfile().

Here is the call graph for this function:

◆ mate_desktop_item_ref()

MateDesktopItem * mate_desktop_item_ref ( MateDesktopItem *  item)

mate_desktop_item_ref: @item: A desktop item

Description: Increases the reference count of the specified item.

Returns: the newly referenced @item

References _MateDesktopItem::refcount.

◆ mate_desktop_item_save()

gboolean mate_desktop_item_save ( MateDesktopItem *  item,
const char *  under,
gboolean  force,
GError **  error 
)

mate_desktop_item_save: @item: A desktop item @under: A new uri (location) for this MateDesktopItem @force: Save even if it wasn't modified @error: #GError return

Writes the specified item to disk. If the 'under' is NULL, the original location is used. It sets the location of this entry to point to the new location.

Returns: boolean. TRUE if the file was saved, FALSE otherwise

References ditem_save(), _MateDesktopItem::location, MATE_DESKTOP_ITEM_ERROR, MATE_DESKTOP_ITEM_ERROR_NO_FILENAME, _MateDesktopItem::modified, and _MateDesktopItem::mtime.

Referenced by test_ditem().

Here is the call graph for this function:

◆ mate_desktop_item_set_boolean()

void mate_desktop_item_set_boolean ( MateDesktopItem *  item,
const char *  attr,
gboolean  value 
)

References _MateDesktopItem::refcount, and set().

Here is the call graph for this function:

◆ mate_desktop_item_set_entry_type()

void mate_desktop_item_set_entry_type ( MateDesktopItem *  item,
MateDesktopItemType  type 
)

◆ mate_desktop_item_set_launch_time()

void mate_desktop_item_set_launch_time ( MateDesktopItem *  item,
guint32  timestamp 
)

◆ mate_desktop_item_set_localestring()

void mate_desktop_item_set_localestring ( MateDesktopItem *  item,
const char *  attr,
const char *  value 
)

References get_language(), _MateDesktopItem::refcount, and set_locale().

Referenced by test_ditem().

Here is the call graph for this function:

◆ mate_desktop_item_set_localestring_lang()

void mate_desktop_item_set_localestring_lang ( MateDesktopItem *  item,
const char *  attr,
const char *  language,
const char *  value 
)

References _MateDesktopItem::refcount, and set_locale().

Here is the call graph for this function:

◆ mate_desktop_item_set_location()

void mate_desktop_item_set_location ( MateDesktopItem *  item,
const char *  location 
)

mate_desktop_item_set_location: @item: A desktop item @location: A uri string specifying the file location of this particular item.

Set's the 'location' uri of this item.

References DONT_UPDATE_MTIME, _MateDesktopItem::location, _MateDesktopItem::modified, _MateDesktopItem::mtime, and _MateDesktopItem::refcount.

Referenced by mate_desktop_item_set_location_file(), and mate_desktop_item_set_location_gfile().

◆ mate_desktop_item_set_location_file()

void mate_desktop_item_set_location_file ( MateDesktopItem *  item,
const char *  file 
)

References mate_desktop_item_set_location(), mate_desktop_item_set_location_gfile(), and _MateDesktopItem::refcount.

Here is the call graph for this function:

◆ mate_desktop_item_set_location_gfile()

static void mate_desktop_item_set_location_gfile ( MateDesktopItem *  item,
GFile *  file 
)
static

References mate_desktop_item_set_location(), and _MateDesktopItem::refcount.

Referenced by make_fake_directory(), mate_desktop_item_new_from_gfile(), and mate_desktop_item_set_location_file().

Here is the call graph for this function:

◆ mate_desktop_item_set_string()

void mate_desktop_item_set_string ( MateDesktopItem *  item,
const char *  attr,
const char *  value 
)

References MATE_DESKTOP_ITEM_TYPE, _MateDesktopItem::refcount, set(), _MateDesktopItem::type, and type_from_string().

Referenced by mate_desktop_item_new(), and read_sort_order().

Here is the call graph for this function:

◆ mate_desktop_item_set_strings()

void mate_desktop_item_set_strings ( MateDesktopItem *  item,
const char *  attr,
char **  strings 
)

References _MateDesktopItem::refcount, and set().

Here is the call graph for this function:

◆ mate_desktop_item_unref()

void mate_desktop_item_unref ( MateDesktopItem *  item)

mate_desktop_item_unref: @item: A desktop item

Decreases the reference count of the specified item, and destroys the item if there are no more references left.

References free_section(), _MateDesktopItem::keys, _MateDesktopItem::languages, _MateDesktopItem::location, _MateDesktopItem::main_hash, _MateDesktopItem::refcount, and _MateDesktopItem::sections.

Referenced by _mate_desktop_item_free(), and mate_desktop_item_new_from_gfile().

Here is the call graph for this function:

◆ read_sort_order()

static void read_sort_order ( MateDesktopItem *  item,
GFile *  dir 
)
static

References mate_desktop_item_set_string(), MATE_DESKTOP_ITEM_SORT_ORDER, readbuf_close(), readbuf_gets(), and readbuf_open().

Referenced by make_fake_directory(), and mate_desktop_item_new_from_gfile().

Here is the call graph for this function:

◆ readbuf_close()

static void readbuf_close ( ReadBuf *  rb)
static

◆ readbuf_getc()

static int readbuf_getc ( ReadBuf *  rb)
static

◆ readbuf_gets()

static char * readbuf_gets ( char *  buf,
gsize  bufsize,
ReadBuf *  rb 
)
static

References readbuf_getc().

Referenced by get_encoding(), and read_sort_order().

Here is the call graph for this function:

◆ readbuf_new_from_string()

static ReadBuf * readbuf_new_from_string ( const char *  uri,
const char *  string,
gssize  length 
)
static

◆ readbuf_open()

◆ readbuf_rewind()

static gboolean readbuf_rewind ( ReadBuf *  rb,
GError **  error 
)
static

◆ sanitize()

static void sanitize ( MateDesktopItem *  item,
const char *  uri 
)
static

References _MateDesktopItem::keys, lookup(), _MateDesktopItem::main_hash, MATE_DESKTOP_ITEM_ENCODING, MATE_DESKTOP_ITEM_EXEC, MATE_DESKTOP_ITEM_NAME, MATE_DESKTOP_ITEM_TYPE, MATE_DESKTOP_ITEM_URL, MATE_DESKTOP_ITEM_VERSION, set(), and try_english_key().

Referenced by ditem_load().

Here is the call graph for this function:

◆ section_from_key()

static Section * section_from_key ( MateDesktopItem *  item,
const char *  key 
)
static

References find_section().

Referenced by set().

Here is the call graph for this function:

◆ set()

static void set ( MateDesktopItem *  item,
const char *  key,
const char *  value 
)
static

◆ set_locale()

static void set_locale ( MateDesktopItem *  item,
const char *  key,
const char *  locale,
const char *  value 
)
static

References _MateDesktopItem::languages, and set().

Referenced by mate_desktop_item_clear_localestring(), mate_desktop_item_set_localestring(), and mate_desktop_item_set_localestring_lang().

Here is the call graph for this function:

◆ setup_type()

static void setup_type ( MateDesktopItem *  item,
const char *  uri 
)
static

References _MateDesktopItem::keys, _MateDesktopItem::main_hash, MATE_DESKTOP_ITEM_TYPE, MATE_DESKTOP_ITEM_TYPE_DIRECTORY, MATE_DESKTOP_ITEM_TYPE_NULL, _MateDesktopItem::type, and type_from_string().

Referenced by ditem_load().

Here is the call graph for this function:

◆ snarf_locale_from_key()

static char * snarf_locale_from_key ( const char *  key)
static

Referenced by insert_key().

◆ standard_is_boolean()

static gboolean standard_is_boolean ( const char *  key)
static

◆ standard_is_strings()

static gboolean standard_is_strings ( const char *  key)
static

◆ stream_printf()

static void stream_printf ( GFileOutputStream *  stream,
const char *  format,
  ... 
)
static

Referenced by ditem_save(), and dump_section().

◆ stringify_files()

static char * stringify_files ( GSList *  args)
inlinestatic

References ADDED_NONE, append_all_converted(), and URI_TO_LOCAL_PATH.

Referenced by ditem_execute().

Here is the call graph for this function:

◆ stringify_uris()

static char * stringify_uris ( GSList *  args)
inlinestatic

References ADDED_NONE, append_all_converted(), and URI_TO_STRING.

Referenced by ditem_execute().

Here is the call graph for this function:

◆ strip_the_amp()

static gboolean strip_the_amp ( char *  exec)
static

◆ try_english_key()

static char * try_english_key ( MateDesktopItem *  item,
const char *  key 
)
static

References lookup_locale().

Referenced by sanitize().

Here is the call graph for this function:

◆ type_from_string()