Turn GtkRecentInfo into an object
This is in preparation to eventually using a list model of recent infos.
This commit is contained in:
@@ -2599,8 +2599,6 @@ gtk_recent_manager_move_item
|
||||
gtk_recent_manager_get_items
|
||||
gtk_recent_manager_purge_items
|
||||
<SUBSECTION>
|
||||
gtk_recent_info_ref
|
||||
gtk_recent_info_unref
|
||||
gtk_recent_info_get_uri
|
||||
gtk_recent_info_get_display_name
|
||||
gtk_recent_info_get_description
|
||||
|
||||
@@ -169,7 +169,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkViewport, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkVolumeButton, g_object_unref)
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkPaperSize, gtk_paper_size_free)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRecentInfo, gtk_recent_info_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSelectionData, gtk_selection_data_free)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkTextIter, gtk_text_iter_free)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkTreeIter, gtk_tree_iter_free)
|
||||
|
||||
@@ -7541,7 +7541,7 @@ recent_start_loading (GtkFileChooserWidget *impl)
|
||||
g_list_free_full (folders, g_object_unref);
|
||||
}
|
||||
|
||||
g_list_free_full (items, (GDestroyNotify) gtk_recent_info_unref);
|
||||
g_list_free_full (items, (GDestroyNotify) g_object_unref);
|
||||
|
||||
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->browse_files_tree_view),
|
||||
GTK_TREE_MODEL (priv->recent_model));
|
||||
|
||||
@@ -139,6 +139,8 @@ typedef struct
|
||||
*/
|
||||
struct _GtkRecentInfo
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
gchar *uri;
|
||||
|
||||
gchar *display_name;
|
||||
@@ -158,8 +160,11 @@ struct _GtkRecentInfo
|
||||
int n_groups;
|
||||
|
||||
gboolean is_private;
|
||||
};
|
||||
|
||||
gint ref_count;
|
||||
struct _GtkRecentInfoClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
struct _GtkRecentManagerPrivate
|
||||
@@ -222,7 +227,6 @@ static void purge_recent_items_list (GtkRecentManager *manag
|
||||
GError **error);
|
||||
|
||||
static GtkRecentInfo *gtk_recent_info_new (const gchar *uri);
|
||||
static void gtk_recent_info_free (GtkRecentInfo *recent_info);
|
||||
|
||||
static guint signal_changed = 0;
|
||||
|
||||
@@ -1473,9 +1477,12 @@ gtk_recent_manager_clamp_to_size (GtkRecentManager *manager,
|
||||
* GtkRecentInfo *
|
||||
*****************/
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GtkRecentInfo, gtk_recent_info,
|
||||
gtk_recent_info_ref,
|
||||
gtk_recent_info_unref)
|
||||
G_DEFINE_TYPE (GtkRecentInfo, gtk_recent_info, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gtk_recent_info_init (GtkRecentInfo *info)
|
||||
{
|
||||
}
|
||||
|
||||
static GtkRecentInfo *
|
||||
gtk_recent_info_new (const gchar *uri)
|
||||
@@ -1484,7 +1491,8 @@ gtk_recent_info_new (const gchar *uri)
|
||||
|
||||
g_assert (uri != NULL);
|
||||
|
||||
info = g_new0 (GtkRecentInfo, 1);
|
||||
info = g_object_new (GTK_TYPE_RECENT_INFO, NULL);
|
||||
|
||||
info->uri = g_strdup (uri);
|
||||
|
||||
info->applications = NULL;
|
||||
@@ -1492,19 +1500,15 @@ gtk_recent_info_new (const gchar *uri)
|
||||
|
||||
info->groups = NULL;
|
||||
|
||||
info->ref_count = 1;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_recent_info_free (GtkRecentInfo *recent_info)
|
||||
gtk_recent_info_finalize (GObject *object)
|
||||
{
|
||||
GtkRecentInfo *recent_info = GTK_RECENT_INFO (object);
|
||||
int i;
|
||||
|
||||
if (!recent_info)
|
||||
return;
|
||||
|
||||
g_free (recent_info->uri);
|
||||
g_free (recent_info->display_name);
|
||||
g_free (recent_info->description);
|
||||
@@ -1527,46 +1531,15 @@ gtk_recent_info_free (GtkRecentInfo *recent_info)
|
||||
|
||||
g_free (recent_info->groups);
|
||||
|
||||
g_free (recent_info);
|
||||
G_OBJECT_CLASS (gtk_recent_info_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_recent_info_ref:
|
||||
* @info: a #GtkRecentInfo
|
||||
*
|
||||
* Increases the reference count of @recent_info by one.
|
||||
*
|
||||
* Returns: the recent info object with its reference count
|
||||
* increased by one
|
||||
*/
|
||||
GtkRecentInfo *
|
||||
gtk_recent_info_ref (GtkRecentInfo *info)
|
||||
static void
|
||||
gtk_recent_info_class_init (GtkRecentInfoClass *class)
|
||||
{
|
||||
g_return_val_if_fail (info != NULL, NULL);
|
||||
g_return_val_if_fail (info->ref_count > 0, NULL);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
info->ref_count += 1;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_recent_info_unref:
|
||||
* @info: a #GtkRecentInfo
|
||||
*
|
||||
* Decreases the reference count of @info by one. If the reference
|
||||
* count reaches zero, @info is deallocated, and the memory freed.
|
||||
*/
|
||||
void
|
||||
gtk_recent_info_unref (GtkRecentInfo *info)
|
||||
{
|
||||
g_return_if_fail (info != NULL);
|
||||
g_return_if_fail (info->ref_count > 0);
|
||||
|
||||
info->ref_count -= 1;
|
||||
|
||||
if (info->ref_count == 0)
|
||||
gtk_recent_info_free (info);
|
||||
object_class->finalize = gtk_recent_info_finalize;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,6 +32,9 @@ G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_RECENT_INFO (gtk_recent_info_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (GtkRecentInfo, gtk_recent_info, GTK, RECENT_INFO, GObject)
|
||||
|
||||
#define GTK_TYPE_RECENT_MANAGER (gtk_recent_manager_get_type ())
|
||||
#define GTK_RECENT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RECENT_MANAGER, GtkRecentManager))
|
||||
#define GTK_IS_RECENT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RECENT_MANAGER))
|
||||
@@ -39,7 +42,6 @@ G_BEGIN_DECLS
|
||||
#define GTK_IS_RECENT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RECENT_MANAGER))
|
||||
#define GTK_RECENT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RECENT_MANAGER, GtkRecentManagerClass))
|
||||
|
||||
typedef struct _GtkRecentInfo GtkRecentInfo;
|
||||
typedef struct _GtkRecentData GtkRecentData;
|
||||
typedef struct _GtkRecentManager GtkRecentManager;
|
||||
typedef struct _GtkRecentManagerClass GtkRecentManagerClass;
|
||||
@@ -189,15 +191,6 @@ GDK_AVAILABLE_IN_ALL
|
||||
gint gtk_recent_manager_purge_items (GtkRecentManager *manager,
|
||||
GError **error);
|
||||
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_recent_info_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkRecentInfo * gtk_recent_info_ref (GtkRecentInfo *info);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_recent_info_unref (GtkRecentInfo *info);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const gchar * gtk_recent_info_get_uri (GtkRecentInfo *info);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
||||
@@ -247,7 +247,7 @@ recent_manager_lookup_item (void)
|
||||
|
||||
g_assert (gtk_recent_info_has_application (info, "testrecentchooser"));
|
||||
|
||||
gtk_recent_info_unref (info);
|
||||
g_object_unref (info);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user