static void
load_apps_thread (GTask        *task,
                  gpointer      panel,
                  gpointer      task_data,
                  GCancellable *cancellable)
{
  GList *iter, *apps;

  apps = g_app_info_get_all ();

  for (iter = apps; iter && !g_cancellable_is_cancelled (cancellable); iter = iter->next)
    {
      GDesktopAppInfo *app;

      app = iter->data;
      if (g_desktop_app_info_get_boolean (app, "X-GNOME-UsesNotifications")) {
        process_app_info (panel, task, G_APP_INFO (app));
        g_debug ("Processing app '%s'", g_app_info_get_id (G_APP_INFO (app)));
      } else {
        g_debug ("Skipped app '%s', doesn't use notifications", g_app_info_get_id (G_APP_INFO (app)));
      }
    }

  g_list_free_full (apps, g_object_unref);
}
Exemple #2
0
EphyWebApplication *
ephy_web_application_for_profile_directory (const char *profile_dir)
{
  EphyWebApplication *app;
  char *desktop_file_path;
  const char *id;
  GDesktopAppInfo *desktop_info;
  const char *exec;
  int argc;
  char **argv;
  GFile *file;
  GFileInfo *file_info;
  guint64 created;
  GDate *date;

  id = get_app_id_from_profile_directory (profile_dir);
  if (!id)
    return NULL;

  app = g_new0 (EphyWebApplication, 1);
  app->id = g_strdup (id);

  app->desktop_file = get_app_desktop_filename (id);
  desktop_file_path = g_build_filename (profile_dir, app->desktop_file, NULL);
  desktop_info = g_desktop_app_info_new_from_filename (desktop_file_path);
  if (!desktop_info) {
    ephy_web_application_free (app);
    g_free (desktop_file_path);
    return NULL;
  }

  app->name = g_strdup (g_app_info_get_name (G_APP_INFO (desktop_info)));
  app->icon_url = g_desktop_app_info_get_string (desktop_info, "Icon");
  exec = g_app_info_get_commandline (G_APP_INFO (desktop_info));
  if (g_shell_parse_argv (exec, &argc, &argv, NULL)) {
    app->url = g_strdup (argv[argc - 1]);
    g_strfreev (argv);
  }

  g_object_unref (desktop_info);

  file = g_file_new_for_path (desktop_file_path);

  /* FIXME: this should use TIME_CREATED but it does not seem to be working. */
  file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED, 0, NULL, NULL);
  created = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED);

  date = g_date_new ();
  g_date_set_time_t (date, (time_t)created);
  g_date_strftime (app->install_date, 127, "%x", date);

  g_date_free (date);
  g_object_unref (file);
  g_object_unref (file_info);
  g_free (desktop_file_path);

  return app;
}
Exemple #3
0
static GList *
xde_entry(MenuContext *ctx, GMenuTreeEntry *ent)
{
	GDesktopAppInfo *info;
	GList *text = NULL, *acts;
	const char *name;
	char *esc1, *esc2, *cmd, *p;
	char *s, *icon = NULL;
	GIcon *gicon = NULL;
	char *appid;

	if (!(info = gmenu_tree_entry_get_app_info(ent)) || g_desktop_app_info_get_is_hidden(info)
	    || g_desktop_app_info_get_nodisplay(info) || !g_desktop_app_info_get_show_in(info, NULL)
	    || !g_app_info_should_show(G_APP_INFO(info)))
		return (text);
	name = g_app_info_get_name(G_APP_INFO(info));
	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);
	icon = xde_get_app_icon(ctx, info, gicon, "exec", "unknown",
				GET_ENTRY_ICON_FLAG_XPM | GET_ENTRY_ICON_FLAG_PNG |
				GET_ENTRY_ICON_FLAG_JPG | GET_ENTRY_ICON_FLAG_SVG);

	if (options.launch) {
		cmd = g_strdup_printf("xdg-launch --pointer %s", appid);
	} else {
		cmd = xde_get_command(info, appid, icon);
	}
	esc2 = xde_character_escape(cmd, '}');
	icon = ctx->wmm.wrap(ctx, icon);
	if (options.actions && (acts = ctx->wmm.ops.actions(ctx, ent, info))) {
		xde_increase_indent(ctx);
		s = g_strdup_printf("%s[exec] (%s) {%s}%s\n", ctx->indent, esc1, esc2, icon);
		xde_decrease_indent(ctx);
		acts = g_list_prepend(acts, s);
		s = g_strdup_printf("%s[submenu] (%s) {%s}%s\n", ctx->indent, esc1, esc1, icon);
		acts = g_list_prepend(acts, s);
		s = g_strdup_printf("%s[end]\n", ctx->indent);
		acts = g_list_append(acts, s);
		text = g_list_concat(text, acts);
	} else {
		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);
}
/* Now we implement a set of iterator functions that will handle item lookup hell for us. */
void menu_iterate_begin(pqi inst, menu_iter *it, int showfirst)
{
	it->reverse = FALSE;
	it->showfirst = showfirst;
	it->si = (inst->items->next? showfirst? inst->items : inst->items->next : inst->items);
	it->valid = (it->si != NULL);
	
	if (it->valid)
		it->text = g_app_info_get_display_name(G_APP_INFO(it->si->dfile)),
		it->icon = g_app_info_get_icon(G_APP_INFO(it->si->dfile));
}
void menu_iterate_rbegin(pqi inst, menu_iter *it, int showfirst)
{
	it->reverse = TRUE;
	it->showfirst = showfirst;
	it->si = inst->lastitem;
	it->valid = (it->si != NULL); /* Wehther or not we show the first item, whether or not this is the first item, if it exists, we return it. */
	
	if (it->valid)
		it->text = g_app_info_get_display_name(G_APP_INFO(it->si->dfile)),
		it->icon = g_app_info_get_icon(G_APP_INFO(it->si->dfile));
}
void menu_iter_next(menu_iter* it)
{
	if (it->reverse)
		it->si = it->si->prev,
		it->valid = (it->si != NULL && (it->showfirst || it->si->prev));
	else
		it->si = it->si->next,
		it->valid = (it->si != NULL);
	
	if (it->valid)
		it->text = g_app_info_get_display_name(G_APP_INFO(it->si->dfile)),
		it->icon = g_app_info_get_icon(G_APP_INFO(it->si->dfile));
}
static void
notification_cb (NotifyNotification *notification,
                 gchar              *action,
                 gpointer            user_data)
{
  GAppLaunchContext *ctx;
  GDesktopAppInfo *app;
  GError *error;

  /* TODO: Hmm, would be nice to set the screen, timestamp etc etc */
  ctx = g_app_launch_context_new ();

  app = g_desktop_app_info_new ("gnome-online-accounts-panel.desktop");

  error = NULL;
  if (!g_app_info_launch (G_APP_INFO (app),
                          NULL, /* files */
                          ctx,
                          &error))
    {
      goa_warning ("Error launching: %s (%s, %d)",
                   error->message, g_quark_to_string (error->domain), error->code);
      g_error_free (error);
    }
  g_object_unref (app);
  g_object_unref (ctx);
}
static gint
egg_compare_app_infos (gconstpointer a,
                       gconstpointer b,
                       gpointer      user_data)
{
  return strcmp (g_app_info_get_display_name (G_APP_INFO (a)), g_app_info_get_display_name (G_APP_INFO (b)));
}
Exemple #9
0
static void
on_open_with_easytag (NautilusMenuItem *item,
                      gpointer data)
{
    GList *files;
    GDesktopAppInfo *appinfo;

    files = g_object_get_data (G_OBJECT (item), "files");

    appinfo = g_desktop_app_info_new ("easytag.desktop");

    if (appinfo)
    {
        GdkAppLaunchContext *context;
        GList *l;
        GList *uris = NULL;

        for (l = files; l != NULL; l = g_list_next (l))
        {
            uris = g_list_append (uris,
                                  nautilus_file_info_get_uri (l->data));
        }

        context = gdk_display_get_app_launch_context (gdk_display_get_default ());

        g_app_info_launch_uris (G_APP_INFO (appinfo), uris,
                                G_APP_LAUNCH_CONTEXT (context), NULL);
    }
}
Exemple #10
0
/**
 * cinnamon_app_create_icon_texture:
 *
 * Look up the icon for this application, and create a #ClutterTexture
 * for it at the given size.
 *
 * Return value: (transfer none): A floating #ClutterActor
 */
