aboutsummaryrefslogtreecommitdiffstats
path: root/src/matchbox-stroke.c
blob: 692bcf5039e7702b9222f43f0eb879f6b556d812 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "matchbox-stroke.h"

MBStrokeStroke*
mb_stroke_current_stroke(MBStroke *stroke)
{
  return stroke->current_stroke;
}


MBStrokeMode*
mb_stroke_lookup_mode(MBStroke     *stroke, 
		      char         *name)
{
  MBStrokeMode *mode_item = stroke->modes;

  while (mode_item != NULL)
    {
      if (streq( mb_stroke_mode_name(mode_item), name))
	return mode_item;
      mode_item = mb_stroke_mode_next(mode_item);
    }

  return NULL;
}

MBStrokeMode*
mb_stroke_current_mode(MBStroke     *stroke)
{
  return stroke->current_mode;
}

MBStrokeMode*
mb_stroke_global_mode(MBStroke     *stroke)
{
  return stroke->global_mode;
}

MBStroke*
mb_stroke_app_new(int argc, char **argv)
{
  MBStroke *stroke = NULL;
  int       i;

  stroke = util_malloc0(sizeof(MBStroke));

  stroke->ui_mode = MBStrokeUIModeInputWin;

  for (i = 1; i < argc; i++) 
    {
      if (streq ("--fullscreen", argv[i]) || streq ("-fs", argv[i]))
	{
	  stroke->ui_mode = MBStrokeUIModeFullscreen;	      
	}
    }

  stroke->global_mode = mb_stroke_mode_new(stroke, 
					   "global");

  mb_stroke_add_mode(stroke, stroke->global_mode);

  if (!mb_stroke_config_load(stroke))
    return NULL;

  if (!matchbox_stroke_ui_init(stroke))
    return NULL;

  if (!matchbox_stroke_ui_realize(stroke->ui))
    return NULL;

  stroke->current_mode = stroke->global_mode;

  return stroke;
}

void
mb_stroke_run(MBStroke *stroke)
{
  mb_stroke_ui_event_loop(stroke->ui);
}

int
main(int argc, char **argv)
{
  MBStroke *stroke = NULL;

  stroke = mb_stroke_app_new(argc, argv);

  if (stroke)
    mb_stroke_run(stroke);

  return 1;
}