static void remove_clicked_cb (GtkMenuItem *item, gpointer user_data) { NemoMimeApplicationChooser *chooser = user_data; GError *error; GAppInfo *info; info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (chooser->details->open_with_widget)); if (info) { error = NULL; if (!g_app_info_remove_supports_type (info, chooser->details->content_type, &error)) { eel_show_error_dialog (_("Could not forget association"), error->message, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (chooser)))); g_error_free (error); } gtk_app_chooser_refresh (GTK_APP_CHOOSER (chooser->details->open_with_widget)); g_object_unref (info); } g_signal_emit_by_name (nemo_signaller_get_current (), "mime_data_changed"); }
static VALUE appinfo_remove_supports_type(VALUE self, VALUE value) { GError *error = NULL; if (!g_app_info_remove_supports_type(_SELF(self), RVAL2CSTR(value), &error)) rbgio_raise_error(error); return self; }
static void delete_recent_cb (GtkWidget *widget, gpointer callback_data) { DialogData *data = callback_data; GtkTreeSelection *selection; GtkTreeIter iter; if (data->last_clicked_list == data->o_recent_tree_view) { char *editor; char **editors; selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->o_recent_tree_view)); if (! gtk_tree_selection_get_selected (selection, NULL, &iter)) return; gtk_tree_model_get (data->recent_model, &iter, 0, &editor, -1); gtk_list_store_remove (GTK_LIST_STORE (data->recent_model), &iter); /**/ editors = g_settings_get_strv (data->settings, PREF_GENERAL_EDITORS); if (_g_strv_remove (editors, editor)) g_settings_set_strv (data->settings, PREF_GENERAL_EDITORS, (const gchar * const *) editors); g_strfreev (editors); g_free (editor); } else if (data->last_clicked_list == data->o_app_tree_view) { GAppInfo *app; selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->o_app_tree_view)); if (! gtk_tree_selection_get_selected (selection, NULL, &iter)) return; gtk_tree_model_get (data->app_model, &iter, DATA_COLUMN, &app, -1); gtk_list_store_remove (GTK_LIST_STORE (data->app_model), &iter); if (g_app_info_can_remove_supports_type (app)) { const char *mime_type; mime_type = get_file_mime_type_for_path ((char*) data->file_list->data, FALSE); g_app_info_remove_supports_type (app, mime_type, NULL); } } }
static void forget_menu_item_activate_cb (GtkMenuItem *item, gpointer user_data) { GtkAppChooserDialog *self = user_data; GAppInfo *info; info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self)); if (info != NULL) { g_app_info_remove_supports_type (info, self->priv->content_type, NULL); gtk_app_chooser_refresh (GTK_APP_CHOOSER (self)); g_object_unref (info); } }
static GAppInfo* app_info_create_from_commandline(const char *commandline, const char *application_name, const char *bin_name, const char *mime_type, gboolean terminal, gboolean keep) { GAppInfo* app = NULL; char* dirname = g_build_filename (g_get_user_data_dir (), "applications", NULL); const char* app_basename = strrchr(bin_name, '/'); if(app_basename) app_basename++; else app_basename = bin_name; if(g_mkdir_with_parents(dirname, 0700) == 0) { char *filename = NULL; int fd; #if GLIB_CHECK_VERSION(2, 37, 6) if (mime_type && application_name[0]) { /* SF bug #871: new GLib has ids cached so we do a trick here: we create a dummy app before really creating the file */ app = g_app_info_create_from_commandline(commandline, app_basename, 0, NULL); if (app) { g_app_info_remove_supports_type(app, mime_type, NULL); filename = g_strdup(g_desktop_app_info_get_filename(G_DESKTOP_APP_INFO(app))); g_object_unref(app); app = NULL; } } if (filename) fd = g_open(filename, O_RDWR, 0); else #endif { filename = g_strdup_printf ("%s/userapp-%s-XXXXXX.desktop", dirname, app_basename); fd = g_mkstemp (filename); } if(fd != -1) { GString* content = g_string_sized_new(256); g_string_printf(content, "[" G_KEY_FILE_DESKTOP_GROUP "]\n" G_KEY_FILE_DESKTOP_KEY_TYPE "=" G_KEY_FILE_DESKTOP_TYPE_APPLICATION "\n" G_KEY_FILE_DESKTOP_KEY_NAME "=%s\n" G_KEY_FILE_DESKTOP_KEY_EXEC "=%s\n" G_KEY_FILE_DESKTOP_KEY_CATEGORIES "=Other;\n" G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY "=true\n", application_name, commandline ); if(mime_type) g_string_append_printf(content, G_KEY_FILE_DESKTOP_KEY_MIME_TYPE "=%s\n", mime_type); g_string_append_printf(content, G_KEY_FILE_DESKTOP_KEY_TERMINAL "=%s\n", terminal ? "true" : "false"); if(terminal) g_string_append_printf(content, "X-KeepTerminal=%s\n", keep ? "true" : "false"); close(fd); /* g_file_set_contents() may fail creating duplicate */ if(g_file_set_contents(filename, content->str, content->len, NULL)) { char *fbname = g_path_get_basename(filename); app = G_APP_INFO(g_desktop_app_info_new(fbname)); g_free(fbname); if (app == NULL) { g_warning("failed to load %s as an application", filename); g_unlink(filename); } /* if there is mime_type set then created application will be saved for the mime type (see fm_choose_app_for_mime_type() below) but if not then we should remove this temp. file */ else if (!mime_type || !application_name[0]) /* save the name so this file will be removed later */ g_object_weak_ref(G_OBJECT(app), on_temp_appinfo_destroy, g_strdup(filename)); } else g_unlink(filename); g_string_free(content, TRUE); } g_free(filename); } g_free(dirname); return app; }