ClutterActor *
cinnamon_app_create_icon_texture (CinnamonApp   *app,
                               int         size)
{
  GIcon *icon;
  ClutterActor *ret;

  ret = NULL;

  if (app->entry == NULL)
    return window_backed_app_get_icon (app, size);

  icon = g_app_info_get_icon (G_APP_INFO (gmenu_tree_entry_get_app_info (app->entry)));
  if (icon != NULL)
    ret = st_texture_cache_load_gicon (st_texture_cache_get_default (), NULL, icon, size);

  if (ret == NULL)
    {
      icon = g_themed_icon_new ("application-x-executable");
      ret = st_texture_cache_load_gicon (st_texture_cache_get_default (), NULL, icon, size);
      g_object_unref (icon);
    }

  return ret;
}
static gchar *
gtk_application_window_get_app_desktop_name (void)
{
  gchar *retval = NULL;

#ifdef HAVE_GIO_UNIX
  GDesktopAppInfo *app_info;
  const gchar *app_name = NULL;
  gchar *desktop_file;

  desktop_file = g_strconcat (g_get_prgname (), ".desktop", NULL);
  app_info = g_desktop_app_info_new (desktop_file);
  g_free (desktop_file);

  if (app_info != NULL)
    app_name = g_app_info_get_name (G_APP_INFO (app_info));

  if (app_name != NULL)
    retval = g_strdup (app_name);

  g_clear_object (&app_info);
#endif /* HAVE_GIO_UNIX */

  return retval;
}
Exemple #12
0
gboolean
panel_launch_key_file (GKeyFile   *keyfile,
		       GList      *uri_list,
		       GdkScreen  *screen,
		       GError    **error)
{
	GDesktopAppInfo *appinfo;
	gboolean         retval;

	g_return_val_if_fail (keyfile != NULL, FALSE);
	g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
	g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

	appinfo = g_desktop_app_info_new_from_keyfile (keyfile);

	if (appinfo == NULL)
		return FALSE;

	retval = panel_app_info_launch_uris (G_APP_INFO (appinfo),
					     uri_list, screen,
					     gtk_get_current_event_time (),
					     error);

	g_object_unref (appinfo);

	return retval;
}
static void
maybe_add_app_id (CcNotificationsPanel *panel,
                  const char *canonical_app_id)
{
  Application *app;
  gchar *path;
  gchar *full_app_id;
  GSettings *settings;
  GAppInfo *app_info;

  if (g_hash_table_contains (panel->known_applications,
                             canonical_app_id))
    return;

  path = g_strconcat (APP_PREFIX, canonical_app_id, "/", NULL);
  settings = g_settings_new_with_path (APP_SCHEMA, path);

  full_app_id = g_settings_get_string (settings, "application-id");
  app_info = G_APP_INFO (g_desktop_app_info_new (full_app_id));

  if (app_info == NULL) {
    /* The application cannot be found, probably it was uninstalled */
    g_object_unref (settings);
  } else {
    app = g_slice_new (Application);
    app->canonical_app_id = g_strdup (canonical_app_id);
    app->settings = settings;
    app->app_info = app_info;

    add_application (panel, app);
  }

  g_free (path);
  g_free (full_app_id);
}
static void
_settings_launcher_button_clicked_cb (MxButton *button,
                                      gpointer  userdata)
{
  MnbPeoplePanelPrivate *priv = GET_PRIVATE (userdata);
  GDesktopAppInfo *app_info;
  GError *error = NULL;
  const gchar *args[2] = { NULL, };

  app_info = g_desktop_app_info_new ("empathy-accounts.desktop");
  args[0] = g_app_info_get_commandline (G_APP_INFO (app_info));
  args[1] = NULL;

  if (!g_spawn_async (NULL,
                      (gchar **)args,
                      NULL,
                      G_SPAWN_SEARCH_PATH,
                      NULL,
                      NULL,
                      NULL,
                      &error))
  {
    g_warning (G_STRLOC ": Error starting empathy-accounts: %s",
               error->message);
    g_clear_error (&error);
  } else {
    if (priv->panel_client)
      mpl_panel_client_hide (priv->panel_client);
  }

  g_object_unref (app_info);
}
Exemple #15
0
static MxAction *
_action_new_from_desktop_file (const gchar *desktop_file_id)
{
  GDesktopAppInfo *dai;

  dai = g_desktop_app_info_new (desktop_file_id);

  if (dai)
    {
      MxAction *action;
      GAppInfo *ai;
      GIcon *icon;

      ai = G_APP_INFO (dai);

      action = mx_action_new_full (g_app_info_get_name (ai),
                                   g_app_info_get_display_name (ai),
                                   G_CALLBACK (_app_launcher_cb),
                                   (gpointer)g_app_info_get_commandline (ai));

     icon = g_app_info_get_icon (ai);
     if (icon)
       {
         gchar *icon_name;
         icon_name =  g_icon_to_string (icon);

         mx_action_set_icon (action, icon_name);

         g_free (icon_name);
       }

      return action;
    }
  return NULL;
}
static GtkHotkeyInfo*
get_hotkey_info_from_key_file (GKeyFile	*keyfile,
							   const gchar *app_id,
							   const gchar *key_id,
							   GError **error)
{
	GtkHotkeyInfo   *info = NULL;
	gchar			*group, *description, *app_info_id, *signature;
	GAppInfo		*app_info = NULL;
	
	g_return_val_if_fail (keyfile != NULL, NULL);
	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
	g_return_val_if_fail (app_id != NULL, NULL);
	g_return_val_if_fail (key_id != NULL, NULL);
	
	group = g_strconcat (HOTKEY_GROUP, key_id, NULL);
	description = g_key_file_get_string (keyfile, group, "Description", NULL);
	app_info_id = g_key_file_get_string (keyfile, group, "AppInfo", NULL);
	signature = g_key_file_get_string (keyfile, group, "Signature", NULL);
	
	if (!g_key_file_has_group (keyfile, group)) {
		g_set_error (error, GTK_HOTKEY_REGISTRY_ERROR,
					 GTK_HOTKEY_REGISTRY_ERROR_UNKNOWN_KEY,
					 "Keyfile has no group "HOTKEY_GROUP"%s", key_id);
		goto clean_up;
	}
	
	if (!signature) {
		g_set_error (error, GTK_HOTKEY_REGISTRY_ERROR,
					 GTK_HOTKEY_REGISTRY_ERROR_BAD_SIGNATURE,
					 "No 'Signature' defined for hotkey '%s' for application '%s'",
					 key_id, app_id);
		goto clean_up;
	}
	
	if (app_info_id) {
		app_info = G_APP_INFO(g_desktop_app_info_new (app_info_id));
		if (!G_IS_APP_INFO(app_info)) {
			g_set_error (error, GTK_HOTKEY_REGISTRY_ERROR,
						 GTK_HOTKEY_REGISTRY_ERROR_MISSING_APP,
						 "Keyfile refering to 'AppInfo = %s', but no application"
						 "by that id is registered on the system", app_info_id);
			goto clean_up;
		}	
	}
	
	info = gtk_hotkey_info_new (app_id, key_id, signature, app_info);
	if (description)
		gtk_hotkey_info_set_description (info, description);
	
	clean_up:
		g_free (group);
		if (signature) g_free (signature);
		if (description) g_free (description);
		if (app_info_id) g_free (app_info_id);
		if (app_info) g_object_unref (app_info);
			
	return info;
}
/**
 * pk_plugin_sqlite_add_filename_details:
 **/
