Beispiel #1
0
static gint handle_scroll_horizontal_signal (GtkWidget *widget, GtkScrollType scroll_type, gfloat position, C_signal *cs)
{
	PREPARECV(cs,cv);
  	_clip_mputn(cs->cw->cmachine, &cv, HASH_SCROLLTYPE, scroll_type);
  	_clip_mputn(cs->cw->cmachine, &cv, HASH_POSITION, position);
        INVOKESIGHANDLER(widget,cs,cv);
}
Beispiel #2
0
CLIP_DLLEXPORT void
_extext_linedata_to_map(ClipMachine * cm, GtkExText * text, GtkExTextLineData * lined, ClipVar * m_lined)
{
   ClipVar  *c = NEW(ClipVar);

   ClipVar  *a = NEW(ClipVar);

   gint      l;

   if (!lined || !m_lined || m_lined->t.ClipVartype_type_of_ClipType != MAP_type_of_ClipVarType)
      return;

   _clip_map(cm, c);
   _clip_mputn(cm, c, HASH_STARTPOS, lined->startpos);
   _clip_madd(cm, m_lined, HASH_STARTPOS, c);

   _clip_map(cm, c);
   _clip_mputn(cm, c, HASH_ENDPOS, lined->endpos);
   _clip_madd(cm, m_lined, HASH_ENDPOS, c);

   _clip_map(cm, c);
   _clip_mputn(cm, c, HASH_LINE, lined->line_number);
   _clip_madd(cm, m_lined, HASH_LINE, c);

   l = lined->endpos - lined->startpos;
   _clip_map(cm, c);
   _clip_mputc(cm, c, HASH_TEXT, text->text + lined->startpos, l);
   _clip_madd(cm, m_lined, HASH_TEXT, c);

   _clip_destroy(cm, c);
   free(c);
   free(a);

}
Beispiel #3
0
/* Signal handlers */
static gint handle_extend_selection_signal (GtkWidget *widget, GtkScrollType scroll_type, gfloat position, gboolean auto_start_selection, C_signal *cs)
{
	PREPARECV(cs,cv);
  	_clip_mputn(cs->cw->cmachine, &cv, HASH_SCROLLTYPE, scroll_type);
  	_clip_mputn(cs->cw->cmachine, &cv, HASH_POSITION, position);
  	_clip_mputl(cs->cw->cmachine, &cv, HASH_AUTOSTARTSELECTION, auto_start_selection);
        INVOKESIGHANDLER(widget,cs,cv);
}
Beispiel #4
0
static    gint
handle_changed_signal(GtkWidget * widget, gint row, gint col, C_signal * cs)
{
   PREPARECV(cs, cv);
   _clip_mputn(cs->cw->cmachine, &cv, HASH_ROW, row + 1);
   _clip_mputn(cs->cw->cmachine, &cv, HASH_COL, col + 1);
   INVOKESIGHANDLER(widget, cs, cv);
}
Beispiel #5
0
/* Get color and store it to map */
CLIP_DLLEXPORT void
_gdk_color_to_map (ClipMachine *cm, GdkColor gdk_color, ClipVar *col)
{
	_clip_mputn(cm, col, HASH_RED, gdk_color.red);
	_clip_mputn(cm, col, HASH_GREEN, gdk_color.green);
	_clip_mputn(cm, col, HASH_BLUE, gdk_color.blue);
	_clip_mputn(cm, col, HASH_PIXEL, gdk_color.pixel);
}
Beispiel #6
0
static gint handle_size_allocate_signal (GtkWidget *widget, GtkAllocation *allocation, C_signal *cs)
	{
	PREPARECV(cs,cv);
	_clip_mputn(cs->cw->cmachine, &cv, HASH_X, allocation->x);
	_clip_mputn(cs->cw->cmachine, &cv, HASH_Y, allocation->y);
	_clip_mputn(cs->cw->cmachine, &cv, HASH_WIDTH, allocation->width);
	_clip_mputn(cs->cw->cmachine, &cv, HASH_HEIGHT, allocation->height);
	INVOKESIGHANDLER(widget,cs,cv);
	}
