Exemplo n.º 1
0
static VALUE
ifact_popup(VALUE self, VALUE x, VALUE y, VALUE mouse_button, VALUE time)
{
    gtk_item_factory_popup(_SELF(self), NUM2UINT(x), NUM2UINT(y), NUM2UINT(mouse_button),
                           NUM2UINT(time));
    return self;
}
Exemplo n.º 2
0
void mainWindow_press( GtkWidget* widget, 
		       GdkEventButton* event, gpointer callback_data )
{
    if ( event->button == 1 )
    {
	gdk_window_raise(widget->window );
	gdk_pointer_grab(widget->window, FALSE, (GdkEventMask)
	    ( GDK_BUTTON_MOTION_MASK | 
	    GDK_BUTTON_RELEASE_MASK ), GDK_NONE, GDK_NONE, GDK_CURRENT_TIME);
	offset_x = (int)event->x;
	offset_y = (int)event->y;
	indrag=1;
    }

    else if ( event->button == 3 )
    {
	int x,y;
	gdk_window_get_pointer( NULL, &x, &y, NULL );

	gtk_item_factory_popup( GTK_ITEM_FACTORY( mainMenu ), 
				x, 
				y, 
				3, 
				GDK_CURRENT_TIME );
    }
}
Exemplo n.º 3
0
gint button_press_event(GtkWidget *widget, GdkEventButton *event)
{
	GtkTextIter iter;
	guint offset;
	gint buffer_x, buffer_y;
	GdkRectangle location;
	gboolean too_far=FALSE;

	
	LOG(LOG_DEBUG, "IN : button_press_event()");

	if((event->type == GDK_BUTTON_PRESS) &&
		(event->button == 1)){

		// If you don't convert position as buffer origin, 
		// position will be invalid when scrolling
		gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(widget),
						      GTK_TEXT_WINDOW_TEXT,
						      (gint)(event->x),
						      (gint)(event->y),
						      &buffer_x,
						      &buffer_y);

		gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget),
						   &iter,
						   buffer_x,
						   buffer_y);

		offset = gtk_text_iter_get_offset(&iter);

		gtk_text_view_get_iter_location(GTK_TEXT_VIEW(widget),
					&iter,
					&location);
		if((buffer_x >= location.x + font_width) || (buffer_x <= location.x - font_width))
			too_far = TRUE;
		else
			too_far = FALSE;
	

		if(scan_link(offset) && !too_far){	
			if(follow_link(offset) == TRUE)
				return(TRUE);
		}

	} else 	if((event->type == GDK_BUTTON_PRESS) &&
		((event->button == 2) || (event->button == 3))){
		gtk_item_factory_popup(GTK_ITEM_FACTORY(text_item_factory), 
				       event->x_root, event->y_root, 
				       event->button, event->time);
		LOG(LOG_DEBUG, "OUT : button_press_event() = TRUE");
		return(TRUE);

	}

	//gdk_window_get_pointer(widget->window, &x, &y, &mask);
	LOG(LOG_DEBUG, "OUT : button_press_event() = FALSE");
	return(FALSE);
}
Exemplo n.º 4
0
gboolean search_list_clicked(GtkWidget * widget, GdkEventButton * event, gpointer user_data)
{
    GtkTreePath *treepath = NULL;
    GtkTreeViewColumn *treevc = NULL;
    GtkTreeIter iter;
    GtkTreeModel *model;

    model = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));

    gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)), &model, &iter);

    if ((event->type == GDK_BUTTON_PRESS) && (event->button == 3))
    {
	GtkItemFactory *ifactory = NULL;
	GGaduMenu *umenu;

	if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), event->x, event->y, &treepath, &treevc, NULL, NULL))
	    return FALSE;

	if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)), &model, &iter))
	{
	    GGaduContact *k;
	    GtkWidget *w;
	    gtk_tree_model_get(model, &iter, 2, &k, -1);

	    umenu = ggadu_menu_create();
	    ggadu_menu_add_submenu(umenu, ggadu_menu_new_item(_("Add"), search_user_add, NULL));
	    ggadu_menu_print(umenu, NULL);

	    ifactory = gtk_item_factory_new(GTK_TYPE_MENU, "<name>", NULL);
	    w = gtk_item_factory_get_widget(ifactory, "<name>");
	    if (w)
	    {
		g_object_set_data(G_OBJECT(w), "plugin_name", g_object_get_data(G_OBJECT(widget), "plugin_name"));
		g_object_set_data(G_OBJECT(w), "contact", k);
	    }
	    gui_produce_menu_for_factory(umenu, ifactory, NULL, w);
	    gtk_item_factory_popup(ifactory, event->x_root, event->y_root, event->button, event->time);
	}

	gtk_tree_path_free(treepath);
	return TRUE;
    }
    return FALSE;
}
Exemplo n.º 5
0
/******************************************************************************
* gtk_ItemFactoryPopup( itemFactory, nx, ny, nmouse_button, ntime ) --> NIL
* itemFactory of type GLIP_GTK_TYPE_MENU
******************************************************************************/
int
clip_GTK_ITEMFACTORYPOPUP(ClipMachine * cm)
{
        C_object       *citem = _fetch_co_arg(cm);
        gint                x = _clip_parni(cm, 2);
        gint                y = _clip_parni(cm, 3);
        gint     mouse_button = _clip_parni(cm, 4);
        guint32          time = _clip_parni(cm, 5);

	CHECKARG(1, MAP_t); CHECKCOBJ(citem, GTK_IS_ITEM_FACTORY(citem->object));
        CHECKARG(2, NUMERIC_t);
        CHECKARG(3, NUMERIC_t);
        CHECKARG(4, NUMERIC_t);
        CHECKARG(5, NUMERIC_t);

	gtk_item_factory_popup(GTK_ITEM_FACTORY(citem->object), x, y,
        	mouse_button, time );

	return 0;
err:
	return 1;
}
Exemplo n.º 6
0
static gint
on_button_press_event (GtkWidget *widget, GdkEventButton *event,
		       GtkamList *list)
{
	GtkTreePath *path = NULL;
	GtkWidget *w;
	GtkamCamera *camera;
	CameraAbilities a;

	switch (event->button) {
	case 3:
		if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (list),
				event->x, event->y, &path, NULL, NULL, NULL))
			return (FALSE);
		gtk_tree_model_get_iter (GTK_TREE_MODEL (list->priv->store),
					 &list->priv->iter, path);
		gtk_tree_path_free (path);
		camera = gtkam_list_get_camera_from_iter (list,
							  &list->priv->iter);
		gp_camera_get_abilities (camera->camera, &a);

		/* What operations does the camera support? */
		w = gtk_item_factory_get_widget (list->priv->factory,
						 "/Delete");
		gtk_widget_set_sensitive (w,
			(a.file_operations & GP_FILE_OPERATION_DELETE));

