void gl_ui_cmd_file_open_recent (GtkRecentChooser *chooser, glWindow *window) { GtkRecentInfo *item; gchar *utf8_filename; gl_debug (DEBUG_COMMANDS, "START"); g_return_if_fail (chooser && GTK_IS_RECENT_CHOOSER(chooser)); g_return_if_fail (window && GL_IS_WINDOW(window)); item = gtk_recent_chooser_get_current_item (chooser); if (!item) return; utf8_filename = gl_recent_get_utf8_filename (item); gl_debug (DEBUG_COMMANDS, "Selected %s\n", utf8_filename); gl_file_open_recent (utf8_filename, window); gtk_recent_info_unref (item); gl_debug (DEBUG_COMMANDS, "END"); }
static void item_activated_cb (GtkRecentChooser *chooser, gpointer data) { GtkRecentInfo *info; GString *text; gchar *label_text; info = gtk_recent_chooser_get_current_item (chooser); if (!info) { g_warning ("Unable to retrieve the current item, aborting..."); return; } text = g_string_new ("Selected recent item:\n"); g_string_append_printf (text, " URI: %s\n", gtk_recent_info_get_uri (info)); g_string_append_printf (text, " MIME Type: %s\n", gtk_recent_info_get_mime_type (info)); label_text = g_string_free (text, FALSE); gtk_label_set_text (GTK_LABEL (label), label_text); gtk_recent_info_unref (info); g_free (label_text); }
JNIEXPORT jlong JNICALL Java_org_gnome_gtk_GtkRecentChooser_gtk_1recent_1chooser_1get_1current_1item ( JNIEnv* env, jclass cls, jlong _self ) { GtkRecentInfo* result; jlong _result; GtkRecentChooser* self; // convert parameter self self = (GtkRecentChooser*) _self; // call function result = gtk_recent_chooser_get_current_item(self); // cleanup parameter self // translate return value to JNI type _result = (jlong) result; // and finally return _result; }
/** * Print the uri of the selected item in a recent file chooser. * @param recent_chooser recent file chooser to print information about */ void mk_print_GtkRecentChooser_info(GtkRecentChooser* recent_chooser) { GtkRecentInfo* info; info = gtk_recent_chooser_get_current_item(recent_chooser); if (info != NULL) { const gchar* uri = gtk_recent_info_get_uri(info); g_printf("\t%s", uri); gtk_recent_info_unref(info); } }
static void recent_cb (GSimpleAction *action, GVariant *parameter, gpointer app) { GtkWidget *dialog; GtkWindow *win; GtkRecentInfo *info; GtkRecentChooser *chooser; GtkRecentFilter *filter; GtkRecentFilter *filter_all; const gchar *uri = NULL; win = gtk_application_get_active_window (app); dialog = gtk_recent_chooser_dialog_new ( _("Recent Files"), win, _("_Cancel"), GTK_RESPONSE_CANCEL, _("_Open"), GTK_RESPONSE_ACCEPT, NULL); gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (dialog), GTK_RECENT_SORT_MRU); /* Most Recently Used first */ gtk_recent_chooser_set_show_icons (GTK_RECENT_CHOOSER (dialog), TRUE); filter = gtk_recent_filter_new (); gtk_recent_filter_set_name (filter, _("Parlatype")); gtk_recent_filter_add_application (filter, "parlatype"); gtk_recent_filter_add_mime_type (filter, "audio/*"); gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (dialog), filter); filter_all = gtk_recent_filter_new (); gtk_recent_filter_set_name (filter_all, _("All files")); gtk_recent_filter_add_pattern (filter_all, "*"); gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (dialog), filter_all); gtk_recent_chooser_set_filter (GTK_RECENT_CHOOSER (dialog), filter); if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { chooser = GTK_RECENT_CHOOSER (dialog); info = gtk_recent_chooser_get_current_item (chooser); uri = gtk_recent_info_get_uri (info); } gtk_widget_destroy (dialog); if (uri) { /* GStreamer has problems with uris from recent chooser, as a workaround use GFile magic */ GFile *file = g_file_new_for_uri (uri); gchar *tmp = g_file_get_uri (file); pt_window_open_file (PT_WINDOW (win), tmp); g_free (tmp); g_object_unref (file); gtk_recent_info_unref (info); } }
static void recent_documents_activate_cb (GtkRecentChooser *chooser, gpointer data) { GtkRecentInfo *recent_info; const char *uri; const char *mime_type; GdkScreen *screen; GError *error = NULL; screen = gtk_widget_get_screen (GTK_WIDGET (chooser)); recent_info = gtk_recent_chooser_get_current_item (chooser); uri = gtk_recent_info_get_uri (recent_info); mime_type = gtk_recent_info_get_mime_type (recent_info); //FIXME gtk_recent_info_get_application_info() could be useful if (show_uri (uri, mime_type, screen, &error) != TRUE) { char *uri_utf8; uri_utf8 = g_filename_to_utf8 (uri, -1, NULL, NULL, NULL); //FIXME this could fail... Maybe we want gtk_recent_info_get_display_name() if (error) { char *primary; primary = g_strdup_printf (_("Could not open recently used document \"%s\""), uri_utf8); panel_error_dialog (NULL, screen, "cannot_open_recent_doc", TRUE, primary, error->message); g_free (primary); g_error_free (error); } else { char *primary; char *secondary; primary = g_strdup_printf (_("Could not open recently used document \"%s\""), uri_utf8); secondary = g_strdup_printf (_("An unknown error occurred while trying to open \"%s\"."), uri_utf8); panel_error_dialog (NULL, screen, "cannot_open_recent_doc", TRUE, primary, secondary); g_free (primary); g_free (secondary); } g_free (uri_utf8); } /* we can unref it only after having used the data we fetched from it */ gtk_recent_info_unref (recent_info); }
void on_open_recent_activate (GtkRecentChooser *chooser, gpointer user_data) { GtkRecentInfo *item; gchar *filename; gchar *utf8_filename = NULL; GtkWidget *dialog; const gchar *uri; g_return_if_fail (chooser && GTK_IS_RECENT_CHOOSER(chooser)); item = gtk_recent_chooser_get_current_item (chooser); if (!item) return; uri = gtk_recent_info_get_uri (item); filename = g_filename_from_uri (uri, NULL, NULL); if ( filename != NULL ) { utf8_filename = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL); g_free (filename); } if (! utf8_filename || ! ca_open (utf8_filename, FALSE)) { dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Problem when opening '%s' CA database"), utf8_filename); gtk_dialog_run (GTK_DIALOG(dialog)); gtk_widget_destroy (dialog); } else { __recent_add_utf8_filename (utf8_filename); } gtk_recent_info_unref (item); return; }
/* Callback for when of the items from the File->Open Recent submenu is selected */ void action_open_recent(GtkAction *action, I7App *app) { GtkRecentInfo *item = gtk_recent_chooser_get_current_item(GTK_RECENT_CHOOSER(action)); g_assert(gtk_recent_info_has_application(item, "Inform 7")); GFile *file = g_file_new_for_uri(gtk_recent_info_get_uri(item)); if(gtk_recent_info_has_group(item, "inform7_project")) { i7_story_new_from_file(app, file); } else if(gtk_recent_info_has_group(item, "inform7_extension")) { i7_extension_new_from_file(app, file, FALSE); } else if(gtk_recent_info_has_group(item, "inform7_builtin")) { i7_extension_new_from_file(app, file, TRUE); } else { g_warning("Recent manager file does not have an Inform tag. This means " "it was not saved by Inform. I'll try to open it anyway."); i7_story_new_from_file(app, file); } g_object_unref(file); gtk_recent_info_unref(item); }
static VALUE rc_get_current_item(VALUE self) { return BOXED2RVAL(gtk_recent_chooser_get_current_item(_SELF(self)), GTK_TYPE_RECENT_INFO); }