Beispiel #7
0
static    gint
handle_changed_signal(GtkAccelMap * map, gchar * path, guint key, GdkModifierType type, C_signal * cs)
{
   OBJECTPREPARECV(cs, cv);
   _clip_mputc(cs->co->cmachine, &cv, HASH_ACCEL_PATH, path, strlen(path));
   _clip_mputn(cs->co->cmachine, &cv, HASH_ACCEL_KEY, key);
   _clip_mputn(cs->co->cmachine, &cv, HASH_ACCEL_MODS, (int) type);
   OBJECTINVOKESIGHANDLER(cs, cv);
}
Beispiel #8
0
static gint
handle_focus_in_out_event (GtkWidget *widget, GdkEventFocus *event, C_signal *cs)
{
	PREPARECV(cs,cv);
	_clip_mputn(cs->cw->cmachine, &cv, HASH_TYPE, event->type);
	_clip_mputn(cs->cw->cmachine, &cv, HASH_SENDEVENT, event->send_event);
	_clip_mputn(cs->cw->cmachine, &cv, HASH_IN, event->in);
	INVOKESIGHANDLER(widget,cs,cv);
}
Beispiel #9
0
// Put colors from GTK+ to a map
CLIP_DLLEXPORT void
_map_put_colors (ClipMachine *cm, ClipVar *map, double colors[])
{
	if (map && map->t.type==MAP_t)
	{
		_clip_mputn(cm, map, HASH_RED, colors[0]);
		_clip_mputn(cm, map, HASH_GREEN, colors[1]);
		_clip_mputn(cm, map, HASH_BLUE, colors[2]);
		_clip_mputn(cm, map, HASH_OPACITY, colors[3]);
	}
}
Beispiel #10
0
/* Set GdkRectangle data to a map */
CLIP_DLLEXPORT int
_map_put_gdk_rectangle(ClipMachine * ClipMachineMemory, ClipVar * map, GdkRectangle * region)
{
   if (map && map->ClipType_t_of_ClipVar.ClipVartype_type_of_ClipType == MAP_type_of_ClipVarType && region)
    {
       _clip_mputn(ClipMachineMemory, map, HASH_X, region->x);
       _clip_mputn(ClipMachineMemory, map, HASH_Y, region->y);
       _clip_mputn(ClipMachineMemory, map, HASH_WIDTH, region->width);
       _clip_mputn(ClipMachineMemory, map, HASH_HEIGHT, region->height);
       return 0;
    }
   return -1;
}
Beispiel #11
0
CLIP_DLLEXPORT void
_stock_item_to_map(ClipMachine *cm, ClipVar *cv, GtkStockItem *item)
{

	_clip_map(cm, cv);

	_clip_mputc(cm, cv, HASH_STOCK_ID, item->stock_id, strlen(item->stock_id));
	_clip_mputc(cm, cv, HASH_LABEL, item->label, strlen(item->label));
	_clip_mputn(cm, cv, HASH_MODIFIER, item->modifier);
	_clip_mputn(cm, cv, HASH_KEYVAL, item->keyval);
	_clip_mputc(cm, cv, HASH_TRANSL_DOMAIN,	item->translation_domain, strlen(item->translation_domain));

}
Beispiel #12
0
/**** LABEL constructor ****/
int
clip_GTK_LABELNEW(ClipMachine * cm)
{
	ClipVar * cv   = _clip_spar(cm, 1);
	char  * text   = _clip_parc(cm, 2);
	char * pchar   = _clip_parc(cm, 3);
	guint accel_key = 0;
	GtkWidget *wid = NULL;
	C_widget *cwid;
	CHECKOPT(1,MAP_t);
	CHECKOPT(2,CHARACTER_t); CHECKOPT(3,CHARACTER_t);

	if (pchar)
	{
		char *pc;
		for (pc = text;pc && *pc; pc++)
			if (*pc == *pchar)
				*pc='_';
	}
	LOCALE_TO_UTF(text);
	wid = gtk_label_new(text);
	if (!wid) goto err;
	if (pchar)
		accel_key = gtk_label_parse_uline(GTK_LABEL(wid),text);
	FREE_TEXT(text);

	cwid = _register_widget(cm, wid, cv);
	_clip_mclone(cm,RETPTR(cm),&cwid->obj);
	_clip_mputn(cm,&cwid->obj,HASH_ACCELKEY,accel_key);

	return 0;
err:
	return 1;
}
Beispiel #13
0
/* Signals table */
static    gint
handle_size_allocate_signal(GtkMenuItem * menuitem, gint size_allocate, C_signal * cs)
{
   PREPARECV(cs, cv);
   _clip_mputn(cs->cw->cmachine, &cv, HASH_SIZE_ALLOCATE, size_allocate);
   INVOKESIGHANDLER(GTK_WIDGET(menuitem), cs, cv);
}
Beispiel #14
0
/* Sets the text within the GtkLabel widget. It overwrites any text that was
 * there before. Note that underlines that were there before do not get
 * overwritten. If you want to erase underlines just send NULL to
 * gtk_label_set_pattern().  */
