Merge branch 'kill-buttonbox' into 'master'

Drop GtkButtonBox

See merge request GNOME/gtk!554
This commit is contained in:
Matthias Clasen 2019-02-05 13:06:09 +00:00
commit 3489ed087d
34 changed files with 33 additions and 1765 deletions

View File

@ -1,127 +0,0 @@
/* Button Boxes
*
* The Button Box widgets are used to arrange buttons with padding.
*/
#include <glib/gi18n.h>
#include <gtk/gtk.h>
static GtkWidget *
create_bbox (gint horizontal,
char *title,
gint spacing,
gint layout)
{
GtkWidget *frame;
GtkWidget *bbox;
GtkWidget *button;
frame = gtk_frame_new (title);
if (horizontal)
bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
else
bbox = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
g_object_set (bbox, "margin", 5, NULL);
gtk_container_add (GTK_CONTAINER (frame), bbox);
gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), layout);
gtk_box_set_spacing (GTK_BOX (bbox), spacing);
button = gtk_button_new_with_label (_("OK"));
gtk_container_add (GTK_CONTAINER (bbox), button);
button = gtk_button_new_with_label (_("Cancel"));
gtk_container_add (GTK_CONTAINER (bbox), button);
button = gtk_button_new_with_label (_("Help"));
gtk_container_add (GTK_CONTAINER (bbox), button);
return frame;
}
GtkWidget *
do_button_box (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
GtkWidget *main_vbox;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *frame_horz;
GtkWidget *frame_vert;
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Button Boxes");
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&window);
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
g_object_set (main_vbox, "margin", 10, NULL);
gtk_container_add (GTK_CONTAINER (window), main_vbox);
frame_horz = gtk_frame_new ("Horizontal Button Boxes");
gtk_widget_set_margin_top (frame_horz, 10);
gtk_widget_set_margin_bottom (frame_horz, 10);
gtk_container_add (GTK_CONTAINER (main_vbox), frame_horz);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
g_object_set (vbox, "margin", 10, NULL);
gtk_container_add (GTK_CONTAINER (frame_horz), vbox);
gtk_container_add (GTK_CONTAINER (vbox),
create_bbox (TRUE, "Spread", 40, GTK_BUTTONBOX_SPREAD));
gtk_container_add (GTK_CONTAINER (vbox),
create_bbox (TRUE, "Edge", 40, GTK_BUTTONBOX_EDGE));
gtk_container_add (GTK_CONTAINER (vbox),
create_bbox (TRUE, "Start", 40, GTK_BUTTONBOX_START));
gtk_container_add (GTK_CONTAINER (vbox),
create_bbox (TRUE, "End", 40, GTK_BUTTONBOX_END));
gtk_container_add (GTK_CONTAINER (vbox),
create_bbox (TRUE, "Center", 40, GTK_BUTTONBOX_CENTER));
gtk_container_add (GTK_CONTAINER (vbox),
create_bbox (TRUE, "Expand", 0, GTK_BUTTONBOX_EXPAND));
frame_vert = gtk_frame_new ("Vertical Button Boxes");
gtk_container_add (GTK_CONTAINER (main_vbox), frame_vert);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
g_object_set (hbox, "margin", 10, NULL);
gtk_container_add (GTK_CONTAINER (frame_vert), hbox);
gtk_container_add (GTK_CONTAINER (hbox),
create_bbox (FALSE, "Spread", 10, GTK_BUTTONBOX_SPREAD));
gtk_container_add (GTK_CONTAINER (hbox),
create_bbox (FALSE, "Edge", 10, GTK_BUTTONBOX_EDGE));
gtk_container_add (GTK_CONTAINER (hbox),
create_bbox (FALSE, "Start", 10, GTK_BUTTONBOX_START));
gtk_container_add (GTK_CONTAINER (hbox),
create_bbox (FALSE, "End", 10, GTK_BUTTONBOX_END));
gtk_container_add (GTK_CONTAINER (hbox),
create_bbox (FALSE, "Center", 10, GTK_BUTTONBOX_CENTER));
gtk_container_add (GTK_CONTAINER (hbox),
create_bbox (FALSE, "Expand", 0, GTK_BUTTONBOX_EXPAND));
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
return window;
}

