~ubuntu-branches/ubuntu/wily/xfce4-panel/wily

« back to all changes in this revision

Viewing changes to plugins/clock/clock-digital.c

  • Committer: Package Import Robot
  • Author(s): Unit 193, Unit 193, Lionel Le Folgoc
  • Date: 2014-02-12 15:41:39 UTC
  • mfrom: (1.1.36)
  • Revision ID: package-import@ubuntu.com-20140212154139-j4cm4hlso68qadjw
Tags: 4.11.0~0.git20140209.86a1b73-0ubuntu1
[ Unit 193 ]
* New git snapshot. (LP: #1238997)
* debian/patches:
  - 02_potfiles-fix-ftbfs.patch: added, add missing files to po/POTFILES.in.
* debian/control: add b-dep on newer garcon.

[ Lionel Le Folgoc ]
* debian/patches:
  - xubuntu_add-calendar-popup-to-clock-plugin.patch: dropped, included.
  - series: refreshed.
* debian/xfce4-panel.install: include both (gtk2 and gtk3) wrappers.
* debian/rules: pass --enable-gtk3 --disable-silent-rules to configure script.
* debian/control: add b-dep on libgtk-3-dev.
* debian/xfce4-panel.shlibs: updated for the gtk3 library.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <config.h>
21
21
#endif
22
22
 
23
 
#ifdef HAVE_TIME_H
24
 
#include <time.h>
25
 
#endif
26
 
 
27
23
#include <gtk/gtk.h>
28
24
 
29
25
#include "clock.h"
 
26
#include "clock-time.h"
30
27
#include "clock-digital.h"
31
28
 
32
29
 
40
37
                                                 GValue                *value,
41
38
                                                 GParamSpec            *pspec);
42
39
static void     xfce_clock_digital_finalize     (GObject               *object);
43
 
static gboolean xfce_clock_digital_update       (gpointer               user_data);
 
40
static gboolean xfce_clock_digital_update       (XfceClockDigital      *digital,
 
41
                                                 ClockTime             *time);
 
42
 
44
43
 
45
44
 
46
45
 
61
60
{
62
61
  GtkLabel __parent__;
63
62
 
64
 
  ClockPluginTimeout *timeout;
 
63
  ClockTime          *time;
 
64
  ClockTimeTimeout   *timeout;
65
65
 
66
66
  gchar *format;
67
67
};
111
111
xfce_clock_digital_init (XfceClockDigital *digital)
112
112
{
113
113
  digital->format = g_strdup (DEFAULT_DIGITAL_FORMAT);
114
 
  digital->timeout = clock_plugin_timeout_new (clock_plugin_interval_from_format (digital->format),
115
 
                                               xfce_clock_digital_update,
116
 
                                               digital);
117
114
 
118
115
  gtk_label_set_justify (GTK_LABEL (digital), GTK_JUSTIFY_CENTER);
119
116
}
147
144
    }
148
145
 
149
146
  /* reschedule the timeout and redraw */
150
 
  clock_plugin_timeout_set_interval (digital->timeout,
151
 
      clock_plugin_interval_from_format (digital->format));
152
 
  xfce_clock_digital_update (digital);
 
147
  clock_time_timeout_set_interval (digital->timeout,
 
148
      clock_time_interval_from_format (digital->format));
 
149
  xfce_clock_digital_update (digital, digital->time);
153
150
}
154
151
 
155
152
 
186
183
  XfceClockDigital *digital = XFCE_CLOCK_DIGITAL (object);
187
184
 
188
185
  /* stop the timeout */
189
 
  clock_plugin_timeout_free (digital->timeout);
 
186
  clock_time_timeout_free (digital->timeout);
190
187
 
191
188
  g_free (digital->format);
192
189
 
196
193
 
197
194
 
198
195
static gboolean
199
 
xfce_clock_digital_update (gpointer user_data)
 
196
xfce_clock_digital_update (XfceClockDigital *digital,
 
197
                           ClockTime        *time)
200
198
{
201
 
  XfceClockDigital *digital = XFCE_CLOCK_DIGITAL (user_data);
202
199
  gchar            *string;
203
 
  struct tm         tm;
204
200
 
205
201
  panel_return_val_if_fail (XFCE_CLOCK_IS_DIGITAL (digital), FALSE);
206
 
 
207
 
  /* get the local time */
208
 
  clock_plugin_get_localtime (&tm);
 
202
  panel_return_val_if_fail (XFCE_IS_CLOCK_TIME (time), FALSE);
209
203
 
210
204
  /* set time string */
211
 
  string = clock_plugin_strdup_strftime (digital->format, &tm);
 
205
  string = clock_time_strdup_strftime (digital->time, digital->format);
212
206
  gtk_label_set_markup (GTK_LABEL (digital), string);
213
207
  g_free (string);
214
208
 
218
212
 
219
213
 
220
214
GtkWidget *
221
 
xfce_clock_digital_new (void)
 
215
xfce_clock_digital_new (ClockTime *time)
222
216
{
223
 
  return g_object_new (XFCE_CLOCK_TYPE_DIGITAL, NULL);
 
217
  XfceClockDigital *digital = g_object_new (XFCE_CLOCK_TYPE_DIGITAL, NULL);
 
218
 
 
219
  digital->time = time;
 
220
  digital->timeout = clock_time_timeout_new (clock_time_interval_from_format (digital->format),
 
221
                                             digital->time,
 
222
                                             G_CALLBACK (xfce_clock_digital_update), digital);
 
223
 
 
224
  return GTK_WIDGET (digital);
224
225
}