Merge branch 'wip/baedert/for-master' into 'master'

Wip/baedert/for master

Closes #2980, #2974, #2949, and #2766

See merge request GNOME/gtk!2333
This commit is contained in:
Matthias Clasen 2020-08-01 23:58:04 +00:00
commit 0b2833f69c
25 changed files with 205 additions and 189 deletions

View File

@ -293,6 +293,7 @@ do_paintable_mediastream (GtkWidget *do_widget)
gtk_widget_get_display (do_widget)); gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Nuclear MediaStream"); gtk_window_set_title (GTK_WINDOW (window), "Nuclear MediaStream");
gtk_window_set_default_size (GTK_WINDOW (window), 300, 200); gtk_window_set_default_size (GTK_WINDOW (window), 300, 200);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
nuclear = gtk_nuclear_media_stream_new (); nuclear = gtk_nuclear_media_stream_new ();
gtk_media_stream_set_loop (GTK_MEDIA_STREAM (nuclear), TRUE); gtk_media_stream_set_loop (GTK_MEDIA_STREAM (nuclear), TRUE);

View File

@ -257,6 +257,7 @@ GtkListBoxUpdateHeaderFunc
gtk_list_box_new gtk_list_box_new
gtk_list_box_prepend gtk_list_box_prepend
gtk_list_box_append
gtk_list_box_insert gtk_list_box_insert
gtk_list_box_remove gtk_list_box_remove
gtk_list_box_select_row gtk_list_box_select_row

View File

