mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 14:10:30 +00:00
Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master See merge request GNOME/gtk!1768
This commit is contained in:
commit
7da995da1d
File diff suppressed because it is too large
Load Diff
@ -41,21 +41,12 @@
|
||||
#include "gtkactionable.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
|
||||
typedef struct _GtkFontChooserDialogPrivate GtkFontChooserDialogPrivate;
|
||||
typedef struct _GtkFontChooserDialogClass GtkFontChooserDialogClass;
|
||||
typedef struct _GtkFontChooserDialogClass GtkFontChooserDialogClass;
|
||||
|
||||
struct _GtkFontChooserDialog
|
||||
{
|
||||
GtkDialog parent_instance;
|
||||
};
|
||||
|
||||
struct _GtkFontChooserDialogClass
|
||||
{
|
||||
GtkDialogClass parent_class;
|
||||
};
|
||||
|
||||
struct _GtkFontChooserDialogPrivate
|
||||
{
|
||||
GtkWidget *fontchooser;
|
||||
|
||||
GtkWidget *select_button;
|
||||
@ -63,6 +54,11 @@ struct _GtkFontChooserDialogPrivate
|
||||
GtkWidget *tweak_button;
|
||||
};
|
||||
|
||||
struct _GtkFontChooserDialogClass
|
||||
{
|
||||
GtkDialogClass parent_class;
|
||||
};
|
||||
|
||||
/**
|
||||
* SECTION:gtkfontchooserdialog
|
||||
* @Short_description: A dialog for selecting fonts
|
||||
@ -85,7 +81,6 @@ static GObject *gtk_font_chooser_dialog_buildable_get_internal_child (GtkBuildab
|
||||
const gchar *childname);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkFontChooserDialog, gtk_font_chooser_dialog, GTK_TYPE_DIALOG,
|
||||
G_ADD_PRIVATE (GtkFontChooserDialog)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_FONT_CHOOSER,
|
||||
_gtk_font_chooser_delegate_iface_init)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
||||
@ -100,12 +95,11 @@ gtk_font_chooser_dialog_set_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkFontChooserDialog *dialog = GTK_FONT_CHOOSER_DIALOG (object);
|
||||
GtkFontChooserDialogPrivate *priv = gtk_font_chooser_dialog_get_instance_private (dialog);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
default:
|
||||
g_object_set_property (G_OBJECT (priv->fontchooser), pspec->name, value);
|
||||
g_object_set_property (G_OBJECT (dialog->fontchooser), pspec->name, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -117,12 +111,11 @@ gtk_font_chooser_dialog_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkFontChooserDialog *dialog = GTK_FONT_CHOOSER_DIALOG (object);
|
||||
GtkFontChooserDialogPrivate *priv = gtk_font_chooser_dialog_get_instance_private (dialog);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
default:
|
||||
g_object_get_property (G_OBJECT (priv->fontchooser), pspec->name, value);
|
||||
g_object_get_property (G_OBJECT (dialog->fontchooser), pspec->name, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -145,34 +138,31 @@ dialog_forward_key (GtkEventControllerKey *controller,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkFontChooserDialog *dialog = GTK_FONT_CHOOSER_DIALOG (widget);
|
||||
GtkFontChooserDialogPrivate *priv = gtk_font_chooser_dialog_get_instance_private (dialog);
|
||||
|
||||
return gtk_event_controller_key_forward (controller, priv->fontchooser);
|
||||
return gtk_event_controller_key_forward (controller, dialog->fontchooser);
|
||||
}
|
||||
|
||||
static void
|
||||
update_tweak_button (GtkFontChooserDialog *dialog)
|
||||
{
|
||||
GtkFontChooserDialogPrivate *priv = gtk_font_chooser_dialog_get_instance_private (dialog);
|
||||
GtkFontChooserLevel level;
|
||||
|
||||
if (!priv->tweak_button)
|
||||
if (!dialog->tweak_button)
|
||||
return;
|
||||
|
||||
g_object_get (priv->fontchooser, "level", &level, NULL);
|
||||
g_object_get (dialog->fontchooser, "level", &level, NULL);
|
||||
if ((level & (GTK_FONT_CHOOSER_LEVEL_FEATURES | GTK_FONT_CHOOSER_LEVEL_VARIATIONS)) != 0)
|
||||
gtk_widget_show (priv->tweak_button);
|
||||
gtk_widget_show (dialog->tweak_button);
|
||||
else
|
||||
gtk_widget_hide (priv->tweak_button);
|
||||
gtk_widget_hide (dialog->tweak_button);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_tweak_button (GtkFontChooserDialog *dialog)
|
||||
{
|
||||
GtkFontChooserDialogPrivate *priv = gtk_font_chooser_dialog_get_instance_private (dialog);
|
||||
gboolean use_header;
|
||||
|
||||
if (priv->tweak_button)
|
||||
if (dialog->tweak_button)
|
||||
return;
|
||||
|
||||
g_object_get (dialog, "use-header-bar", &use_header, NULL);
|
||||
@ -183,7 +173,7 @@ setup_tweak_button (GtkFontChooserDialog *dialog)
|
||||
GActionGroup *actions;
|
||||
|
||||
actions = G_ACTION_GROUP (g_simple_action_group_new ());
|
||||
g_action_map_add_action (G_ACTION_MAP (actions), gtk_font_chooser_widget_get_tweak_action (priv->fontchooser));
|
||||
g_action_map_add_action (G_ACTION_MAP (actions), gtk_font_chooser_widget_get_tweak_action (dialog->fontchooser));
|
||||
gtk_widget_insert_action_group (GTK_WIDGET (dialog), "font", actions);
|
||||
g_object_unref (actions);
|
||||
|
||||
@ -196,7 +186,7 @@ setup_tweak_button (GtkFontChooserDialog *dialog)
|
||||
header = gtk_dialog_get_header_bar (GTK_DIALOG (dialog));
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
|
||||
|
||||
priv->tweak_button = button;
|
||||
dialog->tweak_button = button;
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,9 +218,9 @@ gtk_font_chooser_dialog_class_init (GtkFontChooserDialogClass *klass)
|
||||
gtk_widget_class_set_template_from_resource (widget_class,
|
||||
"/org/gtk/libgtk/ui/gtkfontchooserdialog.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkFontChooserDialog, fontchooser);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkFontChooserDialog, select_button);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkFontChooserDialog, cancel_button);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkFontChooserDialog, fontchooser);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkFontChooserDialog, select_button);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkFontChooserDialog, cancel_button);
|
||||
gtk_widget_class_bind_template_callback (widget_class, font_activated_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, dialog_forward_key);
|
||||
}
|
||||
@ -238,12 +228,11 @@ gtk_font_chooser_dialog_class_init (GtkFontChooserDialogClass *klass)
|
||||
static void
|
||||
update_button (GtkFontChooserDialog *dialog)
|
||||
{
|
||||
GtkFontChooserDialogPrivate *priv = gtk_font_chooser_dialog_get_instance_private (dialog);
|
||||
PangoFontDescription *desc;
|
||||
|
||||
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (priv->fontchooser));
|
||||
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (dialog->fontchooser));
|
||||
|
||||
gtk_widget_set_sensitive (priv->select_button, desc != NULL);
|
||||
gtk_widget_set_sensitive (dialog->select_button, desc != NULL);
|
||||
|
||||
if (desc)
|
||||
pango_font_description_free (desc);
|
||||
@ -251,21 +240,19 @@ update_button (GtkFontChooserDialog *dialog)
|
||||
|
||||
|
||||
static void
|
||||
gtk_font_chooser_dialog_init (GtkFontChooserDialog *fontchooserdiag)
|
||||
gtk_font_chooser_dialog_init (GtkFontChooserDialog *dialog)
|
||||
{
|
||||
GtkFontChooserDialogPrivate *priv = gtk_font_chooser_dialog_get_instance_private (fontchooserdiag);
|
||||
gtk_widget_init_template (GTK_WIDGET (dialog));
|
||||
gtk_dialog_set_use_header_bar_from_setting (GTK_DIALOG (dialog));
|
||||
|
||||
gtk_widget_init_template (GTK_WIDGET (fontchooserdiag));
|
||||
gtk_dialog_set_use_header_bar_from_setting (GTK_DIALOG (fontchooserdiag));
|
||||
_gtk_font_chooser_set_delegate (GTK_FONT_CHOOSER (dialog),
|
||||
GTK_FONT_CHOOSER (dialog->fontchooser));
|
||||
|
||||
_gtk_font_chooser_set_delegate (GTK_FONT_CHOOSER (fontchooserdiag),
|
||||
GTK_FONT_CHOOSER (priv->fontchooser));
|
||||
|
||||
g_signal_connect_swapped (priv->fontchooser, "notify::font-desc",
|
||||
G_CALLBACK (update_button), fontchooserdiag);
|
||||
update_button (fontchooserdiag);
|
||||
g_signal_connect_swapped (priv->fontchooser, "notify::level",
|
||||
G_CALLBACK (update_tweak_button), fontchooserdiag);
|
||||
g_signal_connect_swapped (dialog->fontchooser, "notify::font-desc",
|
||||
G_CALLBACK (update_button), dialog);
|
||||
update_button (dialog);
|
||||
g_signal_connect_swapped (dialog->fontchooser, "notify::level",
|
||||
G_CALLBACK (update_tweak_button), dialog);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -304,12 +291,11 @@ gtk_font_chooser_dialog_buildable_get_internal_child (GtkBuildable *buildable,
|
||||
const gchar *childname)
|
||||
{
|
||||
GtkFontChooserDialog *dialog = GTK_FONT_CHOOSER_DIALOG (buildable);
|
||||
GtkFontChooserDialogPrivate *priv = gtk_font_chooser_dialog_get_instance_private (dialog);
|
||||
|
||||
if (g_strcmp0 (childname, "select_button") == 0)
|
||||
return G_OBJECT (priv->select_button);
|
||||
return G_OBJECT (dialog->select_button);
|
||||
else if (g_strcmp0 (childname, "cancel_button") == 0)
|
||||
return G_OBJECT (priv->cancel_button);
|
||||
return G_OBJECT (dialog->cancel_button);
|
||||
|
||||
return parent_buildable_iface->get_internal_child (buildable, builder, childname);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -73,12 +73,15 @@
|
||||
#include <string.h>
|
||||
|
||||
typedef struct _GtkLinkButtonClass GtkLinkButtonClass;
|
||||
typedef struct _GtkLinkButtonPrivate GtkLinkButtonPrivate;
|
||||
|
||||
struct _GtkLinkButton
|
||||
{
|
||||
/*< private >*/
|
||||
GtkButton parent_instance;
|
||||
|
||||
char *uri;
|
||||
gboolean visited;
|
||||
GtkWidget *popup_menu;
|
||||
};
|
||||
|
||||
struct _GtkLinkButtonClass
|
||||
@ -90,15 +93,6 @@ struct _GtkLinkButtonClass
|
||||
gboolean (* activate_link) (GtkLinkButton *button);
|
||||
};
|
||||
|
||||
struct _GtkLinkButtonPrivate
|
||||
{
|
||||
gchar *uri;
|
||||
|
||||
gboolean visited;
|
||||
|
||||
GtkWidget *popup_menu;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
@ -147,7 +141,7 @@ static const char *link_drop_types[] = {
|
||||
|
||||
static guint link_signals[LAST_SIGNAL] = { 0, };
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkLinkButton, gtk_link_button, GTK_TYPE_BUTTON)
|
||||
G_DEFINE_TYPE (GtkLinkButton, gtk_link_button, GTK_TYPE_BUTTON)
|
||||
|
||||
static void
|
||||
gtk_link_button_activate_clipboard_copy (GtkWidget *widget,
|
||||
@ -155,9 +149,8 @@ gtk_link_button_activate_clipboard_copy (GtkWidget *widget,
|
||||
GVariant *parameter)
|
||||
{
|
||||
GtkLinkButton *link_button = GTK_LINK_BUTTON (widget);
|
||||
GtkLinkButtonPrivate *priv = gtk_link_button_get_instance_private (link_button);
|
||||
|
||||
gdk_clipboard_set_text (gtk_widget_get_clipboard (widget), priv->uri);
|
||||
gdk_clipboard_set_text (gtk_widget_get_clipboard (widget), link_button->uri);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -311,10 +304,9 @@ gtk_link_content_get_value (GdkContentProvider *provider,
|
||||
if (G_VALUE_HOLDS (value, G_TYPE_STRING) &&
|
||||
content->link != NULL)
|
||||
{
|
||||
GtkLinkButtonPrivate *priv = gtk_link_button_get_instance_private (content->link);
|
||||
char *uri;
|
||||
|
||||
uri = g_strdup_printf ("%s\r\n", priv->uri);
|
||||
uri = g_strdup_printf ("%s\r\n", content->link->uri);
|
||||
g_value_set_string (value, uri);
|
||||
g_free (uri);
|
||||
|
||||
@ -376,11 +368,10 @@ static void
|
||||
gtk_link_button_finalize (GObject *object)
|
||||
{
|
||||
GtkLinkButton *link_button = GTK_LINK_BUTTON (object);
|
||||
GtkLinkButtonPrivate *priv = gtk_link_button_get_instance_private (link_button);
|
||||
|
||||
g_free (priv->uri);
|
||||
g_free (link_button->uri);
|
||||
|
||||
g_clear_pointer (&priv->popup_menu, gtk_widget_unparent);
|
||||
g_clear_pointer (&link_button->popup_menu, gtk_widget_unparent);
|
||||
|
||||
G_OBJECT_CLASS (gtk_link_button_parent_class)->finalize (object);
|
||||
}
|
||||
@ -392,15 +383,14 @@ gtk_link_button_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkLinkButton *link_button = GTK_LINK_BUTTON (object);
|
||||
GtkLinkButtonPrivate *priv = gtk_link_button_get_instance_private (link_button);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_URI:
|
||||
g_value_set_string (value, priv->uri);
|
||||
g_value_set_string (value, link_button->uri);
|
||||
break;
|
||||
case PROP_VISITED:
|
||||
g_value_set_boolean (value, priv->visited);
|
||||
g_value_set_boolean (value, link_button->visited);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -435,19 +425,17 @@ gtk_link_button_do_popup (GtkLinkButton *link_button,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkLinkButtonPrivate *priv = gtk_link_button_get_instance_private (link_button);
|
||||
|
||||
if (!priv->popup_menu)
|
||||
if (!link_button->popup_menu)
|
||||
{
|
||||
GMenuModel *model;
|
||||
|
||||
model = gtk_link_button_get_menu_model ();
|
||||
priv->popup_menu = gtk_popover_menu_new_from_model (model);
|
||||
gtk_widget_set_parent (priv->popup_menu, GTK_WIDGET (link_button));
|
||||
gtk_popover_set_position (GTK_POPOVER (priv->popup_menu), GTK_POS_BOTTOM);
|
||||
link_button->popup_menu = gtk_popover_menu_new_from_model (model);
|
||||
gtk_widget_set_parent (link_button->popup_menu, GTK_WIDGET (link_button));
|
||||
gtk_popover_set_position (GTK_POPOVER (link_button->popup_menu), GTK_POS_BOTTOM);
|
||||
|
||||
gtk_popover_set_has_arrow (GTK_POPOVER (priv->popup_menu), FALSE);
|
||||
gtk_widget_set_halign (priv->popup_menu, GTK_ALIGN_START);
|
||||
gtk_popover_set_has_arrow (GTK_POPOVER (link_button->popup_menu), FALSE);
|
||||
gtk_widget_set_halign (link_button->popup_menu, GTK_ALIGN_START);
|
||||
|
||||
g_object_unref (model);
|
||||
}
|
||||
@ -455,12 +443,12 @@ gtk_link_button_do_popup (GtkLinkButton *link_button,
|
||||
if (x != -1 && y != -1)
|
||||
{
|
||||
GdkRectangle rect = { x, y, 1, 1 };
|
||||
gtk_popover_set_pointing_to (GTK_POPOVER (priv->popup_menu), &rect);
|
||||
gtk_popover_set_pointing_to (GTK_POPOVER (link_button->popup_menu), &rect);
|
||||
}
|
||||
else
|
||||
gtk_popover_set_pointing_to (GTK_POPOVER (priv->popup_menu), NULL);
|
||||
gtk_popover_set_pointing_to (GTK_POPOVER (link_button->popup_menu), NULL);
|
||||
|
||||
gtk_popover_popup (GTK_POPOVER (priv->popup_menu));
|
||||
gtk_popover_popup (GTK_POPOVER (link_button->popup_menu));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -471,7 +459,6 @@ gtk_link_button_pressed_cb (GtkGestureClick *gesture,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkLinkButton *link_button = user_data;
|
||||
GtkLinkButtonPrivate *priv = gtk_link_button_get_instance_private (link_button);
|
||||
GdkEventSequence *sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
||||
GdkEvent *event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
|
||||
|
||||
@ -479,7 +466,7 @@ gtk_link_button_pressed_cb (GtkGestureClick *gesture,
|
||||
gtk_widget_grab_focus (GTK_WIDGET (link_button));
|
||||
|
||||
if (gdk_event_triggers_context_menu (event) &&
|
||||
priv->uri != NULL)
|
||||
link_button->uri != NULL)
|
||||
{
|
||||
gtk_link_button_do_popup (link_button, x, y);
|
||||
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
||||
@ -493,12 +480,11 @@ gtk_link_button_pressed_cb (GtkGestureClick *gesture,
|
||||
static gboolean
|
||||
gtk_link_button_activate_link (GtkLinkButton *link_button)
|
||||
{
|
||||
GtkLinkButtonPrivate *priv = gtk_link_button_get_instance_private (link_button);
|
||||
GtkWidget *toplevel;
|
||||
|
||||
toplevel = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (link_button)));
|
||||
|
||||
gtk_show_uri (GTK_WINDOW (toplevel), priv->uri, GDK_CURRENT_TIME);
|
||||
gtk_show_uri (GTK_WINDOW (toplevel), link_button->uri, GDK_CURRENT_TIME);
|
||||
gtk_link_button_set_visited (link_button, TRUE);
|
||||
|
||||
return TRUE;
|
||||
@ -604,12 +590,11 @@ gtk_link_button_query_tooltip_cb (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GtkLinkButton *link_button = GTK_LINK_BUTTON (widget);
|
||||
GtkLinkButtonPrivate *priv = gtk_link_button_get_instance_private (link_button);
|
||||
const gchar *label, *uri;
|
||||
gchar *text, *markup;
|
||||
|
||||
label = gtk_button_get_label (GTK_BUTTON (link_button));
|
||||
uri = priv->uri;
|
||||
uri = link_button->uri;
|
||||
text = gtk_widget_get_tooltip_text (widget);
|
||||
markup = gtk_widget_get_tooltip_markup (widget);
|
||||
|
||||
@ -641,13 +626,11 @@ void
|
||||
gtk_link_button_set_uri (GtkLinkButton *link_button,
|
||||
const gchar *uri)
|
||||
{
|
||||
GtkLinkButtonPrivate *priv = gtk_link_button_get_instance_private (link_button);
|
||||
|
||||
g_return_if_fail (GTK_IS_LINK_BUTTON (link_button));
|
||||
g_return_if_fail (uri != NULL);
|
||||
|
||||
g_free (priv->uri);
|
||||
priv->uri = g_strdup (uri);
|
||||
g_free (link_button->uri);
|
||||
link_button->uri = g_strdup (uri);
|
||||
|
||||
g_object_notify (G_OBJECT (link_button), "uri");
|
||||
|
||||
@ -666,11 +649,9 @@ gtk_link_button_set_uri (GtkLinkButton *link_button,
|
||||
const gchar *
|
||||
gtk_link_button_get_uri (GtkLinkButton *link_button)
|
||||
{
|
||||
GtkLinkButtonPrivate *priv = gtk_link_button_get_instance_private (link_button);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_LINK_BUTTON (link_button), NULL);
|
||||
|
||||
return priv->uri;
|
||||
return link_button->uri;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -685,15 +666,13 @@ void
|
||||
gtk_link_button_set_visited (GtkLinkButton *link_button,
|
||||
gboolean visited)
|
||||
{
|
||||
GtkLinkButtonPrivate *priv = gtk_link_button_get_instance_private (link_button);
|
||||
|
||||
g_return_if_fail (GTK_IS_LINK_BUTTON (link_button));
|
||||
|
||||
visited = visited != FALSE;
|
||||
|
||||
if (priv->visited != visited)
|
||||
if (link_button->visited != visited)
|
||||
{
|
||||
priv->visited = visited;
|
||||
link_button->visited = visited;
|
||||
|
||||
if (visited)
|
||||
{
|
||||
@ -725,9 +704,7 @@ gtk_link_button_set_visited (GtkLinkButton *link_button,
|
||||
gboolean
|
||||
gtk_link_button_get_visited (GtkLinkButton *link_button)
|
||||
{
|
||||
GtkLinkButtonPrivate *priv = gtk_link_button_get_instance_private (link_button);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_LINK_BUTTON (link_button), FALSE);
|
||||
|
||||
return priv->visited;
|
||||
return link_button->visited;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static void gtk_overlay_buildable_init (GtkBuildableIface *iface);
|
||||
|
||||
typedef struct _GtkOverlayClass GtkOverlayClass;
|
||||
typedef struct _GtkOverlayClass GtkOverlayClass;
|
||||
|
||||
struct _GtkOverlay
|
||||
{
|
||||
@ -91,12 +91,7 @@ struct _GtkOverlayClass
|
||||
GtkAllocation *allocation);
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
GtkLayoutManager *layout;
|
||||
} GtkOverlayPrivate;
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkOverlay, gtk_overlay, GTK_TYPE_BIN,
|
||||
G_ADD_PRIVATE (GtkOverlay)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
||||
gtk_overlay_buildable_init))
|
||||
|
||||
@ -331,9 +326,6 @@ gtk_overlay_class_init (GtkOverlayClass *klass)
|
||||
static void
|
||||
gtk_overlay_init (GtkOverlay *overlay)
|
||||
{
|
||||
GtkOverlayPrivate *priv = gtk_overlay_get_instance_private (overlay);
|
||||
|
||||
priv->layout = gtk_widget_get_layout_manager (GTK_WIDGET (overlay));
|
||||
}
|
||||
|
||||
static GtkBuildableIface *parent_buildable_iface;
|
||||
@ -424,13 +416,14 @@ gtk_overlay_set_measure_overlay (GtkOverlay *overlay,
|
||||
GtkWidget *widget,
|
||||
gboolean measure)
|
||||
{
|
||||
GtkOverlayPrivate *priv = gtk_overlay_get_instance_private (overlay);
|
||||
GtkLayoutManager *layout;
|
||||
GtkOverlayLayoutChild *child;
|
||||
|
||||
g_return_if_fail (GTK_IS_OVERLAY (overlay));
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
child = GTK_OVERLAY_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout, widget));
|
||||
layout = gtk_widget_get_layout_manager (GTK_WIDGET (overlay));
|
||||
child = GTK_OVERLAY_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (layout, widget));
|
||||
gtk_overlay_layout_child_set_measure (child, measure);
|
||||
}
|
||||
|
||||
@ -448,13 +441,14 @@ gboolean
|
||||
gtk_overlay_get_measure_overlay (GtkOverlay *overlay,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkOverlayPrivate *priv = gtk_overlay_get_instance_private (overlay);
|
||||
GtkLayoutManager *layout;
|
||||
GtkOverlayLayoutChild *child;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_OVERLAY (overlay), FALSE);
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
|
||||
|
||||
child = GTK_OVERLAY_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout, widget));
|
||||
layout = gtk_widget_get_layout_manager (GTK_WIDGET (overlay));
|
||||
child = GTK_OVERLAY_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (layout, widget));
|
||||
return gtk_overlay_layout_child_get_measure (child);
|
||||
}
|
||||
|
||||
@ -472,13 +466,14 @@ gtk_overlay_set_clip_overlay (GtkOverlay *overlay,
|
||||
GtkWidget *widget,
|
||||
gboolean clip_overlay)
|
||||
{
|
||||
GtkOverlayPrivate *priv = gtk_overlay_get_instance_private (overlay);
|
||||
GtkLayoutManager *layout;
|
||||
GtkOverlayLayoutChild *child;
|
||||
|
||||
g_return_if_fail (GTK_IS_OVERLAY (overlay));
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
child = GTK_OVERLAY_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout, widget));
|
||||
layout = gtk_widget_get_layout_manager (GTK_WIDGET (overlay));
|
||||
child = GTK_OVERLAY_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (layout, widget));
|
||||
gtk_overlay_layout_child_set_clip_overlay (child, clip_overlay);
|
||||
}
|
||||
|
||||
@ -496,13 +491,14 @@ gboolean
|
||||
gtk_overlay_get_clip_overlay (GtkOverlay *overlay,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkOverlayPrivate *priv = gtk_overlay_get_instance_private (overlay);
|
||||
GtkLayoutManager *layout;
|
||||
GtkOverlayLayoutChild *child;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_OVERLAY (overlay), FALSE);
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
|
||||
|
||||
child = GTK_OVERLAY_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout, widget));
|
||||
layout = gtk_widget_get_layout_manager (GTK_WIDGET (overlay));
|
||||
child = GTK_OVERLAY_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (layout, widget));
|
||||
|
||||
return gtk_overlay_layout_child_get_clip_overlay (child);
|
||||
}
|
||||
|
@ -96,16 +96,7 @@ typedef struct _GtkProgressBarClass GtkProgressBarClass;
|
||||
struct _GtkProgressBar
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
};
|
||||
|
||||
struct _GtkProgressBarClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gchar *text;
|
||||
|
||||
GtkWidget *label;
|
||||
@ -131,7 +122,12 @@ typedef struct
|
||||
guint ellipsize : 3;
|
||||
guint show_text : 1;
|
||||
guint inverted : 1;
|
||||
} GtkProgressBarPrivate;
|
||||
};
|
||||
|
||||
struct _GtkProgressBarClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
@ -164,7 +160,6 @@ static void gtk_progress_bar_direction_changed (GtkWidget *widget,
|
||||
GtkTextDirection previous_dir);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkProgressBar, gtk_progress_bar, GTK_TYPE_WIDGET,
|
||||
G_ADD_PRIVATE (GtkProgressBar)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL))
|
||||
|
||||
static void
|
||||
@ -267,37 +262,35 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
|
||||
static void
|
||||
update_fraction_classes (GtkProgressBar *pbar)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
gboolean empty = FALSE;
|
||||
gboolean full = FALSE;
|
||||
|
||||
/* Here we set classes based on fill-level unless we're in activity-mode.
|
||||
*/
|
||||
|
||||
if (!priv->activity_mode)
|
||||
if (!pbar->activity_mode)
|
||||
{
|
||||
if (priv->fraction <= 0.0)
|
||||
if (pbar->fraction <= 0.0)
|
||||
empty = TRUE;
|
||||
else if (priv->fraction >= 1.0)
|
||||
else if (pbar->fraction >= 1.0)
|
||||
full = TRUE;
|
||||
}
|
||||
|
||||
if (empty)
|
||||
gtk_widget_add_css_class (priv->trough_widget, "empty");
|
||||
gtk_widget_add_css_class (pbar->trough_widget, "empty");
|
||||
else
|
||||
gtk_widget_remove_css_class (priv->trough_widget, "empty");
|
||||
gtk_widget_remove_css_class (pbar->trough_widget, "empty");
|
||||
|
||||
if (full)
|
||||
gtk_widget_add_css_class (priv->trough_widget, "full");
|
||||
gtk_widget_add_css_class (pbar->trough_widget, "full");
|
||||
else
|
||||
gtk_widget_remove_css_class (priv->trough_widget, "full");
|
||||
gtk_widget_remove_css_class (pbar->trough_widget, "full");
|
||||
}
|
||||
|
||||
static void
|
||||
update_node_classes (GtkProgressBar *pbar)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
gboolean left = FALSE;
|
||||
gboolean left = FALSE;
|
||||
gboolean right = FALSE;
|
||||
gboolean top = FALSE;
|
||||
gboolean bottom = FALSE;
|
||||
@ -306,61 +299,61 @@ update_node_classes (GtkProgressBar *pbar)
|
||||
* progressbar the progress touches.
|
||||
*/
|
||||
|
||||
if (priv->activity_mode)
|
||||
if (pbar->activity_mode)
|
||||
{
|
||||
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
if (pbar->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
left = priv->activity_pos <= 0.0;
|
||||
right = priv->activity_pos >= 1.0;
|
||||
left = pbar->activity_pos <= 0.0;
|
||||
right = pbar->activity_pos >= 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
top = priv->activity_pos <= 0.0;
|
||||
bottom = priv->activity_pos >= 1.0;
|
||||
top = pbar->activity_pos <= 0.0;
|
||||
bottom = pbar->activity_pos >= 1.0;
|
||||
}
|
||||
}
|
||||
else /* continuous */
|
||||
{
|
||||
gboolean inverted;
|
||||
|
||||
inverted = priv->inverted;
|
||||
inverted = pbar->inverted;
|
||||
if (gtk_widget_get_direction (GTK_WIDGET (pbar)) == GTK_TEXT_DIR_RTL)
|
||||
{
|
||||
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
if (pbar->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
inverted = !inverted;
|
||||
}
|
||||
|
||||
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
if (pbar->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
left = !inverted || priv->fraction >= 1.0;
|
||||
right = inverted || priv->fraction >= 1.0;
|
||||
left = !inverted || pbar->fraction >= 1.0;
|
||||
right = inverted || pbar->fraction >= 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
top = !inverted || priv->fraction >= 1.0;
|
||||
bottom = inverted || priv->fraction >= 1.0;
|
||||
top = !inverted || pbar->fraction >= 1.0;
|
||||
bottom = inverted || pbar->fraction >= 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
if (left)
|
||||
gtk_widget_add_css_class (priv->progress_widget, GTK_STYLE_CLASS_LEFT);
|
||||
gtk_widget_add_css_class (pbar->progress_widget, GTK_STYLE_CLASS_LEFT);
|
||||
else
|
||||
gtk_widget_remove_css_class (priv->progress_widget, GTK_STYLE_CLASS_LEFT);
|
||||
gtk_widget_remove_css_class (pbar->progress_widget, GTK_STYLE_CLASS_LEFT);
|
||||
|
||||
if (right)
|
||||
gtk_widget_add_css_class (priv->progress_widget, GTK_STYLE_CLASS_RIGHT);
|
||||
gtk_widget_add_css_class (pbar->progress_widget, GTK_STYLE_CLASS_RIGHT);
|
||||
else
|
||||
gtk_widget_remove_css_class (priv->progress_widget, GTK_STYLE_CLASS_RIGHT);
|
||||
gtk_widget_remove_css_class (pbar->progress_widget, GTK_STYLE_CLASS_RIGHT);
|
||||
|
||||
if (top)
|
||||
gtk_widget_add_css_class (priv->progress_widget, GTK_STYLE_CLASS_TOP);
|
||||
gtk_widget_add_css_class (pbar->progress_widget, GTK_STYLE_CLASS_TOP);
|
||||
else
|
||||
gtk_widget_remove_css_class (priv->progress_widget, GTK_STYLE_CLASS_TOP);
|
||||
gtk_widget_remove_css_class (pbar->progress_widget, GTK_STYLE_CLASS_TOP);
|
||||
|
||||
if (bottom)
|
||||
gtk_widget_add_css_class (priv->progress_widget, GTK_STYLE_CLASS_BOTTOM);
|
||||
gtk_widget_add_css_class (pbar->progress_widget, GTK_STYLE_CLASS_BOTTOM);
|
||||
else
|
||||
gtk_widget_remove_css_class (priv->progress_widget, GTK_STYLE_CLASS_BOTTOM);
|
||||
gtk_widget_remove_css_class (pbar->progress_widget, GTK_STYLE_CLASS_BOTTOM);
|
||||
|
||||
update_fraction_classes (pbar);
|
||||
}
|
||||
@ -373,49 +366,48 @@ allocate_trough (GtkGizmo *gizmo,
|
||||
|
||||
{
|
||||
GtkProgressBar *pbar = GTK_PROGRESS_BAR (gtk_widget_get_parent (GTK_WIDGET (gizmo)));
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
GtkAllocation alloc;
|
||||
int progress_width, progress_height;
|
||||
gboolean inverted;
|
||||
|
||||
inverted = priv->inverted;
|
||||
inverted = pbar->inverted;
|
||||
if (gtk_widget_get_direction (GTK_WIDGET (pbar)) == GTK_TEXT_DIR_RTL)
|
||||
{
|
||||
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
if (pbar->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
inverted = !inverted;
|
||||
}
|
||||
|
||||
gtk_widget_measure (priv->progress_widget, GTK_ORIENTATION_VERTICAL, -1,
|
||||
gtk_widget_measure (pbar->progress_widget, GTK_ORIENTATION_VERTICAL, -1,
|
||||
&progress_height, NULL,
|
||||
NULL, NULL);
|
||||
|
||||
gtk_widget_measure (priv->progress_widget, GTK_ORIENTATION_HORIZONTAL, -1,
|
||||
gtk_widget_measure (pbar->progress_widget, GTK_ORIENTATION_HORIZONTAL, -1,
|
||||
&progress_width, NULL,
|
||||
NULL, NULL);
|
||||
|
||||
if (priv->activity_mode)
|
||||
if (pbar->activity_mode)
|
||||
{
|
||||
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
if (pbar->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
alloc.width = progress_width + (width - progress_width) / priv->activity_blocks;
|
||||
alloc.x = priv->activity_pos * (width - alloc.width);
|
||||
alloc.width = progress_width + (width - progress_width) / pbar->activity_blocks;
|
||||
alloc.x = pbar->activity_pos * (width - alloc.width);
|
||||
alloc.y = (height - progress_height) / 2;
|
||||
alloc.height = progress_height;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
alloc.height = progress_height + (height - progress_height) / priv->activity_blocks;
|
||||
alloc.y = priv->activity_pos * (height - alloc.height);
|
||||
alloc.height = progress_height + (height - progress_height) / pbar->activity_blocks;
|
||||
alloc.y = pbar->activity_pos * (height - alloc.height);
|
||||
alloc.x = (width - progress_width) / 2;
|
||||
alloc.width = progress_width;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
if (pbar->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
alloc.width = progress_width + (width - progress_width) * priv->fraction;
|
||||
alloc.width = progress_width + (width - progress_width) * pbar->fraction;
|
||||
alloc.height = progress_height;
|
||||
alloc.y = (height - progress_height) / 2;
|
||||
|
||||
@ -427,7 +419,7 @@ allocate_trough (GtkGizmo *gizmo,
|
||||
else
|
||||
{
|
||||
alloc.width = progress_width;
|
||||
alloc.height = progress_height + (height - progress_height) * priv->fraction;
|
||||
alloc.height = progress_height + (height - progress_height) * pbar->fraction;
|
||||
alloc.x = (width - progress_width) / 2;
|
||||
|
||||
if (!inverted)
|
||||
@ -437,39 +429,37 @@ allocate_trough (GtkGizmo *gizmo,
|
||||
}
|
||||
}
|
||||
|
||||
gtk_widget_size_allocate (priv->progress_widget, &alloc, -1);
|
||||
gtk_widget_size_allocate (pbar->progress_widget, &alloc, -1);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_progress_bar_init (GtkProgressBar *pbar)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
pbar->inverted = FALSE;
|
||||
pbar->pulse_fraction = 0.1;
|
||||
pbar->activity_pos = 0;
|
||||
pbar->activity_dir = 1;
|
||||
pbar->activity_blocks = 5;
|
||||
pbar->ellipsize = PANGO_ELLIPSIZE_NONE;
|
||||
pbar->show_text = FALSE;
|
||||
|
||||
priv->inverted = FALSE;
|
||||
priv->pulse_fraction = 0.1;
|
||||
priv->activity_pos = 0;
|
||||
priv->activity_dir = 1;
|
||||
priv->activity_blocks = 5;
|
||||
priv->ellipsize = PANGO_ELLIPSIZE_NONE;
|
||||
priv->show_text = FALSE;
|
||||
pbar->text = NULL;
|
||||
pbar->fraction = 0.0;
|
||||
|
||||
priv->text = NULL;
|
||||
priv->fraction = 0.0;
|
||||
|
||||
priv->trough_widget = gtk_gizmo_new ("trough",
|
||||
pbar->trough_widget = gtk_gizmo_new ("trough",
|
||||
NULL,
|
||||
allocate_trough,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL, NULL);
|
||||
gtk_widget_set_parent (priv->trough_widget, GTK_WIDGET (pbar));
|
||||
gtk_widget_set_parent (pbar->trough_widget, GTK_WIDGET (pbar));
|
||||
|
||||
priv->progress_widget = gtk_gizmo_new ("progress", NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
gtk_widget_set_parent (priv->progress_widget, priv->trough_widget);
|
||||
pbar->progress_widget = gtk_gizmo_new ("progress", NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
gtk_widget_set_parent (pbar->progress_widget, pbar->trough_widget);
|
||||
|
||||
/* horizontal is default */
|
||||
priv->orientation = GTK_ORIENTATION_VERTICAL; /* Just to force an update... */
|
||||
pbar->orientation = GTK_ORIENTATION_VERTICAL; /* Just to force an update... */
|
||||
gtk_progress_bar_set_orientation (pbar, GTK_ORIENTATION_HORIZONTAL);
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (pbar));
|
||||
}
|
||||
@ -520,30 +510,29 @@ gtk_progress_bar_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkProgressBar *pbar = GTK_PROGRESS_BAR (object);
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ORIENTATION:
|
||||
g_value_set_enum (value, priv->orientation);
|
||||
g_value_set_enum (value, pbar->orientation);
|
||||
break;
|
||||
case PROP_INVERTED:
|
||||
g_value_set_boolean (value, priv->inverted);
|
||||
g_value_set_boolean (value, pbar->inverted);
|
||||
break;
|
||||
case PROP_FRACTION:
|
||||
g_value_set_double (value, priv->fraction);
|
||||
g_value_set_double (value, pbar->fraction);
|
||||
break;
|
||||
case PROP_PULSE_STEP:
|
||||
g_value_set_double (value, priv->pulse_fraction);
|
||||
g_value_set_double (value, pbar->pulse_fraction);
|
||||
break;
|
||||
case PROP_TEXT:
|
||||
g_value_set_string (value, priv->text);
|
||||
g_value_set_string (value, pbar->text);
|
||||
break;
|
||||
case PROP_SHOW_TEXT:
|
||||
g_value_set_boolean (value, priv->show_text);
|
||||
g_value_set_boolean (value, pbar->show_text);
|
||||
break;
|
||||
case PROP_ELLIPSIZE:
|
||||
g_value_set_enum (value, priv->ellipsize);
|
||||
g_value_set_enum (value, pbar->ellipsize);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -572,17 +561,16 @@ static void
|
||||
gtk_progress_bar_finalize (GObject *object)
|
||||
{
|
||||
GtkProgressBar *pbar = GTK_PROGRESS_BAR (object);
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
|
||||
if (priv->activity_mode)
|
||||
if (pbar->activity_mode)
|
||||
gtk_progress_bar_act_mode_leave (pbar);
|
||||
|
||||
g_free (priv->text);
|
||||
g_free (pbar->text);
|
||||
|
||||
g_clear_pointer (&priv->label, gtk_widget_unparent);
|
||||
g_clear_pointer (&pbar->label, gtk_widget_unparent);
|
||||
|
||||
gtk_widget_unparent (priv->progress_widget);
|
||||
gtk_widget_unparent (priv->trough_widget);
|
||||
gtk_widget_unparent (pbar->progress_widget);
|
||||
gtk_widget_unparent (pbar->trough_widget);
|
||||
|
||||
G_OBJECT_CLASS (gtk_progress_bar_parent_class)->finalize (object);
|
||||
}
|
||||
@ -590,12 +578,10 @@ gtk_progress_bar_finalize (GObject *object)
|
||||
static gchar *
|
||||
get_current_text (GtkProgressBar *pbar)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
|
||||
if (priv->text)
|
||||
return g_strdup (priv->text);
|
||||
if (pbar->text)
|
||||
return g_strdup (pbar->text);
|
||||
else
|
||||
return g_strdup_printf (C_("progress bar label", "%.0f %%"), priv->fraction * 100.0);
|
||||
return g_strdup_printf (C_("progress bar label", "%.0f %%"), pbar->fraction * 100.0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -604,55 +590,54 @@ tick_cb (GtkWidget *widget,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkProgressBar *pbar = GTK_PROGRESS_BAR (widget);
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
gint64 frame_time;
|
||||
gdouble iteration, pulse_iterations, current_iterations, fraction;
|
||||
|
||||
if (priv->pulse2 == 0 && priv->pulse1 == 0)
|
||||
if (pbar->pulse2 == 0 && pbar->pulse1 == 0)
|
||||
return G_SOURCE_CONTINUE;
|
||||
|
||||
frame_time = gdk_frame_clock_get_frame_time (frame_clock);
|
||||
gtk_progress_tracker_advance_frame (&priv->tracker, frame_time);
|
||||
gtk_progress_tracker_advance_frame (&pbar->tracker, frame_time);
|
||||
|
||||
g_assert (priv->pulse2 > priv->pulse1);
|
||||
g_assert (pbar->pulse2 > pbar->pulse1);
|
||||
|
||||
pulse_iterations = (priv->pulse2 - priv->pulse1) / (gdouble) G_USEC_PER_SEC;
|
||||
current_iterations = (frame_time - priv->pulse1) / (gdouble) G_USEC_PER_SEC;
|
||||
pulse_iterations = (pbar->pulse2 - pbar->pulse1) / (double) G_USEC_PER_SEC;
|
||||
current_iterations = (frame_time - pbar->pulse1) / (double) G_USEC_PER_SEC;
|
||||
|
||||
iteration = gtk_progress_tracker_get_iteration (&priv->tracker);
|
||||
iteration = gtk_progress_tracker_get_iteration (&pbar->tracker);
|
||||
/* Determine the fraction to move the block from one frame
|
||||
* to the next when pulse_fraction is how far the block should
|
||||
* move between two calls to gtk_progress_bar_pulse().
|
||||
*/
|
||||
fraction = priv->pulse_fraction * (iteration - priv->last_iteration) / MAX (pulse_iterations, current_iterations);
|
||||
priv->last_iteration = iteration;
|
||||
fraction = pbar->pulse_fraction * (iteration - pbar->last_iteration) / MAX (pulse_iterations, current_iterations);
|
||||
pbar->last_iteration = iteration;
|
||||
|
||||
if (current_iterations > 3 * pulse_iterations)
|
||||
return G_SOURCE_CONTINUE;
|
||||
|
||||
/* advance the block */
|
||||
if (priv->activity_dir == 0)
|
||||
if (pbar->activity_dir == 0)
|
||||
{
|
||||
priv->activity_pos += fraction;
|
||||
if (priv->activity_pos > 1.0)
|
||||
pbar->activity_pos += fraction;
|
||||
if (pbar->activity_pos > 1.0)
|
||||
{
|
||||
priv->activity_pos = 1.0;
|
||||
priv->activity_dir = 1;
|
||||
pbar->activity_pos = 1.0;
|
||||
pbar->activity_dir = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
priv->activity_pos -= fraction;
|
||||
if (priv->activity_pos <= 0)
|
||||
pbar->activity_pos -= fraction;
|
||||
if (pbar->activity_pos <= 0)
|
||||
{
|
||||
priv->activity_pos = 0;
|
||||
priv->activity_dir = 0;
|
||||
pbar->activity_pos = 0;
|
||||
pbar->activity_dir = 0;
|
||||
}
|
||||
}
|
||||
|
||||
update_node_classes (pbar);
|
||||
|
||||
gtk_widget_queue_allocate (priv->trough_widget);
|
||||
gtk_widget_queue_allocate (pbar->trough_widget);
|
||||
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
@ -660,51 +645,48 @@ tick_cb (GtkWidget *widget,
|
||||
static void
|
||||
gtk_progress_bar_act_mode_enter (GtkProgressBar *pbar)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
GtkWidget *widget = GTK_WIDGET (pbar);
|
||||
gboolean inverted;
|
||||
|
||||
gtk_widget_add_css_class (priv->progress_widget, GTK_STYLE_CLASS_PULSE);
|
||||
gtk_widget_add_css_class (pbar->progress_widget, GTK_STYLE_CLASS_PULSE);
|
||||
|
||||
inverted = priv->inverted;
|
||||
inverted = pbar->inverted;
|
||||
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
|
||||
{
|
||||
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
if (pbar->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
inverted = !inverted;
|
||||
}
|
||||
|
||||
/* calculate start pos */
|
||||
if (!inverted)
|
||||
{
|
||||
priv->activity_pos = 0.0;
|
||||
priv->activity_dir = 0;
|
||||
pbar->activity_pos = 0.0;
|
||||
pbar->activity_dir = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
priv->activity_pos = 1.0;
|
||||
priv->activity_dir = 1;
|
||||
pbar->activity_pos = 1.0;
|
||||
pbar->activity_dir = 1;
|
||||
}
|
||||
|
||||
update_node_classes (pbar);
|
||||
/* No fixed schedule for pulses, will adapt after calls to update_pulse. Just
|
||||
* start the tracker to repeat forever with iterations every second.*/
|
||||
gtk_progress_tracker_start (&priv->tracker, G_USEC_PER_SEC, 0, INFINITY);
|
||||
priv->tick_id = gtk_widget_add_tick_callback (widget, tick_cb, NULL, NULL);
|
||||
priv->pulse2 = 0;
|
||||
priv->pulse1 = 0;
|
||||
priv->last_iteration = 0;
|
||||
gtk_progress_tracker_start (&pbar->tracker, G_USEC_PER_SEC, 0, INFINITY);
|
||||
pbar->tick_id = gtk_widget_add_tick_callback (widget, tick_cb, NULL, NULL);
|
||||
pbar->pulse2 = 0;
|
||||
pbar->pulse1 = 0;
|
||||
pbar->last_iteration = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_progress_bar_act_mode_leave (GtkProgressBar *pbar)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
if (pbar->tick_id)
|
||||
gtk_widget_remove_tick_callback (GTK_WIDGET (pbar), pbar->tick_id);
|
||||
pbar->tick_id = 0;
|
||||
|
||||
if (priv->tick_id)
|
||||
gtk_widget_remove_tick_callback (GTK_WIDGET (pbar), priv->tick_id);
|
||||
priv->tick_id = 0;
|
||||
|
||||
gtk_widget_remove_css_class (priv->progress_widget, GTK_STYLE_CLASS_PULSE);
|
||||
gtk_widget_remove_css_class (pbar->progress_widget, GTK_STYLE_CLASS_PULSE);
|
||||
update_node_classes (pbar);
|
||||
}
|
||||
|
||||
@ -712,21 +694,17 @@ static void
|
||||
gtk_progress_bar_set_activity_mode (GtkProgressBar *pbar,
|
||||
gboolean activity_mode)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
if (pbar->activity_mode == activity_mode)
|
||||
return;
|
||||
|
||||
activity_mode = !!activity_mode;
|
||||
pbar->activity_mode = activity_mode;
|
||||
|
||||
if (priv->activity_mode != activity_mode)
|
||||
{
|
||||
priv->activity_mode = activity_mode;
|
||||
if (pbar->activity_mode)
|
||||
gtk_progress_bar_act_mode_enter (pbar);
|
||||
else
|
||||
gtk_progress_bar_act_mode_leave (pbar);
|
||||
|
||||
if (priv->activity_mode)
|
||||
gtk_progress_bar_act_mode_enter (pbar);
|
||||
else
|
||||
gtk_progress_bar_act_mode_leave (pbar);
|
||||
|
||||
gtk_widget_queue_resize (GTK_WIDGET (pbar));
|
||||
}
|
||||
gtk_widget_queue_resize (GTK_WIDGET (pbar));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -742,22 +720,20 @@ void
|
||||
gtk_progress_bar_set_fraction (GtkProgressBar *pbar,
|
||||
gdouble fraction)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
|
||||
g_return_if_fail (GTK_IS_PROGRESS_BAR (pbar));
|
||||
|
||||
priv->fraction = CLAMP (fraction, 0.0, 1.0);
|
||||
pbar->fraction = CLAMP (fraction, 0.0, 1.0);
|
||||
|
||||
if (priv->label)
|
||||
if (pbar->label)
|
||||
{
|
||||
char *text = get_current_text (pbar);
|
||||
gtk_label_set_label (GTK_LABEL (priv->label), text);
|
||||
gtk_label_set_label (GTK_LABEL (pbar->label), text);
|
||||
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
gtk_progress_bar_set_activity_mode (pbar, FALSE);
|
||||
gtk_widget_queue_allocate (priv->trough_widget);
|
||||
gtk_widget_queue_allocate (pbar->trough_widget);
|
||||
update_fraction_classes (pbar);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (pbar), progress_props[PROP_FRACTION]);
|
||||
@ -766,14 +742,13 @@ gtk_progress_bar_set_fraction (GtkProgressBar *pbar,
|
||||
static void
|
||||
gtk_progress_bar_update_pulse (GtkProgressBar *pbar)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
gint64 pulse_time = g_get_monotonic_time ();
|
||||
|
||||
if (priv->pulse2 == pulse_time)
|
||||
if (pbar->pulse2 == pulse_time)
|
||||
return;
|
||||
|
||||
priv->pulse1 = priv->pulse2;
|
||||
priv->pulse2 = pulse_time;
|
||||
pbar->pulse1 = pbar->pulse2;
|
||||
pbar->pulse2 = pulse_time;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -815,19 +790,17 @@ void
|
||||
gtk_progress_bar_set_text (GtkProgressBar *pbar,
|
||||
const gchar *text)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
|
||||
g_return_if_fail (GTK_IS_PROGRESS_BAR (pbar));
|
||||
|
||||
/* Don't notify again if nothing's changed. */
|
||||
if (g_strcmp0 (priv->text, text) == 0)
|
||||
if (g_strcmp0 (pbar->text, text) == 0)
|
||||
return;
|
||||
|
||||
g_free (priv->text);
|
||||
priv->text = g_strdup (text);
|
||||
g_free (pbar->text);
|
||||
pbar->text = g_strdup (text);
|
||||
|
||||
if (priv->label)
|
||||
gtk_label_set_label (GTK_LABEL (priv->label), text);
|
||||
if (pbar->label)
|
||||
gtk_label_set_label (GTK_LABEL (pbar->label), text);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (pbar), progress_props[PROP_TEXT]);
|
||||
}
|
||||
@ -850,33 +823,31 @@ void
|
||||
gtk_progress_bar_set_show_text (GtkProgressBar *pbar,
|
||||
gboolean show_text)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
|
||||
g_return_if_fail (GTK_IS_PROGRESS_BAR (pbar));
|
||||
|
||||
show_text = !!show_text;
|
||||
|
||||
if (priv->show_text == show_text)
|
||||
if (pbar->show_text == show_text)
|
||||
return;
|
||||
|
||||
priv->show_text = show_text;
|
||||
pbar->show_text = show_text;
|
||||
|
||||
if (show_text)
|
||||
{
|
||||
char *text = get_current_text (pbar);
|
||||
|
||||
priv->label = g_object_new (GTK_TYPE_LABEL,
|
||||
pbar->label = g_object_new (GTK_TYPE_LABEL,
|
||||
"css-name", "text",
|
||||
"label", text,
|
||||
"ellipsize", priv->ellipsize,
|
||||
"ellipsize", pbar->ellipsize,
|
||||
NULL);
|
||||
gtk_widget_insert_after (priv->label, GTK_WIDGET (pbar), NULL);
|
||||
gtk_widget_insert_after (pbar->label, GTK_WIDGET (pbar), NULL);
|
||||
|
||||
g_free (text);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_clear_pointer (&priv->label, gtk_widget_unparent);
|
||||
g_clear_pointer (&pbar->label, gtk_widget_unparent);
|
||||
}
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (pbar), progress_props[PROP_SHOW_TEXT]);
|
||||
@ -894,11 +865,9 @@ gtk_progress_bar_set_show_text (GtkProgressBar *pbar,
|
||||
gboolean
|
||||
gtk_progress_bar_get_show_text (GtkProgressBar *pbar)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_PROGRESS_BAR (pbar), FALSE);
|
||||
|
||||
return priv->show_text;
|
||||
return pbar->show_text;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -913,11 +882,9 @@ void
|
||||
gtk_progress_bar_set_pulse_step (GtkProgressBar *pbar,
|
||||
gdouble fraction)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
|
||||
g_return_if_fail (GTK_IS_PROGRESS_BAR (pbar));
|
||||
|
||||
priv->pulse_fraction = fraction;
|
||||
pbar->pulse_fraction = fraction;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (pbar), progress_props[PROP_PULSE_STEP]);
|
||||
}
|
||||
@ -937,27 +904,26 @@ static void
|
||||
gtk_progress_bar_set_orientation (GtkProgressBar *pbar,
|
||||
GtkOrientation orientation)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
GtkBoxLayout *layout;
|
||||
|
||||
if (priv->orientation == orientation)
|
||||
if (pbar->orientation == orientation)
|
||||
return;
|
||||
|
||||
priv->orientation = orientation;
|
||||
pbar->orientation = orientation;
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
gtk_widget_set_vexpand (priv->trough_widget, FALSE);
|
||||
gtk_widget_set_hexpand (priv->trough_widget, TRUE);
|
||||
gtk_widget_set_halign (priv->trough_widget, GTK_ALIGN_FILL);
|
||||
gtk_widget_set_valign (priv->trough_widget, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_vexpand (pbar->trough_widget, FALSE);
|
||||
gtk_widget_set_hexpand (pbar->trough_widget, TRUE);
|
||||
gtk_widget_set_halign (pbar->trough_widget, GTK_ALIGN_FILL);
|
||||
gtk_widget_set_valign (pbar->trough_widget, GTK_ALIGN_CENTER);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_vexpand (priv->trough_widget, TRUE);
|
||||
gtk_widget_set_hexpand (priv->trough_widget, FALSE);
|
||||
gtk_widget_set_halign (priv->trough_widget, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (priv->trough_widget, GTK_ALIGN_FILL);
|
||||
gtk_widget_set_vexpand (pbar->trough_widget, TRUE);
|
||||
gtk_widget_set_hexpand (pbar->trough_widget, FALSE);
|
||||
gtk_widget_set_halign (pbar->trough_widget, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (pbar->trough_widget, GTK_ALIGN_FILL);
|
||||
}
|
||||
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (pbar));
|
||||
@ -981,14 +947,12 @@ void
|
||||
gtk_progress_bar_set_inverted (GtkProgressBar *pbar,
|
||||
gboolean inverted)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
|
||||
g_return_if_fail (GTK_IS_PROGRESS_BAR (pbar));
|
||||
|
||||
if (priv->inverted == inverted)
|
||||
if (pbar->inverted == inverted)
|
||||
return;
|
||||
|
||||
priv->inverted = inverted;
|
||||
pbar->inverted = inverted;
|
||||
|
||||
update_node_classes (pbar);
|
||||
|
||||
@ -1010,11 +974,9 @@ gtk_progress_bar_set_inverted (GtkProgressBar *pbar,
|
||||
const gchar*
|
||||
gtk_progress_bar_get_text (GtkProgressBar *pbar)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_PROGRESS_BAR (pbar), NULL);
|
||||
|
||||
return priv->text;
|
||||
return pbar->text;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1028,11 +990,9 @@ gtk_progress_bar_get_text (GtkProgressBar *pbar)
|
||||
gdouble
|
||||
gtk_progress_bar_get_fraction (GtkProgressBar *pbar)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_PROGRESS_BAR (pbar), 0);
|
||||
|
||||
return priv->fraction;
|
||||
return pbar->fraction;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1046,11 +1006,9 @@ gtk_progress_bar_get_fraction (GtkProgressBar *pbar)
|
||||
gdouble
|
||||
gtk_progress_bar_get_pulse_step (GtkProgressBar *pbar)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_PROGRESS_BAR (pbar), 0);
|
||||
|
||||
return priv->pulse_fraction;
|
||||
return pbar->pulse_fraction;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1064,11 +1022,9 @@ gtk_progress_bar_get_pulse_step (GtkProgressBar *pbar)
|
||||
gboolean
|
||||
gtk_progress_bar_get_inverted (GtkProgressBar *pbar)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_PROGRESS_BAR (pbar), FALSE);
|
||||
|
||||
return priv->inverted;
|
||||
return pbar->inverted;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1083,21 +1039,19 @@ void
|
||||
gtk_progress_bar_set_ellipsize (GtkProgressBar *pbar,
|
||||
PangoEllipsizeMode mode)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
|
||||
g_return_if_fail (GTK_IS_PROGRESS_BAR (pbar));
|
||||
g_return_if_fail (mode >= PANGO_ELLIPSIZE_NONE &&
|
||||
mode <= PANGO_ELLIPSIZE_END);
|
||||
|
||||
if ((PangoEllipsizeMode)priv->ellipsize != mode)
|
||||
{
|
||||
priv->ellipsize = mode;
|
||||
if ((PangoEllipsizeMode)pbar->ellipsize == mode)
|
||||
return;
|
||||
|
||||
if (priv->label)
|
||||
gtk_label_set_ellipsize (GTK_LABEL (priv->label), mode);
|
||||
pbar->ellipsize = mode;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (pbar), progress_props[PROP_ELLIPSIZE]);
|
||||
}
|
||||
if (pbar->label)
|
||||
gtk_label_set_ellipsize (GTK_LABEL (pbar->label), mode);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (pbar), progress_props[PROP_ELLIPSIZE]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1112,9 +1066,7 @@ gtk_progress_bar_set_ellipsize (GtkProgressBar *pbar,
|
||||
PangoEllipsizeMode
|
||||
gtk_progress_bar_get_ellipsize (GtkProgressBar *pbar)
|
||||
{
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_PROGRESS_BAR (pbar), PANGO_ELLIPSIZE_NONE);
|
||||
|
||||
return priv->ellipsize;
|
||||
return pbar->ellipsize;
|
||||
}
|
||||
|
@ -47,11 +47,13 @@
|
||||
* gets one of the .horizontal or .vertical style classes.
|
||||
*/
|
||||
|
||||
typedef struct _GtkSeparatorClass GtkSeparatorClass;
|
||||
typedef struct _GtkSeparatorClass GtkSeparatorClass;
|
||||
|
||||
struct _GtkSeparator
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
|
||||
GtkOrientation orientation;
|
||||
};
|
||||
|
||||
struct _GtkSeparatorClass
|
||||
@ -59,13 +61,6 @@ struct _GtkSeparatorClass
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
typedef struct _GtkSeparatorPrivate GtkSeparatorPrivate;
|
||||
struct _GtkSeparatorPrivate
|
||||
{
|
||||
GtkOrientation orientation;
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_ORIENTATION
|
||||
@ -73,7 +68,6 @@ enum {
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkSeparator, gtk_separator, GTK_TYPE_WIDGET,
|
||||
G_ADD_PRIVATE (GtkSeparator)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL))
|
||||
|
||||
|
||||
@ -84,14 +78,13 @@ gtk_separator_set_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkSeparator *separator = GTK_SEPARATOR (object);
|
||||
GtkSeparatorPrivate *priv = gtk_separator_get_instance_private (separator);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ORIENTATION:
|
||||
if (priv->orientation != g_value_get_enum (value))
|
||||
if (separator->orientation != g_value_get_enum (value))
|
||||
{
|
||||
priv->orientation = g_value_get_enum (value);
|
||||
separator->orientation = g_value_get_enum (value);
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (object));
|
||||
gtk_widget_queue_resize (GTK_WIDGET (object));
|
||||
g_object_notify_by_pspec (object, pspec);
|
||||
@ -110,12 +103,11 @@ gtk_separator_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkSeparator *separator = GTK_SEPARATOR (object);
|
||||
GtkSeparatorPrivate *priv = gtk_separator_get_instance_private (separator);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ORIENTATION:
|
||||
g_value_set_enum (value, priv->orientation);
|
||||
g_value_set_enum (value, separator->orientation);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -126,9 +118,7 @@ gtk_separator_get_property (GObject *object,
|
||||
static void
|
||||
gtk_separator_init (GtkSeparator *separator)
|
||||
{
|
||||
GtkSeparatorPrivate *priv = gtk_separator_get_instance_private (separator);
|
||||
|
||||
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
|
||||
separator->orientation = GTK_ORIENTATION_HORIZONTAL;
|
||||
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (separator));
|
||||
}
|
||||
|
@ -68,11 +68,14 @@
|
||||
#define TIMEOUT_EXPAND 500
|
||||
|
||||
typedef struct _GtkStackSwitcherClass GtkStackSwitcherClass;
|
||||
typedef struct _GtkStackSwitcherPrivate GtkStackSwitcherPrivate;
|
||||
|
||||
struct _GtkStackSwitcher
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
|
||||
GtkStack *stack;
|
||||
GtkSelectionModel *pages;
|
||||
GHashTable *buttons;
|
||||
};
|
||||
|
||||
struct _GtkStackSwitcherClass
|
||||
@ -80,26 +83,17 @@ struct _GtkStackSwitcherClass
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
struct _GtkStackSwitcherPrivate
|
||||
{
|
||||
GtkStack *stack;
|
||||
GtkSelectionModel *pages;
|
||||
GHashTable *buttons;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_STACK
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkStackSwitcher, gtk_stack_switcher, GTK_TYPE_WIDGET)
|
||||
G_DEFINE_TYPE (GtkStackSwitcher, gtk_stack_switcher, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
gtk_stack_switcher_init (GtkStackSwitcher *switcher)
|
||||
{
|
||||
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (switcher);
|
||||
|
||||
priv->buttons = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL);
|
||||
switcher->buttons = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL);
|
||||
|
||||
gtk_widget_add_css_class (GTK_WIDGET (switcher), "linked");
|
||||
}
|
||||
@ -109,7 +103,6 @@ on_button_toggled (GtkWidget *button,
|
||||
GParamSpec *pspec,
|
||||
GtkStackSwitcher *self)
|
||||
{
|
||||
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (self);
|
||||
gboolean active;
|
||||
guint index;
|
||||
|
||||
@ -118,11 +111,11 @@ on_button_toggled (GtkWidget *button,
|
||||
|
||||
if (active)
|
||||
{
|
||||
gtk_selection_model_select_item (priv->pages, index, TRUE);
|
||||
gtk_selection_model_select_item (self->pages, index, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gboolean selected = gtk_selection_model_is_selected (priv->pages, index);
|
||||
gboolean selected = gtk_selection_model_is_selected (self->pages, index);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), selected);
|
||||
}
|
||||
}
|
||||
@ -201,10 +194,9 @@ on_page_updated (GtkStackPage *page,
|
||||
GParamSpec *pspec,
|
||||
GtkStackSwitcher *self)
|
||||
{
|
||||
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (self);
|
||||
GtkWidget *button;
|
||||
|
||||
button = g_hash_table_lookup (priv->buttons, page);
|
||||
button = g_hash_table_lookup (self->buttons, page);
|
||||
update_button (self, page, button);
|
||||
}
|
||||
|
||||
@ -255,7 +247,6 @@ static void
|
||||
add_child (guint position,
|
||||
GtkStackSwitcher *self)
|
||||
{
|
||||
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (self);
|
||||
GtkWidget *button;
|
||||
gboolean selected;
|
||||
GtkStackPage *page;
|
||||
@ -269,19 +260,19 @@ add_child (guint position,
|
||||
g_signal_connect (controller, "leave", G_CALLBACK (gtk_stack_switcher_drag_leave), NULL);
|
||||
gtk_widget_add_controller (button, controller);
|
||||
|
||||
page = g_list_model_get_item (G_LIST_MODEL (priv->pages), position);
|
||||
page = g_list_model_get_item (G_LIST_MODEL (self->pages), position);
|
||||
update_button (self, page, button);
|
||||
|
||||
gtk_widget_set_parent (button, GTK_WIDGET (self));
|
||||
|
||||
g_object_set_data (G_OBJECT (button), "child-index", GUINT_TO_POINTER (position));
|
||||
selected = gtk_selection_model_is_selected (priv->pages, position);
|
||||
selected = gtk_selection_model_is_selected (self->pages, position);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), selected);
|
||||
|
||||
g_signal_connect (button, "notify::active", G_CALLBACK (on_button_toggled), self);
|
||||
g_signal_connect (page, "notify", G_CALLBACK (on_page_updated), self);
|
||||
|
||||
g_hash_table_insert (priv->buttons, g_object_ref (page), button);
|
||||
g_hash_table_insert (self->buttons, g_object_ref (page), button);
|
||||
|
||||
g_object_unref (page);
|
||||
}
|
||||
@ -289,22 +280,20 @@ add_child (guint position,
|
||||
static void
|
||||
populate_switcher (GtkStackSwitcher *self)
|
||||
{
|
||||
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (self);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (priv->pages)); i++)
|
||||
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (self->pages)); i++)
|
||||
add_child (i, self);
|
||||
}
|
||||
|
||||
static void
|
||||
clear_switcher (GtkStackSwitcher *self)
|
||||
{
|
||||
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (self);
|
||||
GHashTableIter iter;
|
||||
GtkWidget *page;
|
||||
GtkWidget *button;
|
||||
|
||||
g_hash_table_iter_init (&iter, priv->buttons);
|
||||
g_hash_table_iter_init (&iter, self->buttons);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer *)&page, (gpointer *)&button))
|
||||
{
|
||||
gtk_widget_unparent (button);
|
||||
@ -330,7 +319,6 @@ selection_changed_cb (GtkSelectionModel *model,
|
||||
guint n_items,
|
||||
GtkStackSwitcher *switcher)
|
||||
{
|
||||
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (switcher);
|
||||
guint i;
|
||||
|
||||
for (i = position; i < position + n_items; i++)
|
||||
@ -339,11 +327,11 @@ selection_changed_cb (GtkSelectionModel *model,
|
||||
GtkWidget *button;
|
||||
gboolean selected;
|
||||
|
||||
page = g_list_model_get_item (G_LIST_MODEL (priv->pages), i);
|
||||
button = g_hash_table_lookup (priv->buttons, page);
|
||||
page = g_list_model_get_item (G_LIST_MODEL (switcher->pages), i);
|
||||
button = g_hash_table_lookup (switcher->buttons, page);
|
||||
if (button)
|
||||
{
|
||||
selected = gtk_selection_model_is_selected (priv->pages, i);
|
||||
selected = gtk_selection_model_is_selected (switcher->pages, i);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), selected);
|
||||
}
|
||||
g_object_unref (page);
|
||||
@ -353,31 +341,25 @@ selection_changed_cb (GtkSelectionModel *model,
|
||||
static void
|
||||
disconnect_stack_signals (GtkStackSwitcher *switcher)
|
||||
{
|
||||
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (switcher);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (priv->pages, items_changed_cb, switcher);
|
||||
g_signal_handlers_disconnect_by_func (priv->pages, selection_changed_cb, switcher);
|
||||
g_signal_handlers_disconnect_by_func (switcher->pages, items_changed_cb, switcher);
|
||||
g_signal_handlers_disconnect_by_func (switcher->pages, selection_changed_cb, switcher);
|
||||
}
|
||||
|
||||
static void
|
||||
connect_stack_signals (GtkStackSwitcher *switcher)
|
||||
{
|
||||
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (switcher);
|
||||
|
||||
g_signal_connect (priv->pages, "items-changed", G_CALLBACK (items_changed_cb), switcher);
|
||||
g_signal_connect (priv->pages, "selection-changed", G_CALLBACK (selection_changed_cb), switcher);
|
||||
g_signal_connect (switcher->pages, "items-changed", G_CALLBACK (items_changed_cb), switcher);
|
||||
g_signal_connect (switcher->pages, "selection-changed", G_CALLBACK (selection_changed_cb), switcher);
|
||||
}
|
||||
|
||||
static void
|
||||
set_stack (GtkStackSwitcher *switcher,
|
||||
GtkStack *stack)
|
||||
{
|
||||
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (switcher);
|
||||
|
||||
if (stack)
|
||||
{
|
||||
priv->stack = g_object_ref (stack);
|
||||
priv->pages = gtk_stack_get_pages (stack);
|
||||
switcher->stack = g_object_ref (stack);
|
||||
switcher->pages = gtk_stack_get_pages (stack);
|
||||
populate_switcher (switcher);
|
||||
connect_stack_signals (switcher);
|
||||
}
|
||||
@ -386,14 +368,12 @@ set_stack (GtkStackSwitcher *switcher,
|
||||
static void
|
||||
unset_stack (GtkStackSwitcher *switcher)
|
||||
{
|
||||
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (switcher);
|
||||
|
||||
if (priv->stack)
|
||||
if (switcher->stack)
|
||||
{
|
||||
disconnect_stack_signals (switcher);
|
||||
clear_switcher (switcher);
|
||||
g_clear_object (&priv->stack);
|
||||
g_clear_object (&priv->pages);
|
||||
g_clear_object (&switcher->stack);
|
||||
g_clear_object (&switcher->pages);
|
||||
}
|
||||
}
|
||||
|
||||
@ -408,12 +388,10 @@ void
|
||||
gtk_stack_switcher_set_stack (GtkStackSwitcher *switcher,
|
||||
GtkStack *stack)
|
||||
{
|
||||
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (switcher);
|
||||
|
||||
g_return_if_fail (GTK_IS_STACK_SWITCHER (switcher));
|
||||
g_return_if_fail (GTK_IS_STACK (stack) || stack == NULL);
|
||||
|
||||
if (priv->stack == stack)
|
||||
if (switcher->stack == stack)
|
||||
return;
|
||||
|
||||
unset_stack (switcher);
|
||||
@ -437,11 +415,9 @@ gtk_stack_switcher_set_stack (GtkStackSwitcher *switcher,
|
||||
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;
|
||||
return switcher->stack;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -451,13 +427,11 @@ gtk_stack_switcher_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkStackSwitcher *switcher = GTK_STACK_SWITCHER (object);
|
||||
GtkStackSwitcherPrivate *priv;
|
||||
|
||||
priv = gtk_stack_switcher_get_instance_private (switcher);
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_STACK:
|
||||
g_value_set_object (value, priv->stack);
|
||||
g_value_set_object (value, switcher->stack);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -500,9 +474,8 @@ static void
|
||||
gtk_stack_switcher_finalize (GObject *object)
|
||||
{
|
||||
GtkStackSwitcher *switcher = GTK_STACK_SWITCHER (object);
|
||||
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (switcher);
|
||||
|
||||
g_hash_table_destroy (priv->buttons);
|
||||
g_hash_table_destroy (switcher->buttons);
|
||||
|
||||
G_OBJECT_CLASS (gtk_stack_switcher_parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -70,10 +70,7 @@ typedef struct _GtkViewportClass GtkViewportClass;
|
||||
struct _GtkViewport
|
||||
{
|
||||
GtkBin parent_instance;
|
||||
};
|
||||
|
||||
struct _GtkViewportPrivate
|
||||
{
|
||||
GtkAdjustment *hadjustment;
|
||||
GtkAdjustment *vadjustment;
|
||||
|
||||
@ -124,7 +121,6 @@ static void setup_focus_change_handler (GtkViewport *viewport);
|
||||
static void clear_focus_change_handler (GtkViewport *viewport);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkViewport, gtk_viewport, GTK_TYPE_BIN,
|
||||
G_ADD_PRIVATE (GtkViewport)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL))
|
||||
|
||||
static void
|
||||
@ -132,7 +128,6 @@ viewport_set_adjustment_values (GtkViewport *viewport,
|
||||
GtkOrientation orientation)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN (viewport);
|
||||
GtkViewportPrivate *priv = gtk_viewport_get_instance_private (viewport);
|
||||
GtkAdjustment *adjustment;
|
||||
GtkScrollablePolicy scroll_policy;
|
||||
GtkScrollablePolicy other_scroll_policy;
|
||||
@ -147,21 +142,21 @@ viewport_set_adjustment_values (GtkViewport *viewport,
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
adjustment = priv->hadjustment;
|
||||
adjustment = viewport->hadjustment;
|
||||
other_orientation = GTK_ORIENTATION_VERTICAL;
|
||||
viewport_size = view_width;
|
||||
other_viewport_size = view_height;
|
||||
scroll_policy = priv->hscroll_policy;
|
||||
other_scroll_policy = priv->vscroll_policy;
|
||||
scroll_policy = viewport->hscroll_policy;
|
||||
other_scroll_policy = viewport->vscroll_policy;
|
||||
}
|
||||
else /* VERTICAL */
|
||||
{
|
||||
adjustment = priv->vadjustment;
|
||||
adjustment = viewport->vadjustment;
|
||||
other_orientation = GTK_ORIENTATION_HORIZONTAL;
|
||||
viewport_size = view_height;
|
||||
other_viewport_size = view_width;
|
||||
scroll_policy = priv->vscroll_policy;
|
||||
other_scroll_policy = priv->hscroll_policy;
|
||||
scroll_policy = viewport->vscroll_policy;
|
||||
other_scroll_policy = viewport->hscroll_policy;
|
||||
}
|
||||
|
||||
|
||||
@ -249,11 +244,10 @@ static void
|
||||
gtk_viewport_root (GtkWidget *widget)
|
||||
{
|
||||
GtkViewport *viewport = GTK_VIEWPORT (widget);
|
||||
GtkViewportPrivate *priv = gtk_viewport_get_instance_private (viewport);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_viewport_parent_class)->root (widget);
|
||||
|
||||
if (priv->scroll_to_focus)
|
||||
if (viewport->scroll_to_focus)
|
||||
setup_focus_change_handler (viewport);
|
||||
}
|
||||
|
||||
@ -261,9 +255,8 @@ static void
|
||||
gtk_viewport_unroot (GtkWidget *widget)
|
||||
{
|
||||
GtkViewport *viewport = GTK_VIEWPORT (widget);
|
||||
GtkViewportPrivate *priv = gtk_viewport_get_instance_private (viewport);
|
||||
|
||||
if (priv->scroll_to_focus)
|
||||
if (viewport->scroll_to_focus)
|
||||
clear_focus_change_handler (viewport);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_viewport_parent_class)->unroot (widget);
|
||||
@ -314,7 +307,6 @@ gtk_viewport_set_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkViewport *viewport = GTK_VIEWPORT (object);
|
||||
GtkViewportPrivate *priv = gtk_viewport_get_instance_private (viewport);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@ -325,17 +317,17 @@ gtk_viewport_set_property (GObject *object,
|
||||
viewport_set_adjustment (viewport, GTK_ORIENTATION_VERTICAL, g_value_get_object (value));
|
||||
break;
|
||||
case PROP_HSCROLL_POLICY:
|
||||
if (priv->hscroll_policy != g_value_get_enum (value))
|
||||
if (viewport->hscroll_policy != g_value_get_enum (value))
|
||||
{
|
||||
priv->hscroll_policy = g_value_get_enum (value);
|
||||
viewport->hscroll_policy = g_value_get_enum (value);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (viewport));
|
||||
g_object_notify_by_pspec (object, pspec);
|
||||
}
|
||||
break;
|
||||
case PROP_VSCROLL_POLICY:
|
||||
if (priv->vscroll_policy != g_value_get_enum (value))
|
||||
if (viewport->vscroll_policy != g_value_get_enum (value))
|
||||
{
|
||||
priv->vscroll_policy = g_value_get_enum (value);
|
||||
viewport->vscroll_policy = g_value_get_enum (value);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (viewport));
|
||||
g_object_notify_by_pspec (object, pspec);
|
||||
}
|
||||
@ -356,24 +348,23 @@ gtk_viewport_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkViewport *viewport = GTK_VIEWPORT (object);
|
||||
GtkViewportPrivate *priv = gtk_viewport_get_instance_private (viewport);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_HADJUSTMENT:
|
||||
g_value_set_object (value, priv->hadjustment);
|
||||
g_value_set_object (value, viewport->hadjustment);
|
||||
break;
|
||||
case PROP_VADJUSTMENT:
|
||||
g_value_set_object (value, priv->vadjustment);
|
||||
g_value_set_object (value, viewport->vadjustment);
|
||||
break;
|
||||
case PROP_HSCROLL_POLICY:
|
||||
g_value_set_enum (value, priv->hscroll_policy);
|
||||
g_value_set_enum (value, viewport->hscroll_policy);
|
||||
break;
|
||||
case PROP_VSCROLL_POLICY:
|
||||
g_value_set_enum (value, priv->vscroll_policy);
|
||||
g_value_set_enum (value, viewport->vscroll_policy);
|
||||
break;
|
||||
case PROP_SCROLL_TO_FOCUS:
|
||||
g_value_set_boolean (value, priv->scroll_to_focus);
|
||||
g_value_set_boolean (value, viewport->scroll_to_focus);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -385,14 +376,13 @@ static void
|
||||
gtk_viewport_init (GtkViewport *viewport)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkViewportPrivate *priv = gtk_viewport_get_instance_private (viewport);
|
||||
|
||||
widget = GTK_WIDGET (viewport);
|
||||
|
||||
gtk_widget_set_overflow (widget, GTK_OVERFLOW_HIDDEN);
|
||||
|
||||
priv->hadjustment = NULL;
|
||||
priv->vadjustment = NULL;
|
||||
viewport->hadjustment = NULL;
|
||||
viewport->vadjustment = NULL;
|
||||
|
||||
gtk_widget_add_css_class (widget, GTK_STYLE_CLASS_FRAME);
|
||||
viewport_set_adjustment (viewport, GTK_ORIENTATION_HORIZONTAL, NULL);
|
||||
@ -425,13 +415,12 @@ gtk_viewport_new (GtkAdjustment *hadjustment,
|
||||
|
||||
#define ADJUSTMENT_POINTER(orientation) \
|
||||
(((orientation) == GTK_ORIENTATION_HORIZONTAL) ? \
|
||||
&priv->hadjustment : &priv->vadjustment)
|
||||
&viewport->hadjustment : &viewport->vadjustment)
|
||||
|
||||
static void
|
||||
viewport_disconnect_adjustment (GtkViewport *viewport,
|
||||
GtkOrientation orientation)
|
||||
{
|
||||
GtkViewportPrivate *priv = gtk_viewport_get_instance_private (viewport);
|
||||
GtkAdjustment **adjustmentp = ADJUSTMENT_POINTER (orientation);
|
||||
|
||||
if (*adjustmentp)
|
||||
@ -460,7 +449,6 @@ viewport_set_adjustment (GtkViewport *viewport,
|
||||
GtkOrientation orientation,
|
||||
GtkAdjustment *adjustment)
|
||||
{
|
||||
GtkViewportPrivate *priv = gtk_viewport_get_instance_private (viewport);
|
||||
GtkAdjustment **adjustmentp = ADJUSTMENT_POINTER (orientation);
|
||||
|
||||
if (adjustment && adjustment == *adjustmentp)
|
||||
@ -488,9 +476,8 @@ gtk_viewport_size_allocate (GtkWidget *widget,
|
||||
int baseline)
|
||||
{
|
||||
GtkViewport *viewport = GTK_VIEWPORT (widget);
|
||||
GtkViewportPrivate *priv = gtk_viewport_get_instance_private (viewport);
|
||||
GtkAdjustment *hadjustment = priv->hadjustment;
|
||||
GtkAdjustment *vadjustment = priv->vadjustment;
|
||||
GtkAdjustment *hadjustment = viewport->hadjustment;
|
||||
GtkAdjustment *vadjustment = viewport->vadjustment;
|
||||
GtkWidget *child;
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (hadjustment));
|
||||
@ -535,11 +522,9 @@ gtk_viewport_adjustment_value_changed (GtkAdjustment *adjustment,
|
||||
gboolean
|
||||
gtk_viewport_get_scroll_to_focus (GtkViewport *viewport)
|
||||
{
|
||||
GtkViewportPrivate *priv = gtk_viewport_get_instance_private (viewport);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_VIEWPORT (viewport), FALSE);
|
||||
|
||||
return priv->scroll_to_focus;
|
||||
return viewport->scroll_to_focus;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -554,14 +539,12 @@ void
|
||||
gtk_viewport_set_scroll_to_focus (GtkViewport *viewport,
|
||||
gboolean scroll_to_focus)
|
||||
{
|
||||
GtkViewportPrivate *priv = gtk_viewport_get_instance_private (viewport);
|
||||
|
||||
g_return_if_fail (GTK_IS_VIEWPORT (viewport));
|
||||
|
||||
if (priv->scroll_to_focus == scroll_to_focus)
|
||||
if (viewport->scroll_to_focus == scroll_to_focus)
|
||||
return;
|
||||
|
||||
priv->scroll_to_focus = scroll_to_focus;
|
||||
viewport->scroll_to_focus = scroll_to_focus;
|
||||
|
||||
if (gtk_widget_get_root (GTK_WIDGET (viewport)))
|
||||
{
|
||||
@ -594,7 +577,6 @@ static void
|
||||
focus_change_handler (GtkWidget *widget)
|
||||
{
|
||||
GtkViewport *viewport = GTK_VIEWPORT (widget);
|
||||
GtkViewportPrivate *priv = gtk_viewport_get_instance_private (viewport);
|
||||
GtkRoot *root;
|
||||
GtkWidget *focus_widget;
|
||||
GtkWidget *child;
|
||||
@ -623,33 +605,31 @@ focus_change_handler (GtkWidget *widget)
|
||||
(int)rect.origin.y,
|
||||
&x, &y);
|
||||
|
||||
scroll_to_view (priv->hadjustment, x, rect.size.width);
|
||||
scroll_to_view (priv->vadjustment, y, rect.size.height);
|
||||
scroll_to_view (viewport->hadjustment, x, rect.size.width);
|
||||
scroll_to_view (viewport->vadjustment, y, rect.size.height);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_focus_change_handler (GtkViewport *viewport)
|
||||
{
|
||||
GtkViewportPrivate *priv = gtk_viewport_get_instance_private (viewport);
|
||||
GtkRoot *root;
|
||||
|
||||
root = gtk_widget_get_root (GTK_WIDGET (viewport));
|
||||
|
||||
priv->focus_handler = g_signal_connect_swapped (root, "notify::focus-widget",
|
||||
viewport->focus_handler = g_signal_connect_swapped (root, "notify::focus-widget",
|
||||
G_CALLBACK (focus_change_handler), viewport);
|
||||
}
|
||||
|
||||
static void
|
||||
clear_focus_change_handler (GtkViewport *viewport)
|
||||
{
|
||||
GtkViewportPrivate *priv = gtk_viewport_get_instance_private (viewport);
|
||||
GtkRoot *root;
|
||||
|
||||
root = gtk_widget_get_root (GTK_WIDGET (viewport));
|
||||
|
||||
if (priv->focus_handler)
|
||||
if (viewport->focus_handler)
|
||||
{
|
||||
g_signal_handler_disconnect (root, priv->focus_handler);
|
||||
priv->focus_handler = 0;
|
||||
g_signal_handler_disconnect (root, viewport->focus_handler);
|
||||
viewport->focus_handler = 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user