2008-07-01 22:57:50 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
1998-01-18 23:01:09 +00:00
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
* GtkStatusbar Copyright (C) 1998 Shawn T. Amundson
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1998-01-18 23:01:09 +00:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-07-26 11:33:08 +00:00
|
|
|
* Lesser General Public License for more details.
|
1998-01-18 23:01:09 +00:00
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
1998-01-18 23:01:09 +00:00
|
|
|
*/
|
|
|
|
|
1999-02-24 07:37:18 +00:00
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:37:18 +00:00
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
2008-05-19 14:15:34 +00:00
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
1999-02-24 07:37:18 +00:00
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2011-01-04 19:51:19 +00:00
|
|
|
|
2011-10-02 20:21:49 +00:00
|
|
|
#include "gtkstatusbar.h"
|
|
|
|
|
|
|
|
#include "gtkboxprivate.h"
|
1998-01-18 23:01:09 +00:00
|
|
|
#include "gtkframe.h"
|
|
|
|
#include "gtklabel.h"
|
2001-11-17 23:28:51 +00:00
|
|
|
#include "gtkmarshalers.h"
|
2001-03-29 21:17:45 +00:00
|
|
|
#include "gtkwindow.h"
|
2005-03-22 02:14:55 +00:00
|
|
|
#include "gtkprivate.h"
|
2001-06-04 23:15:51 +00:00
|
|
|
#include "gtkintl.h"
|
2009-11-12 17:57:37 +00:00
|
|
|
#include "gtkbuildable.h"
|
2011-06-07 23:55:46 +00:00
|
|
|
#include "gtkorientable.h"
|
2011-01-04 19:51:19 +00:00
|
|
|
#include "gtktypebuiltins.h"
|
2011-07-01 04:47:41 +00:00
|
|
|
#include "a11y/gtkstatusbaraccessible.h"
|
1998-01-18 23:01:09 +00:00
|
|
|
|
2010-06-08 23:44:56 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gtkstatusbar
|
|
|
|
* @title: GtkStatusbar
|
|
|
|
* @short_description: Report messages of minor importance to the user
|
|
|
|
*
|
|
|
|
* A #GtkStatusbar is usually placed along the bottom of an application's
|
|
|
|
* main #GtkWindow. It may provide a regular commentary of the application's
|
|
|
|
* status (as is usually the case in a web browser, for example), or may be
|
|
|
|
* used to simply output a message when the status changes, (when an upload
|
|
|
|
* is complete in an FTP client, for example).
|
|
|
|
*
|
|
|
|
* Status bars in GTK+ maintain a stack of messages. The message at
|
|
|
|
* the top of the each bar's stack is the one that will currently be displayed.
|
|
|
|
*
|
|
|
|
* Any messages added to a statusbar's stack must specify a
|
|
|
|
* <emphasis>context id</emphasis> that is used to uniquely identify
|
|
|
|
* the source of a message. This context id can be generated by
|
|
|
|
* gtk_statusbar_get_context_id(), given a message and the statusbar that
|
|
|
|
* it will be added to. Note that messages are stored in a stack, and when
|
|
|
|
* choosing which message to display, the stack structure is adhered to,
|
|
|
|
* regardless of the context identifier of a message.
|
|
|
|
*
|
|
|
|
* One could say that a statusbar maintains one stack of messages for
|
|
|
|
* display purposes, but allows multiple message producers to maintain
|
|
|
|
* sub-stacks of the messages they produced (via context ids).
|
|
|
|
*
|
|
|
|
* Status bars are created using gtk_statusbar_new().
|
|
|
|
*
|
|
|
|
* Messages are added to the bar's stack with gtk_statusbar_push().
|
|
|
|
*
|
|
|
|
* The message at the top of the stack can be removed using
|
|
|
|
* gtk_statusbar_pop(). A message can be removed from anywhere in the
|
|
|
|
* stack if its message id was recorded at the time it was added. This
|
|
|
|
* is done using gtk_statusbar_remove().
|
|
|
|
*/
|
2001-02-03 01:09:41 +00:00
|
|
|
typedef struct _GtkStatusbarMsg GtkStatusbarMsg;
|
|
|
|
|
2010-08-26 17:15:37 +00:00
|
|
|
struct _GtkStatusbarPrivate
|
2010-07-12 23:46:15 +00:00
|
|
|
{
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *label;
|
|
|
|
|
|
|
|
GSList *messages;
|
|
|
|
GSList *keys;
|
|
|
|
|
|
|
|
guint seq_context_id;
|
|
|
|
guint seq_message_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-02-03 01:09:41 +00:00
|
|
|
struct _GtkStatusbarMsg
|
|
|
|
{
|
|
|
|
gchar *text;
|
|
|
|
guint context_id;
|
|
|
|
guint message_id;
|
|
|
|
};
|
1998-02-23 15:13:03 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SIGNAL_TEXT_PUSHED,
|
|
|
|
SIGNAL_TEXT_POPPED,
|
|
|
|
SIGNAL_LAST
|
|
|
|
};
|
|
|
|
|
2009-11-12 17:57:37 +00:00
|
|
|
static void gtk_statusbar_buildable_interface_init (GtkBuildableIface *iface);
|
|
|
|
static GObject *gtk_statusbar_buildable_get_internal_child (GtkBuildable *buildable,
|
|
|
|
GtkBuilder *builder,
|
|
|
|
const gchar *childname);
|
2004-02-26 22:29:24 +00:00
|
|
|
static void gtk_statusbar_update (GtkStatusbar *statusbar,
|
|
|
|
guint context_id,
|
|
|
|
const gchar *text);
|
2010-10-30 01:13:55 +00:00
|
|
|
static void gtk_statusbar_realize (GtkWidget *widget);
|
2010-09-18 23:55:42 +00:00
|
|
|
static void gtk_statusbar_destroy (GtkWidget *widget);
|
2004-02-26 22:29:24 +00:00
|
|
|
static void gtk_statusbar_size_allocate (GtkWidget *widget,
|
2010-10-08 05:43:24 +00:00
|
|
|
GtkAllocation *allocation);
|
|
|
|
static void gtk_statusbar_hierarchy_changed (GtkWidget *widget,
|
|
|
|
GtkWidget *previous_toplevel);
|
2004-02-26 22:29:24 +00:00
|
|
|
|
2001-03-29 21:17:45 +00:00
|
|
|
|
1998-03-09 15:16:28 +00:00
|
|
|
static guint statusbar_signals[SIGNAL_LAST] = { 0 };
|
1998-01-18 23:01:09 +00:00
|
|
|
|
2011-06-07 23:55:46 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkStatusbar, gtk_statusbar, GTK_TYPE_BOX,
|
2009-11-12 17:57:37 +00:00
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
|
|
|
gtk_statusbar_buildable_interface_init));
|
1998-01-18 23:01:09 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_statusbar_class_init (GtkStatusbarClass *class)
|
|
|
|
{
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
|
|
|
|
widget_class = (GtkWidgetClass *) class;
|
|
|
|
|
2010-10-30 01:13:55 +00:00
|
|
|
widget_class->realize = gtk_statusbar_realize;
|
2010-09-18 23:55:42 +00:00
|
|
|
widget_class->destroy = gtk_statusbar_destroy;
|
2001-06-04 23:15:51 +00:00
|
|
|
widget_class->size_allocate = gtk_statusbar_size_allocate;
|
2010-10-08 05:43:24 +00:00
|
|
|
widget_class->hierarchy_changed = gtk_statusbar_hierarchy_changed;
|
|
|
|
|
documented necessary changes for 1.4 transition.
Fri May 12 17:13:32 2000 Tim Janik <timj@gtk.org>
* docs/Changes-1.4.txt: documented necessary changes for 1.4 transition.
* gtk/gtktext.c: made the adjustments no-construct args, simply
provide default adjustments.
(gtk_text_destroy): release adjustments.
* gtk/gtkprogressbar.c (gtk_progress_bar_class_init): made the
adjustment argument non-construct.
* gtk/gtkprogress.c (gtk_progress_destroy): release adjustment here,
instead of in finalize.
(gtk_progress_get_text_from_value):
(gtk_progress_get_current_text):
(gtk_progress_set_value):
(gtk_progress_get_percentage_from_value):
(gtk_progress_get_current_percentage):
(gtk_progress_set_percentage):
(gtk_progress_configure): ensure an adjustment is present.
Thu May 11 01:24:08 2000 Tim Janik <timj@gtk.org>
* gtk/gtkcolorsel.[hc]:
* gtk/gtkcolorseldialog.[hc]:
* gtk/gtkhsv.[hc]: major code cleanups, destroy handlers need to chain
their parent implementation, use bit fields for boolean values, don't
create unused widgets, usage of glib types, braces go on their own
lines, function argument alignment, #include directives etc. etc. etc..
* gtk/Makefile.am (gtk_public_h_sources): install gtkhsv.h.
Wed May 10 23:29:52 2000 Tim Janik <timj@gtk.org>
* gtk/gtktoolbar.c (gtk_toolbar_destroy): don't unref a NULL tooltips.
* gtk/gtkfilesel.c (gtk_file_selection_destroy): don't free a cmpl_state
of NULL.
* gtk/gtkcombo.c (gtk_combo_item_destroy): don#t keep references
to freed data.
(gtk_combo_destroy): don't keep a pointer to a destroyed window.
* gtk/gtkmenu.c (gtk_menu_init): reset the menu's toplevel pointer
to NULL when the toplevel is getting destroyed.
(gtk_menu_set_tearoff_state): same here for the tearoff_window.
(gtk_menu_destroy):
(gtk_menu_init): store the information of whether we have to
readd the initial child ref_count during destruction in a new
GtkMenu field needs_destruction_ref_count.
* gtk/gtkviewport.c: SHAME! ok this one is tricky, so i note it
here, those reading: learn from my mistake! ;)
in order for set_?adjustment to support a default adjustemnt if
invoked with an adjustment pointer of NULL, the code read (pseudo):
if (v->adjustment) unref (v->adjustment);
if (!adjustment) adjustment = adjustment_new ();
if (v->adjustment != adjustment) v->adjustment = ref (adjustment);
now imagine the first unref to actually free the old adjustment and
adjustment_new() creating a new adjustment from the very same memory
portion. here, the latter comparision will unintendedly fail, and
all hell breaks loose.
(gtk_viewport_set_hadjustment):
(gtk_viewport_set_vadjustment): reset viewport->?adjustment to NULL
after unreferencing it.
* gtk/gtkcontainer.[hc]: removed toplevel registration
functions: gtk_container_register_toplevel(),
gtk_container_unregister_toplevel() and
gtk_container_get_toplevels() which had wrong semantics
anyways: it didn't reference and copy the list.
* gtk/gtkwindow.c: we take over the container toplevel registration
bussiness now. windows are registered across multiple destructions,
untill they are finalized. the initial implicit reference count
users are holding on windows is removed with the first destruction
though.
(gtk_window_init): ref & sink and set has_user_ref_count, got
rid of gtk_container_register_toplevel() call. add window to
toplevel_list.
(gtk_window_destroy): unref the window if has_user_ref_count
is still set, got rid of call to
gtk_container_unregister_toplevel().
(gtk_window_finalize): remove window from toplevel list.
(gtk_window_list_toplevels): new function to return a newly
created list with referenced toplevels.
(gtk_window_read_rcfiles): use gtk_window_list_toplevels().
* gtk/gtkhscale.c (gtk_hscale_class_init): made the GtkRange
adjustment a non-construct arg.
* gtk/gtkvscale.c (gtk_vscale_class_init): likewise.
* gtk/gtkhscrollbar.c (gtk_vscrollbar_class_init): likewise.
* gtk/gtkvscrollbar.c (gtk_vscrollbar_class_init): likewise.
* gtk/gtkrange.c: added some realized checks.
(gtk_range_destroy): get rid of the h/v adjustments in the
destroy handler instead of finalize. remove timer.
(gtk_range_get_adjustment): demand create adjustment.
* gtk/gtkviewport.c: made h/v adjustment non-construct args.
we simply create them on demand now and get rid of them in
the destroy handler.
(gtk_viewport_destroy): get rid of the h/v adjustments in the
destroy handler instead of finalize.
(gtk_viewport_get_hadjustment):
(gtk_viewport_get_vadjustment):
(gtk_viewport_size_allocate): demand create h/v adjustment
if required.
* gtk/gtkwidget.c (gtk_widget_finalize): duplicate part of the
gtk_widget_real_destroy () functionality.
(gtk_widget_real_destroy): reinitialize with a new style, instead
of setting widget->style to NULL.
Fri May 5 13:02:09 2000 Tim Janik <timj@gtk.org>
* gtk/gtkcalendar.c:
* gtk/gtkbutton.c: ported _get_type() implementation over to
GType, either to preserve memchunks allocation facilities,
or because Gtk+ 1.0 GtkTypeInfo was still being used.
* gtk/gtkobject.[hc]: derive from GObject. ported various functions
over. prepare for ::destroy to be emitted multiple times.
removed reference tracer magic. chain into GObjectClass.shutdown()
to emit ::destroy signal.
* gtk/gtksignal.c: removed assumptions about GTK_TYPE_OBJECT being
fundamental.
* gtk/gtkmain.c: removed gtk_object_post_arg_parsing_init()
cludge.
* gtk/gtksocket.c:
* gtk/gtkplug.c:
* gtk/gtklayout.c:
* gtk/gtklabel.c:
* gtk/gtkargcollector.c:
* gtk/gtkarg.c: various fixups to work with GTK_TYPE_OBJECT
not being a fundamental anymore, and to work with the new
type system (nuked fundamental type varargs clutter).
* gtk/*.c: install finalize handlers in the GObjectClass
part of the class structure.
changed direct GTK_OBJECT()->klass accesses to
GTK_*_GET_CLASS().
changed direct object_class->type accesses to GTK_CLASS_TYPE().
* gtktypeutils.[hc]: use the reserved fundamental ids provided by
GType. made most of the GTK_*() type macros and Gtk* typedefs
simple wrappers around macros and types provided by GType.
most notably, a significant portion of the old API vanished:
GTK_TYPE_MAKE(),
GTK_TYPE_SEQNO(),
GTK_TYPE_FLAT_FIRST, GTK_TYPE_FLAT_LAST,
GTK_TYPE_STRUCTURED_FIRST, GTK_TYPE_STRUCTURED_LAST,
GTK_TYPE_ARGS,
GTK_TYPE_CALLBACK,
GTK_TYPE_C_CALLBACK,
GTK_TYPE_FOREIGN,
GtkTypeQuery,
gtk_type_query(),
gtk_type_set_varargs_type(),
gtk_type_get_varargs_type(),
gtk_type_check_object_cast(),
gtk_type_check_class_cast(),
gtk_type_describe_tree(),
gtk_type_describe_heritage(),
gtk_type_free(),
gtk_type_children_types(),
gtk_type_set_chunk_alloc(),
gtk_type_register_enum(),
gtk_type_register_flags(),
gtk_type_parent_class().
replacements, where available are described in ../docs/Changes-1.4.txt.
implemented compatibility functions for the remaining API.
* configure.in: depend on glib 1.3.1, use gobject module.
2000-05-12 15:25:50 +00:00
|
|
|
class->text_pushed = gtk_statusbar_update;
|
|
|
|
class->text_popped = gtk_statusbar_update;
|
2007-01-07 05:34:40 +00:00
|
|
|
|
2011-01-24 02:50:39 +00:00
|
|
|
/**
|
2007-01-07 05:34:40 +00:00
|
|
|
* GtkStatusbar::text-pushed:
|
2011-01-24 02:50:39 +00:00
|
|
|
* @statusbar: the object which received the signal
|
|
|
|
* @context_id: the context id of the relevant message/statusbar
|
|
|
|
* @text: the message that was pushed
|
|
|
|
*
|
2007-01-07 05:34:40 +00:00
|
|
|
* Is emitted whenever a new message gets pushed onto a statusbar's stack.
|
|
|
|
*/
|
1998-02-23 15:13:03 +00:00
|
|
|
statusbar_signals[SIGNAL_TEXT_PUSHED] =
|
2008-08-08 14:36:41 +00:00
|
|
|
g_signal_new (I_("text-pushed"),
|
2002-10-09 00:38:22 +00:00
|
|
|
G_OBJECT_CLASS_TYPE (class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GtkStatusbarClass, text_pushed),
|
|
|
|
NULL, NULL,
|
|
|
|
_gtk_marshal_VOID__UINT_STRING,
|
|
|
|
G_TYPE_NONE, 2,
|
|
|
|
G_TYPE_UINT,
|
|
|
|
G_TYPE_STRING);
|
2007-01-07 05:34:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GtkStatusbar::text-popped:
|
2011-01-24 02:50:39 +00:00
|
|
|
* @statusbar: the object which received the signal
|
|
|
|
* @context_id: the context id of the relevant message/statusbar
|
|
|
|
* @text: the message that was just popped
|
2007-01-07 05:34:40 +00:00
|
|
|
*
|
|
|
|
* Is emitted whenever a new message is popped off a statusbar's stack.
|
|
|
|
*/
|
1998-02-23 15:13:03 +00:00
|
|
|
statusbar_signals[SIGNAL_TEXT_POPPED] =
|
2008-08-08 14:36:41 +00:00
|
|
|
g_signal_new (I_("text-popped"),
|
2002-10-09 00:38:22 +00:00
|
|
|
G_OBJECT_CLASS_TYPE (class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GtkStatusbarClass, text_popped),
|
|
|
|
NULL, NULL,
|
|
|
|
_gtk_marshal_VOID__UINT_STRING,
|
|
|
|
G_TYPE_NONE, 2,
|
|
|
|
G_TYPE_UINT,
|
|
|
|
G_TYPE_STRING);
|
2001-06-04 23:15:51 +00:00
|
|
|
|
|
|
|
gtk_widget_class_install_style_property (widget_class,
|
2005-03-09 06:15:13 +00:00
|
|
|
g_param_spec_enum ("shadow-type",
|
2004-01-16 23:10:05 +00:00
|
|
|
P_("Shadow type"),
|
|
|
|
P_("Style of bevel around the statusbar text"),
|
2001-06-04 23:15:51 +00:00
|
|
|
GTK_TYPE_SHADOW_TYPE,
|
|
|
|
GTK_SHADOW_IN,
|
2005-03-22 02:14:55 +00:00
|
|
|
GTK_PARAM_READABLE));
|
2010-07-12 23:46:15 +00:00
|
|
|
|
2010-08-26 17:15:37 +00:00
|
|
|
g_type_class_add_private (class, sizeof (GtkStatusbarPrivate));
|
2011-07-01 04:47:41 +00:00
|
|
|
|
|
|
|
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_STATUSBAR_ACCESSIBLE);
|
1998-01-18 23:01:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_statusbar_init (GtkStatusbar *statusbar)
|
|
|
|
{
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkStatusbarPrivate *priv;
|
2010-07-12 23:46:15 +00:00
|
|
|
GtkBox *box = GTK_BOX (statusbar);
|
2009-11-12 17:57:37 +00:00
|
|
|
GtkWidget *message_area;
|
2001-06-04 23:15:51 +00:00
|
|
|
GtkShadowType shadow_type;
|
2010-07-12 23:46:15 +00:00
|
|
|
|
|
|
|
statusbar->priv = G_TYPE_INSTANCE_GET_PRIVATE (statusbar,
|
|
|
|
GTK_TYPE_STATUSBAR,
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkStatusbarPrivate);
|
2010-07-12 23:46:15 +00:00
|
|
|
priv = statusbar->priv;
|
1998-02-23 15:13:03 +00:00
|
|
|
|
2009-07-24 04:45:34 +00:00
|
|
|
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (box), TRUE);
|
|
|
|
|
2010-05-24 23:57:10 +00:00
|
|
|
gtk_box_set_spacing (box, 2);
|
|
|
|
gtk_box_set_homogeneous (box, FALSE);
|
1998-01-18 23:01:09 +00:00
|
|
|
|
2005-03-26 05:49:15 +00:00
|
|
|
gtk_widget_style_get (GTK_WIDGET (statusbar), "shadow-type", &shadow_type, NULL);
|
2010-07-12 23:46:15 +00:00
|
|
|
|
|
|
|
priv->frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (priv->frame), shadow_type);
|
|
|
|
gtk_box_pack_start (box, priv->frame, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (priv->frame);
|
1998-01-18 23:01:09 +00:00
|
|
|
|
2010-10-31 17:07:20 +00:00
|
|
|
message_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
2010-07-12 23:46:15 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (priv->frame), message_area);
|
2009-11-12 17:57:37 +00:00
|
|
|
gtk_widget_show (message_area);
|
|
|
|
|
2010-07-12 23:46:15 +00:00
|
|
|
priv->label = gtk_label_new ("");
|
|
|
|
gtk_label_set_single_line_mode (GTK_LABEL (priv->label), TRUE);
|
2011-05-19 11:16:18 +00:00
|
|
|
gtk_widget_set_halign (priv->label, GTK_ALIGN_START);
|
|
|
|
gtk_widget_set_valign (priv->label, GTK_ALIGN_CENTER);
|
2010-07-12 23:46:15 +00:00
|
|
|
gtk_label_set_ellipsize (GTK_LABEL (priv->label), PANGO_ELLIPSIZE_END);
|
|
|
|
gtk_container_add (GTK_CONTAINER (message_area), priv->label);
|
|
|
|
gtk_widget_show (priv->label);
|
|
|
|
|
|
|
|
priv->seq_context_id = 1;
|
|
|
|
priv->seq_message_id = 1;
|
|
|
|
priv->messages = NULL;
|
|
|
|
priv->keys = NULL;
|
1998-01-18 23:01:09 +00:00
|
|
|
}
|
|
|
|
|
2009-11-12 17:57:37 +00:00
|
|
|
static GtkBuildableIface *parent_buildable_iface;
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_statusbar_buildable_interface_init (GtkBuildableIface *iface)
|
|
|
|
{
|
|
|
|
parent_buildable_iface = g_type_interface_peek_parent (iface);
|
|
|
|
iface->get_internal_child = gtk_statusbar_buildable_get_internal_child;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GObject *
|
|
|
|
gtk_statusbar_buildable_get_internal_child (GtkBuildable *buildable,
|
|
|
|
GtkBuilder *builder,
|
|
|
|
const gchar *childname)
|
|
|
|
{
|
2010-07-12 23:46:15 +00:00
|
|
|
GtkStatusbar *statusbar = GTK_STATUSBAR (buildable);
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkStatusbarPrivate *priv = statusbar->priv;
|
2010-07-12 23:46:15 +00:00
|
|
|
|
2009-11-12 17:57:37 +00:00
|
|
|
if (strcmp (childname, "message_area") == 0)
|
2010-07-12 23:46:15 +00:00
|
|
|
return G_OBJECT (gtk_bin_get_child (GTK_BIN (priv->frame)));
|
2009-11-12 17:57:37 +00:00
|
|
|
|
|
|
|
return parent_buildable_iface->get_internal_child (buildable,
|
|
|
|
builder,
|
|
|
|
childname);
|
|
|
|
}
|
|
|
|
|
2007-01-07 05:34:40 +00:00
|
|
|
/**
|
|
|
|
* gtk_statusbar_new:
|
|
|
|
*
|
|
|
|
* Creates a new #GtkStatusbar ready for messages.
|
|
|
|
*
|
|
|
|
* Returns: the new #GtkStatusbar
|
|
|
|
*/
|
1998-01-18 23:01:09 +00:00
|
|
|
GtkWidget*
|
1998-05-03 22:41:32 +00:00
|
|
|
gtk_statusbar_new (void)
|
1998-01-18 23:01:09 +00:00
|
|
|
{
|
2002-10-09 00:38:22 +00:00
|
|
|
return g_object_new (GTK_TYPE_STATUSBAR, NULL);
|
1998-02-23 15:13:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_statusbar_update (GtkStatusbar *statusbar,
|
1998-03-01 23:29:40 +00:00
|
|
|
guint context_id,
|
1998-02-23 15:13:03 +00:00
|
|
|
const gchar *text)
|
|
|
|
{
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkStatusbarPrivate *priv;
|
2010-07-12 23:46:15 +00:00
|
|
|
|
1998-02-23 15:13:03 +00:00
|
|
|
g_return_if_fail (GTK_IS_STATUSBAR (statusbar));
|
1998-01-18 23:01:09 +00:00
|
|
|
|
2010-07-12 23:46:15 +00:00
|
|
|
priv = statusbar->priv;
|
|
|
|
|
1998-02-23 15:13:03 +00:00
|
|
|
if (!text)
|
|
|
|
text = "";
|
1998-01-18 23:01:09 +00:00
|
|
|
|
2010-07-12 23:46:15 +00:00
|
|
|
gtk_label_set_text (GTK_LABEL (priv->label), text);
|
1998-01-18 23:01:09 +00:00
|
|
|
}
|
|
|
|
|
2007-01-07 05:34:40 +00:00
|
|
|
/**
|
|
|
|
* gtk_statusbar_get_context_id:
|
|
|
|
* @statusbar: a #GtkStatusbar
|
|
|
|
* @context_description: textual description of what context
|
|
|
|
* the new message is being used in
|
|
|
|
*
|
|
|
|
* Returns a new context identifier, given a description
|
|
|
|
* of the actual context. Note that the description is
|
|
|
|
* <emphasis>not</emphasis> shown in the UI.
|
|
|
|
*
|
|
|
|
* Returns: an integer id
|
|
|
|
*/
|
1998-03-01 23:29:40 +00:00
|
|
|
guint
|
|
|
|
gtk_statusbar_get_context_id (GtkStatusbar *statusbar,
|
|
|
|
const gchar *context_description)
|
|
|
|
{
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkStatusbarPrivate *priv;
|
1998-03-01 23:29:40 +00:00
|
|
|
gchar *string;
|
2007-05-23 15:06:03 +00:00
|
|
|
guint id;
|
1998-03-01 23:29:40 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_STATUSBAR (statusbar), 0);
|
|
|
|
g_return_val_if_fail (context_description != NULL, 0);
|
|
|
|
|
2010-07-12 23:46:15 +00:00
|
|
|
priv = statusbar->priv;
|
|
|
|
|
1998-03-01 23:29:40 +00:00
|
|
|
/* we need to preserve namespaces on object datas */
|
|
|
|
string = g_strconcat ("gtk-status-bar-context:", context_description, NULL);
|
|
|
|
|
2007-05-01 22:22:49 +00:00
|
|
|
id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (statusbar), string));
|
|
|
|
if (id == 0)
|
1998-03-01 23:29:40 +00:00
|
|
|
{
|
2010-07-12 23:46:15 +00:00
|
|
|
id = priv->seq_context_id++;
|
2007-05-01 22:22:49 +00:00
|
|
|
g_object_set_data_full (G_OBJECT (statusbar), string, GUINT_TO_POINTER (id), NULL);
|
2010-07-12 23:46:15 +00:00
|
|
|
priv->keys = g_slist_prepend (priv->keys, string);
|
1998-03-01 23:29:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
g_free (string);
|
|
|
|
|
2007-05-01 22:22:49 +00:00
|
|
|
return id;
|
1998-03-01 23:29:40 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 14:01:23 +00:00
|
|
|
static GtkStatusbarMsg *
|
|
|
|
gtk_statusbar_msg_create (GtkStatusbar *statusbar,
|
|
|
|
guint context_id,
|
|
|
|
const gchar *text)
|
|
|
|
{
|
|
|
|
GtkStatusbarMsg *msg;
|
|
|
|
|
|
|
|
msg = g_slice_new (GtkStatusbarMsg);
|
|
|
|
msg->text = g_strdup (text);
|
|
|
|
msg->context_id = context_id;
|
|
|
|
msg->message_id = statusbar->priv->seq_message_id++;
|
|
|
|
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_statusbar_msg_free (GtkStatusbarMsg *msg)
|
|
|
|
{
|
|
|
|
g_free (msg->text);
|
|
|
|
g_slice_free (GtkStatusbarMsg, msg);
|
|
|
|
}
|
|
|
|
|
2007-01-07 05:34:40 +00:00
|
|
|
/**
|
|
|
|
* gtk_statusbar_push:
|
|
|
|
* @statusbar: a #GtkStatusbar
|
|
|
|
* @context_id: the message's context id, as returned by
|
|
|
|
* gtk_statusbar_get_context_id()
|
|
|
|
* @text: the message to add to the statusbar
|
|
|
|
*
|
|
|
|
* Pushes a new message onto a statusbar's stack.
|
|
|
|
*
|
|
|
|
* Returns: a message id that can be used with
|
|
|
|
* gtk_statusbar_remove().
|
|
|
|
*/
|
1998-02-23 15:13:03 +00:00
|
|
|
guint
|
|
|
|
gtk_statusbar_push (GtkStatusbar *statusbar,
|
1998-03-01 23:29:40 +00:00
|
|
|
guint context_id,
|
1998-02-23 15:13:03 +00:00
|
|
|
const gchar *text)
|
1998-01-18 23:01:09 +00:00
|
|
|
{
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkStatusbarPrivate *priv;
|
1998-01-18 23:01:09 +00:00
|
|
|
GtkStatusbarMsg *msg;
|
1998-02-23 15:13:03 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_STATUSBAR (statusbar), 0);
|
|
|
|
g_return_val_if_fail (text != NULL, 0);
|
1998-01-18 23:01:09 +00:00
|
|
|
|
2010-07-12 23:46:15 +00:00
|
|
|
priv = statusbar->priv;
|
|
|
|
|
2011-04-09 14:01:23 +00:00
|
|
|
msg = gtk_statusbar_msg_create (statusbar, context_id, text);
|
2010-07-12 23:46:15 +00:00
|
|
|
priv->messages = g_slist_prepend (priv->messages, msg);
|
1998-01-18 23:01:09 +00:00
|
|
|
|
2002-10-09 00:38:22 +00:00
|
|
|
g_signal_emit (statusbar,
|
|
|
|
statusbar_signals[SIGNAL_TEXT_PUSHED],
|
|
|
|
0,
|
|
|
|
msg->context_id,
|
|
|
|
msg->text);
|
1998-01-18 23:01:09 +00:00
|
|
|
|
1998-03-01 23:29:40 +00:00
|
|
|
return msg->message_id;
|
1998-01-18 23:01:09 +00:00
|
|
|
}
|
|
|
|
|
2007-01-07 05:34:40 +00:00
|
|
|
/**
|
|
|
|
* gtk_statusbar_pop:
|
|
|
|
* @statusbar: a #GtkStatusBar
|
|
|
|
* @context_id: a context identifier
|
|
|
|
*
|
|
|
|
* Removes the first message in the #GtkStatusBar's stack
|
|
|
|
* with the given context id.
|
|
|
|
*
|
|
|
|
* Note that this may not change the displayed message, if
|
|
|
|
* the message at the top of the stack has a different
|
|
|
|
* context id.
|
|
|
|
*/
|
1998-02-23 15:13:03 +00:00
|
|
|
void
|
1998-03-01 23:29:40 +00:00
|
|
|
gtk_statusbar_pop (GtkStatusbar *statusbar,
|
|
|
|
guint context_id)
|
1998-01-18 23:01:09 +00:00
|
|
|
{
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkStatusbarPrivate *priv;
|
1998-02-23 15:13:03 +00:00
|
|
|
GtkStatusbarMsg *msg;
|
1998-01-18 23:01:09 +00:00
|
|
|
|
1998-02-23 15:13:03 +00:00
|
|
|
g_return_if_fail (GTK_IS_STATUSBAR (statusbar));
|
1998-01-18 23:01:09 +00:00
|
|
|
|
2010-07-12 23:46:15 +00:00
|
|
|
priv = statusbar->priv;
|
|
|
|
|
|
|
|
if (priv->messages)
|
1998-02-23 15:13:03 +00:00
|
|
|
{
|
1998-03-01 23:29:40 +00:00
|
|
|
GSList *list;
|
1998-04-10 00:44:35 +00:00
|
|
|
|
2010-07-12 23:46:15 +00:00
|
|
|
for (list = priv->messages; list; list = list->next)
|
1998-04-10 00:44:35 +00:00
|
|
|
{
|
|
|
|
msg = list->data;
|
|
|
|
|
|
|
|
if (msg->context_id == context_id)
|
|
|
|
{
|
2011-04-09 14:01:23 +00:00
|
|
|
priv->messages = g_slist_remove_link (priv->messages, list);
|
|
|
|
gtk_statusbar_msg_free (msg);
|
1998-04-10 00:44:35 +00:00
|
|
|
g_slist_free_1 (list);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1998-02-23 15:13:03 +00:00
|
|
|
}
|
|
|
|
|
2010-07-12 23:46:15 +00:00
|
|
|
msg = priv->messages ? priv->messages->data : NULL;
|
1998-01-18 23:01:09 +00:00
|
|
|
|
2002-10-09 00:38:22 +00:00
|
|
|
g_signal_emit (statusbar,
|
|
|
|
statusbar_signals[SIGNAL_TEXT_POPPED],
|
|
|
|
0,
|
|
|
|
(guint) (msg ? msg->context_id : 0),
|
|
|
|
msg ? msg->text : NULL);
|
1998-01-18 23:01:09 +00:00
|
|
|
}
|
|
|
|
|
2007-01-07 05:34:40 +00:00
|
|
|
/**
|
|
|
|
* gtk_statusbar_remove:
|
|
|
|
* @statusbar: a #GtkStatusBar
|
|
|
|
* @context_id: a context identifier
|
|
|
|
* @message_id: a message identifier, as returned by gtk_statusbar_push()
|
|
|
|
*
|
|
|
|
* Forces the removal of a message from a statusbar's stack.
|
|
|
|
* The exact @context_id and @message_id must be specified.
|
|
|
|
*/
|
1998-01-18 23:01:09 +00:00
|
|
|
void
|
1998-03-01 23:29:40 +00:00
|
|
|
gtk_statusbar_remove (GtkStatusbar *statusbar,
|
|
|
|
guint context_id,
|
|
|
|
guint message_id)
|
1998-01-18 23:01:09 +00:00
|
|
|
{
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkStatusbarPrivate *priv;
|
1998-02-23 15:13:03 +00:00
|
|
|
GtkStatusbarMsg *msg;
|
1998-01-18 23:01:09 +00:00
|
|
|
|
1998-02-23 15:13:03 +00:00
|
|
|
g_return_if_fail (GTK_IS_STATUSBAR (statusbar));
|
1998-03-01 23:29:40 +00:00
|
|
|
g_return_if_fail (message_id > 0);
|
1998-01-18 23:01:09 +00:00
|
|
|
|
2010-07-12 23:46:15 +00:00
|
|
|
priv = statusbar->priv;
|
|
|
|
|
|
|
|
msg = priv->messages ? priv->messages->data : NULL;
|
1998-02-23 15:13:03 +00:00
|
|
|
if (msg)
|
|
|
|
{
|
1998-03-01 23:29:40 +00:00
|
|
|
GSList *list;
|
|
|
|
|
|
|
|
/* care about signal emission if the topmost item is removed */
|
|
|
|
if (msg->context_id == context_id &&
|
|
|
|
msg->message_id == message_id)
|
1998-02-23 15:13:03 +00:00
|
|
|
{
|
1998-03-01 23:29:40 +00:00
|
|
|
gtk_statusbar_pop (statusbar, context_id);
|
1998-02-23 15:13:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-07-12 23:46:15 +00:00
|
|
|
for (list = priv->messages; list; list = list->next)
|
1998-02-23 15:13:03 +00:00
|
|
|
{
|
|
|
|
msg = list->data;
|
|
|
|
|
1998-03-01 23:29:40 +00:00
|
|
|
if (msg->context_id == context_id &&
|
|
|
|
msg->message_id == message_id)
|
1998-02-23 15:13:03 +00:00
|
|
|
{
|
2010-07-12 23:46:15 +00:00
|
|
|
priv->messages = g_slist_remove_link (priv->messages, list);
|
2011-04-09 14:01:23 +00:00
|
|
|
gtk_statusbar_msg_free (msg);
|
1998-03-01 23:29:40 +00:00
|
|
|
g_slist_free_1 (list);
|
1998-02-23 15:13:03 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1998-01-18 23:01:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-15 20:58:30 +00:00
|
|
|
/**
|
|
|
|
* gtk_statusbar_remove_all:
|
|
|
|
* @statusbar: a #GtkStatusBar
|
|
|
|
* @context_id: a context identifier
|
|
|
|
*
|
|
|
|
* Forces the removal of all messages from a statusbar's
|
|
|
|
* stack with the exact @context_id.
|
|
|
|
*
|
|
|
|
* Since: 2.22
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_statusbar_remove_all (GtkStatusbar *statusbar,
|
|
|
|
guint context_id)
|
|
|
|
{
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkStatusbarPrivate *priv;
|
2010-05-15 20:58:30 +00:00
|
|
|
GtkStatusbarMsg *msg;
|
|
|
|
GSList *prev, *list;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_STATUSBAR (statusbar));
|
|
|
|
|
2010-07-12 23:46:15 +00:00
|
|
|
priv = statusbar->priv;
|
|
|
|
|
|
|
|
if (priv->messages == NULL)
|
2010-05-15 20:58:30 +00:00
|
|
|
return;
|
|
|
|
|
2010-07-12 23:46:15 +00:00
|
|
|
msg = priv->messages->data;
|
2010-05-15 20:58:30 +00:00
|
|
|
|
|
|
|
/* care about signal emission if the topmost item is removed */
|
|
|
|
if (msg->context_id == context_id)
|
|
|
|
{
|
|
|
|
gtk_statusbar_pop (statusbar, context_id);
|
|
|
|
|
|
|
|
prev = NULL;
|
2010-07-12 23:46:15 +00:00
|
|
|
list = priv->messages;
|
2010-05-15 20:58:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-12 23:46:15 +00:00
|
|
|
prev = priv->messages;
|
2010-05-15 20:58:30 +00:00
|
|
|
list = prev->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (list != NULL)
|
|
|
|
{
|
|
|
|
msg = list->data;
|
|
|
|
|
|
|
|
if (msg->context_id == context_id)
|
|
|
|
{
|
|
|
|
if (prev == NULL)
|
2010-07-12 23:46:15 +00:00
|
|
|
priv->messages = list->next;
|
2010-05-15 20:58:30 +00:00
|
|
|
else
|
|
|
|
prev->next = list->next;
|
|
|
|
|
2011-04-09 14:01:23 +00:00
|
|
|
gtk_statusbar_msg_free (msg);
|
2010-05-15 20:58:30 +00:00
|
|
|
g_slist_free_1 (list);
|
|
|
|
|
|
|
|
if (prev == NULL)
|
2010-07-12 23:46:15 +00:00
|
|
|
prev = priv->messages;
|
2010-05-15 20:58:30 +00:00
|
|
|
|
2011-01-31 16:32:19 +00:00
|
|
|
if (prev)
|
|
|
|
list = prev->next;
|
|
|
|
else
|
|
|
|
list = NULL;
|
2010-05-15 20:58:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
prev = list;
|
|
|
|
list = prev->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-12 17:57:37 +00:00
|
|
|
/**
|
|
|
|
* gtk_statusbar_get_message_area:
|
|
|
|
* @statusbar: a #GtkStatusBar
|
|
|
|
*
|
|
|
|
* Retrieves the box containing the label widget.
|
|
|
|
*
|
2010-09-21 04:18:11 +00:00
|
|
|
* Returns: (transfer none): a #GtkBox
|
2009-11-12 17:57:37 +00:00
|
|
|
*
|
|
|
|
* Since: 2.20
|
|
|
|
*/
|
|
|
|
GtkWidget*
|
|
|
|
gtk_statusbar_get_message_area (GtkStatusbar *statusbar)
|
|
|
|
{
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkStatusbarPrivate *priv;
|
2010-07-12 23:46:15 +00:00
|
|
|
|
2009-11-12 17:57:37 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_STATUSBAR (statusbar), NULL);
|
|
|
|
|
2010-07-12 23:46:15 +00:00
|
|
|
priv = statusbar->priv;
|
|
|
|
|
|
|
|
return gtk_bin_get_child (GTK_BIN (priv->frame));
|
2009-11-12 17:57:37 +00:00
|
|
|
}
|
|
|
|
|
1998-01-18 23:01:09 +00:00
|
|
|
static void
|
2010-09-18 23:55:42 +00:00
|
|
|
gtk_statusbar_destroy (GtkWidget *widget)
|
1998-01-18 23:01:09 +00:00
|
|
|
{
|
2010-09-18 23:55:42 +00:00
|
|
|
GtkStatusbar *statusbar = GTK_STATUSBAR (widget);
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkStatusbarPrivate *priv = statusbar->priv;
|
1998-02-23 15:13:03 +00:00
|
|
|
|
2011-04-09 14:01:23 +00:00
|
|
|
g_slist_free_full (priv->messages, (GDestroyNotify) gtk_statusbar_msg_free);
|
2010-07-12 23:46:15 +00:00
|
|
|
priv->messages = NULL;
|
1998-01-18 23:01:09 +00:00
|
|
|
|
2011-04-09 14:01:23 +00:00
|
|
|
g_slist_free_full (priv->keys, g_free);
|
2010-07-12 23:46:15 +00:00
|
|
|
priv->keys = NULL;
|
1998-03-12 07:28:41 +00:00
|
|
|
|
2010-09-18 23:55:42 +00:00
|
|
|
GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->destroy (widget);
|
1998-03-01 23:29:40 +00:00
|
|
|
}
|
2001-03-29 21:17:45 +00:00
|
|
|
|
2004-11-10 16:33:33 +00:00
|
|
|
/* look for extra children between the frame containing
|
2010-10-08 05:43:24 +00:00
|
|
|
* the label and where we want to draw the resize grip
|
2004-11-10 16:33:33 +00:00
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
has_extra_children (GtkStatusbar *statusbar)
|
|
|
|
{
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkStatusbarPrivate *priv = statusbar->priv;
|
2010-07-14 22:46:22 +00:00
|
|
|
GtkPackType child_pack_type, frame_pack_type;
|
|
|
|
GtkWidget *child, *frame;
|
2010-06-02 04:28:22 +00:00
|
|
|
GList *l, *children;
|
2010-07-26 13:24:15 +00:00
|
|
|
gboolean retval = FALSE;
|
2004-11-10 16:33:33 +00:00
|
|
|
|
|
|
|
frame = NULL;
|
2010-07-26 13:24:15 +00:00
|
|
|
children = _gtk_box_get_children (GTK_BOX (statusbar));
|
2010-06-02 04:28:22 +00:00
|
|
|
for (l = children; l; l = l->next)
|
2004-11-10 16:33:33 +00:00
|
|
|
{
|
|
|
|
frame = l->data;
|
|
|
|
|
2010-07-14 22:46:22 +00:00
|
|
|
if (frame == priv->frame)
|
2010-10-08 05:43:24 +00:00
|
|
|
break;
|
2004-11-10 16:33:33 +00:00
|
|
|
}
|
2010-07-14 22:46:22 +00:00
|
|
|
|
|
|
|
gtk_box_query_child_packing (GTK_BOX (statusbar), frame,
|
|
|
|
NULL, NULL, NULL, &frame_pack_type);
|
|
|
|
|
2004-11-10 16:33:33 +00:00
|
|
|
for (l = l->next; l; l = l->next)
|
|
|
|
{
|
|
|
|
child = l->data;
|
|
|
|
|
2010-07-14 22:46:22 +00:00
|
|
|
if (!gtk_widget_get_visible (child))
|
2010-10-08 05:43:24 +00:00
|
|
|
continue;
|
2004-11-10 16:33:33 +00:00
|
|
|
|
2010-10-08 05:43:24 +00:00
|
|
|
gtk_box_query_child_packing (GTK_BOX (statusbar), child,
|
2010-07-14 22:46:22 +00:00
|
|
|
NULL, NULL, NULL, &child_pack_type);
|
|
|
|
|
|
|
|
if (frame_pack_type == GTK_PACK_START || child_pack_type == GTK_PACK_END)
|
2010-07-26 13:24:15 +00:00
|
|
|
{
|
2010-10-08 05:43:24 +00:00
|
|
|
retval = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2004-11-10 16:33:33 +00:00
|
|
|
}
|
|
|
|
|
2010-06-02 04:28:22 +00:00
|
|
|
g_list_free (children);
|
|
|
|
|
2010-07-26 13:24:15 +00:00
|
|
|
return retval;
|
2004-11-10 16:33:33 +00:00
|
|
|
}
|
|
|
|
|
2001-06-04 23:15:51 +00:00
|
|
|
static void
|
2010-10-08 05:43:24 +00:00
|
|
|
gtk_statusbar_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation)
|
2001-06-04 23:15:51 +00:00
|
|
|
{
|
2004-11-10 16:33:33 +00:00
|
|
|
GtkStatusbar *statusbar = GTK_STATUSBAR (widget);
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkStatusbarPrivate *priv = statusbar->priv;
|
2004-11-12 17:52:08 +00:00
|
|
|
gboolean extra_children = FALSE;
|
2010-10-08 05:43:24 +00:00
|
|
|
gboolean has_resize_grip = FALSE;
|
2004-11-12 17:52:08 +00:00
|
|
|
GdkRectangle rect;
|
2010-10-08 05:43:24 +00:00
|
|
|
GtkWidget *window;
|
|
|
|
gint x, y;
|
|
|
|
GdkRectangle translated_rect;
|
2001-06-04 23:15:51 +00:00
|
|
|
|
2010-10-08 05:43:24 +00:00
|
|
|
window = gtk_widget_get_toplevel (widget);
|
2010-10-30 01:13:55 +00:00
|
|
|
|
2010-10-08 05:43:24 +00:00
|
|
|
if (GTK_IS_WINDOW (window) &&
|
|
|
|
gtk_window_resize_grip_is_visible (GTK_WINDOW (window)))
|
2004-11-10 16:33:33 +00:00
|
|
|
{
|
2010-10-08 05:43:24 +00:00
|
|
|
gtk_window_get_resize_grip_area (GTK_WINDOW (window), &rect);
|
2012-01-15 00:53:48 +00:00
|
|
|
if (gtk_widget_translate_coordinates (widget, window, 0, 0, &x, &y))
|
2010-10-08 05:43:24 +00:00
|
|
|
{
|
|
|
|
translated_rect.x = x;
|
|
|
|
translated_rect.y = y;
|
|
|
|
translated_rect.width = allocation->width;
|
|
|
|
translated_rect.height = allocation->height;
|
|
|
|
|
|
|
|
if (gdk_rectangle_intersect (&rect, &translated_rect, NULL))
|
|
|
|
{
|
|
|
|
has_resize_grip = TRUE;
|
|
|
|
extra_children = has_extra_children (statusbar);
|
|
|
|
|
|
|
|
/* If there are extra children, we don't want them to occupy
|
|
|
|
* the space where we draw the resize grip, so we temporarily
|
|
|
|
* shrink the allocation.
|
|
|
|
* If there are no extra children, we want the frame to get
|
|
|
|
* the full allocation, and we fix up the allocation of the
|
|
|
|
* label afterwards to make room for the grip.
|
|
|
|
*/
|
|
|
|
if (extra_children)
|
|
|
|
{
|
|
|
|
allocation->width -= rect.width;
|
|
|
|
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
|
|
|
|
allocation->x += rect.width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-11-10 16:33:33 +00:00
|
|
|
}
|
2005-07-21 19:10:48 +00:00
|
|
|
|
2004-11-09 07:27:40 +00:00
|
|
|
/* chain up normally */
|
2006-05-02 23:56:43 +00:00
|
|
|
GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->size_allocate (widget, allocation);
|
2004-11-09 07:27:40 +00:00
|
|
|
|
2010-10-08 05:43:24 +00:00
|
|
|
if (has_resize_grip)
|
2001-06-04 23:15:51 +00:00
|
|
|
{
|
2010-10-08 05:43:24 +00:00
|
|
|
if (extra_children)
|
|
|
|
{
|
|
|
|
allocation->width += rect.width;
|
|
|
|
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
|
|
|
|
allocation->x -= rect.width;
|
|
|
|
|
|
|
|
gtk_widget_set_allocation (widget, allocation);
|
|
|
|
}
|
2004-11-10 16:33:33 +00:00
|
|
|
else
|
2010-10-08 05:43:24 +00:00
|
|
|
{
|
2010-08-11 20:54:33 +00:00
|
|
|
GtkAllocation child_allocation, frame_allocation;
|
2010-10-08 05:43:24 +00:00
|
|
|
GtkWidget *child;
|
2006-12-25 12:12:10 +00:00
|
|
|
|
2010-10-08 05:43:24 +00:00
|
|
|
/* Use the frame's child instead of statusbar->label directly, in case
|
|
|
|
* the label has been replaced by a container as the frame's child
|
|
|
|
* (and the label reparented into that container).
|
|
|
|
*/
|
|
|
|
child = gtk_bin_get_child (GTK_BIN (priv->frame));
|
2006-12-25 12:12:10 +00:00
|
|
|
|
2010-08-11 20:54:33 +00:00
|
|
|
gtk_widget_get_allocation (child, &child_allocation);
|
|
|
|
gtk_widget_get_allocation (priv->frame, &frame_allocation);
|
2010-10-08 05:43:24 +00:00
|
|
|
if (child_allocation.width + rect.width > frame_allocation.width)
|
|
|
|
{
|
|
|
|
/* shrink the label to make room for the grip */
|
|
|
|
*allocation = child_allocation;
|
|
|
|
allocation->width = MAX (1, allocation->width - rect.width);
|
|
|
|
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
|
|
|
|
allocation->x += child_allocation.width - allocation->width;
|
|
|
|
|
|
|
|
gtk_widget_size_allocate (child, allocation);
|
|
|
|
}
|
|
|
|
}
|
2001-06-04 23:15:51 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-09 07:27:40 +00:00
|
|
|
|
2004-11-09 17:20:04 +00:00
|
|
|
static void
|
2010-10-08 05:43:24 +00:00
|
|
|
resize_grip_visible_changed (GObject *object,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
gpointer user_data)
|
2004-11-09 17:20:04 +00:00
|
|
|
{
|
2010-10-08 05:43:24 +00:00
|
|
|
GtkStatusbar *statusbar = GTK_STATUSBAR (user_data);
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkStatusbarPrivate *priv = statusbar->priv;
|
2004-11-09 17:20:04 +00:00
|
|
|
|
2010-10-08 05:43:24 +00:00
|
|
|
gtk_widget_queue_resize (priv->label);
|
|
|
|
gtk_widget_queue_resize (priv->frame);
|
2010-10-30 01:13:55 +00:00
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (statusbar));
|
2010-10-08 05:43:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_statusbar_hierarchy_changed (GtkWidget *widget,
|
|
|
|
GtkWidget *previous_toplevel)
|
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
|
|
|
|
if (previous_toplevel)
|
|
|
|
g_signal_handlers_disconnect_by_func (previous_toplevel,
|
|
|
|
G_CALLBACK (resize_grip_visible_changed),
|
|
|
|
widget);
|
|
|
|
window = gtk_widget_get_toplevel (widget);
|
|
|
|
if (GTK_IS_WINDOW (window))
|
|
|
|
g_signal_connect (window, "notify::resize-grip-visible",
|
|
|
|
G_CALLBACK (resize_grip_visible_changed), widget);
|
2010-10-30 01:13:55 +00:00
|
|
|
|
|
|
|
resize_grip_visible_changed (NULL, NULL, widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_statusbar_realize (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->realize (widget);
|
|
|
|
|
|
|
|
resize_grip_visible_changed (NULL, NULL, widget);
|
2004-11-09 17:20:04 +00:00
|
|
|
}
|