Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
4013783361 | ||
|
4bb2226ae9 | ||
|
5f459add7b | ||
|
875f4fe6c3 | ||
|
33319a7456 | ||
|
62f6599a07 | ||
|
696ddbcb5f | ||
|
3e9d6a6eb5 | ||
|
6a7620173e | ||
|
5978fa8a0a | ||
|
7eec09796c | ||
|
4cc23a183b |
@@ -43,6 +43,7 @@ demos = \
|
||||
search_entry.c \
|
||||
sizegroup.c \
|
||||
spinner.c \
|
||||
stack.c \
|
||||
stock_browser.c \
|
||||
textview.c \
|
||||
textscroll.c \
|
||||
@@ -110,6 +111,7 @@ RESOURCES= $(demos) \
|
||||
application.ui \
|
||||
demo.ui \
|
||||
menus.ui \
|
||||
stack.ui \
|
||||
theming.ui \
|
||||
alphatest.png \
|
||||
apple-red.png \
|
||||
|
@@ -55,6 +55,9 @@
|
||||
<file preprocess="to-pixdata">gnome-fs-directory.png</file>
|
||||
<file preprocess="to-pixdata">gnome-fs-regular.png</file>
|
||||
</gresource>
|
||||
<gresource prefix="/stack">
|
||||
<file>stack.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/images">
|
||||
<file>alphatest.png</file>
|
||||
<file>floppybuddy.gif</file>
|
||||
@@ -110,6 +113,7 @@
|
||||
<file>rotated_text.c</file>
|
||||
<file>search_entry.c</file>
|
||||
<file>sizegroup.c</file>
|
||||
<file>stack.c</file>
|
||||
<file>spinner.c</file>
|
||||
<file>stock_browser.c</file>
|
||||
<file>textview.c</file>
|
||||
|
48
demos/gtk-demo/stack.c
Normal file
48
demos/gtk-demo/stack.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/* Stack
|
||||
*
|
||||
* GtkStack is a container that shows a single child at a time,
|
||||
* with nice transitions when the visible child changes.
|
||||
*
|
||||
* GtkStackSwitcher adds buttons to control which child is visible.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static GtkBuilder *builder;
|
||||
|
||||
GtkWidget *
|
||||
do_stack (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GError *err = NULL;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
builder = gtk_builder_new ();
|
||||
gtk_builder_add_from_resource (builder, "/stack/stack.ui", &err);
|
||||
if (err)
|
||||
{
|
||||
g_error ("ERROR: %s\n", err->message);
|
||||
return NULL;
|
||||
}
|
||||
gtk_builder_connect_signals (builder, NULL);
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (do_widget));
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
{
|
||||
gtk_widget_show_all (window);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_destroy (window);
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
|
||||
return window;
|
||||
}
|
82
demos/gtk-demo/stack.ui
Normal file
82
demos/gtk-demo/stack.ui
Normal file
@@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<!-- interface-requires gtk+ 3.6 -->
|
||||
<object class="GtkWindow" id="window1">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">GtkStack</property>
|
||||
<child>
|
||||
<object class="GtkGrid" id="grid1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkStackSwitcher" id="switcher">
|
||||
<property name="visible">True</property>
|
||||
<property name="stack">stack</property>
|
||||
<property name="halign">center</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStack" id="stack">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="transition-type">crossfade</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin-top">20</property>
|
||||
<property name="margin-bottom">20</property>
|
||||
<property name="resource">/application/gtk-logo-48.png</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">page1</property>
|
||||
<property name="title" translatable="yes">Page 1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="checkbutton1">
|
||||
<property name="label" translatable="yes">Page 2</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">page2</property>
|
||||
<property name="title" translatable="yes">Page 2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinner" id="spinner1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="active">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">page3</property>
|
||||
<property name="icon-name">face-laugh-symbolic</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
@@ -234,6 +234,8 @@
|
||||
<xi:include href="xml/gtkpaned.xml" />
|
||||
<xi:include href="xml/gtklayout.xml" />
|
||||
<xi:include href="xml/gtknotebook.xml" />
|
||||
<xi:include href="xml/gtkstack.xml" />
|
||||
<xi:include href="xml/gtkstackswitcher.xml" />
|
||||
<xi:include href="xml/gtkexpander.xml" />
|
||||
<xi:include href="xml/gtkoverlay.xml" />
|
||||
<xi:include href="xml/gtkheaderbar.xml" />
|
||||
|
@@ -7564,3 +7564,33 @@ GTK_HEADER_BAR_GET_CLASS
|
||||
<SUBSECTION Private>
|
||||
gtk_header_bar_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkstack</FILE>
|
||||
<TITLE>GtkStack</TITLE>
|
||||
GtkStack
|
||||
gtk_stack_new
|
||||
gtk_stack_add_named
|
||||
gtk_stack_add_titled
|
||||
gtk_stack_set_visible_child
|
||||
gtk_stack_get_visible_child
|
||||
gtk_stack_set_visible_child_name
|
||||
gtk_stack_get_visible_child_name
|
||||
gtk_stack_set_visible_child_full
|
||||
gtk_stack_set_homogeneous
|
||||
gtk_stack_get_homogeneous
|
||||
gtk_stack_set_transition_duration
|
||||
gtk_stack_get_transition_duration
|
||||
GtkStackTransitionType
|
||||
gtk_stack_set_transition_type
|
||||
gtk_stack_get_transition_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkstackswitcher</FILE>
|
||||
<TITLE>GtkStackSwitcher</TITLE>
|
||||
GtkStackSwitcher
|
||||
gtk_stack_switcher_new
|
||||
gtk_stack_switcher_set_stack
|
||||
gtk_stack_switcher_get_stack
|
||||
</SECTION>
|
||||
|
@@ -331,6 +331,8 @@ gtk_public_h_sources = \
|
||||
gtksocket.h \
|
||||
gtkspinbutton.h \
|
||||
gtkspinner.h \
|
||||
gtkstack.h \
|
||||
gtkstackswitcher.h \
|
||||
gtkstatusbar.h \
|
||||
gtkstatusicon.h \
|
||||
gtkstock.h \
|
||||
@@ -830,6 +832,8 @@ gtk_base_c_sources = \
|
||||
gtkshow.c \
|
||||
gtkspinbutton.c \
|
||||
gtkspinner.c \
|
||||
gtkstack.c \
|
||||
gtkstackswitcher.c \
|
||||
gtkstatusbar.c \
|
||||
gtkstatusicon.c \
|
||||
gtkstock.c \
|
||||
|
@@ -179,6 +179,8 @@
|
||||
#include <gtk/gtksizerequest.h>
|
||||
#include <gtk/gtkspinbutton.h>
|
||||
#include <gtk/gtkspinner.h>
|
||||
#include <gtk/gtkstack.h>
|
||||
#include <gtk/gtkstackswitcher.h>
|
||||
#include <gtk/gtkstatusbar.h>
|
||||
#include <gtk/gtkstatusicon.h>
|
||||
#include <gtk/gtkstock.h>
|
||||
|
@@ -2598,6 +2598,26 @@ gtk_spinner_new
|
||||
gtk_spinner_start
|
||||
gtk_spinner_stop
|
||||
gtk_spin_type_get_type
|
||||
gtk_stack_add_named
|
||||
gtk_stack_add_titled
|
||||
gtk_stack_get_homogeneous
|
||||
gtk_stack_get_transition_duration
|
||||
gtk_stack_get_transition_type
|
||||
gtk_stack_get_type
|
||||
gtk_stack_get_visible_child
|
||||
gtk_stack_get_visible_child_name
|
||||
gtk_stack_new
|
||||
gtk_stack_set_homogeneous
|
||||
gtk_stack_set_transition_duration
|
||||
gtk_stack_set_transition_type
|
||||
gtk_stack_set_visible_child
|
||||
gtk_stack_set_visible_child_full
|
||||
gtk_stack_set_visible_child_name
|
||||
gtk_stack_switcher_get_stack
|
||||
gtk_stack_switcher_get_type
|
||||
gtk_stack_switcher_new
|
||||
gtk_stack_switcher_set_stack
|
||||
gtk_stack_transition_type_get_type
|
||||
gtk_state_flags_get_type
|
||||
gtk_state_type_get_type
|
||||
gtk_statusbar_accessible_get_type
|
||||
|
1682
gtk/gtkstack.c
Normal file
1682
gtk/gtkstack.c
Normal file
File diff suppressed because it is too large
Load Diff
90
gtk/gtkstack.h
Normal file
90
gtk/gtkstack.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Red Hat, Inc.
|
||||
*
|
||||
* This program 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 program 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 program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Author: Alexander Larsson <alexl@redhat.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __GTK_STACK_H__
|
||||
#define __GTK_STACK_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define GTK_TYPE_STACK (gtk_stack_get_type ())
|
||||
#define GTK_STACK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_STACK, GtkStack))
|
||||
#define GTK_STACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_STACK, GtkStackClass))
|
||||
#define GTK_IS_STACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_STACK))
|
||||
#define GTK_IS_STACK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_STACK))
|
||||
#define GTK_STACK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_STACK, GtkStackClass))
|
||||
|
||||
typedef struct _GtkStack GtkStack;
|
||||
typedef struct _GtkStackClass GtkStackClass;
|
||||
typedef struct _GtkStackPrivate GtkStackPrivate;
|
||||
|
||||
typedef enum {
|
||||
GTK_STACK_TRANSITION_TYPE_NONE,
|
||||
GTK_STACK_TRANSITION_TYPE_CROSSFADE,
|
||||
GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT,
|
||||
GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT,
|
||||
GTK_STACK_TRANSITION_TYPE_SLIDE_UP,
|
||||
GTK_STACK_TRANSITION_TYPE_SLIDE_DOWN
|
||||
} GtkStackTransitionType;
|
||||
|
||||
struct _GtkStack {
|
||||
GtkContainer parent_instance;
|
||||
GtkStackPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkStackClass {
|
||||
GtkContainerClass parent_class;
|
||||
};
|
||||
|
||||
GType gtk_stack_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gtk_stack_new (void);
|
||||
void gtk_stack_add_named (GtkStack *stack,
|
||||
GtkWidget *child,
|
||||
const gchar *name);
|
||||
void gtk_stack_add_titled (GtkStack *stack,
|
||||
GtkWidget *child,
|
||||
const gchar *name,
|
||||
const gchar *title);
|
||||
void gtk_stack_set_visible_child (GtkStack *stack,
|
||||
GtkWidget *child);
|
||||
GtkWidget * gtk_stack_get_visible_child (GtkStack *stack);
|
||||
void gtk_stack_set_visible_child_name (GtkStack *stack,
|
||||
const gchar *name);
|
||||
const gchar * gtk_stack_get_visible_child_name (GtkStack *stack);
|
||||
void gtk_stack_set_visible_child_full (GtkStack *stack,
|
||||
const gchar *name,
|
||||
GtkStackTransitionType transition_type);
|
||||
void gtk_stack_set_homogeneous (GtkStack *stack,
|
||||
gboolean homogeneous);
|
||||
gboolean gtk_stack_get_homogeneous (GtkStack *stack);
|
||||
void gtk_stack_set_transition_duration (GtkStack *stack,
|
||||
guint transition_duration);
|
||||
guint gtk_stack_get_transition_duration (GtkStack *stack);
|
||||
void gtk_stack_set_transition_type (GtkStack *stack,
|
||||
GtkStackTransitionType transition_type);
|
||||
GtkStackTransitionType gtk_stack_get_transition_type (GtkStack *stack);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
445
gtk/gtkstackswitcher.c
Normal file
445
gtk/gtkstackswitcher.c
Normal file
@@ -0,0 +1,445 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Red Hat, Inc.
|
||||
*
|
||||
* This program 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 program 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 program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "gtkstackswitcher.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
/**
|
||||
* SECTION:gtkstackswitcher
|
||||
* @Short_decription: A controller for GtkStack
|
||||
* @Title: GtkStackSwitcher
|
||||
* @See_also: #GtkStack
|
||||
*
|
||||
* The GtkStackSwitcher widget acts as a controller for a
|
||||
* #GtkStack; it shows a row of buttons to switch between
|
||||
* the various pages of the associated stack widget.
|
||||
*
|
||||
* All the content for the buttons comes from the child properties
|
||||
* of the #GtkStack.
|
||||
*
|
||||
* It is possible to associate multiple #GtkStackSwitcher widgets
|
||||
* with the same stack widget.
|
||||
*
|
||||
* The GtkStackSwitcher widget was added in 3.10.
|
||||
*/
|
||||
|
||||
struct _GtkStackSwitcherPrivate
|
||||
{
|
||||
GtkStack *stack;
|
||||
GHashTable *buttons;
|
||||
gboolean in_child_changed;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_STACK
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkStackSwitcher, gtk_stack_switcher, GTK_TYPE_BOX);
|
||||
|
||||
static void
|
||||
gtk_stack_switcher_init (GtkStackSwitcher *switcher)
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
GtkStackSwitcherPrivate *priv;
|
||||
|
||||
priv = G_TYPE_INSTANCE_GET_PRIVATE (switcher, GTK_TYPE_STACK_SWITCHER, GtkStackSwitcherPrivate);
|
||||
switcher->priv = priv;
|
||||
|
||||
priv->stack = NULL;
|
||||
priv->buttons = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
|
||||
context = gtk_widget_get_style_context (GTK_WIDGET (switcher));
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_LINKED);
|
||||
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (switcher), GTK_ORIENTATION_HORIZONTAL);
|
||||
}
|
||||
|
||||
static void
|
||||
clear_switcher (GtkStackSwitcher *self)
|
||||
{
|
||||
gtk_container_foreach (GTK_CONTAINER (self), (GtkCallback) gtk_widget_destroy, self);
|
||||
}
|
||||
|
||||
static void
|
||||
on_button_clicked (GtkWidget *widget,
|
||||
GtkStackSwitcher *self)
|
||||
{
|
||||
GtkWidget *child;
|
||||
|
||||
if (!self->priv->in_child_changed)
|
||||
{
|
||||
child = g_object_get_data (G_OBJECT (widget), "stack-child");
|
||||
gtk_stack_set_visible_child (self->priv->stack, child);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rebuild_child (GtkWidget *self,
|
||||
const gchar *icon_name,
|
||||
const gchar *title)
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
GtkWidget *button_child;
|
||||
|
||||
gtk_widget_set_valign (GTK_WIDGET (self), GTK_ALIGN_CENTER);
|
||||
|
||||
button_child = gtk_bin_get_child (GTK_BIN (self));
|
||||
if (button_child != NULL)
|
||||
gtk_widget_destroy (button_child);
|
||||
|
||||
button_child = NULL;
|
||||
context = gtk_widget_get_style_context (GTK_WIDGET (self));
|
||||
|
||||
if (icon_name != NULL)
|
||||
{
|
||||
button_child = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
|
||||
if (title != NULL)
|
||||
gtk_widget_set_tooltip_text (GTK_WIDGET (self), title);
|
||||
|
||||
gtk_style_context_remove_class (context, "text-button");
|
||||
gtk_style_context_add_class (context, "image-button");
|
||||
}
|
||||
else if (title != NULL)
|
||||
{
|
||||
button_child = gtk_label_new (title);
|
||||
|
||||
gtk_style_context_remove_class (context, "image-button");
|
||||
gtk_style_context_add_class (context, "text-button");
|
||||
}
|
||||
|
||||
if (button_child)
|
||||
{
|
||||
gtk_widget_show_all (button_child);
|
||||
gtk_container_add (GTK_CONTAINER (self), button_child);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_button (GtkStackSwitcher *self,
|
||||
GtkWidget *widget,
|
||||
GtkWidget *button)
|
||||
{
|
||||
gchar *title;
|
||||
gchar *icon_name;
|
||||
|
||||
gtk_container_child_get (GTK_CONTAINER (self->priv->stack), widget,
|
||||
"title", &title,
|
||||
"icon-name", &icon_name,
|
||||
NULL);
|
||||
|
||||
rebuild_child (button, icon_name, title);
|
||||
|
||||
gtk_widget_set_visible (button, title != NULL || icon_name != NULL);
|
||||
|
||||
if (icon_name != NULL)
|
||||
gtk_widget_set_size_request (button, -1, -1);
|
||||
else
|
||||
gtk_widget_set_size_request (button, 100, -1);
|
||||
|
||||
g_free (title);
|
||||
g_free (icon_name);
|
||||
}
|
||||
|
||||
static void
|
||||
on_title_icon_updated (GtkWidget *widget,
|
||||
GParamSpec *pspec,
|
||||
GtkStackSwitcher *self)
|
||||
{
|
||||
GtkWidget *button;
|
||||
|
||||
button = g_hash_table_lookup (self->priv->buttons, widget);
|
||||
update_button (self, widget, button);
|
||||
}
|
||||
|
||||
static void
|
||||
on_position_updated (GtkWidget *widget,
|
||||
GParamSpec *pspec,
|
||||
GtkStackSwitcher *self)
|
||||
{
|
||||
GtkWidget *button;
|
||||
gint position;
|
||||
|
||||
button = g_hash_table_lookup (self->priv->buttons, widget);
|
||||
|
||||
gtk_container_child_get (GTK_CONTAINER (self->priv->stack), widget,
|
||||
"position", &position,
|
||||
NULL);
|
||||
|
||||
gtk_box_reorder_child (GTK_BOX (self), button, position);
|
||||
}
|
||||
|
||||
static void
|
||||
add_child (GtkStackSwitcher *self,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *button;
|
||||
GList *group;
|
||||
|
||||
button = gtk_radio_button_new (NULL);
|
||||
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
|
||||
|
||||
update_button (self, widget, button);
|
||||
|
||||
group = gtk_container_get_children (GTK_CONTAINER (self));
|
||||
if (group != NULL)
|
||||
{
|
||||
gtk_radio_button_join_group (GTK_RADIO_BUTTON (button), GTK_RADIO_BUTTON (group->data));
|
||||
g_list_free (group);
|
||||
}
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (self), button);
|
||||
|
||||
g_object_set_data (G_OBJECT (button), "stack-child", widget);
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (on_button_clicked), self);
|
||||
g_signal_connect (widget, "child-notify::title", G_CALLBACK (on_title_icon_updated), self);
|
||||
g_signal_connect (widget, "child-notify::icon-name", G_CALLBACK (on_title_icon_updated), self);
|
||||
g_signal_connect (widget, "child-notify::position", G_CALLBACK (on_position_updated), self);
|
||||
|
||||
g_hash_table_insert (self->priv->buttons, widget, button);
|
||||
}
|
||||
|
||||
static void
|
||||
foreach_stack (GtkWidget *widget,
|
||||
GtkStackSwitcher *self)
|
||||
{
|
||||
add_child (self, widget);
|
||||
}
|
||||
|
||||
static void
|
||||
populate_switcher (GtkStackSwitcher *self)
|
||||
{
|
||||
gtk_container_foreach (GTK_CONTAINER (self->priv->stack), (GtkCallback)foreach_stack, self);
|
||||
}
|
||||
|
||||
static void
|
||||
on_child_changed (GtkWidget *widget,
|
||||
GParamSpec *pspec,
|
||||
GtkStackSwitcher *self)
|
||||
{
|
||||
GtkWidget *child;
|
||||
GtkWidget *button;
|
||||
|
||||
child = gtk_stack_get_visible_child (GTK_STACK (widget));
|
||||
button = g_hash_table_lookup (self->priv->buttons, child);
|
||||
if (button != NULL)
|
||||
{
|
||||
self->priv->in_child_changed = TRUE;
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
||||
self->priv->in_child_changed = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_stack_child_added (GtkContainer *container,
|
||||
GtkWidget *widget,
|
||||
GtkStackSwitcher *self)
|
||||
{
|
||||
add_child (self, widget);
|
||||
}
|
||||
|
||||
static void
|
||||
on_stack_child_removed (GtkContainer *container,
|
||||
GtkWidget *widget,
|
||||
GtkStackSwitcher *self)
|
||||
{
|
||||
GtkWidget *button;
|
||||
|
||||
button = g_hash_table_lookup (self->priv->buttons, widget);
|
||||
gtk_container_remove (GTK_CONTAINER (self), button);
|
||||
g_hash_table_remove (self->priv->buttons, widget);
|
||||
}
|
||||
|
||||
static void
|
||||
disconnect_stack_signals (GtkStackSwitcher *switcher)
|
||||
{
|
||||
GtkStackSwitcherPrivate *priv = switcher->priv;
|
||||
|
||||
g_signal_handlers_disconnect_by_func (priv->stack, on_stack_child_added, switcher);
|
||||
g_signal_handlers_disconnect_by_func (priv->stack, on_stack_child_removed, switcher);
|
||||
g_signal_handlers_disconnect_by_func (priv->stack, on_child_changed, switcher);
|
||||
g_signal_handlers_disconnect_by_func (priv->stack, disconnect_stack_signals, switcher);
|
||||
}
|
||||
|
||||
static void
|
||||
connect_stack_signals (GtkStackSwitcher *switcher)
|
||||
{
|
||||
GtkStackSwitcherPrivate *priv = switcher->priv;
|
||||
|
||||
g_signal_connect_after (priv->stack, "add",
|
||||
G_CALLBACK (on_stack_child_added), switcher);
|
||||
g_signal_connect_after (priv->stack, "remove",
|
||||
G_CALLBACK (on_stack_child_removed), switcher);
|
||||
g_signal_connect (priv->stack, "notify::visible-child",
|
||||
G_CALLBACK (on_child_changed), switcher);
|
||||
g_signal_connect_swapped (priv->stack, "destroy",
|
||||
G_CALLBACK (disconnect_stack_signals), switcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_stack_switcher_set_stack:
|
||||
* @switcher: a #GtkStackSwitcher
|
||||
* @stack: (allow-none): a #GtkStack
|
||||
*
|
||||
* Sets the stack to control.
|
||||
*
|
||||
* Since: 3.10
|
||||
*/
|
||||
void
|
||||
gtk_stack_switcher_set_stack (GtkStackSwitcher *switcher,
|
||||
GtkStack *stack)
|
||||
{
|
||||
GtkStackSwitcherPrivate *priv;
|
||||
|
||||
g_return_if_fail (GTK_IS_STACK_SWITCHER (switcher));
|
||||
if (stack)
|
||||
g_return_if_fail (GTK_IS_STACK (stack));
|
||||
|
||||
priv = switcher->priv;
|
||||
|
||||
if (priv->stack == stack)
|
||||
return;
|
||||
|
||||
if (priv->stack)
|
||||
{
|
||||
disconnect_stack_signals (switcher);
|
||||
clear_switcher (switcher);
|
||||
g_clear_object (&priv->stack);
|
||||
}
|
||||
|
||||
if (stack)
|
||||
{
|
||||
priv->stack = g_object_ref (stack);
|
||||
populate_switcher (switcher);
|
||||
connect_stack_signals (switcher);
|
||||
}
|
||||
|
||||
gtk_widget_queue_resize (GTK_WIDGET (switcher));
|
||||
|
||||
g_object_notify (G_OBJECT (switcher), "stack");
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_stack_switcher_get_stack:
|
||||
* @switcher: a #GtkStackSwitcher
|
||||
*
|
||||
* Retrieves the stack.
|
||||
* See gtk_stack_switcher_set_stack().
|
||||
*
|
||||
* Return value: (transfer none): the stack, or %NULL if
|
||||
* none has been set explicitly.
|
||||
*
|
||||
* Since: 3.10
|
||||
*/
|
||||
GtkStack *
|
||||
gtk_stack_switcher_get_stack (GtkStackSwitcher *switcher)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_STACK_SWITCHER (switcher), NULL);
|
||||
|
||||
return switcher->priv->stack;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_stack_switcher_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkStackSwitcher *switcher = GTK_STACK_SWITCHER (object);
|
||||
GtkStackSwitcherPrivate *priv = switcher->priv;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_STACK:
|
||||
g_value_set_object (value, priv->stack);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_stack_switcher_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkStackSwitcher *switcher = GTK_STACK_SWITCHER (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_STACK:
|
||||
gtk_stack_switcher_set_stack (switcher, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_stack_switcher_dispose (GObject *object)
|
||||
{
|
||||
GtkStackSwitcher *switcher = GTK_STACK_SWITCHER (object);
|
||||
|
||||
gtk_stack_switcher_set_stack (switcher, NULL);
|
||||
|
||||
G_OBJECT_CLASS (gtk_stack_switcher_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_stack_switcher_class_init (GtkStackSwitcherClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
object_class->get_property = gtk_stack_switcher_get_property;
|
||||
object_class->set_property = gtk_stack_switcher_set_property;
|
||||
object_class->dispose = gtk_stack_switcher_dispose;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_STACK,
|
||||
g_param_spec_object ("stack",
|
||||
P_("Stack"),
|
||||
P_("Stack"),
|
||||
GTK_TYPE_STACK,
|
||||
GTK_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (GtkStackSwitcherPrivate));
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_stack_switcher_new:
|
||||
*
|
||||
* Create a new #GtkStackSwitcher.
|
||||
*
|
||||
* Return value: a new #GtkStackSwitcher.
|
||||
*
|
||||
* Since: 3.10
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_stack_switcher_new (void)
|
||||
{
|
||||
return GTK_WIDGET (g_object_new (GTK_TYPE_STACK_SWITCHER, NULL));
|
||||
}
|
65
gtk/gtkstackswitcher.h
Normal file
65
gtk/gtkstackswitcher.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Red Hat, Inc.
|
||||
*
|
||||
* This program 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 program 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 program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __GTK_STACK_SWITCHER_H__
|
||||
#define __GTK_STACK_SWITCHER_H__
|
||||
|
||||
#include "gtkstack.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_STACK_SWITCHER (gtk_stack_switcher_get_type ())
|
||||
#define GTK_STACK_SWITCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_STACK_SWITCHER, GtkStackSwitcher))
|
||||
#define GTK_STACK_SWITCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_STACK_SWITCHER, GtkStackSwitcherClass))
|
||||
#define GTK_IS_STACK_SWITCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_STACK_SWITCHER))
|
||||
#define GTK_IS_STACK_SWITCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_STACK_SWITCHER))
|
||||
#define GTK_STACK_SWITCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_STACK_SWITCHER, GtkStackSwitcherClass))
|
||||
|
||||
typedef struct _GtkStackSwitcher GtkStackSwitcher;
|
||||
typedef struct _GtkStackSwitcherPrivate GtkStackSwitcherPrivate;
|
||||
typedef struct _GtkStackSwitcherClass GtkStackSwitcherClass;
|
||||
|
||||
struct _GtkStackSwitcher
|
||||
{
|
||||
GtkBox widget;
|
||||
|
||||
/*< private >*/
|
||||
GtkStackSwitcherPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkStackSwitcherClass
|
||||
{
|
||||
GtkBoxClass parent_class;
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved4) (void);
|
||||
};
|
||||
|
||||
GType gtk_stack_switcher_get_type (void) G_GNUC_CONST;
|
||||
GtkWidget * gtk_stack_switcher_new (void);
|
||||
void gtk_stack_switcher_set_stack (GtkStackSwitcher *switcher,
|
||||
GtkStack *stack);
|
||||
GtkStack * gtk_stack_switcher_get_stack (GtkStackSwitcher *switcher);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_STACK_SWITCHER_H__ */
|
@@ -130,7 +130,8 @@ noinst_PROGRAMS = $(TEST_PROGS) \
|
||||
testpixbuf-color \
|
||||
testpixbuf-scale \
|
||||
testgmenu \
|
||||
testlogout
|
||||
testlogout \
|
||||
teststack
|
||||
|
||||
if USE_X11
|
||||
noinst_PROGRAMS += testerrors
|
||||
@@ -254,6 +255,7 @@ testpixbuf_color_DEPENDENCIES = $(TEST_DEPS)
|
||||
testpixbuf_scale_DEPENDENCIES = $(TEST_DEPS)
|
||||
testgmenu_DEPENDENCIES = $(TEST_DEPS)
|
||||
testlogout_DEPENDENCIES = $(TEST_DEPS)
|
||||
teststack_DEPENDENCIES = $(TEST_DEPS)
|
||||
|
||||
animated_resizing_SOURCES = \
|
||||
animated-resizing.c \
|
||||
@@ -452,6 +454,8 @@ testcolorchooser_SOURCES = testcolorchooser.c
|
||||
|
||||
testkineticscrolling_SOURCES = testkineticscrolling.c
|
||||
|
||||
teststack_SOURCES = teststack.c
|
||||
|
||||
EXTRA_DIST += \
|
||||
gradient1.png \
|
||||
prop-editor.h \
|
||||
|
245
tests/teststack.c
Normal file
245
tests/teststack.c
Normal file
@@ -0,0 +1,245 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
GtkWidget *stack;
|
||||
GtkWidget *switcher;
|
||||
GtkWidget *w1;
|
||||
|
||||
static void
|
||||
set_visible_child (GtkWidget *button, gpointer data)
|
||||
{
|
||||
gtk_stack_set_visible_child (GTK_STACK (stack), GTK_WIDGET (data));
|
||||
}
|
||||
|
||||
static void
|
||||
set_visible_child_name (GtkWidget *button, gpointer data)
|
||||
{
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (stack), (const char *)data);
|
||||
}
|
||||
|
||||
static void
|
||||
toggle_homogeneous (GtkWidget *button, gpointer data)
|
||||
{
|
||||
gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
|
||||
gtk_stack_set_homogeneous (GTK_STACK (stack), active);
|
||||
}
|
||||
|
||||
static void
|
||||
toggle_icon_name (GtkWidget *button, gpointer data)
|
||||
{
|
||||
gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
|
||||
gtk_container_child_set (GTK_CONTAINER (stack), w1,
|
||||
"icon-name", active ? "edit-find-symbolic" : NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
toggle_transitions (GtkWidget *combo, gpointer data)
|
||||
{
|
||||
int id = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
|
||||
gtk_stack_set_transition_type (GTK_STACK (stack), id);
|
||||
}
|
||||
|
||||
static void
|
||||
on_back_button_clicked (GtkButton *button, GtkStack *stack)
|
||||
{
|
||||
const gchar *seq[] = { "1", "2", "3" };
|
||||
const gchar *vis;
|
||||
gint i;
|
||||
|
||||
vis = gtk_stack_get_visible_child_name (stack);
|
||||
|
||||
for (i = 1; i < G_N_ELEMENTS (seq); i++)
|
||||
{
|
||||
if (g_strcmp0 (vis, seq[i]) == 0)
|
||||
{
|
||||
gtk_stack_set_visible_child_full (stack, seq[i - 1], GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_forward_button_clicked (GtkButton *button, GtkStack *stack)
|
||||
{
|
||||
const gchar *seq[] = { "1", "2", "3" };
|
||||
const gchar *vis;
|
||||
gint i;
|
||||
|
||||
vis = gtk_stack_get_visible_child_name (stack);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (seq) - 1; i++)
|
||||
{
|
||||
if (g_strcmp0 (vis, seq[i]) == 0)
|
||||
{
|
||||
gtk_stack_set_visible_child_full (stack, seq[i + 1], GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_back_button_sensitivity (GtkStack *stack, GParamSpec *pspec, GtkWidget *button)
|
||||
{
|
||||
const gchar *vis;
|
||||
|
||||
vis = gtk_stack_get_visible_child_name (stack);
|
||||
gtk_widget_set_sensitive (button, g_strcmp0 (vis, "1") != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
update_forward_button_sensitivity (GtkStack *stack, GParamSpec *pspec, GtkWidget *button)
|
||||
{
|
||||
const gchar *vis;
|
||||
|
||||
vis = gtk_stack_get_visible_child_name (stack);
|
||||
gtk_widget_set_sensitive (button, g_strcmp0 (vis, "3") != 0);
|
||||
}
|
||||
|
||||
gint
|
||||
main (gint argc,
|
||||
gchar ** argv)
|
||||
{
|
||||
GtkWidget *window, *box, *button, *hbox, *combo;
|
||||
GtkWidget *w2, *w3;
|
||||
GtkListStore* store;
|
||||
GtkWidget *tree_view;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkWidget *scrolled_win;
|
||||
int i;
|
||||
GtkTreeIter iter;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_widget_set_size_request (window, 300, 300);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), box);
|
||||
|
||||
switcher = gtk_stack_switcher_new ();
|
||||
gtk_box_pack_start (GTK_BOX (box), switcher, FALSE, FALSE, 0);
|
||||
|
||||
stack = gtk_stack_new ();
|
||||
|
||||
/* Make transitions longer so we can see that they work */
|
||||
gtk_stack_set_transition_duration (GTK_STACK (stack), 500);
|
||||
|
||||
gtk_widget_set_halign (stack, GTK_ALIGN_START);
|
||||
gtk_container_add (GTK_CONTAINER (box), stack);
|
||||
|
||||
gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (stack));
|
||||
|
||||
w1 = gtk_text_view_new ();
|
||||
gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (w1)),
|
||||
"This is a\nTest\nBalh!", -1);
|
||||
|
||||
gtk_container_add_with_properties (GTK_CONTAINER (stack), w1,
|
||||
"name", "1",
|
||||
"title", "1",
|
||||
NULL);
|
||||
|
||||
w2 = gtk_button_new_with_label ("Gazoooooooooooooooonk");
|
||||
gtk_container_add (GTK_CONTAINER (stack), w2);
|
||||
gtk_container_child_set (GTK_CONTAINER (stack), w2,
|
||||
"name", "2",
|
||||
"title", "2",
|
||||
NULL);
|
||||
|
||||
|
||||
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_widget_set_size_request (scrolled_win, 100, 200);
|
||||
|
||||
|
||||
store = gtk_list_store_new (1, G_TYPE_STRING);
|
||||
|
||||
for (i = 0; i < 40; i++)
|
||||
gtk_list_store_insert_with_values (store, &iter, i, 0, "Testvalule", -1);
|
||||
|
||||
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (scrolled_win), tree_view);
|
||||
w3 = scrolled_win;
|
||||
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes ("Target", renderer,
|
||||
"text", 0, NULL);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
|
||||
|
||||
gtk_stack_add_titled (GTK_STACK (stack), w3, "3", "3");
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_container_add (GTK_CONTAINER (box), hbox);
|
||||
|
||||
button = gtk_button_new_with_label ("1");
|
||||
gtk_container_add (GTK_CONTAINER (hbox), button);
|
||||
g_signal_connect (button, "clicked", (GCallback) set_visible_child, w1);
|
||||
|
||||
button = gtk_button_new_with_label ("2");
|
||||
gtk_container_add (GTK_CONTAINER (hbox), button);
|
||||
g_signal_connect (button, "clicked", (GCallback) set_visible_child, w2);
|
||||
|
||||
button = gtk_button_new_with_label ("3");
|
||||
gtk_container_add (GTK_CONTAINER (hbox), button);
|
||||
g_signal_connect (button, "clicked", (GCallback) set_visible_child, w3);
|
||||
|
||||
button = gtk_button_new_with_label ("1");
|
||||
gtk_container_add (GTK_CONTAINER (hbox), button);
|
||||
g_signal_connect (button, "clicked", (GCallback) set_visible_child_name, (gpointer) "1");
|
||||
|
||||
button = gtk_button_new_with_label ("2");
|
||||
gtk_container_add (GTK_CONTAINER (hbox), button);
|
||||
g_signal_connect (button, "clicked", (GCallback) set_visible_child_name, (gpointer) "2");
|
||||
|
||||
button = gtk_button_new_with_label ("3");
|
||||
gtk_container_add (GTK_CONTAINER (hbox), button);
|
||||
g_signal_connect (button, "clicked", (GCallback) set_visible_child_name, (gpointer) "3");
|
||||
|
||||
button = gtk_check_button_new_with_label ("homogeneous");
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
|
||||
gtk_stack_get_homogeneous (GTK_STACK (stack)));
|
||||
gtk_container_add (GTK_CONTAINER (hbox), button);
|
||||
g_signal_connect (button, "clicked", (GCallback) toggle_homogeneous, NULL);
|
||||
|
||||
button = gtk_toggle_button_new_with_label ("Add icon");
|
||||
g_signal_connect (button, "toggled", (GCallback) toggle_icon_name, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (hbox), button);
|
||||
|
||||
combo = gtk_combo_box_text_new ();
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "NONE");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "CROSSFADE");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "SLIDE_RIGHT");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "SLIDE_LEFT");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "SLIDE_UP");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "SLIDE_DOWN");
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (hbox), combo);
|
||||
g_signal_connect (combo, "changed", (GCallback) toggle_transitions, NULL);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_container_add (GTK_CONTAINER (box), hbox);
|
||||
|
||||
button = gtk_button_new_with_label ("<");
|
||||
g_signal_connect (button, "clicked", (GCallback) on_back_button_clicked, stack);
|
||||
g_signal_connect (stack, "notify::visible-child-name",
|
||||
(GCallback)update_back_button_sensitivity, button);
|
||||
gtk_container_add (GTK_CONTAINER (hbox), button);
|
||||
|
||||
button = gtk_button_new_with_label (">");
|
||||
gtk_container_add (GTK_CONTAINER (hbox), button);
|
||||
g_signal_connect (button, "clicked", (GCallback) on_forward_button_clicked, stack);
|
||||
g_signal_connect (stack, "notify::visible-child-name",
|
||||
(GCallback)update_forward_button_sensitivity, button);
|
||||
|
||||
|
||||
gtk_widget_show_all (window);
|
||||
gtk_main ();
|
||||
|
||||
gtk_widget_destroy (window);
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user