summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorSøren Sandmann <sandmann@redhat.com>2008-06-05 22:50:27 -0400
committerSøren Sandmann <sandmann@redhat.com>2008-06-05 22:50:27 -0400
commit6b90e189d35af19e9cfdcdc54314bfbdaf633951 (patch)
tree316b4ba298c499a2e261b3f3e63d8ee1b956c70c /main.c
parente9eaa5b1ec9eb280589f7f692ca8191dddca9ee7 (diff)
Introduce new viewport_size_changed signal
Diffstat (limited to 'main.c')
-rw-r--r--main.c84
1 files changed, 50 insertions, 34 deletions
diff --git a/main.c b/main.c
index 8f4289c..03c1cd1 100644
--- a/main.c
+++ b/main.c
@@ -76,47 +76,61 @@ on_main_paint (FooScrollArea *scroll_area,
}
static void
-on_viewport_changed (FooScrollArea *scroll_area,
- GdkRectangle *viewport,
- GdkRectangle *old_viewport)
+on_viewport_size_changed (FooScrollArea *scroll_area,
+ GdkRectangle *viewport,
+ GdkRectangle *old_viewport)
{
- int th;
+#if 0
double ratio;
-
- if (old_viewport)
- {
- slide_width = viewport->width - 2 * MARGIN;
- slide_height = slide_width / RATIO;
-
- th = N_SLIDES * slide_height + (N_SLIDES + 1) * MARGIN;
-
- g_print ("new slide height: %d, new y: %d\n", slide_height, viewport->y);
-
- /* FIXME: We can recurse infinitely here when the area gets
- * narrow enough that the scrollbar disappears causing the area
- * to widen a little causing the scrollbar to appear causing
- * the arrow to narrow causing ...
- *
- * For now we work around by have POLICY_ALWAYS on the scrollbar,
- * it needs to be thought through and fixed in the scroll area
- */
-
- ratio = (double)viewport->width / old_viewport->width;
-
- g_print ("ratio: %f (%d %d)\n", ratio, old_viewport->y, (int)(old_viewport->y * ratio));
-
- foo_scroll_area_set_size_fixed_y (scroll_area, viewport->width, th,
- old_viewport->y + 100,
- (old_viewport->y + 100) * ratio + 0.5);
- }
+ int th;
+
+ g_print ("new slide height: %d, new y: %d\n", slide_height, viewport->y);
+
+ /* FIXME: We can recurse infinitely here when the area gets
+ * narrow enough that the scrollbar disappears causing the area
+ * to widen a little causing the scrollbar to appear causing
+ * the arrow to narrow causing ...
+ *
+ * For now we work around by have POLICY_ALWAYS on the scrollbar,
+ * it needs to be thought through and fixed in the scroll area
+ */
+
+ ratio = (double)viewport->width / old_viewport->width;
#if 0
- foo_scroll_area_set_size (scroll_area, viewport->width, th);
+ g_print ("ratio: %f (%d %d)\n", ratio, old_viewport->y, (int)(old_viewport->y * ratio));
+
+ g_print ("old, new: %f %f\n", slide_n, MARGIN + slide_n * (MARGIN + (double)slide_height));
#endif
+
+ foo_scroll_area_set_size_fixed_y (scroll_area, viewport->width, th,
+ slide_n,
+ MARGIN + slide_n * (MARGIN + slide_height));
+#endif
+
+ int th;
+ double slide_n;
+
+ slide_width = viewport->width - 2 * MARGIN;
+ slide_height = slide_width / RATIO;
+
+ th = N_SLIDES * slide_height + (N_SLIDES + 1) * MARGIN;
+ foo_scroll_area_set_size (scroll_area, viewport->width, th);
+
+ g_print ("size changed - set size %d %d\n", viewport->width, th);
+
foo_scroll_area_invalidate (scroll_area);
}
static void
+on_viewport_changed (FooScrollArea *scroll_area,
+ GdkRectangle *viewport,
+ GdkRectangle *old_viewport)
+{
+ g_print ("viewport changed\n");
+}
+
+static void
set_size (GtkWindow *window)
{
GdkScreen *screen;
@@ -146,8 +160,8 @@ main (int argc, char **argv)
app = g_new0 (App, 1);
app->xml = glade_xml_new (GLADE_FILE, NULL, NULL);
- app->main_area = foo_scroll_area_new();
- app->thumbnails = foo_scroll_area_new();
+ app->main_area = (FooScrollArea *)foo_scroll_area_new();
+ app->thumbnails = (FooScrollArea *)foo_scroll_area_new();
gtk_container_add (
GTK_CONTAINER (get_widget (app, "main_area_scrolled_window")),
@@ -163,6 +177,8 @@ main (int argc, char **argv)
G_CALLBACK (on_main_paint), app);
g_signal_connect (app->main_area, "viewport_changed",
G_CALLBACK (on_viewport_changed), app);
+ g_signal_connect (app->main_area, "viewport_size_changed",
+ G_CALLBACK (on_viewport_size_changed), app);
g_signal_connect (app->thumbnails, "paint",
G_CALLBACK (on_thumbs_paint), app);