Пример #1
0
int main(int argc, char *argv[])
{
	static char *dpyName = "";
	static char *theme = "default";
	static DAProgramOption op[] = {
		{"-d", "--display", "display to use", DOString, False, {&dpyName} },
		{"-t", "--theme", "icon theme", DOString, False, {&theme} }
	};

	DAParseArguments(argc, argv, op,
					 sizeof(op)/sizeof(DAProgramOption),
					 "",
					 PACKAGE_NAME " version " PACKAGE_VERSION);

	if (!wmvm_init_dockapp(dpyName, argc, argv, theme))
		return 1;

	if (!wmvm_do_udisks_init())
		return 1;

	wmvm_update_icon();

	wmvm_run_dockapp();

	return 0;
}
Пример #2
0
int
main(int argc, char **argv)
{
	unsigned int x = 1, y = 1;
	Pixmap back;
	DACallbacks eventCallbacks = {
		destroy, /* destroy */
		NULL, /* buttonPress */
		NULL, /* buttonRelease */
		NULL, /* motion (mouse) */
		NULL, /* mouse enters window */
		NULL, /* mouse leaves window */
		moveBall /* timeout */
	};

	/* provide standard command-line options */
	DAParseArguments(
		argc, argv, /* Where the options come from */
		NULL, 0, /* Our list with options - none as you can see */
		"This is the help text for the basic example of how to "
		"use libDockapp.\n",
		"Basic example version 1.1");

	/* Tell libdockapp what version we expect it to be (a date from
	 * NEWS should do).
	 */
	DASetExpectedVersion(20020126);

	DAOpenDisplay(
		NULL /* default display */,
		argc, argv /* needed by libdockapp */
		);
	DACreateIcon(
		"daBasicExample" /* WM_CLASS hint; don't use chars in [.?*: ] */,
		48, 48 /* geometry of dockapp internals */,
		argc, argv      /* needed by libdockapp */
		);

	/* The pixmap that makes up the background of the dockapp */
	back = DAMakePixmap();
	drawRelief(back);
	DASetPixmap(back);
	XFreePixmap(DADisplay, back);

	/* A window(!) for the ball pixmap.
	 * Moving a window is a lot easier then erasing/copying the pixmap all
	 * the time.
	 *
	 * I use a DAShapedPixmap here, which contains all the information
	 * related to the pixmap: pixmap, mask and geometry.
	 */
	ballPix = DAMakeShapedPixmapFromData(ball_red_xpm);
	ballWin = XCreateSimpleWindow(DADisplay, DAWindow,
				      x, y,
				      /* Use the geometry of the shaped pixmap */
				      ballPix->geometry.width, ballPix->geometry.height,
				      0, 0, 0);
	DASPSetPixmapForWindow(ballWin, ballPix);

	/* Respond to destroy and timeout events (the ones not NULL in the
	 * eventCallbacks variable.
	 */
	DASetCallbacks(&eventCallbacks);

	/* Set the time for timeout events (in msec) */
	DASetTimeout(SPEED);

	/* Randomize movement variation.
	 * Run multiple versions of the dockapp simultaneously to see the effect
	 * best.
	 * (which function to use is set from the Imakefile)
	 */
#ifdef HAS_RANDOMDEV
	srandomdev();
#else
	srandom(time(NULL));
#endif

	DAShow(); /* Show the dockapp window. */

	/* Process events and keep the dockapp running */
	DAEventLoop();

	/* not reached */
	exit(EXIT_SUCCESS);
}
Пример #3
0
/*
 * Function main (argc, )
 *
 *    Starts all the fun!
 *
 */