#ifdef HAVE_BONOBO
{
    Bonobo_ServerInfoList *l;
    guint i;
    GtkWidget *item, *c;
    CORBA_Environment ev;
    CameraFileInfo finfo;
    gchar *fo, *fi, *query;
    ViewAsData *d;
    GList *cl;

    w = gtk_item_factory_get_widget (list->priv->factory, "/View with...");
    c = gtk_item_factory_get_widget (list->priv->factory,
		    		     "/View with.../Built-in viewer");
    cl = gtk_container_get_children (GTK_CONTAINER (w));
    for (i = 0; i < g_list_length (cl); i++) {
	    if (g_list_nth_data (cl, i) != c)
		    gtk_container_remove (GTK_CONTAINER (w),
				    GTK_WIDGET (g_list_nth_data (cl, i)));
    }

    fo = gtkam_list_get_folder_from_iter (list, &list->priv->iter);
    fi = gtkam_list_get_name_from_iter (list, &list->priv->iter);
    gp_camera_file_get_info (camera->camera, fo, fi, &finfo, NULL);
    g_free (fo);
    g_free (fi);

    if (finfo.file.fields & GP_FILE_INFO_TYPE) {
	CORBA_exception_init (&ev);
	query = g_strconcat ("repo_ids.has ('IDL:Bonobo/Control:1.0') AND "
			     "bonobo:supported_mime_types.has ('", 
			     finfo.file.type, "')", NULL);
	l = bonobo_activation_query (query, NULL, &ev);
	g_free (query);
	CORBA_exception_free (&ev);

	if (l && l->_length) {
		for (i = 0; i < l->_length; i++) {
			Bonobo_ServerInfo *si = &l->_buffer[i];
			const gchar *n;

			if (!si->iid)
				continue;

			n = bonobo_server_info_prop_lookup (si, "name", NULL);
			if (!n)
				n = si->iid;
			item = gtk_menu_item_new_with_label (n);
			gtk_widget_show (item);
			gtk_menu_shell_append (GTK_MENU_SHELL (w), item);

			d = g_new0 (ViewAsData, 1);
			d->list = list;
			d->camera = camera;
			g_object_ref (G_OBJECT (d->camera));
			d->folder = gtkam_list_get_folder_from_iter (list,
							&list->priv->iter);
			d->file = gtkam_list_get_name_from_iter (list, 
							&list->priv->iter);
			d->iid = g_strdup (si->iid);
			g_signal_connect (G_OBJECT (item), "activate",
				G_CALLBACK (on_view_as_activate), d);
			g_signal_connect (G_OBJECT (item), "destroy",
				G_CALLBACK (on_menu_item_destroy), d);
		}
	}
	if (l)
		CORBA_free (l);
    }
}
#endif

		gtk_item_factory_popup (list->priv->factory, event->x_root,
				event->y_root, event->button, event->time);

		return (TRUE);
	default:
		return (FALSE);
	}
}
Exemplo n.º 7
0
void GTKWindow::ContextClick(int x, int y, int t)
{
    gtk_item_factory_popup(contextPopup, x, y, 3, t);
}