/** * shell_app_system_get_app_for_path: * @system: a #ShellAppSystem * @desktop_path: (type utf8): UTF-8 encoded absolute file name * * Find or create a #ShellApp corresponding to a given absolute * file name which must be in the standard paths (XDG_DATA_DIRS). * For files outside the datadirs, this function returns %NULL. * * If already cached elsewhere in memory, return that instance. * Otherwise, create a new one. * * Return value: (transfer full): The #ShellApp for id, or %NULL if none */ ShellApp * shell_app_system_get_app_for_path (ShellAppSystem *system, const char *desktop_path) { const char *basename; ShellAppInfo *info; basename = g_strrstr (desktop_path, "/"); if (basename) basename += 1; else basename = desktop_path; info = g_hash_table_lookup (system->priv->app_id_to_info, basename); if (!info) return NULL; if (info->type == SHELL_APP_INFO_TYPE_ENTRY) { const char *full_path = gmenu_tree_entry_get_desktop_file_path ((GMenuTreeEntry*) info->entry); if (strcmp (desktop_path, full_path) != 0) return NULL; } else return NULL; return shell_app_system_get_app (system, basename); }
static void activate_app_def (GtkWidget *menuitem, GMenuTreeEntry *entry) { const char *path; path = gmenu_tree_entry_get_desktop_file_path (entry); panel_menu_item_activate_desktop_file (menuitem, path); }
static void add_entry(GMenuTreeEntry *entry, const char *path, GSList**p) { GSList* data = *p; char *utf8_path; char *utf8_file_id; Menu_list_item * item; gchar * file_name; utf8_path = g_filename_to_utf8(gmenu_tree_entry_get_desktop_file_path(entry), -1, NULL, NULL, NULL); utf8_file_id = g_filename_to_utf8(gmenu_tree_entry_get_desktop_file_id(entry), -1, NULL, NULL, NULL); file_name = utf8_path ? utf8_path : _("[Invalid Filename]"); item = g_malloc(sizeof(Menu_list_item)); item->item_type = MENU_ITEM_ENTRY; item->name = gmenu_tree_entry_get_name(entry); item->icon = gmenu_tree_entry_get_icon(entry); item->exec = gmenu_tree_entry_get_exec(entry); char *str = item->exec; while (*str) { if (*str == '%') { *str = ' '; if (*(str + 1)) { str++; *str = ' '; } } str++; } item->comment = gmenu_tree_entry_get_comment(entry); item->launch_in_terminal = gmenu_tree_entry_get_launch_in_terminal(entry); item->desktop = g_strdup(file_name); data = g_slist_append(data, item); *p = data; g_free(utf8_file_id); g_free(utf8_path); }
char * shell_app_info_get_desktop_file_path (ShellAppInfo *info) { switch (info->type) { case SHELL_APP_INFO_TYPE_ENTRY: return g_strdup (gmenu_tree_entry_get_desktop_file_path ((GMenuTreeEntry*)info->entry)); case SHELL_APP_INFO_TYPE_DESKTOP_FILE: return g_strdup (info->keyfile_path); case SHELL_APP_INFO_TYPE_WINDOW: return NULL; } g_assert_not_reached (); return NULL; }
static GList * xde_action(MenuContext *ctx, GMenuTreeEntry *ent, GDesktopAppInfo *info, const char *action) { GList *text = NULL; const char *name, *path; char *esc1, *esc2, *cmd, *p; char *s, *icon = NULL; GIcon *gicon = NULL; char *appid; name = g_desktop_app_info_get_action_name(info, action); esc1 = xde_character_escape(name, ')'); if ((appid = strdup(gmenu_tree_entry_get_desktop_file_id(ent))) && (p = strstr(appid, ".desktop"))) *p = '\0'; if (ctx->stack) gicon = gmenu_tree_directory_get_icon(ctx->stack->data); if ((path = gmenu_tree_entry_get_desktop_file_path(ent))) { GKeyFile *file = g_key_file_new(); g_key_file_load_from_file(file, path, G_KEY_FILE_NONE, NULL); icon = xde_get_action_icon(ctx, file, action, gicon, "exec", "unknown", GET_ENTRY_ICON_FLAG_XPM | GET_ENTRY_ICON_FLAG_PNG | GET_ENTRY_ICON_FLAG_JPG | GET_ENTRY_ICON_FLAG_SVG); g_key_file_unref(file); } else icon = xde_get_icon2(ctx, "exec", "unknown"); gicon = g_app_info_get_icon(G_APP_INFO(info)); if (options.launch) cmd = g_strdup_printf("xdg-launch --pointer --action='%s' %s", action, appid); else cmd = xde_get_action(info, appid, icon, action); esc2 = xde_character_escape(cmd, '}'); icon = ctx->wmm.wrap(ctx, icon); s = g_strdup_printf("%s[exec] (%s) {%s}%s\n", ctx->indent, esc1, esc2, icon); text = g_list_append(text, s); free(icon); free(appid); free(esc1); free(esc2); free(cmd); return (text); }
static void print_entry(GMenuTreeEntry *entry, const char *path) { char *utf8_path; char *utf8_file_id; utf8_path = g_filename_to_utf8(gmenu_tree_entry_get_desktop_file_path(entry), -1, NULL, NULL, NULL); utf8_file_id = g_filename_to_utf8(gmenu_tree_entry_get_desktop_file_id(entry), -1, NULL, NULL, NULL); g_print("%s\t%s\t%s%s\n", path, utf8_file_id ? utf8_file_id : _("Invalid desktop file ID"), utf8_path ? utf8_path : _("[Invalid Filename]"), gmenu_tree_entry_get_is_excluded(entry) ? _(" <excluded>") : ""); g_free(utf8_file_id); g_free(utf8_path); }
static void drag_data_get_menu_cb (GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection_data, guint info, guint time, GMenuTreeEntry *entry) { const char *path; char *uri; char *uri_list; path = gmenu_tree_entry_get_desktop_file_path (entry); uri = g_filename_to_uri (path, NULL, NULL); uri_list = g_strconcat (uri, "\r\n", NULL); g_free (uri); gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data), 8, (guchar *)uri_list, strlen (uri_list)); g_free (uri_list); }
/** * shell_app_system_lookup_app_for_path: * @system: a #ShellAppSystem * @desktop_path: (type utf8): UTF-8 encoded absolute file name * * Find or create a #ShellApp corresponding to a given absolute file * name which must be in the standard paths (XDG_DATA_DIRS). For * files outside the datadirs, this function returns %NULL. * * Return value: (transfer none): The #ShellApp for id, or %NULL if none */ ShellApp * shell_app_system_lookup_app_for_path (ShellAppSystem *system, const char *desktop_path) { const char *basename; const char *app_path; ShellApp *app; basename = g_strrstr (desktop_path, "/"); if (basename) basename += 1; else basename = desktop_path; app = shell_app_system_lookup_app (system, basename); if (!app) return NULL; app_path = gmenu_tree_entry_get_desktop_file_path (shell_app_get_tree_entry (app)); if (strcmp (desktop_path, app_path) != 0) return NULL; return app; }
static char * get_prefix_for_entry (GMenuTreeEntry *entry) { char *prefix = NULL, *file_prefix = NULL; const char *id; GFile *file; char *name; int i = 0; id = gmenu_tree_entry_get_desktop_file_id (entry); file = g_file_new_for_path (gmenu_tree_entry_get_desktop_file_path (entry)); name = g_file_get_basename (file); if (!name) { g_object_unref (file); return NULL; } for (i = 0; vendor_prefixes[i]; i++) { if (g_str_has_prefix (name, vendor_prefixes[i])) { file_prefix = g_strdup (vendor_prefixes[i]); break; } } while (strcmp (name, id) != 0) { char *t; char *pname; GFile *parent = g_file_get_parent (file); if (!parent) { g_warn_if_reached (); break; } pname = g_file_get_basename (parent); if (!pname) { g_object_unref (parent); break; } if (!g_strstr_len (id, -1, pname)) { /* handle <LegacyDir prefix="..."> */ char *t; size_t name_len = strlen (name); size_t id_len = strlen (id); char *t_id = g_strdup (id); t_id[id_len - name_len] = '\0'; t = g_strdup(t_id); g_free (prefix); g_free (t_id); g_free (name); name = g_strdup (id); prefix = t; g_object_unref (file); file = parent; g_free (pname); g_free (file_prefix); file_prefix = NULL; break; } t = g_strconcat (pname, "-", name, NULL); g_free (name); name = t; t = g_strconcat (pname, "-", prefix, NULL); g_free (prefix); prefix = t; g_object_unref (file); file = parent; g_free (pname); } if (file) g_object_unref (file); if (strcmp (name, id) == 0) { g_free (name); if (file_prefix && !prefix) return file_prefix; if (file_prefix) { char *t = g_strconcat (prefix, "-", file_prefix, NULL); g_free (prefix); g_free (file_prefix); prefix = t; } return prefix; } g_free (name); g_free (prefix); g_free (file_prefix); g_return_val_if_reached (NULL); }
void slingshot_backend_gmenu_entries_enumerate_apps (GeeArrayList* source, GeeHashMap* icons, gint icon_size, GeeArrayList** list) { GeeArrayList* _vala_list = NULL; GtkIconTheme* _tmp0_ = NULL; GtkIconTheme* _tmp1_; GtkIconTheme* icon_theme; GeeArrayList* _tmp2_; GError * _inner_error_ = NULL; g_return_if_fail (source != NULL); g_return_if_fail (icons != NULL); _tmp0_ = gtk_icon_theme_get_default (); _tmp1_ = _g_object_ref0 (_tmp0_); icon_theme = _tmp1_; _tmp2_ = gee_array_list_new (GEE_TYPE_HASH_MAP, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL); _g_object_unref0 (_vala_list); _vala_list = _tmp2_; { GeeArrayList* _tmp3_; GeeArrayList* _tmp4_; GeeArrayList* _app_list; GeeArrayList* _tmp5_; gint _tmp6_; gint _tmp7_; gint _app_size; gint _app_index; _tmp3_ = source; _tmp4_ = _g_object_ref0 (_tmp3_); _app_list = _tmp4_; _tmp5_ = _app_list; _tmp6_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp5_); _tmp7_ = _tmp6_; _app_size = _tmp7_; _app_index = -1; while (TRUE) { gint _tmp8_; gint _tmp9_; gint _tmp10_; GeeArrayList* _tmp11_; gint _tmp12_; gpointer _tmp13_ = NULL; GMenuTreeEntry* app; gboolean _tmp14_ = FALSE; gboolean _tmp15_ = FALSE; GMenuTreeEntry* _tmp16_; gboolean _tmp17_ = FALSE; gboolean _tmp20_; gboolean _tmp23_; _tmp8_ = _app_index; _app_index = _tmp8_ + 1; _tmp9_ = _app_index; _tmp10_ = _app_size; if (!(_tmp9_ < _tmp10_)) { break; } _tmp11_ = _app_list; _tmp12_ = _app_index; _tmp13_ = gee_abstract_list_get ((GeeAbstractList*) _tmp11_, _tmp12_); app = (GMenuTreeEntry*) _tmp13_; _tmp16_ = app; _tmp17_ = gmenu_tree_entry_get_is_nodisplay (_tmp16_); if (_tmp17_ == FALSE) { GMenuTreeEntry* _tmp18_; gboolean _tmp19_ = FALSE; _tmp18_ = app; _tmp19_ = gmenu_tree_entry_get_is_excluded (_tmp18_); _tmp15_ = _tmp19_ == FALSE; } else { _tmp15_ = FALSE; } _tmp20_ = _tmp15_; if (_tmp20_) { GMenuTreeEntry* _tmp21_; const gchar* _tmp22_ = NULL; _tmp21_ = app; _tmp22_ = gmenu_tree_entry_get_icon (_tmp21_); _tmp14_ = _tmp22_ != NULL; } else { _tmp14_ = FALSE; } _tmp23_ = _tmp14_; if (_tmp23_) { GeeHashMap* _tmp24_; GeeHashMap* app_to_add; GeeHashMap* _tmp25_; GMenuTreeEntry* _tmp26_; const gchar* _tmp27_ = NULL; GeeHashMap* _tmp28_; GMenuTreeEntry* _tmp29_; const gchar* _tmp30_ = NULL; GeeHashMap* _tmp31_; GMenuTreeEntry* _tmp32_; const gchar* _tmp33_ = NULL; GeeHashMap* _tmp34_; GMenuTreeEntry* _tmp35_; const gchar* _tmp36_ = NULL; GeeHashMap* _tmp37_; GeeHashMap* _tmp38_; gpointer _tmp39_ = NULL; gchar* _tmp40_; gboolean _tmp41_ = FALSE; gboolean _tmp42_; GeeArrayList* _tmp102_; GeeHashMap* _tmp103_; _tmp24_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL); app_to_add = _tmp24_; _tmp25_ = app_to_add; _tmp26_ = app; _tmp27_ = gmenu_tree_entry_get_comment (_tmp26_); gee_abstract_map_set ((GeeAbstractMap*) _tmp25_, "description", _tmp27_); _tmp28_ = app_to_add; _tmp29_ = app; _tmp30_ = gmenu_tree_entry_get_name (_tmp29_); gee_abstract_map_set ((GeeAbstractMap*) _tmp28_, "name", _tmp30_); _tmp31_ = app_to_add; _tmp32_ = app; _tmp33_ = gmenu_tree_entry_get_exec (_tmp32_); gee_abstract_map_set ((GeeAbstractMap*) _tmp31_, "command", _tmp33_); _tmp34_ = app_to_add; _tmp35_ = app; _tmp36_ = gmenu_tree_entry_get_desktop_file_path (_tmp35_); gee_abstract_map_set ((GeeAbstractMap*) _tmp34_, "desktop_file", _tmp36_); _tmp37_ = icons; _tmp38_ = app_to_add; _tmp39_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp38_, "command"); _tmp40_ = (gchar*) _tmp39_; _tmp41_ = gee_abstract_map_has_key ((GeeAbstractMap*) _tmp37_, _tmp40_); _tmp42_ = !_tmp41_; _g_free0 (_tmp40_); if (_tmp42_) { GMenuTreeEntry* _tmp43_; const gchar* _tmp44_ = NULL; gchar* _tmp45_; gchar* app_icon; GtkIconTheme* _tmp46_; const gchar* _tmp47_; gboolean _tmp48_ = FALSE; _tmp43_ = app; _tmp44_ = gmenu_tree_entry_get_icon (_tmp43_); _tmp45_ = g_strdup (_tmp44_); app_icon = _tmp45_; _tmp46_ = icon_theme; _tmp47_ = app_icon; _tmp48_ = gtk_icon_theme_has_icon (_tmp46_, _tmp47_); if (_tmp48_) { GtkIconTheme* _tmp49_; const gchar* _tmp50_; gint _tmp51_; GtkIconInfo* _tmp52_ = NULL; GtkIconInfo* _tmp53_; GdkPixbuf* _tmp54_ = NULL; GdkPixbuf* _tmp55_; GdkPixbuf* _tmp56_; GeeHashMap* _tmp57_; GeeHashMap* _tmp58_; gpointer _tmp59_ = NULL; gchar* _tmp60_; GdkPixbuf* _tmp61_; _tmp49_ = icon_theme; _tmp50_ = app_icon; _tmp51_ = icon_size; _tmp52_ = gtk_icon_theme_lookup_icon (_tmp49_, _tmp50_, _tmp51_, 0); _tmp53_ = _tmp52_; _tmp54_ = gtk_icon_info_load_icon (_tmp53_, &_inner_error_); _tmp55_ = _tmp54_; _gtk_icon_info_free0 (_tmp53_); _tmp56_ = _tmp55_; if (_inner_error_ != NULL) { _g_free0 (app_icon); _g_object_unref0 (app_to_add); _gmenu_tree_item_unref0 (app); _g_object_unref0 (_app_list); _g_object_unref0 (icon_theme); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } _tmp57_ = icons; _tmp58_ = app_to_add; _tmp59_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp58_, "command"); _tmp60_ = (gchar*) _tmp59_; _tmp61_ = _tmp56_; gee_abstract_map_set ((GeeAbstractMap*) _tmp57_, _tmp60_, _tmp61_); _g_object_unref0 (_tmp61_); _g_free0 (_tmp60_); } else { const gchar* _tmp62_; GFile* _tmp63_ = NULL; GFile* _tmp64_; gboolean _tmp65_ = FALSE; gboolean _tmp66_; _tmp62_ = app_icon; _tmp63_ = g_file_new_for_path (_tmp62_); _tmp64_ = _tmp63_; _tmp65_ = g_file_query_exists (_tmp64_, NULL); _tmp66_ = _tmp65_; _g_object_unref0 (_tmp64_); if (_tmp66_) { { const gchar* _tmp67_; const gchar* _tmp68_ = NULL; gint _tmp69_; GdkPixbuf* _tmp70_; GdkPixbuf* _tmp71_; GeeHashMap* _tmp72_; GeeHashMap* _tmp73_; gpointer _tmp74_ = NULL; gchar* _tmp75_; GdkPixbuf* _tmp76_; _tmp67_ = app_icon; _tmp68_ = string_to_string (_tmp67_); _tmp69_ = icon_size; _tmp70_ = gdk_pixbuf_new_from_file_at_scale (_tmp68_, -1, _tmp69_, TRUE, &_inner_error_); _tmp71_ = _tmp70_; if (_inner_error_ != NULL) { goto __catch1_g_error; } _tmp72_ = icons; _tmp73_ = app_to_add; _tmp74_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp73_, "command"); _tmp75_ = (gchar*) _tmp74_; _tmp76_ = _tmp71_; gee_abstract_map_set ((GeeAbstractMap*) _tmp72_, _tmp75_, _tmp76_); _g_object_unref0 (_tmp76_); _g_free0 (_tmp75_); } goto __finally1; __catch1_g_error: { GtkIconTheme* _tmp77_; gint _tmp78_; GtkIconInfo* _tmp79_ = NULL; GtkIconInfo* _tmp80_; GdkPixbuf* _tmp81_ = NULL; GdkPixbuf* _tmp82_; GdkPixbuf* _tmp83_; GeeHashMap* _tmp84_; GeeHashMap* _tmp85_; gpointer _tmp86_ = NULL; gchar* _tmp87_; GdkPixbuf* _tmp88_; FILE* _tmp89_; g_clear_error (&_inner_error_); _inner_error_ = NULL; _tmp77_ = icon_theme; _tmp78_ = icon_size; _tmp79_ = gtk_icon_theme_lookup_icon (_tmp77_, "application-default-icon", _tmp78_, 0); _tmp80_ = _tmp79_; _tmp81_ = gtk_icon_info_load_icon (_tmp80_, &_inner_error_); _tmp82_ = _tmp81_; _gtk_icon_info_free0 (_tmp80_); _tmp83_ = _tmp82_; if (_inner_error_ != NULL) { goto __finally1; } _tmp84_ = icons; _tmp85_ = app_to_add; _tmp86_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp85_, "command"); _tmp87_ = (gchar*) _tmp86_; _tmp88_ = _tmp83_; gee_abstract_map_set ((GeeAbstractMap*) _tmp84_, _tmp87_, _tmp88_); _g_object_unref0 (_tmp88_); _g_free0 (_tmp87_); _tmp89_ = stdout; fprintf (_tmp89_, "Failed to load icon from file.\n"); } __finally1: if (_inner_error_ != NULL) { _g_free0 (app_icon); _g_object_unref0 (app_to_add); _gmenu_tree_item_unref0 (app); _g_object_unref0 (_app_list); _g_object_unref0 (icon_theme); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } } else { GtkIconTheme* _tmp90_; gint _tmp91_; GtkIconInfo* _tmp92_ = NULL; GtkIconInfo* _tmp93_; GdkPixbuf* _tmp94_ = NULL; GdkPixbuf* _tmp95_; GdkPixbuf* _tmp96_; GeeHashMap* _tmp97_; GeeHashMap* _tmp98_; gpointer _tmp99_ = NULL; gchar* _tmp100_; GdkPixbuf* _tmp101_; _tmp90_ = icon_theme; _tmp91_ = icon_size; _tmp92_ = gtk_icon_theme_lookup_icon (_tmp90_, "application-default-icon", _tmp91_, 0); _tmp93_ = _tmp92_; _tmp94_ = gtk_icon_info_load_icon (_tmp93_, &_inner_error_); _tmp95_ = _tmp94_; _gtk_icon_info_free0 (_tmp93_); _tmp96_ = _tmp95_; if (_inner_error_ != NULL) { _g_free0 (app_icon); _g_object_unref0 (app_to_add); _gmenu_tree_item_unref0 (app); _g_object_unref0 (_app_list); _g_object_unref0 (icon_theme); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } _tmp97_ = icons; _tmp98_ = app_to_add; _tmp99_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp98_, "command"); _tmp100_ = (gchar*) _tmp99_; _tmp101_ = _tmp96_; gee_abstract_map_set ((GeeAbstractMap*) _tmp97_, _tmp100_, _tmp101_); _g_object_unref0 (_tmp101_); _g_free0 (_tmp100_); } } _g_free0 (app_icon); } _tmp102_ = _vala_list; _tmp103_ = app_to_add; gee_abstract_collection_add ((GeeAbstractCollection*) _tmp102_, _tmp103_); _g_object_unref0 (app_to_add); } _gmenu_tree_item_unref0 (app); } _g_object_unref0 (_app_list); } _g_object_unref0 (icon_theme); if (list) { *list = _vala_list; } else { _g_object_unref0 (_vala_list); } }
/*! \fn gboolean CDesktopAppChooser::m_AddAppsMenuLeafNode(GMenuTreeDirectory *appsDir) \brief To create leaf nodes(applications). \param[in] appsDir \return TRUE or FALSE */ gboolean CDesktopAppChooser::m_AddAppsMenuLeafNode(GMenuTreeDirectory *appsDir) { GSList *itemList = NULL; if( G_UNLIKELY(!appsDir) ) return false; for( itemList = gmenu_tree_directory_get_contents(appsDir); itemList; itemList = itemList->next ) { GMenuTreeItem *item = (GMenuTreeItem*)itemList->data; GMenuTreeItemType type = gmenu_tree_item_get_type(item); if( type == GMENU_TREE_ITEM_DIRECTORY ) { /* To pars sub-directory items and add it to the menu tree. Here using recursive parse. */ m_AddAppsMenuLeafNode( (GMenuTreeDirectory*)item ); } else if( type == GMENU_TREE_ITEM_ENTRY ) { GdkPixbuf *pixbuf = NULL; const gchar *icon_name = gmenu_tree_entry_get_icon( (GMenuTreeEntry*)item ); APP_ITEM_INFO *appInfo = NULL; /* To determine if the current item need not to be shown. If it is, continue. */ if(gmenu_tree_entry_get_is_nodisplay( (GMenuTreeEntry*)item ) || gmenu_tree_entry_get_is_excluded( (GMenuTreeEntry*)item ) ) continue; /* To create the icon for the currently read node. */ if(icon_name) pixbuf = m_LoadIcon(icon_name, IMG_SIZE, TRUE ); else pixbuf = m_LoadIcon(DEFAULT_APP__MIME_ICON, IMG_SIZE, TRUE ); // If there has no icon name in .desktop file, using the system default icon for application. /* To create a object containing information about current leaf node. */ appInfo = new APP_ITEM_INFO ; /* Zero out the new allocated memory. */ memset(appInfo, 0x00, sizeof(APP_ITEM_INFO)); if(appInfo) { gchar *name = (gchar*)gmenu_tree_entry_get_name( (GMenuTreeEntry*)item ) ; gchar *exec = (gchar*)gmenu_tree_entry_get_exec( (GMenuTreeEntry*)item ); gchar *comment = (gchar*)gmenu_tree_entry_get_comment( (GMenuTreeEntry*)item ); #if 1 gchar *desktopfile = (gchar*)gmenu_tree_entry_get_desktop_file_path( (GMenuTreeEntry*)item ); #else gchar *desktopfile = (gchar*)gmenu_tree_entry_get_desktop_file_id( (GMenuTreeEntry*)item ); #endif if(name) appInfo->name = (gchar*)g_strdup(name); if(icon_name) appInfo->icon = (gchar*)g_strdup(icon_name); if(exec) appInfo->exec = (gchar*)g_strdup(exec); if(comment) appInfo->comment = (gchar*)g_strdup(comment); if(desktopfile) appInfo->desktopfile = (gchar*)g_strdup(desktopfile); } /* Add a tree leaf. */ gtk_tree_store_append(m_TreeStore, &m_ChildNodeIter, &m_TopLevelNodeIter); gtk_tree_store_set(m_TreeStore, &m_ChildNodeIter, COLUMN_ICON, pixbuf, COLUMN_TEXT, gmenu_tree_entry_get_name( (GMenuTreeEntry*)item ), COLUMN_NODEDATA, appInfo, -1); /* pixbuf has a referece count of "1" now, as the tree store has added its own reference. So to decrease the reference count of pixbuf. */ g_object_unref(pixbuf); } } // The end of for() return true; }
/** * shell_app_info_launch_full: * @timestamp: Event timestamp, or 0 for current event timestamp * @uris: List of uris to pass to application * @workspace: Start on this workspace, or -1 for default * @startup_id: (out): Returned startup notification ID, or %NULL if none * @error: A #GError */ gboolean shell_app_info_launch_full (ShellAppInfo *info, guint timestamp, GList *uris, int workspace, char **startup_id, GError **error) { ShellApp *shell_app; GDesktopAppInfo *gapp; GdkAppLaunchContext *context; gboolean ret; ShellGlobal *global; MetaScreen *screen; if (startup_id) *startup_id = NULL; if (info->type == SHELL_APP_INFO_TYPE_WINDOW) { /* We can't pass URIs into a window; shouldn't hit this * code path. If we do, fix the caller to disallow it. */ g_return_val_if_fail (uris == NULL, TRUE); meta_window_activate (info->window, timestamp); return TRUE; } else if (info->type == SHELL_APP_INFO_TYPE_ENTRY) { /* Can't use g_desktop_app_info_new, see bug 614879 */ const char *filename = gmenu_tree_entry_get_desktop_file_path ((GMenuTreeEntry *)info->entry); gapp = g_desktop_app_info_new_from_filename (filename); } else { char *filename = shell_app_info_get_desktop_file_path (info); gapp = g_desktop_app_info_new_from_filename (filename); g_free (filename); } if (!gapp) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Not found"); return FALSE; } global = shell_global_get (); screen = shell_global_get_screen (global); if (timestamp == 0) timestamp = clutter_get_current_event_time (); if (workspace < 0) workspace = meta_screen_get_active_workspace_index (screen); context = gdk_app_launch_context_new (); gdk_app_launch_context_set_timestamp (context, timestamp); gdk_app_launch_context_set_desktop (context, workspace); shell_app = shell_app_system_get_app (shell_app_system_get_default (), shell_app_info_get_id (info)); /* In the case where we know an app, we handle reaping the child internally, * in the window tracker. */ if (shell_app != NULL) ret = g_desktop_app_info_launch_uris_as_manager (gapp, uris, G_APP_LAUNCH_CONTEXT (context), G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, _gather_pid_callback, shell_app, error); else ret = g_desktop_app_info_launch_uris_as_manager (gapp, uris, G_APP_LAUNCH_CONTEXT (context), G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL, error); g_object_unref (G_OBJECT (gapp)); return ret; }
static void write_entry( FILE* of, GMenuTreeEntry* item ) { const char* cstr; char* str; int flags = 0; // if( gmenu_tree_entry_get_is_nodisplay(item) /* || gmenu_tree_entry_get_is_excluded(item) */ ) // return; /* dekstop id, not necessarily the same as file basename */ fprintf( of, "-%s\n", gmenu_tree_entry_get_desktop_file_id( item ) ); /* Name */ fprintf( of, "%s\n", gmenu_tree_entry_get_name( item ) ); /* Comment */ cstr = gmenu_tree_entry_get_comment( item ); fprintf( of, "%s\n", cstr ? cstr : "" ); /* Icon */ cstr = gmenu_tree_entry_get_icon( item ); fprintf( of, "%s\n", cstr ? cstr : "" ); /* file dir/basename */ if( gmenu_tree_entry_get_desktop_file_path( item ) ) { /* file basenames are the same as desktop ids, except that sometimes * the '/' in paths are replaced with '-'. * for ex, /usr/share/applications/foo/bar.desktop has the app dir * /usr/share/applications, the filename foo/bar.desltop, and the * desktop id: foo-bar.desktop */ /* filename */ str = g_path_get_basename( gmenu_tree_entry_get_desktop_file_path( item ) ); if( strcmp(str, gmenu_tree_entry_get_desktop_file_id(item) ) ) fprintf( of, "%s\n", str ); else fprintf( of, "\n" ); g_free( str ); /* dirname */ str = g_path_get_dirname( gmenu_tree_entry_get_desktop_file_path( item ) ); fprintf( of, "%d\n", dirname_index( str) ); g_free( str ); } else { fprintf( of, "\n-1\n" ); } /* DisplayName */ cstr = gmenu_tree_entry_get_display_name( item ); fprintf( of, "%s\n", cstr ? cstr : "" ); /* Exec */ fprintf( of, "%s\n", gmenu_tree_entry_get_exec( item ) ); /* Terminal/StartupNotify flags */ if( gmenu_tree_entry_get_launch_in_terminal( item ) ) flags |= FLAG_USE_TERMINAL; if( gmenu_tree_entry_get_use_startup_notify( item ) ) flags |= FLAG_USE_SN; if( gmenu_tree_entry_get_is_nodisplay( item ) ) flags |= FLAG_IS_NODISPLAY; fprintf( of, "%u\n", flags ); /* ShowIn info */ fprintf( of, "%d\n", gmenu_tree_entry_get_show_in_flags(item) ); /* if( gmenu_tree_entry_get_desktop_file_path( item ) ) write_item_ex_info(of, gmenu_tree_entry_get_desktop_file_path( item )); fputs( "\n", of ); */ }