static gint
pk_plugin_sqlite_add_filename_details (PkPlugin *plugin,
				       const gchar *filename,
				       const gchar *package,
				       const gchar *md5)
{
	gchar *statement;
	gchar *error_msg = NULL;
	sqlite3_stmt *sql_statement = NULL;
	gint rc = -1;
	gint show;
	GDesktopAppInfo *info;

	/* find out if we should show desktop file in menus */
	info = g_desktop_app_info_new_from_filename (filename);
	if (info == NULL) {
		g_warning ("could not load desktop file %s", filename);
		goto out;
	}
	show = g_app_info_should_show (G_APP_INFO (info));
	g_object_unref (info);

	g_debug ("add filename %s from %s with md5: %s (show: %i)",
		 filename, package, md5, show);

	/* the row might already exist */
	statement = g_strdup_printf ("DELETE FROM cache WHERE filename = '%s'",
				     filename);
	sqlite3_exec (plugin->priv->db, statement, NULL, NULL, NULL);
	g_free (statement);

	/* prepare the query, as we don't escape it */
	rc = sqlite3_prepare_v2 (plugin->priv->db,
				 "INSERT INTO cache (filename, package, show, md5) "
				 "VALUES (?, ?, ?, ?)",
				 -1, &sql_statement, NULL);
	if (rc != SQLITE_OK) {
		g_warning ("SQL failed to prepare: %s",
			   sqlite3_errmsg (plugin->priv->db));
		goto out;
	}

	/* add data */
	sqlite3_bind_text (sql_statement, 1, filename, -1, SQLITE_STATIC);
	sqlite3_bind_text (sql_statement, 2, package, -1, SQLITE_STATIC);
	sqlite3_bind_int (sql_statement, 3, show);
	sqlite3_bind_text (sql_statement, 4, md5, -1, SQLITE_STATIC);

	/* save this */
	sqlite3_step (sql_statement);
	rc = sqlite3_finalize (sql_statement);
	if (rc != SQLITE_OK) {
		g_warning ("SQL error: %s\n", error_msg);
		sqlite3_free (error_msg);
		goto out;
	}
out:
	return rc;
}
Exemple #18
0
/* Take a desktop file and execute it */
static void
desktop_activate_cb (DbusmenuMenuitem * mi, guint timestamp, gpointer data)
{
	GAppInfo * appinfo = G_APP_INFO(data);
	g_return_if_fail(appinfo != NULL);
	g_app_info_launch(appinfo, NULL, NULL, NULL);
	return;
}
Exemple #19
0
const char *
cinnamon_app_get_description (CinnamonApp *app)
{
  if (app->entry)
    return g_app_info_get_description (G_APP_INFO (gmenu_tree_entry_get_app_info (app->entry)));
  else
    return NULL;
}
Exemple #20
0
static gboolean
exo_open_launch_desktop_file (const gchar *arg)
{
#ifdef HAVE_GIO_UNIX
  GFile           *gfile;
  gchar           *contents;
  gsize            length;
  gboolean         result;
  GKeyFile        *key_file;
  GDesktopAppInfo *appinfo;

  /* try to open a file from the arguments */
  gfile = g_file_new_for_commandline_arg (arg);
  if (G_UNLIKELY (gfile == NULL))
    return FALSE;

  /* load the contents of the file */
  result = g_file_load_contents (gfile, NULL, &contents, &length, NULL, NULL);
  g_object_unref (G_OBJECT (gfile));
  if (G_UNLIKELY (!result || length == 0))
    return FALSE;

  /* create the key file */
  key_file = g_key_file_new ();
  result = g_key_file_load_from_data (key_file, contents, length, G_KEY_FILE_NONE, NULL);
  g_free (contents);
  if (G_UNLIKELY (!result))
    {
      g_key_file_free (key_file);
      return FALSE;
    }

  /* create the appinfo */
  appinfo = g_desktop_app_info_new_from_keyfile (key_file);
  g_key_file_free (key_file);
  if (G_UNLIKELY (appinfo == NULL))
    return FALSE;

  /* try to launch a (non-hidden) desktop file */
  if (G_LIKELY (!g_desktop_app_info_get_is_hidden (appinfo)))
    result = g_app_info_launch (G_APP_INFO (appinfo), NULL, NULL, NULL);
  else
    result = FALSE;

  g_object_unref (G_OBJECT (appinfo));

#ifndef NDEBUG
  g_debug ("launching desktop file %s", result ? "succeeded" : "failed");
#endif

  return result;
#else /* !HAVE_GIO_UNIX */
  g_critical (_("Launching desktop files is not supported when %s is compiled "
                "without GIO-Unix features."), g_get_prgname ());

  return FALSE;
#endif
}
static void on_browse_btn_clicked(GtkButton* btn, AppChooserData* data)
{
    FmPath* file;
    GtkFileFilter* filter = gtk_file_filter_new();
    char* binary;
    gtk_file_filter_add_custom(filter,
        GTK_FILE_FILTER_FILENAME|GTK_FILE_FILTER_MIME_TYPE, exec_filter_func, NULL, NULL);
    /* gtk_file_filter_set_name(filter, _("Executable files")); */
    file = fm_select_file(GTK_WINDOW(data->dlg), NULL, "/usr/bin", TRUE, FALSE, filter, NULL);

    if (file == NULL)
        return;
    binary = fm_path_to_str(file);
    if (g_str_has_suffix(fm_path_get_basename(file), ".desktop"))
    {
        GKeyFile *kf = g_key_file_new();
        GDesktopAppInfo *info;
        if (g_key_file_load_from_file(kf, binary, 0, NULL) &&
            (info = g_desktop_app_info_new_from_keyfile(kf)) != NULL)
            /* it is a valid desktop entry */
        {
            /* FIXME: it will duplicate the file, how to avoid that? */
            gtk_entry_set_text(data->cmdline,
                               g_app_info_get_commandline(G_APP_INFO(info)));
            gtk_entry_set_text(data->app_name,
                               g_app_info_get_name(G_APP_INFO(info)));
            gtk_toggle_button_set_active(data->use_terminal,
                                         g_key_file_get_boolean(kf, G_KEY_FILE_DESKTOP_GROUP,
                                                                G_KEY_FILE_DESKTOP_KEY_TERMINAL,
                                                                NULL));
            gtk_toggle_button_set_active(data->keep_open,
                                         g_key_file_get_boolean(kf, G_KEY_FILE_DESKTOP_GROUP,
                                                                "X-KeepTerminal",
                                                                NULL));
            g_object_unref(info);
            g_key_file_free(kf);
            fm_path_unref(file);
            return;
        }
        g_key_file_free(kf);
    }
    gtk_entry_set_text(data->cmdline, binary);
    g_free(binary);
    fm_path_unref(file);
}
Exemple #22
0
static GList *
xde_entry(MenuContext *ctx, GMenuTreeEntry *ent)
{
	GDesktopAppInfo *info;
	GList *text = NULL;
	const char *name;
	char *esc1, *qname, *esc2, *cmd, *p;
	char *s, *icon = NULL;
	GIcon *gicon = NULL;
	char *appid;

	if (!(info = gmenu_tree_entry_get_app_info(ent)) || g_desktop_app_info_get_is_hidden(info)
	    || g_desktop_app_info_get_nodisplay(info) || !g_desktop_app_info_get_show_in(info, NULL)
	    || !g_app_info_should_show(G_APP_INFO(info)))
		return (text);
	name = g_app_info_get_name(G_APP_INFO(info));
	esc1 = xde_character_escape(name, '"');
	qname = g_strdup_printf("\"%s\"", esc1);

	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);
	icon = xde_get_app_icon(ctx, info, gicon, "exec", "unknown",
				GET_ENTRY_ICON_FLAG_XPM | GET_ENTRY_ICON_FLAG_PNG |
				GET_ENTRY_ICON_FLAG_JPG | GET_ENTRY_ICON_FLAG_SVG);
	if (options.launch) {
		cmd = g_strdup_printf("xdg-launch --pointer %s", appid);
	} else {
		cmd = xde_get_command(info, appid, icon);
	}
	esc2 = xde_character_escape(cmd, '"');

	s = g_strdup_printf("    %-32s  f.exec \"exec %s &\"\n", qname, esc2);
	text = g_list_append(text, s);

	free(icon);
	free(appid);
	g_free(qname);
	free(esc1);
	free(esc2);
	free(cmd);
	return (text);
}
Exemple #23
0
static void on_content_type_finished(GObject* src_obj, GAsyncResult* res, gpointer user_data)
{
    AutoRun* data = (AutoRun*)user_data;
    GMount* mount = G_MOUNT(src_obj);
    char** types;
    char* desc = NULL;

    types = g_mount_guess_content_type_finish(mount, res, NULL);
    if(types)
    {
        GtkTreeIter it;
        GList* apps = NULL, *l;
        char** type;
        if(types[0])
        {
            for(type=types;*type;++type)
            {
                l = g_app_info_get_all_for_type(*type);
                if(l)
                    apps = g_list_concat(apps, l);
            }
            desc = g_content_type_get_description(types[0]);
        }
        g_strfreev(types);

        if(apps)
        {
            int pos = 0;
            GtkTreePath* tp;
            for(l = apps; l; l=l->next, ++pos)
            {
                GAppInfo* app = G_APP_INFO(l->data);
                gtk_list_store_insert_with_values(data->store, &it, pos,
                                   0, g_app_info_get_icon(app),
                                   1, g_app_info_get_name(app),
                                   2, app, -1);
                g_object_unref(app);
            }
            g_list_free(apps);

            gtk_tree_model_get_iter_first(GTK_TREE_MODEL(data->store), &it);
            gtk_tree_selection_select_iter(gtk_tree_view_get_selection(data->view), &it);
            tp = gtk_tree_path_new_first();
            gtk_tree_view_set_cursor(data->view, tp, NULL, FALSE);
            gtk_tree_path_free(tp);
        }
    }

    if(desc)
    {
        gtk_label_set_text(data->type, desc);
        g_free(desc);
    }
    else
        gtk_label_set_text(data->type, _("Removable Disk"));

}
Exemple #24
0
/* Look at the GAppInfo structures and sort based on
   the application names */
