Commit ce14a736 authored by Juan Pablo Ugarte's avatar Juan Pablo Ugarte

* gladeui/glade-app.c: replaced GladeDesignLayout API with the new private one

  * gladeui/glade-design-layout.[ch]:
    o added widget maximization on label double click
    o fixed size allocation to be able to maximize widget without making the viewport
      scrollbars appear
    o removed glade_design_layout_selection_set()

  * gladeui/glade-design-view.c:
    o improved viewport scrolling to selected toplevel, now we only scroll if
      the selection was not triggered by the layout.
    o replaced on_project_add_widget() on_project_remove_widget() with new project
      signal widget-visibility-changed

  * gladeui/glade-project.[ch]:
    o added GladeProject::widget-visibility-changed signal
    o added glade_project_widget_visibility_changed() function

  * gladeui/glade-widget.c:
    o added visible property.
    o use glade_project_widget_visibility_changed() to emit signal on widget visibility change

  * gladeui/glade.h: removed glade-design-layout.h since now its private

  * gladeui/Makefile.am: do not install private header glade-design-layout.h

  * plugins/gtk+/Makefile.am: do not install headers
parent 887b3827
......@@ -119,7 +119,6 @@ libgladeuiinclude_HEADERS = \
glade-editor-property.h \
glade-signal-editor.h \
glade-palette.h \
glade-design-layout.h \
glade-design-view.h \
glade-widget.h \
glade-widget-adaptor.h \
......@@ -144,7 +143,8 @@ libgladeuiinclude_HEADERS = \
glade-cell-renderer-icon.h \
glade-signal-model.h
noinst_HEADERS = \
glade-design-layout.h
if PLATFORM_WIN32
libgladeui_2_la_LDFLAGS += -no-undefined
......
......@@ -36,6 +36,7 @@
#include "glade-cursor.h"
#include "glade-catalog.h"
#include "glade-design-view.h"
#include "glade-design-layout.h"
#include "glade-marshallers.h"
#include "glade-accumulators.h"
......@@ -391,7 +392,7 @@ glade_app_do_event (GdkEvent *event)
*/
if (widget && IS_GLADE_WIDGET_EVENT (event->type) &&
(layout = gtk_widget_get_ancestor (widget, GLADE_TYPE_DESIGN_LAYOUT)))
return glade_design_layout_do_event (GLADE_DESIGN_LAYOUT (layout), event);
return _glade_design_layout_do_event (GLADE_DESIGN_LAYOUT (layout), event);
return FALSE;
}
......
......@@ -2,6 +2,7 @@
* glade-design-layout.c
*
* Copyright (C) 2006-2007 Vincent Geddes
* 2011 Juan Pablo Ugarte
*
* Authors:
* Vincent Geddes <vgeddes@gnome.org>
......@@ -37,7 +38,7 @@
GladeDesignLayoutPrivate))
#define OUTLINE_WIDTH 4
#define PADDING 2
#define PADDING 10
typedef enum
{
......@@ -51,12 +52,12 @@ struct _GladeDesignLayoutPrivate
{
GdkWindow *window, *offscreen_window;
GList *selection;
gint child_offset;
GdkRectangle east, south, south_east;
GdkCursor *cursors[sizeof (Activity)];
gboolean should_scroll;
PangoLayout *widget_name;
/* state machine */
......@@ -74,7 +75,7 @@ G_DEFINE_TYPE (GladeDesignLayout, glade_design_layout, GTK_TYPE_BIN)
#define RECTANGLE_POINT_IN(rect,x,y) (x >= rect.x && x <= (rect.x + rect.width) && y >= rect.y && y <= (rect.y + rect.height))
static Activity
gdl_get_activity_from_pointer (GladeDesignLayout * layout, gint x, gint y)
gdl_get_activity_from_pointer (GladeDesignLayout *layout, gint x, gint y)
{
GladeDesignLayoutPrivate *priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (layout);
......@@ -88,8 +89,7 @@ gdl_get_activity_from_pointer (GladeDesignLayout * layout, gint x, gint y)
}
static gboolean
glade_design_layout_leave_notify_event (GtkWidget * widget,
GdkEventCrossing * ev)
glade_design_layout_leave_notify_event (GtkWidget *widget, GdkEventCrossing *ev)
{
GtkWidget *child;
GladeDesignLayoutPrivate *priv;
......@@ -106,10 +106,10 @@ glade_design_layout_leave_notify_event (GtkWidget * widget,
return FALSE;
}
static void
glade_design_layout_update_child (GladeDesignLayout * layout,
GtkWidget * child, GtkAllocation * allocation)
glade_design_layout_update_child (GladeDesignLayout *layout,
GtkWidget *child,
GtkAllocation *allocation)
{
GladeDesignLayoutPrivate *priv;
GladeWidget *gchild;
......@@ -126,8 +126,7 @@ glade_design_layout_update_child (GladeDesignLayout * layout,
}
static gboolean
glade_design_layout_motion_notify_event (GtkWidget * widget,
GdkEventMotion * ev)
glade_design_layout_motion_notify_event (GtkWidget *widget, GdkEventMotion *ev)
{
GtkWidget *child;
GladeDesignLayoutPrivate *priv;
......@@ -201,8 +200,8 @@ typedef struct
} GladeFindInContainerData;
static void
glade_design_layout_find_inside_container (GtkWidget * widget,
GladeFindInContainerData * data)
glade_design_layout_find_inside_container (GtkWidget *widget,
GladeFindInContainerData *data)
{
GtkAllocation allocation;
gint x;
......@@ -233,14 +232,15 @@ glade_design_layout_find_inside_container (GtkWidget * widget,
}
static gboolean
glade_design_layout_button_press_event (GtkWidget * widget, GdkEventButton * ev)
glade_design_layout_button_press_event (GtkWidget *widget, GdkEventButton *ev)
{
GtkWidget *child;
GtkAllocation child_allocation;
GladeDesignLayoutPrivate *priv;
gint x, y;
if ((child = gtk_bin_get_child (GTK_BIN (widget))) == NULL)
if (ev->button != 1 ||
(child = gtk_bin_get_child (GTK_BIN (widget))) == NULL)
return FALSE;
priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
......@@ -248,14 +248,57 @@ glade_design_layout_button_press_event (GtkWidget * widget, GdkEventButton * ev)
x = ev->x;
y = ev->y;
if (ev->button == 1)
if (ev->type == GDK_BUTTON_PRESS)
{
GladeWidget *gchild;
gtk_widget_get_allocation (child, &child_allocation);
priv->dx = x - (child_allocation.x + child_allocation.width);
priv->dy = y - (child_allocation.y + child_allocation.height);
priv->activity = gdl_get_activity_from_pointer (GLADE_DESIGN_LAYOUT (widget), x, y);
gdk_window_set_cursor (priv->window, priv->cursors[priv->activity]);
if (priv->activity != ACTIVITY_NONE &&
(gchild = glade_widget_get_from_gobject (G_OBJECT (child))))
{
GladeProject *project = glade_widget_get_project (gchild);
priv->should_scroll = FALSE;
if (project)
glade_project_selection_set (project, G_OBJECT (gtk_bin_get_child (GTK_BIN (widget))), TRUE);
priv->should_scroll = TRUE;
}
}
else if (ev->type == GDK_2BUTTON_PRESS)
{
GtkAdjustment *vadj, *hadj;
GtkAllocation alloc;
GtkWidget *win;
gint height;
if (priv->widget_name)
pango_layout_get_pixel_size (priv->widget_name, NULL, &height);
else
height = PADDING;
win = gtk_widget_get_ancestor (widget, GTK_TYPE_SCROLLED_WINDOW);
vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (win));
hadj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (win));
gtk_widget_get_allocation (widget, &alloc);
alloc.width = gtk_adjustment_get_page_size (hadj) - priv->child_offset * 2;
alloc.height = gtk_adjustment_get_page_size (vadj) - (PADDING + height + 3 * OUTLINE_WIDTH);
/* Maximize */
glade_design_layout_update_child (GLADE_DESIGN_LAYOUT (widget),
child, &alloc);
/* give a chance for widget to realocate */
while (gtk_events_pending ()) gtk_main_iteration_do (FALSE);
/* Position layout */
gtk_adjustment_set_value (hadj, 0);
gtk_adjustment_set_value (vadj, alloc.y);
}
return FALSE;
......@@ -314,8 +357,8 @@ glade_design_layout_get_preferred_height (GtkWidget * widget,
else
height = PADDING;
*minimum = MAX (*minimum, PADDING + height + child_height + 3 * OUTLINE_WIDTH);
*natural = MAX (*natural, PADDING + height + child_height + 3 * OUTLINE_WIDTH);
*minimum = MAX (*minimum, PADDING + 2.5 * OUTLINE_WIDTH + child_height + height);
*natural = MAX (*natural, PADDING + 2.5 * OUTLINE_WIDTH + child_height + height);
}
*minimum += border_width * 2;
......@@ -350,8 +393,8 @@ glade_design_layout_get_preferred_width (GtkWidget * widget,
child_width = MAX (child_width, *minimum);
*minimum = MAX (*minimum, 2 * PADDING + child_width + 2 * OUTLINE_WIDTH);
*natural = MAX (*natural, 2 * PADDING + child_width + 2 * OUTLINE_WIDTH);
*minimum = MAX (*minimum, PADDING + child_width + 3 * OUTLINE_WIDTH);
*natural = MAX (*natural, PADDING + child_width + 3 * OUTLINE_WIDTH);
}
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
......@@ -518,9 +561,6 @@ glade_design_layout_remove (GtkContainer * container, GtkWidget * widget)
static void
glade_design_layout_finalize (GObject * object)
{
/* Free selection list */
glade_design_layout_selection_set (GLADE_DESIGN_LAYOUT (object), NULL);
G_OBJECT_CLASS (glade_design_layout_parent_class)->finalize (object);
}
......@@ -532,10 +572,8 @@ glade_design_layout_damage (GtkWidget *widget, GdkEventExpose *event)
}
static inline void
draw_frame (GladeDesignLayoutPrivate *priv, GtkStyle *style, cairo_t * cr, int x, int y, int w, int h)
draw_frame (cairo_t * cr, GladeDesignLayoutPrivate *priv, GtkStyle *style, GtkStateType state, int x, int y, int w, int h)
{
GtkStateType state = (priv->selection) ? GTK_STATE_SELECTED : GTK_STATE_NORMAL;
cairo_save (cr);
cairo_set_line_width (cr, OUTLINE_WIDTH);
......@@ -614,51 +652,36 @@ glade_design_layout_draw (GtkWidget * widget, cairo_t * cr)
if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
{
GladeProject *project;
GladeWidget *gchild;
GtkStyle *style;
GtkWidget *child;
GdkWindow *window;
gint border_width;
gint width, height;
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
window = gtk_widget_get_window (widget);
style = gtk_widget_get_style (widget);
width = gtk_widget_get_allocated_width (widget);
height = gtk_widget_get_allocated_height (widget);
child = gtk_bin_get_child (GTK_BIN (widget));
/* draw a white widget background */
glade_utils_cairo_draw_rectangle (cr,
&style->
base[gtk_widget_get_state (widget)],
TRUE, border_width, border_width,
width - 2 * border_width,
height - 2 * border_width);
if (child && gtk_widget_get_visible (child))
gdk_cairo_set_source_color (cr, &style->base[gtk_widget_get_state (widget)]);
cairo_paint (cr);
if ((child = gtk_bin_get_child (GTK_BIN (widget))) &&
gtk_widget_get_visible (child) &&
(gchild = glade_widget_get_from_gobject (G_OBJECT (child))) &&
(project = glade_widget_get_project (gchild)))
{
const GdkColor *color = &gtk_widget_get_style (widget)->bg[GTK_STATE_SELECTED];
gint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
GtkAllocation child_allocation;
gboolean selection = FALSE;
gfloat r, g, b;
GList *l;
gtk_widget_get_allocation (child, &child_allocation);
/* draw frame */
draw_frame (priv, style, cr,
border_width + PADDING,
border_width + PADDING,
child_allocation.width + 2 * OUTLINE_WIDTH,
child_allocation.height + 2 * OUTLINE_WIDTH);
/* draw offscreen widgets */
gdk_cairo_set_source_window (cr, priv->offscreen_window, priv->child_offset, priv->child_offset);
cairo_rectangle (cr,
priv->child_offset, priv->child_offset,
child_allocation.width,
child_allocation.height);
gdk_cairo_set_source_window (cr, priv->offscreen_window,
priv->child_offset, priv->child_offset);
cairo_rectangle (cr, priv->child_offset, priv->child_offset,
child_allocation.width, child_allocation.height);
cairo_fill (cr);
/* Draw selection */
......@@ -667,11 +690,28 @@ glade_design_layout_draw (GtkWidget * widget, cairo_t * cr)
b = color->blue/65535.;
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
for (l = priv->selection; l; l = g_list_next (l))
for (l = glade_project_selection_get (project); l; l = g_list_next (l))
{
/* Dont draw selection on toplevels */
if (child != l->data)
draw_selection (cr, child, l->data, priv->child_offset, r, g, b);
{
if (gtk_widget_is_ancestor (l->data, child))
{
draw_selection (cr, child, l->data, priv->child_offset, r, g, b);
selection = TRUE;
}
}
else
selection = TRUE;
}
/* draw frame */
draw_frame (cr, priv, style,
(selection) ? GTK_STATE_SELECTED : GTK_STATE_NORMAL,
border_width + PADDING,
border_width + PADDING,
child_allocation.width + 2 * OUTLINE_WIDTH,
child_allocation.height + 2 * OUTLINE_WIDTH);
}
}
else if (gtk_cairo_should_draw_window (cr, priv->offscreen_window))
......@@ -879,7 +919,11 @@ glade_design_layout_unrealize (GtkWidget * widget)
priv->cursors[ACTIVITY_RESIZE_WIDTH_AND_HEIGHT] = NULL;
}
if (priv->widget_name) g_object_unref (priv->widget_name);
if (priv->widget_name)
{
g_object_unref (priv->widget_name);
priv->widget_name = NULL;
}
GTK_WIDGET_CLASS (glade_design_layout_parent_class)->unrealize (widget);
}
......@@ -901,8 +945,8 @@ glade_design_layout_init (GladeDesignLayout * layout)
priv->new_width = -1;
priv->new_height = -1;
priv->selection = NULL;
priv->should_scroll = TRUE;
/* setup static member of rectangles */
priv->east.width = PADDING + OUTLINE_WIDTH;
priv->south.height = PADDING + OUTLINE_WIDTH;
......@@ -945,93 +989,16 @@ glade_design_layout_class_init (GladeDesignLayoutClass * klass)
g_type_class_add_private (object_class, sizeof (GladeDesignLayoutPrivate));
}
/* Public API */
/* Internal API */
GtkWidget *
glade_design_layout_new (void)
_glade_design_layout_new (void)
{
return g_object_new (GLADE_TYPE_DESIGN_LAYOUT, NULL);
}
static void
on_selected_child_parent_set (GtkWidget *widget,
GtkWidget *old_parent,
GladeDesignLayout * layout)
{
GladeDesignLayoutPrivate *priv;
GladeWidget *layout_gchild, *gtoplevel, *gwidget;
GtkWidget *child;
if ((child = gtk_bin_get_child (GTK_BIN (layout))) == NULL) return;
priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (layout);
layout_gchild = glade_widget_get_from_gobject (G_OBJECT (child));
if ((gwidget = glade_widget_get_from_gobject (G_OBJECT (widget))) &&
(gtoplevel = glade_widget_get_toplevel (gwidget)) &&
gtoplevel != layout_gchild)
{
glade_design_layout_selection_set (layout, NULL);
}
}
/**
* glade_design_layout_selection_set:
* @layout: A #GladeDesignLayout
* @selection: A list of selected widgets.
*
* Set the widget selection list or NULL.
*
*/
void
glade_design_layout_selection_set (GladeDesignLayout * layout, GList *selection)
{
GladeDesignLayoutPrivate *priv;
GladeWidget *layout_gchild;
GtkWidget *child;
GList *l;
g_return_if_fail (GLADE_IS_DESIGN_LAYOUT (layout));
if ((child = gtk_bin_get_child (GTK_BIN (layout))) == NULL) return;
priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (layout);
/* Disconnect handlers */
for (l = priv->selection; l; l = g_list_next (l))
g_signal_handlers_block_by_func (l->data, on_selected_child_parent_set, layout);
/* Free list */
g_list_free (priv->selection);
priv->selection = NULL;
layout_gchild = glade_widget_get_from_gobject (G_OBJECT (child));
for (l = selection; l; l = g_list_next (l))
{
GladeWidget *gtoplevel, *gwidget;
if ((gwidget = glade_widget_get_from_gobject (G_OBJECT (l->data))) &&
(gtoplevel = glade_widget_get_toplevel (gwidget)) &&
gtoplevel == layout_gchild)
{
/* its a descendant, prepend to list */
priv->selection = g_list_prepend (priv->selection, l->data);
/* we unset the whole selection list if one of the widgets is
* removed or reparented since Glade Project will take care
* of update it properly
*/
g_signal_connect (l->data, "parent-set", G_CALLBACK (on_selected_child_parent_set), layout);
}
}
gtk_widget_queue_draw (GTK_WIDGET (layout));
}
/**
* glade_design_layout_do_event:
/*
* _glade_design_layout_do_event:
* @layout: A #GladeDesignLayout
* @event: an event to process
*
......@@ -1041,11 +1008,12 @@ glade_design_layout_selection_set (GladeDesignLayout * layout, GList *selection)
* Returns: true if the event was handled.
*/
gboolean
glade_design_layout_do_event (GladeDesignLayout * layout, GdkEvent * event)
_glade_design_layout_do_event (GladeDesignLayout * layout, GdkEvent * event)
{
GladeFindInContainerData data = { 0, };
GladeDesignLayoutPrivate *priv;
GtkWidget *child;
gboolean retval;
if ((child = gtk_bin_get_child (GTK_BIN (layout))) == NULL)
return FALSE;
......@@ -1057,11 +1025,32 @@ glade_design_layout_do_event (GladeDesignLayout * layout, GdkEvent * event)
glade_design_layout_find_inside_container (child, &data);
priv->should_scroll = FALSE;
/* Try the placeholder first */
if (data.placeholder && gtk_widget_event (data.placeholder, event)) return TRUE;
if (data.placeholder && gtk_widget_event (data.placeholder, event))
retval = TRUE;
else if (data.gwidget) /* Then we try a GladeWidget */
retval = glade_widget_event (data.gwidget, event);
else
retval = FALSE;
/* Then we try a GladeWidget */
if (data.gwidget) return glade_widget_event (data.gwidget, event);
priv->should_scroll = TRUE;
return FALSE;
return retval;
}
/*
* _glade_design_layout_should_scroll:
* @layout: A #GladeDesignLayout
*
*
*
* Returns: true if it is ok to scroll or not.
*/
gboolean
_glade_design_layout_should_scroll (GladeDesignLayout *layout)
{
GladeDesignLayoutPrivate *priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (layout);
return priv->should_scroll;
}
......@@ -59,15 +59,14 @@ struct _GladeDesignLayoutClass
};
GType glade_design_layout_get_type (void) G_GNUC_CONST;
GType glade_design_layout_get_type (void) G_GNUC_CONST;
GtkWidget *glade_design_layout_new (void);
GtkWidget *_glade_design_layout_new (void);
void glade_design_layout_selection_set (GladeDesignLayout * layout,
GList * selection);
gboolean _glade_design_layout_do_event (GladeDesignLayout *layout,
GdkEvent *event);
gboolean glade_design_layout_do_event (GladeDesignLayout * layout,
GdkEvent * event);
gboolean _glade_design_layout_should_scroll (GladeDesignLayout *layout);
G_END_DECLS
......
......@@ -2,9 +2,11 @@
* glade-design-view.c
*
* Copyright (C) 2006 Vincent Geddes
* 2011 Juan Pablo Ugarte
*
* Authors:
* Vincent Geddes <vincent.geddes@gmail.com>
* Juan Pablo Ugarte <juanpablougarte@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -27,8 +29,7 @@
* @Title: GladeDesignView
* @Short_Description: A widget to embed the workspace.
*
* Use this widget to embed the currently active #GtkWindow
* in a given #GladeProject.
* Use this widget to embed toplevel widgets in a given #GladeProject.
*/
#include "config.h"
......@@ -105,25 +106,16 @@ glade_design_view_load_progress (GladeProject * project,
step * 1.0 / total);
}
static void
layout_box_foreach (GtkWidget *widget, gpointer data)
{
if (GLADE_IS_DESIGN_LAYOUT (widget))
glade_design_layout_selection_set (GLADE_DESIGN_LAYOUT (widget), data);
}
static void
glade_design_view_selection_changed (GladeProject * project, GladeDesignView * view)
{
GList *selection = glade_project_selection_get (project);
GladeWidget *gwidget, *gtoplevel;
GList *selection;
/* FIXME: this does not fell right, perhaps DesignLayout should support more than one child */
gtk_container_foreach (GTK_CONTAINER (view->priv->layout_box),
layout_box_foreach,
selection);
if (selection && g_list_next (selection) == NULL &&
/* Check if its only one widget selected and scroll viewport to show toplevel */
if ((selection = glade_project_selection_get (project)) &&
g_list_next (selection) == NULL &&
GTK_IS_WIDGET (selection->data) &&
!GLADE_IS_PLACEHOLDER (selection->data) &&
(gwidget = glade_widget_get_from_gobject (G_OBJECT (selection->data))) &&
......@@ -134,61 +126,68 @@ glade_design_view_selection_changed (GladeProject * project, GladeDesignView * v
if (GTK_IS_WIDGET (toplevel) &&
(layout = gtk_widget_get_parent (GTK_WIDGET (toplevel))) &&
GLADE_IS_DESIGN_LAYOUT (layout))
GLADE_IS_DESIGN_LAYOUT (layout) &&
_glade_design_layout_should_scroll (GLADE_DESIGN_LAYOUT (layout)))
{
gdouble vadj_val, hadj_val, vpage_end, hpage_end;
GtkAdjustment *vadj, *hadj;
GtkAllocation alloc;
vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (view->priv->scrolled_window));
hadj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (view->priv->scrolled_window));
gtk_widget_get_allocation (layout, &alloc);
/*
g_message ("%s %dx%d page=%lf upper=%lf, lower=%lf", __func__, alloc.x, alloc.y,
gtk_adjustment_get_page_size (vadj),
gtk_adjustment_get_upper (vadj),
gtk_adjustment_get_lower (vadj));
*/
/* TODO: we could set this value in increments in a timeout callback to make it look like its scrolling instead of jumping */
gtk_adjustment_set_value (hadj, alloc.x);
gtk_adjustment_set_value (vadj, alloc.y);
}
}
}
static void
on_project_add_widget (GladeProject *project, GladeWidget *widget, GladeDesignView * view)
{
GtkWidget *layout;
GObject *object;
vadj_val = gtk_adjustment_get_value (vadj);
hadj_val = gtk_adjustment_get_value (hadj);
vpage_end = gtk_adjustment_get_page_size (vadj) + vadj_val;
hpage_end = gtk_adjustment_get_page_size (hadj) + hadj_val;
if (widget == NULL || glade_widget_get_parent (widget) ||
(object = glade_widget_get_object (widget)) == NULL ||
!GTK_IS_WIDGET (object)) return;
gtk_widget_get_allocation (layout, &alloc);
layout = glade_design_layout_new ();
gtk_box_pack_start (GTK_BOX (view->priv->layout_box), layout, FALSE, TRUE, 0);
/* TODO: we could set this value in increments in a timeout callback
* to make it look like its scrolling instead of jumping.
*/
if (alloc.y < vadj_val || alloc.y > vpage_end || (alloc.y + alloc.height) > vpage_end)
gtk_adjustment_set_value (vadj, alloc.y);
gtk_container_add (GTK_CONTAINER (layout), GTK_WIDGET (object));
gtk_widget_show (GTK_WIDGET (object));
gtk_widget_show (layout);
if (alloc.x < hadj_val || alloc.x > hpage_end || (alloc.x + alloc.width) > hpage_end)
gtk_adjustment_set_value (hadj, alloc.x);
}
}
}
static void
on_project_remove_widget (GladeProject *project, GladeWidget *widget, GladeDesignView * view)
glade_design_view_widget_visibility_changed (GladeProject *project,
GladeWidget *widget,
gboolean visible,
GladeDesignView *view)
{
GtkWidget *layout;
GObject *object;
if (widget == NULL || glade_widget_get_parent (widget) ||
/* Ignore non toplevel widgets */
if (glade_widget_get_parent (widget) ||
(object = glade_widget_get_object (widget)) == NULL ||
!GTK_IS_WIDGET (object)) return;
layout = gtk_widget_get_parent (GTK_WIDGET (object));
if (layout)
if (visible)
{
/* Create a GladeDesignLayout and add the toplevel widget to the view */
layout = _glade_design_layout_new ();
gtk_box_pack_start (GTK_BOX (view->priv->layout_box), layout, FALSE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (layout), GTK_WIDGET (object));
gtk_widget_show (GTK_WIDGET (object));
gtk_widget_show (layout);
}
else
{
gtk_container_remove (GTK_CONTAINER (layout), GTK_WIDGET (object));
gtk_container_remove (GTK_CONTAINER (view->priv->layout_box), layout);
/* Remove toplevel widget from the view */
layout = gtk_widget_get_parent (GTK_WIDGET (object));
if (layout)
{
gtk_container_remove (GTK_CONTAINER (layout), GTK_WIDGET (object));
gtk_container_remove (GTK_CONTAINER (view->priv->layout_box), layout);
}
}
}
......@@ -199,10 +198,6 @@ glade_design_view_set_project (GladeDesignView * view, GladeProject * project)
view->priv->project = project;
g_signal_connect (project, "add-widget",
G_CALLBACK (on_project_add_widget), view);
g_signal_connect (project, "remove-widget",
G_CALLBACK (on_project_remove_widget), view);
g_signal_connect (project, "parse-began",
G_CALLBACK (glade_design_view_parse_began), view);
g_signal_connect (project, "parse-finished",
......@@ -211,9 +206,10 @@ glade_design_view_set_project (GladeDesignView * view, GladeProject * project)
G_CALLBACK (glade_design_view_load_progress), view);
g_signal_connect (project, "selection-changed",
G_CALLBACK (glade_design_view_selection_changed), view);
g_signal_connect (project, "widget-visibility-changed",
G_CALLBACK (glade_design_view_widget_visibility_changed), view);
g_object_set_data (G_OBJECT (view->priv->project), GLADE_DESIGN_VIEW_KEY,
view);
g_object_set_data (G_OBJECT (project), GLADE_DESIGN_VIEW_KEY, view);
}
static void
......@@ -270,9 +266,9 @@ glade_design_view_init (GladeDesignView * view)
gtk_widget_set_no_show_all (GTK_WIDGET (view), TRUE);
view->priv->project = NULL;
view->priv->layout_box = gtk_vbox_new (FALSE, 8);
gtk_container_set_border_width (GTK_CONTAINER (view->priv->layout_box), 8);
gtk_box_pack_end (GTK_BOX (view->priv->layout_box), gtk_label_new (""), FALSE, FALSE, 0);
view->priv->layout_box = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (view->priv->layout_box), 0);
gtk_box_pack_end (GTK_BOX (view->priv->layout_box), gtk_fixed_new (), FALSE, FALSE, 0);
view->priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW
......@@ -384,9 +380,3 @@ glade_design_view_get_from_project (GladeProject * project)
return (p != NULL) ? GLADE_DESIGN_VIEW (p) : NULL;
}
GladeDesignLayout *
glade_design_view_get_layout (GladeDesignView * view)
{
return NULL;
}
......@@ -64,6 +64,7 @@ enum
PARSE_FINISHED,
TARGETS_CHANGED,
LOAD_PROGRESS,
WIDGET_VISIBILITY_CHANGED,