/** * eel_gtk_container_child_add: * * @container: A GtkContainer widget. * @child: A non NULL unparented child. * * Add a @child to a @container. The @child is realized, mapped * and resized if needed. This is usually called from the "GtkContainer::add" * method of the @container. The @child cannot be NULL. */ void eel_gtk_container_child_add (GtkContainer *container, GtkWidget *child) { GtkWidget *widget; g_return_if_fail (GTK_IS_CONTAINER (container)); g_return_if_fail (GTK_IS_WIDGET (child)); widget = GTK_WIDGET (container); gtk_widget_set_parent (child, widget); if (gtk_widget_get_realized (widget)) { gtk_widget_realize (child); } if (gtk_widget_get_mapped (widget) && gtk_widget_get_visible (child)) { if (gtk_widget_get_mapped (widget)) { gtk_widget_map (child); } gtk_widget_queue_resize (child); } }
static gboolean idle_do_action (gpointer data) { GtkComboBox *combo_box; GtkWidget *widget; GailComboBox *gail_combo_box; AtkObject *popup; gboolean do_popup; gail_combo_box = GAIL_COMBO_BOX (data); gail_combo_box->action_idle_handler = 0; widget = GTK_ACCESSIBLE (gail_combo_box)->widget; if (widget == NULL || /* State is defunct */ !gtk_widget_get_sensitive (widget) || !gtk_widget_get_visible (widget)) return FALSE; combo_box = GTK_COMBO_BOX (widget); popup = gtk_combo_box_get_popup_accessible (combo_box); do_popup = !gtk_widget_get_mapped (GTK_ACCESSIBLE (popup)->widget); if (do_popup) gtk_combo_box_popup (combo_box); else gtk_combo_box_popdown (combo_box); return FALSE; }
/* PUBLIC FUNCS */ static void ensure_tooltip (AwnTooltip *tooltip) { AwnTooltipPrivate *priv = tooltip->priv; gchar *normal = NULL; GdkColor clr; gchar *color = NULL; gchar *markup = NULL; if (priv->text == NULL || priv->font_color == NULL) { return; } normal = g_markup_escape_text (priv->text, -1); desktop_agnostic_color_get_color (priv->font_color, &clr); color = gdk_color_to_string (&clr); markup = g_strdup_printf ("<span foreground='%s' font_desc='%s'>%s</span>", color, priv->font_name, normal); gtk_label_set_max_width_chars (GTK_LABEL (priv->label), 120); gtk_label_set_ellipsize (GTK_LABEL (priv->label), PANGO_ELLIPSIZE_END); gtk_label_set_markup (GTK_LABEL (priv->label), markup); g_free (normal); g_free (color); g_free (markup); if (gtk_widget_get_mapped (GTK_WIDGET (tooltip)) && GTK_IS_WIDGET (priv->focus)) { awn_tooltip_update_position (tooltip); } }
/** * gdl_dock_add_floating_item: * @dock: A #GdlDock widget * @item: A #GdlDockItem widget * @x: X coordinate of the floating item * @y: Y coordinate of the floating item * @width: width of the floating item * @height: height of the floating item * * Dock an item as a floating item. It creates a new window containing a new * dock widget sharing the same master where the item is docked. */ void gdl_dock_add_floating_item (GdlDock *dock, GdlDockItem *item, gint x, gint y, gint width, gint height) { GdlDock *new_dock; g_return_if_fail (dock != NULL); g_return_if_fail (item != NULL); new_dock = GDL_DOCK (g_object_new (GDL_TYPE_DOCK, "master", gdl_dock_object_get_master (GDL_DOCK_OBJECT (dock)), "floating", TRUE, "width", width, "height", height, "floatx", x, "floaty", y, "skip-taskbar", dock->priv->skip_taskbar, NULL)); if (gtk_widget_get_visible (GTK_WIDGET (dock))) { gtk_widget_show (GTK_WIDGET (new_dock)); if (gtk_widget_get_mapped (GTK_WIDGET (dock))) gtk_widget_map (GTK_WIDGET (new_dock)); /* Make the widget resize. */ gtk_widget_queue_resize (GTK_WIDGET (new_dock)); } gdl_dock_add_item (GDL_DOCK (new_dock), item, GDL_DOCK_TOP); }
void create_input_dialog () { static GtkWidget *inputd = NULL; if (!inputd) { inputd = gtk_input_dialog_new(); g_signal_connect (inputd, "destroy", G_CALLBACK (input_dialog_destroy), (gpointer) &inputd); g_signal_connect_swapped (GTK_INPUT_DIALOG (inputd)->close_button, "clicked", G_CALLBACK (gtk_widget_hide), inputd); gtk_widget_hide (GTK_INPUT_DIALOG (inputd)->save_button); gtk_widget_show (inputd); } else { if (!gtk_widget_get_mapped (inputd)) gtk_widget_show (inputd); else gdk_window_raise (inputd->window); } }
static void menu_item_style_set (GtkImage *image, gpointer data) { GtkWidget *widget; GdkPixbuf *pixbuf; GtkIconSize icon_size = (GtkIconSize) GPOINTER_TO_INT (data); int icon_height; gboolean is_mapped; if (!gtk_icon_size_lookup (icon_size, NULL, &icon_height)) return; pixbuf = gtk_image_get_pixbuf (image); if (!pixbuf) return; if (gdk_pixbuf_get_height (pixbuf) == icon_height) return; widget = GTK_WIDGET (image); is_mapped = gtk_widget_get_mapped (widget); if (is_mapped) gtk_widget_unmap (widget); gtk_image_set_from_pixbuf (image, NULL); if (is_mapped) gtk_widget_map (widget); }
static gboolean gd_stack_transition_cb (GdStack *stack, GdkFrameClock *frame_clock, gpointer user_data) { GdStackPrivate *priv = stack->priv; gint64 now; gdouble t; now = gdk_frame_clock_get_frame_time (frame_clock); t = 1.0; if (now < priv->end_time) t = (now - priv->start_time) / (double) (priv->end_time - priv->start_time); /* Finish animation early if not mapped anymore */ if (!gtk_widget_get_mapped (GTK_WIDGET (stack))) t = 1.0; if (gd_stack_set_transition_position (stack, t)) { gtk_widget_set_opacity (GTK_WIDGET (stack), 1.0); priv->tick_id = 0; return FALSE; } return TRUE; }
static void gtk_revealer_start_animation (GtkRevealer *revealer, gdouble target) { GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer); GtkWidget *widget = GTK_WIDGET (revealer); GtkRevealerTransitionType transition; if (priv->target_pos == target) return; priv->target_pos = target; g_object_notify (G_OBJECT (revealer), "reveal-child"); transition = effective_transition (revealer); if (gtk_widget_get_mapped (widget) && priv->transition_duration != 0 && transition != GTK_REVEALER_TRANSITION_TYPE_NONE) { priv->source_pos = priv->current_pos; priv->start_time = gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (widget)); priv->end_time = priv->start_time + (priv->transition_duration * 1000); if (priv->tick_id == 0) priv->tick_id = gtk_widget_add_tick_callback (widget, (GtkTickCallback)gtk_revealer_animate_cb, revealer, NULL); gtk_revealer_animate_step (revealer, priv->start_time); } else { gtk_revealer_set_position (revealer, target); } }
static void gd_stack_start_transition (GdStack *stack) { GdStackPrivate *priv = stack->priv; GtkWidget *widget = GTK_WIDGET (stack); gboolean animations_enabled; g_object_get (gtk_widget_get_settings (widget), "gtk-enable-animations", &animations_enabled, NULL); if (gtk_widget_get_mapped (widget) && animations_enabled && priv->transition_type != GD_STACK_TRANSITION_TYPE_NONE && priv->last_visible_child != NULL) { gtk_widget_set_opacity (widget, 0.999); priv->transition_pos = 0.0; priv->start_time = gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (widget)); priv->end_time = priv->start_time + (priv->transition_duration * 1000); gd_stack_schedule_ticks (stack); } else { gd_stack_unschedule_ticks (stack); gd_stack_set_transition_position (stack, 1.0); } }
static gboolean gtk_menu_item_accessible_do_action (AtkAction *action, gint i) { GtkWidget *item, *item_parent; gboolean item_mapped; item = gtk_accessible_get_widget (GTK_ACCESSIBLE (action)); if (item == NULL) return FALSE; if (i != 0) return FALSE; if (!gtk_widget_get_sensitive (item) || !gtk_widget_get_visible (item)) return FALSE; item_parent = gtk_widget_get_parent (item); if (!GTK_IS_MENU_SHELL (item_parent)) return FALSE; gtk_menu_shell_select_item (GTK_MENU_SHELL (item_parent), item); item_mapped = gtk_widget_get_mapped (item); /* This is what is called when <Return> is pressed for a menu item. * The last argument means 'force hide'. */ g_signal_emit_by_name (item_parent, "activate-current", 1); if (!item_mapped) ensure_menus_unposted (GTK_MENU_ITEM_ACCESSIBLE (action)); return TRUE; }
static gboolean idle_do_action (gpointer data) { GtkWidget *item; GtkWidget *item_parent; GailMenuItem *menu_item; gboolean item_mapped; menu_item = GAIL_MENU_ITEM (data); menu_item->action_idle_handler = 0; item = GTK_ACCESSIBLE (menu_item)->widget; if (item == NULL /* State is defunct */ || !gtk_widget_get_sensitive (item) || !gtk_widget_get_visible (item)) return FALSE; item_parent = gtk_widget_get_parent (item); gtk_menu_shell_select_item (GTK_MENU_SHELL (item_parent), item); item_mapped = gtk_widget_get_mapped (item); /* * This is what is called when <Return> is pressed for a menu item */ g_signal_emit_by_name (item_parent, "activate_current", /*force_hide*/ 1); if (!item_mapped) ensure_menus_unposted (menu_item); return FALSE; }
void moz_container_map (GtkWidget *widget) { MozContainer *container; GList *tmp_list; GtkWidget *tmp_child; g_return_if_fail (IS_MOZ_CONTAINER(widget)); container = MOZ_CONTAINER (widget); gtk_widget_set_mapped(widget, TRUE); tmp_list = container->children; while (tmp_list) { tmp_child = ((MozContainerChild *)tmp_list->data)->widget; if (gtk_widget_get_visible(tmp_child)) { if (!gtk_widget_get_mapped(tmp_child)) gtk_widget_map(tmp_child); } tmp_list = tmp_list->next; } gdk_window_show (gtk_widget_get_window(widget)); }
static gboolean gail_select_watcher (GSignalInvocationHint *ihint, guint n_param_values, const GValue *param_values, gpointer data) { GObject *object; GtkWidget *widget; object = g_value_get_object (param_values + 0); g_return_val_if_fail (GTK_IS_WIDGET(object), FALSE); widget = GTK_WIDGET (object); if (!gtk_widget_get_mapped (widget)) { g_signal_connect (widget, "map", G_CALLBACK (gail_map_cb), NULL); } else gail_finish_select (widget); return TRUE; }
void columns_add(Columns *cols, GtkWidget *child, gint colstart, gint colspan) { ColumnsChild *childdata; g_return_if_fail(cols != NULL); g_return_if_fail(IS_COLUMNS(cols)); g_return_if_fail(child != NULL); g_return_if_fail(gtk_widget_get_parent(child) == NULL); childdata = g_new(ColumnsChild, 1); childdata->widget = child; childdata->colstart = colstart; childdata->colspan = colspan; childdata->force_left = FALSE; childdata->same_height_as = NULL; cols->children = g_list_append(cols->children, childdata); cols->taborder = g_list_append(cols->taborder, child); gtk_widget_set_parent(child, GTK_WIDGET(cols)); #if GTK_CHECK_VERSION(2, 0, 0) gtk_container_set_focus_chain(GTK_CONTAINER(cols), cols->taborder); #endif if (gtk_widget_get_realized(GTK_WIDGET(cols))) gtk_widget_realize(child); if (gtk_widget_get_visible(GTK_WIDGET(cols)) && gtk_widget_get_visible(child)) { if (gtk_widget_get_mapped(GTK_WIDGET(cols))) gtk_widget_map(child); gtk_widget_queue_resize(child); } }
/** * gtk_tool_item_set_use_drag_window: * @tool_item: a #GtkToolItem * @use_drag_window: Whether @tool_item has a drag window. * * Sets whether @tool_item has a drag window. When %TRUE the * toolitem can be used as a drag source through gtk_drag_source_set(). * When @tool_item has a drag window it will intercept all events, * even those that would otherwise be sent to a child of @tool_item. * * Since: 2.4 **/ void gtk_tool_item_set_use_drag_window (GtkToolItem *toolitem, gboolean use_drag_window) { g_return_if_fail (GTK_IS_TOOL_ITEM (toolitem)); use_drag_window = use_drag_window != FALSE; if (toolitem->priv->use_drag_window != use_drag_window) { toolitem->priv->use_drag_window = use_drag_window; if (use_drag_window) { if (!toolitem->priv->drag_window && gtk_widget_get_realized (GTK_WIDGET (toolitem))) { create_drag_window(toolitem); if (gtk_widget_get_mapped (GTK_WIDGET (toolitem))) gdk_window_show (toolitem->priv->drag_window); } } else { destroy_drag_window (toolitem); } } }
static void exo_wrap_table_add (GtkContainer *container, GtkWidget *widget) { ExoWrapTable *table = EXO_WRAP_TABLE (container); /* take over ownership */ gtk_widget_set_parent (widget, GTK_WIDGET (table)); /* add the child to our internal list */ table->priv->children = g_list_append (table->priv->children, widget); /* realize the widget if required */ if (gtk_widget_get_realized (GTK_WIDGET (container))) gtk_widget_realize (widget); /* map the widget if required */ if (gtk_widget_get_visible (GTK_WIDGET (container)) && gtk_widget_get_visible (widget)) { if (gtk_widget_get_mapped (GTK_WIDGET (container))) gtk_widget_map (widget); } /* queue a resize on the table */ gtk_widget_queue_resize (GTK_WIDGET (container)); }
static void gail_window_real_initialize (AtkObject *obj, gpointer data) { GtkWidget *widget = GTK_WIDGET (data); GailWindow *window; /* * A GailWindow can be created for a GtkHandleBox or a GtkWindow */ if (!GTK_IS_WINDOW (widget) && !GTK_IS_HANDLE_BOX (widget)) gail_return_if_fail (FALSE); ATK_OBJECT_CLASS (gail_window_parent_class)->initialize (obj, data); window = GAIL_WINDOW (obj); window->name_change_handler = 0; window->previous_name = g_strdup (gtk_window_get_title (GTK_WINDOW (data))); g_signal_connect (data, "window_state_event", G_CALLBACK (gail_window_state_event_gtk), NULL); g_object_set_data (G_OBJECT (obj), "atk-component-layer", GINT_TO_POINTER (ATK_LAYER_WINDOW)); if (GTK_IS_FILE_SELECTION (widget)) obj->role = ATK_ROLE_FILE_CHOOSER; else if (GTK_IS_COLOR_SELECTION_DIALOG (widget)) obj->role = ATK_ROLE_COLOR_CHOOSER; else if (GTK_IS_FONT_SELECTION_DIALOG (widget)) obj->role = ATK_ROLE_FONT_CHOOSER; else if (GTK_IS_MESSAGE_DIALOG (widget)) obj->role = ATK_ROLE_ALERT; else if (GTK_IS_DIALOG (widget)) obj->role = ATK_ROLE_DIALOG; else { const gchar *name; name = gtk_widget_get_name (widget); if (name && (!strcmp (name, "gtk-tooltip") || !strcmp (name, "gtk-tooltips"))) obj->role = ATK_ROLE_TOOL_TIP; else if (GTK_IS_PLUG (widget)) obj->role = ATK_ROLE_PANEL; else if (GTK_WINDOW (widget)->type == GTK_WINDOW_POPUP) obj->role = ATK_ROLE_WINDOW; else obj->role = ATK_ROLE_FRAME; } /* * Notify that tooltip is showing */ if (obj->role == ATK_ROLE_TOOL_TIP && gtk_widget_get_mapped (widget)) atk_object_notify_state_change (obj, ATK_STATE_SHOWING, 1); }
void uim_cand_win_gtk_layout(UIMCandWinGtk *cwin, gint topwin_x, gint topwin_y, gint topwin_width, gint topwin_height) { GtkRequisition req; int x, y; int cursor_x, cursor_y; int sc_he, cw_he; /*screen height, candidate window height*/ int sc_wi, cw_wi; g_return_if_fail(UIM_IS_CAND_WIN_GTK(cwin)); #if GTK_CHECK_VERSION(3, 0, 0) gtk_widget_get_preferred_size(GTK_WIDGET(cwin), &req, NULL); #else gtk_widget_size_request(GTK_WIDGET(cwin), &req); #endif cw_wi = req.width; cw_he = req.height; sc_he = gdk_screen_get_height(gdk_screen_get_default ()); sc_wi = gdk_screen_get_width (gdk_screen_get_default ()); /* FIXME */ switch (cwin->position) { case UIM_CAND_WIN_POS_LEFT: cursor_x = 0; break; case UIM_CAND_WIN_POS_RIGHT: cursor_x = topwin_width - cw_wi; break; default: cursor_x = cwin->cursor.x; break; } cursor_y = cwin->cursor.y; if (sc_wi < topwin_x + cursor_x + cw_wi) { /* x = topwin_x + cursor_x - cw_wi; */ x = sc_wi - cw_wi; } else { x = topwin_x + cursor_x; } if (sc_he < topwin_y + cursor_y + cwin->cursor.height + cw_he) { y = topwin_y + cursor_y - cw_he; } else { y = topwin_y + cursor_y + cwin->cursor.height; } gtk_window_move(GTK_WINDOW(cwin), x, y); #if GTK_CHECK_VERSION(3, 7, 8) if (gtk_widget_get_mapped(cwin->view) && GTK_IS_TREE_VIEW(cwin->view)) gtk_widget_queue_resize_no_redraw(cwin->view); #endif uim_cand_win_gtk_layout_sub_window(cwin); }
/*most of this function stolen from the real gtk_menu_popup*/ static void restore_grabs(GtkWidget *w, gpointer data) { GtkWidget *menu_item = data; GtkMenu *menu = GTK_MENU (gtk_widget_get_parent (menu_item)); GtkWidget *xgrab_shell; GtkWidget *parent; /* Find the last viewable ancestor, and make an X grab on it */ parent = GTK_WIDGET (menu); xgrab_shell = NULL; while (parent) { gboolean viewable = TRUE; GtkWidget *tmp = parent; while (tmp) { if (!gtk_widget_get_mapped (tmp)) { viewable = FALSE; break; } tmp = gtk_widget_get_parent (tmp); } if (viewable) xgrab_shell = parent; #if GTK_CHECK_VERSION (3, 0, 0) parent = gtk_menu_shell_get_parent_shell (GTK_MENU_SHELL (parent)); #else parent = GTK_MENU_SHELL (parent)->parent_menu_shell; #endif } /*only grab if this HAD a grab before*/ /* FIXME fix for GTK3 */ #if !GTK_CHECK_VERSION (3, 0, 0) if (xgrab_shell && (GTK_MENU_SHELL (xgrab_shell)->have_xgrab)) { GdkWindow *window = gtk_widget_get_window (xgrab_shell); if (gdk_pointer_grab (window, TRUE, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK, NULL, NULL, 0) == 0) { if (gdk_keyboard_grab (window, TRUE, GDK_CURRENT_TIME) == 0) GTK_MENU_SHELL (xgrab_shell)->have_xgrab = TRUE; else gdk_pointer_ungrab (GDK_CURRENT_TIME); } } #endif gtk_grab_add (GTK_WIDGET (menu)); }
gboolean nsgtk_widget_get_mapped(GtkWidget *widget) { #if GTK_CHECK_VERSION(2,20,0) return gtk_widget_get_mapped(widget); #else return GTK_WIDGET_MAPPED(widget); #endif }
static void mud_subwindow_set_size_force_grid (MudSubwindow *window, VteTerminal *screen, gboolean even_if_mapped, int force_grid_width, int force_grid_height) { /* TODO: Missing get_padding in new VTE; maybe we can just use vte_terminal_set_size? */ #if 0 #warning Reimplement mud_subwindow size forcing /* Owen's hack from gnome-terminal */ GtkWidget *widget; GtkWidget *app; GtkRequisition toplevel_request; GtkRequisition widget_request; int w, h; int char_width; int char_height; int grid_width; int grid_height; int xpad; int ypad; g_return_if_fail(MUD_IS_SUBWINDOW(window)); /* be sure our geometry is up-to-date */ mud_subwindow_update_geometry (window); widget = GTK_WIDGET (screen); app = window->priv->window; gtk_widget_size_request (app, &toplevel_request); gtk_widget_size_request (widget, &widget_request); w = toplevel_request.width - widget_request.width; h = toplevel_request.height - widget_request.height; char_width = vte_terminal_get_char_width (screen); char_height = vte_terminal_get_char_height (screen); grid_width = vte_terminal_get_column_count (screen); grid_height = vte_terminal_get_row_count (screen); if (force_grid_width >= 0) grid_width = force_grid_width; if (force_grid_height >= 0) grid_height = force_grid_height; vte_terminal_get_padding (VTE_TERMINAL (screen), &xpad, &ypad); w += xpad * 2 + char_width * grid_width; h += ypad * 2 + char_height * grid_height; if (even_if_mapped && gtk_widget_get_mapped (app)) { gtk_window_resize (GTK_WINDOW (app), w, h); } }
static void gth_media_viewer_page_real_focus (GthViewerPage *base) { GtkWidget *widget; widget = GTH_MEDIA_VIEWER_PAGE (base)->priv->area; if (gtk_widget_get_realized (widget) && gtk_widget_get_mapped (widget)) gtk_widget_grab_focus (widget); }
void gs_grab_focus_when_mapped (GtkWidget *widget) { if (gtk_widget_get_mapped (widget)) gtk_widget_grab_focus (widget); else g_signal_connect_after (widget, "map", G_CALLBACK (grab_focus), NULL); }
// set the window hints information void window_resizable(GtkWidget *window, GtkWidget *vte, gint set_hints_inc) { #ifdef DEFENSIVE if ((window==NULL) || (vte==NULL)) return; #endif #ifdef DETAIL g_debug("! Launch window_resizable() with window = %p, vte = %p, set_hints_inc = %d", window, vte, set_hints_inc); #endif // DIRTY HACK: don't run window_resizable too much times before window is shown! if ((set_hints_inc != 1) && (gtk_widget_get_mapped(window) == FALSE)) return; // vte=NULL when creating a new root window with drag & drop. // if (vte==NULL) return; GdkGeometry hints = {0}; // g_debug("Trying to get padding..."); vte_terminal_get_padding (VTE_TERMINAL(vte), &(hints.base_width), &(hints.base_height)); // g_debug("hints.base_width = %d, hints.base_height = %d", hints.base_width, hints.base_height); switch (set_hints_inc) { case 1: hints.width_inc = vte_terminal_get_char_width(VTE_TERMINAL(vte)); hints.height_inc = vte_terminal_get_char_height(VTE_TERMINAL(vte)); break; case 2: hints.width_inc = 1; hints.height_inc = 1; break; } // g_debug("hints.width_inc = %d, hints.height_inc = %d", // hints.width_inc, hints.height_inc); // // minsize = -1: the size of vte can NOT be changed. // if (minsize == -1) // { // hints.min_width = minsize; // hints.min_height = minsize; // } // else // { hints.min_width = hints.base_width + hints.width_inc; hints.min_height = hints.base_height + hints.height_inc; // } // g_debug("Tring to set geometry on %p, and set_hints_inc = %d", vte, set_hints_inc); gtk_window_set_geometry_hints (GTK_WINDOW (window), GTK_WIDGET (vte), &hints, GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE); //g_debug("current the size of vte %p whith hinting = %ld x %ld", // vte, // vte_terminal_get_column_count(VTE_TERMINAL(vte)), // vte_terminal_get_row_count(VTE_TERMINAL(vte))); }
static void na_tray_child_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { NaTrayChild *child = NA_TRAY_CHILD (widget); GtkAllocation widget_allocation; gboolean moved, resized; gtk_widget_get_allocation (widget, &widget_allocation); moved = (allocation->x != widget_allocation.x || allocation->y != widget_allocation.y); resized = (allocation->width != widget_allocation.width || allocation->height != widget_allocation.height); /* When we are allocating the widget while mapped we need special handling * for both real and fake transparency. * * Real transparency: we need to invalidate and trigger a redraw of the old * and new areas. (GDK really should handle this for us, but doesn't as of * GTK+-2.14) * * Fake transparency: if the widget moved, we need to force the contents to * be redrawn with the new offset for the parent-relative background. */ if ((moved || resized) && gtk_widget_get_mapped (widget)) { if (na_tray_child_has_alpha (child)) gdk_window_invalidate_rect (gdk_window_get_parent (gtk_widget_get_window (widget)), &widget_allocation, FALSE); } GTK_WIDGET_CLASS (na_tray_child_parent_class)->size_allocate (widget, allocation); if ((moved || resized) && gtk_widget_get_mapped (widget)) { if (na_tray_child_has_alpha (NA_TRAY_CHILD (widget))) gdk_window_invalidate_rect (gdk_window_get_parent (gtk_widget_get_window (widget)), &widget_allocation, FALSE); else if (moved && child->parent_relative_bg) na_tray_child_force_redraw (child); } }
void ags_indicator_map(GtkWidget *widget) { if (gtk_widget_get_realized (widget) && !gtk_widget_get_mapped (widget)) { GTK_WIDGET_CLASS (ags_indicator_parent_class)->map(widget); gdk_window_show(widget->window); // ags_indicator_draw(widget); } }
/* Translate GtkWidget mapped state into AtkObject showing */ static gint map_cb (GtkWidget *widget) { AtkObject *accessible; accessible = gtk_widget_get_accessible (widget); atk_object_notify_state_change (accessible, ATK_STATE_SHOWING, gtk_widget_get_mapped (widget)); return 1; }
/* If we are faking transparency with a window-relative background, force a * redraw of the icon. This should be called if the background changes or if * the child is shifted with respect to the background. */ void na_tray_child_force_redraw (NaTrayChild *child) { GtkWidget *widget = GTK_WIDGET (child); if (gtk_widget_get_mapped (widget) && child->parent_relative_bg) { #if 1 /* Sending an ExposeEvent might cause redraw problems if the * icon is expecting the server to clear-to-background before * the redraw. It should be ok for GtkStatusIcon or EggTrayIcon. */ Display *xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (widget)); XEvent xev; GdkWindow *plug_window; GtkAllocation allocation; plug_window = gtk_socket_get_plug_window (GTK_SOCKET (child)); gtk_widget_get_allocation (widget, &allocation); xev.xexpose.type = Expose; #if GTK_CHECK_VERSION (3, 0, 0) xev.xexpose.window = GDK_WINDOW_XID (plug_window); #else xev.xexpose.window = GDK_WINDOW_XWINDOW (plug_window); #endif xev.xexpose.x = 0; xev.xexpose.y = 0; xev.xexpose.width = allocation.width; xev.xexpose.height = allocation.height; xev.xexpose.count = 0; gdk_error_trap_push (); XSendEvent (GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (widget)), xev.xexpose.window, False, ExposureMask, &xev); /* We have to sync to reliably catch errors from the XSendEvent(), * since that is asynchronous. */ XSync (xdisplay, False); #if GTK_CHECK_VERSION (3, 0, 0) gdk_error_trap_pop_ignored (); #else gdk_error_trap_pop (); #endif #else /* Hiding and showing is the safe way to do it, but can result in more * flickering. */ gdk_window_hide (widget->window); gdk_window_show (widget->window); #endif } }
static void change_direction (GtkRevealer *revealer) { if (gtk_widget_get_mapped (GTK_WIDGET (revealer))) { gboolean revealed; revealed = gtk_revealer_get_child_revealed (revealer); gtk_revealer_set_reveal_child (revealer, !revealed); } }
static void panel_frame_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { PanelFrame *frame = (PanelFrame *) widget; GtkBin *bin = (GtkBin *) widget; GtkStyleContext *context; GtkBorder padding; GtkAllocation child_allocation; GtkAllocation child_allocation_current; GtkWidget *child; int border_width; gtk_widget_set_allocation (widget, allocation); context = gtk_widget_get_style_context (widget); gtk_style_context_get_padding (context, gtk_widget_get_state_flags (widget), &padding); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); child_allocation.x = allocation->x + border_width; child_allocation.y = allocation->y + border_width; child_allocation.width = allocation->width - 2 * border_width; child_allocation.height = allocation->height - 2 * border_width; if (frame->edges & PANEL_EDGE_LEFT) { child_allocation.x += padding.left; child_allocation.width -= padding.left; } if (frame->edges & PANEL_EDGE_TOP) { child_allocation.y += padding.top; child_allocation.height -= padding.top; } if (frame->edges & PANEL_EDGE_RIGHT) child_allocation.width -= padding.left; if (frame->edges & PANEL_EDGE_BOTTOM) child_allocation.height -= padding.top; child = gtk_bin_get_child (bin); gtk_widget_get_allocation (child, &child_allocation_current); if (gtk_widget_get_mapped (widget) && (child_allocation.x != child_allocation_current.x || child_allocation.y != child_allocation_current.y || child_allocation.width != child_allocation_current.width || child_allocation.height != child_allocation_current.height)) gdk_window_invalidate_rect (gtk_widget_get_window (widget), allocation, FALSE); if (child && gtk_widget_get_visible (child)) gtk_widget_size_allocate (child, &child_allocation); }