int main(int argc, char *argv[])
{
   obex_object_t *object;
   int ret;
   unsigned height,width;
   int i;

   DAParseArguments(argc, argv, options,
		    sizeof(options)/sizeof(DAProgramOption),
		    "CapShare Document Management Dock Applet\nBen Moore [email protected]\n",
		    VERSION);


   DAInitialize(displayName, "wmcapshare", 60,60, argc, argv);
   DAMakePixmapFromData(lcdchars2_xpm, &char_buf, &char_mask, &height, &width);
   DAMakePixmapFromData(lcdnums_xpm, &num_buf, &num_mask, &height, &width);
   DAMakePixmapFromData(base_xpm, &pixmap, &mask, &height, &width);
   DAMakePixmapFromData(tstatfld_xpm, &tstatfld_buf, &tstatfld_mask, &height, &width);
   DAMakePixmapFromData(tstatfld_xpm, &blank_buf, &blank_mask, &height, &width);
   DAMakePixmapFromData(capshare_xpm, &capshare_pic, &capshare_mask, &height, &width);
   DAMakePixmapFromData(transfering_xpm, &transfer_pic, &transfer_mask, &height, &width);
   DAMakePixmapFromData(connected_xpm, &connect_pic, &connect_mask, &height, &width);
   DAMakePixmapFromData(disconnected_xpm, &disconnect_pic, &disconnect_mask, &height, &width);
   DAMakePixmapFromData( plane00_xpm, &plane_anim[0], &plane_animmask[1], &height, &width);
   DAMakePixmapFromData( plane01_xpm, &plane_anim[1], &plane_animmask[2], &height, &width);
   DAMakePixmapFromData( plane02_xpm, &plane_anim[2], &plane_animmask[3], &height, &width);
   DAMakePixmapFromData( plane03_xpm, &plane_anim[3], &plane_animmask[4], &height, &width);
   DAMakePixmapFromData( plane04_xpm, &plane_anim[4], &plane_animmask[5], &height, &width);
   DAMakePixmapFromData( plane05_xpm, &plane_anim[5], &plane_animmask[6], &height, &width);
   DAMakePixmapFromData( plane06_xpm, &plane_anim[6], &plane_animmask[6], &height, &width);
   DAMakePixmapFromData( plane07_xpm, &plane_anim[7], &plane_animmask[7], &height, &width);
   DAMakePixmapFromData( plane08_xpm, &plane_anim[8], &plane_animmask[8], &height, &width);
   DAMakePixmapFromData( plane09_xpm, &plane_anim[9], &plane_animmask[9], &height, &width);
   DAMakePixmapFromData( plane10_xpm, &plane_anim[10], &plane_animmask[10], &height, &width);
   DAMakePixmapFromData( plane11_xpm, &plane_anim[11], &plane_animmask[11], &height, &width);
   DAMakePixmapFromData( plane12_xpm, &plane_anim[12], &plane_animmask[12], &height, &width);
   DAMakePixmapFromData( plane13_xpm, &plane_anim[13], &plane_animmask[13], &height, &width);
   DAMakePixmapFromData( plane14_xpm, &plane_anim[14], &plane_animmask[14], &height, &width);
   DAMakePixmapFromData( plane15_xpm, &plane_anim[15], &plane_animmask[15], &height, &width);
   DAMakePixmapFromData( plane16_xpm, &plane_anim[16], &plane_animmask[16], &height, &width);
   DAMakePixmapFromData( plane17_xpm, &plane_anim[17], &plane_animmask[17], &height, &width);
   DAMakePixmapFromData( plane18_xpm, &plane_anim[18], &plane_animmask[18], &height, &width);
   DAMakePixmapFromData( plane19_xpm, &plane_anim[19], &plane_animmask[19], &height, &width);

   gc = DefaultGC(DADisplay, DefaultScreen(DADisplay));


/*
 string2pixmap("recieve", &tstatfld_buf);
 XCopyArea(DADisplay, plane_pic, pixmap, gc, 0, 0, 60, 29, 0, 15);
 XCopyArea(DADisplay, tstatfld_buf, pixmap, gc, 0, 0, 42,  8, 16, 48);
 DASetPixmap(pixmap);
 XCopyArea(DADisplay, connect_pic, pixmap, gc, 0, 0, 14, 15, 0, 45);
 DASetPixmap(pixmap);
 */

   XCopyArea(DADisplay, capshare_pic, pixmap, gc, 0, 0, 60, 29,  0, 15);
   DAShow();

   while(1) {
      handle = OBEX_Init(OBEX_TRANS_IRDA, obex_event, 0);

      printf("Waiting for files\n");
      OBEX_ServerRegister(handle, "OBEX");

      while (!finished) {
	 updateDisplay();
	 OBEX_HandleInput(handle, 1);
      }

      finished = FALSE;
   }

   return 0;
}
Пример #4
0
int
main(int argc, char **argv)
{
	/* define the event handlers for the events */
	DACallbacks eventCallbacks = {
		destroy, /* destroy */
		buttonPress, /* buttonPress */
		buttonRelease, /* buttonRelease */
		mouseMove, /* motion (mouse) */
		mouseEnter, /* mouse enters window */
		mouseLeave, /* mouse leaves window */
		NULL    /* timeout */
	};

	/* define regions (x, y, width, height) that need event-handling */
	Region clipRegion = XCreateRegion();

	DARect btn = {0, 0, 16, 16},
	       square = {0, 25, 22, 22},
	       slider = {24, 0, 23, 48};

	/* define what to do if an event occurs in a rectangle */
	DAActionRect *buttonPressRects, *buttonReleaseRects,
	*mouseMoveRects, *mouseEnterRects, *mouseLeaveRects;

	buttonPressRects = malloc(3 * sizeof(DAActionRect));
	buttonPressRects[0] = setRectAction(btn, btnDown);
	buttonPressRects[1] = setRectAction(square, squareDown);
	buttonPressRects[2] = setRectAction(slider, sliderDown);

	buttonReleaseRects = malloc(2 * sizeof(DAActionRect));
	buttonReleaseRects[0] = setRectAction(btn, btnUp);
	buttonReleaseRects[1] = setRectAction(slider, sliderUp);

	mouseMoveRects = malloc(sizeof(DAActionRect));
	mouseMoveRects[0] = setRectAction(slider, sliderMove);

	mouseEnterRects = malloc(sizeof(DAActionRect));
	mouseEnterRects[0] = setRectAction(slider, sliderEnter);

	mouseLeaveRects = malloc(2 * sizeof(DAActionRect));
	mouseLeaveRects[0] = setRectAction(btn, btnLeave);
	mouseLeaveRects[1] = setRectAction(slider, sliderLeave);


	/* XXX: make action rectangles available outside main()
	 * ...libDockapp should be able to do this... (reminder)
	 */
	actionRects = malloc(6 * sizeof(DAActionRect *));
	actionRects[0] = buttonPressRects;
	actionRects[1] = buttonReleaseRects;
	actionRects[2] = mouseMoveRects;
	actionRects[3] = mouseEnterRects;
	actionRects[4] = mouseLeaveRects;
	actionRects[5] = NULL;

	/* provide standard command-line options */
	DAParseArguments(
		argc, argv, /* Where the options come from */
		NULL, 0, /* Our list with options - none as you can see */
		"This is the help text for the rectangle example of how to "
		"use libDockapp.\n",
		"Rectangle example version 1.0");

	/* Tell libdockapp what version we expect it to be, so that you can use
	 * older programs with newer versions of libdockapp with less risc for
	 * compatibility problems.
	 */
	DASetExpectedVersion(20030126);

	/* Initialize a dockapp */
	DAInitialize(
		"",             /* Use default display */
		"daRectangleExample",   /* WM_CLASS hint; don't use chars in [.?*: ] */
		48, 48,         /* geometry of dockapp internals */
		argc, argv      /* (needed internally) */
		);

	/* Create a pixmap to draw on, and to display */
	pixmap = DAMakePixmap(); /* size == dockapp geometry (48,48) */

	colors = setGCs(pixmap);

	XFillRectangle(DADisplay, pixmap, DAClearGC, 0, 0, 48, 48);
	XClearWindow(DADisplay, DAWindow);

	/* Make a "Region" from the shapes we have */
	XUnionRectWithRegion(&btn, clipRegion, clipRegion);
	XUnionRectWithRegion(&square, clipRegion, clipRegion);
	XUnionRectWithRegion(&slider, clipRegion, clipRegion);

	/* Make this region a window shape mask */
	XShapeCombineRegion(DADisplay, DAWindow, ShapeBounding,
			    0, 0, clipRegion, ShapeSet);

	/* We don't need the region anymore (it is copied by XShapeCombineRegion).
	 * XXX: That's not certain, it is not documented. XSetRegion does so,
	 * though, so it is a likely assumption that it does copy.
	 */
	XDestroyRegion(clipRegion);

	/* The cursor we want to use.
	 * Specify 'None' for the default,
	 * or one from X11/cursorfont.h
	 */
	pointer = XCreateFontCursor(DADisplay, XC_based_arrow_up);
	XDefineCursor(DADisplay, DAWindow, pointer);

	/* a square with an image that changes when clicked (A button). */
	createBtn(btn);

	/* a square that shows the number of the mouse-button pressed on click. */
	createSquare(square);

	/* a slider a using two dashed line GC's. */
	createSlider(slider);

	/* Tell libdockapp this is the pixmap that we want to show */
	DASetPixmap(pixmap);

	/* Process events every 100ms */
	DASetTimeout(100);

	/* set event callbacks */
	DASetCallbacks(&eventCallbacks);

	/* Display the pixmap we said it to show */
	DAShow();

	/* Process events and keep the dockapp running */
	DAEventLoop();

	return 0;
}