View File

@ -143,7 +143,6 @@
<file>application_demo.c</file>
<file>assistant.c</file>
<file>builder.c</file>
<file>button_box.c</file>
<file>changedisplay.c</file>
<file>clipboard.c</file>
<file>colorsel.c</file>

View File

@ -4,7 +4,6 @@ demos = files([
'application_demo.c',
'assistant.c',
'builder.c',
'button_box.c',
'changedisplay.c',
'clipboard.c',
'colorsel.c',

View File

@ -11,7 +11,6 @@ private_headers = [
'gtkapplicationprivate.h',
'gtkbindingsprivate.h',
'gtkbitmaskprivate.h',
'gtkboxprivate.h',
'gtkbuilderprivate.h',
'gtkbuttonprivate.h',
'gtkcellareaboxcontextprivate.h',

View File

@ -13,19 +13,19 @@ activate (GtkApplication *app,
{
GtkWidget *window;
GtkWidget *button;
GtkWidget *button_box;
GtkWidget *box;
window = gtk_application_window_new (app);
gtk_window_set_title (GTK_WINDOW (window), "Window");
gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
button_box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
gtk_container_add (GTK_CONTAINER (window), button_box);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_add (GTK_CONTAINER (window), box);
button = gtk_button_new_with_label ("Hello World");
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
gtk_container_add (GTK_CONTAINER (button_box), button);
gtk_container_add (GTK_CONTAINER (box), button);
gtk_widget_show (window);
}

View File

@ -36,7 +36,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkBox, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkBuildable, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkBuilder, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkButton, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkButtonBox, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkCalendar, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkCellArea, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkCellAreaBox, g_object_unref)

View File

@ -44,7 +44,6 @@
#include <gtk/gtkapplicationwindow.h>
#include <gtk/gtkaspectframe.h>
#include <gtk/gtkassistant.h>
#include <gtk/gtkbbox.h>
#include <gtk/gtkbin.h>
#include <gtk/gtkbindings.h>
#include <gtk/gtkborder.h>

View File

@ -34,7 +34,6 @@
#include "gtkaboutdialog.h"
#include "gtkbutton.h"
#include "gtkbbox.h"
#include "gtkdialog.h"
#include "gtkgrid.h"
#include "gtkbox.h"
@ -717,22 +716,12 @@ apply_use_header_bar (GtkAboutDialog *about)
g_signal_connect (priv->credits_button, "toggled", G_CALLBACK (toggle_credits), about);
gtk_dialog_add_action_widget (GTK_DIALOG (about), priv->credits_button, GTK_RESPONSE_NONE);
gtk_container_child_set (GTK_CONTAINER (gtk_widget_get_parent (priv->credits_button)),
priv->credits_button,
"secondary", TRUE,
NULL);
priv->license_button = gtk_toggle_button_new_with_mnemonic (_("_License"));
g_object_bind_property (priv->license_page, "visible",
priv->license_button, "visible", G_BINDING_SYNC_CREATE);
g_signal_connect (priv->license_button, "toggled", G_CALLBACK (toggle_license), about);
gtk_dialog_add_action_widget (GTK_DIALOG (about), priv->license_button, GTK_RESPONSE_NONE);
gtk_container_child_set (GTK_CONTAINER (gtk_widget_get_parent (priv->license_button)),
priv->license_button,
"secondary", TRUE,
NULL);
gtk_dialog_add_button (GTK_DIALOG (about), _("_Close"), GTK_RESPONSE_DELETE_EVENT);
}
}

View File

@ -48,7 +48,6 @@
#include "gtkmessagedialog.h"
#include "gtksettings.h"
#include "gtklabel.h"
#include "gtkbbox.h"
#include "gtkbutton.h"
#include "gtkentry.h"
#include "gtktogglebutton.h"

File diff suppressed because it is too large Load Diff

View File

@ -1,130 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GTK_BUTTON_BOX_H__
#define __GTK_BUTTON_BOX_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/gtkbox.h>
G_BEGIN_DECLS
#define GTK_TYPE_BUTTON_BOX (gtk_button_box_get_type ())
#define GTK_BUTTON_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_BUTTON_BOX, GtkButtonBox))
#define GTK_BUTTON_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_BUTTON_BOX, GtkButtonBoxClass))
#define GTK_IS_BUTTON_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_BUTTON_BOX))
#define GTK_IS_BUTTON_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_BUTTON_BOX))
#define GTK_BUTTON_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_BUTTON_BOX, GtkButtonBoxClass))
typedef struct _GtkButtonBox GtkButtonBox;
typedef struct _GtkButtonBoxPrivate GtkButtonBoxPrivate;
typedef struct _GtkButtonBoxClass GtkButtonBoxClass;
struct _GtkButtonBox
{
GtkBox box;
/*< private >*/
GtkButtonBoxPrivate *priv;
};
/**
* GtkButtonBoxClass:
* @parent_class: The parent class.
*/
struct _GtkButtonBoxClass
{
GtkBoxClass parent_class;
/*< private >*/
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
/**
* GtkButtonBoxStyle:
* @GTK_BUTTONBOX_SPREAD: Buttons are evenly spread across the box.
* @GTK_BUTTONBOX_EDGE: Buttons are placed at the edges of the box.
* @GTK_BUTTONBOX_START: Buttons are grouped towards the start of the box,
* (on the left for a HBox, or the top for a VBox).
* @GTK_BUTTONBOX_END: Buttons are grouped towards the end of the box,
* (on the right for a HBox, or the bottom for a VBox).
* @GTK_BUTTONBOX_CENTER: Buttons are centered in the box
* @GTK_BUTTONBOX_EXPAND: Buttons expand to fill the box. This entails giving
* buttons a "linked" appearance, making button sizes homogeneous, and
* setting spacing to 0 (same as calling gtk_box_set_homogeneous() and
* gtk_box_set_spacing() manually)
*
* Used to dictate the style that a #GtkButtonBox uses to layout the buttons it
* contains.
*/
typedef enum
{
GTK_BUTTONBOX_SPREAD = 1,
GTK_BUTTONBOX_EDGE,
GTK_BUTTONBOX_START,
GTK_BUTTONBOX_END,
GTK_BUTTONBOX_CENTER,
GTK_BUTTONBOX_EXPAND
} GtkButtonBoxStyle;
GDK_AVAILABLE_IN_ALL
GType gtk_button_box_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkWidget * gtk_button_box_new (GtkOrientation orientation);
GDK_AVAILABLE_IN_ALL
GtkButtonBoxStyle gtk_button_box_get_layout (GtkButtonBox *widget);
GDK_AVAILABLE_IN_ALL
void gtk_button_box_set_layout (GtkButtonBox *widget,
GtkButtonBoxStyle layout_style);
GDK_AVAILABLE_IN_ALL
gboolean gtk_button_box_get_child_secondary (GtkButtonBox *widget,
GtkWidget *child);
GDK_AVAILABLE_IN_ALL
void gtk_button_box_set_child_secondary (GtkButtonBox *widget,
GtkWidget *child,
gboolean is_secondary);
GDK_AVAILABLE_IN_ALL
gboolean gtk_button_box_get_child_non_homogeneous (GtkButtonBox *widget,
GtkWidget *child);
GDK_AVAILABLE_IN_ALL
void gtk_button_box_set_child_non_homogeneous (GtkButtonBox *widget,
GtkWidget *child,
gboolean non_homogeneous);
G_END_DECLS
#endif /* __GTK_BUTTON_BOX_H__ */

View File

@ -57,7 +57,6 @@
#include "config.h"
#include "gtkbox.h"
#include "gtkboxprivate.h"
#include "gtkcsspositionvalueprivate.h"
#include "gtkintl.h"
#include "gtkorientable.h"
@ -1081,22 +1080,6 @@ gtk_box_forall (GtkContainer *container,
}
GList *
_gtk_box_get_children (GtkBox *box)
{
GtkWidget *p;
GList *retval = NULL;
g_return_val_if_fail (GTK_IS_BOX (box), NULL);
for (p = _gtk_widget_get_first_child (GTK_WIDGET (box));
p != NULL;
p = _gtk_widget_get_next_sibling (p))
retval = g_list_prepend (retval, p);
return g_list_reverse (retval);
}
/**
* gtk_box_insert_child_after:
* @box: a #GtkBox

View File

@ -1,30 +0,0 @@
/* GTK - The GIMP Toolkit
*
* Copyright (C) 2011 Javier Jardón
*
* 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
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_BOX_PRIVATE_H__
#define __GTK_BOX_PRIVATE_H__
#include "gtkbox.h"
G_BEGIN_DECLS
GList *_gtk_box_get_children (GtkBox *box);
G_END_DECLS
#endif /* __GTK_BOX_PRIVATE_H__ */

View File

@ -171,7 +171,7 @@
* <child internal-child="vbox">
* <object class="GtkBox" id="vbox1">
* <child internal-child="action_area">
* <object class="GtkButtonBox" id="hbuttonbox1">
* <object class="GtkBox" id="hbuttonbox1">
* <child>
* <object class="GtkButton" id="ok_button">
* <property name="label">gtk-ok</property>

View File

@ -31,11 +31,9 @@
#include "gtkdialog.h"
#include "gtkdialogprivate.h"
#include "gtkheaderbar.h"
#include "gtkbbox.h"
#include "gtklabel.h"
#include "gtkmarshalers.h"
#include "gtkbox.h"
#include "gtkboxprivate.h"
#include "gtkcontainerprivate.h"
#include "gtkmain.h"
#include "gtkintl.h"
@ -389,9 +387,6 @@ apply_response_for_action_area (GtkDialog *dialog,
GtkDialogPrivate *priv = gtk_dialog_get_instance_private (dialog);
g_assert (gtk_widget_get_parent (child) == priv->action_area);
if (response_id == GTK_RESPONSE_HELP)
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (priv->action_area), child, TRUE);
}
static void

View File

@ -346,8 +346,7 @@ typedef enum
* @GTK_PACK_START: The child is packed into the start of the box
* @GTK_PACK_END: The child is packed into the end of the box
*
* Represents the packing location #GtkBox children. (See: #GtkVBox,
* #GtkHBox, and #GtkButtonBox).
* Represents the packing location #GtkBox children
*/
typedef enum
{

View File

@ -35,7 +35,6 @@
#include "gtkaccessible.h"
#include "gtkbuildable.h"
#include "gtkbuilderprivate.h"
#include "gtkbbox.h"
#include "gtkbox.h"
#include "gtklabel.h"
#include "gtkbutton.h"
@ -510,9 +509,6 @@ gtk_info_bar_add_action_widget (GtkInfoBar *info_bar,
g_warning ("Only 'activatable' widgets can be packed into the action area of a GtkInfoBar");
gtk_container_add (GTK_CONTAINER (priv->action_area), child);
if (response_id == GTK_RESPONSE_HELP)
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (priv->action_area),
child, TRUE);
}
/**
@ -975,10 +971,6 @@ gtk_info_bar_buildable_custom_finished (GtkBuildable *buildable,
G_OBJECT (info_bar));
g_signal_connect_closure_by_id (object, signal_id, 0, closure, FALSE);
}
if (ad->response_id == GTK_RESPONSE_HELP)
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (priv->action_area),
GTK_WIDGET (object), TRUE);
}
g_slist_free_full (data->items, action_widget_info_free);

View File

@ -33,7 +33,6 @@
#include "gtkbuildable.h"
#include "gtklabel.h"
#include "gtkbox.h"
#include "gtkbbox.h"
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtktypebuiltins.h"
@ -281,7 +280,8 @@ gtk_message_dialog_init (GtkMessageDialog *dialog)
gtk_widget_init_template (GTK_WIDGET (dialog));
action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
gtk_button_box_set_layout (GTK_BUTTON_BOX (action_area), GTK_BUTTONBOX_EXPAND);
gtk_widget_set_halign (action_area, GTK_ALIGN_FILL);
gtk_box_set_homogeneous (GTK_BOX (action_area), TRUE);
settings = gtk_widget_get_settings (GTK_WIDGET (dialog));
g_object_get (settings, "gtk-keynav-use-caret", &use_caret, NULL);

View File

@ -167,7 +167,6 @@ gtk_public_sources = files([
'gtkapplicationwindow.c',
'gtkaspectframe.c',
'gtkassistant.c',
'gtkbbox.c',
'gtkbin.c',
'gtkbindings.c',
'gtkborder.c',
@ -417,7 +416,6 @@ gtk_public_headers = files([
'gtkapplicationwindow.h',
'gtkaspectframe.h',
'gtkassistant.h',
'gtkbbox.h',
'gtkbin.h',
'gtkbindings.h',
'gtkborder.h',

View File

@ -19,8 +19,7 @@
</object>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="layout-style">end</property>
<object class="GtkBox" id="dialog-action_area1">
<property name="hexpand">1</property>
<property name="halign">end</property>
</object>

View File

@ -29,9 +29,9 @@
<class name="dialog-action-box"/>
</style>
<child>
<object class="GtkButtonBox" id="action_area">
<property name="layout-style">end</property>
<object class="GtkBox" id="action_area">
<property name="hexpand">1</property>
<property name="halign">end</property>
<style>
<class name="dialog-action-area"/>
</style>

View File

@ -10,9 +10,8 @@
<object class="GtkBox">
<property name="orientation">vertical</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<object class="GtkBox" id="dialog-action_area1">
<property name="margin">6</property>
<property name="layout-style">end</property>
<property name="hexpand">1</property>
<property name="halign">end</property>
</object>

View File

@ -15,10 +15,10 @@
</object>
</child>
<child>
<object class="GtkButtonBox" id="action_area">
<object class="GtkBox" id="action_area">
<property name="spacing">6</property>
<property name="margin">6</property>
<property name="layout-style">end</property>
<property name="halign">end</property>
</object>
</child>
<child>

View File

@ -221,7 +221,7 @@ main (int argc, char *argv[])
gtk_container_add (GTK_CONTAINER (scrolled), extra_hbox);
gtk_widget_show (extra_hbox);
bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
bbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_spacing (GTK_BOX (bbox), 6);
gtk_container_add (GTK_CONTAINER (box), bbox);
gtk_widget_show (bbox);

View File

@ -18,7 +18,6 @@ gtk_tests = [
['testappchooserbutton'],
['testassistant'],
['testbaseline'],
['testbbox'],
['testbox'],
['testboxcss'],
['testbuttons'],

View File

@ -329,7 +329,7 @@ main (int argc,
for (j = 0; j < 3; j++)
{
hbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_add (GTK_CONTAINER (vbox), hbox);
gtk_box_set_baseline_position (GTK_BOX (hbox), j);

View File

@ -1,173 +0,0 @@
/*
* Copyright (C) 2006 Nokia Corporation.
* Author: Xan Lopez <xan.lopez@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* 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
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <gtk/gtk.h>
#define N_BUTTONS 3
GtkWidget *bbox = NULL;
GtkWidget *hbbox = NULL, *vbbox = NULL;
static const char* styles[] = { "GTK_BUTTONBOX_SPREAD",
"GTK_BUTTONBOX_EDGE",
"GTK_BUTTONBOX_START",
"GTK_BUTTONBOX_END",
"GTK_BUTTONBOX_CENTER",
"GTK_BUTTONBOX_EXPAND",
NULL};
static const char* types[] = { "GtkHButtonBox",
"GtkVButtonBox",
NULL};
static void
populate_combo_with (GtkComboBoxText *combo, const char** elements)
{
int i;
for (i = 0; elements[i] != NULL; i++) {
gtk_combo_box_text_append_text (combo, elements[i]);
}
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
}
static void
combo_changed_cb (GtkComboBoxText *combo,
gpointer user_data)
{
gint active = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox),
(GtkButtonBoxStyle) (active + 1));
}
static void
reparent_widget (GtkWidget *widget,
GtkWidget *old_parent,
GtkWidget *new_parent)
{
g_object_ref (widget);
gtk_container_remove (GTK_CONTAINER (old_parent), widget);
gtk_container_add (GTK_CONTAINER (new_parent), widget);
g_object_unref (widget);
}
static void
combo_types_changed_cb (GtkComboBoxText *combo,
GtkWidget **buttons)
{
int i;
GtkWidget *old_parent, *new_parent;
GtkButtonBoxStyle style;
gint active = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
if (active == GTK_ORIENTATION_HORIZONTAL) {
old_parent = vbbox;
new_parent = hbbox;
} else {
old_parent = hbbox;
new_parent = vbbox;
}
bbox = new_parent;
for (i = 0; i < N_BUTTONS; i++) {
reparent_widget (buttons[i], old_parent, new_parent);
}
gtk_widget_hide (old_parent);
style = gtk_button_box_get_layout (GTK_BUTTON_BOX (old_parent));
gtk_button_box_set_layout (GTK_BUTTON_BOX (new_parent), style);
gtk_widget_show (new_parent);
}
static void
option_cb (GtkToggleButton *option,
GtkWidget *button)
{
gboolean active = gtk_toggle_button_get_active (option);
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (bbox),
button, active);
}
static const char* strings[] = { "Ok", "Cancel", "Help" };
int
main (int argc,
char **argv)
{
GtkWidget *window, *buttons[N_BUTTONS];
GtkWidget *vbox, *hbox, *combo_styles, *combo_types, *option;
int i;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_container_add (GTK_CONTAINER (window), vbox);
/* GtkHButtonBox */
hbbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
gtk_container_add (GTK_CONTAINER (vbox), hbbox);
for (i = 0; i < N_BUTTONS; i++) {
buttons[i] = gtk_button_new_with_label (strings[i]);
gtk_container_add (GTK_CONTAINER (hbbox), buttons[i]);
}
bbox = hbbox;
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbbox), GTK_BUTTONBOX_SPREAD);
/* GtkVButtonBox */
vbbox = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
gtk_container_add (GTK_CONTAINER (vbox), vbbox);
/* Options */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_add (GTK_CONTAINER (vbox), hbox);
combo_types = gtk_combo_box_text_new ();
populate_combo_with (GTK_COMBO_BOX_TEXT (combo_types), types);
g_signal_connect (G_OBJECT (combo_types), "changed", G_CALLBACK (combo_types_changed_cb), buttons);
gtk_container_add (GTK_CONTAINER (hbox), combo_types);
combo_styles = gtk_combo_box_text_new ();
populate_combo_with (GTK_COMBO_BOX_TEXT (combo_styles), styles);
g_signal_connect (G_OBJECT (combo_styles), "changed", G_CALLBACK (combo_changed_cb), NULL);
gtk_container_add (GTK_CONTAINER (hbox), combo_styles);
option = gtk_check_button_new_with_label ("Help is secondary");
g_signal_connect (G_OBJECT (option), "toggled", G_CALLBACK (option_cb), buttons[N_BUTTONS - 1]);
gtk_container_add (GTK_CONTAINER (hbox), option);
gtk_widget_show (window);
gtk_widget_hide (vbbox);
gtk_main ();
return 0;
}

