infobar: Remove priv pointer

This commit is contained in:
Timm Bäder 2018-06-20 20:05:06 +02:00
parent 99099a1053
commit cf9121977f
2 changed files with 37 additions and 29 deletions

View File

@ -135,7 +135,7 @@ enum
LAST_PROP LAST_PROP
}; };
struct _GtkInfoBarPrivate typedef struct
{ {
GtkWidget *content_area; GtkWidget *content_area;
GtkWidget *action_area; GtkWidget *action_area;
@ -144,7 +144,7 @@ struct _GtkInfoBarPrivate
gboolean show_close_button; gboolean show_close_button;
GtkMessageType message_type; GtkMessageType message_type;
}; } GtkInfoBarPrivate;
typedef struct _ResponseData ResponseData; typedef struct _ResponseData ResponseData;
@ -270,10 +270,11 @@ static GtkWidget *
find_button (GtkInfoBar *info_bar, find_button (GtkInfoBar *info_bar,
gint response_id) gint response_id)
{ {
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
GList *children, *list; GList *children, *list;
GtkWidget *child = NULL; GtkWidget *child = NULL;
children = gtk_container_get_children (GTK_CONTAINER (info_bar->priv->action_area)); children = gtk_container_get_children (GTK_CONTAINER (priv->action_area));
for (list = children; list; list = list->next) for (list = children; list; list = list->next)
{ {
@ -294,7 +295,9 @@ find_button (GtkInfoBar *info_bar,
static void static void
gtk_info_bar_close (GtkInfoBar *info_bar) gtk_info_bar_close (GtkInfoBar *info_bar)
{ {
if (!gtk_widget_get_visible (info_bar->priv->close_button) GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
if (!gtk_widget_get_visible (priv->close_button)
&& !find_button (info_bar, GTK_RESPONSE_CANCEL)) && !find_button (info_bar, GTK_RESPONSE_CANCEL))
return; return;
@ -415,11 +418,9 @@ close_button_clicked_cb (GtkWidget *button,
static void static void
gtk_info_bar_init (GtkInfoBar *info_bar) gtk_info_bar_init (GtkInfoBar *info_bar)
{ {
GtkInfoBarPrivate *priv; GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
GtkWidget *widget = GTK_WIDGET (info_bar); GtkWidget *widget = GTK_WIDGET (info_bar);
priv = info_bar->priv = gtk_info_bar_get_instance_private (info_bar);
/* message-type is a CONSTRUCT property, so we init to a value /* message-type is a CONSTRUCT property, so we init to a value
* different from its default to trigger its property setter * different from its default to trigger its property setter
* during construction */ * during construction */
@ -480,6 +481,7 @@ gtk_info_bar_add_action_widget (GtkInfoBar *info_bar,
GtkWidget *child, GtkWidget *child,
gint response_id) gint response_id)
{ {
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
ResponseData *ad; ResponseData *ad;
guint signal_id; guint signal_id;
@ -506,9 +508,9 @@ gtk_info_bar_add_action_widget (GtkInfoBar *info_bar,
else else
g_warning ("Only 'activatable' widgets can be packed into the action area of a GtkInfoBar"); g_warning ("Only 'activatable' widgets can be packed into the action area of a GtkInfoBar");
gtk_box_pack_end (GTK_BOX (info_bar->priv->action_area), child); gtk_box_pack_end (GTK_BOX (priv->action_area), child);
if (response_id == GTK_RESPONSE_HELP) if (response_id == GTK_RESPONSE_HELP)
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (info_bar->priv->action_area), gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (priv->action_area),
child, TRUE); child, TRUE);
} }
@ -523,9 +525,11 @@ gtk_info_bar_add_action_widget (GtkInfoBar *info_bar,
GtkWidget* GtkWidget*
gtk_info_bar_get_action_area (GtkInfoBar *info_bar) gtk_info_bar_get_action_area (GtkInfoBar *info_bar)
{ {
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
g_return_val_if_fail (GTK_IS_INFO_BAR (info_bar), NULL); g_return_val_if_fail (GTK_IS_INFO_BAR (info_bar), NULL);
return info_bar->priv->action_area; return priv->action_area;
} }
/** /**
@ -539,9 +543,11 @@ gtk_info_bar_get_action_area (GtkInfoBar *info_bar)
GtkWidget* GtkWidget*
gtk_info_bar_get_content_area (GtkInfoBar *info_bar) gtk_info_bar_get_content_area (GtkInfoBar *info_bar)
{ {
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
g_return_val_if_fail (GTK_IS_INFO_BAR (info_bar), NULL); g_return_val_if_fail (GTK_IS_INFO_BAR (info_bar), NULL);
return info_bar->priv->content_area; return priv->content_area;
} }
/** /**
@ -692,11 +698,12 @@ gtk_info_bar_set_response_sensitive (GtkInfoBar *info_bar,
gint response_id, gint response_id,
gboolean setting) gboolean setting)
{ {
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
GList *children, *list; GList *children, *list;
g_return_if_fail (GTK_IS_INFO_BAR (info_bar)); g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
children = gtk_container_get_children (GTK_CONTAINER (info_bar->priv->action_area)); children = gtk_container_get_children (GTK_CONTAINER (priv->action_area));
for (list = children; list; list = list->next) for (list = children; list; list = list->next)
{ {
@ -726,11 +733,12 @@ void
gtk_info_bar_set_default_response (GtkInfoBar *info_bar, gtk_info_bar_set_default_response (GtkInfoBar *info_bar,
gint response_id) gint response_id)
{ {
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
GList *children, *list; GList *children, *list;
g_return_if_fail (GTK_IS_INFO_BAR (info_bar)); g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
children = gtk_container_get_children (GTK_CONTAINER (info_bar->priv->action_area)); children = gtk_container_get_children (GTK_CONTAINER (priv->action_area));
for (list = children; list; list = list->next) for (list = children; list; list = list->next)
{ {
@ -924,10 +932,11 @@ gtk_info_bar_buildable_custom_finished (GtkBuildable *buildable,
const gchar *tagname, const gchar *tagname,
gpointer user_data) gpointer user_data)
{ {
GtkInfoBar *info_bar = GTK_INFO_BAR (buildable);
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
GSList *l; GSList *l;
SubParserData *data; SubParserData *data;
GObject *object; GObject *object;
GtkInfoBar *info_bar;
ResponseData *ad; ResponseData *ad;
guint signal_id; guint signal_id;
@ -938,7 +947,6 @@ gtk_info_bar_buildable_custom_finished (GtkBuildable *buildable,
return; return;
} }
info_bar = GTK_INFO_BAR (buildable);
data = (SubParserData*)user_data; data = (SubParserData*)user_data;
data->items = g_slist_reverse (data->items); data->items = g_slist_reverse (data->items);
@ -968,7 +976,7 @@ gtk_info_bar_buildable_custom_finished (GtkBuildable *buildable,
} }
if (ad->response_id == GTK_RESPONSE_HELP) if (ad->response_id == GTK_RESPONSE_HELP)
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (info_bar->priv->action_area), gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (priv->action_area),
GTK_WIDGET (object), TRUE); GTK_WIDGET (object), TRUE);
} }
@ -990,12 +998,10 @@ void
gtk_info_bar_set_message_type (GtkInfoBar *info_bar, gtk_info_bar_set_message_type (GtkInfoBar *info_bar,
GtkMessageType message_type) GtkMessageType message_type)
{ {
GtkInfoBarPrivate *priv; GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
g_return_if_fail (GTK_IS_INFO_BAR (info_bar)); g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
priv = info_bar->priv;
if (priv->message_type != message_type) if (priv->message_type != message_type)
{ {
GtkStyleContext *context; GtkStyleContext *context;
@ -1072,9 +1078,11 @@ gtk_info_bar_set_message_type (GtkInfoBar *info_bar,
GtkMessageType GtkMessageType
gtk_info_bar_get_message_type (GtkInfoBar *info_bar) gtk_info_bar_get_message_type (GtkInfoBar *info_bar)
{ {
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
g_return_val_if_fail (GTK_IS_INFO_BAR (info_bar), GTK_MESSAGE_OTHER); g_return_val_if_fail (GTK_IS_INFO_BAR (info_bar), GTK_MESSAGE_OTHER);
return info_bar->priv->message_type; return priv->message_type;
} }
@ -1090,12 +1098,14 @@ void
gtk_info_bar_set_show_close_button (GtkInfoBar *info_bar, gtk_info_bar_set_show_close_button (GtkInfoBar *info_bar,
gboolean setting) gboolean setting)
{ {
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
g_return_if_fail (GTK_IS_INFO_BAR (info_bar)); g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
if (setting != info_bar->priv->show_close_button) if (setting != priv->show_close_button)
{ {
info_bar->priv->show_close_button = setting; priv->show_close_button = setting;
gtk_widget_set_visible (info_bar->priv->close_button, setting); gtk_widget_set_visible (priv->close_button, setting);
g_object_notify_by_pspec (G_OBJECT (info_bar), props[PROP_SHOW_CLOSE_BUTTON]); g_object_notify_by_pspec (G_OBJECT (info_bar), props[PROP_SHOW_CLOSE_BUTTON]);
} }
} }
@ -1111,9 +1121,11 @@ gtk_info_bar_set_show_close_button (GtkInfoBar *info_bar,
gboolean gboolean
gtk_info_bar_get_show_close_button (GtkInfoBar *info_bar) gtk_info_bar_get_show_close_button (GtkInfoBar *info_bar)
{ {
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
g_return_val_if_fail (GTK_IS_INFO_BAR (info_bar), FALSE); g_return_val_if_fail (GTK_IS_INFO_BAR (info_bar), FALSE);
return info_bar->priv->show_close_button; return priv->show_close_button;
} }
/** /**

View File

@ -49,17 +49,13 @@ G_BEGIN_DECLS
#define GTK_INFO_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INFO_BAR, GtkInfoBarClass)) #define GTK_INFO_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INFO_BAR, GtkInfoBarClass))
typedef struct _GtkInfoBarPrivate GtkInfoBarPrivate;
typedef struct _GtkInfoBarClass GtkInfoBarClass; typedef struct _GtkInfoBarClass GtkInfoBarClass;
typedef struct _GtkInfoBar GtkInfoBar; typedef struct _GtkInfoBar GtkInfoBar;
struct _GtkInfoBar struct _GtkInfoBar
{ {
GtkBox parent; GtkBox parent_instance;
/*< private > */
GtkInfoBarPrivate *priv;
}; };