summaryrefslogtreecommitdiff
path: root/libslab
diff options
context:
space:
mode:
authorWu Xiaotian <[email protected]>2019-05-22 12:03:03 +0800
committerraveit65 <[email protected]>2019-06-06 14:33:45 +0200
commit9dc5fef7fcf9a1040c95055c324f18a551060072 (patch)
tree03288d451a1ee888a6b368e52522c30f960f7a5c /libslab
parent47220bd4a0b39a07292cc76882b8e5bd7958a567 (diff)
downloadmate-control-center-9dc5fef7fcf9a1040c95055c324f18a551060072.tar.bz2
mate-control-center-9dc5fef7fcf9a1040c95055c324f18a551060072.tar.xz
libslab: avoid deprecated g_type_class_add_private
Diffstat (limited to 'libslab')
-rw-r--r--libslab/application-tile.c45
-rw-r--r--libslab/nameplate-tile.c10
-rw-r--r--libslab/search-bar.c32
-rw-r--r--libslab/themed-icon.c10
-rw-r--r--libslab/tile.c23
5 files changed, 55 insertions, 65 deletions
diff --git a/libslab/application-tile.c b/libslab/application-tile.c
index 2e41eaba..53f46c75 100644
--- a/libslab/application-tile.c
+++ b/libslab/application-tile.c
@@ -32,8 +32,6 @@
#include "bookmark-agent.h"
#include "themed-icon.h"
-G_DEFINE_TYPE (ApplicationTile, application_tile, NAMEPLATE_TILE_TYPE)
-
typedef enum {
APP_IN_USER_STARTUP_DIR,
APP_NOT_IN_STARTUP_DIR,
@@ -83,14 +81,14 @@ typedef struct {
gulong notify_signal_id;
} ApplicationTilePrivate;
-#define APPLICATION_TILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), APPLICATION_TILE_TYPE, ApplicationTilePrivate))
-
enum {
PROP_0,
PROP_APPLICATION_NAME,
PROP_APPLICATION_DESCRIPTION
};
+G_DEFINE_TYPE_WITH_PRIVATE (ApplicationTile, application_tile, NAMEPLATE_TILE_TYPE)
+
static void
application_tile_class_init (ApplicationTileClass *app_tile_class)
{
@@ -100,8 +98,6 @@ application_tile_class_init (ApplicationTileClass *app_tile_class)
g_obj_class->set_property = application_tile_set_property;
g_obj_class->finalize = application_tile_finalize;
- g_type_class_add_private (app_tile_class, sizeof (ApplicationTilePrivate));
-
g_object_class_install_property (
g_obj_class, PROP_APPLICATION_NAME,
g_param_spec_string (
@@ -151,7 +147,7 @@ application_tile_new_full (const gchar *desktop_item_id,
}
this = g_object_new (APPLICATION_TILE_TYPE, "tile-uri", uri, NULL);
- priv = APPLICATION_TILE_GET_PRIVATE (this);
+ priv = application_tile_get_instance_private (this);
priv->image_size = image_size;
priv->desktop_item = desktop_item;
@@ -165,7 +161,7 @@ application_tile_new_full (const gchar *desktop_item_id,
static void
application_tile_init (ApplicationTile *tile)
{
- ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (tile);
+ ApplicationTilePrivate *priv = application_tile_get_instance_private (tile);
priv->desktop_item = NULL;
priv->image_id = NULL;
@@ -183,7 +179,7 @@ static void
application_tile_finalize (GObject *g_object)
{
ApplicationTile *tile = APPLICATION_TILE (g_object);
- ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (g_object);
+ ApplicationTilePrivate *priv = application_tile_get_instance_private (tile);
if (tile->name) {
g_free (tile->name);
@@ -256,7 +252,7 @@ application_tile_set_property (GObject *g_obj, guint prop_id, const GValue *valu
static void
application_tile_setup (ApplicationTile *this)
{
- ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
+ ApplicationTilePrivate *priv = application_tile_get_instance_private (this);
GtkWidget *image;
GtkWidget *header;
@@ -444,20 +440,24 @@ create_subheader (const gchar *desc)
static void
start_trigger (Tile *tile, TileEvent *event, TileAction *action)
{
- open_desktop_item_exec (APPLICATION_TILE_GET_PRIVATE (tile)->desktop_item);
+ ApplicationTile *this = APPLICATION_TILE (tile);
+ ApplicationTilePrivate *priv = application_tile_get_instance_private (this);
+ open_desktop_item_exec (priv->desktop_item);
}
static void
help_trigger (Tile *tile, TileEvent *event, TileAction *action)
{
- open_desktop_item_help (APPLICATION_TILE_GET_PRIVATE (tile)->desktop_item);
+ ApplicationTile *this = APPLICATION_TILE (tile);
+ ApplicationTilePrivate *priv = application_tile_get_instance_private (this);
+ open_desktop_item_help (priv->desktop_item);
}
static void
user_apps_trigger (Tile *tile, TileEvent *event, TileAction *action)
{
ApplicationTile *this = APPLICATION_TILE (tile);
- ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
+ ApplicationTilePrivate *priv = application_tile_get_instance_private (this);
if (priv->is_bookmarked)
remove_from_user_list (this);
@@ -470,7 +470,7 @@ user_apps_trigger (Tile *tile, TileEvent *event, TileAction *action)
static void
add_to_user_list (ApplicationTile *this)
{
- ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
+ ApplicationTilePrivate *priv = application_tile_get_instance_private (this);
BookmarkItem *item;
@@ -488,7 +488,7 @@ add_to_user_list (ApplicationTile *this)
static void
remove_from_user_list (ApplicationTile *this)
{
- ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
+ ApplicationTilePrivate *priv = application_tile_get_instance_private (this);
bookmark_agent_remove_item (priv->agent, TILE (this)->uri);
@@ -499,7 +499,7 @@ static void
startup_trigger (Tile *tile, TileEvent *event, TileAction *action)
{
ApplicationTile *this = APPLICATION_TILE (tile);
- ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
+ ApplicationTilePrivate *priv = application_tile_get_instance_private (this);
switch (priv->startup_status) {
case APP_IN_USER_STARTUP_DIR:
@@ -520,7 +520,7 @@ startup_trigger (Tile *tile, TileEvent *event, TileAction *action)
static void
add_to_startup_list (ApplicationTile *this)
{
- ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
+ ApplicationTilePrivate *priv = application_tile_get_instance_private (this);
gchar *desktop_item_filename;
gchar *desktop_item_basename;
@@ -562,7 +562,7 @@ add_to_startup_list (ApplicationTile *this)
static void
remove_from_startup_list (ApplicationTile *this)
{
- ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
+ ApplicationTilePrivate *priv = application_tile_get_instance_private (this);
gchar *ditem_filename;
gchar *ditem_basename;
@@ -594,13 +594,16 @@ remove_from_startup_list (ApplicationTile *this)
MateDesktopItem *
application_tile_get_desktop_item (ApplicationTile *tile)
{
- return APPLICATION_TILE_GET_PRIVATE (tile)->desktop_item;
+ ApplicationTilePrivate *priv;
+
+ priv = application_tile_get_instance_private (tile);
+ return priv->desktop_item;
}
static void
update_user_list_menu_item (ApplicationTile *this)
{
- ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
+ ApplicationTilePrivate *priv = application_tile_get_instance_private (this);
TileAction *action;
GtkWidget *item;
@@ -717,7 +720,7 @@ static void
update_startup_menu_item (ApplicationTile *this)
{
TileAction *action = TILE (this)->actions [APPLICATION_TILE_ACTION_UPDATE_STARTUP];
- ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
+ ApplicationTilePrivate *priv = application_tile_get_instance_private (this);
if (!action)
return;
diff --git a/libslab/nameplate-tile.c b/libslab/nameplate-tile.c
index 8e282ab6..cdf3c50b 100644
--- a/libslab/nameplate-tile.c
+++ b/libslab/nameplate-tile.c
@@ -37,8 +37,6 @@ typedef struct
GtkContainer *subheader_ctnr;
} NameplateTilePrivate;
-#define NAMEPLATE_TILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NAMEPLATE_TILE_TYPE, NameplateTilePrivate))
-
enum
{
PROP_0,
@@ -47,7 +45,7 @@ enum
PROP_NAMEPLATE_SUBHEADER,
};
-G_DEFINE_TYPE (NameplateTile, nameplate_tile, TILE_TYPE)
+G_DEFINE_TYPE_WITH_PRIVATE (NameplateTile, nameplate_tile, TILE_TYPE)
GtkWidget *nameplate_tile_new (const gchar * uri, GtkWidget * image, GtkWidget * header,
GtkWidget * subheader)
@@ -73,8 +71,6 @@ nameplate_tile_class_init (NameplateTileClass * this_class)
widget_class->drag_begin = nameplate_tile_drag_begin;
- g_type_class_add_private (this_class, sizeof (NameplateTilePrivate));
-
g_object_class_install_property (g_obj_class, PROP_NAMEPLATE_IMAGE,
g_param_spec_object ("nameplate-image", "nameplate-image", "nameplate image",
GTK_TYPE_WIDGET, G_PARAM_READWRITE));
@@ -133,7 +129,7 @@ nameplate_tile_set_property (GObject * g_object, guint prop_id, const GValue * v
GParamSpec * param_spec)
{
NameplateTile *this = NAMEPLATE_TILE (g_object);
- NameplateTilePrivate *priv = NAMEPLATE_TILE_GET_PRIVATE (this);
+ NameplateTilePrivate *priv = nameplate_tile_get_instance_private (this);
GObject *widget_obj = NULL;
@@ -208,7 +204,7 @@ nameplate_tile_set_property (GObject * g_object, guint prop_id, const GValue * v
static void
nameplate_tile_setup (NameplateTile *this)
{
- NameplateTilePrivate *priv = NAMEPLATE_TILE_GET_PRIVATE (this);
+ NameplateTilePrivate *priv = nameplate_tile_get_instance_private (this);
GtkWidget *hbox;
GtkWidget *vbox;
diff --git a/libslab/search-bar.c b/libslab/search-bar.c
index 157c4ba4..da54c765 100644
--- a/libslab/search-bar.c
+++ b/libslab/search-bar.c
@@ -37,8 +37,6 @@ typedef struct
gboolean block_signal;
} NldSearchBarPrivate;
-#define NLD_SEARCH_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NLD_TYPE_SEARCH_BAR, NldSearchBarPrivate))
-
static void nld_search_bar_class_init (NldSearchBarClass *);
static void nld_search_bar_init (NldSearchBar *);
static void nld_search_bar_finalize (GObject *);
@@ -54,7 +52,7 @@ enum
static guint signals[LAST_SIGNAL] = { 0 };
-G_DEFINE_TYPE (NldSearchBar, nld_search_bar, GTK_TYPE_BOX)
+G_DEFINE_TYPE_WITH_PRIVATE (NldSearchBar, nld_search_bar, GTK_TYPE_BOX)
static void emit_search (NldSearchBar * search_bar);
static void emit_search_callback (GtkWidget * widget, gpointer search_bar);
@@ -68,8 +66,6 @@ static void nld_search_bar_class_init (NldSearchBarClass * nld_search_bar_class)
widget_class->focus = nld_search_bar_focus;
widget_class->grab_focus = nld_search_bar_grab_focus;
- g_type_class_add_private (nld_search_bar_class, sizeof (NldSearchBarPrivate));
-
signals[SEARCH] =
g_signal_new ("search", G_TYPE_FROM_CLASS (nld_search_bar_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (NldSearchBarClass, search),
@@ -79,7 +75,7 @@ static void nld_search_bar_class_init (NldSearchBarClass * nld_search_bar_class)
static void
nld_search_bar_init (NldSearchBar * search_bar)
{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
+ NldSearchBarPrivate *priv = nld_search_bar_get_instance_private (search_bar);
GtkWidget *entry;
gtk_widget_set_can_focus (GTK_WIDGET (search_bar), TRUE);
@@ -103,7 +99,7 @@ nld_search_bar_init (NldSearchBar * search_bar)
static void
nld_search_bar_finalize (GObject * object)
{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (object);
+ NldSearchBarPrivate *priv = nld_search_bar_get_instance_private (NLD_SEARCH_BAR(object));
if (priv->timeout_id)
g_source_remove (priv->timeout_id);
@@ -114,7 +110,7 @@ nld_search_bar_finalize (GObject * object)
static gboolean
nld_search_bar_focus (GtkWidget * widget, GtkDirectionType dir)
{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (widget);
+ NldSearchBarPrivate *priv = nld_search_bar_get_instance_private (NLD_SEARCH_BAR(widget));
return gtk_widget_child_focus (priv->hbox, dir);
}
@@ -122,7 +118,7 @@ nld_search_bar_focus (GtkWidget * widget, GtkDirectionType dir)
gboolean
nld_search_bar_has_focus (NldSearchBar * search_bar)
{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
+ NldSearchBarPrivate *priv = nld_search_bar_get_instance_private (search_bar);
return gtk_widget_has_focus (GTK_WIDGET (priv->entry));
}
@@ -130,7 +126,7 @@ nld_search_bar_has_focus (NldSearchBar * search_bar)
static void
nld_search_bar_grab_focus (GtkWidget * widget)
{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (widget);
+ NldSearchBarPrivate *priv = nld_search_bar_get_instance_private (NLD_SEARCH_BAR(widget));
gtk_widget_grab_focus (GTK_WIDGET (priv->entry));
}
@@ -144,7 +140,7 @@ nld_search_bar_new (void)
void
nld_search_bar_clear (NldSearchBar * search_bar)
{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
+ NldSearchBarPrivate *priv = nld_search_bar_get_instance_private (search_bar);
priv->block_signal = TRUE;
gtk_entry_set_text (priv->entry, "");
@@ -154,7 +150,7 @@ nld_search_bar_clear (NldSearchBar * search_bar)
static void
emit_search (NldSearchBar * search_bar)
{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
+ NldSearchBarPrivate *priv = nld_search_bar_get_instance_private (search_bar);
if (priv->block_signal)
return;
@@ -178,7 +174,7 @@ emit_search_callback (GtkWidget * widget, gpointer search_bar)
static gboolean
search_timeout (gpointer search_bar)
{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
+ NldSearchBarPrivate *priv = nld_search_bar_get_instance_private (search_bar);
priv->timeout_id = 0;
emit_search (search_bar);
@@ -188,7 +184,7 @@ search_timeout (gpointer search_bar)
static void
entry_changed (GtkWidget * entry, gpointer search_bar)
{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
+ NldSearchBarPrivate *priv = nld_search_bar_get_instance_private (search_bar);
if (priv->search_timeout == 0)
emit_search (search_bar);
@@ -204,7 +200,7 @@ entry_changed (GtkWidget * entry, gpointer search_bar)
int
nld_search_bar_get_search_timeout (NldSearchBar * search_bar)
{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
+ NldSearchBarPrivate *priv = nld_search_bar_get_instance_private (search_bar);
return priv->search_timeout;
}
@@ -212,7 +208,7 @@ nld_search_bar_get_search_timeout (NldSearchBar * search_bar)
void
nld_search_bar_set_search_timeout (NldSearchBar * search_bar, int search_timeout)
{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
+ NldSearchBarPrivate *priv = nld_search_bar_get_instance_private (search_bar);
if (priv->search_timeout != -1 && search_timeout == -1)
g_signal_handlers_disconnect_by_func (priv->entry, entry_changed, search_bar);
@@ -227,7 +223,7 @@ nld_search_bar_set_search_timeout (NldSearchBar * search_bar, int search_timeout
const char *
nld_search_bar_get_text (NldSearchBar * search_bar)
{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
+ NldSearchBarPrivate *priv = nld_search_bar_get_instance_private (search_bar);
return gtk_entry_get_text (priv->entry);
}
@@ -235,7 +231,7 @@ nld_search_bar_get_text (NldSearchBar * search_bar)
void
nld_search_bar_set_text (NldSearchBar * search_bar, const char *text, gboolean activate)
{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
+ NldSearchBarPrivate *priv = nld_search_bar_get_instance_private (search_bar);
gtk_entry_set_text (priv->entry, text);
if (activate)
diff --git a/libslab/themed-icon.c b/libslab/themed-icon.c
index 29c4a0cc..124a224a 100644
--- a/libslab/themed-icon.c
+++ b/libslab/themed-icon.c
@@ -43,9 +43,7 @@ typedef struct
gboolean icon_loaded;
} ThemedIconPrivate;
-#define THEMED_ICON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), THEMED_ICON_TYPE, ThemedIconPrivate))
-
-G_DEFINE_TYPE (ThemedIcon, themed_icon, GTK_TYPE_IMAGE)
+G_DEFINE_TYPE_WITH_PRIVATE (ThemedIcon, themed_icon, GTK_TYPE_IMAGE)
static void themed_icon_class_init (ThemedIconClass * themed_icon_class)
{
@@ -59,8 +57,6 @@ static void themed_icon_class_init (ThemedIconClass * themed_icon_class)
widget_class->show = themed_icon_show;
widget_class->style_updated = themed_icon_style_updated;
- g_type_class_add_private (themed_icon_class, sizeof (ThemedIconPrivate));
-
g_object_class_install_property (g_obj_class, PROP_ICON_ID, g_param_spec_string ("icon-id",
"icon-id", "the identifier of the icon", NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
@@ -74,7 +70,7 @@ static void themed_icon_class_init (ThemedIconClass * themed_icon_class)
static void
themed_icon_init (ThemedIcon * icon)
{
- ThemedIconPrivate *priv = THEMED_ICON_GET_PRIVATE (icon);
+ ThemedIconPrivate *priv = themed_icon_get_instance_private (icon);
priv->icon_loaded = FALSE;
}
@@ -148,7 +144,7 @@ static void
themed_icon_show (GtkWidget * widget)
{
ThemedIcon *icon = THEMED_ICON (widget);
- ThemedIconPrivate *priv = THEMED_ICON_GET_PRIVATE (icon);
+ ThemedIconPrivate *priv = themed_icon_get_instance_private (icon);
if (!priv->icon_loaded)
priv->icon_loaded = load_image_by_id (GTK_IMAGE (icon), icon->size, icon->id);
diff --git a/libslab/tile.c b/libslab/tile.c
index 712a61dc..c2f632ca 100644
--- a/libslab/tile.c
+++ b/libslab/tile.c
@@ -25,15 +25,15 @@
#include "double-click-detector.h"
-G_DEFINE_TYPE (Tile, tile, GTK_TYPE_BUTTON)
-
typedef struct
{
DoubleClickDetector *double_click_detector;
-
+
gboolean is_dragging;
} TilePrivate;
+G_DEFINE_TYPE_WITH_PRIVATE (Tile, tile, GTK_TYPE_BUTTON)
+
static void tile_finalize (GObject *);
static void tile_dispose (GObject *);
static void tile_get_property (GObject *, guint, GValue *, GParamSpec *);
@@ -63,8 +63,6 @@ gpointer, gpointer);
typedef void (*marshal_func_VOID__POINTER_POINTER) (gpointer, gpointer, gpointer, gpointer);
-#define TILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TILE_TYPE, TilePrivate))
-
enum
{
TILE_ACTIVATED_SIGNAL,
@@ -111,8 +109,6 @@ tile_class_init (TileClass * this_class)
this_class->tile_activated = NULL;
this_class->tile_action_triggered = tile_tile_action_triggered;
- g_type_class_add_private (this_class, sizeof (TilePrivate));
-
g_object_class_install_property (g_obj_class, PROP_TILE_URI,
g_param_spec_string ("tile-uri", "tile-uri", "the uri of the tile", NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
@@ -142,7 +138,7 @@ tile_constructor (GType type, guint n_param, GObjectConstructParam * param)
g_obj = (*G_OBJECT_CLASS (tile_parent_class)->constructor) (type, n_param, param);
- priv = TILE_GET_PRIVATE (g_obj);
+ priv = tile_get_instance_private (TILE(g_obj));
priv->double_click_detector = double_click_detector_new ();
tile_setup (TILE (g_obj));
@@ -153,7 +149,7 @@ tile_constructor (GType type, guint n_param, GObjectConstructParam * param)
static void
tile_init (Tile * tile)
{
- TilePrivate *priv = TILE_GET_PRIVATE (tile);
+ TilePrivate *priv = tile_get_instance_private (tile);
tile->uri = NULL;
tile->context_menu = NULL;
@@ -173,7 +169,7 @@ static void
tile_finalize (GObject * g_object)
{
Tile *tile = TILE (g_object);
- TilePrivate *priv = TILE_GET_PRIVATE (g_object);
+ TilePrivate *priv = tile_get_instance_private (TILE(tile));
if (tile->n_actions) /* this will also free "default_action" entry */
{
@@ -364,7 +360,7 @@ static gboolean
tile_button_release (GtkWidget * widget, GdkEventButton * event)
{
Tile *tile = TILE (widget);
- TilePrivate *priv = TILE_GET_PRIVATE (tile);
+ TilePrivate *priv = tile_get_instance_private (tile);
TileEvent *tile_event;
@@ -453,7 +449,10 @@ tile_popup_menu (GtkWidget * widget)
static void
tile_drag_begin (GtkWidget * widget, GdkDragContext * context)
{
- TILE_GET_PRIVATE (widget)->is_dragging = TRUE;
+ TilePrivate *priv;
+
+ priv = tile_get_instance_private (TILE(widget));
+ priv->is_dragging = TRUE;
}
static void