Remove deprecated member access
[projects/chimara/chimara.git] / libchimara / window.c
index 41bd9f0f6856928664acebda755380a669a20495..fb7311e7280a09f0c1300fa026630a2221fcb1c3 100644 (file)
@@ -35,6 +35,8 @@ window_new_common(glui32 rock)
        win->history = NULL;
        win->echo_line_input = TRUE;
        win->echo_current_line_input = TRUE;
+       win->extra_line_terminators = NULL;
+       win->current_extra_line_terminators = NULL;
 
        /* Initialise the buffer */
        win->buffer = g_string_sized_new(1024);
@@ -65,6 +67,8 @@ window_close_common(winid_t win, gboolean destroy_node)
        
        g_list_foreach(win->history, (GFunc)g_free, NULL);
        g_list_free(win->history);
+       g_slist_free(win->extra_line_terminators);
+       g_slist_free(win->current_extra_line_terminators);
        
        g_string_free(win->buffer, TRUE);
        g_hash_table_destroy(win->hyperlinks);
@@ -198,8 +202,8 @@ glk_window_get_sibling(winid_t win)
        if(G_NODE_IS_ROOT(win->window_node))
                return NULL;
        if(win->window_node->next)
-               return (winid_t)win->window_node->next;
-       return (winid_t)win->window_node->prev;
+               return (winid_t)win->window_node->next->data;
+       return (winid_t)win->window_node->prev->data;
 }
 
 /**
@@ -412,16 +416,16 @@ glk_window_get_root()
  *  A   C   
  * </literallayout></textobject></mediaobject></entry> 
  * </row></tbody></tgroup></informaltable>
- * After the first split, the new pair window (O1, which covers the whole
- * screen) knows that its first child (A) is above the second, and gets 50% of
- * its own area. (A is the key window for this split, but a proportional split
- * doesn't care about key windows.)
+ * The initial window is A. After the first split, the new pair window (O1,
+ * which covers the whole screen) knows that its new child (B) is below A, and
+ * gets 50% of its own area. (B is the key window for this split, but a
+ * proportional split doesn't care about key windows.)
  * 
- * After the second split, all this remains true; O1 knows that its first child
- * gets 50% of its space, and A is O1's key window. But now O1's first child is
- * O2 instead of A. The newer pair window (O2) knows that its first child (C)
- * is above the second, and gets a fixed size of two rows. (As measured in C's
- * font, because C is O2's key window.)
+ * After the <emphasis>second</emphasis> split, all this remains true; O1 knows
+ * that its first child gets 50% of its space, and B is O1's key window. But
+ * now O1's first child is O2 instead of A. The newer pair window (O2) knows
+ * that its first child (C) is above the second, and gets a fixed size of two
+ * rows. (As measured in C's font, because C is O2's key window.)
  * 
  * If we split C, now, the resulting pair will still be two C-font rows high
  * &mdash; that is, tall enough for two lines of whatever font C displays. For
@@ -458,8 +462,9 @@ glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype,
                 glui32 rock)
 {
        VALID_WINDOW_OR_NULL(split, return NULL);
-       g_return_val_if_fail(method == (method & (winmethod_DirMask | winmethod_DivisionMask)), NULL);
-       g_return_val_if_fail(!(((method & winmethod_DivisionMask) == winmethod_Proportional) && size > 100), NULL);     
+       g_return_val_if_fail(!(((method & winmethod_DivisionMask) == winmethod_Proportional) && size > 100), NULL);
+       if(method != (method & (winmethod_DirMask | winmethod_DivisionMask | winmethod_BorderMask)))
+               WARNING("Unrecognized bits in method constant");
 
        ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
        
@@ -1003,13 +1008,19 @@ glk_window_clear(winid_t win)
 
                case wintype_Graphics:
                {
+                       GtkAllocation allocation;
+
                        /* Wait for the window's size to be updated */
                        g_mutex_lock(glk_data->arrange_lock);
                        if(glk_data->needs_rearrange)
                                g_cond_wait(glk_data->rearranged, glk_data->arrange_lock);
                        g_mutex_unlock(glk_data->arrange_lock);
 
-                       glk_window_erase_rect(win, 0, 0, win->widget->allocation.width, win->widget->allocation.height);
+                       gdk_threads_enter();
+                       gtk_widget_get_allocation(win->widget, &allocation);
+                       gdk_threads_leave();
+
+                       glk_window_erase_rect(win, 0, 0, allocation.width, allocation.height);
                }
                        break;
                
@@ -1129,6 +1140,7 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr)
 {
        VALID_WINDOW(win, return);
 
+       GtkAllocation allocation;
        ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
        
     switch(win->type)
@@ -1149,9 +1161,10 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr)
                        g_mutex_unlock(glk_data->arrange_lock);
                        
                        gdk_threads_enter();
+                       gtk_widget_get_allocation(win->widget, &allocation);
                        /* Cache the width and height */
-                       win->width = (glui32)(win->widget->allocation.width / win->unit_width);
-                   win->height = (glui32)(win->widget->allocation.height / win->unit_height);
+                       win->width = (glui32)(allocation.width / win->unit_width);
+                   win->height = (glui32)(allocation.height / win->unit_height);
             gdk_threads_leave();
                        
             if(widthptr != NULL)
@@ -1168,10 +1181,11 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr)
                        g_mutex_unlock(glk_data->arrange_lock);
                        
             gdk_threads_enter();
+            gtk_widget_get_allocation(win->widget, &allocation);
             if(widthptr != NULL)
-                *widthptr = (glui32)(win->widget->allocation.width / win->unit_width);
+                *widthptr = (glui32)(allocation.width / win->unit_width);
             if(heightptr != NULL)
-                *heightptr = (glui32)(win->widget->allocation.height / win->unit_height);
+                *heightptr = (glui32)(allocation.height / win->unit_height);
             gdk_threads_leave();
             
             break;
@@ -1183,10 +1197,11 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr)
                        g_mutex_unlock(glk_data->arrange_lock);
                        
             gdk_threads_enter();
+            gtk_widget_get_allocation(win->widget, &allocation);
             if(widthptr != NULL)
-                *widthptr = (glui32)(win->widget->allocation.width);
+                *widthptr = (glui32)(allocation.width);
             if(heightptr != NULL)
-                *heightptr = (glui32)(win->widget->allocation.height);
+                *heightptr = (glui32)(allocation.height);
             gdk_threads_leave();
             
             break;