View File

@ -663,8 +663,8 @@ create_calendar(void)
* Glue everything together
*/
bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
bbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_halign (bbox, GTK_ALIGN_END);
button = gtk_button_new_with_label ("Close");
g_signal_connect (button, "clicked", G_CALLBACK (gtk_main_quit), NULL);

View File

@ -706,7 +706,7 @@ main (int argc, char **argv)
control_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
vbbox = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
vbbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (control_window), vbbox);
button = gtk_button_new_with_mnemonic ("_Select all");

View File

@ -597,122 +597,6 @@ create_radio_buttons (GtkWidget *widget)
gtk_widget_destroy (window);
}
/*
* GtkButtonBox
*/
static GtkWidget *
create_bbox (gint horizontal,
char* title,
gint spacing,
gint child_w,
gint child_h,
gint layout)
{
GtkWidget *frame;
GtkWidget *bbox;
GtkWidget *button;
frame = gtk_frame_new (title);
if (horizontal)
bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
else
bbox = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
gtk_container_add (GTK_CONTAINER (frame), bbox);
gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), layout);
gtk_box_set_spacing (GTK_BOX (bbox), spacing);
button = gtk_button_new_with_label ("OK");
gtk_container_add (GTK_CONTAINER (bbox), button);
button = gtk_button_new_with_label ("Cancel");
gtk_container_add (GTK_CONTAINER (bbox), button);
button = gtk_button_new_with_label ("Help");
gtk_container_add (GTK_CONTAINER (bbox), button);
return frame;
}
static void
create_button_box (GtkWidget *widget)
{
static GtkWidget* window = NULL;
GtkWidget *main_vbox;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *frame_horz;
GtkWidget *frame_vert;
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (widget));
gtk_window_set_title (GTK_WINDOW (window), "Button Boxes");
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&window);
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), main_vbox);
frame_horz = gtk_frame_new ("Horizontal Button Boxes");
gtk_widget_set_margin_top (frame_horz, 10);
gtk_widget_set_margin_bottom (frame_horz, 10);
gtk_container_add (GTK_CONTAINER (main_vbox), frame_horz);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (frame_horz), vbox);
gtk_container_add (GTK_CONTAINER (vbox),
create_bbox (TRUE, "Spread", 40, 85, 20, GTK_BUTTONBOX_SPREAD));
gtk_container_add (GTK_CONTAINER (vbox),
create_bbox (TRUE, "Edge", 40, 85, 20, GTK_BUTTONBOX_EDGE));
gtk_container_add (GTK_CONTAINER (vbox),
create_bbox (TRUE, "Start", 40, 85, 20, GTK_BUTTONBOX_START));
gtk_container_add (GTK_CONTAINER (vbox),
create_bbox (TRUE, "End", 40, 85, 20, GTK_BUTTONBOX_END));
gtk_container_add (GTK_CONTAINER (vbox),
create_bbox (TRUE, "Center", 40, 85, 20, GTK_BUTTONBOX_CENTER));
frame_vert = gtk_frame_new ("Vertical Button Boxes");
gtk_widget_set_margin_top (frame_vert, 10);
gtk_widget_set_margin_bottom (frame_vert, 10);
gtk_container_add (GTK_CONTAINER (main_vbox), frame_vert);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_add (GTK_CONTAINER (frame_vert), hbox);
gtk_container_add (GTK_CONTAINER (hbox),
create_bbox (FALSE, "Spread", 30, 85, 20, GTK_BUTTONBOX_SPREAD));
gtk_container_add (GTK_CONTAINER (hbox),
create_bbox (FALSE, "Edge", 30, 85, 20, GTK_BUTTONBOX_EDGE));
gtk_container_add (GTK_CONTAINER (hbox),
create_bbox (FALSE, "Start", 30, 85, 20, GTK_BUTTONBOX_START));
gtk_container_add (GTK_CONTAINER (hbox),
create_bbox (FALSE, "End", 30, 85, 20, GTK_BUTTONBOX_END));
gtk_container_add (GTK_CONTAINER (hbox),
create_bbox (FALSE, "Center", 30, 85, 20, GTK_BUTTONBOX_CENTER));
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
}
/*
* GtkToolBar
*/
@ -3602,7 +3486,7 @@ create_forward_back (const char *title,
GtkTextDirection text_dir)
{
GtkWidget *frame = gtk_frame_new (title);
GtkWidget *bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
GtkWidget *bbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
GtkWidget *back_button = gtk_button_new_with_label ("Back");
GtkWidget *forward_button = gtk_button_new_with_label ("Forward");
@ -3902,7 +3786,8 @@ create_display_screen (GtkWidget *widget)
gtk_grid_attach (GTK_GRID (grid), label_dpy, 0, 0, 1, 1);
gtk_grid_attach (GTK_GRID (grid), combo_dpy, 0, 1, 1, 1);
bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
bbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_halign (bbox, GTK_ALIGN_END);
applyb = gtk_button_new_with_label ("_Apply");
cancelb = gtk_button_new_with_label ("_Cancel");
@ -6674,7 +6559,6 @@ struct {
} buttons[] =
{
{ "alpha window", create_alpha_window },
{ "button box", create_button_box },
{ "buttons", create_buttons },
{ "check buttons", create_check_buttons },
{ "color selection", create_color_selection },

View File

@ -539,8 +539,8 @@ main (gint argc, gchar **argv)
gtk_paned_add2 (GTK_PANED (paned), scrolled_window);
bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_START);
bbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_halign (bbox, GTK_ALIGN_START);
gtk_container_add (GTK_CONTAINER (vbox), bbox);
button = gtk_button_new_with_label ("Add some");
@ -563,8 +563,8 @@ main (gint argc, gchar **argv)
g_signal_connect (button, "clicked", G_CALLBACK (swap_rows), icon_list);
gtk_container_add (GTK_CONTAINER (bbox), button);
bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_START);
bbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_halign (bbox, GTK_ALIGN_START);
gtk_container_add (GTK_CONTAINER (vbox), bbox);
button = gtk_button_new_with_label ("Select all");