int
clip_GTK_LABELSETTEXT(ClipMachine * ClipMachineMemory)
{
   C_widget *clbl = _fetch_cw_arg(ClipMachineMemory);

   char     *text = _clip_parc(ClipMachineMemory, 2);

   char     *pchar = _clip_parc(ClipMachineMemory, 3);

   guint     accel_key = 0;

   CHECKCWID(clbl, GTK_IS_LABEL);
   CHECKOPT(2, CHARACTER_type_of_ClipVarType);
   CHECKOPT(3, CHARACTER_type_of_ClipVarType);
   if (_clip_parinfo(ClipMachineMemory, 2) == UNDEF_type_of_ClipVarType)
      text = "\0";
   LOCALE_TO_UTF(text);
   gtk_label_set_text(GTK_LABEL(clbl->widget), text);
   if (pchar)
    {
       char     *pc;

       for (pc = text; pc && *pc; pc++)
	  if (*pc == *pchar)
	     *pc = '_';
       accel_key = gtk_label_parse_uline(GTK_LABEL(clbl->widget), text);
    }
   FREE_TEXT(text);
   _clip_mputn(ClipMachineMemory, &clbl->obj, HASH_ACCELKEY, accel_key);
   return 0;
 err:
   return 1;
}
Beispiel #15
0
static    gint
handle_change_value_signal(GtkSpinButton * sbutton, GtkScrollType * type, C_signal * cs)
{
   PREPARECV(cs, cv);
   _clip_mputn(cs->cw->cmachine, &cv, HASH_SCROLL_TYPE, (gint) type);
   INVOKESIGHANDLER(GTK_WIDGET(sbutton), cs, cv);
}
Beispiel #16
0
/**** BUTTON constructor ****/
int
clip_GTK_BUTTONNEW(ClipMachine * ClipMachineMemory)
{
    ClipVar  *cv = _clip_spar(ClipMachineMemory, 1);

    char     *title = _clip_parc(ClipMachineMemory, 2);

    char     *pchar = _clip_parc(ClipMachineMemory, 3);

    GtkWidget *wid = NULL, *label = NULL;

    C_widget *cwid, *clabel = NULL;

    guint     accel_key = 0;

    CHECKOPT(1, MAP_type_of_ClipVarType);
    CHECKOPT(2, CHARACTER_type_of_ClipVarType);
    CHECKOPT(3, CHARACTER_type_of_ClipVarType);

    if (pchar)
    {
        unsigned char *pc;

        for (pc = (unsigned char *) title; pc && *pc; pc++)
            if (*pc == *pchar)
            {
                *pc = '_';
                accel_key = *(pc + 1);
            }
    }
    if (_clip_parinfo(ClipMachineMemory, 2) == CHARACTER_type_of_ClipVarType)
    {
        LOCALE_TO_UTF(title);
        wid = gtk_button_new_with_label(title);
        label = GTK_BIN(&(GTK_BUTTON(wid)->bin))->child;
        if (pchar)
            accel_key = gtk_label_parse_uline(GTK_LABEL(label), title);
        FREE_TEXT(title);
    }
    else
    {
        wid = gtk_button_new();
    }
    if (!wid)
        goto err;

    cwid = _register_widget(ClipMachineMemory, wid, cv);

    if (label)
        clabel = _register_widget(ClipMachineMemory, label, NULL);
    if (clabel)
        _clip_madd(ClipMachineMemory, &cwid->obj, HASH_LABEL, &clabel->obj);

    _clip_mclone(ClipMachineMemory, RETPTR(ClipMachineMemory), &cwid->obj);
    _clip_mputn(ClipMachineMemory, &cwid->obj, HASH_ACCELKEY, accel_key);

    return 0;
err:
    return 1;
}
Beispiel #17
0
static gint handler_scroll_child_signal (GtkScrolledWindow *swin, GtkScrollType type, gboolean arg2, C_signal *cs)
{
    PREPARECV(cs,cv);
    _clip_mputn(cs->cw->cmachine, &cv, HASH_SCROLLTYPE, type);
    _clip_mputl(cs->cw->cmachine, &cv, HASH_ARG2, arg2);
    INVOKESIGHANDLER(GTK_WIDGET(swin),cs,cv);
}
Beispiel #18
0
/* Signal handlers */
static    gint
handle_input_dialog_signal(GtkInputDialog * dialog, gint deviceid, C_signal * cs)
{
   PREPARECV(cs, cv);
   _clip_mputn(cs->cw->cmachine, &cv, HASH_DEVICEID, deviceid);
   INVOKESIGHANDLER(GTK_WIDGET(dialog), cs, cv);
}
Beispiel #19
0
/* Common signal handlers. It called from signal handler in C and passes it to CLIP */
CLIP_DLLEXPORT gint
handle_signals( GtkWidget *widget, C_signal *cs, ClipVar *cv )
{
	ClipVar stack[2];
	ClipVar res;
	int ret = TRUE;

	if (!cs) return ret;
	if (!cs->cw) return ret;
	memset( stack, 0, sizeof(stack) );
	_clip_mclone(cs->cw->cmachine, &stack[0], &cs->cw->obj);
	//stack[0] = cs->cw->obj;

	if (!cs->cw->sigenabled) return FALSE;

	if (cv && cv->t.type==MAP_t)
		stack[1] = *cv;
	else
		_clip_map(cs->cw->cmachine,&stack[1]);

	_clip_mputn(cs->cw->cmachine,&stack[1], HASH_EVENT, (double)cs->sigid);

	memset( &res, 0, sizeof(ClipVar) );
	if ( _clip_eval( cs->cw->cmachine, &(cs->cfunc), 2, stack, &res ) == 0 )
		ret = res.t.type == LOGICAL_t ? res.l.val : ret;
	_clip_destroy(cs->cw->cmachine, &res);

	//_clip_destroy(cw->cmachine, &stack[0]);
	//_clip_destroy(cw->cmachine, &stack[1]);
	return TRUE;
	//return ret;
}
Beispiel #20
0
/* Signals table */
static    gint
handle_action_activated_signal(GtkEntryCompletion * completion, gint index, C_signal * cs)
{
   OBJECTPREPARECV(cs, cv);
   _clip_mputn(cs->co->cmachine, &cv, HASH_INDEX, index);
   OBJECTINVOKESIGHANDLER(cs, cv);
}
Beispiel #21
0
CLIP_DLLEXPORT void
_list_put_cobject(ClipMachine * cm, void *pointer, C_object * cobj)
{
	if (widget_list->t.type != MAP_t)
		_clip_map(cm, widget_list);
	if (pointer)
		_clip_mputn(cm, widget_list, (long) pointer, (long) cobj);
}
Beispiel #22
0
void
_list_put_func(ClipMachine * cm, gint id, ClipVar * cfunc)
{
	if (func_list->t.type != MAP_t)
		_clip_map(cm, func_list);
	if (id)
		_clip_mputn(cm, func_list, (long) id, (long) cfunc);
}
Beispiel #23
0
void
_list_put_data(ClipMachine * cm, gint id, ClipVar * cdata)
{
	if (data_list->t.type != MAP_t)
		_clip_map(cm, data_list);
	if (id)
		_clip_mputn(cm, data_list, (long) id, (long) cdata);
}
Beispiel #24
0
CLIP_DLLEXPORT void
_list_put_action(ClipMachine * cm, void *pointer, ClipVar *cv)
{
	if (action_list->t.type != MAP_t)
		_clip_map(cm, action_list);
	if (pointer)
		_clip_mputn(cm, action_list, (long) pointer, (long) cv);
}
Beispiel #25
0
gint handle_tree_unselect_row_signal (GtkWidget *widget, GtkCTreeNode *node, gint column, C_signal *cs)
{
	C_object *cnode = (C_object*)_list_get_cobject(cs->cw->cmachine,node);
	PREPARECV(cs,cv);
	if (!cnode) cnode = _register_object(cs->cw->cmachine,node,GTK_TYPE_CTREE_NODE,NULL,NULL);
	if (cnode) _clip_madd(cs->cw->cmachine, &cv, HASH_NODE, &cnode->obj);
	_clip_mputn(cs->cw->cmachine, &cv, HASH_COLUMN, column+1);
	INVOKESIGHANDLER(widget,cs,cv);
}
Beispiel #26
0
CLIP_DLLEXPORT void
_file_filter_info_to_map (ClipMachine *cm, GtkFileFilterInfo *info, ClipVar *cv)
{

	_clip_mputn(cm, cv, HASH_CONTAINS, info->contains);
	_clip_mputc(cm, cv, HASH_FILENAME, (gchar *)info->filename, strlen(info->filename));
	_clip_mputc(cm, cv, HASH_URI, (gchar *)info->uri, strlen(info->uri));
	_clip_mputc(cm, cv, HASH_DISPLAY_NAME, (gchar *)info->display_name, strlen(info->display_name));
	_clip_mputc(cm, cv, HASH_MIME_TYPE, (gchar *)info->mime_type, strlen(info->mime_type));
}
Beispiel #27
0
CLIP_DLLEXPORT C_object *
_register_object(ClipMachine * cm, void * data, long clip_type, ClipVar * cv, coDestructor fDestroy)
{
	int handle = -1;
	C_object * cobj = (C_object*)calloc(1,sizeof(C_object));
	WTypeTable *wt_item;
	long clip_wtype = GTK_WIDGET_UNKNOWN;

	cobj->object = data;
	cobj->objtype = GTK_OBJ_OBJECT;
	cobj->cmachine = cm;
	cobj->type = clip_type;
	cobj->destroy = fDestroy;

	/* alena add signals to object */
	cobj->sigenabled = TRUE;
	cobj->usersigenabled = TRUE;
	cobj->evntenabled = TRUE;

	wt_item = _wtype_table_get(cobj->type);
	if (wt_item && wt_item->fclip_type) clip_wtype = wt_item->fclip_type();
	if (wt_item && wt_item->ftype_name) cobj->type_name = wt_item->ftype_name();
	if (cv && cv->t.type == MAP_t)
		//_clip_mclone(cm, &cobj->obj, cv);
		cobj->obj = *cv;
	else
		_clip_map(cm, &cobj->obj);

	/* Saving widget info into CLIP state machine
	 * and it`s handle to a map HANDLE property */
	handle = _clip_store_c_item(cm, cobj, _C_ITEM_TYPE_WIDGET, NULL);
	cobj->handle = handle;
	_clip_mputn(cm, &cobj->obj, HASH_HANDLE, handle);
	_clip_mputn(cm, &cobj->obj, HASH_TYPE, clip_wtype);
	/* Store C_object pointer in list of widgets */
	_list_put_cobject(cm, data, cobj);
  	if (data && clip_type != GDK_TYPE_ATOM && clip_type != GTK_TYPE_TREE_ITER && clip_type != GTK_TYPE_TREE_PATH && clip_type != GTK_TYPE_SELECTION_DATA)

  		if (G_IS_OBJECT(data)) g_object_set_data_full(G_OBJECT(data),"destructor",cobj,
			(GDestroyNotify)object_destructor);
	return cobj;
}
Beispiel #28
0
static    gint
handle_widget_selected_signal(GtkWidget * widget, GtkWidget * wid,
			      gchar * tip_text, gchar * tip_private, GdkEventButton * event, C_signal * cs)
{
   C_widget *cwid = _list_get_cwidget(cs->cw->cmachine, wid);

   PREPARECV(cs, cv);
   if (!cwid)
      cwid = _register_widget(cs->cw->cmachine, wid, NULL);
   if (cwid)
      _clip_madd(cs->cw->cmachine, &cv, HASH_WIDGET, &cwid->obj);
   LOCALE_FROM_UTF(tip_text);
   LOCALE_FROM_UTF(tip_private);
   _clip_mputc(cs->cw->cmachine, &cv, HASH_TIPTEXT, tip_text, strlen(tip_text));
   _clip_mputc(cs->cw->cmachine, &cv, HASH_TIPPRIVATE, tip_private, strlen(tip_private));
   _clip_mputn(cs->cw->cmachine, &cv, HASH_BUTTON, event->button);
   _clip_mputn(cs->cw->cmachine, &cv, HASH_X, event->x);
   _clip_mputn(cs->cw->cmachine, &cv, HASH_Y, event->y);
   _clip_mputn(cs->cw->cmachine, &cv, HASH_XROOT, event->x_root);
   _clip_mputn(cs->cw->cmachine, &cv, HASH_YROOT, event->y_root);
   _clip_mputn(cs->cw->cmachine, &cv, HASH_STATE, event->state);
   FREE_TEXT(tip_text);
   FREE_TEXT(tip_private);
   INVOKESIGHANDLER(widget, cs, cv);
}
Beispiel #29
0
CLIP_DLLEXPORT C_widget *
_register_widget(ClipMachine * cm, GtkWidget * wid, ClipVar * cv)
{
	int handle = -1;
	C_widget * cwid = (C_widget*)calloc(1,sizeof(C_widget));
	WTypeTable *wt_item;
	long clip_wtype = GTK_WIDGET_UNKNOWN;
	cwid->widget = wid;
	cwid->objtype = GTK_OBJ_WIDGET;
	cwid->cmachine = cm;

	cwid->type = wid ? GTK_WIDGET_TYPE(wid) : GTK_TYPE_INVALID;
	wt_item = _wtype_table_get(cwid->type);
	if (wt_item && wt_item->fclip_type) clip_wtype = wt_item->fclip_type();
	if (wt_item && wt_item->ftype_name) cwid->type_name = wt_item->ftype_name();

	cwid->sigenabled = TRUE;
	cwid->usersigenabled = TRUE;
	cwid->evntenabled = TRUE;
	cwid->destroy = NULL;

	if (cv && cv->t.type == MAP_t)
		//_clip_mclone(cm, &cwid->obj, cv);
		cwid->obj = *cv;
	else
		_clip_map(cm, &cwid->obj);
	/* Saving widget info into CLIP state machine
	 * and it`s handle to a map HANDLE property */
	handle = _clip_store_c_item(cm, cwid, _C_ITEM_TYPE_WIDGET, NULL);
	cwid->handle = handle;
	_clip_mputn(cm, &cwid->obj, HASH_HANDLE, handle);
	_clip_mputn(cm, &cwid->obj, HASH_TYPE, clip_wtype);
	/* Store C_widget pointer in list of widgets */
	_list_put_cwidget(cm, wid, cwid);
	//if (wid && GTK_IS_OBJECT(wid))
	if (wid && GTK_IS_WIDGET(wid))
		g_object_set_data_full(G_OBJECT(wid),"destructor",cwid,
			(GDestroyNotify)widget_destructor);
	return cwid;
}
Beispiel #30
0
/* Returns a map with fields RED, GREEN and BLUE */
int
clip_GDK_COLORRGB(ClipMachine * cm)
{
	long RGB = _clip_parnl(cm,1);
	CHECKOPT(1,NUMERIC_t);
	if (_clip_parinfo(cm,1) != UNDEF_t)
	{
		ClipVar *ret = RETPTR(cm);
		memset(ret, 0, sizeof(*ret)); _clip_map(cm, ret);
		_clip_mputn(cm, ret, HASH_RED, (RGB & 0xFF) << 8);
		_clip_mputn(cm, ret, HASH_GREEN, ((RGB >> 8) & 0xFF) << 8);
		_clip_mputn(cm, ret, HASH_BLUE, ((RGB >> 16) & 0xFF) << 8);
	}