Advertisement
Guest User

hexclock.patch

a guest
May 20th, 2012
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 22.56 KB | None | 0 0
  1. diff --git a/plugins/clock/Makefile.am b/plugins/clock/Makefile.am
  2. index 923fb33..e0287d3 100644
  3. --- a/plugins/clock/Makefile.am
  4. +++ b/plugins/clock/Makefile.am
  5. @@ -25,7 +25,9 @@ libclock_la_SOURCES = \
  6.     clock-fuzzy.c \
  7.     clock-fuzzy.h \
  8.     clock-lcd.c \
  9. -   clock-lcd.h
  10. +   clock-lcd.h \
  11. +   clock-hex.c \
  12. +   clock-hex.h
  13.  
  14.  libclock_la_CFLAGS = \
  15.     $(GTK_CFLAGS) \
  16. diff --git a/plugins/clock/clock-dialog.glade b/plugins/clock/clock-dialog.glade
  17. index 68e9639..7f62476 100644
  18. --- a/plugins/clock/clock-dialog.glade
  19. +++ b/plugins/clock/clock-dialog.glade
  20. @@ -344,6 +344,43 @@
  21.                              <property name="position">8</property>
  22.                            </packing>
  23.                          </child>
  24. +                        <child>
  25. +                          <object class="GtkCheckButton" id="true-hex">
  26. +                            <property name="label" translatable="yes">True _hexadecimal time</property>
  27. +                            <property name="visible">True</property>
  28. +                            <property name="can_focus">True</property>
  29. +                            <property name="receives_default">False</property>
  30. +                            <property name="use_underline">True</property>
  31. +                            <property name="draw_indicator">True</property>
  32. +                          </object>
  33. +                          <packing>
  34. +                            <property name="position">1</property>
  35. +                          </packing>
  36. +                        </child>
  37. +                        <child>
  38. +                          <object class="GtkHBox" id="hex-box">
  39. +                            <property name="visible">True</property>
  40. +                            <property name="spacing">12</property>
  41. +                            <child>
  42. +                              <object class="GtkLabel" id="label9">
  43. +                                <property name="visible">True</property>
  44. +                                <property name="label" translatable="yes">F_ormat:</property>
  45. +                                <property name="use_underline">True</property>
  46. +                              </object>
  47. +                              <packing>
  48. +                                <property name="expand">False</property>
  49. +                                <property name="position">0</property>
  50. +                              </packing>
  51. +                            </child>
  52. +                            <child>
  53. +                              <object class="GtkEntry" id="hex-format">
  54. +                                <property name="visible">True</property>
  55. +                                <property name="text">5</property>
  56. +                                <property name="tooltip_text" translatable="yes">%H: hours, %X: maximes(true hex only), %M: minutes, %S: seconds (fake hex only). Case of identifier specifies digit case (0xa vs 0xA).</property>
  57. +                              </object>
  58. +                            </child>
  59. +                          </object>
  60. +                        </child>
  61.                        </object>
  62.                      </child>
  63.                    </object>
  64. @@ -436,6 +473,9 @@
  65.        <row>
  66.          <col id="0" translatable="yes">LCD</col>
  67.        </row>
  68. +      <row>
  69. +        <col id="0" translatable="yes">Hexadecimal</col>
  70. +      </row>
  71.      </data>
  72.    </object>
  73.  </interface>
  74. diff --git a/plugins/clock/clock-hex.c b/plugins/clock/clock-hex.c
  75. new file mode 100644
  76. index 0000000..5a756a5
  77. --- /dev/null
  78. +++ b/plugins/clock/clock-hex.c
  79. @@ -0,0 +1,496 @@
  80. +/*
  81. + * Copyright (C) 2007-2010 Nick Schermer <nick@xfce.org>
  82. + * Copyright (C)      2012 Jonas Kulla   <Nyocurio@gmail.com>
  83. + *
  84. + * This library is free software; you can redistribute it and/or modify it
  85. + * under the terms of the GNU General Public License as published by the Free
  86. + * Software Foundation; either version 2 of the License, or (at your option)
  87. + * any later version.
  88. + *
  89. + * This library is distributed in the hope that it will be useful, but WITHOUT
  90. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  91. + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  92. + * more details.
  93. + *
  94. + * You should have received a copy of the GNU Lesser General Public
  95. + * License along with this library; if not, write to the Free Software
  96. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  97. + */
  98. +
  99. +#ifdef HAVE_CONFIG_H
  100. +#include <config.h>
  101. +#endif
  102. +
  103. +#ifdef HAVE_TIME_H
  104. +#include <time.h>
  105. +#endif
  106. +
  107. +#include <gtk/gtk.h>
  108. +
  109. +#include "clock.h"
  110. +#include "clock-hex.h"
  111. +
  112. +#define DEFAULT_FONT_SIZE 10
  113. +
  114. +
  115. +struct xtm
  116. +{
  117. +  guint8 seconds : 4;
  118. +  guint8 minutes : 4;
  119. +  guint8 maximes : 4;
  120. +  guint8 hours   : 4;
  121. +};
  122. +
  123. +
  124. +static void     xfce_clock_hex_set_property      (GObject               *object,
  125. +                                                  guint                  prop_id,
  126. +                                                  const GValue          *value,
  127. +                                                  GParamSpec            *pspec);
  128. +static void     xfce_clock_hex_get_property      (GObject               *object,
  129. +                                                  guint                  prop_id,
  130. +                                                  GValue                *value,
  131. +                                                  GParamSpec            *pspec);
  132. +static void     xfce_clock_hex_finalize          (GObject               *object);
  133. +static gboolean xfce_clock_hex_update            (gpointer               user_data);
  134. +static void     xfce_clock_hex_update_font_size  (XfceClockHex          *hex);
  135. +
  136. +static void     xfce_clock_hex_tm_to_xtm         (const struct tm        *_tm,
  137. +                                                  struct xtm             *_xtm);
  138. +static gchar    xfce_clock_hex_uint_to_xchar     (guint                  u,
  139. +                                                  gboolean               upcase);
  140. +static gchar *  xfce_clock_hex_format_true_xtime (gchar                 *buffer,
  141. +                                                  gsize                  buffer_size,
  142. +                                                  const gchar           *format,
  143. +                                                  struct xtm            *xtime);
  144. +static gchar *  xfce_clock_hex_format_fake_xtime (gchar                 *buffer,
  145. +                                                  gsize                  buffer_size,
  146. +                                                  const gchar           *format,
  147. +                                                  struct tm             *_time);
  148. +void            xfce_clock_hex_write_hex_uint    (gchar                 **bufferp,
  149. +                                                  guint                  u,
  150. +                                                  gboolean               upcase,
  151. +                                                  gboolean               leading_zero);
  152. +
  153. +
  154. +
  155. +enum
  156. +{
  157. +  PROP_0,
  158. +  PROP_TRUE_HEX,
  159. +  PROP_HEX_FORMAT,
  160. +  PROP_FONT_SIZE,
  161. +  PROP_SIZE_RATIO,
  162. +  PROP_ORIENTATION
  163. +};
  164. +
  165. +struct _XfceClockHexClass
  166. +{
  167. + GtkLabelClass __parent__;
  168. +};
  169. +
  170. +struct _XfceClockHex
  171. +{
  172. +  GtkLabel __parent__;
  173. +
  174. +  ClockPluginTimeout *timeout;
  175. +
  176. +  guint true_hex : 1;
  177. +  gchar *format;
  178. +  guint font_size;
  179. +
  180. +  struct xtm xtime;
  181. +};
  182. +
  183. +
  184. +
  185. +XFCE_PANEL_DEFINE_TYPE (XfceClockHex, xfce_clock_hex, GTK_TYPE_LABEL)
  186. +
  187. +
  188. +
  189. +static void
  190. +xfce_clock_hex_class_init (XfceClockHexClass *klass)
  191. +{
  192. +  GObjectClass *gobject_class;
  193. +
  194. +  gobject_class = G_OBJECT_CLASS (klass);
  195. +  gobject_class->finalize = xfce_clock_hex_finalize;
  196. +  gobject_class->set_property = xfce_clock_hex_set_property;
  197. +  gobject_class->get_property = xfce_clock_hex_get_property;
  198. +
  199. +  g_object_class_install_property (gobject_class,
  200. +                                   PROP_SIZE_RATIO,
  201. +                                   g_param_spec_double ("size-ratio", NULL, NULL,
  202. +                                                        -1, G_MAXDOUBLE, 0.0,
  203. +                                                        G_PARAM_READABLE
  204. +                                                        | G_PARAM_STATIC_STRINGS));
  205. +
  206. +  g_object_class_install_property (gobject_class,
  207. +                                   PROP_ORIENTATION,
  208. +                                   g_param_spec_enum ("orientation", NULL, NULL,
  209. +                                                      GTK_TYPE_ORIENTATION,
  210. +                                                      GTK_ORIENTATION_HORIZONTAL,
  211. +                                                      G_PARAM_WRITABLE
  212. +                                                      | G_PARAM_STATIC_STRINGS));
  213. +
  214. +  g_object_class_install_property (gobject_class,
  215. +                                   PROP_TRUE_HEX,
  216. +                                   g_param_spec_boolean ("true-hex", NULL, NULL,
  217. +                                                         TRUE,
  218. +                                                         G_PARAM_READWRITE
  219. +                                                         | G_PARAM_STATIC_STRINGS));
  220. +
  221. +  g_object_class_install_property (gobject_class,
  222. +                                   PROP_HEX_FORMAT,
  223. +                                   g_param_spec_string ("hex-format", NULL, NULL,
  224. +                                                        DEFAULT_HEX_FORMAT,
  225. +                                                        G_PARAM_READWRITE
  226. +                                                        | G_PARAM_STATIC_STRINGS));
  227. +
  228. +  g_object_class_install_property (gobject_class,
  229. +                                   PROP_FONT_SIZE,
  230. +                                   g_param_spec_uint ("font-size", NULL, NULL,
  231. +                                                      DEFAULT_FONT_SIZE, 0, G_MAXUINT,
  232. +                                                      G_PARAM_READABLE
  233. +                                                      | G_PARAM_STATIC_STRINGS));
  234. +}
  235. +
  236. +
  237. +
  238. +static void
  239. +xfce_clock_hex_init (XfceClockHex *hex)
  240. +{
  241. +  hex->format = g_strdup (DEFAULT_HEX_FORMAT);
  242. +  hex->timeout = clock_plugin_timeout_new (CLOCK_INTERVAL_SECOND,  //FIXME: make this dependent on "true-hex"
  243. +                                           xfce_clock_hex_update,
  244. +                                           hex);
  245. +
  246. +  gtk_label_set_justify (GTK_LABEL (hex), GTK_JUSTIFY_CENTER);
  247. +  hex->font_size = DEFAULT_FONT_SIZE;
  248. +  xfce_clock_hex_update_font_size (hex);
  249. +}
  250. +
  251. +
  252. +
  253. +static void
  254. +xfce_clock_hex_set_property (GObject      *object,
  255. +                             guint         prop_id,
  256. +                             const GValue *value,
  257. +                             GParamSpec   *pspec)
  258. +{
  259. +  XfceClockHex *hex = XFCE_CLOCK_HEX (object);
  260. +
  261. +  switch (prop_id)
  262. +    {
  263. +    case PROP_ORIENTATION:
  264. +      gtk_label_set_angle (GTK_LABEL (object),
  265. +          g_value_get_enum (value) == GTK_ORIENTATION_HORIZONTAL ?
  266. +          0 : 270);
  267. +      break;
  268. +
  269. +    case PROP_TRUE_HEX:
  270. +     hex->true_hex = g_value_get_boolean (value);
  271. +     break;
  272. +
  273. +    case PROP_HEX_FORMAT:
  274. +      g_free (hex->format);
  275. +      hex->format = g_value_dup_string (value);
  276. +      break;
  277. +
  278. +    case PROP_FONT_SIZE:
  279. +      hex->font_size = g_value_get_uint (value);
  280. +      xfce_clock_hex_update_font_size (hex);
  281. +
  282. +    default:
  283. +      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
  284. +      break;
  285. +    }
  286. +
  287. +  /* reschedule the timeout and redraw */
  288. +  if (hex->true_hex)
  289. +  {
  290. +    clock_plugin_timeout_set_interval (hex->timeout,
  291. +                                       CLOCK_INTERVAL_SECOND);
  292. +  }
  293. +  else
  294. +  {
  295. +   clock_plugin_timeout_set_interval (hex->timeout,
  296. +      clock_plugin_interval_from_format (hex->format));
  297. +  }
  298. +
  299. +  xfce_clock_hex_update (hex);
  300. +}
  301. +
  302. +
  303. +
  304. +static void
  305. +xfce_clock_hex_get_property (GObject    *object,
  306. +                             guint       prop_id,
  307. +                             GValue     *value,
  308. +                             GParamSpec *pspec)
  309. +{
  310. +  XfceClockHex *hex = XFCE_CLOCK_HEX (object);
  311. +
  312. +  switch (prop_id)
  313. +    {
  314. +   case PROP_TRUE_HEX:
  315. +     g_value_set_boolean (value, hex->true_hex);
  316. +     break;
  317. +
  318. +    case PROP_HEX_FORMAT:
  319. +      g_value_set_string (value, hex->format);
  320. +      break;
  321. +
  322. +    case PROP_SIZE_RATIO:
  323. +      g_value_set_double (value, -1.0);
  324. +      break;
  325. +
  326. +    default:
  327. +      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
  328. +      break;
  329. +    }
  330. +}
  331. +
  332. +
  333. +
  334. +static void
  335. +xfce_clock_hex_finalize (GObject *object)
  336. +{
  337. +  XfceClockHex *hex = XFCE_CLOCK_HEX (object);
  338. +
  339. +  /* stop the timeout */
  340. +  clock_plugin_timeout_free (hex->timeout);
  341. +
  342. +  g_free (hex->format);
  343. +
  344. +  (*G_OBJECT_CLASS (xfce_clock_hex_parent_class)->finalize) (object);
  345. +}
  346. +
  347. +
  348. +
  349. +static gboolean
  350. +xfce_clock_hex_update (gpointer user_data)
  351. +{
  352. +  XfceClockHex *hex = XFCE_CLOCK_HEX (user_data);
  353. +  gchar         string[64];
  354. +  struct tm     tm;
  355. +
  356. +  panel_return_val_if_fail (XFCE_CLOCK_IS_HEX (hex), FALSE);
  357. +
  358. +  /* get the local time */
  359. +  clock_plugin_get_localtime (&tm);
  360. +
  361. +  if (hex->true_hex)
  362. +  {
  363. +   xfce_clock_hex_tm_to_xtm (&tm, &hex->xtime);
  364. +   xfce_clock_hex_format_true_xtime (string, 64, hex->format, &hex->xtime);
  365. +  }
  366. +  else
  367. +  {
  368. +   xfce_clock_hex_format_fake_xtime (string, 64, hex->format, &tm);
  369. +  }
  370. +
  371. +  gtk_label_set_markup (GTK_LABEL (hex), string);
  372. +
  373. +  return TRUE;
  374. +}
  375. +
  376. +
  377. +
  378. +
  379. +static void
  380. +xfce_clock_hex_update_font_size (XfceClockHex *hex)
  381. +{
  382. +   gchar string[20];
  383. +
  384. +   g_snprintf (string, 20, "Monospace %d", hex->font_size);
  385. +   gtk_widget_modify_font (GTK_WIDGET(hex),
  386. +                           pango_font_description_from_string(string));
  387. +}
  388. +
  389. +
  390. +
  391. +static void
  392. +xfce_clock_hex_tm_to_xtm (const struct tm  *_tm,
  393. +                          struct xtm       *_xtm)
  394. +{
  395. +  guint   seconds_passed;
  396. +  gdouble day_passed;
  397. +  guint16 xsec_passed;
  398. +
  399. +  seconds_passed = _tm->tm_sec + (_tm->tm_min * 60) + (_tm->tm_hour * 3600);
  400. +  day_passed = (gdouble)seconds_passed / (60*60*24);
  401. +
  402. +//*((guint16*)&hex->xtime) = 0x10000 * day_passed;
  403. +  xsec_passed = 0x10000 * day_passed;
  404. +
  405. +  _xtm->seconds = (xsec_passed >> 0x0) & 0xF;
  406. +  _xtm->minutes = (xsec_passed >> 0x4) & 0xF;
  407. +  _xtm->maximes = (xsec_passed >> 0x8) & 0xF;
  408. +  _xtm->hours   = (xsec_passed >> 0xC) & 0xF;
  409. +}
  410. +
  411. +
  412. +
  413. +static gchar
  414. +xfce_clock_hex_uint_to_xchar (guint    u,
  415. +                              gboolean upcase)
  416. +{
  417. +  if (u < 10)
  418. +    return u + '0';
  419. +  else if (u < 16)
  420. +    return (u - 10) + (upcase ? 'A' : 'a');
  421. +  else
  422. +    return 0;
  423. +}
  424. +
  425. +
  426. +
  427. +static gchar *
  428. +xfce_clock_hex_format_true_xtime (gchar       *buffer,
  429. +                                  gsize        buffer_size,
  430. +                                  const gchar *format,
  431. +                                  struct xtm  *xtime)
  432. +{
  433. +  gsize    chars_written = 0;
  434. +  gboolean upcase;
  435. +
  436. +  for ( ; *format; format++)
  437. +  {
  438. +    if (G_UNLIKELY(++chars_written == buffer_size))
  439. +      break;
  440. +
  441. +    if (*format != '%')
  442. +    {
  443. +      *(buffer++) = *format;
  444. +      continue;
  445. +    }
  446. +
  447. +    upcase = *++format <= 'Z';
  448. +
  449. +    switch (*format)
  450. +      {
  451. +      case 'H' :
  452. +      case 'h' :
  453. +        *buffer++ = xfce_clock_hex_uint_to_xchar (xtime->hours, upcase);
  454. +        break;
  455. +
  456. +      case 'X' :
  457. +      case 'x' :
  458. +        *buffer++ = xfce_clock_hex_uint_to_xchar (xtime->maximes, upcase);
  459. +        break;
  460. +
  461. +      case 'M' :
  462. +      case 'm' :
  463. +        *buffer++ = xfce_clock_hex_uint_to_xchar (xtime->minutes, upcase);
  464. +        break;
  465. +
  466. +      //case 'S' :
  467. +      //case 's' :
  468. +        //*buffer++ = xfce_clock_hex_uint_to_xchar (xtime->seconds, upcase);
  469. +        //break;
  470. +
  471. +      default :
  472. +        *buffer++ = '%';
  473. +       format--;
  474. +     }
  475. +  }
  476. +
  477. +  *buffer = '\0';
  478. +  return  buffer;
  479. +}
  480. +
  481. +
  482. +
  483. +void
  484. +xfce_clock_hex_write_hex_uint (gchar    **bufferp,
  485. +                               guint    u,
  486. +                               gboolean upcase,
  487. +                               gboolean leading_zero)
  488. +{
  489. +  gchar    _conv[3];
  490. +  gchar    *conv = _conv;
  491. +  gboolean two_digits = u > 0xF;
  492. +
  493. +  g_snprintf (_conv, 3, "%x", u);
  494. +
  495. +  if (upcase) { conv = g_ascii_strup (_conv, 3); }
  496. +
  497. +  if (leading_zero && !two_digits)
  498. +  {
  499. +    *(*bufferp)++ = '0';
  500. +    *(*bufferp)++ = conv[0];
  501. +  }
  502. +  else
  503. +  {
  504. +    *(*bufferp)++ = conv[0];
  505. +    if (two_digits) { *(*bufferp)++ = conv[1]; }
  506. +  }
  507. +
  508. +  if (upcase) { g_free(conv); }
  509. +}
  510. +
  511. +
  512. +
  513. +static gchar *
  514. +xfce_clock_hex_format_fake_xtime (gchar       *buffer,
  515. +                                  gsize       buffer_size,
  516. +                                  const gchar *format,
  517. +                                  struct tm   *_time)
  518. +{
  519. +  gsize    chars_written = 0;
  520. +  gboolean upcase;
  521. +
  522. +  for ( ; *format; format++)
  523. +  {
  524. +   if (G_UNLIKELY(++chars_written == buffer_size))
  525. +      break;
  526. +
  527. +    if (*format != '%')
  528. +   {
  529. +       *(buffer++) = *format;
  530. +       continue;
  531. +   }
  532. +
  533. +    if (chars_written + 1 == buffer_size)
  534. +      break;
  535. +
  536. +    upcase = *++format <= 'Z';
  537. +
  538. +    switch (*format)
  539. +      {
  540. +      case 'H' :
  541. +      case 'h' :
  542. +        xfce_clock_hex_write_hex_uint (&buffer, _time->tm_hour, upcase, TRUE);
  543. +        chars_written++;
  544. +        break;
  545. +
  546. +      case 'M' :
  547. +      case 'm' :
  548. +        xfce_clock_hex_write_hex_uint (&buffer, _time->tm_min, upcase, TRUE);
  549. +        chars_written++;
  550. +        break;
  551. +
  552. +      case 'S' :
  553. +      case 's' :
  554. +        xfce_clock_hex_write_hex_uint (&buffer, _time->tm_sec, upcase, TRUE);
  555. +        chars_written++;
  556. +        break;
  557. +
  558. +      default :
  559. +        *buffer++ = '%';
  560. +        format--;
  561. +      }
  562. +  }
  563. +
  564. +  *buffer = '\0';
  565. +  return buffer;
  566. +}
  567. +
  568. +
  569. +
  570. +
  571. +GtkWidget *
  572. +xfce_clock_hex_new (void)
  573. +{
  574. +  return g_object_new (XFCE_CLOCK_TYPE_HEX, NULL);
  575. +}
  576. diff --git a/plugins/clock/clock-hex.h b/plugins/clock/clock-hex.h
  577. new file mode 100644
  578. index 0000000..248a9fd
  579. --- /dev/null
  580. +++ b/plugins/clock/clock-hex.h
  581. @@ -0,0 +1,45 @@
  582. +/*
  583. + * Copyright (C) 2007-2010 Nick Schermer <nick@xfce.org>
  584. + * Copyright (C)      2012 Jonas Kulla   <Nyocurio@gmail.com>
  585. + *
  586. + * This library is free software; you can redistribute it and/or modify it
  587. + * under the terms of the GNU General Public License as published by the Free
  588. + * Software Foundation; either version 2 of the License, or (at your option)
  589. + * any later version.
  590. + *
  591. + * This library is distributed in the hope that it will be useful, but WITHOUT
  592. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  593. + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  594. + * more details.
  595. + *
  596. + * You should have received a copy of the GNU Lesser General Public
  597. + * License along with this library; if not, write to the Free Software
  598. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  599. + */
  600. +
  601. +#ifndef __CLOCK_HEX_H__
  602. +#define __CLOCK_HEX_H__
  603. +
  604. +G_BEGIN_DECLS
  605. +
  606. +#define DEFAULT_HEX_FORMAT " %H_%X%M "
  607. +
  608. +typedef struct _XfceClockHexClass XfceClockHexClass;
  609. +typedef struct _XfceClockHex      XfceClockHex;
  610. +
  611. +#define XFCE_CLOCK_TYPE_HEX            (xfce_clock_hex_get_type ())
  612. +#define XFCE_CLOCK_HEX(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_CLOCK_TYPE_HEX, XfceClockHex))
  613. +#define XFCE_CLOCK_HEX_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_CLOCK_TYPE_HEX, XfceClockHexClass))
  614. +#define XFCE_CLOCK_IS_HEX(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_CLOCK_TYPE_HEX))
  615. +#define XFCE_CLOCK_IS_HEX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_CLOCK_TYPE_HEX))
  616. +#define XFCE_CLOCK_HEX_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_CLOCK_TYPE_HEX, XfceClockHexClass))
  617. +
  618. +GType      xfce_clock_hex_get_type      (void) G_GNUC_CONST;
  619. +
  620. +void       xfce_clock_hex_register_type (XfcePanelTypeModule *type_module);
  621. +
  622. +GtkWidget *xfce_clock_hex_new           (void) G_GNUC_MALLOC;
  623. +
  624. +G_END_DECLS
  625. +
  626. +#endif /* !__CLOCK_HEX_H__ */
  627. diff --git a/plugins/clock/clock.c b/plugins/clock/clock.c
  628. index 2e38943..72ba83e 100644
  629. --- a/plugins/clock/clock.c
  630. +++ b/plugins/clock/clock.c
  631. @@ -42,6 +42,7 @@
  632.  #include "clock-fuzzy.h"
  633.  #include "clock-lcd.h"
  634.  #include "clock-dialog_ui.h"
  635. +#include "clock-hex.h"
  636.  
  637.  #define DEFAULT_TOOLTIP_FORMAT "%A %d %B %Y"
  638.  
  639. @@ -94,10 +95,11 @@ typedef enum
  640.    CLOCK_PLUGIN_MODE_DIGITAL,
  641.    CLOCK_PLUGIN_MODE_FUZZY,
  642.    CLOCK_PLUGIN_MODE_LCD,
  643. +  CLOCK_PLUGIN_MODE_HEX,
  644.  
  645.    /* defines */
  646.    CLOCK_PLUGIN_MODE_MIN = CLOCK_PLUGIN_MODE_ANALOG,
  647. -  CLOCK_PLUGIN_MODE_MAX = CLOCK_PLUGIN_MODE_LCD,
  648. +  CLOCK_PLUGIN_MODE_MAX = CLOCK_PLUGIN_MODE_HEX,
  649.    CLOCK_PLUGIN_MODE_DEFAULT = CLOCK_PLUGIN_MODE_DIGITAL
  650.  }
  651.  ClockPluginMode;
  652. @@ -172,7 +174,8 @@ XFCE_PANEL_DEFINE_PLUGIN (ClockPlugin, clock_plugin,
  653.    xfce_clock_binary_register_type,
  654.    xfce_clock_digital_register_type,
  655.    xfce_clock_fuzzy_register_type,
  656. -  xfce_clock_lcd_register_type)
  657. +  xfce_clock_lcd_register_type,
  658. +  xfce_clock_hex_register_type)
  659.  
  660.  
  661.  
  662. @@ -566,6 +569,8 @@ clock_plugin_configure_plugin_mode_changed (GtkComboBox       *combo,
  663.      { "fuzziness-box", "fuzziness", "value" },
  664.      { "show-inactive", "show-inactive", "active" },
  665.      { "show-grid", "show-grid", "active" },
  666. +    { "true-hex", "true-hex", "active" },
  667. +    { "hex-box", "hex-format", "text" },
  668.    };
  669.  
  670.    panel_return_if_fail (GTK_IS_COMBO_BOX (combo));
  671. @@ -596,6 +601,10 @@ clock_plugin_configure_plugin_mode_changed (GtkComboBox       *combo,
  672.        active = 1 << 1 | 1 << 3 | 1 << 4 | 1 << 5;
  673.        break;
  674.  
  675. +    case CLOCK_PLUGIN_MODE_HEX:
  676. +      active = 1 << 10 | 1 << 11;
  677. +      break;
  678. +
  679.      default:
  680.        panel_assert_not_reached ();
  681.        active = 0;
  682. @@ -805,7 +814,7 @@ clock_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
  683.  static void
  684.  clock_plugin_set_mode (ClockPlugin *plugin)
  685.  {
  686. -  const PanelProperty properties[][5] =
  687. +  const PanelProperty properties[][6] =
  688.    {
  689.      { /* analog */
  690.        { "show-seconds", G_TYPE_BOOLEAN },
  691. @@ -832,6 +841,11 @@ clock_plugin_set_mode (ClockPlugin *plugin)
  692.        { "show-meridiem", G_TYPE_BOOLEAN },
  693.        { "flash-separators", G_TYPE_BOOLEAN },
  694.        { NULL },
  695. +    },
  696. +    { /* hex */
  697. +      { "true-hex", G_TYPE_BOOLEAN },
  698. +      { "hex-format", G_TYPE_STRING },
  699. +      { NULL },
  700.      }
  701.    };
  702.    GtkOrientation      orientation;
  703. @@ -850,8 +864,10 @@ clock_plugin_set_mode (ClockPlugin *plugin)
  704.      plugin->clock = xfce_clock_digital_new ();
  705.    else if (plugin->mode == CLOCK_PLUGIN_MODE_FUZZY)
  706.      plugin->clock = xfce_clock_fuzzy_new ();
  707. -  else
  708. +  else if (plugin->mode == CLOCK_PLUGIN_MODE_LCD)
  709.      plugin->clock = xfce_clock_lcd_new ();
  710. +  else
  711. +    plugin->clock = xfce_clock_hex_new ();
  712.  
  713.    if (plugin->rotate_vertically)
  714.      {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement