Exemple #1
0
static gboolean link_event_handler(GtkTextTag *tag, GObject *text_view,GdkEvent *event, GtkTextIter *iter, gpointer user_data) {
	if(event->type == GDK_BUTTON_PRESS) {
		GtkTextIter uri_begin = *iter;
		GtkTextIter uri_end = *iter;
		gchar *uri = NULL;
		gtk_text_iter_backward_to_tag_toggle(&uri_begin, tag);
		gtk_text_iter_forward_to_tag_toggle(&uri_end, tag);
		uri = gtk_text_iter_get_slice(&uri_begin, &uri_end);
		if(((GdkEventButton *)event)->button == 1) {
			GError *error = NULL;
			gtk_show_uri(NULL, uri, gdk_event_get_time(event), &error);
			if(error) {
				g_warning("Could not open %s from chat: %s", uri, error->message);
				g_error_free(error);
			}
		} else if(((GdkEventButton *)event)->button == 3) {
			GtkMenu *menu = GTK_MENU(g_object_get_data(text_view, "link_ctx_menu"));
			g_object_set_data_full(G_OBJECT(menu), "uri", g_strdup(uri), g_free);
			gtk_menu_popup(menu, NULL, NULL, NULL, NULL, 3, gdk_event_get_time(event));
		}
		g_free(uri);
		return TRUE;
	}
	return FALSE;
}
static gboolean
grab_keyboard (GtkWidget *win, GdkEvent *event, gpointer data)
{
	GdkGrabStatus status;

#if GTK_CHECK_VERSION (3,0,0)
	GdkDevice *device;
	GdkDeviceManager *manager;
	GdkDisplay *display;
	GList *devices, *l;
	guint32 at;

	if (grabbed_device || !GRAB_KEYBOARD)
		return FALSE;

	display = gtk_widget_get_display (win);
	manager = gdk_display_get_device_manager (display);
	devices = gdk_device_manager_list_devices (manager, GDK_DEVICE_TYPE_MASTER);
	for (l = devices; l; l = g_list_next (l)) {
		device = l->data;
		if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
			break;
	}
	g_list_free (devices);

	if (!device) {
		g_message ("couldn't find device to grab");
		return FALSE;
	}

	at = gdk_event_get_time (event);
	status = gdk_device_grab (device, gtk_widget_get_window (win),
				  GDK_OWNERSHIP_WINDOW, TRUE,
				  GDK_KEY_PRESS | GDK_KEY_RELEASE, NULL, at);
	if (status == GDK_GRAB_SUCCESS) {
		grab_broken_id = g_signal_connect (win, "grab-broken-event",
						   G_CALLBACK (on_grab_broken), NULL);
		gtk_device_grab_add (win, device, TRUE);
		grabbed_device = device;
		grabbed_at = at;
	} else {
		g_message ("could not grab keyboard: %d", (int)status);
	}
#else
	if (!keyboard_grabbed && GRAB_KEYBOARD) {
		status = gdk_keyboard_grab (gtk_widget_get_window (win), FALSE, gdk_event_get_time (event));
		if (status == GDK_GRAB_SUCCESS) {
			keyboard_grabbed = TRUE;
		} else {
			g_message ("could not grab keyboard: %d", (int)status);
		}
	}
#endif

	/* Always return false, so event is handled elsewhere */
	return FALSE;
}
static gboolean on_deepin_cloned_widget_released(MetaDeepinClonedWidget* cloned,
               GdkEvent* event, gpointer data)
{
    DeepinWorkspaceOverview* self = (DeepinWorkspaceOverview*)data;
    meta_verbose("%s\n", __func__);
    if (!self->priv->ready) return FALSE;

    MetaWindow* mw = meta_deepin_cloned_widget_get_window(cloned);
    if (mw->workspace && mw->workspace != mw->screen->active_workspace) {
        meta_workspace_activate(mw->workspace, gdk_event_get_time(event));
    }
    meta_window_activate(mw, gdk_event_get_time(event));
    g_idle_add((GSourceFunc)on_idle_end_grab, gdk_event_get_time(event));
    return TRUE;
}
void
xpath_view_popup_menu (GtkWidget *treeview, GdkEventButton *event, XpathExplorer *ttt)
{

	GtkWidget *results_menu, *results_item;
	results_menu = gtk_menu_new();

	results_item = gtk_menu_item_new_with_label(_("Copy XPath"));
	g_signal_connect(results_item, "activate", G_CALLBACK(xpath_results_copy), ttt);
	gtk_menu_shell_append(GTK_MENU_SHELL(results_menu), results_item);

	results_item = gtk_menu_item_new_with_label(_("Copy Name"));
	g_signal_connect(results_item, "activate", G_CALLBACK(xpath_results_copy), ttt);
	gtk_menu_shell_append(GTK_MENU_SHELL(results_menu), results_item);

	results_item = gtk_menu_item_new_with_label(_("Copy Value"));
	g_signal_connect(results_item, "activate", G_CALLBACK(xpath_results_copy), ttt);
	gtk_menu_shell_append(GTK_MENU_SHELL(results_menu), results_item);

	results_item = gtk_menu_item_new_with_label(_("Show in XML Navigator"));
	g_signal_connect(results_item, "activate", G_CALLBACK(xpath_show_in_navigator), ttt);
	gtk_menu_shell_append(GTK_MENU_SHELL(results_menu), results_item);

	gtk_widget_show_all(results_menu);

    gtk_menu_popup(GTK_MENU(results_menu), NULL, NULL, NULL, NULL,
                   (event != NULL) ? event->button : 0,
                   gdk_event_get_time((GdkEvent*)event));
	
}
Exemple #5
0
static void show_popup(GtkWidget *widget,
				GdkEventButton *event, gpointer user_data)
{
	GtkWidget *menu;
	GtkWidget *item;

	menu = gtk_menu_new();

	item = gtk_menu_item_new_with_label("Connect");
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
	g_signal_connect(G_OBJECT(item), "activate",
				G_CALLBACK(connect_callback), user_data);

	item = gtk_menu_item_new_with_label("Disconnect");
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
	g_signal_connect(G_OBJECT(item), "activate",
				G_CALLBACK(disconnect_callback), user_data);

	item = gtk_menu_item_new_with_label("Remove");
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
	g_signal_connect(G_OBJECT(item), "activate",
				G_CALLBACK(remove_callback), user_data);

	gtk_widget_show_all(menu);

	gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
					(event != NULL) ? event->button : 0,
					gdk_event_get_time((GdkEvent*) event));
}
Exemple #6
0
void menu_info_item_clicked(GtkWidget* item, GdkEventButton* event,
        menu_info_item_t* mii)
{
#ifdef DEBUG
    g_message("[systray] button-press-event mod:%s button:%i",
            (event->state & GDK_CONTROL_MASK) ? "ctrl" : "", event->button);
#endif

    switch(event->button)
    {
        /* on left-click, set device as default */
        case 1:
            pulseaudio_set_default(mii);
            break;
        /* on middle-click, toggle mute device/stream */
        case 2:
            pulseaudio_toggle_mute(mii);
            break;
        /* on right-click, show context menu (if any) */
        case 3:
            if(mii->context)
                gtk_menu_popup(GTK_MENU(mii->context), NULL, NULL, NULL, NULL,
                        (event != NULL) ? event->button : 0,
                        gdk_event_get_time((GdkEvent*)event));
            break;
    }
}
Exemple #7
0
void menu_info_item_clicked(GtkWidget* item, GdkEventButton* event,
        menu_info_item_t* mii)
{
    g_debug("[menu_info] item clicked mod:%s%s button:%i",
            (event->state & GDK_CONTROL_MASK) ? "[ctrl]" : "",
            (event->state & GDK_MOD1_MASK) ? "[alt]" : "",
            event->button);

    switch(event->button)
    {
        case 1:
            /* on alt + left-click, toggle mute device/stream */
            if(event->state & GDK_MOD1_MASK)
                pulseaudio_toggle_mute(mii);

            /* on left-click, set device as default */
            else
                pulseaudio_set_default(mii);
            break;
        /* on middle-click, toggle mute device/stream */
        case 2:
            pulseaudio_toggle_mute(mii);
            break;
        /* on right-click, show context menu (if any) */
        case 3:
            if(mii->context)
                gtk_menu_popup(GTK_MENU(mii->context), NULL, NULL, NULL, NULL,
                        (event != NULL) ? event->button : 0,
                        gdk_event_get_time((GdkEvent*)event));
            break;
    }
}
Exemple #8
0
WebMouseEvent WebEventFactory::createWebMouseEvent(const GdkEvent* event, int currentClickCount)
{
    double x, y, xRoot, yRoot;
    gdk_event_get_coords(event, &x, &y);
    gdk_event_get_root_coords(event, &xRoot, &yRoot);

    WebEvent::Type type = static_cast<WebEvent::Type>(0);
    switch (event->type) {
    case GDK_MOTION_NOTIFY:
        type = WebEvent::MouseMove;
        break;
    case GDK_BUTTON_PRESS:
    case GDK_2BUTTON_PRESS:
    case GDK_3BUTTON_PRESS:
        type = WebEvent::MouseDown;
        break;
    case GDK_BUTTON_RELEASE:
        type = WebEvent::MouseUp;
        break;
    default :
        ASSERT_NOT_REACHED();
    }

    return WebMouseEvent(type,
                         buttonForEvent(event),
                         IntPoint(x, y),
                         IntPoint(xRoot, yRoot),
                         0 /* deltaX */,
                         0 /* deltaY */,
                         0 /* deltaZ */,
                         currentClickCount,
                         modifiersForEvent(event),
                         gdk_event_get_time(event));
}
Exemple #9
0
static void
set_user_time (GdkWindow *window,
               GdkEvent  *event)
{
  g_return_if_fail (event != NULL);

  window = gdk_window_get_toplevel (event->any.window);
  g_return_if_fail (GDK_IS_WINDOW (window));

  /* If an event doesn't have a valid timestamp, we shouldn't use it
   * to update the latest user interaction time.
   */
  if (gdk_event_get_time (event) != GDK_CURRENT_TIME)
    gdk_x11_window_set_user_time (gdk_window_get_toplevel (window),
                                  gdk_event_get_time (event));
}
Exemple #10
0
static void
show_popup_menu (GtkTreeView *treeview, GdkEventButton *event) {
    GtkTreeSelection *selection;
    GtkWidget *menu, *item;
    char label_buf[200];

    selection = gtk_tree_view_get_selection (treeview);
    if (!gtk_tree_selection_count_selected_rows (selection)) {
        // don't show menu on empty tree view
        return;
    }

    menu = gtk_menu_new ();

    sprintf(label_buf, "Add to playlist '%s'", last_search_query);
    item = gtk_menu_item_new_with_label (label_buf);
    g_signal_connect (item, "activate", G_CALLBACK (on_menu_item_add_to_new_playlist), treeview);
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);

    item = gtk_menu_item_new_with_label ("Add to current playlist");
    g_signal_connect (item, "activate", G_CALLBACK (on_menu_item_add_to_playlist), treeview);
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);

    item = gtk_menu_item_new_with_label ("Copy URL(s)");
    g_signal_connect (item, "activate", G_CALLBACK (on_menu_item_copy_url), treeview);
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), item);

    gtk_widget_show_all (menu);
    gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 0,
                    gdk_event_get_time ((GdkEvent *) event));
}
Exemple #11
0
static gboolean link_event_handler(GtkTextTag *tag, GObject *text_view,GdkEvent *event, GtkTextIter *iter, GtkWidget *chat_view) {
	if(event->type == GDK_BUTTON_PRESS) {
		GtkTextIter uri_begin = *iter;
		GtkTextIter uri_end = *iter;
		gchar *uri = NULL;
		LinphoneChatRoom *chat_room = (LinphoneChatRoom *)g_object_get_data(G_OBJECT(chat_view), "cr");
		
		gtk_text_iter_backward_to_tag_toggle(&uri_begin, tag);
		gtk_text_iter_forward_to_tag_toggle(&uri_end, tag);
		uri = gtk_text_iter_get_slice(&uri_begin, &uri_end);
		if(((GdkEventButton *)event)->button == 1) {
			linphone_gtk_open_browser(uri);
		} else if(((GdkEventButton *)event)->button == 3) {
			GtkMenu *menu = GTK_MENU(g_object_get_data(text_view, "link_ctx_menu"));
			g_object_set_data_full(G_OBJECT(menu), "uri", g_strdup(uri), g_free);
			gtk_menu_popup(menu, NULL, NULL, NULL, NULL, 3, gdk_event_get_time(event));
		}
		g_free(uri);
		
		linphone_chat_room_mark_as_read(chat_room);
		linphone_gtk_friend_list_update_chat_picture();
		
		return TRUE;
	}
	return FALSE;
}
/* Remove grab.  */
static void
ungrab_keyboard (GtkWidget *win, GdkEvent *event, gpointer data)
{
    gdk_keyboard_ungrab (gdk_event_get_time (event));
    /* Unmake window transient for the root window.  */
    gdk_window_set_transient_for (win->window, NULL);
}
gboolean
gimp_display_shell_keyboard_grab (GimpDisplayShell *shell,
                                  const GdkEvent   *event)
{
  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->keyboard_grabbed == FALSE, FALSE);

  status = gdk_keyboard_grab (gtk_widget_get_window (shell->canvas),
                              FALSE,
                              gdk_event_get_time (event));

  if (status == GDK_GRAB_SUCCESS)
    {
      shell->keyboard_grabbed = TRUE;

      return TRUE;
    }

  g_printerr ("%s: gdk_keyboard_grab failed with status %d\n",
              G_STRFUNC, status);

  return FALSE;
}
static gboolean
password_dialog_grab_keyboard (GtkWidget *widget,
    GdkEvent *event,
    gpointer user_data)
{
  EmpathyPasswordDialogPriv *priv = EMPATHY_PASSWORD_DIALOG (user_data)->priv;

  if (!priv->grabbing)
    {
      GdkDevice *device = gdk_event_get_device (event);

      if (device != NULL)
        {
          GdkGrabStatus status = gdk_device_grab (device,
              gtk_widget_get_window (widget),
              GDK_OWNERSHIP_WINDOW,
              FALSE,
              GDK_ALL_EVENTS_MASK,
              NULL,
              gdk_event_get_time (event));

          if (status != GDK_GRAB_SUCCESS)
            DEBUG ("Could not grab keyboard; grab status was %u", status);
          else
            priv->grabbing = TRUE;
        }
      else
        DEBUG ("Could not get the event device!");
    }

  return FALSE;
}
/**
* win: ignored
* event: the event that triggered ungrabbing
* data: ignored
*
* Will ungrab the keyboard
*
* Returns FALSE
**/
static gboolean
ungrab_keyboard (GtkWidget *win, GdkEvent *event, gpointer data)
{
	if (keyboard_grabbed)
		gdk_keyboard_ungrab (gdk_event_get_time (event));
	keyboard_grabbed = FALSE;
	return FALSE;
}
Exemple #16
0
void GtkPopupMenu::popUp(const IntSize& menuSize, const IntPoint& menuPosition, int itemCount, int selectedItem, const GdkEvent* event)
{
    resetTypeAheadFindState();
    m_menuPosition = menuPosition;
    gtk_menu_set_active(GTK_MENU(m_popup.get()), selectedItem);

    // This approach follows the one in gtkcombobox.c.
    GtkRequisition requisition;
    gtk_widget_set_size_request(m_popup.get(), -1, -1);
#ifdef GTK_API_VERSION_2
    gtk_widget_size_request(m_popup.get(), &requisition);
#else
    gtk_widget_get_preferred_size(m_popup.get(), &requisition, 0);
#endif

    gtk_widget_set_size_request(m_popup.get(), std::max(menuSize.width(), requisition.width), -1);

    GList* children = gtk_container_get_children(GTK_CONTAINER(m_popup.get()));
    GList* p = children;
    if (itemCount) {
        for (int i = 0; i < itemCount; i++) {
            if (i > selectedItem)
                break;

            GtkWidget* item = reinterpret_cast<GtkWidget*>(p->data);
            GtkRequisition itemRequisition;
#ifdef GTK_API_VERSION_2
            gtk_widget_get_child_requisition(item, &itemRequisition);
#else
            gtk_widget_get_preferred_size(item, &itemRequisition, 0);
#endif
            m_menuPosition.setY(m_menuPosition.y() - itemRequisition.height);

            p = g_list_next(p);
        }
    } else {
        // Center vertically the empty popup in the combo box area.
        m_menuPosition.setY(m_menuPosition.y() - menuSize.height() / 2);
    }
    g_list_free(children);

    guint button;
    guint32 activateTime;
    if (event) {
        button = event->type == GDK_BUTTON_PRESS ? event->button.button : 1;
        activateTime = gdk_event_get_time(event);
    } else {
        button = 1;
        activateTime = GDK_CURRENT_TIME;
    }

#ifdef GTK_API_VERSION_2
    gtk_menu_popup(GTK_MENU(m_popup.get()), 0, 0, reinterpret_cast<GtkMenuPositionFunc>(menuPositionFunction), this, button, activateTime);
#else
    gtk_menu_popup_for_device(GTK_MENU(m_popup.get()), event ? gdk_event_get_device(event) : 0, 0, 0,
                              reinterpret_cast<GtkMenuPositionFunc>(menuPositionFunction), this, 0, button, activateTime);
#endif
}
Exemple #17
0
void 
gnac_ui_show_popup_menu(GtkWidget      *treeview,
                        GdkEventButton *event, 
                        gpointer        user_data)
{
  GtkMenu *popup_menu = GTK_MENU(gnac_ui_get_widget("main_popup"));
  gtk_menu_popup(popup_menu, NULL, NULL, NULL, NULL,
      event ? event->button : 0, gdk_event_get_time((GdkEvent *) event));
}
/* Grab the keyboard for maximum security */
static void
grab_keyboard (GtkWidget *win, GdkEvent *event, gpointer data)
{
  if (!pinentry->grab)
    return;

  if (gdk_keyboard_grab (win->window, FALSE, gdk_event_get_time (event)))
    g_error ("could not grab keyboard");
}
void WebPopupMenuProxyGtk::showPopupMenu(const IntRect& rect, TextDirection, double /* pageScaleFactor */, const Vector<WebPopupItem>& items, const PlatformPopupMenuData&, int32_t selectedIndex)
{
    populatePopupMenu(items);
    gtk_menu_set_active(GTK_MENU(m_popup), selectedIndex);

    resetTypeAheadFindState();


    IntPoint menuPosition = convertWidgetPointToScreenPoint(m_webView, rect.location());
    menuPosition.move(0, rect.height());

    // This approach follows the one in gtkcombobox.c.
    GtkRequisition requisition;
    gtk_widget_set_size_request(m_popup, -1, -1);
    gtk_widget_get_preferred_size(m_popup, &requisition, nullptr);
    gtk_widget_set_size_request(m_popup, std::max(rect.width(), requisition.width), -1);

    if (int itemCount = items.size()) {
        GUniquePtr<GList> children(gtk_container_get_children(GTK_CONTAINER(m_popup)));
        int i;
        GList* child;
        for (i = 0, child = children.get(); i < itemCount; i++, child = g_list_next(child)) {
            if (i > selectedIndex)
                break;

            GtkWidget* item = GTK_WIDGET(child->data);
            GtkRequisition itemRequisition;
            gtk_widget_get_preferred_size(item, &itemRequisition, nullptr);
            menuPosition.setY(menuPosition.y() - itemRequisition.height);
        }
    } else {
        // Center vertically the empty popup in the combo box area.
        menuPosition.setY(menuPosition.y() - rect.height() / 2);
    }

    const GdkEvent* event = m_client->currentlyProcessedMouseDownEvent() ? m_client->currentlyProcessedMouseDownEvent()->nativeEvent() : nullptr;
    gtk_menu_popup_for_device(GTK_MENU(m_popup), event ? gdk_event_get_device(event) : nullptr, nullptr, nullptr,
        [](GtkMenu*, gint* x, gint* y, gboolean* pushIn, gpointer userData) {
            // We can pass a pointer to the menuPosition local variable because the nested main loop ensures this is called in the function context.
            IntPoint* menuPosition = static_cast<IntPoint*>(userData);
            *x = menuPosition->x();
            *y = menuPosition->y();
            *pushIn = menuPosition->y() < 0;
        }, &menuPosition, nullptr, event && event->type == GDK_BUTTON_PRESS ? event->button.button : 1,
        event ? gdk_event_get_time(event) : GDK_CURRENT_TIME);

    // Now that the menu has a position, schedule a resize to make sure it's resized to fit vertically in the work area.
    gtk_widget_queue_resize(m_popup);

    // PopupMenu can fail to open when there is no mouse grab.
    // Ensure WebCore does not go into some pesky state.
    if (!gtk_widget_get_visible(m_popup)) {
       m_client->failedToShowPopupMenu();
       return;
    }
}
/* ungrab_keyboard - remove grab */
static gboolean
ungrab_keyboard (GtkWidget *win, GdkEvent *event, gpointer data)
{
#ifndef _DEBUG
	if (g_object_get_data (G_OBJECT (win), "keyboard-grabbed"))
		gdk_keyboard_ungrab (gdk_event_get_time (event));
	g_object_set_data (G_OBJECT (win), "keyboard-grabbed", NULL);
#endif
	return FALSE;
}
Exemple #21
0
static bool on_treeview_button_press_event(G_GNUC_UNUSED GtkWidget *widget,
	GdkEventButton *event)
{
	// Right click
	if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
		gtk_menu_popup(gui.menu_treeview, NULL, NULL, NULL, NULL, 3,
			gdk_event_get_time((GdkEvent *)event));
	}

	return false;
}
Exemple #22
0
/*! \brief Popup context-sensitive menu.
 *  \par Function Description
 *  Pops up a context-sensitive menu.
 *
 *  <B>event</B> can be NULL if the popup is triggered by a key binding
 *  instead of a mouse click.
 *
 *  \param [in] pagesel  The Pagesel object.
 *  \param [in] event    Mouse click event info.
 */