static gint
sort_app_infos (gconstpointer a, gconstpointer b)
{
	GAppInfo * appa = G_APP_INFO(a);
	GAppInfo * appb = G_APP_INFO(b);

	const gchar * namea = NULL;
	const gchar * nameb = NULL;

	if (appa != NULL) {
		namea = g_app_info_get_name(appa);
	}

	if (appb != NULL) {
		nameb = g_app_info_get_name(appb);
	}

	return g_strcmp0(namea, nameb);
}
Exemple #25
0
JS_EXPORT_API
char* dcore_get_name_by_appid(const char* id)
{
    GDesktopAppInfo* a = guess_desktop_file(id);
    if (a != NULL) {
        char* name = g_strdup(g_app_info_get_name(G_APP_INFO(a)));
        g_object_unref(a);
        return name;
    }
    return g_strdup("");
}
const char *
desktop_entry_get_comment (DesktopEntry *entry)
{
  if (entry->type == DESKTOP_ENTRY_DESKTOP)
    {
      g_return_val_if_fail (G_IS_DESKTOP_APP_INFO (((DesktopEntryDesktop*)entry)->appinfo), NULL);
      return g_app_info_get_description (G_APP_INFO (((DesktopEntryDesktop*)entry)->appinfo));
    }

  return ((DesktopEntryDirectory*)entry)->comment;
}
GIcon *
desktop_entry_get_icon (DesktopEntry *entry)
{
  if (entry->type == DESKTOP_ENTRY_DESKTOP)
    {
      g_return_val_if_fail (G_IS_DESKTOP_APP_INFO (((DesktopEntryDesktop*)entry)->appinfo), NULL);
      return g_app_info_get_icon (G_APP_INFO (((DesktopEntryDesktop*)entry)->appinfo));
    }

  return ((DesktopEntryDirectory*)entry)->icon;
}
Exemple #28
0
/**
 * fm_app_menu_view_dup_selected_app
 * @view: a widget
 *
 * Retrieves selected application from the widget.
 * The returned data should be freed with g_object_unref() after usage.
 *
 * Before 1.0.0 this call had name fm_app_menu_view_get_selected_app.
 *
 * Returns: (transfer full): selected application descriptor.
 *
 * Since: 0.1.0
 */
