Exemplo n.º 1
0
static void
hippo_canvas_block_init(HippoCanvasBlock *block)
{
    block->expandable = TRUE;
    block->linkify_title = TRUE;
    
    HIPPO_CANVAS_BOX(block)->border_left = 1;
    HIPPO_CANVAS_BOX(block)->border_right = 1;
    HIPPO_CANVAS_BOX(block)->border_top = 1;
    HIPPO_CANVAS_BOX(block)->border_bottom = 1;
    HIPPO_CANVAS_BOX(block)->border_color_rgba = 0xffffffff;
}
Exemplo n.º 2
0
void
hippo_canvas_open_test_window(void)
{
    GtkWidget *window;
    GtkWidget *canvas;
    HippoCanvasItem *root;
    HippoCanvasItem *shape1;
    HippoCanvasItem *shape2;
    int i;
    
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_container_set_border_width(GTK_CONTAINER(window), 10);
    canvas = hippo_canvas_new();
    gtk_widget_show(canvas);
    gtk_container_add(GTK_CONTAINER(window), canvas);

    root = HIPPO_CANVAS_ITEM(hippo_canvas_box_new());

#if 0
    shape1 = g_object_new(HIPPO_TYPE_CANVAS_SHAPE,
                          "width", 50, "height", 100,
                          NULL);

    shape2 = g_object_new(HIPPO_TYPE_CANVAS_SHAPE,
                          "width", 70, "height", 40,
                          "color", 0x00ff00ff,
                          NULL);

    hippo_canvas_box_append(HIPPO_CANVAS_BOX(root),
                            shape1, 0);
    g_object_unref(shape1);
    hippo_canvas_box_append(HIPPO_CANVAS_BOX(root),
                            shape2, 0);
    g_object_unref(shape2);
#endif
    
    for (i = 0; i < (int) G_N_ELEMENTS(box_rows); ++i) {
        HippoCanvasItem *row = create_row(box_rows[i]);
        hippo_canvas_box_append(HIPPO_CANVAS_BOX(root), row, 0);
        g_object_unref(row);
    }
    
    
    hippo_canvas_set_root(HIPPO_CANVAS(canvas), root);
    g_object_unref(root);

    gtk_widget_show(window);
}
Exemplo n.º 3
0
void 
hippo_canvas_stack_update_hidden_blocks(HippoCanvasStack *canvas_stack)
{
    UpdateHiddenData uhd;

    /* The algorithm here isn't efficient; we walk through the entire
     * stack each time a block is added or restacked and accumulate
     * the set of music tracks that have been chatted on. Any music person
     * block about these tracks that occurs after the music chat block
     * is suppressed. This makes initial construction of the stack
     * an O(N^2) operation, though the individual walks are pretty
     * fast.
     *
     * A more efficient thing to do would be to keep a permanent list
     * of chatted track ids for the stack, and update visibility only
     * when a new track is added to that list or a music person block
     * is restacked (and thus has a new play id).
     */
    uhd.canvas_stack = canvas_stack;
    uhd.chatted = g_hash_table_new(g_str_hash, g_str_equal);
    
    hippo_canvas_box_foreach(HIPPO_CANVAS_BOX(canvas_stack),
                             foreach_update_hidden,
                             &uhd);
    
    g_hash_table_destroy(uhd.chatted);
}
Exemplo n.º 4
0
static void
set_surface_from_name(HippoCanvasImage *image)
{
    if (image->image_name == NULL) {
        set_surface(image, NULL);
    } else {
        cairo_surface_t *surface;
        HippoCanvasContext *context;

        context = hippo_canvas_box_get_context(HIPPO_CANVAS_BOX(image));

        /* If context is NULL, we'll call set_surface_from_name again
         * when a new context is set
         */
        if (context != NULL) {
            /* may return NULL */
            surface = hippo_canvas_context_load_image(context,
                                                      image->image_name);
            set_surface(image, surface);
            
            if (surface != NULL)
                cairo_surface_destroy(surface);
        } else {
            set_surface(image, NULL);
        }
    }
}
Exemplo n.º 5
0
static void
hippo_canvas_control_set_context(HippoCanvasItem    *item,
                                 HippoCanvasContext *context)
{
    HippoCanvasBox *box = HIPPO_CANVAS_BOX(item);

    if (context == box->context)
        return;

    if (box->context) {
        hippo_canvas_context_unregister_widget_item(box->context, item);

        g_signal_handlers_disconnect_by_func(box->context,
                                             (gpointer)on_context_style_changed,
                                             context);
    }

    /* chain up, which invalidates our old context */
    item_parent_class->set_context(item, context);

    if (box->context) {
        hippo_canvas_context_register_widget_item(box->context, item);

        g_signal_connect(box->context, "style-changed",
                         G_CALLBACK(on_context_style_changed), item);
    }

    on_context_style_changed(context, TRUE, HIPPO_CANVAS_CONTROL(item));
}
Exemplo n.º 6
0
/* this is analogous to what pygtk does for GtkObject, GtkWindow, etc.
 * but it just has to be a bug in pygtk that it works this way.
 */
