void ro_gui_cookies_open(void) { tree_set_redraw(ro_treeview_get_tree(cookies_window.tv), true); ro_gui_cookies_toolbar_update_buttons(); if (!ro_gui_dialog_open_top(cookies_window.window, cookies_window.toolbar, 600, 800)) { ro_treeview_set_origin(cookies_window.tv, 0, -(ro_toolbar_height(cookies_window.toolbar))); } }
void ro_gui_global_history_open(void) { tree_set_redraw(ro_treeview_get_tree(global_history_window.tv), true); ro_gui_global_history_toolbar_update_buttons(); if (!ro_gui_dialog_open_top(global_history_window.window, global_history_window.toolbar, 600, 800)) { ro_treeview_set_origin(global_history_window.tv, 0, -(ro_toolbar_height( global_history_window.toolbar))); } }
void gui_cert_verify(const char *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw) { struct ro_sslcert *sslcert_window; wimp_window_state state; wimp_icon_state istate; wimp_window_info info; os_error *error; bool set_extent; assert(certs); sslcert_window = malloc(sizeof(struct ro_sslcert)); if (sslcert_window == NULL) { LOG(("Failed to allocate memory for SSL Cert Dialog")); return; } /* Create the SSL window and its pane. */ error = xwimp_create_window(ro_gui_cert_dialog_template, &(sslcert_window->window)); if (error) { LOG(("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess)); free(sslcert_window); return; } error = xwimp_create_window(ro_gui_cert_tree_template, &(sslcert_window->pane)); if (error) { LOG(("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess)); free(sslcert_window); return; } /* Create the SSL data and build a tree from it. */ sslcert_window->tv = ro_treeview_create(sslcert_window->pane, NULL, NULL, sslcert_get_tree_flags()); if (sslcert_window->tv == NULL) { LOG(("Failed to allocate treeview")); free(sslcert_window); return; } sslcert_window->data = sslcert_create_session_data(num, url, cb, cbpw); sslcert_load_tree(ro_treeview_get_tree(sslcert_window->tv), certs, sslcert_window->data); tree_set_redraw(ro_treeview_get_tree(sslcert_window->tv), true); /* Set up the certificate window event handling. * * (The action buttons are registered as button events, not OK and * Cancel, as both need to carry out actions.) */ ro_gui_wimp_event_set_user_data(sslcert_window->window, sslcert_window); ro_gui_wimp_event_register_close_window(sslcert_window->window, ro_gui_cert_close_window); ro_gui_wimp_event_register_button(sslcert_window->window, ICON_SSL_REJECT, ro_gui_cert_reject); ro_gui_wimp_event_register_button(sslcert_window->window, ICON_SSL_ACCEPT, ro_gui_cert_accept); ro_gui_dialog_open_persistent(NULL, sslcert_window->window, false); /* Nest the tree window inside the pane window. To do this, we: * - Get the current pane extent, * - Get the parent window position and the location of the pane- * locating icon inside it, * - Set the visible area of the pane to suit, * - Check that the pane extents are OK for this visible area, and * increase them if necessary, * - Before finally opening the pane as a nested part of the parent. */ info.w = sslcert_window->pane; error = xwimp_get_window_info_header_only(&info); if (error) { ro_gui_cert_release_window(sslcert_window); LOG(("xwimp_get_window_info: 0x%x: %s", error->errnum, error->errmess)); return; } state.w = sslcert_window->window; error = xwimp_get_window_state(&state); if (error) { ro_gui_cert_release_window(sslcert_window); LOG(("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess)); return; } istate.w = sslcert_window->window; istate.i = ICON_SSL_PANE; error = xwimp_get_icon_state(&istate); if (error) { ro_gui_cert_release_window(sslcert_window); LOG(("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess)); return; } state.w = sslcert_window->pane; state.visible.x1 = state.visible.x0 + istate.icon.extent.x1 - 20 - ro_get_vscroll_width(sslcert_window->pane); state.visible.x0 += istate.icon.extent.x0 + 20; state.visible.y0 = state.visible.y1 + istate.icon.extent.y0 + 20 + ro_get_hscroll_height(sslcert_window->pane); state.visible.y1 += istate.icon.extent.y1 - 32; set_extent = false; if ((info.extent.x1 - info.extent.x0) < (state.visible.x1 - state.visible.x0)) { info.extent.x0 = 0; info.extent.x1 = state.visible.x1 - state.visible.x0; set_extent = true; } if ((info.extent.y1 - info.extent.y0) < (state.visible.y1 - state.visible.y0)) { info.extent.y1 = 0; info.extent.x1 = state.visible.y0 - state.visible.y1; set_extent = true; } if (set_extent) { error = xwimp_set_extent(sslcert_window->pane, &(info.extent)); if (error) { ro_gui_cert_release_window(sslcert_window); LOG(("xwimp_set_extent: 0x%x: %s", error->errnum, error->errmess)); return; } } error = xwimp_open_window_nested(PTR_WIMP_OPEN(&state), sslcert_window->window, wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT << wimp_CHILD_XORIGIN_SHIFT | wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT << wimp_CHILD_YORIGIN_SHIFT | wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT << wimp_CHILD_LS_EDGE_SHIFT | wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT << wimp_CHILD_RS_EDGE_SHIFT); if (error) { ro_gui_cert_release_window(sslcert_window); LOG(("xwimp_open_window_nested: 0x%x: %s", error->errnum, error->errmess)); ro_gui_cert_release_window(sslcert_window); return; } ro_treeview_set_origin(sslcert_window->tv, 0, 0); }
static gboolean nsgtk_tree_window_draw_event(GtkWidget *widget, cairo_t *cr, gpointer data) { struct tree *tree = (struct tree *)data; struct redraw_context ctx = { .interactive = true, .background_images = true, .plot = &nsgtk_plotters }; double x1; double y1; double x2; double y2; current_widget = widget; current_cr = cr; cairo_clip_extents(cr, &x1, &y1, &x2, &y2); tree_set_redraw(tree, true); tree_draw(tree, 0, 0, x1, y1, x2 - x1, y2 - y1, &ctx); current_widget = NULL; return FALSE; } #else /* signal handler functions for a tree window */ static gboolean nsgtk_tree_window_draw_event(GtkWidget *widget, GdkEventExpose *event, gpointer g) { struct tree *tree = (struct tree *) g; struct redraw_context ctx = { .interactive = true, .background_images = true, .plot = &nsgtk_plotters }; int x, y, width, height; x = event->area.x; y = event->area.y; width = event->area.width; height = event->area.height; current_widget = widget; current_cr = gdk_cairo_create(nsgtk_widget_get_window(widget)); tree_set_redraw(tree, true); tree_draw(tree, 0, 0, x, y, width, height, &ctx); current_widget = NULL; cairo_destroy(current_cr); return FALSE; } #endif void nsgtk_tree_window_hide(GtkWidget *widget, gpointer g) { struct nsgtk_treeview *tw = g; struct tree *tree = tw->tree; if (tree != NULL) tree_set_redraw(tree, false); } gboolean nsgtk_tree_window_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer g) { struct nsgtk_treeview *tw = g; struct tree *tree = tw->tree; gtk_widget_grab_focus(GTK_WIDGET(tw->drawing_area)); tw->mouse_pressed = true; tw->mouse_pressed_x = event->x; tw->mouse_pressed_y = event->y; if (event->type == GDK_2BUTTON_PRESS) tw->mouse_state = BROWSER_MOUSE_DOUBLE_CLICK; switch (event->button) { case 1: tw->mouse_state |= BROWSER_MOUSE_PRESS_1; break; case 3: tw->mouse_state |= BROWSER_MOUSE_PRESS_2; break; } /* Handle the modifiers too */ if (event->state & GDK_SHIFT_MASK) tw->mouse_state |= BROWSER_MOUSE_MOD_1; if (event->state & GDK_CONTROL_MASK) tw->mouse_state |= BROWSER_MOUSE_MOD_2; if (event->state & GDK_MOD1_MASK) tw->mouse_state |= BROWSER_MOUSE_MOD_3; /* Record where we pressed, for use when determining whether to start * a drag in motion notify events. */ tw->last_x = event->x; tw->last_y = event->y; tree_mouse_action(tree, tw->mouse_state, event->x, event->y); return TRUE; } gboolean nsgtk_tree_window_button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer g) { bool shift = event->state & GDK_SHIFT_MASK; bool ctrl = event->state & GDK_CONTROL_MASK; bool alt = event->state & GDK_MOD1_MASK; struct nsgtk_treeview *tw = (struct nsgtk_treeview *) g; struct tree *tree = tw->tree; /* We consider only button 1 clicks as double clicks. * If the mouse state is PRESS then we are waiting for a release to emit * a click event, otherwise just reset the state to nothing*/ if (tw->mouse_state & BROWSER_MOUSE_DOUBLE_CLICK) { if (tw->mouse_state & BROWSER_MOUSE_PRESS_1) tw->mouse_state ^= BROWSER_MOUSE_PRESS_1 | BROWSER_MOUSE_CLICK_1; else if (tw->mouse_state & BROWSER_MOUSE_PRESS_2) tw->mouse_state ^= (BROWSER_MOUSE_PRESS_2 | BROWSER_MOUSE_CLICK_2 | BROWSER_MOUSE_DOUBLE_CLICK); } else if (tw->mouse_state & BROWSER_MOUSE_PRESS_1) tw->mouse_state ^= (BROWSER_MOUSE_PRESS_1 | BROWSER_MOUSE_CLICK_1); else if (tw->mouse_state & BROWSER_MOUSE_PRESS_2) tw->mouse_state ^= (BROWSER_MOUSE_PRESS_2 | BROWSER_MOUSE_CLICK_2); /* Handle modifiers being removed */ if (tw->mouse_state & BROWSER_MOUSE_MOD_1 && !shift) tw->mouse_state ^= BROWSER_MOUSE_MOD_1; if (tw->mouse_state & BROWSER_MOUSE_MOD_2 && !ctrl) tw->mouse_state ^= BROWSER_MOUSE_MOD_2; if (tw->mouse_state & BROWSER_MOUSE_MOD_3 && !alt) tw->mouse_state ^= BROWSER_MOUSE_MOD_3; if (tw->mouse_state & (BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_CLICK_2 | BROWSER_MOUSE_DOUBLE_CLICK)) tree_mouse_action(tree, tw->mouse_state, event->x, event->y); else tree_drag_end(tree, tw->mouse_state, tw->mouse_pressed_x, tw->mouse_pressed_y, event->x, event->y); tw->mouse_state = 0; tw->mouse_pressed = false; return TRUE; } gboolean nsgtk_tree_window_motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer g) { bool shift = event->state & GDK_SHIFT_MASK; bool ctrl = event->state & GDK_CONTROL_MASK; bool alt = event->state & GDK_MOD1_MASK; struct nsgtk_treeview *tw = (struct nsgtk_treeview *) g; struct tree *tree = tw->tree; if (tw->mouse_pressed == false) return TRUE; if ((abs(event->x - tw->last_x) < 5) && (abs(event->y - tw->last_y) < 5)) { /* Mouse hasn't moved far enough from press coordinate for this * to be considered a drag. */ return FALSE; } else { /* This is a drag, ensure it's always treated as such, even if * we drag back over the press location */ tw->last_x = INT_MIN; tw->last_y = INT_MIN; } /* Handle modifiers being removed */ if (tw->mouse_state & BROWSER_MOUSE_MOD_1 && !shift) tw->mouse_state ^= BROWSER_MOUSE_MOD_1; if (tw->mouse_state & BROWSER_MOUSE_MOD_2 && !ctrl) tw->mouse_state ^= BROWSER_MOUSE_MOD_2; if (tw->mouse_state & BROWSER_MOUSE_MOD_3 && !alt) tw->mouse_state ^= BROWSER_MOUSE_MOD_3; if (tw->mouse_state & BROWSER_MOUSE_PRESS_1) { /* Start button 1 drag */ tree_mouse_action(tree, BROWSER_MOUSE_DRAG_1, tw->mouse_pressed_x, tw->mouse_pressed_y); /* Replace PRESS with HOLDING and declare drag in progress */ tw->mouse_state ^= (BROWSER_MOUSE_PRESS_1 | BROWSER_MOUSE_HOLDING_1); tw->mouse_state |= BROWSER_MOUSE_DRAG_ON; return TRUE; } else if (tw->mouse_state & BROWSER_MOUSE_PRESS_2){ /* Start button 2s drag */ tree_mouse_action(tree, BROWSER_MOUSE_DRAG_2, tw->mouse_pressed_x, tw->mouse_pressed_y); /* Replace PRESS with HOLDING and declare drag in progress */ tw->mouse_state ^= (BROWSER_MOUSE_PRESS_2 | BROWSER_MOUSE_HOLDING_2); tw->mouse_state |= BROWSER_MOUSE_DRAG_ON; return TRUE; } if (tw->mouse_state & (BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_HOLDING_2)) tree_mouse_action(tree, tw->mouse_state, event->x, event->y); return TRUE; }