1 /*
2 * Copyright © 2009, 2010 Christian Persch <chpe@src.gnome.org>
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <config.h>
19
20 #include "ar-style.h"
21 #include "ar-style-private.h"
22
23 #include "ar-debug.h"
24
25 enum
26 {
27 PROP_0,
28 PROP_CARD_OVERHANG,
29 PROP_CARD_SLOT_RATIO,
30 PROP_CARD_STEP,
31 PROP_CARD_THEME,
32 PROP_CLICK_TO_MOVE,
33 PROP_DND_DRAG_THRESHOLD,
34 PROP_DOUBLE_CLICK_TIME,
35 PROP_ENABLE_ANIMATIONS,
36 PROP_ENABLE_SOUND,
37 PROP_FOCUS_LINE_WIDTH,
38 PROP_FOCUS_PADDING,
39 PROP_INTERIOR_FOCUS,
40 PROP_RTL,
41 PROP_SELECTION_COLOR,
42 PROP_SHOW_TOOLTIPS,
43 PROP_SHOW_STATUS_MESSAGES,
44 PROP_TOUCHSCREEN_MODE
45 };
46
47 /* private functions */
48
49 /* GObjectClass impl */
50
G_DEFINE_TYPE(ArStyle,ar_style,G_TYPE_OBJECT)51 G_DEFINE_TYPE (ArStyle, ar_style, G_TYPE_OBJECT)
52
53 static void
54 ar_style_init (ArStyle *style)
55 {
56 ArStylePrivate *priv;
57
58 priv = style->priv = G_TYPE_INSTANCE_GET_PRIVATE (style, AR_TYPE_STYLE, ArStylePrivate);
59
60 priv->selection_color = default_selection_color;
61 priv->card_slot_ratio = DEFAULT_CARD_SLOT_RATIO;
62 priv->card_overhang = DEFAULT_CARD_OVERHANG;
63 priv->card_step = DEFAULT_CARD_STEP;
64 priv->dnd_drag_threshold = 8;
65 priv->double_click_time = 250;
66 priv->focus_line_width = 1;
67 priv->focus_padding = 1;
68 priv->enable_animations_gtk = FALSE;
69 priv->enable_animations = FALSE;
70 priv->enable_sound_gtk = FALSE;
71 priv->enable_sound = FALSE;
72 priv->touchscreen_mode = FALSE;
73 priv->rtl = FALSE;
74 priv->interior_focus = FALSE;
75 priv->click_to_move = FALSE;
76 priv->enable_tooltips = DEFAULT_SHOW_TOOLTIPS;
77 priv->enable_status_messages = DEFAULT_SHOW_STATUS_MESSAGES;
78 }
79
80 static void
ar_style_finalize(GObject * object)81 ar_style_finalize (GObject *object)
82 {
83 ArStyle *style = AR_STYLE (object);
84 ArStylePrivate *priv = style->priv;
85
86 if (priv->card_theme) {
87 g_object_unref (priv->card_theme);
88 }
89
90 G_OBJECT_CLASS (ar_style_parent_class)->finalize (object);
91 }
92
93 static void
ar_style_get_property(GObject * object,guint property_id,GValue * value,GParamSpec * pspec)94 ar_style_get_property (GObject *object,
95 guint property_id,
96 GValue *value,
97 GParamSpec *pspec)
98 {
99 ArStyle *style = AR_STYLE (object);
100 ArStylePrivate *priv = style->priv;
101
102 switch (property_id) {
103 case PROP_CARD_OVERHANG:
104 g_value_set_double (value, ar_style_get_card_overhang (style));
105 break;
106
107 case PROP_CARD_SLOT_RATIO:
108 g_value_set_double (value, ar_style_get_card_slot_ratio (style));
109 break;
110
111 case PROP_CARD_STEP:
112 g_value_set_double (value, ar_style_get_card_step (style));
113 break;
114
115 case PROP_CARD_THEME:
116 g_value_set_object (value, ar_style_get_card_theme (style));
117 break;
118
119 case PROP_CLICK_TO_MOVE:
120 g_value_set_boolean (value, ar_style_get_click_to_move (style));
121 break;
122
123 case PROP_DND_DRAG_THRESHOLD:
124 g_value_set_int (value, priv->dnd_drag_threshold);
125 break;
126
127 case PROP_DOUBLE_CLICK_TIME:
128 g_value_set_int (value, ar_style_get_double_click_time (style));
129 break;
130
131 case PROP_ENABLE_ANIMATIONS:
132 g_value_set_boolean (value, ar_style_get_enable_animations (style));
133 break;
134
135 case PROP_ENABLE_SOUND:
136 g_value_set_boolean (value, ar_style_get_enable_sound (style));
137 break;
138
139 case PROP_FOCUS_LINE_WIDTH:
140 g_value_set_int (value, ar_style_get_focus_line_width (style));
141 break;
142
143 case PROP_FOCUS_PADDING:
144 g_value_set_int (value, ar_style_get_focus_padding (style));
145 break;
146
147 case PROP_INTERIOR_FOCUS:
148 g_value_set_boolean (value, ar_style_get_interior_focus (style));
149 break;
150
151 case PROP_RTL:
152 g_value_set_boolean (value, ar_style_get_rtl (style));
153 break;
154
155 case PROP_SELECTION_COLOR:
156 g_value_set_boxed (value, &priv->selection_color);
157 break;
158
159 case PROP_SHOW_TOOLTIPS:
160 g_value_set_boolean (value, ar_style_get_show_tooltips (style));
161 break;
162
163 case PROP_SHOW_STATUS_MESSAGES:
164 g_value_set_boolean (value, ar_style_get_show_status_messages (style));
165 break;
166
167 case PROP_TOUCHSCREEN_MODE:
168 g_value_set_boolean (value, ar_style_get_touchscreen_mode (style));
169 break;
170
171 default:
172 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
173 }
174 }
175
176 static void
ar_style_set_property(GObject * object,guint property_id,const GValue * value,GParamSpec * pspec)177 ar_style_set_property (GObject *object,
178 guint property_id,
179 const GValue *value,
180 GParamSpec *pspec)
181 {
182 ArStyle *style = AR_STYLE (object);
183 ArStylePrivate *priv = style->priv;
184
185 switch (property_id) {
186 case PROP_CARD_OVERHANG:
187 priv->card_overhang = g_value_get_double (value);
188 break;
189
190 case PROP_CARD_SLOT_RATIO:
191 priv->card_slot_ratio = g_value_get_double (value);
192 break;
193
194 case PROP_CARD_STEP:
195 priv->card_step = g_value_get_double (value);
196 break;
197
198 case PROP_CARD_THEME:
199 ar_style_set_card_theme (style, g_value_get_object (value));
200 break;
201
202 case PROP_CLICK_TO_MOVE:
203 ar_style_set_click_to_move (style, g_value_get_boolean (value));
204 break;
205
206 case PROP_DND_DRAG_THRESHOLD:
207 priv->dnd_drag_threshold = g_value_get_int (value);
208 break;
209
210 case PROP_DOUBLE_CLICK_TIME:
211 priv->double_click_time = g_value_get_int (value);
212 break;
213
214 case PROP_ENABLE_ANIMATIONS:
215 ar_style_set_enable_animations (style, g_value_get_boolean (value));
216 break;
217
218 case PROP_FOCUS_LINE_WIDTH:
219 priv->focus_line_width = g_value_get_int (value);
220 break;
221
222 case PROP_FOCUS_PADDING:
223 priv->focus_padding = g_value_get_int (value);
224 break;
225
226 case PROP_INTERIOR_FOCUS:
227 priv->interior_focus = g_value_get_boolean (value) != FALSE;
228 break;
229
230 case PROP_RTL:
231 priv->rtl = g_value_get_boolean (value) != FALSE;
232 break;
233
234 case PROP_SELECTION_COLOR: {
235 const GdkRGBA *color;
236
237 if ((color = g_value_get_boxed (value)) != NULL) {
238 priv->selection_color = *color;
239 } else {
240 priv->selection_color = default_selection_color;
241 }
242 break;
243 }
244
245 case PROP_ENABLE_SOUND:
246 ar_style_set_enable_sound (style, g_value_get_boolean (value));
247 break;
248
249 case PROP_SHOW_TOOLTIPS:
250 priv->enable_tooltips = g_value_get_boolean (value) != FALSE;
251 break;
252
253 case PROP_SHOW_STATUS_MESSAGES:
254 priv->enable_status_messages = g_value_get_boolean (value) != FALSE;
255 break;
256
257 case PROP_TOUCHSCREEN_MODE:
258 priv->touchscreen_mode = g_value_get_boolean (value) != FALSE;
259 break;
260
261 default:
262 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
263 }
264 }
265
266 static void
ar_style_class_init(ArStyleClass * klass)267 ar_style_class_init (ArStyleClass *klass)
268 {
269 GObjectClass *object_class = G_OBJECT_CLASS (klass);
270
271 g_type_class_add_private (klass, sizeof (ArStylePrivate));
272
273 object_class->set_property = ar_style_set_property;
274 object_class->get_property = ar_style_get_property;
275 object_class->finalize = ar_style_finalize;
276
277 g_object_class_install_property
278 (object_class,
279 PROP_CARD_SLOT_RATIO,
280 g_param_spec_double (AR_STYLE_PROP_CARD_SLOT_RATIO, NULL, NULL,
281 0.1, 1.0, DEFAULT_CARD_SLOT_RATIO,
282 G_PARAM_READWRITE |
283 G_PARAM_STATIC_STRINGS));
284
285 /**
286 * ArStyle:card-overhang:
287 *
288 * This controls how much of a card is allowed to hang off of the bottom
289 * of the screen. If set to %0.0, the last card is always fully visible.
290 */
291 g_object_class_install_property
292 (object_class,
293 PROP_CARD_OVERHANG,
294 g_param_spec_double (AR_STYLE_PROP_CARD_OVERHANG, NULL, NULL,
295 0.0, 1.0, DEFAULT_CARD_OVERHANG,
296 G_PARAM_READWRITE |
297 G_PARAM_STATIC_STRINGS));
298
299 /**
300 * ArStyle:card-step:
301 *
302 * This controls how much one card is offset the previous one in card stacks.
303 * A game-specified a value for the card step takes precedence over this.
304 */
305 g_object_class_install_property
306 (object_class,
307 PROP_CARD_STEP,
308 g_param_spec_double (AR_STYLE_PROP_CARD_STEP, NULL, NULL,
309 MIN_CARD_STEP, MAX_CARD_STEP, DEFAULT_CARD_STEP,
310 G_PARAM_READWRITE |
311 G_PARAM_STATIC_STRINGS));
312
313 g_object_class_install_property
314 (object_class,
315 PROP_CARD_THEME,
316 g_param_spec_object (AR_STYLE_PROP_CARD_THEME, NULL, NULL,
317 AR_TYPE_CARD_THEME,
318 G_PARAM_READWRITE |
319 G_PARAM_STATIC_STRINGS));
320
321 g_object_class_install_property
322 (object_class,
323 PROP_CLICK_TO_MOVE,
324 g_param_spec_boolean (AR_STYLE_PROP_CLICK_TO_MOVE, NULL, NULL,
325 FALSE,
326 G_PARAM_READWRITE |
327 G_PARAM_STATIC_STRINGS));
328
329 g_object_class_install_property
330 (object_class,
331 PROP_DND_DRAG_THRESHOLD,
332 g_param_spec_int (AR_STYLE_PROP_DND_DRAG_THRESHOLD, NULL, NULL,
333 1, G_MAXINT, 8,
334 G_PARAM_READWRITE |
335 G_PARAM_STATIC_STRINGS));
336
337 g_object_class_install_property
338 (object_class,
339 PROP_DOUBLE_CLICK_TIME,
340 g_param_spec_int (AR_STYLE_PROP_DOUBLE_CLICK_TIME, NULL, NULL,
341 0, G_MAXINT, 250,
342 G_PARAM_READWRITE |
343 G_PARAM_STATIC_STRINGS));
344
345 g_object_class_install_property
346 (object_class,
347 PROP_ENABLE_ANIMATIONS,
348 g_param_spec_boolean (AR_STYLE_PROP_ENABLE_ANIMATIONS, NULL, NULL,
349 FALSE,
350 G_PARAM_READWRITE |
351 G_PARAM_STATIC_STRINGS));
352
353 g_object_class_install_property
354 (object_class,
355 PROP_ENABLE_SOUND,
356 g_param_spec_boolean (AR_STYLE_PROP_ENABLE_SOUND, NULL, NULL,
357 FALSE,
358 G_PARAM_READWRITE |
359 G_PARAM_STATIC_STRINGS));
360
361 g_object_class_install_property
362 (object_class,
363 PROP_FOCUS_LINE_WIDTH,
364 g_param_spec_int (AR_STYLE_PROP_FOCUS_LINE_WIDTH, NULL, NULL,
365 0, G_MAXINT, 1,
366 G_PARAM_READWRITE |
367 G_PARAM_STATIC_STRINGS));
368
369 g_object_class_install_property
370 (object_class,
371 PROP_FOCUS_PADDING,
372 g_param_spec_int (AR_STYLE_PROP_FOCUS_PADDING, NULL, NULL,
373 0, G_MAXINT, 1,
374 G_PARAM_READWRITE |
375 G_PARAM_STATIC_STRINGS));
376
377 g_object_class_install_property
378 (object_class,
379 PROP_INTERIOR_FOCUS,
380 g_param_spec_boolean (AR_STYLE_PROP_INTERIOR_FOCUS, NULL, NULL,
381 FALSE,
382 G_PARAM_READWRITE |
383 G_PARAM_STATIC_STRINGS));
384
385 g_object_class_install_property
386 (object_class,
387 PROP_RTL,
388 g_param_spec_boolean (AR_STYLE_PROP_RTL, NULL, NULL,
389 FALSE,
390 G_PARAM_READWRITE |
391 G_PARAM_STATIC_STRINGS));
392
393 g_object_class_install_property
394 (object_class,
395 PROP_SELECTION_COLOR,
396 g_param_spec_boxed (AR_STYLE_PROP_SELECTION_COLOR, NULL, NULL,
397 GDK_TYPE_RGBA,
398 G_PARAM_READWRITE |
399 G_PARAM_STATIC_STRINGS));
400
401 /**
402 * ArStyle:show-tooltips:
403 *
404 * Whether to show tooltips on the cards and slots.
405 */
406 g_object_class_install_property
407 (object_class,
408 PROP_SHOW_TOOLTIPS,
409 g_param_spec_boolean (AR_STYLE_PROP_SHOW_TOOLTIPS, NULL, NULL,
410 DEFAULT_SHOW_TOOLTIPS,
411 G_PARAM_READWRITE |
412 G_PARAM_STATIC_STRINGS));
413
414 /**
415 * ArStyle:show-status-messages:
416 *
417 * Whether to show status messages on motion over the cards and slots.
418 */
419 g_object_class_install_property
420 (object_class,
421 PROP_SHOW_STATUS_MESSAGES,
422 g_param_spec_boolean (AR_STYLE_PROP_SHOW_STATUS_MESSAGES, NULL, NULL,
423 DEFAULT_SHOW_STATUS_MESSAGES,
424 G_PARAM_READWRITE |
425 G_PARAM_STATIC_STRINGS));
426
427 g_object_class_install_property
428 (object_class,
429 PROP_TOUCHSCREEN_MODE,
430 g_param_spec_boolean (AR_STYLE_PROP_TOUCHSCREEN_MODE, NULL, NULL,
431 FALSE,
432 G_PARAM_READWRITE |
433 G_PARAM_STATIC_STRINGS));
434 }
435
436 /* private API */
437
438 /* public API */
439
440 /**
441 * ar_style_new:
442 *
443 * Return value:
444 */
445 ArStyle*
ar_style_new(void)446 ar_style_new (void)
447 {
448 return g_object_new (AR_TYPE_STYLE, NULL);
449 }
450
451 /**
452 * ar_style_get_enable_animations:
453 * @style: an #ArStyle
454 *
455 * Returns: whether animations are enabled
456 */
457 gboolean
ar_style_get_enable_animations(ArStyle * style)458 ar_style_get_enable_animations (ArStyle *style)
459 {
460 ArStylePrivate *priv = style->priv;
461
462 return priv->enable_animations && priv->enable_animations_gtk;
463 }
464
465 /**
466 * ar_style_set_enable_animations:
467 * @style: an #ArStyle
468 * @enable: whether to enable animations
469 *
470 * Note that animations are only used when this the
471 * global gtk-enable-animations setting is enabled as well.
472 */
473 void
ar_style_set_enable_animations(ArStyle * style,gboolean enable)474 ar_style_set_enable_animations (ArStyle *style,
475 gboolean enable)
476 {
477 ArStylePrivate *priv = style->priv;
478
479 enable = enable != FALSE;
480 if (priv->enable_animations == enable)
481 return;
482
483 priv->enable_animations = enable;
484 g_object_notify (G_OBJECT (style), AR_STYLE_PROP_ENABLE_ANIMATIONS);
485 }
486
487 /**
488 * ar_style_get_enable_sound:
489 * @style: an #ArStyle
490 *
491 * Returns: whether sound is enabled
492 */
493 gboolean
ar_style_get_enable_sound(ArStyle * style)494 ar_style_get_enable_sound (ArStyle *style)
495 {
496 ArStylePrivate *priv = style->priv;
497
498 return priv->enable_sound && priv->enable_sound_gtk;
499 }
500
501 /**
502 * ar_style_set_enable_sound:
503 * @style: an #ArStyle
504 * @enable: whether to enable sound
505 *
506 * Note that sound is only used when this the
507 * global gtk-enable-event-sounds setting is enabled as well.
508 */
509 void
ar_style_set_enable_sound(ArStyle * style,gboolean enable)510 ar_style_set_enable_sound (ArStyle *style,
511 gboolean enable)
512 {
513 ArStylePrivate *priv = style->priv;
514
515 enable = enable != FALSE;
516 if (priv->enable_sound == enable)
517 return;
518
519 priv->enable_sound = enable;
520 g_object_notify (G_OBJECT (style), AR_STYLE_PROP_ENABLE_SOUND);
521 }
522
523 /**
524 * ar_style_get_click_to_move:
525 * @style: an #ArStyle
526 *
527 * Returns: whether sound is enabled
528 */
529 gboolean
ar_style_get_click_to_move(ArStyle * style)530 ar_style_get_click_to_move (ArStyle *style)
531 {
532 ArStylePrivate *priv = style->priv;
533
534 return priv->click_to_move;
535 }
536
537 /**
538 * ar_style_set_click_to_move:
539 * @style: an #ArStyle
540 * @enable: whether to enable sound
541 *
542 * Note that sound is only used when this the
543 * global gtk-enable-event-sounds setting is enabled as well.
544 */
545 void
ar_style_set_click_to_move(ArStyle * style,gboolean enable)546 ar_style_set_click_to_move (ArStyle *style,
547 gboolean enable)
548 {
549 ArStylePrivate *priv = style->priv;
550
551 enable = enable != FALSE;
552 if (priv->click_to_move == enable)
553 return;
554
555 priv->click_to_move = enable;
556 g_object_notify (G_OBJECT (style), AR_STYLE_PROP_CLICK_TO_MOVE);
557 }
558
559 /**
560 * ar_style_get_card_theme:
561 * @style: an #ArStyle
562 *
563 * Returns: @style's #ArCardTheme
564 */
565 ArCardTheme *
ar_style_get_card_theme(ArStyle * style)566 ar_style_get_card_theme (ArStyle *style)
567 {
568 ArStylePrivate *priv = style->priv;
569
570 return priv->card_theme;
571 }
572
573 /**
574 * ar_style_set_card_theme:
575 * @style: an #ArStyle
576 * @card_theme: a #ArCardTheme
577 *
578 * Note that animations are only used when this the
579 * global gtk-enable-animations setting is enabled as well.
580 */
581 void
ar_style_set_card_theme(ArStyle * style,ArCardTheme * theme)582 ar_style_set_card_theme (ArStyle *style,
583 ArCardTheme *theme)
584 {
585 ArStylePrivate *priv = style->priv;
586
587 if (priv->card_theme == theme)
588 return;
589
590 if (priv->card_theme != NULL) {
591 g_object_unref (priv->card_theme);
592 }
593 priv->card_theme = g_object_ref (theme);
594
595 g_object_notify (G_OBJECT (style), AR_STYLE_PROP_CARD_THEME);
596 }
597
598 /**
599 * ar_style_get_touchscreen_mode:
600 * @style: an #ArStyle
601 *
602 * Returns: whether sound is enabled
603 */
604 gboolean
ar_style_get_touchscreen_mode(ArStyle * style)605 ar_style_get_touchscreen_mode (ArStyle *style)
606 {
607 ArStylePrivate *priv = style->priv;
608
609 return priv->touchscreen_mode;
610 }
611
612 /**
613 * ar_style_get_interior_focus:
614 * @style: an #ArStyle
615 *
616 * Returns:
617 */
618 gboolean
ar_style_get_interior_focus(ArStyle * style)619 ar_style_get_interior_focus (ArStyle *style)
620 {
621 ArStylePrivate *priv = style->priv;
622
623 return priv->interior_focus;
624 }
625
626 /**
627 * ar_style_get_rtl:
628 * @style: an #ArStyle
629 *
630 * Returns:
631 */
632 gboolean
ar_style_get_rtl(ArStyle * style)633 ar_style_get_rtl (ArStyle *style)
634 {
635 ArStylePrivate *priv = style->priv;
636
637 return priv->rtl;
638 }
639
640 /**
641 * ar_style_get_show_tooltips:
642 * @style: an #ArStyle
643 *
644 * Returns:
645 */
646 gboolean
ar_style_get_show_tooltips(ArStyle * style)647 ar_style_get_show_tooltips (ArStyle *style)
648 {
649 ArStylePrivate *priv = style->priv;
650
651 return priv->enable_tooltips;
652 }
653
654 /**
655 * ar_style_get_show_status_messages:
656 * @style: an #ArStyle
657 *
658 * Returns:
659 */
660 gboolean
ar_style_get_show_status_messages(ArStyle * style)661 ar_style_get_show_status_messages (ArStyle *style)
662 {
663 ArStylePrivate *priv = style->priv;
664
665 return priv->enable_status_messages;
666 }
667
668 /**
669 * ar_style_get_double_click_time:
670 * @style: an #ArStyle
671 *
672 * Returns: the double click time
673 */
674 int
ar_style_get_double_click_time(ArStyle * style)675 ar_style_get_double_click_time (ArStyle *style)
676 {
677 ArStylePrivate *priv = style->priv;
678
679 return priv->double_click_time;
680 }
681
682 /**
683 * ar_style_get_focus_line_width:
684 * @style: an #ArStyle
685 *
686 * Returns:
687 */
688 int
ar_style_get_focus_line_width(ArStyle * style)689 ar_style_get_focus_line_width (ArStyle *style)
690 {
691 ArStylePrivate *priv = style->priv;
692
693 return priv->focus_line_width;
694 }
695
696 /**
697 * ar_style_get_focus_padding:
698 * @style: an #ArStyle
699 *
700 * Returns:
701 */
ar_style_get_focus_padding(ArStyle * style)702 int ar_style_get_focus_padding (ArStyle *style)
703 {
704 ArStylePrivate *priv = style->priv;
705
706 return priv->focus_padding;
707 }
708
709 /**
710 * ar_style_get_card_slot_ratio:
711 * @style: an #ArStyle
712 *
713 * Returns:
714 */
715 double
ar_style_get_card_slot_ratio(ArStyle * style)716 ar_style_get_card_slot_ratio (ArStyle *style)
717 {
718 ArStylePrivate *priv = style->priv;
719
720 return priv->card_slot_ratio;
721 }
722
723 /**
724 * ar_style_get_card_overhang:
725 * @style: an #ArStyle
726 *
727 * Returns:
728 */
729 double
ar_style_get_card_overhang(ArStyle * style)730 ar_style_get_card_overhang (ArStyle *style)
731 {
732 ArStylePrivate *priv = style->priv;
733
734 return priv->card_overhang;
735 }
736
737 /**
738 * ar_style_get_card_step:
739 * @style: an #ArStyle
740 *
741 * Returns:
742 */
743 double
ar_style_get_card_step(ArStyle * style)744 ar_style_get_card_step (ArStyle *style)
745 {
746 ArStylePrivate *priv = style->priv;
747
748 return priv->card_step;
749 }
750
751 /**
752 * ar_style_get_selection_color:
753 * @style: an #ArStyle
754 * @color: location to store the color
755 *
756 */
757 void
ar_style_get_selection_color(ArStyle * style,GdkRGBA * const color)758 ar_style_get_selection_color (ArStyle *style,
759 GdkRGBA * const color)
760 {
761 ArStylePrivate *priv = style->priv;
762
763 *color = priv->selection_color;
764 }
765
766 /**
767 * ar_style_check_dnd_drag_threshold:
768 * @style:
769 * @x1:
770 * @y1:
771 * @x2:
772 * @y2:
773 *
774 * Checks whether the distance between (x1, y1) and (x2, y2) is
775 * greater than the drag threshold.
776 *
777 * Returns: %TRUE if the distance between the points is greater
778 * than the drag threshold
779 */
780 gboolean
ar_style_check_dnd_drag_threshold(ArStyle * style,float x1,float y1,float x2,float y2)781 ar_style_check_dnd_drag_threshold (ArStyle *style,
782 float x1,
783 float y1,
784 float x2,
785 float y2)
786 {
787 ArStylePrivate *priv = style->priv;
788
789 /* FIXMEchpe: are these coordinates pixels, or something else? */
790 /* FIXMEchpe: shouldn't this be (x2 - x1)**2 + (y2 - y1)**2 >= threshold**2 ? */
791 return (ABS (x2 - x1) > priv->dnd_drag_threshold ||
792 ABS (y2 - y1) > priv->dnd_drag_threshold);
793 }
794