@ -95,7 +95,10 @@
* set the title property explicitly when constructing a GtkAboutDialog, * set the title property explicitly when constructing a GtkAboutDialog,
* as shown in the following example: * as shown in the following example:
* |[<!-- language="C" --> * |[<!-- language="C" -->
* GdkTexture *example_logo = gdk_texture_new_from_file ("./logo.png", NULL); * GFile *logo_file = g_file_new_for_path ("./logo.png");
* GdkTexture *example_logo = gdk_texture_new_from_file (logo_file, NULL);
* g_object_unref (logo_file);
*
* gtk_show_about_dialog (NULL, * gtk_show_about_dialog (NULL,
* "program-name", "ExampleCode", * "program-name", "ExampleCode",
* "logo", example_logo, * "logo", example_logo,

View File

@ -629,7 +629,7 @@ gtk_button_buildable_iface_init (GtkBuildableIface *iface)
* gtk_button_new: * gtk_button_new:
* *
* Creates a new #GtkButton widget. To add a child widget to the button, * Creates a new #GtkButton widget. To add a child widget to the button,
* use gtk_container_add(). * use gtk_button_set_child().
* *
* Returns: The newly created #GtkButton widget. * Returns: The newly created #GtkButton widget.
*/ */
@ -1035,7 +1035,7 @@ gtk_button_set_child (GtkButton *button,
gtk_widget_set_parent (priv->child, GTK_WIDGET (button)); gtk_widget_set_parent (priv->child, GTK_WIDGET (button));
gtk_button_set_child_type (button, WIDGET_CHILD); gtk_button_set_child_type (button, WIDGET_CHILD);
g_object_notify (G_OBJECT (button), "child"); g_object_notify_by_pspec (G_OBJECT (button), props[PROP_CHILD]);
} }
/** /**

View File

@ -730,7 +730,7 @@ gtk_dialog_new_empty (const char *title,
* *
* Heres a simple example: * Heres a simple example:
* |[<!-- language="C" --> * |[<!-- language="C" -->
* GtkWidget *main_app_window; // Window the dialog should show up on * GtkWindow *main_app_window; // Window the dialog should show up on
* GtkWidget *dialog; * GtkWidget *dialog;
* GtkDialogFlags flags = GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT; * GtkDialogFlags flags = GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT;
* dialog = gtk_dialog_new_with_buttons ("My dialog", * dialog = gtk_dialog_new_with_buttons ("My dialog",

View File

@ -85,10 +85,12 @@ static guint signals[LAST_SIGNAL] = { 0, };
* ## Simple GtkDrawingArea usage * ## Simple GtkDrawingArea usage
* *
* |[<!-- language="C" --> * |[<!-- language="C" -->
* void * static void
* draw_function (GtkDrawingArea *area, cairo_t *cr, * draw_function (GtkDrawingArea *area,
* int width, int height, * cairo_t *cr,
* gpointer data) * int width,
* int height,
* gpointer data)
* { * {
* GdkRGBA color; * GdkRGBA color;
* GtkStyleContext *context; * GtkStyleContext *context;
@ -107,7 +109,8 @@ static guint signals[LAST_SIGNAL] = { 0, };
* cairo_fill (cr); * cairo_fill (cr);
* } * }
* *
* void main (int argc, char **argv) * int
* main (int argc, char **argv)
* { * {
* gtk_init (); * gtk_init ();
* *
@ -117,7 +120,7 @@ static guint signals[LAST_SIGNAL] = { 0, };
* gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (area), * gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (area),
* draw_function, * draw_function,
* NULL, NULL); * NULL, NULL);
* * return 0;
* } * }
* ]| * ]|
* *

View File

@ -40,7 +40,7 @@
* ## Forcing entry to uppercase. * ## Forcing entry to uppercase.
* *
* |[<!-- language="C" --> * |[<!-- language="C" -->
* #include <ctype.h>; * #include <ctype.h>
* *
* void * void
* insert_text_handler (GtkEditable *editable, * insert_text_handler (GtkEditable *editable,

View File

@ -482,17 +482,26 @@ gtk_file_chooser_get_files (GtkFileChooser *chooser)
* file and is saving it for the first time, do not call this function. * file and is saving it for the first time, do not call this function.
* Instead, use something similar to this: * Instead, use something similar to this:
* |[<!-- language="C" --> * |[<!-- language="C" -->
* if (document_is_new) * static void
* { * prepare_file_chooser (GtkFileChooser *chooser,
* // the user just created a new document * GFile *existing_file)
* gtk_file_chooser_set_current_folder (chooser, default_file_for_saving); * {
* gtk_file_chooser_set_current_name (chooser, "Untitled document"); * gboolean document_is_new = (existing_file == NULL);
* } *
* else * if (document_is_new)
* { * {
* // the user edited an existing document * GFile *default_file_for_saving = g_file_new_for_path ("./out.txt");
* gtk_file_chooser_set_file (chooser, existing_file); * // the user just created a new document
* } * gtk_file_chooser_set_current_folder (chooser, default_file_for_saving, NULL);
* gtk_file_chooser_set_current_name (chooser, "Untitled document");
* g_object_unref (default_file_for_saving);
* }
* else
* {
* // the user edited an existing document
* gtk_file_chooser_set_file (chooser, existing_file, NULL);
* }
* }
* ]| * ]|
* *
* Returns: Not useful. * Returns: Not useful.

View File

@ -84,7 +84,7 @@
* *
* button = gtk_file_chooser_button_new (_("Select a file"), * button = gtk_file_chooser_button_new (_("Select a file"),
* GTK_FILE_CHOOSER_ACTION_OPEN); * GTK_FILE_CHOOSER_ACTION_OPEN);
* gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (button), cwd); * gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (button), cwd, NULL);
* g_object_unref (cwd); * g_object_unref (cwd);
* } * }
* ]| * ]|

View File

@ -68,7 +68,7 @@
* *
* |[<!-- language="C" --> * |[<!-- language="C" -->
* static void * static void
* on_response (GtkNativeDialog *dialog, * on_response (GtkNativeDialog *native,
* int response) * int response)
* { * {
* if (response == GTK_RESPONSE_ACCEPT) * if (response == GTK_RESPONSE_ACCEPT)
@ -102,12 +102,12 @@
* *
* |[<!-- language="C" --> * |[<!-- language="C" -->
* static void * static void
* on_response (GtkNativeDialog *dialog, * on_response (GtkNativeDialog *native,
* int response) * int response)
* { * {
* if (response == GTK_RESPONSE_ACCEPT) * if (response == GTK_RESPONSE_ACCEPT)
* { * {
* GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog); * GtkFileChooser *chooser = GTK_FILE_CHOOSER (native);
* GFile *file = gtk_file_chooser_get_file (chooser); * GFile *file = gtk_file_chooser_get_file (chooser);
* *
* save_to_file (file); * save_to_file (file);
@ -131,11 +131,9 @@
* chooser = GTK_FILE_CHOOSER (native); * chooser = GTK_FILE_CHOOSER (native);
* *
* if (user_edited_a_new_document) * if (user_edited_a_new_document)
* gtk_file_chooser_set_current_name (chooser, * gtk_file_chooser_set_current_name (chooser, _("Untitled document"));
* _("Untitled document"));
* else * else
* gtk_file_chooser_set_filename (chooser, * gtk_file_chooser_set_file (chooser, existing_file, NULL);
* existing_filename);
* *
* g_signal_connect (native, "response", G_CALLBACK (on_response), NULL); * g_signal_connect (native, "response", G_CALLBACK (on_response), NULL);
* gtk_native_dialog_show (GTK_NATIVE_DIALOG (native)); * gtk_native_dialog_show (GTK_NATIVE_DIALOG (native));

View File

@ -48,7 +48,7 @@
* The children of a GtkFlowBox can be dynamically sorted and filtered. * The children of a GtkFlowBox can be dynamically sorted and filtered.
* *
* Although a GtkFlowBox must have only #GtkFlowBoxChild children, * Although a GtkFlowBox must have only #GtkFlowBoxChild children,
* you can add any kind of widget to it via gtk_container_add(), and * you can add any kind of widget to it via gtk_flow_box_insert(), and
* a GtkFlowBoxChild widget will automatically be inserted between * a GtkFlowBoxChild widget will automatically be inserted between
* the box and the widget. * the box and the widget.
* *
@ -4042,8 +4042,7 @@ gtk_flow_box_insert_css_node (GtkFlowBox *box,
* Inserts the @widget into @box at @position. * Inserts the @widget into @box at @position.
* *
* If a sort function is set, the widget will actually be inserted * If a sort function is set, the widget will actually be inserted
* at the calculated position and this function has the same effect * at the calculated position.
* as gtk_container_add().
* *
* If @position is -1, or larger than the total number of children * If @position is -1, or larger than the total number of children
* in the @box, then the @widget will be appended to the end. * in the @box, then the @widget will be appended to the end.
@ -4239,7 +4238,7 @@ gtk_flow_box_check_model_compat (GtkFlowBox *box)
* If @model is %NULL, @box is left empty. * If @model is %NULL, @box is left empty.
* *
* It is undefined to add or remove widgets directly (for example, with * It is undefined to add or remove widgets directly (for example, with
* gtk_flow_box_insert() or gtk_container_add()) while @box is bound to a * gtk_flow_box_insert()) while @box is bound to a
* model. * model.
* *
* Note that using a model is incompatible with the filtering and sorting * Note that using a model is incompatible with the filtering and sorting

View File

@ -55,7 +55,8 @@
* button in it). * button in it).
* *
* Although a #GtkListBox must have only #GtkListBoxRow children you can * Although a #GtkListBox must have only #GtkListBoxRow children you can
* add any kind of widget to it via gtk_container_add(), and a #GtkListBoxRow * add any kind of widget to it via gtk_list_box_prepend(),
* gtk_list_box_append() and gtk_list_box_insert() and a #GtkListBoxRow
* widget will automatically be inserted between the list and the widget. * widget will automatically be inserted between the list and the widget.
* *
* #GtkListBoxRows can be marked as activatable or selectable. If a row * #GtkListBoxRows can be marked as activatable or selectable. If a row
@ -2574,8 +2575,7 @@ gtk_list_box_size_allocate (GtkWidget *widget,
* @child: the #GtkWidget to add * @child: the #GtkWidget to add
* *
* Prepend a widget to the list. If a sort function is set, the widget will * Prepend a widget to the list. If a sort function is set, the widget will
* actually be inserted at the calculated position and this function has the * actually be inserted at the calculated position.
* same effect of gtk_container_add().
*/ */
void void
gtk_list_box_prepend (GtkListBox *box, gtk_list_box_prepend (GtkListBox *box,
@ -2584,6 +2584,21 @@ gtk_list_box_prepend (GtkListBox *box,
gtk_list_box_insert (box, child, 0); gtk_list_box_insert (box, child, 0);
} }
/**
* gtk_list_box_append:
* @box: a #GtkListBox
* @child: the #GtkWidget to add
*
* Append a widget to the list. If a sort function is set, the widget will
* actually be inserted at the calculated position.
*/
void
gtk_list_box_append (GtkListBox *box,
GtkWidget *child)
{
gtk_list_box_insert (box, child, -1);
}
/** /**
* gtk_list_box_insert: * gtk_list_box_insert:
* @box: a #GtkListBox * @box: a #GtkListBox
@ -2591,8 +2606,7 @@ gtk_list_box_prepend (GtkListBox *box,
* @position: the position to insert @child in * @position: the position to insert @child in
* *
* Insert the @child into the @box at @position. If a sort function is * Insert the @child into the @box at @position. If a sort function is
* set, the widget will actually be inserted at the calculated position and * set, the widget will actually be inserted at the calculated position.
* this function has the same effect of gtk_container_add().
* *
* If @position is -1, or larger than the total number of items in the * If @position is -1, or larger than the total number of items in the
* @box, then the @child will be appended to the end. * @box, then the @child will be appended to the end.
@ -3562,7 +3576,7 @@ gtk_list_box_check_model_compat (GtkListBox *box)
* If @model is %NULL, @box is left empty. * If @model is %NULL, @box is left empty.
* *
* It is undefined to add or remove widgets directly (for example, with * It is undefined to add or remove widgets directly (for example, with
* gtk_list_box_insert() or gtk_container_add()) while @box is bound to a * gtk_list_box_insert()) while @box is bound to a
* model. * model.
* *
* Note that using a model is incompatible with the filtering and sorting * Note that using a model is incompatible with the filtering and sorting

View File

@ -168,6 +168,9 @@ GDK_AVAILABLE_IN_ALL
void gtk_list_box_prepend (GtkListBox *box, void gtk_list_box_prepend (GtkListBox *box,
GtkWidget *child); GtkWidget *child);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
void gtk_list_box_append (GtkListBox *box,
GtkWidget *child);
GDK_AVAILABLE_IN_ALL
void gtk_list_box_insert (GtkListBox *box, void gtk_list_box_insert (GtkListBox *box,
GtkWidget *child, GtkWidget *child,
int position); int position);

View File

@ -420,7 +420,7 @@ gtk_overlay_new (void)
* Adds @widget to @overlay. * Adds @widget to @overlay.
* *
* The widget will be stacked on top of the main widget * The widget will be stacked on top of the main widget
* added with gtk_container_add(). * added with gtk_overlay_set_child().
* *
* The position at which @widget is placed is determined * The position at which @widget is placed is determined
* from its #GtkWidget:halign and #GtkWidget:valign properties. * from its #GtkWidget:halign and #GtkWidget:valign properties.

View File

@ -870,8 +870,7 @@ gtk_popover_init (GtkPopover *popover)
gtk_widget_set_layout_manager (priv->contents_widget, gtk_bin_layout_new ()); gtk_widget_set_layout_manager (priv->contents_widget, gtk_bin_layout_new ());
gtk_widget_set_parent (priv->contents_widget, GTK_WIDGET (popover)); gtk_widget_set_parent (priv->contents_widget, GTK_WIDGET (popover));
gtk_css_node_add_class (gtk_widget_get_css_node (GTK_WIDGET (popover)), gtk_widget_add_css_class (widget, "background");
g_quark_from_static_string (GTK_STYLE_CLASS_BACKGROUND));
add_actions (popover); add_actions (popover);
} }

View File

@ -68,12 +68,12 @@
* Widgets with native scrolling support, i.e. those whose classes implement the * Widgets with native scrolling support, i.e. those whose classes implement the
* #GtkScrollable interface, are added directly. For other types of widget, the * #GtkScrollable interface, are added directly. For other types of widget, the
* class #GtkViewport acts as an adaptor, giving scrollability to other widgets. * class #GtkViewport acts as an adaptor, giving scrollability to other widgets.
* GtkScrolledWindows implementation of gtk_container_add() intelligently * gtk_scrolled_window_set_child() intelligently
* accounts for whether or not the added child is a #GtkScrollable. If it isnt, * accounts for whether or not the added child is a #GtkScrollable. If it isnt,
* #GtkScrolledWindow wraps the child in a #GtkViewport and adds that for you. * #GtkScrolledWindow wraps the child in a #GtkViewport and adds that for you.
* Therefore, you can just add any child widget and not worry about the details. * Therefore, you can just add any child widget and not worry about the details.
* *
* If gtk_container_add() has added a #GtkViewport for you, you can remove * If gtk_scrolled_window_set_child() has added a #GtkViewport for you, you can remove
* both your added child widget from the #GtkViewport, and the #GtkViewport * both your added child widget from the #GtkViewport, and the #GtkViewport
* from the GtkScrolledWindow, like this: * from the GtkScrolledWindow, like this:
* *

View File

@ -1270,7 +1270,7 @@ stack_child_visibility_notify_cb (GObject *obj,
* gtk_stack_add_titled: * gtk_stack_add_titled:
* @stack: a #GtkStack * @stack: a #GtkStack
* @child: the widget to add * @child: the widget to add
* @name: the name for @child * @name: (nullable): the name for @child
* @title: a human-readable title for @child * @title: a human-readable title for @child
* *
* Adds a child to @stack. * Adds a child to @stack.
@ -1282,9 +1282,9 @@ stack_child_visibility_notify_cb (GObject *obj,
*/ */
GtkStackPage * GtkStackPage *
gtk_stack_add_titled (GtkStack *stack, gtk_stack_add_titled (GtkStack *stack,
GtkWidget *child, GtkWidget *child,
const char *name, const char *name,
const char *title) const char *title)
{ {
g_return_val_if_fail (GTK_IS_STACK (stack), NULL); g_return_val_if_fail (GTK_IS_STACK (stack), NULL);
g_return_val_if_fail (GTK_IS_WIDGET (child), NULL); g_return_val_if_fail (GTK_IS_WIDGET (child), NULL);
@ -1296,7 +1296,7 @@ gtk_stack_add_titled (GtkStack *stack,
* gtk_stack_add_named: * gtk_stack_add_named:
* @stack: a #GtkStack * @stack: a #GtkStack
* @child: the widget to add * @child: the widget to add
* @name: the name for @child * @name: (nullable): the name for @child or %NULL
* *
* Adds a child to @stack. * Adds a child to @stack.
* The child is identified by the @name. * The child is identified by the @name.
@ -1305,8 +1305,8 @@ gtk_stack_add_titled (GtkStack *stack,
*/ */
GtkStackPage * GtkStackPage *
gtk_stack_add_named (GtkStack *stack, gtk_stack_add_named (GtkStack *stack,
GtkWidget *child, GtkWidget *child,
const char *name) const char *name)
{ {
g_return_val_if_fail (GTK_IS_STACK (stack), NULL); g_return_val_if_fail (GTK_IS_STACK (stack), NULL);
g_return_val_if_fail (GTK_IS_WIDGET (child), NULL); g_return_val_if_fail (GTK_IS_WIDGET (child), NULL);
@ -1348,14 +1348,17 @@ gtk_stack_add_page (GtkStack *stack,
g_return_if_fail (child_info->widget != NULL); g_return_if_fail (child_info->widget != NULL);
for (l = priv->children; l != NULL; l = l->next) if (child_info->name)
{ {
GtkStackPage *info = l->data; for (l = priv->children; l != NULL; l = l->next)
if (info->name &&
g_strcmp0 (info->name, child_info->name) == 0)
{ {
g_warning ("While adding page: duplicate child name in GtkStack: %s", child_info->name); GtkStackPage *info = l->data;
break; if (info->name &&
g_strcmp0 (info->name, child_info->name) == 0)
{
g_warning ("While adding page: duplicate child name in GtkStack: %s", child_info->name);
break;
}
} }
} }

View File

@ -3107,6 +3107,7 @@ gtk_text_view_set_editable (GtkTextView *text_view,
gtk_accessible_update_property (GTK_ACCESSIBLE (text_view), gtk_accessible_update_property (GTK_ACCESSIBLE (text_view),
GTK_ACCESSIBLE_PROPERTY_READ_ONLY, !setting, GTK_ACCESSIBLE_PROPERTY_READ_ONLY, !setting,
-1); -1);
gtk_text_view_update_emoji_action (text_view);
g_object_notify (G_OBJECT (text_view), "editable"); g_object_notify (G_OBJECT (text_view), "editable");
} }
@ -8531,7 +8532,8 @@ static void
gtk_text_view_update_emoji_action (GtkTextView *text_view) gtk_text_view_update_emoji_action (GtkTextView *text_view)
{ {
gtk_widget_action_set_enabled (GTK_WIDGET (text_view), "misc.insert-emoji", gtk_widget_action_set_enabled (GTK_WIDGET (text_view), "misc.insert-emoji",
(gtk_text_view_get_input_hints (text_view) & GTK_INPUT_HINT_NO_EMOJI) == 0); (gtk_text_view_get_input_hints (text_view) & GTK_INPUT_HINT_NO_EMOJI) == 0 &&
text_view->priv->editable);
} }
static GMenuModel * static GMenuModel *

View File

@ -115,36 +115,86 @@ enum {
NUM_PROPERTIES NUM_PROPERTIES
}; };
static guint toggle_button_signals[LAST_SIGNAL] = { 0 };
static GParamSpec *toggle_button_props[NUM_PROPERTIES] = { NULL, }; static GParamSpec *toggle_button_props[NUM_PROPERTIES] = { NULL, };
static gboolean gtk_toggle_button_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling);
static void gtk_toggle_button_clicked (GtkButton *button);
static void gtk_toggle_button_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_toggle_button_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static guint toggle_button_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE_WITH_CODE (GtkToggleButton, gtk_toggle_button, GTK_TYPE_BUTTON, G_DEFINE_TYPE_WITH_CODE (GtkToggleButton, gtk_toggle_button, GTK_TYPE_BUTTON,
G_ADD_PRIVATE (GtkToggleButton)) G_ADD_PRIVATE (GtkToggleButton))
static void
gtk_toggle_button_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkToggleButton *tb = GTK_TOGGLE_BUTTON (object);
switch (prop_id)
{
case PROP_ACTIVE:
gtk_toggle_button_set_active (tb, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_toggle_button_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkToggleButton *tb = GTK_TOGGLE_BUTTON (object);
GtkToggleButtonPrivate *priv = gtk_toggle_button_get_instance_private (tb);
switch (prop_id)
{
case PROP_ACTIVE:
g_value_set_boolean (value, priv->active);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static gboolean
gtk_toggle_button_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling)
{
/*
* We override the standard implementation in
* gtk_widget_real_mnemonic_activate() in order to focus the widget even
* if there is no mnemonic conflict.
*/
if (gtk_widget_get_can_focus (widget))
gtk_widget_grab_focus (widget);
if (!group_cycling)
gtk_widget_activate (widget);
return TRUE;
}
static void
gtk_toggle_button_clicked (GtkButton *button)
{
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (button);
GtkToggleButtonPrivate *priv = gtk_toggle_button_get_instance_private (toggle_button);
gtk_toggle_button_set_active (toggle_button, !priv->active);
GTK_BUTTON_CLASS (gtk_toggle_button_parent_class)->clicked (button);
}
static void static void
gtk_toggle_button_class_init (GtkToggleButtonClass *class) gtk_toggle_button_class_init (GtkToggleButtonClass *class)
{ {
GObjectClass *gobject_class; GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class; GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
GtkButtonClass *button_class; GtkButtonClass *button_class = GTK_BUTTON_CLASS (class);
gobject_class = G_OBJECT_CLASS (class);
widget_class = (GtkWidgetClass*) class;
button_class = (GtkButtonClass*) class;
gobject_class->set_property = gtk_toggle_button_set_property; gobject_class->set_property = gtk_toggle_button_set_property;
gobject_class->get_property = gtk_toggle_button_get_property; gobject_class->get_property = gtk_toggle_button_get_property;
@ -173,12 +223,12 @@ gtk_toggle_button_class_init (GtkToggleButtonClass *class)
*/ */
toggle_button_signals[TOGGLED] = toggle_button_signals[TOGGLED] =
g_signal_new (I_("toggled"), g_signal_new (I_("toggled"),
G_OBJECT_CLASS_TYPE (gobject_class), G_OBJECT_CLASS_TYPE (gobject_class),
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkToggleButtonClass, toggled), G_STRUCT_OFFSET (GtkToggleButtonClass, toggled),
NULL, NULL, NULL, NULL,
NULL, NULL,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
gtk_widget_class_set_css_name (widget_class, I_("button")); gtk_widget_class_set_css_name (widget_class, I_("button"));
} }
@ -201,7 +251,7 @@ gtk_toggle_button_init (GtkToggleButton *toggle_button)
* *
* Returns: a new toggle button. * Returns: a new toggle button.
*/ */
GtkWidget* GtkWidget *
gtk_toggle_button_new (void) gtk_toggle_button_new (void)
{ {
return g_object_new (GTK_TYPE_TOGGLE_BUTTON, NULL); return g_object_new (GTK_TYPE_TOGGLE_BUTTON, NULL);
@ -215,7 +265,7 @@ gtk_toggle_button_new (void)
* *
* Returns: a new toggle button. * Returns: a new toggle button.
*/ */
GtkWidget* GtkWidget *
gtk_toggle_button_new_with_label (const char *label) gtk_toggle_button_new_with_label (const char *label)
{ {
return g_object_new (GTK_TYPE_TOGGLE_BUTTON, "label", label, NULL); return g_object_new (GTK_TYPE_TOGGLE_BUTTON, "label", label, NULL);
@ -232,54 +282,13 @@ gtk_toggle_button_new_with_label (const char *label)
* *
* Returns: a new #GtkToggleButton * Returns: a new #GtkToggleButton
*/ */
GtkWidget* GtkWidget *
gtk_toggle_button_new_with_mnemonic (const char *label) gtk_toggle_button_new_with_mnemonic (const char *label)
{ {
return g_object_new (GTK_TYPE_TOGGLE_BUTTON, return g_object_new (GTK_TYPE_TOGGLE_BUTTON,
"label", label, "label", label,
"use-underline", TRUE, "use-underline", TRUE,
NULL); NULL);
}
static void
gtk_toggle_button_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkToggleButton *tb;
tb = GTK_TOGGLE_BUTTON (object);
switch (prop_id)
{
case PROP_ACTIVE:
gtk_toggle_button_set_active (tb, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_toggle_button_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkToggleButton *tb = GTK_TOGGLE_BUTTON (object);
GtkToggleButtonPrivate *priv = gtk_toggle_button_get_instance_private (tb);
switch (prop_id)
{
case PROP_ACTIVE:
g_value_set_boolean (value, priv->active);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
} }
/** /**
@ -295,7 +304,7 @@ gtk_toggle_button_get_property (GObject *object,
*/ */
void void
gtk_toggle_button_set_active (GtkToggleButton *toggle_button, gtk_toggle_button_set_active (GtkToggleButton *toggle_button,
gboolean is_active) gboolean is_active)
{ {
GtkToggleButtonPrivate *priv = gtk_toggle_button_get_instance_private (toggle_button); GtkToggleButtonPrivate *priv = gtk_toggle_button_get_instance_private (toggle_button);
@ -356,34 +365,3 @@ gtk_toggle_button_toggled (GtkToggleButton *toggle_button)
g_signal_emit (toggle_button, toggle_button_signals[TOGGLED], 0); g_signal_emit (toggle_button, toggle_button_signals[TOGGLED], 0);
} }
static gboolean
gtk_toggle_button_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling)
{
/*
* We override the standard implementation in
* gtk_widget_real_mnemonic_activate() in order to focus the widget even
* if there is no mnemonic conflict.
*/
if (gtk_widget_get_can_focus (widget))
gtk_widget_grab_focus (widget);
if (!group_cycling)
gtk_widget_activate (widget);
return TRUE;
}
static void
gtk_toggle_button_clicked (GtkButton *button)
{
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (button);
GtkToggleButtonPrivate *priv = gtk_toggle_button_get_instance_private (toggle_button);
gtk_toggle_button_set_active (toggle_button, !priv->active);
if (GTK_BUTTON_CLASS (gtk_toggle_button_parent_class)->clicked)
GTK_BUTTON_CLASS (gtk_toggle_button_parent_class)->clicked (button);
}

View File

@ -49,14 +49,6 @@
* capabilities. Use GtkViewport to scroll child widgets such as * capabilities. Use GtkViewport to scroll child widgets such as
* #GtkGrid, #GtkBox, and so on. * #GtkGrid, #GtkBox, and so on.
* *
* If a widget has native scrolling abilities, such as #GtkTextView,
* #GtkTreeView or #GtkIconView, it can be added to a #GtkScrolledWindow
* with gtk_container_add(). If a widget does not, you must first add the
* widget to a #GtkViewport, then add the viewport to the scrolled window.
* gtk_container_add() does this automatically if a child that does not
* implement #GtkScrollable is added to a #GtkScrolledWindow, so you can
* ignore the presence of the viewport.
*
* The GtkViewport will start scrolling content only if allocated less * The GtkViewport will start scrolling content only if allocated less
* than the child widgets minimum size in a given orientation. * than the child widgets minimum size in a given orientation.
* *

View File

@ -132,8 +132,8 @@
* *
* |[<!-- language="plain" --> * |[<!-- language="plain" -->
* window.background * window.background
* <titlebar child>.titlebar [.default-decoration] * <child>
* <child> * <titlebar child>.titlebar [.default-decoration]
* ]| * ]|
* *
* GtkWindow has a main CSS node with name window and style class .background. * GtkWindow has a main CSS node with name window and style class .background.
@ -2824,7 +2824,7 @@ gtk_window_set_titlebar (GtkWindow *window,
gtk_window_enable_csd (window); gtk_window_enable_csd (window);
priv->title_box = titlebar; priv->title_box = titlebar;
gtk_widget_insert_after (priv->title_box, widget, NULL); gtk_widget_insert_before (priv->title_box, widget, NULL);
gtk_widget_add_css_class (titlebar, GTK_STYLE_CLASS_TITLEBAR); gtk_widget_add_css_class (titlebar, GTK_STYLE_CLASS_TITLEBAR);
@ -4308,7 +4308,7 @@ gtk_window_realize (GtkWidget *widget)
gtk_widget_add_css_class (priv->titlebar, GTK_STYLE_CLASS_TITLEBAR); gtk_widget_add_css_class (priv->titlebar, GTK_STYLE_CLASS_TITLEBAR);
gtk_widget_add_css_class (priv->titlebar, "default-decoration"); gtk_widget_add_css_class (priv->titlebar, "default-decoration");
gtk_widget_insert_after (priv->titlebar, widget, NULL); gtk_widget_insert_before (priv->titlebar, widget, NULL);
priv->title_box = priv->titlebar; priv->title_box = priv->titlebar;
} }
@ -7084,7 +7084,7 @@ gtk_window_set_child (GtkWindow *window,
if (child) if (child)
{ {
priv->child = child; priv->child = child;
gtk_widget_set_parent (child, GTK_WIDGET (window)); gtk_widget_insert_before (child, GTK_WIDGET (window), priv->title_box);
} }
g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_CHILD]); g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_CHILD]);

View File

@ -390,7 +390,8 @@ gtk_inspector_a11y_set_object (GtkInspectorA11y *sl,
GtkWidget *stack; GtkWidget *stack;
GtkStackPage *page; GtkStackPage *page;
GtkATContext *context; GtkATContext *context;
if (sl->object)
if (sl->object && GTK_IS_ACCESSIBLE (sl->object))
{ {
context = gtk_accessible_get_at_context (GTK_ACCESSIBLE (sl->object)); context = gtk_accessible_get_at_context (GTK_ACCESSIBLE (sl->object));
g_signal_handlers_disconnect_by_func (context, refresh_all, sl); g_signal_handlers_disconnect_by_func (context, refresh_all, sl);
@ -426,7 +427,7 @@ dispose (GObject *o)
{ {
GtkInspectorA11y *sl = GTK_INSPECTOR_A11Y (o); GtkInspectorA11y *sl = GTK_INSPECTOR_A11Y (o);
if (sl->object) if (sl->object && GTK_IS_ACCESSIBLE (sl->object))
{ {
GtkATContext *context; GtkATContext *context;

View File

@ -919,9 +919,15 @@ update_go_buttons (GtkInspectorWindow *iw)
switch (kind) switch (kind)
{ {
case CHILD_KIND_WIDGET: case CHILD_KIND_WIDGET:
update_go_button (iw->go_down_button, gtk_widget_get_first_child (GTK_WIDGET (object)) != NULL, "First child"); update_go_button (iw->go_down_button,
update_go_button (iw->go_previous_button, gtk_widget_get_prev_sibling (GTK_WIDGET (object)) != NULL, "Previous sibling"); GTK_IS_WIDGET (object) &&gtk_widget_get_first_child (GTK_WIDGET (object)) != NULL,
update_go_button (iw->go_next_button, gtk_widget_get_next_sibling (GTK_WIDGET (object)) != NULL, "Next sibling"); "First child");
update_go_button (iw->go_previous_button,
GTK_IS_WIDGET (object) && gtk_widget_get_prev_sibling (GTK_WIDGET (object)) != NULL,
"Previous sibling");
update_go_button (iw->go_next_button,
GTK_IS_WIDGET (object) && gtk_widget_get_next_sibling (GTK_WIDGET (object)) != NULL,
"Next sibling");
gtk_widget_hide (iw->list_position_label); gtk_widget_hide (iw->list_position_label);
break; break;
case CHILD_KIND_LISTITEM: case CHILD_KIND_LISTITEM:

View File

@ -1738,6 +1738,10 @@ popover.background {
box-shadow: 0 1px 2px transparentize(black, 0.7); box-shadow: 0 1px 2px transparentize(black, 0.7);
} }
&:backdrop {
background-color: transparent;
}
> contents { > contents {
padding: 8px; padding: 8px;
border-radius: $popover_radius; border-radius: $popover_radius;

View File

@ -1,4 +1,8 @@
window.background.csd:dir(ltr) window.background.csd:dir(ltr)
stack:dir(ltr)
box.horizontal:dir(ltr)
box.horizontal:dir(ltr)
box.horizontal:dir(ltr)
headerbar.titlebar:dir(ltr) headerbar.titlebar:dir(ltr)
windowhandle:dir(ltr) windowhandle:dir(ltr)
box:dir(ltr) box:dir(ltr)
@ -15,7 +19,3 @@ window.background.csd:dir(ltr)
button.text-button.toggle:dir(ltr) button.text-button.toggle:dir(ltr)
label:dir(ltr) label:dir(ltr)
box.end.horizontal:dir(ltr) box.end.horizontal:dir(ltr)
stack:dir(ltr)
box.horizontal:dir(ltr)
box.horizontal:dir(ltr)
box.horizontal:dir(ltr)