static void pagesel_popup_menu (Pagesel *pagesel,
                                GdkEventButton *event)
{
    GtkTreePath *path;
    GtkWidget *menu;
    struct menuitem_t {
        gchar *label;
        GCallback callback;
    };
    struct menuitem_t menuitems[] = {
        { N_("New Page"),     G_CALLBACK (pagesel_callback_popup_new_page)     },
        { N_("Open Page..."), G_CALLBACK (pagesel_callback_popup_open_page)    },
        { "-",                NULL                                             },
        { N_("Save Page"),    G_CALLBACK (pagesel_callback_popup_save_page)    },
        { N_("Close Page"),   G_CALLBACK (pagesel_callback_popup_close_page)   },
        { N_("Discard Page"), G_CALLBACK (pagesel_callback_popup_discard_page) },
        { NULL,               NULL                                             }
    };
    struct menuitem_t *tmp;

    if (event != NULL &&
            gtk_tree_view_get_path_at_pos (pagesel->treeview,
                                           (gint)event->x,
                                           (gint)event->y,
                                           &path, NULL, NULL, NULL)) {
        GtkTreeSelection *selection;
        selection = gtk_tree_view_get_selection (pagesel->treeview);
        gtk_tree_selection_unselect_all (selection);
        gtk_tree_selection_select_path (selection, path);
        gtk_tree_path_free (path);
    }

    /* create the context menu */
    menu = gtk_menu_new();
    for (tmp = menuitems; tmp->label != NULL; tmp++) {
        GtkWidget *menuitem;
        if (g_strcasecmp (tmp->label, "-") == 0) {
            menuitem = gtk_separator_menu_item_new ();
        } else {
            menuitem = gtk_menu_item_new_with_label (_(tmp->label));
            g_signal_connect (menuitem,
                              "activate",
                              tmp->callback,
                              pagesel);
        }
        gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
    }
    gtk_widget_show_all (menu);
    /* make menu a popup menu */
    gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
                    (event != NULL) ? event->button : 0,
                    gdk_event_get_time ((GdkEvent*)event));

}
Exemple #23
0
/* Remove grab.  */
static void
ungrab_keyboard (GtkWidget *win, GdkEvent *event, gpointer data)
{
  gdk_keyboard_ungrab (gdk_event_get_time (event));
  /* Unmake window transient for the root window.  */
  /* gdk_window_set_transient_for cannot be used with parent = NULL to
     unset transient hint (unlike gtk_ version which can).  Replacement
     code is taken from gtk_window_transient_parent_unrealized.  */
  gdk_property_delete (win->window,
                       gdk_atom_intern_static_string ("WM_TRANSIENT_FOR"));
}
Exemple #24
0
static void menu_cardview_context_menu(GtkWidget *treeview, GdkEventButton *event, gpointer userdata)
/* Create a right click context menu */
{
    GtkWidget *menu, *menuitem;
    GtkTreeViewColumn *column2 = gtk_tree_view_get_column(GTK_TREE_VIEW(treeview),2);
#if GTK_CHECK_VERSION(3,6,0)
    GtkWidget *menuitem_child;
#endif
    UNUSED(userdata);

    menu = gtk_menu_new();

    /* Menu Item */
    menuitem = gtk_menu_item_new_with_label("Copy");
    g_signal_connect(menuitem, "activate",
                     (GCallback) menu_cardview_copy, treeview);
#if GTK_CHECK_VERSION(3,6,0)
    menuitem_child = gtk_bin_get_child (GTK_BIN (menuitem));
    gtk_accel_label_set_accel (GTK_ACCEL_LABEL (menuitem_child), GDK_KEY_c, GDK_CONTROL_MASK);
#endif
    gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);

    /* Menu Item */
    menuitem = gtk_menu_item_new_with_label("Expand all");
    g_signal_connect(menuitem, "activate",
                     (GCallback) menu_cardview_context_menu_expand_all, treeview);
    gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);

    /* Menu Item */
    if (gtk_tree_view_column_get_visible(column2))
    {
        menuitem = gtk_menu_item_new_with_label("Show interpreted value");
        g_signal_connect(menuitem, "activate",
                         (GCallback) menu_cardview_context_menu_change_value_type, treeview);
    }
    else
    {
        menuitem = gtk_menu_item_new_with_label("Show raw value");
        g_signal_connect(menuitem, "activate",
                         (GCallback) menu_cardview_context_menu_change_value_type, treeview);
    }
