static void icon_released (GtkEntry *entry, GtkEntryIconPosition pos, GdkEvent *event, gpointer user_data) { GtkSettings *settings; gint timeout; settings = gtk_widget_get_settings (GTK_WIDGET (entry)); g_object_get (settings, "gtk-tooltip-timeout", &timeout, NULL); g_object_set (settings, "gtk-tooltip-timeout", 1, NULL); gtk_tooltip_trigger_tooltip_query (gtk_widget_get_display (GTK_WIDGET (entry))); g_object_set (settings, "gtk-tooltip-timeout", timeout, NULL); }
void _gtk_tooltip_hide (GtkWidget *widget) { GdkDisplay *display; GtkTooltip *tooltip; display = gtk_widget_get_display (widget); tooltip = g_object_get_data (G_OBJECT (display), "gdk-display-current-tooltip"); if (!tooltip || !GTK_TOOLTIP_VISIBLE (tooltip) || !tooltip->tooltip_widget) return; if (widget == tooltip->tooltip_widget) gtk_tooltip_hide_tooltip (tooltip); }
gboolean show_tooltip_now (GtkWidget *widget, GdkEvent *event) { GtkSettings *settings; gint timeout; settings = gtk_widget_get_settings (widget); g_object_get (settings, "gtk-tooltip-timeout", &timeout, NULL); g_object_set (settings, "gtk-tooltip-timeout", 1, NULL); gtk_tooltip_trigger_tooltip_query (gtk_widget_get_display (widget)); g_object_set (settings, "gtk-tooltip-timeout", timeout, NULL); return FALSE; }
/** * na_tray_child_get_wm_class; * @child: a #NaTrayChild * @res_name: return location for a string containing the application name of * @child, or %NULL * @res_class: return location for a string containing the application class of * @child, or %NULL * * Fetches the resource associated with @child. */ void na_tray_child_get_wm_class (NaTrayChild *child, char **res_name, char **res_class) { GdkDisplay *display; g_return_if_fail (NA_IS_TRAY_CHILD (child)); display = gtk_widget_get_display (GTK_WIDGET (child)); _get_wmclass (GDK_DISPLAY_XDISPLAY (display), child->icon_window, res_class, res_name); }
static gint tooltip_browse_mode_expired (gpointer data) { GtkTooltip *tooltip; tooltip = GTK_TOOLTIP (data); tooltip->browse_mode_enabled = FALSE; tooltip->browse_mode_timeout_id = 0; /* destroy tooltip */ g_object_set_data (G_OBJECT (gtk_widget_get_display (tooltip->window)), "gdk-display-current-tooltip", NULL); return FALSE; }
static void egg_tray_icon_manager_window_destroyed (EggTrayIcon *icon) { GdkWindow *gdkwin; g_return_if_fail (icon->manager_window != None); gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)), icon->manager_window); gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon); icon->manager_window = None; egg_tray_icon_update_manager_window (icon, TRUE); }
static void gdl_dock_item_grip_realize (GtkWidget *widget) { GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (widget); GTK_WIDGET_CLASS (parent_class)->realize (widget); if (!grip->title_window) { GdkWindowAttr attributes; GdkRectangle area; GdkCursor *cursor; ensure_title_and_icon_pixbuf (grip); gdl_dock_item_grip_get_title_area (grip, &area); attributes.x = area.x; attributes.y = area.y; attributes.width = area.width; attributes.height = area.height; attributes.window_type = GDK_WINDOW_TEMP; attributes.wclass = GDK_INPUT_ONLY; attributes.override_redirect = TRUE; attributes.event_mask = (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_MOTION_MASK | gtk_widget_get_events (widget)); grip->title_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, (GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR)); gdk_window_set_user_data (grip->title_window, widget); if (GDL_DOCK_ITEM_CANT_CLOSE (grip->item)) cursor = NULL; else if (GDL_DOCK_ITEM_CANT_ICONIFY (grip->item)) cursor = NULL; else cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), GDK_HAND2); gdk_window_set_cursor (grip->title_window, cursor); if (cursor) gdk_cursor_unref (cursor); } }
static void point_press (PointState *point, GtkWidget *widget, guint button) { GdkDisplay *display; GdkDevice *device; GdkSeat *seat; GdkEvent *ev; display = gtk_widget_get_display (widget); seat = gdk_display_get_default_seat (display); device = gdk_seat_get_pointer (seat); if (point == &mouse_state) { ev = gdk_event_new (GDK_BUTTON_PRESS); ev->any.window = g_object_ref (gtk_widget_get_window (widget)); ev->button.time = GDK_CURRENT_TIME; ev->button.x = point->x; ev->button.y = point->y; ev->button.button = button; ev->button.state = point->state; point->state |= GDK_BUTTON1_MASK << (button - 1); } else { ev = gdk_event_new (GDK_TOUCH_BEGIN); ev->any.window = g_object_ref (gtk_widget_get_window (widget)); ev->touch.time = GDK_CURRENT_TIME; ev->touch.x = point->x; ev->touch.y = point->y; ev->touch.sequence = EVENT_SEQUENCE (point); if (point == &touch_state[0]) ev->touch.emulating_pointer = TRUE; } gdk_event_set_device (ev, device); gtk_main_do_event (ev); gdk_event_free (ev); point->widget = widget; }
gboolean gimp_display_shell_pointer_grab (GimpDisplayShell *shell, const GdkEvent *event, GdkEventMask event_mask) { GdkGrabStatus status; g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE); g_return_val_if_fail (event != NULL, FALSE); g_return_val_if_fail (shell->pointer_grabbed == FALSE, FALSE); status = gdk_pointer_grab (gtk_widget_get_window (shell->canvas), FALSE, event_mask, NULL, NULL, gdk_event_get_time (event)); if (status == GDK_GRAB_SUCCESS) { shell->pointer_grabbed = TRUE; return TRUE; } else if (status == GDK_GRAB_ALREADY_GRABBED) { GimpDeviceManager *manager; GdkDisplay *gdk_display; manager = gimp_devices_get_manager (shell->display->gimp); gdk_display = gtk_widget_get_display (GTK_WIDGET (shell)); /* EEK: trying to grab an extended device always returns * ALREADY_GRABBED, so simply assume the grab succeeded anyway */ if (gimp_device_manager_get_current_device (manager)->device != gdk_display_get_core_pointer (gdk_display)) { shell->pointer_grabbed = TRUE; return TRUE; } } g_printerr ("%s: gdk_pointer_grab failed with status %d\n", G_STRFUNC, status); return FALSE; }
static bool HasClientDecor(GtkWidget* widget) { GdkDisplay* display = gtk_widget_get_display(widget); #ifdef GDK_WINDOWING_WAYLAND if (GDK_IS_WAYLAND_DISPLAY(display)) return true; #endif #ifdef GDK_WINDOWING_MIR if (GDK_IS_MIR_DISPLAY(display)) return true; #endif #ifdef GDK_WINDOWING_BROADWAY if (GDK_IS_BROADWAY_DISPLAY(display)) return true; #endif return false; }
/********************************************************************\ * gnc_window_adjust_for_screen * * adjust the window size if it is bigger than the screen size. * * * * Args: window - the window to adjust * * Returns: nothing * \********************************************************************/ void gnc_window_adjust_for_screen(GtkWindow * window) { #if GTK_CHECK_VERSION(3,22,0) GdkWindow *win; GdkMonitor *mon; GdkRectangle monitor_size; #endif gint screen_width; gint screen_height; gint width; gint height; if (window == NULL) return; g_return_if_fail(GTK_IS_WINDOW(window)); if (gtk_widget_get_window (GTK_WIDGET(window)) == NULL) return; #if GTK_CHECK_VERSION(3,22,0) win = gdk_screen_get_root_window (gtk_window_get_screen (window)); mon = gdk_display_get_monitor_at_window (gtk_widget_get_display (GTK_WIDGET(window)), win); gdk_monitor_get_geometry (mon, &monitor_size); screen_width = monitor_size.width; screen_height = monitor_size.height; #else screen_width = gdk_screen_width(); screen_height = gdk_screen_height(); #endif width = gdk_window_get_width (gtk_widget_get_window (GTK_WIDGET(window))); height = gdk_window_get_height (gtk_widget_get_window (GTK_WIDGET(window))); if ((width <= screen_width) && (height <= screen_height)) return; width = MIN(width, screen_width - 10); width = MAX(width, 0); height = MIN(height, screen_height - 10); height = MAX(height, 0); gdk_window_resize(gtk_widget_get_window (GTK_WIDGET(window)), width, height); gtk_widget_queue_resize(GTK_WIDGET(window)); }
/* Sets dialog busy state according to busy * * When busy: * Sets the cursor to busy * Disables the interface to prevent that the user interferes * Reverts all this when non-busy * * Note that this function takes into account the * authentication state of the dialog. So setting the * dialog to busy and then back to normal should leave * the dialog unchanged. */ static void passdlg_set_busy (PasswordDialog *pdialog, gboolean busy) { GtkBuilder *dialog; GtkWidget *toplevel; GdkCursor *cursor = NULL; GdkDisplay *display; dialog = pdialog->ui; /* Set cursor */ toplevel = WID ("change-password"); display = gtk_widget_get_display (toplevel); if (busy) { cursor = gdk_cursor_new_for_display (display, GDK_WATCH); } gdk_window_set_cursor (gtk_widget_get_window (toplevel), cursor); gdk_display_flush (display); if (busy) { gdk_cursor_unref (cursor); } /* Disable/Enable UI */ if (pdialog->authenticated) { /* Authenticated state */ /* Enable/disable new password section */ g_object_set (pdialog->new_password, "sensitive", !busy, NULL); g_object_set (pdialog->retyped_password, "sensitive", !busy, NULL); g_object_set (WID ("new-password-label"), "sensitive", !busy, NULL); g_object_set (WID ("retyped-password-label"), "sensitive", !busy, NULL); /* Enable/disable change password button */ g_object_set (WID ("change-password-button"), "sensitive", !busy, NULL); } else { /* Not-authenticated state */ /* Enable/disable auth section state */ g_object_set (pdialog->current_password, "sensitive", !busy, NULL); g_object_set (WID ("authenticate-button"), "sensitive", !busy, NULL); g_object_set (WID ("current-password-label"), "sensitive", !busy, NULL); } }
static void lsv_copy_activated(GSimpleAction * action, GVariant * parameter, gpointer user_data) { LibBalsaSourceViewerInfo *lsvi = g_object_get_data(G_OBJECT(user_data), "lsvi"); GtkTextView *text = GTK_TEXT_VIEW(lsvi->text); GtkTextBuffer *buffer = gtk_text_view_get_buffer(text); GdkDisplay *display; GtkClipboard *clipboard; display = gtk_widget_get_display(GTK_WIDGET(text)); clipboard = gtk_clipboard_get_for_display(display, GDK_NONE); gtk_text_buffer_copy_clipboard(buffer, clipboard); }
static void layer_select_destroy (LayerSelect *layer_select, guint32 time) { gdk_display_keyboard_ungrab (gtk_widget_get_display (layer_select->window), time); gtk_widget_destroy (layer_select->window); if (layer_select->orig_layer != gimp_image_get_active_layer (layer_select->image)) { gimp_image_flush (layer_select->image); } g_slice_free (LayerSelect, layer_select); }
static gboolean gimp_context_help_key_press (GtkWidget *widget, GdkEventKey *kevent, gpointer data) { if (kevent->keyval == GDK_KEY_Escape) { GdkDisplay *display = gtk_widget_get_display (widget); gtk_grab_remove (widget); gdk_display_keyboard_ungrab (display, kevent->time); gdk_display_pointer_ungrab (display, kevent->time); gtk_widget_destroy (widget); } return TRUE; }
void gtk_inspector_window_select_widget_under_pointer (GtkInspectorWindow *iw) { GdkDisplay *display; GdkDeviceManager *dm; GdkDevice *device; GtkWidget *widget; display = gtk_widget_get_display (GTK_WIDGET (iw)); dm = gdk_display_get_device_manager (display); device = gdk_device_manager_get_client_pointer (dm); widget = find_widget_at_pointer (device); if (widget) select_widget (iw, widget); }
static gint tooltip_browse_mode_expired (gpointer data) { GtkTooltip *tooltip; GdkDisplay *display; tooltip = GTK_TOOLTIP (data); tooltip->browse_mode_enabled = FALSE; tooltip->browse_mode_timeout_id = 0; /* destroy tooltip */ display = gtk_widget_get_display (tooltip->window); g_object_set_qdata (G_OBJECT (display), quark_current_tooltip, NULL); return FALSE; }
/* taken from gtk/gtktreeview.c */ static void send_focus_change (GtkWidget *widget, GdkDevice *device, gboolean in) { GdkDeviceManager *device_manager; GList *devices, *d; device_manager = gdk_display_get_device_manager (gtk_widget_get_display (widget)); devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER); devices = g_list_concat (devices, gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_SLAVE)); devices = g_list_concat (devices, gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_FLOATING)); for (d = devices; d; d = d->next) { GdkDevice *dev = d->data; GdkEvent *fevent; GdkWindow *window; if (gdk_device_get_source (dev) != GDK_SOURCE_KEYBOARD) continue; window = gtk_widget_get_window (widget); /* Skip non-master keyboards that haven't * selected for events from this window */ if (gdk_device_get_device_type (dev) != GDK_DEVICE_TYPE_MASTER && !gdk_window_get_device_events (window, dev)) continue; fevent = gdk_event_new (GDK_FOCUS_CHANGE); fevent->focus_change.type = GDK_FOCUS_CHANGE; fevent->focus_change.window = g_object_ref (window); fevent->focus_change.in = in; gdk_event_set_device (fevent, device); gtk_widget_send_focus_change (widget, fevent); gdk_event_free (fevent); } g_list_free (devices); }
static void egg_tray_icon_update_manager_window (EggTrayIcon *icon, gboolean dock_if_realized) { Display *xdisplay; if (icon->manager_window != None) return; xdisplay = egg_tray_icon_get_x_display(icon); if (xdisplay == NULL) return; XGrabServer (xdisplay); icon->manager_window = XGetSelectionOwner (xdisplay, icon->selection_atom); if (icon->manager_window != None) XSelectInput (xdisplay, icon->manager_window, StructureNotifyMask|PropertyChangeMask); XUngrabServer (xdisplay); XFlush (xdisplay); if (icon->manager_window != None) { GdkWindow *gdkwin; #if GTK_CHECK_VERSION(2,1,0) gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)), icon->manager_window); #else gdkwin = gdk_window_lookup (icon->manager_window); #endif gdk_window_add_filter (gdkwin, egg_tray_icon_manager_filter, icon); if (dock_if_realized && GTK_WIDGET_REALIZED (icon)) egg_tray_icon_send_dock_request (icon); egg_tray_icon_get_orientation_property (icon); } }
cairo_surface_t* RedirectedXCompositeWindow::cairoSurfaceForWidget(GtkWidget* widget) { if (!m_needsNewPixmapAfterResize && m_surface) return m_surface.get(); m_needsNewPixmapAfterResize = false; // It's important that the new pixmap be created with the same Display pointer as the target // widget or else drawing speed can be 100x slower. Display* newPixmapDisplay = GDK_DISPLAY_XDISPLAY(gtk_widget_get_display(widget)); Pixmap newPixmap = XCompositeNameWindowPixmap(newPixmapDisplay, m_window); if (!newPixmap) { cleanupPixmapAndPixmapSurface(); return 0; } XWindowAttributes windowAttributes; if (!XGetWindowAttributes(newPixmapDisplay, m_window, &windowAttributes)) { cleanupPixmapAndPixmapSurface(); XFreePixmap(newPixmapDisplay, newPixmap); return 0; } RefPtr<cairo_surface_t> newSurface = adoptRef(cairo_xlib_surface_create(newPixmapDisplay, newPixmap, windowAttributes.visual, m_size.width(), m_size.height())); // Nvidia drivers seem to prepare their redirected window pixmap asynchronously, so for a few fractions // of a second after each resize, while doing continuous resizing (which constantly destroys and creates // pixmap window-backings), the pixmap memory is uninitialized. To work around this issue, paint the old // pixmap to the new one to properly initialize it. if (m_surface) { RefPtr<cairo_t> cr = adoptRef(cairo_create(newSurface.get())); cairo_set_source_rgb(cr.get(), 1, 1, 1); cairo_paint(cr.get()); cairo_set_source_surface(cr.get(), m_surface.get(), 0, 0); cairo_paint(cr.get()); } cleanupPixmapAndPixmapSurface(); m_pixmap = newPixmap; m_surface = newSurface; return m_surface.get(); }
static void shell_tray_icon_constructed (GObject *object) { GdkWindow *icon_app_window; ShellTrayIcon *icon = SHELL_TRAY_ICON (object); ShellEmbeddedWindow *window; GdkDisplay *display; Window plug_xid; Atom _NET_WM_PID, type; int result, format; gulong nitems, bytes_after, *val = NULL; /* We do all this now rather than computing it on the fly later, * because the shell may want to see their values from a * tray-icon-removed signal handler, at which point the plug has * already been removed from the socket. */ g_object_get (object, "window", &window, NULL); g_return_if_fail (window != NULL); icon->priv->socket = NA_TRAY_CHILD (gtk_bin_get_child (GTK_BIN (window))); g_object_unref (window); icon->priv->title = na_tray_child_get_title (icon->priv->socket); na_tray_child_get_wm_class (icon->priv->socket, NULL, &icon->priv->wm_class); icon_app_window = gtk_socket_get_plug_window (GTK_SOCKET (icon->priv->socket)); plug_xid = GDK_WINDOW_XID (icon_app_window); display = gtk_widget_get_display (GTK_WIDGET (icon->priv->socket)); gdk_error_trap_push (); _NET_WM_PID = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PID"); result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), plug_xid, _NET_WM_PID, 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems, &bytes_after, (guchar **)&val); if (!gdk_error_trap_pop () && result == Success && type == XA_CARDINAL && nitems == 1) icon->priv->pid = *val; if (val) XFree (val); }
GtkWidget * create_glarea_window (GtkWidget *do_widget) { GtkWidget *window, *box, *button, *controls; int i; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget)); gtk_window_set_title (GTK_WINDOW (window), "OpenGL Area"); gtk_window_set_default_size (GTK_WINDOW (window), 400, 600); g_signal_connect (window, "destroy", G_CALLBACK (close_window), NULL); box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE); g_object_set (box, "margin", 12, NULL); gtk_box_set_spacing (GTK_BOX (box), 6); gtk_container_add (GTK_CONTAINER (window), box); gl_area = gtk_gl_area_new (); gtk_widget_set_hexpand (gl_area, TRUE); gtk_widget_set_vexpand (gl_area, TRUE); gtk_container_add (GTK_CONTAINER (box), gl_area); /* We need to initialize and free GL resources, so we use * the realize and unrealize signals on the widget */ g_signal_connect (gl_area, "realize", G_CALLBACK (realize), NULL); g_signal_connect (gl_area, "unrealize", G_CALLBACK (unrealize), NULL); /* The main "draw" call for GtkGLArea */ g_signal_connect (gl_area, "render", G_CALLBACK (render), NULL); controls = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE); gtk_container_add (GTK_CONTAINER (box), controls); gtk_widget_set_hexpand (controls, TRUE); for (i = 0; i < N_AXIS; i++) gtk_container_add (GTK_CONTAINER (controls), create_axis_slider (i)); button = gtk_button_new_with_label ("Quit"); gtk_widget_set_hexpand (button, TRUE); gtk_container_add (GTK_CONTAINER (box), button); g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window); return window; }
static void lookup_start_cb (GdictContext *context, gpointer user_data) { GdictSpeller *speller = GDICT_SPELLER (user_data); GdictSpellerPrivate *priv = speller->priv; if (!priv->busy_cursor) { GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (speller)); priv->busy_cursor = gdk_cursor_new_for_display (display, GDK_WATCH); } if (gtk_widget_get_window (GTK_WIDGET (speller))) gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (speller)), priv->busy_cursor); priv->is_searching = TRUE; }
static gboolean on_widget_button_release (GtkWidget *widget, GdkEventButton *event, char *item_id) { g_print ("%s received 'button-release' signal\n", item_id); if (strstr (item_id, "explicit")) { GdkDisplay *display; display = gtk_widget_get_display (widget); gdk_display_pointer_ungrab (display, event->time); g_print ("released pointer grab\n"); } return TRUE; }
static void video_area_realize_cb (GtkWidget *widget, gpointer user_data) { GthMediaViewerPage *self = user_data; self->priv->video_window_xid = GDK_WINDOW_XID (gtk_widget_get_window (widget)); self->priv->cursor = gdk_cursor_new (GDK_LEFT_PTR); self->priv->cursor_void = gdk_cursor_new_for_display (gtk_widget_get_display (self->priv->area), GDK_BLANK_CURSOR); if (self->priv->cursor_visible) gdk_window_set_cursor (gtk_widget_get_window (self->priv->area), self->priv->cursor); else gdk_window_set_cursor (gtk_widget_get_window (self->priv->area), self->priv->cursor_void); self->priv->caption_layout = gtk_widget_create_pango_layout (widget, ""); pango_layout_set_alignment (self->priv->caption_layout, PANGO_ALIGN_CENTER); _gth_media_viewer_page_update_caption (self); }
static void screenshot_dialog_response_cb (GtkDialog *d, gint response_id, ScreenshotDialog *dialog) { char *uri; if (response_id == GTK_RESPONSE_HELP) { display_help (GTK_WINDOW (d)); } else if (response_id == GTK_RESPONSE_OK) { uri = screenshot_dialog_get_uri (dialog); if (temporary_file == NULL) { save_immediately = TRUE; screenshot_dialog_set_busy (dialog, TRUE); } else { /* we've saved the temporary file, lets try to copy it to the * correct location. */ try_to_save (dialog, uri); } g_free (uri); } else if (response_id == SCREENSHOT_RESPONSE_COPY) { GtkClipboard *clipboard; GdkPixbuf *screenshot; clipboard = gtk_clipboard_get_for_display (gtk_widget_get_display (GTK_WIDGET (d)), GDK_SELECTION_CLIPBOARD); screenshot = screenshot_dialog_get_screenshot (dialog); gtk_clipboard_set_image (clipboard, screenshot); } else /* dialog was canceled */ { gtk_widget_destroy (GTK_WIDGET (d)); gtk_main_quit (); } }
static void dialog_cb(GtkAction* action, AccessxStatusApplet* sapplet) { GError* error = NULL; GdkScreen *screen; GdkAppLaunchContext *launch_context; GAppInfo *appinfo; if (sapplet->error_type != ACCESSX_STATUS_ERROR_NONE) { popup_error_dialog(sapplet); return; } screen = gtk_widget_get_screen (GTK_WIDGET (sapplet->applet)); appinfo = g_app_info_create_from_commandline ("mate-keyboard-properties --a11y", _("Open the keyboard preferences dialog"), G_APP_INFO_CREATE_NONE, &error); if (!error) { launch_context = gdk_display_get_app_launch_context ( gtk_widget_get_display (GTK_WIDGET (screen))); gdk_app_launch_context_set_screen (launch_context, screen); g_app_info_launch (appinfo, NULL, G_APP_LAUNCH_CONTEXT (launch_context), &error); g_object_unref (launch_context); } if (error != NULL) { GtkWidget* dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("There was an error launching the keyboard preferences dialog: %s"), error->message); g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(gtk_widget_destroy), NULL); gtk_window_set_screen(GTK_WINDOW(dialog), screen); gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); gtk_widget_show(dialog); g_error_free(error); } g_object_unref (appinfo); }
static gboolean git_source_view_motion_notify_event (GtkWidget *widget, GdkEventMotion *event) { GitSourceView *sview = (GitSourceView *) widget; GitSourceViewPrivate *priv = sview->priv; gboolean show_cursor = FALSE; /* Show the hand cursor when the pointer is over a commit hash */ if (priv->paint_source) { int n_lines = git_annotated_source_get_n_lines (priv->paint_source); if (event->y < priv->y_offset + priv->line_height * n_lines && event->x < priv->max_hash_length) show_cursor = TRUE; } if (show_cursor) { if (!priv->hand_cursor_set) { /* Create the hand cursor if we haven't already got one. This will be unref'd in the dispose handler */ if (priv->hand_cursor == NULL) priv->hand_cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), GDK_HAND2); gdk_window_set_cursor (widget->window, priv->hand_cursor); priv->hand_cursor_set = TRUE; } } else { if (priv->hand_cursor_set) { gdk_window_set_cursor (widget->window, NULL); priv->hand_cursor_set = FALSE; } } return FALSE; }
static void accept_password_dialog (GtkButton *button, UmPasswordDialog *um) { const gchar *password; password = gtk_entry_get_text (GTK_ENTRY (um->password_entry)); switch (um->password_mode) { act_user_set_password_mode (um->user, ACT_USER_PASSWORD_MODE_REGULAR); case ACT_USER_PASSWORD_MODE_REGULAR: if (act_user_get_uid (um->user) == getuid ()) { GdkDisplay *display; GdkCursor *cursor; /* When setting a password for the current user, * use passwd directly, to preserve the audit trail * and to e.g. update the keyring password. */ passwd_change_password (um->passwd_handler, password, (PasswdCallback) password_changed_cb, um); gtk_widget_set_sensitive (um->dialog, FALSE); display = gtk_widget_get_display (um->dialog); cursor = gdk_cursor_new_for_display (display, GDK_WATCH); gdk_window_set_cursor (gtk_widget_get_window (um->dialog), cursor); gdk_display_flush (display); g_object_unref (cursor); return; } act_user_set_password (um->user, password, ""); break; case ACT_USER_PASSWORD_MODE_SET_AT_LOGIN: act_user_set_password_mode (um->user, um->password_mode); act_user_set_automatic_login (um->user, FALSE); break; default: g_assert_not_reached (); } finish_password_change (um); }
/* 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; xev.xexpose.window = GDK_WINDOW_XID (plug_window); 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 (xdisplay, xev.xexpose.window, False, ExposureMask, &xev); gdk_error_trap_pop_ignored (); #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 } }