void gdl_dock_add_floating_item (GdlDock *dock, GdlDockItem *item, gint x, gint y, gint width, gint height) { GdlDock *new_dock; g_return_if_fail (dock != NULL); g_return_if_fail (item != NULL); new_dock = GDL_DOCK (g_object_new (GDL_TYPE_DOCK, "master", GDL_DOCK_OBJECT_GET_MASTER (dock), "floating", TRUE, "width", width, "height", height, "floatx", x, "floaty", y, NULL)); if (GTK_WIDGET_VISIBLE (dock)) { gtk_widget_show (GTK_WIDGET (new_dock)); if (GTK_WIDGET_MAPPED (dock)) gtk_widget_map (GTK_WIDGET (new_dock)); /* Make the widget resize. */ gtk_widget_queue_resize (GTK_WIDGET (new_dock)); } gdl_dock_add_item (GDL_DOCK (new_dock), item, GDL_DOCK_TOP); }
/** * gdl_dock_add_floating_item: * @dock: A #GdlDock widget * @item: A #GdlDockItem widget * @x: X coordinate of the floating item * @y: Y coordinate of the floating item * @width: width of the floating item * @height: height of the floating item * * Dock an item as a floating item. It creates a new window containing a new * dock widget sharing the same master where the item is docked. */ void gdl_dock_add_floating_item (GdlDock *dock, GdlDockItem *item, gint x, gint y, gint width, gint height) { GdlDock *new_dock; g_return_if_fail (dock != NULL); g_return_if_fail (item != NULL); new_dock = GDL_DOCK (g_object_new (GDL_TYPE_DOCK, "master", gdl_dock_object_get_master (GDL_DOCK_OBJECT (dock)), "floating", TRUE, "width", width, "height", height, "floatx", x, "floaty", y, "skip-taskbar", dock->priv->skip_taskbar, NULL)); if (gtk_widget_get_visible (GTK_WIDGET (dock))) { gtk_widget_show (GTK_WIDGET (new_dock)); if (gtk_widget_get_mapped (GTK_WIDGET (dock))) gtk_widget_map (GTK_WIDGET (new_dock)); /* Make the widget resize. */ gtk_widget_queue_resize (GTK_WIDGET (new_dock)); } gdl_dock_add_item (GDL_DOCK (new_dock), item, GDL_DOCK_TOP); }
static void gdl_dock_size_request (GtkWidget *widget, GtkRequisition *requisition) { GdlDock *dock; GtkContainer *container; guint border_width; g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK (widget)); dock = GDL_DOCK (widget); container = GTK_CONTAINER (widget); border_width = container->border_width; /* make request to root */ if (dock->root && GTK_WIDGET_VISIBLE (dock->root)) gtk_widget_size_request (GTK_WIDGET (dock->root), requisition); else { requisition->width = 0; requisition->height = 0; }; requisition->width += 2 * border_width; requisition->height += 2 * border_width; widget->requisition = *requisition; }
static void gdl_dock_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GdlDock *dock; GtkContainer *container; guint border_width; g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK (widget)); dock = GDL_DOCK (widget); container = GTK_CONTAINER (widget); border_width = container->border_width; widget->allocation = *allocation; /* reduce allocation by border width */ allocation->x += border_width; allocation->y += border_width; allocation->width = MAX (1, allocation->width - 2 * border_width); allocation->height = MAX (1, allocation->height - 2 * border_width); if (dock->root && GTK_WIDGET_VISIBLE (dock->root)) gtk_widget_size_allocate (GTK_WIDGET (dock->root), allocation); }
static void gdl_dock_get_size (GtkWidget *widget, GtkOrientation orientation, gint *minimum, gint *natural) { GdlDock *dock; GtkContainer *container; g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK (widget)); dock = GDL_DOCK (widget); container = GTK_CONTAINER (widget); *minimum = *natural = 0; /* make request to root */ if (dock->priv->root && gtk_widget_get_visible (GTK_WIDGET (dock->priv->root))) { if (orientation == GTK_ORIENTATION_HORIZONTAL) { gtk_widget_get_preferred_width (GTK_WIDGET (dock->priv->root), minimum, natural); } else { gtk_widget_get_preferred_height (GTK_WIDGET (dock->priv->root), minimum, natural); } } }
static gboolean gdl_dock_reorder (GdlDockObject *object, GdlDockObject *requestor, GdlDockPlacement new_position, GValue *other_data) { GdlDock *dock = GDL_DOCK (object); gboolean handled = FALSE; if (dock->_priv->floating && new_position == GDL_DOCK_FLOATING && dock->root == requestor) { if (other_data && G_VALUE_HOLDS (other_data, GDK_TYPE_RECTANGLE)) { GdkRectangle *rect; rect = g_value_get_boxed (other_data); gtk_window_move (GTK_WINDOW (dock->_priv->window), rect->x, rect->y); handled = TRUE; } } return handled; }
static void gdl_dock_destroy (GtkObject *object) { GdlDock *dock = GDL_DOCK (object); if (dock->_priv) { GdlDockPrivate *priv = dock->_priv; dock->_priv = NULL; if (priv->window) { gtk_widget_destroy (priv->window); priv->floating = FALSE; priv->window = NULL; } /* destroy the xor gc */ if (priv->xor_gc) { g_object_unref (priv->xor_gc); priv->xor_gc = NULL; } g_free (priv); } GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); }
static void gdl_dock_present (GdlDockObject *object, GdlDockObject *child) { GdlDock *dock = GDL_DOCK (object); if (dock->_priv->floating) gtk_window_present (GTK_WINDOW (dock->_priv->window)); }
static void gdl_dock_detach (GdlDockObject *object, gboolean recursive) { GdlDock *dock = GDL_DOCK (object); /* detach children */ if (recursive && dock->priv->root) { gdl_dock_object_detach (dock->priv->root, recursive); } }
GdlDock * gdl_dock_object_get_toplevel (GdlDockObject *object) { GdlDockObject *parent = object; g_return_val_if_fail (object != NULL, NULL); while (parent && !GDL_IS_DOCK (parent)) parent = gdl_dock_object_get_parent_object (parent); return parent ? GDL_DOCK (parent) : NULL; }
static void gdl_dock_add (GtkContainer *container, GtkWidget *widget) { g_return_if_fail (container != NULL); g_return_if_fail (GDL_IS_DOCK (container)); g_return_if_fail (GDL_IS_DOCK_ITEM (widget)); gdl_dock_add_item (GDL_DOCK (container), GDL_DOCK_ITEM (widget), GDL_DOCK_TOP); /* default position */ }
static void gdl_dock_detach (GdlDockObject *object, gboolean recursive) { GdlDock *dock = GDL_DOCK (object); /* detach children */ if (recursive && dock->root) { gdl_dock_object_detach (dock->root, recursive); } GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_ATTACHED); }
static void gdl_dock_hide (GtkWidget *widget) { GdlDock *dock; GdlDockMaster *master; g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK (widget)); GTK_WIDGET_CLASS (gdl_dock_parent_class)->hide (widget); dock = GDL_DOCK (widget); if (dock->priv->floating && dock->priv->window) gtk_widget_hide (dock->priv->window); master = GDL_DOCK_MASTER (gdl_dock_object_get_master (GDL_DOCK_OBJECT (dock))); if (GDL_DOCK (gdl_dock_master_get_controller (master)) == dock) { gdl_dock_master_foreach_toplevel (master, FALSE, (GFunc) gdl_dock_foreach_automatic, gtk_widget_hide); } }
static void gdl_dock_notify_cb (GObject *object, GParamSpec *pspec, gpointer user_data) { GdlDock *dock; g_return_if_fail (object != NULL || GDL_IS_DOCK (object)); dock = GDL_DOCK (object); dock->_priv->auto_title = FALSE; gdl_dock_set_title (dock); }
void Dock::addItem(DockItem& item, DockItem::Placement placement) { _dock_items.push_back(&item); gdl_dock_add_item(GDL_DOCK(_gdl_dock), GDL_DOCK_ITEM(item.gobj()), (GdlDockPlacement)placement); // FIXME: This is a hack to prevent the dock from expanding the main window, this can't be done // initially as the paned doesn't exist. if (Gtk::Paned *paned = getParentPaned()) { paned->set_resize_mode(Gtk::RESIZE_QUEUE); } }
static void gdl_dock_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { GdlDock *dock = GDL_DOCK (object); switch (prop_id) { case PROP_FLOATING: dock->priv->floating = g_value_get_boolean (value); break; case PROP_DEFAULT_TITLE: if (gdl_dock_object_get_master (GDL_DOCK_OBJECT (object)) != NULL) g_object_set (gdl_dock_object_get_master (GDL_DOCK_OBJECT (object)), "default-title", g_value_get_string (value), NULL); break; case PROP_WIDTH: dock->priv->width = g_value_get_int (value); break; case PROP_HEIGHT: dock->priv->height = g_value_get_int (value); break; case PROP_FLOAT_X: dock->priv->float_x = g_value_get_int (value); break; case PROP_FLOAT_Y: dock->priv->float_y = g_value_get_int (value); break; case PROP_SKIP_TASKBAR: gdl_dock_set_skip_taskbar (dock, g_value_get_boolean (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } switch (prop_id) { case PROP_WIDTH: case PROP_HEIGHT: case PROP_FLOAT_X: case PROP_FLOAT_Y: if (dock->priv->floating && dock->priv->window) { gtk_window_resize (GTK_WINDOW (dock->priv->window), dock->priv->width, dock->priv->height); } break; } }
static gboolean gdl_dock_floating_window_delete_event_cb (GtkWidget *widget) { GdlDock *dock; g_return_val_if_fail (GTK_IS_WINDOW (widget), FALSE); dock = GDL_DOCK (g_object_get_data (G_OBJECT (widget), "dock")); if (dock->root) { /* this will call reduce on ourselves, hiding the window if appropiate */ gdl_dock_item_hide_item (GDL_DOCK_ITEM (dock->root)); } return TRUE; }
static void gdl_dock_master_lock_unlock (GdlDockMaster *master, gboolean locked) { GList *l; for (l = master->toplevel_docks; l; l = l->next) { GdlDock *dock = GDL_DOCK (l->data); if (dock->root) foreach_lock_unlock (GDL_DOCK_ITEM (dock->root), locked); } /* just to be sure hidden items are set too */ gdl_dock_master_foreach (master, (GFunc) foreach_lock_unlock, GINT_TO_POINTER (locked)); }
static void gdl_dock_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data) { GdlDock *dock; g_return_if_fail (container != NULL); g_return_if_fail (GDL_IS_DOCK (container)); g_return_if_fail (callback != NULL); dock = GDL_DOCK (container); if (dock->root) (*callback) (GTK_WIDGET (dock->root), callback_data); }
static gboolean gdl_dock_floating_configure_event_cb (GtkWidget *widget, GdkEventConfigure *event, gpointer user_data) { GdlDock *dock; g_return_val_if_fail (user_data != NULL && GDL_IS_DOCK (user_data), TRUE); dock = GDL_DOCK (user_data); dock->_priv->float_x = event->x; dock->_priv->float_y = event->y; dock->_priv->width = event->width; dock->_priv->height = event->height; return FALSE; }
static gboolean gdl_dock_child_placement (GdlDockObject *object, GdlDockObject *child, GdlDockPlacement *placement) { GdlDock *dock = GDL_DOCK (object); gboolean retval = TRUE; if (dock->root == child) { if (placement) { if (*placement == GDL_DOCK_NONE || *placement == GDL_DOCK_FLOATING) *placement = GDL_DOCK_TOP; } } else retval = FALSE; return retval; }
static void gdl_dock_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GdlDock *dock; GtkContainer *container; g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK (widget)); dock = GDL_DOCK (widget); container = GTK_CONTAINER (widget); gtk_widget_set_allocation (widget, allocation); if (dock->priv->root && gtk_widget_get_visible (GTK_WIDGET (dock->priv->root))) gtk_widget_size_allocate (GTK_WIDGET (dock->priv->root), allocation); }
static void gdl_dock_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { GdlDock *dock = GDL_DOCK (object); switch (prop_id) { case PROP_FLOATING: g_value_set_boolean (value, dock->priv->floating); break; case PROP_DEFAULT_TITLE: if (gdl_dock_object_get_master (GDL_DOCK_OBJECT (object)) != NULL) { gchar *default_title; g_object_get (gdl_dock_object_get_master (GDL_DOCK_OBJECT (object)), "default-title", &default_title, NULL); g_value_take_string (value, default_title); } else g_value_set_string (value, NULL); break; case PROP_WIDTH: g_value_set_int (value, dock->priv->width); break; case PROP_HEIGHT: g_value_set_int (value, dock->priv->height); break; case PROP_FLOAT_X: g_value_set_int (value, dock->priv->float_x); break; case PROP_FLOAT_Y: g_value_set_int (value, dock->priv->float_y); break; case PROP_SKIP_TASKBAR: g_value_set_boolean (value, dock->priv->skip_taskbar); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void gdl_dock_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { GdlDock *dock = GDL_DOCK (object); switch (prop_id) { case PROP_FLOATING: g_value_set_boolean (value, dock->_priv->floating); break; case PROP_DEFAULT_TITLE: if (GDL_DOCK_OBJECT (object)->master) { gchar *default_title; g_object_get (GDL_DOCK_OBJECT (object)->master, "default-title", &default_title, NULL); #if GLIB_CHECK_VERSION(2,3,0) g_value_take_string (value, default_title); #else g_value_set_string_take_ownership (value, default_title); #endif } else g_value_set_string (value, NULL); break; case PROP_WIDTH: g_value_set_int (value, dock->_priv->width); break; case PROP_HEIGHT: g_value_set_int (value, dock->_priv->height); break; case PROP_FLOAT_X: g_value_set_int (value, dock->_priv->float_x); break; case PROP_FLOAT_Y: g_value_set_int (value, dock->_priv->float_y); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void gdl_dock_master_set_switcher_style (GdlDockMaster *master, GdlSwitcherStyle switcher_style) { GList *l; g_return_if_fail (GDL_IS_DOCK_MASTER (master)); master->_priv->switcher_style = switcher_style; for (l = master->toplevel_docks; l; l = l->next) { GdlDock *dock = GDL_DOCK (l->data); if (dock->root) set_switcher_style_foreach (GTK_WIDGET (dock->root), GINT_TO_POINTER (switcher_style)); } /* just to be sure hidden items are set too */ gdl_dock_master_foreach (master, (GFunc) set_switcher_style_foreach, GINT_TO_POINTER (switcher_style)); }
static void gdl_dock_dispose (GObject *object) { GdlDockPrivate *priv = GDL_DOCK (object)->priv; if (priv->window) { gtk_widget_destroy (priv->window); priv->floating = FALSE; priv->window = NULL; } if (priv->area_window) { gtk_widget_destroy (priv->area_window); priv->area_window = NULL; } G_OBJECT_CLASS (gdl_dock_parent_class)->dispose (object); }
static void gdl_dock_map (GtkWidget *widget) { GtkWidget *child; GdlDock *dock; g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK (widget)); dock = GDL_DOCK (widget); GDL_CALL_PARENT (GTK_WIDGET_CLASS, map, (widget)); if (dock->root) { child = GTK_WIDGET (dock->root); if (GTK_WIDGET_VISIBLE (child) && !GTK_WIDGET_MAPPED (child)) gtk_widget_map (child); } }
static void gdl_dock_map (GtkWidget *widget) { GtkWidget *child; GdlDock *dock; g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK (widget)); dock = GDL_DOCK (widget); GTK_WIDGET_CLASS (gdl_dock_parent_class)->map (widget); if (dock->priv->root) { child = GTK_WIDGET (dock->priv->root); if (gtk_widget_get_visible (child) && !gtk_widget_get_mapped (child)) gtk_widget_map (child); } }
static void gdl_dock_notify_cb (GObject *object, GParamSpec *pspec, gpointer user_data) { GdlDock *dock; gchar* long_name; g_return_if_fail (object != NULL || GDL_IS_DOCK (object)); g_object_get (object, "long-name", &long_name, NULL); if (long_name) { dock = GDL_DOCK (object); dock->priv->auto_title = FALSE; gdl_dock_set_title (dock); } g_free (long_name); }
static void gdl_dock_hide (GtkWidget *widget) { GdlDock *dock; g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK (widget)); GDL_CALL_PARENT (GTK_WIDGET_CLASS, hide, (widget)); dock = GDL_DOCK (widget); if (dock->_priv->floating && dock->_priv->window) gtk_widget_hide (dock->_priv->window); if (GDL_DOCK_IS_CONTROLLER (dock)) { gdl_dock_master_foreach_toplevel (GDL_DOCK_OBJECT_GET_MASTER (dock), FALSE, (GFunc) gdl_dock_foreach_automatic, gtk_widget_hide); } }