#if GTK_CHECK_VERSION(3,6,0)
    menuitem_child = gtk_bin_get_child (GTK_BIN (menuitem));
    gtk_accel_label_set_accel (GTK_ACCEL_LABEL (menuitem_child), GDK_KEY_r, GDK_CONTROL_MASK);
#endif
    gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);


    gtk_widget_show_all(menu);

    gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
                   (event != NULL) ? event->button : 0,
                   gdk_event_get_time((GdkEvent *)event));
}
static gboolean
grab_keyboard (GtkWidget *win, GdkEvent *event, gpointer data)
{
#ifndef _DEBUG
	if (!g_object_get_data (G_OBJECT (win), "keyboard-grabbed"))
		if (gdk_keyboard_grab (gtk_widget_get_window (win), FALSE, gdk_event_get_time (event)))
			g_message ("could not grab keyboard");
	g_object_set_data (G_OBJECT (win), "keyboard-grabbed", GINT_TO_POINTER (TRUE));
#endif
	return FALSE;
}
static gboolean on_deepin_workspace_overview_pressed(DeepinWorkspaceOverview* self,
               GdkEvent* event, gpointer user_data)
{
    DeepinWorkspaceOverviewPrivate* priv = self->priv;
    meta_verbose("%s: ws %s\n", __func__, meta_workspace_get_name(priv->workspace));

    if (!priv->ready || priv->hovered_clone) return TRUE;

    g_idle_add((GSourceFunc)on_idle_end_grab, gdk_event_get_time(event));
    return TRUE;
}
Exemple #27
0
static gboolean
item_grid_button_released (GocItem *item, int button, G_GNUC_UNUSED double x_, G_GNUC_UNUSED double y_)
{
	GnmItemGrid *ig = GNM_ITEM_GRID (item);
	GnmPane  *pane = GNM_PANE (item->canvas);
	SheetControlGUI *scg = ig->scg;
	Sheet *sheet = scg_sheet (scg);
	ItemGridSelectionType selecting = ig->selecting;
	GdkEvent *event = goc_canvas_get_cur_event (item->canvas);

	if (button != 1 && button != 2)
		return FALSE;

	gnm_pane_slide_stop (pane);

	switch (selecting) {
	case GNM_ITEM_GRID_NO_SELECTION:
		return TRUE;

	case GNM_ITEM_GRID_SELECTING_FORMULA_RANGE :
/*  Removal of this code (2 lines)                                                */
/*  should fix http://bugzilla.gnome.org/show_bug.cgi?id=63485                    */
/*			sheet_make_cell_visible (sheet,                           */
/*				sheet->edit_pos.col, sheet->edit_pos.row, FALSE); */
		/* Fall through */
	case GNM_ITEM_GRID_SELECTING_CELL_RANGE :
		sv_selection_simplify (scg_view (scg));
		wb_view_selection_desc (
			wb_control_view (scg_wbc (scg)), TRUE, NULL);
		break;

	default:
		g_assert_not_reached ();
	}

	ig->selecting = GNM_ITEM_GRID_NO_SELECTION;
	gnm_simple_canvas_ungrab (item, gdk_event_get_time (event));

	if (selecting == GNM_ITEM_GRID_SELECTING_FORMULA_RANGE)
		gnm_expr_entry_signal_update (
			wbcg_get_entry_logical (scg_wbcg (scg)), TRUE);

	if (selecting == GNM_ITEM_GRID_SELECTING_CELL_RANGE && button == 1) {
		GnmCellPos const *pos = sv_is_singleton_selected (scg_view (scg));
		if (pos != NULL) {
			GnmHLink *link;
			/* check for hyper links */
			link = sheet_hlink_find (sheet, pos);
			if (link != NULL)
				gnm_hlink_activate (link, scg_wbcg (scg));
		}
	}
	return TRUE;
}
Exemple #28
0
static bool gtkhash_properties_on_treeview_button_press_event(
	struct page_s *page, GdkEventButton *event)
{
	// Right click
	if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
		gtk_menu_popup(page->menu, NULL, NULL, NULL, NULL, 3,
			gdk_event_get_time((GdkEvent *)event));
	}

	return false;
}
Exemple #29
0
/* Grab the keyboard for maximum security */
static void
grab_keyboard (GtkWidget *win, GdkEvent *event, gpointer data)
{
  if (! pinentry->grab)
    return;

  if (gdk_keyboard_grab (win->window, FALSE, gdk_event_get_time (event)))
    {
      g_critical ("could not grab keyboard");
      grab_failed = 1;
      gtk_main_quit ();
    }
}
void
gimp_display_shell_pointer_ungrab (GimpDisplayShell *shell,
                                   const GdkEvent   *event)
{
  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
  g_return_if_fail (event != NULL);
  g_return_if_fail (shell->pointer_grabbed == TRUE);

  gdk_display_pointer_ungrab (gtk_widget_get_display (shell->canvas),
                              gdk_event_get_time (event));

  shell->pointer_grabbed = FALSE;
}