static void
sink_hippocanvasbox(GObject *object)
{
    if (HIPPO_CANVAS_BOX(object)->floating) {
        g_object_ref(object);
        hippo_canvas_item_sink(HIPPO_CANVAS_ITEM(object));
    }
}
Exemplo n.º 7
0
static GObject*
hippo_canvas_chat_preview_constructor (GType                  type,
                                       guint                  n_construct_properties,
                                       GObjectConstructParam *construct_properties)
{
    GObject *object = G_OBJECT_CLASS(hippo_canvas_chat_preview_parent_class)->constructor(type,
                                                                                          n_construct_properties,
                                                                                          construct_properties);
    
    HippoCanvasChatPreview *chat_preview = HIPPO_CANVAS_CHAT_PREVIEW(object);
    HippoCanvasBox *box;
    HippoCanvasItem *item;
    int i;
    
    for (i = 0; i < MAX_PREVIEWED; ++i) {
        chat_preview->message_previews[i] = g_object_new(HIPPO_TYPE_CANVAS_MESSAGE_PREVIEW,
                                                         "actions", chat_preview->actions,
                                                         NULL);
        
        hippo_canvas_box_append(HIPPO_CANVAS_BOX(chat_preview),
                                chat_preview->message_previews[i],
                                0);
    }

    box = g_object_new(HIPPO_TYPE_CANVAS_BOX,
                       "orientation", HIPPO_ORIENTATION_HORIZONTAL,
                       "color", HIPPO_CANVAS_BLOCK_GRAY_TEXT_COLOR,
                       NULL);

    hippo_canvas_box_append(HIPPO_CANVAS_BOX(chat_preview), HIPPO_CANVAS_ITEM(box), 0);
    
    item = g_object_new(HIPPO_TYPE_CANVAS_LINK,
                        "tooltip", "View all quips and comments",
                        NULL);
    chat_preview->chat_link = item;
    hippo_canvas_box_append(box, item, 0);

    g_signal_connect(G_OBJECT(item), "activated",
                     G_CALLBACK(on_chat_activated), chat_preview);

    update_chat_messages_count(chat_preview);
    update_chat_messages(chat_preview);
    hippo_canvas_chat_preview_update_visibility(chat_preview);

    return object;
}
Exemplo n.º 8
0
static void
hippo_canvas_link_init(HippoCanvasLink *link)
{
    HippoCanvasBox *box = HIPPO_CANVAS_BOX(link);

    hippo_canvas_box_set_link_type(box, HIPPO_CANVAS_LINK_LINK);
    hippo_canvas_box_set_clickable(box, TRUE);
}
Exemplo n.º 9
0
HippoCanvasItem*
hippo_canvas_stack_new(void)
{
    HippoCanvasStack *stack = g_object_new(HIPPO_TYPE_CANVAS_STACK, NULL);

    HIPPO_CANVAS_BOX(stack)->background_color_rgba = 0xffffffff;
    
    return HIPPO_CANVAS_ITEM(stack);
}
Exemplo n.º 10
0
static GObject*
hippo_canvas_filter_area_constructor (GType                  type,
                                      guint                  n_construct_properties,
                                      GObjectConstructParam *construct_properties)
{
    GObject *object = G_OBJECT_CLASS(hippo_canvas_filter_area_parent_class)->constructor(type,
                                                                                         n_construct_properties,
                                                                                         construct_properties);
    HippoCanvasFilterArea *area = HIPPO_CANVAS_FILTER_AREA(object);
    HippoCanvasItem *item;    
    HippoCanvasBox *box;
    
    box = g_object_new(HIPPO_TYPE_CANVAS_IMAGE,
                       "orientation", HIPPO_ORIENTATION_HORIZONTAL,
                       NULL);
    hippo_canvas_box_append(HIPPO_CANVAS_BOX(area),
                            HIPPO_CANVAS_ITEM(box), 0);    

    box->background_color_rgba = 0xE4D0EDFF;
    
    item = g_object_new(HIPPO_TYPE_CANVAS_TEXT,
                        "text", "Hide feeds: ",
                        "padding-left", 4,
                        "xalign", HIPPO_ALIGNMENT_START,
                        NULL);
    hippo_canvas_box_append(box, item, 0);    
    
    item = g_object_new(HIPPO_TYPE_CANVAS_IMAGE_BUTTON,
                        "normal-image-name", "checkbox",
                        "xalign", HIPPO_ALIGNMENT_START,
                        "yalign", HIPPO_ALIGNMENT_CENTER,
                        "tooltip", "Whether or not to display group feed items",
                        NULL);
    hippo_canvas_box_append(box, item, 0);
    g_signal_connect(G_OBJECT(item), "activated", G_CALLBACK(on_nofeed_activated), area);
    area->nofeed_item = item;
    
    item = g_object_new(HIPPO_TYPE_CANVAS_TEXT,
                        "text", "Hide my items: ",
                        "padding-left", 40,
                        "xalign", HIPPO_ALIGNMENT_START,
                        NULL);
    hippo_canvas_box_append(box, item, 0);    
    
    item = g_object_new(HIPPO_TYPE_CANVAS_IMAGE_BUTTON,
                        "normal-image-name", "checkbox",
                        "xalign", HIPPO_ALIGNMENT_START,
                        "yalign", HIPPO_ALIGNMENT_CENTER,
                        "tooltip", "Whether or not to show items from me",
                        NULL);
    hippo_canvas_box_append(box, item, 0);
    g_signal_connect(G_OBJECT(item), "activated", G_CALLBACK(on_noselfsource_activated), area);
    area->noselfsource_item = item;    
   
    return object;
}
Exemplo n.º 11
0
static void
remove_extra_children(HippoCanvasStack *canvas_stack)
{
    if (canvas_stack->max_blocks < G_MAXINT) {
        GList *children;
        int count;
        children = hippo_canvas_box_get_children(HIPPO_CANVAS_BOX(canvas_stack));
        count = g_list_length(children);
        if (count > canvas_stack->max_blocks)
            children = g_list_reverse(children);
        while (count > canvas_stack->max_blocks) {
            g_assert(children != NULL);
            hippo_canvas_box_remove(HIPPO_CANVAS_BOX(canvas_stack), children->data);
            children = g_list_remove(children, children->data);
            --count;
        }
        g_list_free(children);
    }
}
Exemplo n.º 12
0
void
hippo_canvas_stack_add_block(HippoCanvasStack *canvas_stack,
                             HippoBlock       *block,
                             gboolean          visible)
{
    HippoCanvasItem *item;
    gint64 sort_timestamp;

    sort_timestamp = hippo_block_get_sort_timestamp(block);
    if (sort_timestamp < canvas_stack->min_timestamp)
        return;

    item = find_block_item(canvas_stack, block);

    if (item != NULL) {
        g_object_ref(item);
        hippo_canvas_box_remove(HIPPO_CANVAS_BOX(canvas_stack), item);
    } else {
        item = hippo_canvas_block_new(hippo_block_get_block_type(block),
                                      canvas_stack->actions);
        g_object_ref(item);
    }

    g_object_set(G_OBJECT(item), "block", block, NULL);
    hippo_canvas_box_insert_sorted(HIPPO_CANVAS_BOX(canvas_stack), item, 0,
                                   canvas_block_compare, canvas_stack);

    hippo_canvas_box_set_child_visible(HIPPO_CANVAS_BOX(canvas_stack), item, visible);
    remove_extra_children(canvas_stack);
    
    g_object_unref(item);

    /* Updating possibly visible blocks at this point doesn't take
     * into account the possibility of a block changing in such a way
     * to cause other blocks to be hidden without being restacked;
     * (for example, a MUSIC_CHAT block changing play_id to match
     * a MUSIC_PERSON block further down the stack). This is unlikely
     * to happen currently.
     */
    hippo_canvas_stack_update_hidden_blocks(canvas_stack);
}
Exemplo n.º 13
0
static HippoCanvasItem*
create_row(BoxAttrs *boxes)
{
    HippoCanvasItem *row;
    int i;
    
    row = g_object_new(HIPPO_TYPE_CANVAS_BOX, "orientation", HIPPO_ORIENTATION_HORIZONTAL, NULL);

    for (i = 0; boxes[i].width > 0; ++i) {
        BoxAttrs *attrs = &boxes[i];
        HippoCanvasItem *shape;
        HippoCanvasItem *label;
        const char *text;

        shape = g_object_new(HIPPO_TYPE_CANVAS_SHAPE,
                             "width", attrs->width,
                             "height", attrs->height,
                             "color", attrs->color,
                             NULL);
        hippo_canvas_box_append(HIPPO_CANVAS_BOX(row), shape, attrs->flags);
        g_object_unref(shape);
        
        if (attrs->flags == (HIPPO_PACK_END | HIPPO_PACK_EXPAND))
            text = "END | EXPAND";
        else if (attrs->flags == HIPPO_PACK_END)
            text = "END";
        else if (attrs->flags == HIPPO_PACK_EXPAND)
            text = "EXPAND";
        else
            text = "0";
        
        label = g_object_new(HIPPO_TYPE_CANVAS_TEXT,
                             "text", text,
                             "background-color", 0x0000ff00,
                             NULL);
        hippo_canvas_box_append(HIPPO_CANVAS_BOX(shape), label, HIPPO_PACK_EXPAND);
        g_object_unref(label);
    }
    return row;
}
Exemplo n.º 14
0
void
hippo_canvas_stack_set_min_timestamp(HippoCanvasStack *canvas_stack,
                                     gint64            min_timestamp)
{
    if (canvas_stack->min_timestamp == min_timestamp)
        return;

    canvas_stack->min_timestamp = min_timestamp;

    hippo_canvas_box_foreach(HIPPO_CANVAS_BOX(canvas_stack),
                             foreach_update_min_timestamp,
                             canvas_stack);
}
Exemplo n.º 15
0
static void
hippo_canvas_image_set_context(HippoCanvasItem    *item,
                               HippoCanvasContext *context)
{
    HippoCanvasImage *image = HIPPO_CANVAS_IMAGE(item);
    HippoCanvasBox *box = HIPPO_CANVAS_BOX(item);
    HippoCanvasContext *old = box->context;

    item_parent_class->set_context(item, context);

    if (old != box->context && image->image_name != NULL)
        set_surface_from_name(image);
}
Exemplo n.º 16
0
static HippoCanvasItem*
create_test_click_release_root(void)
{
    HippoCanvasItem *box;
    HippoCanvasItem *text;
    
    box = g_object_new(HIPPO_TYPE_CANVAS_BOX,
                       "orientation", HIPPO_ORIENTATION_HORIZONTAL,
                       "border", 4,
                       "border-color", 0x000000ff,
                       "padding", 10,
                       "background-color", 0xffffffff,
                       "spacing", 10,
                       NULL);

    text = g_object_new(HIPPO_TYPE_CANVAS_LINK,
                        "size-mode", HIPPO_CANVAS_SIZE_ELLIPSIZE_END,
                        "text", "Click Me!",
                        "background-color", 0xffaaaaff,                        
                        NULL);

    hippo_canvas_box_append(HIPPO_CANVAS_BOX(box), text, 0);

    g_signal_connect(G_OBJECT(text), "activated", G_CALLBACK(on_item_activated), NULL);
    
    text = g_object_new(HIPPO_TYPE_CANVAS_LINK,
                        "size-mode", HIPPO_CANVAS_SIZE_ELLIPSIZE_END,
                        "text", "Click Me!",
                        "background-color", 0x00aaffff,
                        NULL);
    
    hippo_canvas_box_append(HIPPO_CANVAS_BOX(box), text, 0);

    g_signal_connect(G_OBJECT(text), "activated", G_CALLBACK(on_item_activated), NULL);

    return box;
}
Exemplo n.º 17
0
void
hippo_canvas_stack_remove_block(HippoCanvasStack *canvas_stack,
                                HippoBlock       *block)
{
    HippoCanvasItem *item;

    item = find_block_item(canvas_stack, block);

    if (item != NULL) {
        g_object_set(G_OBJECT(item),
                     "block", NULL,
                     NULL);
        hippo_canvas_box_remove(HIPPO_CANVAS_BOX(canvas_stack), item);
    }
}
Exemplo n.º 18
0
static HippoCanvasItem*
find_block_item(HippoCanvasStack *canvas_stack,
                HippoBlock       *block)
{
    FindItemData fid;

    fid.block = block;
    fid.found = NULL;
    
    hippo_canvas_box_foreach(HIPPO_CANVAS_BOX(canvas_stack),
                             foreach_find_item,
                             &fid);

    return fid.found;
}
Exemplo n.º 19
0
static void
hippo_canvas_link_set_visited(HippoCanvasLink    *link,
                              gboolean            visited)
{
    visited = visited != FALSE;
    
    if (visited != link->visited) {
        HippoCanvasBox *box = HIPPO_CANVAS_BOX(link);

        link->visited = visited;
        
        hippo_canvas_box_set_link_type(box,
                                       visited ? HIPPO_CANVAS_LINK_VISITED : HIPPO_CANVAS_LINK_LINK);
    }
}
Exemplo n.º 20
0
static void
foreach_update_min_timestamp(HippoCanvasItem *child,
                             void            *data)
{
    HippoCanvasStack *stack = data;
    HippoBlock *child_block = NULL;
    gint64 sort_timestamp;

    g_object_get(G_OBJECT(child), "block", &child_block, NULL);

    sort_timestamp = hippo_block_get_sort_timestamp(child_block);
    if (sort_timestamp < stack->min_timestamp)
        hippo_canvas_box_remove(HIPPO_CANVAS_BOX(stack), child);

    g_object_unref(child_block);
}
Exemplo n.º 21
0
static gboolean
notification_is_needed(StackManager *manager)
{
    NotificationNeededInfo info;
    
    info.manager = manager;
    info.is_needed = FALSE;
    
    g_debug("Checking if notification is needed\n");
    
    hippo_canvas_box_foreach(HIPPO_CANVAS_BOX(manager->notification_item), 
                             notification_is_needed_callback,
                             &info);

    return info.is_needed;
}
Exemplo n.º 22
0
static void
hippo_canvas_widget_set_context(HippoCanvasItem    *item,
                                HippoCanvasContext *context)
{
    HippoCanvasBox *box = HIPPO_CANVAS_BOX(item);

    if (context == box->context)
        return;

    if (box->context)
        hippo_canvas_context_unregister_widget_item(box->context, item);

    /* chain up, which invalidates our old context */
    item_parent_class->set_context(item, context);

    if (box->context)
        hippo_canvas_context_register_widget_item(box->context, item);
}
Exemplo n.º 23
0
static void
foreach_update_hidden(HippoCanvasItem *child,
                      void            *data)
{
    UpdateHiddenData *uhd = data;
    HippoBlock *child_block = NULL;

    g_object_get(G_OBJECT(child), "block", &child_block, NULL);

    if (HIPPO_IS_BLOCK_MUSIC_CHAT(child_block)) {
        const char *play_id = NULL;
        HippoTrack *track = NULL;
        g_object_get(child_block, "track", &track, NULL);

        if (track) {
            play_id = hippo_track_get_play_id(track);
            g_object_unref(track);
        }

        if (play_id)
            g_hash_table_insert(uhd->chatted, (void *)play_id, GUINT_TO_POINTER(1));
        
    } else if (HIPPO_IS_BLOCK_MUSIC_PERSON(child_block)) {
        const char *play_id = NULL;
        GSList *track_history = NULL;
        gboolean seen_track = FALSE;
        
        g_object_get(child_block, "track_history", &track_history, NULL);

        if (track_history) {
            HippoTrack *track = track_history->data;
            play_id = hippo_track_get_play_id(track);
        }

        if (play_id)
            seen_track = g_hash_table_lookup(uhd->chatted, play_id) != NULL;

        hippo_canvas_box_set_child_visible(HIPPO_CANVAS_BOX(uhd->canvas_stack), 
                                           child, !seen_track);
    }

    if (child_block)
        g_object_unref(child_block);
}
Exemplo n.º 24
0
static void
hippo_canvas_widget_allocate(HippoCanvasItem *item,
                             int              width,
                             int              height,
                             gboolean         origin_changed)
{
    int x, y, w, h;
    int widget_x, widget_y;
    GtkAllocation child_allocation;
    HippoCanvasWidget *widget;
    HippoCanvasBox *box;

    widget = HIPPO_CANVAS_WIDGET(item);
    box = HIPPO_CANVAS_BOX(item);
    
    /* get the box set up */
    item_parent_class->allocate(item, width, height, origin_changed);

    if (widget->widget == NULL)
        return;
    
    /* this probably queues a resize, which is not ideal */
    update_widget_visibility(widget);
    
    /* Now do the GTK allocation for the child widget */
    w = widget->widget->requisition.width;
    h = widget->widget->requisition.height;

    hippo_canvas_box_align(box, w, h, &x, &y, &w, &h);

    widget_x = 0;
    widget_y = 0;
    if (box->context)
        hippo_canvas_context_translate_to_widget(box->context, item,
                                                 &widget_x, &widget_y);

    child_allocation.x = widget_x + x;
    child_allocation.y = widget_y + y;
    child_allocation.width = MAX(w, 1);
    child_allocation.height = MAX(h, 1);

    gtk_widget_size_allocate(widget->widget, &child_allocation);
}
Exemplo n.º 25
0
static char *
hippo_canvas_text_get_tooltip (HippoCanvasItem *item,
                               int              x,
                               int              y,
                               HippoRectangle  *for_area)
{
    HippoCanvasText *text = HIPPO_CANVAS_TEXT(item);
    HippoCanvasBox *box = HIPPO_CANVAS_BOX(item);

    
    if (text->is_ellipsized && text->text) {
        for_area->x = 0;
        for_area->y = 0;
        for_area->width = box->allocated_width;
        for_area->height = box->allocated_height;

        return g_strdup(text->text);
    } else
        return item_parent_class->get_tooltip(item, x, y, for_area);
}
Exemplo n.º 26
0
static void
hippo_canvas_text_set_context(HippoCanvasItem    *item,
                              HippoCanvasContext *context)
{
    HippoCanvasBox *box = HIPPO_CANVAS_BOX(item);
    gboolean changed;
    
    changed = context != box->context;
    
    item_parent_class->set_context(item, context);

    /* we can't create a layout until we have a context,
     * so we have to queue a size change when the context
     * is set.
     */
    if (changed) {
        hippo_canvas_item_emit_request_changed(HIPPO_CANVAS_ITEM(item));
        hippo_canvas_item_emit_paint_needed(HIPPO_CANVAS_ITEM(item), 0, 0, -1, -1);
    }
}
Exemplo n.º 27
0
static void
hippo_canvas_widget_allocate(HippoCanvasItem *item,
                             int              width,
                             int              height,
                             gboolean         origin_changed)
{
    int x, y, w, h;
    int widget_x, widget_y;
    GtkAllocation child_allocation;
    HippoCanvasWidget *widget;
    HippoCanvasBox *box;

    widget = HIPPO_CANVAS_WIDGET(item);
    box = HIPPO_CANVAS_BOX(item);
    
    /* get the box set up */
    item_parent_class->allocate(item, width, height, origin_changed);

    /* Now do the GTK allocation for the child widget */
    if (widget->widget == NULL || !GTK_WIDGET_VISIBLE(widget->widget))
        return;
    
    w = widget->widget->requisition.width;
    h = widget->widget->requisition.height;

    hippo_canvas_box_align(box, w, h, &x, &y, &w, &h);

    widget_x = 0;
    widget_y = 0;
    if (box->context)
        hippo_canvas_context_translate_to_widget(box->context, item,
                                                 &widget_x, &widget_y);

    child_allocation.x = widget_x + x;
    child_allocation.y = widget_y + y;
    child_allocation.width = w;
    child_allocation.height = h;

    gtk_widget_size_allocate(widget->widget, &child_allocation);
}
Exemplo n.º 28
0
static void
hippo_canvas_control_position(HippoCanvasControl *control)
{
    HippoCanvasItem *item = HIPPO_CANVAS_ITEM(control);
    HippoCanvasBox *box = HIPPO_CANVAS_BOX(item);

    int x, y, w, h;
    int control_x, control_y;
    
    if (control->control == NULL)
        return;

    control->control->getLastRequest(&w, &h);

    hippo_canvas_box_align(box, w, h, &x, &y, &w, &h);

    control_x = 0;
    control_y = 0;
    if (box->context)
        hippo_canvas_context_translate_to_widget(box->context, item,
                                                 &control_x, &control_y);

    control->control->sizeAllocate(control_x + x, control_y + y, w, h);
}
Exemplo n.º 29
0
HippoStackManager*
hippo_stack_manager_new(DDMDataModel         *model,
                        HippoStackerPlatform *platform)
{
    StackManager *manager;

    manager = g_new0(StackManager, 1);
    manager->item_to_block = g_hash_table_new_full(g_direct_hash, NULL,
                                                   NULL, (GDestroyNotify)g_object_unref);

    manager->model = g_object_ref(model);
    manager->platform = g_object_ref(platform);
                                                       
    manager->actions = hippo_actions_new(manager->model, manager->platform, manager);
    
    manager->browser_window = hippo_stacker_platform_create_window(manager->platform);

#ifdef WITH_MAEMO
    g_object_set(manager->browser_window, "role", HIPPO_WINDOW_ROLE_NOTIFICATION, NULL);
#endif

    g_signal_connect(manager->browser_window, "minimize",
                     G_CALLBACK(on_browser_minimize), manager);

    hippo_window_set_resizable(manager->browser_window,
                               HIPPO_ORIENTATION_VERTICAL,
                               TRUE);
    
    manager->browser_base_item = g_object_new(HIPPO_TYPE_CANVAS_BASE,
                                              "actions", manager->actions,
                                              "notification-mode", FALSE,
                                              NULL);
    g_signal_connect(manager->browser_base_item,
                     "title-bar-button-press-event",
                     G_CALLBACK(on_browser_title_bar_button_press),
                     manager);
                     
    manager->browser_filter_area_item = g_object_new(HIPPO_TYPE_CANVAS_FILTER_AREA,
                                                     "actions", manager->actions,
                                                     NULL);
                     
    manager->browser_item = g_object_new(HIPPO_TYPE_CANVAS_STACK,
                                         "box-width", UI_WIDTH,
                                         "actions", manager->actions,
                                         "pin-messages", TRUE,
                                         NULL);
    manager->browser_scroll_item = hippo_canvas_scrollbars_new();                                         
    hippo_canvas_scrollbars_set_policy(HIPPO_CANVAS_SCROLLBARS(manager->browser_scroll_item),
                                       HIPPO_ORIENTATION_HORIZONTAL,
                                       HIPPO_SCROLLBAR_NEVER);
    hippo_canvas_scrollbars_set_policy(HIPPO_CANVAS_SCROLLBARS(manager->browser_scroll_item),
                                       HIPPO_ORIENTATION_VERTICAL,
                                       HIPPO_SCROLLBAR_ALWAYS);                                     
    
    manager->browser_resize_grip = g_object_new(HIPPO_TYPE_CANVAS_GRIP,
                                              NULL);

    g_signal_connect(G_OBJECT(manager->browser_resize_grip),
                     "button-press-event",
                     G_CALLBACK(on_browser_resize_grip_button_press),
                     manager);
    
    manager->browser_box = g_object_new(HIPPO_TYPE_CANVAS_BOX,
                                        "orientation", HIPPO_ORIENTATION_VERTICAL,
                                        "border", WINDOW_BORDER,
                                        "border-color", 0x9c9c9cff,
                                        NULL);
    
    hippo_canvas_box_append(HIPPO_CANVAS_BOX(manager->browser_box),
                            manager->browser_base_item,
                            0);
    hippo_canvas_box_append(HIPPO_CANVAS_BOX(manager->browser_box),
                            manager->browser_filter_area_item,
                            0);
    hippo_canvas_item_set_visible(manager->browser_filter_area_item, FALSE);

    hippo_canvas_scrollbars_set_root(HIPPO_CANVAS_SCROLLBARS(manager->browser_scroll_item),
                                     manager->browser_item);
    hippo_canvas_box_append(HIPPO_CANVAS_BOX(manager->browser_box),
                            manager->browser_scroll_item,
                            HIPPO_PACK_EXPAND);
                            
    hippo_canvas_box_append(HIPPO_CANVAS_BOX(manager->browser_box),
                            manager->browser_resize_grip,
                            0);
    
    hippo_window_set_contents(manager->browser_window, manager->browser_box);

    manager->notification_window = hippo_stacker_platform_create_window(manager->platform);

    /* Omit the window from the task-list and (for platforms where there is one) the pager */
    g_object_set(manager->notification_window, "role", HIPPO_WINDOW_ROLE_NOTIFICATION, NULL);

    manager->notification_base_item = g_object_new(HIPPO_TYPE_CANVAS_BASE,
                                                   "actions", manager->actions,
                                                   "notification-mode", TRUE,
                                                   NULL);
    manager->notification_item = g_object_new(HIPPO_TYPE_CANVAS_STACK,
                                              "box-width", UI_WIDTH,
                                              "actions", manager->actions,
                                              "max-blocks", 3,
                                              NULL);

    manager->notification_box = g_object_new(HIPPO_TYPE_CANVAS_BOX,
                                             "orientation", HIPPO_ORIENTATION_VERTICAL,
                                             "border", 1,
                                             "border-color", 0x9c9c9cff,
                                             NULL);

    g_signal_connect(manager->notification_box, "motion-notify-event",
                     G_CALLBACK(on_notification_motion_notify), manager);

    hippo_canvas_box_append(HIPPO_CANVAS_BOX(manager->notification_box),
                            manager->notification_base_item, 0);
    hippo_canvas_box_append(HIPPO_CANVAS_BOX(manager->notification_box),
                            manager->notification_item, 0);

    hippo_window_set_contents(manager->notification_window, manager->notification_box);

    g_signal_connect(manager->model, "ready",
                     G_CALLBACK(on_ready), manager);

    if (ddm_data_model_is_ready(manager->model))
        on_ready(manager->model, manager);

    return manager;
}
Exemplo n.º 30
0
static void
update_for_screen_info (StackManager    *manager,
                        HippoRectangle  *monitor,
                        HippoRectangle  *icon,
                        HippoOrientation icon_orientation,
                        gboolean         position_browser,
                        gboolean         position_notification)
{
    HippoRectangle base;
    gboolean is_west;
    gboolean is_north;

#if 1
    g_debug("SIZING: work area %d,%d %dx%d icon %d,%d %dx%d orientation %d",
        monitor->x, monitor->y, monitor->width,  monitor->height,
        icon->x, icon->y, icon->width, icon->height, 
        icon_orientation);
#endif

    is_west = ((icon->x + icon->width / 2) < (monitor->x + monitor->width / 2));
    is_north = ((icon->y + icon->height / 2) < (monitor->y + monitor->height / 2));

    /* We pretend the icon is always in the corner */
    if (is_west) {
        icon->x = monitor->x;
        if (icon_orientation == HIPPO_ORIENTATION_VERTICAL)
            icon->x -= icon->width;
    } else {
        icon->x = monitor->x + monitor->width - icon->width;
        if (icon_orientation == HIPPO_ORIENTATION_VERTICAL)
            icon->x += icon->width;
    }
    
    if (is_north) {
        icon->y = monitor->y;
        if (icon_orientation == HIPPO_ORIENTATION_HORIZONTAL)
            icon->y -= icon->height;
    } else {
        icon->y = monitor->y + monitor->height - icon->height;
        if (icon_orientation == HIPPO_ORIENTATION_HORIZONTAL)
            icon->y += icon->height;
    }

    /* g_debug("base_on_bottom %d is_north %d", manager->base_on_bottom, is_north); */

    if ((manager->base_on_bottom && is_north) ||
        (!manager->base_on_bottom && !is_north)) {
        hippo_canvas_box_reverse(HIPPO_CANVAS_BOX(manager->notification_box));
        manager->base_on_bottom = !manager->base_on_bottom;
    }

    /* We only resize vertically, so we don't need to worry about EAST/WEST */
    g_object_set(manager->notification_window, 
                 "resize-gravity", is_north ? HIPPO_GRAVITY_NORTH_WEST : HIPPO_GRAVITY_SOUTH_WEST, 
                 NULL);

    if (position_browser)
        position_alongside(manager->browser_window, 3, icon,
                           icon_orientation,
                           is_west, is_north, &base);
    
    if (position_notification)
        position_alongside(manager->notification_window, 3, icon,
                           icon_orientation,
                           is_west, is_north, &base);
}