2009-06-05 18:56:08 +00:00
|
|
|
|
/*
|
|
|
|
|
* gtkinfobar.c
|
2020-09-12 16:01:04 +00:00
|
|
|
|
* This file is part of GTK
|
2009-06-05 18:56:08 +00:00
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2005 - Paolo Maggi
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2009-06-05 18:56:08 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Modified by the gedit Team, 2005. See the AUTHORS file for a
|
|
|
|
|
* list of people on the gtk Team.
|
|
|
|
|
* See the gedit ChangeLog files for a list of changes.
|
|
|
|
|
*
|
|
|
|
|
* Modified by the GTK+ team, 2008-2009.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
#include "gtkinfobar.h"
|
|
|
|
|
#include "gtkbuildable.h"
|
2015-04-25 23:35:22 +00:00
|
|
|
|
#include "gtkbuilderprivate.h"
|
2009-06-05 18:56:08 +00:00
|
|
|
|
#include "gtkbox.h"
|
|
|
|
|
#include "gtklabel.h"
|
|
|
|
|
#include "gtkbutton.h"
|
|
|
|
|
#include "gtkenums.h"
|
|
|
|
|
#include "gtkdialog.h"
|
2013-07-31 16:40:52 +00:00
|
|
|
|
#include "gtkrevealer.h"
|
2009-06-05 18:56:08 +00:00
|
|
|
|
#include "gtkintl.h"
|
|
|
|
|
#include "gtkprivate.h"
|
2011-01-04 19:51:19 +00:00
|
|
|
|
#include "gtktypebuiltins.h"
|
2016-01-02 23:28:12 +00:00
|
|
|
|
#include "gtkwidgetprivate.h"
|
2019-08-28 06:13:18 +00:00
|
|
|
|
#include "gtkbinlayout.h"
|
2020-01-09 21:11:36 +00:00
|
|
|
|
#include "gtkgestureclick.h"
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SECTION:gtkinfobar
|
|
|
|
|
* @short_description: Report important messages to the user
|
|
|
|
|
* @include: gtk/gtk.h
|
|
|
|
|
* @see_also: #GtkStatusbar, #GtkMessageDialog
|
|
|
|
|
*
|
|
|
|
|
* #GtkInfoBar is a widget that can be used to show messages to
|
|
|
|
|
* the user without showing a dialog. It is often temporarily shown
|
|
|
|
|
* at the top or bottom of a document. In contrast to #GtkDialog, which
|
2019-08-25 12:52:24 +00:00
|
|
|
|
* has an action area at the bottom, #GtkInfoBar has an action area
|
2013-07-15 13:33:44 +00:00
|
|
|
|
* at the side.
|
2009-06-05 18:56:08 +00:00
|
|
|
|
*
|
|
|
|
|
* The API of #GtkInfoBar is very similar to #GtkDialog, allowing you
|
|
|
|
|
* to add buttons to the action area with gtk_info_bar_add_button() or
|
|
|
|
|
* gtk_info_bar_new_with_buttons(). The sensitivity of action widgets
|
|
|
|
|
* can be controlled with gtk_info_bar_set_response_sensitive().
|
2020-05-07 16:49:15 +00:00
|
|
|
|
*
|
2009-06-05 18:56:08 +00:00
|
|
|
|
* To add widgets to the main content area of a #GtkInfoBar, use
|
2020-05-07 16:49:15 +00:00
|
|
|
|
* gtk_info_bar_add_child().
|
2009-06-05 18:56:08 +00:00
|
|
|
|
*
|
|
|
|
|
* Similar to #GtkMessageDialog, the contents of a #GtkInfoBar can by
|
|
|
|
|
* classified as error message, warning, informational message, etc,
|
2020-09-12 16:01:04 +00:00
|
|
|
|
* by using gtk_info_bar_set_message_type(). GTK may use the message type
|
2013-07-15 16:37:58 +00:00
|
|
|
|
* to determine how the message is displayed.
|
2009-06-05 18:56:08 +00:00
|
|
|
|
*
|
2018-01-03 16:10:21 +00:00
|
|
|
|
* A simple example for using a #GtkInfoBar:
|
2014-01-27 19:55:18 +00:00
|
|
|
|
* |[<!-- language="C" -->
|
2020-05-07 16:49:15 +00:00
|
|
|
|
* GtkWidget *message_label;
|
|
|
|
|
* GtkWidget *widget;
|
2018-01-03 16:10:21 +00:00
|
|
|
|
* GtkWidget *grid;
|
2014-02-12 21:09:09 +00:00
|
|
|
|
* GtkInfoBar *bar;
|
|
|
|
|
*
|
2018-01-03 16:10:21 +00:00
|
|
|
|
* // set up info bar
|
2014-02-12 21:09:09 +00:00
|
|
|
|
* widget = gtk_info_bar_new ();
|
2017-08-12 20:07:22 +00:00
|
|
|
|
* bar = GTK_INFO_BAR (widget);
|
2018-01-03 16:10:21 +00:00
|
|
|
|
* grid = gtk_grid_new ();
|
2014-02-12 21:09:09 +00:00
|
|
|
|
*
|
2009-06-05 18:56:08 +00:00
|
|
|
|
* message_label = gtk_label_new ("");
|
2020-05-07 16:49:15 +00:00
|
|
|
|
* gtk_info_bar_add_child (bar, message_label);
|
2014-02-12 21:09:09 +00:00
|
|
|
|
* gtk_info_bar_add_button (bar,
|
|
|
|
|
* _("_OK"),
|
|
|
|
|
* GTK_RESPONSE_OK);
|
|
|
|
|
* g_signal_connect (bar,
|
|
|
|
|
* "response",
|
|
|
|
|
* G_CALLBACK (gtk_widget_hide),
|
|
|
|
|
* NULL);
|
2011-09-28 23:06:21 +00:00
|
|
|
|
* gtk_grid_attach (GTK_GRID (grid),
|
2014-02-12 21:09:09 +00:00
|
|
|
|
* widget,
|
2011-09-28 23:06:21 +00:00
|
|
|
|
* 0, 2, 1, 1);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
*
|
2018-01-03 16:10:21 +00:00
|
|
|
|
* // ...
|
2009-06-05 18:56:08 +00:00
|
|
|
|
*
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* // show an error message
|
2018-01-03 16:10:21 +00:00
|
|
|
|
* gtk_label_set_text (GTK_LABEL (message_label), "An error occurred!");
|
2020-05-07 16:49:15 +00:00
|
|
|
|
* gtk_info_bar_set_message_type (bar, GTK_MESSAGE_ERROR);
|
2014-02-12 21:09:09 +00:00
|
|
|
|
* gtk_widget_show (bar);
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* ]|
|
2009-06-05 18:56:08 +00:00
|
|
|
|
*
|
2014-02-05 02:00:58 +00:00
|
|
|
|
* # GtkInfoBar as GtkBuildable
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2009-06-05 18:56:08 +00:00
|
|
|
|
* The GtkInfoBar implementation of the GtkBuildable interface exposes
|
|
|
|
|
* the content area and action area as internal children with the names
|
2014-02-05 18:07:34 +00:00
|
|
|
|
* “content_area” and “action_area”.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* GtkInfoBar supports a custom <action-widgets> element, which can contain
|
|
|
|
|
* multiple <action-widget> elements. The “response” attribute specifies a
|
|
|
|
|
* numeric response, and the content of the element is the id of widget
|
|
|
|
|
* (which should be a child of the dialogs @action_area).
|
2015-10-25 21:18:20 +00:00
|
|
|
|
*
|
|
|
|
|
* # CSS nodes
|
|
|
|
|
*
|
|
|
|
|
* GtkInfoBar has a single CSS node with name infobar. The node may get
|
2016-05-02 06:59:40 +00:00
|
|
|
|
* one of the style classes .info, .warning, .error or .question, depending
|
2015-10-25 21:18:20 +00:00
|
|
|
|
* on the message type.
|
2019-08-28 06:13:18 +00:00
|
|
|
|
* If the info bar shows a close button, that button will have the .close
|
|
|
|
|
* style class applied.
|
2009-06-05 18:56:08 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
PROP_0,
|
2013-07-15 19:04:56 +00:00
|
|
|
|
PROP_MESSAGE_TYPE,
|
2017-01-12 07:42:09 +00:00
|
|
|
|
PROP_SHOW_CLOSE_BUTTON,
|
2017-01-12 08:09:22 +00:00
|
|
|
|
PROP_REVEALED,
|
2017-01-12 07:42:09 +00:00
|
|
|
|
LAST_PROP
|
2009-06-05 18:56:08 +00:00
|
|
|
|
};
|
|
|
|
|
|
2019-05-27 02:30:33 +00:00
|
|
|
|
typedef struct _GtkInfoBarClass GtkInfoBarClass;
|
|
|
|
|
|
|
|
|
|
struct _GtkInfoBar
|
|
|
|
|
{
|
2020-05-07 17:00:51 +00:00
|
|
|
|
GtkWidget parent_instance;
|
2019-05-27 02:30:33 +00:00
|
|
|
|
|
2009-06-05 18:56:08 +00:00
|
|
|
|
GtkWidget *content_area;
|
|
|
|
|
GtkWidget *action_area;
|
2013-07-15 19:04:56 +00:00
|
|
|
|
GtkWidget *close_button;
|
2013-07-31 16:40:52 +00:00
|
|
|
|
GtkWidget *revealer;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
|
|
|
|
GtkMessageType message_type;
|
2020-01-09 21:11:36 +00:00
|
|
|
|
int default_response;
|
|
|
|
|
gboolean default_response_sensitive;
|
2020-03-28 14:48:15 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _GtkInfoBarClass
|
|
|
|
|
{
|
2020-05-07 17:00:51 +00:00
|
|
|
|
GtkWidgetClass parent_class;
|
2020-03-28 14:48:15 +00:00
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
void (* response) (GtkInfoBar *info_bar, int response_id);
|
2020-03-28 14:48:15 +00:00
|
|
|
|
void (* close) (GtkInfoBar *info_bar);
|
|
|
|
|
};
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
|
|
|
|
typedef struct _ResponseData ResponseData;
|
|
|
|
|
|
|
|
|
|
struct _ResponseData
|
|
|
|
|
{
|
2020-05-07 16:28:33 +00:00
|
|
|
|
int response_id;
|
|
|
|
|
gulong handler_id;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
RESPONSE,
|
|
|
|
|
CLOSE,
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
2017-01-12 07:42:09 +00:00
|
|
|
|
static GParamSpec *props[LAST_PROP] = { NULL, };
|
2009-06-05 18:56:08 +00:00
|
|
|
|
static guint signals[LAST_SIGNAL];
|
|
|
|
|
|
|
|
|
|
static void gtk_info_bar_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
static void gtk_info_bar_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2019-08-29 13:21:20 +00:00
|
|
|
|
static void gtk_info_bar_buildable_interface_init (GtkBuildableIface *iface);
|
|
|
|
|
static gboolean gtk_info_bar_buildable_custom_tag_start (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *tagname,
|
2019-08-29 13:21:20 +00:00
|
|
|
|
GtkBuildableParser *parser,
|
|
|
|
|
gpointer *data);
|
|
|
|
|
static void gtk_info_bar_buildable_custom_finished (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *tagname,
|
2019-08-29 13:21:20 +00:00
|
|
|
|
gpointer user_data);
|
|
|
|
|
static void gtk_info_bar_buildable_add_child (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
|
|
|
|
const char *type);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
|
|
|
|
|
2019-08-28 06:13:18 +00:00
|
|
|
|
|
2020-05-07 17:00:51 +00:00
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkInfoBar, gtk_info_bar, GTK_TYPE_WIDGET,
|
2009-06-05 18:56:08 +00:00
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
|
|
|
|
gtk_info_bar_buildable_interface_init))
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_info_bar_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GtkInfoBar *info_bar = GTK_INFO_BAR (object);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_MESSAGE_TYPE:
|
|
|
|
|
gtk_info_bar_set_message_type (info_bar, g_value_get_enum (value));
|
|
|
|
|
break;
|
2013-07-15 19:04:56 +00:00
|
|
|
|
case PROP_SHOW_CLOSE_BUTTON:
|
|
|
|
|
gtk_info_bar_set_show_close_button (info_bar, g_value_get_boolean (value));
|
|
|
|
|
break;
|
2017-01-12 08:09:22 +00:00
|
|
|
|
case PROP_REVEALED:
|
|
|
|
|
gtk_info_bar_set_revealed (info_bar, g_value_get_boolean (value));
|
|
|
|
|
break;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_info_bar_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GtkInfoBar *info_bar = GTK_INFO_BAR (object);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_MESSAGE_TYPE:
|
|
|
|
|
g_value_set_enum (value, gtk_info_bar_get_message_type (info_bar));
|
|
|
|
|
break;
|
2013-07-15 19:04:56 +00:00
|
|
|
|
case PROP_SHOW_CLOSE_BUTTON:
|
|
|
|
|
g_value_set_boolean (value, gtk_info_bar_get_show_close_button (info_bar));
|
|
|
|
|
break;
|
2017-01-12 08:09:22 +00:00
|
|
|
|
case PROP_REVEALED:
|
|
|
|
|
g_value_set_boolean (value, gtk_info_bar_get_revealed (info_bar));
|
|
|
|
|
break;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
response_data_free (gpointer data)
|
|
|
|
|
{
|
|
|
|
|
g_slice_free (ResponseData, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ResponseData *
|
|
|
|
|
get_response_data (GtkWidget *widget,
|
|
|
|
|
gboolean create)
|
|
|
|
|
{
|
|
|
|
|
ResponseData *ad = g_object_get_data (G_OBJECT (widget),
|
|
|
|
|
"gtk-info-bar-response-data");
|
|
|
|
|
|
|
|
|
|
if (ad == NULL && create)
|
|
|
|
|
{
|
|
|
|
|
ad = g_slice_new (ResponseData);
|
|
|
|
|
|
|
|
|
|
g_object_set_data_full (G_OBJECT (widget),
|
|
|
|
|
I_("gtk-info-bar-response-data"),
|
|
|
|
|
ad,
|
|
|
|
|
response_data_free);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ad;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-07 16:28:33 +00:00
|
|
|
|
static void
|
|
|
|
|
clear_response_data (GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
ResponseData *data;
|
|
|
|
|
|
|
|
|
|
data = get_response_data (widget, FALSE);
|
|
|
|
|
g_signal_handler_disconnect (widget, data->handler_id);
|
2020-06-18 07:47:16 +00:00
|
|
|
|
g_object_set_data (G_OBJECT (widget), "gtk-info-bar-response-data", NULL);
|
2020-05-07 16:28:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-06-05 18:56:08 +00:00
|
|
|
|
static GtkWidget *
|
|
|
|
|
find_button (GtkInfoBar *info_bar,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int response_id)
|
2009-06-05 18:56:08 +00:00
|
|
|
|
{
|
2020-05-09 12:26:52 +00:00
|
|
|
|
GtkWidget *child;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
2020-05-09 12:26:52 +00:00
|
|
|
|
for (child = gtk_widget_get_first_child (info_bar->action_area);
|
|
|
|
|
child != NULL;
|
|
|
|
|
child = gtk_widget_get_next_sibling (child))
|
2009-06-05 18:56:08 +00:00
|
|
|
|
{
|
2020-05-09 12:26:52 +00:00
|
|
|
|
ResponseData *rd = get_response_data (child, FALSE);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
|
|
|
|
if (rd && rd->response_id == response_id)
|
2020-05-09 12:26:52 +00:00
|
|
|
|
return child;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-09 12:26:52 +00:00
|
|
|
|
return NULL;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_info_bar_close (GtkInfoBar *info_bar)
|
|
|
|
|
{
|
2020-03-28 14:48:15 +00:00
|
|
|
|
if (!gtk_widget_get_visible (info_bar->close_button) &&
|
|
|
|
|
!find_button (info_bar, GTK_RESPONSE_CANCEL))
|
2009-06-05 18:56:08 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
gtk_info_bar_response (GTK_INFO_BAR (info_bar),
|
|
|
|
|
GTK_RESPONSE_CANCEL);
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-28 06:13:18 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_info_bar_dispose (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GtkInfoBar *self = GTK_INFO_BAR (object);
|
|
|
|
|
|
2020-03-28 14:48:15 +00:00
|
|
|
|
g_clear_pointer (&self->revealer, gtk_widget_unparent);
|
2019-08-28 06:13:18 +00:00
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_info_bar_parent_class)->dispose (object);
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-05 18:56:08 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_info_bar_class_init (GtkInfoBarClass *klass)
|
|
|
|
|
{
|
2018-08-12 14:57:37 +00:00
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
|
|
|
|
object_class->get_property = gtk_info_bar_get_property;
|
|
|
|
|
object_class->set_property = gtk_info_bar_set_property;
|
2019-08-28 06:13:18 +00:00
|
|
|
|
object_class->dispose = gtk_info_bar_dispose;
|
|
|
|
|
|
2009-06-05 18:56:08 +00:00
|
|
|
|
klass->close = gtk_info_bar_close;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkInfoBar:message-type:
|
|
|
|
|
*
|
|
|
|
|
* The type of the message.
|
|
|
|
|
*
|
2013-07-15 16:37:58 +00:00
|
|
|
|
* The type may be used to determine the appearance of the info bar.
|
2009-06-05 18:56:08 +00:00
|
|
|
|
*/
|
2017-01-12 07:42:09 +00:00
|
|
|
|
props[PROP_MESSAGE_TYPE] =
|
|
|
|
|
g_param_spec_enum ("message-type",
|
|
|
|
|
P_("Message Type"),
|
|
|
|
|
P_("The type of message"),
|
|
|
|
|
GTK_TYPE_MESSAGE_TYPE,
|
|
|
|
|
GTK_MESSAGE_INFO,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT|G_PARAM_EXPLICIT_NOTIFY);
|
2013-07-15 19:04:56 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkInfoBar:show-close-button:
|
|
|
|
|
*
|
|
|
|
|
* Whether to include a standard close button.
|
|
|
|
|
*/
|
2017-01-12 07:42:09 +00:00
|
|
|
|
props[PROP_SHOW_CLOSE_BUTTON] =
|
|
|
|
|
g_param_spec_boolean ("show-close-button",
|
|
|
|
|
P_("Show Close Button"),
|
|
|
|
|
P_("Whether to include a standard close button"),
|
|
|
|
|
FALSE,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
|
2017-01-12 08:09:22 +00:00
|
|
|
|
props[PROP_REVEALED] =
|
|
|
|
|
g_param_spec_boolean ("revealed",
|
|
|
|
|
P_("Reveal"),
|
2017-09-05 19:19:33 +00:00
|
|
|
|
P_("Controls whether the info bar shows its contents or not"),
|
2017-01-12 08:09:22 +00:00
|
|
|
|
TRUE,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
|
2017-01-12 07:42:09 +00:00
|
|
|
|
g_object_class_install_properties (object_class, LAST_PROP, props);
|
|
|
|
|
|
2009-06-05 18:56:08 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkInfoBar::response:
|
|
|
|
|
* @info_bar: the object on which the signal is emitted
|
|
|
|
|
* @response_id: the response ID
|
|
|
|
|
*
|
|
|
|
|
* Emitted when an action widget is clicked or the application programmer
|
2017-01-12 07:37:15 +00:00
|
|
|
|
* calls gtk_info_bar_response(). The @response_id depends on which action
|
2009-06-05 18:56:08 +00:00
|
|
|
|
* widget was clicked.
|
|
|
|
|
*/
|
|
|
|
|
signals[RESPONSE] = g_signal_new (I_("response"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (klass),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (GtkInfoBarClass, response),
|
|
|
|
|
NULL, NULL,
|
2019-05-31 03:56:50 +00:00
|
|
|
|
NULL,
|
2009-06-05 18:56:08 +00:00
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
|
G_TYPE_INT);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkInfoBar::close:
|
|
|
|
|
*
|
|
|
|
|
* The ::close signal is a
|
2020-11-17 03:58:53 +00:00
|
|
|
|
* [keybinding signal][GtkSignalAction]
|
2009-06-05 18:56:08 +00:00
|
|
|
|
* which gets emitted when the user uses a keybinding to dismiss
|
|
|
|
|
* the info bar.
|
|
|
|
|
*
|
|
|
|
|
* The default binding for this signal is the Escape key.
|
|
|
|
|
*/
|
|
|
|
|
signals[CLOSE] = g_signal_new (I_("close"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (klass),
|
|
|
|
|
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
|
|
|
|
G_STRUCT_OFFSET (GtkInfoBarClass, close),
|
|
|
|
|
NULL, NULL,
|
2019-05-29 20:05:19 +00:00
|
|
|
|
NULL,
|
2009-06-05 18:56:08 +00:00
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
2018-08-12 14:57:37 +00:00
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_Escape, 0,
|
|
|
|
|
"close",
|
|
|
|
|
NULL);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
2017-11-18 03:49:57 +00:00
|
|
|
|
gtk_widget_class_set_css_name (widget_class, I_("infobar"));
|
2019-08-28 06:13:18 +00:00
|
|
|
|
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
2013-07-15 19:04:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
close_button_clicked_cb (GtkWidget *button,
|
|
|
|
|
GtkInfoBar *info_bar)
|
|
|
|
|
{
|
2020-03-28 14:48:15 +00:00
|
|
|
|
gtk_info_bar_response (GTK_INFO_BAR (info_bar), GTK_RESPONSE_CLOSE);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-09 21:11:36 +00:00
|
|
|
|
static void
|
|
|
|
|
click_released_cb (GtkGestureClick *gesture,
|
|
|
|
|
guint n_press,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double x,
|
|
|
|
|
double y,
|
2020-01-09 21:11:36 +00:00
|
|
|
|
GtkInfoBar *info_bar)
|
|
|
|
|
{
|
2020-03-28 14:48:15 +00:00
|
|
|
|
if (info_bar->default_response && info_bar->default_response_sensitive)
|
|
|
|
|
gtk_info_bar_response (info_bar, info_bar->default_response);
|
2020-01-09 21:11:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-06-05 18:56:08 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_info_bar_init (GtkInfoBar *info_bar)
|
|
|
|
|
{
|
2011-06-17 03:18:03 +00:00
|
|
|
|
GtkWidget *widget = GTK_WIDGET (info_bar);
|
2019-08-28 06:13:18 +00:00
|
|
|
|
GtkWidget *main_box;
|
2020-01-09 21:11:36 +00:00
|
|
|
|
GtkGesture *gesture;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
2012-02-23 23:16:33 +00:00
|
|
|
|
/* message-type is a CONSTRUCT property, so we init to a value
|
|
|
|
|
* different from its default to trigger its property setter
|
|
|
|
|
* during construction */
|
2020-03-28 14:48:15 +00:00
|
|
|
|
info_bar->message_type = GTK_MESSAGE_OTHER;
|
2012-02-23 23:16:33 +00:00
|
|
|
|
|
2020-03-28 14:48:15 +00:00
|
|
|
|
info_bar->revealer = gtk_revealer_new ();
|
|
|
|
|
gtk_revealer_set_reveal_child (GTK_REVEALER (info_bar->revealer), TRUE);
|
|
|
|
|
gtk_widget_set_parent (info_bar->revealer, widget);
|
2019-08-28 06:13:18 +00:00
|
|
|
|
|
|
|
|
|
main_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
2020-05-02 21:02:42 +00:00
|
|
|
|
gtk_revealer_set_child (GTK_REVEALER (info_bar->revealer), main_box);
|
2020-03-28 14:48:15 +00:00
|
|
|
|
|
|
|
|
|
info_bar->content_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
|
|
|
|
gtk_widget_set_hexpand (info_bar->content_area, TRUE);
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_append (GTK_BOX (main_box), info_bar->content_area);
|
2020-03-28 14:48:15 +00:00
|
|
|
|
|
|
|
|
|
info_bar->action_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
|
|
|
|
gtk_widget_set_halign (info_bar->action_area, GTK_ALIGN_END);
|
|
|
|
|
gtk_widget_set_valign (info_bar->action_area, GTK_ALIGN_CENTER);
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_append (GTK_BOX (main_box), info_bar->action_area);
|
2020-03-28 14:48:15 +00:00
|
|
|
|
|
|
|
|
|
info_bar->close_button = gtk_button_new_from_icon_name ("window-close-symbolic");
|
|
|
|
|
gtk_widget_hide (info_bar->close_button);
|
|
|
|
|
gtk_widget_set_valign (info_bar->close_button, GTK_ALIGN_CENTER);
|
|
|
|
|
gtk_widget_add_css_class (info_bar->close_button, "close");
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_append (GTK_BOX (main_box), info_bar->close_button);
|
2020-03-28 14:48:15 +00:00
|
|
|
|
g_signal_connect (info_bar->close_button, "clicked",
|
2013-07-15 19:04:56 +00:00
|
|
|
|
G_CALLBACK (close_button_clicked_cb), info_bar);
|
2020-01-09 21:11:36 +00:00
|
|
|
|
|
|
|
|
|
gesture = gtk_gesture_click_new ();
|
|
|
|
|
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_PRIMARY);
|
|
|
|
|
g_signal_connect (gesture, "released", G_CALLBACK (click_released_cb), widget);
|
|
|
|
|
gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (gesture));
|
2009-06-05 18:56:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GtkBuildableIface *parent_buildable_iface;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_info_bar_buildable_interface_init (GtkBuildableIface *iface)
|
|
|
|
|
{
|
|
|
|
|
parent_buildable_iface = g_type_interface_peek_parent (iface);
|
2019-08-28 06:13:18 +00:00
|
|
|
|
|
|
|
|
|
iface->add_child = gtk_info_bar_buildable_add_child;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
iface->custom_tag_start = gtk_info_bar_buildable_custom_tag_start;
|
|
|
|
|
iface->custom_finished = gtk_info_bar_buildable_custom_finished;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
static int
|
2009-06-05 18:56:08 +00:00
|
|
|
|
get_response_for_widget (GtkInfoBar *info_bar,
|
|
|
|
|
GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
ResponseData *rd;
|
|
|
|
|
|
|
|
|
|
rd = get_response_data (widget, FALSE);
|
|
|
|
|
if (!rd)
|
|
|
|
|
return GTK_RESPONSE_NONE;
|
|
|
|
|
else
|
|
|
|
|
return rd->response_id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
action_widget_activated (GtkWidget *widget,
|
|
|
|
|
GtkInfoBar *info_bar)
|
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int response_id;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
|
|
|
|
response_id = get_response_for_widget (info_bar, widget);
|
|
|
|
|
gtk_info_bar_response (info_bar, response_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_info_bar_add_action_widget:
|
|
|
|
|
* @info_bar: a #GtkInfoBar
|
|
|
|
|
* @child: an activatable widget
|
|
|
|
|
* @response_id: response ID for @child
|
|
|
|
|
*
|
|
|
|
|
* Add an activatable widget to the action area of a #GtkInfoBar,
|
|
|
|
|
* connecting a signal handler that will emit the #GtkInfoBar::response
|
|
|
|
|
* signal on the message area when the widget is activated. The widget
|
|
|
|
|
* is appended to the end of the message areas action area.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_info_bar_add_action_widget (GtkInfoBar *info_bar,
|
|
|
|
|
GtkWidget *child,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int response_id)
|
2009-06-05 18:56:08 +00:00
|
|
|
|
{
|
|
|
|
|
ResponseData *ad;
|
|
|
|
|
guint signal_id;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (child));
|
|
|
|
|
|
|
|
|
|
ad = get_response_data (child, TRUE);
|
|
|
|
|
|
2018-12-26 07:20:34 +00:00
|
|
|
|
G_DEBUG_HERE();
|
2009-06-05 18:56:08 +00:00
|
|
|
|
ad->response_id = response_id;
|
|
|
|
|
|
|
|
|
|
if (GTK_IS_BUTTON (child))
|
|
|
|
|
signal_id = g_signal_lookup ("clicked", GTK_TYPE_BUTTON);
|
|
|
|
|
else
|
|
|
|
|
signal_id = GTK_WIDGET_GET_CLASS (child)->activate_signal;
|
|
|
|
|
|
|
|
|
|
if (signal_id)
|
|
|
|
|
{
|
|
|
|
|
GClosure *closure;
|
|
|
|
|
|
|
|
|
|
closure = g_cclosure_new_object (G_CALLBACK (action_widget_activated),
|
|
|
|
|
G_OBJECT (info_bar));
|
2020-05-07 16:28:33 +00:00
|
|
|
|
ad->handler_id = g_signal_connect_closure_by_id (child, signal_id, 0, closure, FALSE);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
g_warning ("Only 'activatable' widgets can be packed into the action area of a GtkInfoBar");
|
|
|
|
|
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_append (GTK_BOX (info_bar->action_area), child);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-07 16:28:33 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_info_bar_remove_action_widget:
|
|
|
|
|
* @info_bar: a #GtkInfoBar
|
|
|
|
|
* @widget: an action widget to remove
|
|
|
|
|
*
|
|
|
|
|
* Removes a widget from the action area of @info_bar, after
|
|
|
|
|
* it been put there by a call to gtk_info_bar_add_action_widget()
|
|
|
|
|
* or gtk_info_bar_add_button().
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_info_bar_remove_action_widget (GtkInfoBar *info_bar,
|
|
|
|
|
GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
|
|
|
|
g_return_if_fail (gtk_widget_get_parent (widget) == info_bar->action_area);
|
|
|
|
|
|
|
|
|
|
clear_response_data (widget);
|
|
|
|
|
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_remove (GTK_BOX (info_bar->action_area), widget);
|
2020-05-07 16:28:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-06-05 18:56:08 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_info_bar_add_button:
|
|
|
|
|
* @info_bar: a #GtkInfoBar
|
2013-06-25 03:47:52 +00:00
|
|
|
|
* @button_text: text of button
|
2009-06-05 18:56:08 +00:00
|
|
|
|
* @response_id: response ID for the button
|
|
|
|
|
*
|
2013-06-25 03:47:52 +00:00
|
|
|
|
* Adds a button with the given text and sets things up so that
|
2014-02-05 18:07:34 +00:00
|
|
|
|
* clicking the button will emit the “response” signal with the given
|
2013-06-25 03:47:52 +00:00
|
|
|
|
* response_id. The button is appended to the end of the info bars's
|
|
|
|
|
* action area. The button widget is returned, but usually you don't
|
|
|
|
|
* need it.
|
2009-06-05 18:56:08 +00:00
|
|
|
|
*
|
2014-05-26 16:41:21 +00:00
|
|
|
|
* Returns: (transfer none) (type Gtk.Button): the #GtkButton widget
|
|
|
|
|
* that was added
|
2009-06-05 18:56:08 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkWidget*
|
|
|
|
|
gtk_info_bar_add_button (GtkInfoBar *info_bar,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *button_text,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int response_id)
|
2009-06-05 18:56:08 +00:00
|
|
|
|
{
|
|
|
|
|
GtkWidget *button;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_INFO_BAR (info_bar), NULL);
|
|
|
|
|
g_return_val_if_fail (button_text != NULL, NULL);
|
|
|
|
|
|
2013-06-25 03:47:52 +00:00
|
|
|
|
button = gtk_button_new_with_label (button_text);
|
|
|
|
|
gtk_button_set_use_underline (GTK_BUTTON (button), TRUE);
|
|
|
|
|
|
2009-06-05 18:56:08 +00:00
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
|
|
gtk_info_bar_add_action_widget (info_bar, button, response_id);
|
|
|
|
|
|
|
|
|
|
return button;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
add_buttons_valist (GtkInfoBar *info_bar,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *first_button_text,
|
2009-06-05 18:56:08 +00:00
|
|
|
|
va_list args)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char * text;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int response_id;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
|
|
|
|
|
|
|
|
|
|
if (first_button_text == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
text = first_button_text;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
response_id = va_arg (args, int);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
|
|
|
|
while (text != NULL)
|
|
|
|
|
{
|
|
|
|
|
gtk_info_bar_add_button (info_bar, text, response_id);
|
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
|
text = va_arg (args, char *);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
if (text == NULL)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
response_id = va_arg (args, int);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_info_bar_add_buttons:
|
|
|
|
|
* @info_bar: a #GtkInfoBar
|
2016-10-16 11:12:16 +00:00
|
|
|
|
* @first_button_text: button text
|
2009-06-05 18:56:08 +00:00
|
|
|
|
* @...: response ID for first button, then more text-response_id pairs,
|
|
|
|
|
* ending with %NULL
|
|
|
|
|
*
|
|
|
|
|
* Adds more buttons, same as calling gtk_info_bar_add_button()
|
|
|
|
|
* repeatedly. The variable argument list should be %NULL-terminated
|
|
|
|
|
* as with gtk_info_bar_new_with_buttons(). Each button must have both
|
|
|
|
|
* text and response ID.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_info_bar_add_buttons (GtkInfoBar *info_bar,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *first_button_text,
|
2009-06-05 18:56:08 +00:00
|
|
|
|
...)
|
|
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
|
|
va_start (args, first_button_text);
|
|
|
|
|
add_buttons_valist (info_bar, first_button_text, args);
|
|
|
|
|
va_end (args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_info_bar_new:
|
|
|
|
|
*
|
|
|
|
|
* Creates a new #GtkInfoBar object.
|
|
|
|
|
*
|
|
|
|
|
* Returns: a new #GtkInfoBar object
|
|
|
|
|
*/
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_info_bar_new (void)
|
|
|
|
|
{
|
|
|
|
|
return g_object_new (GTK_TYPE_INFO_BAR, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_info_bar_new_with_buttons:
|
2016-10-16 11:12:16 +00:00
|
|
|
|
* @first_button_text: (allow-none): ext to go in first button, or %NULL
|
2009-06-05 18:56:08 +00:00
|
|
|
|
* @...: response ID for first button, then additional buttons, ending
|
|
|
|
|
* with %NULL
|
|
|
|
|
*
|
|
|
|
|
* Creates a new #GtkInfoBar with buttons. Button text/response ID
|
|
|
|
|
* pairs should be listed, with a %NULL pointer ending the list.
|
2016-10-16 11:12:16 +00:00
|
|
|
|
* A response ID can be any positive number,
|
2009-06-05 18:56:08 +00:00
|
|
|
|
* or one of the values in the #GtkResponseType enumeration. If the
|
|
|
|
|
* user clicks one of these dialog buttons, GtkInfoBar will emit
|
2014-02-05 18:07:34 +00:00
|
|
|
|
* the “response” signal with the corresponding response ID.
|
2009-06-05 18:56:08 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: a new #GtkInfoBar
|
|
|
|
|
*/
|
|
|
|
|
GtkWidget*
|
2020-07-24 18:40:36 +00:00
|
|
|
|
gtk_info_bar_new_with_buttons (const char *first_button_text,
|
2009-06-05 18:56:08 +00:00
|
|
|
|
...)
|
|
|
|
|
{
|
|
|
|
|
GtkInfoBar *info_bar;
|
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
|
|
info_bar = GTK_INFO_BAR (gtk_info_bar_new ());
|
|
|
|
|
|
|
|
|
|
va_start (args, first_button_text);
|
|
|
|
|
add_buttons_valist (info_bar, first_button_text, args);
|
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
|
|
return GTK_WIDGET (info_bar);
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-09 21:11:36 +00:00
|
|
|
|
static void
|
|
|
|
|
update_default_response (GtkInfoBar *info_bar,
|
|
|
|
|
int response_id,
|
|
|
|
|
gboolean sensitive)
|
|
|
|
|
{
|
2020-03-28 14:48:15 +00:00
|
|
|
|
info_bar->default_response = response_id;
|
|
|
|
|
info_bar->default_response_sensitive = sensitive;
|
2020-01-09 21:11:36 +00:00
|
|
|
|
|
|
|
|
|
if (response_id && sensitive)
|
2020-02-06 16:32:26 +00:00
|
|
|
|
gtk_widget_add_css_class (GTK_WIDGET (info_bar), "action");
|
2020-01-09 21:11:36 +00:00
|
|
|
|
else
|
2020-02-06 16:32:26 +00:00
|
|
|
|
gtk_widget_remove_css_class (GTK_WIDGET (info_bar), "action");
|
2020-01-09 21:11:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-06-05 18:56:08 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_info_bar_set_response_sensitive:
|
|
|
|
|
* @info_bar: a #GtkInfoBar
|
|
|
|
|
* @response_id: a response ID
|
|
|
|
|
* @setting: TRUE for sensitive
|
|
|
|
|
*
|
|
|
|
|
* Calls gtk_widget_set_sensitive (widget, setting) for each
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* widget in the info bars’s action area with the given response_id.
|
2009-06-05 18:56:08 +00:00
|
|
|
|
* A convenient way to sensitize/desensitize dialog buttons.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_info_bar_set_response_sensitive (GtkInfoBar *info_bar,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int response_id,
|
2009-06-05 18:56:08 +00:00
|
|
|
|
gboolean setting)
|
|
|
|
|
{
|
2020-05-09 12:26:52 +00:00
|
|
|
|
GtkWidget *child;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
|
|
|
|
|
|
2020-05-09 12:26:52 +00:00
|
|
|
|
for (child = gtk_widget_get_first_child (info_bar->action_area);
|
|
|
|
|
child != NULL;
|
|
|
|
|
child = gtk_widget_get_next_sibling (child))
|
2009-06-05 18:56:08 +00:00
|
|
|
|
{
|
2020-05-09 12:26:52 +00:00
|
|
|
|
ResponseData *rd = get_response_data (child, FALSE);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
|
|
|
|
if (rd && rd->response_id == response_id)
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_widget_set_sensitive (child, setting);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-28 14:48:15 +00:00
|
|
|
|
if (response_id == info_bar->default_response)
|
2020-01-09 21:11:36 +00:00
|
|
|
|
update_default_response (info_bar, response_id, setting);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_info_bar_set_default_response:
|
|
|
|
|
* @info_bar: a #GtkInfoBar
|
|
|
|
|
* @response_id: a response ID
|
|
|
|
|
*
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* Sets the last widget in the info bar’s action area with
|
2009-06-05 18:56:08 +00:00
|
|
|
|
* the given response_id as the default widget for the dialog.
|
2014-02-05 18:07:34 +00:00
|
|
|
|
* Pressing “Enter” normally activates the default widget.
|
2009-06-05 18:56:08 +00:00
|
|
|
|
*
|
2010-02-23 16:13:16 +00:00
|
|
|
|
* Note that this function currently requires @info_bar to
|
|
|
|
|
* be added to a widget hierarchy.
|
2009-06-05 18:56:08 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_info_bar_set_default_response (GtkInfoBar *info_bar,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int response_id)
|
2009-06-05 18:56:08 +00:00
|
|
|
|
{
|
2020-05-09 12:26:52 +00:00
|
|
|
|
GtkWidget *child;
|
|
|
|
|
GtkWidget *window;
|
2020-01-09 21:11:36 +00:00
|
|
|
|
gboolean sensitive = TRUE;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
|
|
|
|
|
|
2020-05-09 12:26:52 +00:00
|
|
|
|
window = gtk_widget_get_ancestor (GTK_WIDGET (info_bar), GTK_TYPE_WINDOW);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
2020-05-09 12:26:52 +00:00
|
|
|
|
for (child = gtk_widget_get_first_child (info_bar->action_area);
|
|
|
|
|
child != NULL;
|
|
|
|
|
child = gtk_widget_get_next_sibling (child))
|
2009-06-05 18:56:08 +00:00
|
|
|
|
{
|
2020-05-09 12:26:52 +00:00
|
|
|
|
ResponseData *rd = get_response_data (child, FALSE);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
|
|
|
|
if (rd && rd->response_id == response_id)
|
2019-04-27 03:20:41 +00:00
|
|
|
|
{
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_window_set_default_widget (GTK_WINDOW (window), child);
|
|
|
|
|
sensitive = gtk_widget_get_sensitive (child);
|
|
|
|
|
break;
|
2019-04-27 03:20:41 +00:00
|
|
|
|
}
|
2009-06-05 18:56:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-09 21:11:36 +00:00
|
|
|
|
update_default_response (info_bar, response_id, sensitive);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2009-06-16 00:04:48 +00:00
|
|
|
|
* gtk_info_bar_response:
|
2009-06-05 18:56:08 +00:00
|
|
|
|
* @info_bar: a #GtkInfoBar
|
|
|
|
|
* @response_id: a response ID
|
|
|
|
|
*
|
2014-02-07 19:03:49 +00:00
|
|
|
|
* Emits the “response” signal with the given @response_id.
|
2009-06-05 18:56:08 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_info_bar_response (GtkInfoBar *info_bar,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int response_id)
|
2009-06-05 18:56:08 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
|
|
|
|
|
|
|
|
|
|
g_signal_emit (info_bar, signals[RESPONSE], 0, response_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *name;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int response_id;
|
|
|
|
|
int line;
|
|
|
|
|
int col;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
} ActionWidgetInfo;
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
GtkInfoBar *info_bar;
|
|
|
|
|
GtkBuilder *builder;
|
|
|
|
|
GSList *items;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int response_id;
|
2015-04-25 23:35:22 +00:00
|
|
|
|
gboolean is_text;
|
|
|
|
|
GString *string;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int line;
|
|
|
|
|
int col;
|
2015-04-25 23:35:22 +00:00
|
|
|
|
} SubParserData;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
2016-02-26 19:55:20 +00:00
|
|
|
|
static void
|
|
|
|
|
action_widget_info_free (gpointer data)
|
|
|
|
|
{
|
|
|
|
|
ActionWidgetInfo *item = data;
|
|
|
|
|
|
|
|
|
|
g_free (item->name);
|
|
|
|
|
g_free (item);
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-05 18:56:08 +00:00
|
|
|
|
static void
|
2019-08-29 13:21:20 +00:00
|
|
|
|
parser_start_element (GtkBuildableParseContext *context,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *element_name,
|
|
|
|
|
const char **names,
|
|
|
|
|
const char **values,
|
2019-08-29 13:21:20 +00:00
|
|
|
|
gpointer user_data,
|
|
|
|
|
GError **error)
|
2009-06-05 18:56:08 +00:00
|
|
|
|
{
|
2015-04-25 23:35:22 +00:00
|
|
|
|
SubParserData *data = (SubParserData*)user_data;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
|
|
|
|
if (strcmp (element_name, "action-widget") == 0)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *response;
|
2015-04-25 23:35:22 +00:00
|
|
|
|
GValue gvalue = G_VALUE_INIT;
|
|
|
|
|
|
|
|
|
|
if (!_gtk_builder_check_parent (data->builder, context, "action-widgets", error))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!g_markup_collect_attributes (element_name, names, values, error,
|
|
|
|
|
G_MARKUP_COLLECT_STRING, "response", &response,
|
|
|
|
|
G_MARKUP_COLLECT_INVALID))
|
|
|
|
|
{
|
|
|
|
|
_gtk_builder_prefix_error (data->builder, context, error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!gtk_builder_value_from_string_type (data->builder, GTK_TYPE_RESPONSE_TYPE, response, &gvalue, error))
|
|
|
|
|
{
|
|
|
|
|
_gtk_builder_prefix_error (data->builder, context, error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data->response_id = g_value_get_enum (&gvalue);
|
|
|
|
|
data->is_text = TRUE;
|
|
|
|
|
g_string_set_size (data->string, 0);
|
2019-08-29 13:21:20 +00:00
|
|
|
|
gtk_buildable_parse_context_get_position (context, &data->line, &data->col);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
}
|
|
|
|
|
else if (strcmp (element_name, "action-widgets") == 0)
|
2015-04-25 23:35:22 +00:00
|
|
|
|
{
|
|
|
|
|
if (!_gtk_builder_check_parent (data->builder, context, "object", error))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!g_markup_collect_attributes (element_name, names, values, error,
|
|
|
|
|
G_MARKUP_COLLECT_INVALID, NULL, NULL,
|
|
|
|
|
G_MARKUP_COLLECT_INVALID))
|
|
|
|
|
_gtk_builder_prefix_error (data->builder, context, error);
|
|
|
|
|
}
|
2009-06-05 18:56:08 +00:00
|
|
|
|
else
|
2015-04-25 23:35:22 +00:00
|
|
|
|
{
|
|
|
|
|
_gtk_builder_error_unhandled_tag (data->builder, context,
|
|
|
|
|
"GtkInfoBar", element_name,
|
|
|
|
|
error);
|
|
|
|
|
}
|
2009-06-05 18:56:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-08-29 13:21:20 +00:00
|
|
|
|
parser_text_element (GtkBuildableParseContext *context,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *text,
|
2019-08-29 13:21:20 +00:00
|
|
|
|
gsize text_len,
|
|
|
|
|
gpointer user_data,
|
|
|
|
|
GError **error)
|
2009-06-05 18:56:08 +00:00
|
|
|
|
{
|
2015-04-25 23:35:22 +00:00
|
|
|
|
SubParserData *data = (SubParserData*)user_data;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
2015-04-25 23:35:22 +00:00
|
|
|
|
if (data->is_text)
|
|
|
|
|
g_string_append_len (data->string, text, text_len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-08-29 13:21:20 +00:00
|
|
|
|
parser_end_element (GtkBuildableParseContext *context,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *element_name,
|
2019-08-29 13:21:20 +00:00
|
|
|
|
gpointer user_data,
|
|
|
|
|
GError **error)
|
2015-04-25 23:35:22 +00:00
|
|
|
|
{
|
|
|
|
|
SubParserData *data = (SubParserData*)user_data;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
2015-04-25 23:35:22 +00:00
|
|
|
|
if (data->is_text)
|
|
|
|
|
{
|
|
|
|
|
ActionWidgetInfo *item;
|
|
|
|
|
|
|
|
|
|
item = g_new (ActionWidgetInfo, 1);
|
2015-04-28 03:06:06 +00:00
|
|
|
|
item->name = g_strdup (data->string->str);
|
2015-04-25 23:35:22 +00:00
|
|
|
|
item->response_id = data->response_id;
|
2015-04-28 03:06:06 +00:00
|
|
|
|
item->line = data->line;
|
|
|
|
|
item->col = data->col;
|
2015-04-25 23:35:22 +00:00
|
|
|
|
|
|
|
|
|
data->items = g_slist_prepend (data->items, item);
|
|
|
|
|
data->is_text = FALSE;
|
|
|
|
|
}
|
2009-06-05 18:56:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 13:21:20 +00:00
|
|
|
|
static const GtkBuildableParser sub_parser =
|
2009-06-05 18:56:08 +00:00
|
|
|
|
{
|
2015-04-25 23:35:22 +00:00
|
|
|
|
parser_start_element,
|
|
|
|
|
parser_end_element,
|
|
|
|
|
parser_text_element,
|
2009-06-05 18:56:08 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
gboolean
|
2019-08-29 13:21:20 +00:00
|
|
|
|
gtk_info_bar_buildable_custom_tag_start (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *tagname,
|
2019-08-29 13:21:20 +00:00
|
|
|
|
GtkBuildableParser *parser,
|
|
|
|
|
gpointer *parser_data)
|
2009-06-05 18:56:08 +00:00
|
|
|
|
{
|
2015-04-25 23:35:22 +00:00
|
|
|
|
SubParserData *data;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
2012-05-18 19:05:16 +00:00
|
|
|
|
if (parent_buildable_iface->custom_tag_start (buildable, builder, child,
|
2015-04-25 23:35:22 +00:00
|
|
|
|
tagname, parser, parser_data))
|
2012-05-18 19:05:16 +00:00
|
|
|
|
return TRUE;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
2012-05-18 19:05:16 +00:00
|
|
|
|
if (!child && strcmp (tagname, "action-widgets") == 0)
|
2009-06-05 18:56:08 +00:00
|
|
|
|
{
|
2015-04-25 23:35:22 +00:00
|
|
|
|
data = g_slice_new0 (SubParserData);
|
|
|
|
|
data->info_bar = GTK_INFO_BAR (buildable);
|
|
|
|
|
data->builder = builder;
|
|
|
|
|
data->string = g_string_new ("");
|
|
|
|
|
data->items = NULL;
|
|
|
|
|
|
|
|
|
|
*parser = sub_parser;
|
|
|
|
|
*parser_data = data;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-18 19:05:16 +00:00
|
|
|
|
return FALSE;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_info_bar_buildable_custom_finished (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *tagname,
|
2009-06-05 18:56:08 +00:00
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2018-06-20 18:05:06 +00:00
|
|
|
|
GtkInfoBar *info_bar = GTK_INFO_BAR (buildable);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
GSList *l;
|
2015-04-25 23:35:22 +00:00
|
|
|
|
SubParserData *data;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
GObject *object;
|
|
|
|
|
ResponseData *ad;
|
|
|
|
|
guint signal_id;
|
|
|
|
|
|
|
|
|
|
if (strcmp (tagname, "action-widgets"))
|
|
|
|
|
{
|
|
|
|
|
parent_buildable_iface->custom_finished (buildable, builder, child,
|
|
|
|
|
tagname, user_data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-25 23:35:22 +00:00
|
|
|
|
data = (SubParserData*)user_data;
|
|
|
|
|
data->items = g_slist_reverse (data->items);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
2015-04-25 23:35:22 +00:00
|
|
|
|
for (l = data->items; l; l = l->next)
|
2009-06-05 18:56:08 +00:00
|
|
|
|
{
|
|
|
|
|
ActionWidgetInfo *item = l->data;
|
|
|
|
|
|
2015-04-28 03:06:06 +00:00
|
|
|
|
object = _gtk_builder_lookup_object (builder, item->name, item->line, item->col);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
if (!object)
|
2015-04-28 03:06:06 +00:00
|
|
|
|
continue;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
|
|
|
|
ad = get_response_data (GTK_WIDGET (object), TRUE);
|
2015-04-25 23:35:22 +00:00
|
|
|
|
ad->response_id = item->response_id;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
|
|
|
|
if (GTK_IS_BUTTON (object))
|
|
|
|
|
signal_id = g_signal_lookup ("clicked", GTK_TYPE_BUTTON);
|
|
|
|
|
else
|
|
|
|
|
signal_id = GTK_WIDGET_GET_CLASS (object)->activate_signal;
|
|
|
|
|
|
|
|
|
|
if (signal_id)
|
|
|
|
|
{
|
|
|
|
|
GClosure *closure;
|
|
|
|
|
|
|
|
|
|
closure = g_cclosure_new_object (G_CALLBACK (action_widget_activated),
|
|
|
|
|
G_OBJECT (info_bar));
|
2015-04-25 23:35:22 +00:00
|
|
|
|
g_signal_connect_closure_by_id (object, signal_id, 0, closure, FALSE);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-25 23:35:22 +00:00
|
|
|
|
|
2016-02-26 19:55:20 +00:00
|
|
|
|
g_slist_free_full (data->items, action_widget_info_free);
|
2015-04-25 23:35:22 +00:00
|
|
|
|
g_string_free (data->string, TRUE);
|
|
|
|
|
g_slice_free (SubParserData, data);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-28 06:13:18 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_info_bar_buildable_add_child (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
|
|
|
|
const char *type)
|
|
|
|
|
{
|
|
|
|
|
GtkInfoBar *info_bar = GTK_INFO_BAR (buildable);
|
|
|
|
|
|
2020-05-07 16:49:15 +00:00
|
|
|
|
if (!type && GTK_IS_WIDGET (child))
|
|
|
|
|
gtk_info_bar_add_child (GTK_INFO_BAR (info_bar), GTK_WIDGET (child));
|
2019-08-28 06:13:18 +00:00
|
|
|
|
else if (g_strcmp0 (type, "action") == 0)
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_append (GTK_BOX (info_bar->action_area), GTK_WIDGET (child));
|
2019-08-28 06:13:18 +00:00
|
|
|
|
else
|
|
|
|
|
parent_buildable_iface->add_child (buildable, builder, child, type);
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-05 18:56:08 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_info_bar_set_message_type:
|
|
|
|
|
* @info_bar: a #GtkInfoBar
|
|
|
|
|
* @message_type: a #GtkMessageType
|
|
|
|
|
*
|
|
|
|
|
* Sets the message type of the message area.
|
2016-05-23 18:14:32 +00:00
|
|
|
|
*
|
2020-09-12 16:01:04 +00:00
|
|
|
|
* GTK uses this type to determine how the message is displayed.
|
2009-06-05 18:56:08 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_info_bar_set_message_type (GtkInfoBar *info_bar,
|
|
|
|
|
GtkMessageType message_type)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
|
|
|
|
|
|
2020-03-28 14:48:15 +00:00
|
|
|
|
if (info_bar->message_type != message_type)
|
2009-06-05 18:56:08 +00:00
|
|
|
|
{
|
2012-02-21 22:42:39 +00:00
|
|
|
|
const char *type_class[] = {
|
2020-08-13 23:49:02 +00:00
|
|
|
|
"info",
|
|
|
|
|
"warning",
|
|
|
|
|
"question",
|
|
|
|
|
"error",
|
2012-02-21 22:42:39 +00:00
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-28 14:48:15 +00:00
|
|
|
|
if (type_class[info_bar->message_type])
|
|
|
|
|
gtk_widget_remove_css_class (GTK_WIDGET (info_bar), type_class[info_bar->message_type]);
|
2012-02-21 22:42:39 +00:00
|
|
|
|
|
2020-03-28 14:48:15 +00:00
|
|
|
|
info_bar->message_type = message_type;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (info_bar));
|
|
|
|
|
|
2020-03-28 14:48:15 +00:00
|
|
|
|
if (type_class[info_bar->message_type])
|
|
|
|
|
gtk_widget_add_css_class (GTK_WIDGET (info_bar), type_class[info_bar->message_type]);
|
2012-02-21 22:42:39 +00:00
|
|
|
|
|
2017-01-12 07:42:09 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (info_bar), props[PROP_MESSAGE_TYPE]);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_info_bar_get_message_type:
|
|
|
|
|
* @info_bar: a #GtkInfoBar
|
|
|
|
|
*
|
|
|
|
|
* Returns the message type of the message area.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the message type of the message area.
|
|
|
|
|
*/
|
|
|
|
|
GtkMessageType
|
|
|
|
|
gtk_info_bar_get_message_type (GtkInfoBar *info_bar)
|
|
|
|
|
{
|
2009-06-16 15:34:10 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_INFO_BAR (info_bar), GTK_MESSAGE_OTHER);
|
2009-06-05 18:56:08 +00:00
|
|
|
|
|
2020-03-28 14:48:15 +00:00
|
|
|
|
return info_bar->message_type;
|
2009-06-05 18:56:08 +00:00
|
|
|
|
}
|
2013-07-15 19:04:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_info_bar_set_show_close_button:
|
|
|
|
|
* @info_bar: a #GtkInfoBar
|
|
|
|
|
* @setting: %TRUE to include a close button
|
|
|
|
|
*
|
|
|
|
|
* If true, a standard close button is shown. When clicked it emits
|
|
|
|
|
* the response %GTK_RESPONSE_CLOSE.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_info_bar_set_show_close_button (GtkInfoBar *info_bar,
|
|
|
|
|
gboolean setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
|
|
|
|
|
|
2020-03-28 14:48:15 +00:00
|
|
|
|
if (setting == gtk_info_bar_get_show_close_button (info_bar))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
gtk_widget_set_visible (info_bar->close_button, setting);
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (info_bar), props[PROP_SHOW_CLOSE_BUTTON]);
|
2013-07-15 19:04:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_info_bar_get_show_close_button:
|
|
|
|
|
* @info_bar: a #GtkInfoBar
|
|
|
|
|
*
|
|
|
|
|
* Returns whether the widget will display a standard close button.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the widget displays standard close button
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_info_bar_get_show_close_button (GtkInfoBar *info_bar)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_INFO_BAR (info_bar), FALSE);
|
|
|
|
|
|
2020-03-28 14:48:15 +00:00
|
|
|
|
return gtk_widget_get_visible (info_bar->close_button);
|
2013-07-15 19:04:56 +00:00
|
|
|
|
}
|
2017-01-12 08:09:22 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_info_bar_set_revealed:
|
2017-09-05 19:19:33 +00:00
|
|
|
|
* @info_bar: a #GtkInfoBar
|
2017-01-12 08:09:22 +00:00
|
|
|
|
* @revealed: The new value of the property
|
|
|
|
|
*
|
2017-09-05 19:19:33 +00:00
|
|
|
|
* Sets the #GtkInfoBar:revealed property to @revealed. Changing this will make
|
|
|
|
|
* @info_bar reveal (%TRUE) or conceal (%FALSE) itself via a sliding transition.
|
2017-01-12 08:09:22 +00:00
|
|
|
|
*
|
2017-09-05 19:19:33 +00:00
|
|
|
|
* Note: this does not show or hide @info_bar in the #GtkWidget:visible sense,
|
2017-09-05 20:31:42 +00:00
|
|
|
|
* so revealing has no effect if #GtkWidget:visible is %FALSE.
|
2017-01-12 08:09:22 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_info_bar_set_revealed (GtkInfoBar *info_bar,
|
|
|
|
|
gboolean revealed)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
|
|
|
|
|
|
2020-03-28 14:48:15 +00:00
|
|
|
|
if (revealed == gtk_revealer_get_reveal_child (GTK_REVEALER (info_bar->revealer)))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
gtk_revealer_set_reveal_child (GTK_REVEALER (info_bar->revealer), revealed);
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (info_bar), props[PROP_REVEALED]);
|
2017-01-12 08:09:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_info_bar_get_revealed:
|
|
|
|
|
* @info_bar: a #GtkInfoBar
|
|
|
|
|
*
|
2019-02-24 20:29:08 +00:00
|
|
|
|
* Returns whether the info bar is currently revealed.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the current value of the #GtkInfoBar:revealed property
|
2017-01-12 08:09:22 +00:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_info_bar_get_revealed (GtkInfoBar *info_bar)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_INFO_BAR (info_bar), FALSE);
|
|
|
|
|
|
2020-03-28 14:48:15 +00:00
|
|
|
|
return gtk_revealer_get_reveal_child (GTK_REVEALER (info_bar->revealer));
|
2017-01-12 08:09:22 +00:00
|
|
|
|
}
|
2020-05-07 16:49:15 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_info_bar_add_child:
|
|
|
|
|
* @info_bar: a #GtkInfoBar
|
|
|
|
|
* @widget: the child to be added
|
|
|
|
|
*
|
|
|
|
|
* Adds a widget to the content area of the info bar.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_info_bar_add_child (GtkInfoBar *info_bar,
|
|
|
|
|
GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
|
|
|
|
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_append (GTK_BOX (info_bar->content_area), widget);
|
2020-05-07 16:49:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_info_bar_remove_child:
|
|
|
|
|
* @info_bar: a #GtkInfoBar
|
|
|
|
|
* @widget: a child that has been added to the content area
|
|
|
|
|
*
|
|
|
|
|
* Removes a widget from the content area of the info bar,
|
|
|
|
|
* after it has been added with gtk_info_bar_add_child().
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_info_bar_remove_child (GtkInfoBar *info_bar,
|
|
|
|
|
GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
|
|
|
|
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_remove (GTK_BOX (info_bar->content_area), widget);
|
2020-05-07 16:49:15 +00:00
|
|
|
|
}
|
|
|
|
|
|