View File

@ -69,17 +69,6 @@ main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (box),
gtk_button_new_with_label ("GtkBox 3"));
/* GtkButtonBox */
box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
orientables = g_list_prepend (orientables, box);
gtk_grid_attach (GTK_GRID (grid), box, 1, 1, 1, 1);
gtk_container_add (GTK_CONTAINER (box),
gtk_button_new_with_label ("GtkButtonBox 1"));
gtk_container_add (GTK_CONTAINER (box),
gtk_button_new_with_label ("GtkButtonBox 2"));
gtk_container_add (GTK_CONTAINER (box),
gtk_button_new_with_label ("GtkButtonBox 3"));
/* GtkSeparator */
box = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
orientables = g_list_prepend (orientables, box);

View File

@ -792,8 +792,7 @@ main (int argc, char *argv[])
vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_container_add (GTK_CONTAINER (hbox), vbox2);
bbox = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_SPREAD);
bbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (vbox2), bbox);
button = gtk_button_new_with_mnemonic ("<< (_Q)");
@ -810,8 +809,7 @@ main (int argc, char *argv[])
"changed", G_CALLBACK (selection_changed), button);
gtk_container_add (GTK_CONTAINER (bbox), button);
bbox = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_SPREAD);
bbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (vbox2), bbox);
button = gtk_button_new_with_mnemonic ("<< (_E)");

