Beispiel #1
0
/* 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);
}
Beispiel #2
0
static GtkListStore *
get_list_store(const gchar *recent_group)
{
  GtkRecentManager *manager = gtk_recent_manager_get_default();
  
  GtkListStore *store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);

  GList *ptr;
  int count = 0;
  GtkTreeIter iter;
  GList *list = gtk_recent_manager_get_items(manager);
  for (ptr = list; (ptr != NULL) && (count < 10); ptr = ptr->next)
    {
      GtkRecentInfo *info = ptr->data;
      if (!gtk_recent_info_has_application(info, "KCemu"))
        continue;
      if ((recent_group != NULL) && !gtk_recent_info_has_group(info, recent_group))
        continue;

      GFile *file = g_file_new_for_uri(gtk_recent_info_get_uri(info));
      if (g_file_is_native(file) /* && g_file_query_exists(file, NULL) */)
        {
          gchar *path = g_file_get_path(file);
          gchar *basename = g_file_get_basename(file);

          if ((path != NULL) && (basename != NULL))
            {
              gtk_list_store_append(store, &iter);
              gtk_list_store_set(store, &iter, 0, basename, 1, path, -1);
              count++;
            }

          g_free(path);
          g_free(basename);
        }
      g_object_unref(file);
    }
  
  return store;
}
Beispiel #3
0
static VALUE
rg_has_group_p(VALUE self, VALUE group_name)
{
    return CBOOL2RVAL(gtk_recent_info_has_group(_SELF(self), 
                                                RVAL2CSTR(group_name)));
}
GtkWidget *
totem_open_location_new (void)
{
	TotemOpenLocation *open_location;
	char *clipboard_location;
	GtkEntryCompletion *completion;
	GtkTreeModel *model;
	GList *recent_items, *streams_recent_items = NULL;

	open_location = TOTEM_OPEN_LOCATION (g_object_new (TOTEM_TYPE_OPEN_LOCATION, NULL));

	if (open_location->priv->uri_container == NULL) {
		g_object_unref (open_location);
		return NULL;
	}

	gtk_window_set_title (GTK_WINDOW (open_location), _("Open Location..."));
	gtk_dialog_add_buttons (GTK_DIALOG (open_location),
			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			GTK_STOCK_OPEN, GTK_RESPONSE_OK,
			NULL);
	gtk_dialog_set_response_sensitive (GTK_DIALOG (open_location), GTK_RESPONSE_OK, FALSE);
	gtk_container_set_border_width (GTK_CONTAINER (open_location), 5);
	gtk_dialog_set_default_response (GTK_DIALOG (open_location), GTK_RESPONSE_OK);

	/* Get item from clipboard to fill GtkEntry */
	clipboard_location = totem_open_location_set_from_clipboard (open_location);
	if (clipboard_location != NULL && strcmp (clipboard_location, "") != 0)
		gtk_entry_set_text (open_location->priv->uri_entry, clipboard_location);
	g_free (clipboard_location);

	/* Add items in Totem's GtkRecentManager to the URI GtkEntry's GtkEntryCompletion */
	completion = gtk_entry_completion_new();
	model = GTK_TREE_MODEL (gtk_list_store_new (1, G_TYPE_STRING));
	gtk_entry_set_completion (open_location->priv->uri_entry, completion);

	recent_items = gtk_recent_manager_get_items (gtk_recent_manager_get_default ());

	if (recent_items != NULL)
	{
		GList *p;
		GtkTreeIter iter;

		/* Filter out non-Totem items */
		for (p = recent_items; p != NULL; p = p->next)
		{
			GtkRecentInfo *info = (GtkRecentInfo *) p->data;
			if (!gtk_recent_info_has_group (info, "TotemStreams")) {
				gtk_recent_info_unref (info);
				continue;
			}
			streams_recent_items = g_list_prepend (streams_recent_items, info);
		}

		streams_recent_items = g_list_sort (streams_recent_items, (GCompareFunc) totem_compare_recent_stream_items);

		/* Populate the list store for the combobox */
		for (p = streams_recent_items; p != NULL; p = p->next)
		{
			GtkRecentInfo *info = (GtkRecentInfo *) p->data;
			gtk_list_store_append (GTK_LIST_STORE (model), &iter);
			gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, gtk_recent_info_get_uri (info), -1);
			gtk_recent_info_unref (info);
		}

		g_list_free (streams_recent_items);
	}

	g_list_free (recent_items);

	gtk_entry_completion_set_model (completion, model);
	gtk_entry_completion_set_text_column (completion, 0);
	gtk_entry_completion_set_match_func (completion, (GtkEntryCompletionMatchFunc) totem_open_location_match, model, NULL);

	gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (open_location))),
				open_location->priv->uri_container,
				TRUE,       /* expand */
				TRUE,       /* fill */
				0);         /* padding */

	gtk_widget_show_all (gtk_dialog_get_content_area (GTK_DIALOG (open_location)));

	return GTK_WIDGET (open_location);
}