forked from AuroraMiddleware/gtk
496f0892fc
gtk_accel_group_query gtk_accel_group_from_accel_closure gtk_accel_label_get_accel_widget gtk_accessible_get_widget gtk_actionable_get_action_name gtk_app_chooser_get_app_info gtk_app_chooser_button_get_heading gtk_app_chooser_dialog_get_heading gtk_application_get_window_by_id gtk_assistant_get_nth_page gtk_binding_set_find gtk_builder_get_object gtk_builder_lookup_callback_symbol gtk_builder_get_application gtk_button_get_image gtk_cell_area_get_focus_from_sibling gtk_cell_renderer_start_editing gtk_cell_view_get_model gtk_cell_view_get_displayed_row gtk_clipboard_get_owner gtk_container_get_focus_child gtk_container_get_focus_vadjustment gtk_container_get_focus_hadjustment gtk_dialog_get_widget_for_response gtk_drag_get_source_widget gtk_drag_dest_get_target_list gtk_drag_source_get_target_list gtk_entry_completion_get_model gtk_entry_completion_compute_prefix gtk_expander_get_label_widget gtk_file_chooser_get_filename gtk_file_chooser_get_current_folder gtk_file_chooser_get_uri gtk_file_chooser_get_current_folder_uri gtk_file_chooser_get_preview_widget gtk_file_chooser_get_preview_file gtk_file_chooser_get_preview_filename gtk_file_chooser_get_preview_uri gtk_file_chooser_get_extra_widget gtk_file_chooser_get_filter gtk_file_chooser_native_get_accept_label gtk_file_chooser_native_get_cancel_label gtk_file_filter_get_name gtk_font_chooser_get_font_family gtk_font_chooser_get_font_face gtk_font_chooser_get_font gtk_font_chooser_get_font_desc gtk_font_chooser_get_font_map gtk_frame_get_label gtk_gesture_get_device gtk_gesture_get_window gtk_gl_area_get_error gtk_header_bar_get_title gtk_header_bar_get_subtitle gtk_header_bar_get_custom_title gtk_icon_info_get_filename gtk_icon_view_get_path_at_pos gtk_icon_view_get_model gtk_image_get_pixbuf gtk_image_get_animation gtk_label_get_mnemonic_widget gtk_label_get_attributes gtk_check_version gtk_menu_button_get_popup gtk_menu_button_get_menu_model gtk_menu_button_get_align_widget gtk_menu_button_get_popover gtk_menu_item_get_submenu gtk_menu_item_get_accel_path gtk_native_dialog_get_title gtk_native_dialog_get_transient_for gtk_notebook_get_nth_page gtk_notebook_get_tab_label_text gtk_notebook_get_menu_label gtk_notebook_get_menu_label_text gtk_notebook_get_group_name gtk_notebook_get_action_widget gtk_offscreen_window_get_surface gtk_offscreen_window_get_pixbuf gtk_paned_get_child1 gtk_paned_get_child2 gtk_places_sidebar_get_location gtk_places_sidebar_get_nth_bookmark gtk_plug_get_socket_window gtk_popover_get_default_widget gtk_progress_bar_get_text gtk_recent_filter_get_name gtk_recent_manager_lookup_item gtk_settings_get_default gtk_socket_get_plug_window gtk_stack_sidebar_get_stack gtk_stack_switcher_get_stack gtk_style_context_get_section gtk_style_context_get_parent gtk_style_context_get_frame_clock gtk_test_find_widget gtk_text_buffer_get_mark gtk_text_tag_table_lookup gtk_text_view_get_tabs gtk_text_view_toggle_cursor_visible gtk_text_view_get_window gtk_toolbar_get_nth_item gtk_tool_button_get_label gtk_tool_button_get_icon_name gtk_tool_button_get_label_widget gtk_tool_button_get_icon_widget gtk_tool_palette_get_drop_item gtk_tool_palette_get_drop_group gtk_tree_model_filter_convert_child_path_to_path gtk_tree_model_filter_convert_path_to_child_path gtk_tree_model_sort_convert_child_path_to_path gtk_tree_model_sort_convert_path_to_child_path gtk_tree_view_get_column gtk_tree_view_get_bin_window gtk_tree_view_column_get_widget gtk_tree_view_column_get_tree_view gtk_widget_get_frame_clock gtk_window_group_get_current_device_grab GtkTextBufferSerializeFunc
605 lines
17 KiB
C
605 lines
17 KiB
C
/*
|
|
* 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 "gtkradiobutton.h"
|
|
#include "gtklabel.h"
|
|
#include "gtkorientable.h"
|
|
#include "gtkprivate.h"
|
|
#include "gtkintl.h"
|
|
|
|
/**
|
|
* SECTION:gtkstackswitcher
|
|
* @Short_description: 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.
|
|
*
|
|
* # CSS nodes
|
|
*
|
|
* GtkStackSwitcher has a single CSS node named stackswitcher and
|
|
* style class .stack-switcher.
|
|
*
|
|
* When circumstances require it, GtkStackSwitcher adds the
|
|
* .needs-attention style class to the widgets representing the
|
|
* stack pages.
|
|
*/
|
|
|
|
typedef struct _GtkStackSwitcherPrivate GtkStackSwitcherPrivate;
|
|
struct _GtkStackSwitcherPrivate
|
|
{
|
|
GtkStack *stack;
|
|
GHashTable *buttons;
|
|
gint icon_size;
|
|
gboolean in_child_changed;
|
|
};
|
|
|
|
enum {
|
|
PROP_0,
|
|
PROP_ICON_SIZE,
|
|
PROP_STACK
|
|
};
|
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkStackSwitcher, gtk_stack_switcher, GTK_TYPE_BOX)
|
|
|
|
static void
|
|
gtk_stack_switcher_init (GtkStackSwitcher *switcher)
|
|
{
|
|
GtkStyleContext *context;
|
|
GtkStackSwitcherPrivate *priv;
|
|
|
|
priv = gtk_stack_switcher_get_instance_private (switcher);
|
|
|
|
priv->icon_size = GTK_ICON_SIZE_MENU;
|
|
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, "stack-switcher");
|
|
gtk_style_context_add_class (context, GTK_STYLE_CLASS_LINKED);
|
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (switcher), GTK_ORIENTATION_HORIZONTAL);
|
|
}
|
|
|
|
static void
|
|
on_button_clicked (GtkWidget *widget,
|
|
GtkStackSwitcher *self)
|
|
{
|
|
GtkWidget *child;
|
|
GtkStackSwitcherPrivate *priv;
|
|
|
|
priv = gtk_stack_switcher_get_instance_private (self);
|
|
|
|
if (!priv->in_child_changed)
|
|
{
|
|
child = g_object_get_data (G_OBJECT (widget), "stack-child");
|
|
gtk_stack_set_visible_child (priv->stack, child);
|
|
}
|
|
}
|
|
|
|
static void
|
|
rebuild_child (GtkWidget *self,
|
|
const gchar *icon_name,
|
|
const gchar *title,
|
|
gint icon_size)
|
|
{
|
|
GtkStyleContext *context;
|
|
GtkWidget *button_child;
|
|
|
|
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, icon_size);
|
|
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_widget_set_tooltip_text (GTK_WIDGET (self), NULL);
|
|
|
|
gtk_style_context_remove_class (context, "image-button");
|
|
gtk_style_context_add_class (context, "text-button");
|
|
}
|
|
|
|
if (button_child)
|
|
{
|
|
gtk_widget_set_halign (GTK_WIDGET (button_child), GTK_ALIGN_CENTER);
|
|
gtk_widget_show_all (button_child);
|
|
gtk_container_add (GTK_CONTAINER (self), button_child);
|
|
}
|
|
}
|
|
|
|
static void
|
|
update_needs_attention (GtkWidget *widget, GtkWidget *button, gpointer data)
|
|
{
|
|
GtkContainer *container;
|
|
gboolean needs_attention;
|
|
GtkStyleContext *context;
|
|
|
|
container = GTK_CONTAINER (data);
|
|
gtk_container_child_get (container, widget,
|
|
"needs-attention", &needs_attention,
|
|
NULL);
|
|
|
|
context = gtk_widget_get_style_context (button);
|
|
if (needs_attention)
|
|
gtk_style_context_add_class (context, GTK_STYLE_CLASS_NEEDS_ATTENTION);
|
|
else
|
|
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_NEEDS_ATTENTION);
|
|
}
|
|
|
|
static void
|
|
update_button (GtkStackSwitcher *self,
|
|
GtkWidget *widget,
|
|
GtkWidget *button)
|
|
{
|
|
gchar *title;
|
|
gchar *icon_name;
|
|
GtkStackSwitcherPrivate *priv;
|
|
|
|
priv = gtk_stack_switcher_get_instance_private (self);
|
|
|
|
gtk_container_child_get (GTK_CONTAINER (priv->stack), widget,
|
|
"title", &title,
|
|
"icon-name", &icon_name,
|
|
NULL);
|
|
|
|
rebuild_child (button, icon_name, title, priv->icon_size);
|
|
|
|
gtk_widget_set_visible (button, gtk_widget_get_visible (widget) && (title != NULL || icon_name != NULL));
|
|
|
|
g_free (title);
|
|
g_free (icon_name);
|
|
|
|
update_needs_attention (widget, button, priv->stack);
|
|
}
|
|
|
|
static void
|
|
on_title_icon_visible_updated (GtkWidget *widget,
|
|
GParamSpec *pspec,
|
|
GtkStackSwitcher *self)
|
|
{
|
|
GtkWidget *button;
|
|
GtkStackSwitcherPrivate *priv;
|
|
|
|
priv = gtk_stack_switcher_get_instance_private (self);
|
|
|
|
button = g_hash_table_lookup (priv->buttons, widget);
|
|
update_button (self, widget, button);
|
|
}
|
|
|
|
static void
|
|
on_position_updated (GtkWidget *widget,
|
|
GParamSpec *pspec,
|
|
GtkStackSwitcher *self)
|
|
{
|
|
GtkWidget *button;
|
|
gint position;
|
|
GtkStackSwitcherPrivate *priv;
|
|
|
|
priv = gtk_stack_switcher_get_instance_private (self);
|
|
|
|
button = g_hash_table_lookup (priv->buttons, widget);
|
|
|
|
gtk_container_child_get (GTK_CONTAINER (priv->stack), widget,
|
|
"position", &position,
|
|
NULL);
|
|
|
|
gtk_box_reorder_child (GTK_BOX (self), button, position);
|
|
}
|
|
|
|
static void
|
|
on_needs_attention_updated (GtkWidget *widget,
|
|
GParamSpec *pspec,
|
|
GtkStackSwitcher *self)
|
|
{
|
|
GtkWidget *button;
|
|
GtkStackSwitcherPrivate *priv;
|
|
|
|
priv = gtk_stack_switcher_get_instance_private (self);
|
|
|
|
button = g_hash_table_lookup (priv->buttons, widget);
|
|
update_button (self, widget, button);
|
|
}
|
|
|
|
static void
|
|
add_child (GtkWidget *widget,
|
|
GtkStackSwitcher *self)
|
|
{
|
|
GtkWidget *button;
|
|
GList *group;
|
|
GtkStackSwitcherPrivate *priv;
|
|
|
|
priv = gtk_stack_switcher_get_instance_private (self);
|
|
|
|
button = gtk_radio_button_new (NULL);
|
|
gtk_widget_set_focus_on_click (button, FALSE);
|
|
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, "notify::visible", G_CALLBACK (on_title_icon_visible_updated), self);
|
|
g_signal_connect (widget, "child-notify::title", G_CALLBACK (on_title_icon_visible_updated), self);
|
|
g_signal_connect (widget, "child-notify::icon-name", G_CALLBACK (on_title_icon_visible_updated), self);
|
|
g_signal_connect (widget, "child-notify::position", G_CALLBACK (on_position_updated), self);
|
|
g_signal_connect (widget, "child-notify::needs-attention", G_CALLBACK (on_needs_attention_updated), self);
|
|
|
|
g_hash_table_insert (priv->buttons, widget, button);
|
|
}
|
|
|
|
static void
|
|
remove_child (GtkWidget *widget,
|
|
GtkStackSwitcher *self)
|
|
{
|
|
GtkWidget *button;
|
|
GtkStackSwitcherPrivate *priv;
|
|
|
|
priv = gtk_stack_switcher_get_instance_private (self);
|
|
|
|
g_signal_handlers_disconnect_by_func (widget, on_title_icon_visible_updated, self);
|
|
g_signal_handlers_disconnect_by_func (widget, on_position_updated, self);
|
|
g_signal_handlers_disconnect_by_func (widget, on_needs_attention_updated, self);
|
|
|
|
button = g_hash_table_lookup (priv->buttons, widget);
|
|
gtk_container_remove (GTK_CONTAINER (self), button);
|
|
g_hash_table_remove (priv->buttons, widget);
|
|
}
|
|
|
|
static void
|
|
populate_switcher (GtkStackSwitcher *self)
|
|
{
|
|
GtkStackSwitcherPrivate *priv;
|
|
GtkWidget *widget, *button;
|
|
|
|
priv = gtk_stack_switcher_get_instance_private (self);
|
|
gtk_container_foreach (GTK_CONTAINER (priv->stack), (GtkCallback)add_child, self);
|
|
|
|
widget = gtk_stack_get_visible_child (priv->stack);
|
|
if (widget)
|
|
{
|
|
button = g_hash_table_lookup (priv->buttons, widget);
|
|
priv->in_child_changed = TRUE;
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
|
priv->in_child_changed = FALSE;
|
|
}
|
|
}
|
|
|
|
static void
|
|
clear_switcher (GtkStackSwitcher *self)
|
|
{
|
|
GtkStackSwitcherPrivate *priv;
|
|
|
|
priv = gtk_stack_switcher_get_instance_private (self);
|
|
gtk_container_foreach (GTK_CONTAINER (priv->stack), (GtkCallback)remove_child, self);
|
|
}
|
|
|
|
static void
|
|
on_child_changed (GtkWidget *widget,
|
|
GParamSpec *pspec,
|
|
GtkStackSwitcher *self)
|
|
{
|
|
GtkWidget *child;
|
|
GtkWidget *button;
|
|
GtkStackSwitcherPrivate *priv;
|
|
|
|
priv = gtk_stack_switcher_get_instance_private (self);
|
|
|
|
child = gtk_stack_get_visible_child (GTK_STACK (widget));
|
|
button = g_hash_table_lookup (priv->buttons, child);
|
|
if (button != NULL)
|
|
{
|
|
priv->in_child_changed = TRUE;
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
|
priv->in_child_changed = FALSE;
|
|
}
|
|
}
|
|
|
|
static void
|
|
on_stack_child_added (GtkContainer *container,
|
|
GtkWidget *widget,
|
|
GtkStackSwitcher *self)
|
|
{
|
|
add_child (widget, self);
|
|
}
|
|
|
|
static void
|
|
on_stack_child_removed (GtkContainer *container,
|
|
GtkWidget *widget,
|
|
GtkStackSwitcher *self)
|
|
{
|
|
remove_child (widget, self);
|
|
}
|
|
|
|
static void
|
|
disconnect_stack_signals (GtkStackSwitcher *switcher)
|
|
{
|
|
GtkStackSwitcherPrivate *priv;
|
|
|
|
priv = gtk_stack_switcher_get_instance_private (switcher);
|
|
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;
|
|
|
|
priv = gtk_stack_switcher_get_instance_private (switcher);
|
|
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));
|
|
g_return_if_fail (GTK_IS_STACK (stack) || stack == NULL);
|
|
|
|
priv = gtk_stack_switcher_get_instance_private (switcher);
|
|
|
|
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().
|
|
*
|
|
* Returns: (nullable) (transfer none): the stack, or %NULL if
|
|
* none has been set explicitly.
|
|
*
|
|
* Since: 3.10
|
|
*/
|
|
GtkStack *
|
|
gtk_stack_switcher_get_stack (GtkStackSwitcher *switcher)
|
|
{
|
|
GtkStackSwitcherPrivate *priv;
|
|
g_return_val_if_fail (GTK_IS_STACK_SWITCHER (switcher), NULL);
|
|
|
|
priv = gtk_stack_switcher_get_instance_private (switcher);
|
|
return priv->stack;
|
|
}
|
|
|
|
static void
|
|
gtk_stack_switcher_set_icon_size (GtkStackSwitcher *switcher,
|
|
gint icon_size)
|
|
{
|
|
GtkStackSwitcherPrivate *priv;
|
|
|
|
g_return_if_fail (GTK_IS_STACK_SWITCHER (switcher));
|
|
|
|
priv = gtk_stack_switcher_get_instance_private (switcher);
|
|
|
|
if (icon_size != priv->icon_size)
|
|
{
|
|
priv->icon_size = icon_size;
|
|
|
|
if (priv->stack != NULL)
|
|
{
|
|
clear_switcher (switcher);
|
|
populate_switcher (switcher);
|
|
}
|
|
|
|
g_object_notify (G_OBJECT (switcher), "icon-size");
|
|
}
|
|
}
|
|
|
|
static void
|
|
gtk_stack_switcher_get_property (GObject *object,
|
|
guint prop_id,
|
|
GValue *value,
|
|
GParamSpec *pspec)
|
|
{
|
|
GtkStackSwitcher *switcher = GTK_STACK_SWITCHER (object);
|
|
GtkStackSwitcherPrivate *priv;
|
|
|
|
priv = gtk_stack_switcher_get_instance_private (switcher);
|
|
switch (prop_id)
|
|
{
|
|
case PROP_ICON_SIZE:
|
|
g_value_set_int (value, priv->icon_size);
|
|
break;
|
|
|
|
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_ICON_SIZE:
|
|
gtk_stack_switcher_set_icon_size (switcher, g_value_get_int (value));
|
|
break;
|
|
|
|
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_finalize (GObject *object)
|
|
{
|
|
GtkStackSwitcher *switcher = GTK_STACK_SWITCHER (object);
|
|
GtkStackSwitcherPrivate *priv;
|
|
|
|
priv = gtk_stack_switcher_get_instance_private (switcher);
|
|
|
|
g_hash_table_destroy (priv->buttons);
|
|
|
|
G_OBJECT_CLASS (gtk_stack_switcher_parent_class)->finalize (object);
|
|
}
|
|
|
|
static void
|
|
gtk_stack_switcher_class_init (GtkStackSwitcherClass *class)
|
|
{
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_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;
|
|
object_class->finalize = gtk_stack_switcher_finalize;
|
|
|
|
/**
|
|
* GtkStackSwitcher:icon-size:
|
|
*
|
|
* Use the "icon-size" property to change the size of the image displayed
|
|
* when a #GtkStackSwitcher is displaying icons.
|
|
*
|
|
* Since: 3.20
|
|
*/
|
|
g_object_class_install_property (object_class,
|
|
PROP_ICON_SIZE,
|
|
g_param_spec_int ("icon-size",
|
|
P_("Icon Size"),
|
|
P_("Symbolic size to use for named icon"),
|
|
0, G_MAXINT,
|
|
GTK_ICON_SIZE_MENU,
|
|
G_PARAM_EXPLICIT_NOTIFY | GTK_PARAM_READWRITE));
|
|
|
|
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));
|
|
|
|
gtk_widget_class_set_css_name (widget_class, "stackswitcher");
|
|
}
|
|
|
|
/**
|
|
* gtk_stack_switcher_new:
|
|
*
|
|
* Create a new #GtkStackSwitcher.
|
|
*
|
|
* Returns: a new #GtkStackSwitcher.
|
|
*
|
|
* Since: 3.10
|
|
*/
|
|
GtkWidget *
|
|
gtk_stack_switcher_new (void)
|
|
{
|
|
return g_object_new (GTK_TYPE_STACK_SWITCHER, NULL);
|
|
}
|