View File

@ -922,7 +922,7 @@ test_children (void)
" <object class=\"GtkBox\" id=\"dialog1-vbox\">"
" <property name=\"orientation\">vertical</property>"
" <child internal-child=\"action_area\">"
" <object class=\"GtkButtonBox\" id=\"dialog1-action_area\">"
" <object class=\"GtkBox\" id=\"dialog1-action_area\">"
" <property name=\"orientation\">horizontal</property>"
" </object>"
" </child>"
@ -965,7 +965,7 @@ test_children (void)
action_area = gtk_builder_get_object (builder, "dialog1-action_area");
g_assert (action_area != NULL);
g_assert (GTK_IS_BUTTON_BOX (action_area));
g_assert (GTK_IS_BOX (action_area));
g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (action_area)) == GTK_ORIENTATION_HORIZONTAL);
g_assert (gtk_widget_get_parent (GTK_WIDGET (action_area)) != NULL);
g_assert (gtk_buildable_get_name (GTK_BUILDABLE (action_area)) != NULL);
@ -1324,7 +1324,7 @@ test_dialog (void)
" <object class=\"GtkBox\" id=\"dialog1-vbox\">"
" <property name=\"orientation\">vertical</property>"
" <child internal-child=\"action_area\">"
" <object class=\"GtkButtonBox\" id=\"dialog1-action_area\">"
" <object class=\"GtkBox\" id=\"dialog1-action_area\">"
" <property name=\"orientation\">horizontal</property>"
" <child>"
" <object class=\"GtkButton\" id=\"button_cancel\"/>"
@ -2179,7 +2179,7 @@ test_message_area (void)
" </object>"
" </child>"
" <child internal-child=\"action_area\">"
" <object class=\"GtkButtonBox\" id=\"actionarea1\">"
" <object class=\"GtkBox\" id=\"actionarea1\">"
" <property name=\"orientation\">vertical</property>"
" <child>"
" <object class=\"GtkButton\" id=\"button_ok\">"
@ -2420,7 +2420,7 @@ test_no_ids (void)
" </object>"
" </child>"
" <child internal-child=\"action_area\">"
" <object class=\"GtkButtonBox\">"
" <object class=\"GtkBox\">"
" <property name=\"orientation\">vertical</property>"
" <child>"
" <object class=\"GtkButton\" id=\"button_ok\">"