GAppInfo* fm_app_menu_view_dup_selected_app(GtkTreeView* view)
{
    char* id = fm_app_menu_view_dup_selected_app_desktop_id(view);
    if(id)
    {
        GDesktopAppInfo* app = g_desktop_app_info_new(id);
        g_free(id);
        return G_APP_INFO(app);
    }
    return NULL;
}
Exemple #29
0
static void
cinnamon_app_init_search_data (CinnamonApp *app)
{
  const char *name;
  const char *exec;
  const char *comment;
  char *normalized_exec;
  GDesktopAppInfo *appinfo;

  appinfo = gmenu_tree_entry_get_app_info (app->entry);
  name = g_app_info_get_name (G_APP_INFO (appinfo));
  app->casefolded_name = cinnamon_util_normalize_and_casefold (name);

  comment = g_app_info_get_description (G_APP_INFO (appinfo));
  app->casefolded_description = cinnamon_util_normalize_and_casefold (comment);

  exec = g_app_info_get_executable (G_APP_INFO (appinfo));
  normalized_exec = cinnamon_util_normalize_and_casefold (exec);
  app->casefolded_exec = trim_exec_line (normalized_exec);
  g_free (normalized_exec);
}
Exemple #30
0
gboolean
empathy_launch_external_app (const gchar *desktop_file,
    const gchar *args,
    GError **error)
{
  GDesktopAppInfo *desktop_info;
  gboolean result;
  GError *err = NULL;

  desktop_info = g_desktop_app_info_new (desktop_file);
  if (desktop_info == NULL)
    {
      DEBUG ("%s not found", desktop_file);

      g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
          "%s not found", desktop_file);
      return FALSE;
    }

  if (args == NULL)
    {
      result = launch_app_info (G_APP_INFO (desktop_info), error);
    }
  else
    {
      gchar *cmd;
      GAppInfo *app_info;

      /* glib doesn't have API to start a desktop file with args... (#637875) */
      cmd = g_strdup_printf ("%s %s", g_app_info_get_commandline (
            (GAppInfo *) desktop_info), args);

      app_info = g_app_info_create_from_commandline (cmd, NULL, 0, &err);
      if (app_info == NULL)
        {
          DEBUG ("Failed to launch '%s': %s", cmd, err->message);
          g_free (cmd);
          g_object_unref (desktop_info);
          g_propagate_error (error, err);
          return FALSE;
        }

      result = launch_app_info (app_info, error);

      g_object_unref (app_info);
      g_free (cmd);
    }

  g_object_unref (desktop_info);
  return result;
}