mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Removed get_time from common.c
Uses GDateTime instead
This commit is contained in:
parent
6f2870ed7d
commit
51e5156fab
12
src/common.c
12
src/common.c
@ -48,18 +48,6 @@ create_dir(char *name)
|
||||
e = mkdir(name, S_IRWXU);
|
||||
}
|
||||
|
||||
void
|
||||
get_time(char *thetime)
|
||||
{
|
||||
time_t rawtime;
|
||||
struct tm *timeinfo;
|
||||
|
||||
time(&rawtime);
|
||||
timeinfo = localtime(&rawtime);
|
||||
|
||||
strftime(thetime, 80, "%H:%M", timeinfo);
|
||||
}
|
||||
|
||||
char *
|
||||
str_replace(const char *string, const char *substr,
|
||||
const char *replacement)
|
||||
|
@ -37,7 +37,6 @@
|
||||
|
||||
void p_slist_free_full(GSList *items, GDestroyNotify free_func);
|
||||
void create_dir(char *name);
|
||||
void get_time(char *thetime);
|
||||
char * str_replace(const char *string, const char *substr,
|
||||
const char *replacement);
|
||||
int str_contains(char str[], int size, char ch);
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include <ncurses.h>
|
||||
|
||||
#include "ui.h"
|
||||
#include "common.h"
|
||||
|
||||
static WINDOW *status_bar;
|
||||
static char *message = NULL;
|
||||
@ -34,7 +33,7 @@ static char _active[29] = "[ ][ ][ ][ ][ ][ ][ ][ ][ ]";
|
||||
static int is_active[9];
|
||||
static int is_new[9];
|
||||
static int dirty;
|
||||
static char curr_time[80];
|
||||
static GDateTime *last_time;
|
||||
|
||||
static void _status_bar_update_time(void);
|
||||
|
||||
@ -55,19 +54,21 @@ create_status_bar(void)
|
||||
mvwprintw(status_bar, 0, cols - 29, _active);
|
||||
wattroff(status_bar, COLOUR_BAR_DRAW);
|
||||
|
||||
get_time(curr_time);
|
||||
last_time = g_date_time_new_now_local();
|
||||
|
||||
dirty = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
status_bar_refresh(void)
|
||||
{
|
||||
char new_time[80];
|
||||
get_time(new_time);
|
||||
GDateTime *now_time = g_date_time_new_now_local();
|
||||
GTimeSpan elapsed = g_date_time_difference(now_time, last_time);
|
||||
|
||||
if (strcmp(new_time, curr_time) != 0) {
|
||||
if (elapsed >= 60000000) {
|
||||
dirty = TRUE;
|
||||
strcpy(curr_time, new_time);
|
||||
g_date_time_unref(now_time);
|
||||
last_time = g_date_time_new_now_local();
|
||||
}
|
||||
|
||||
if (dirty) {
|
||||
@ -102,7 +103,7 @@ status_bar_resize(void)
|
||||
if (message != NULL)
|
||||
mvwprintw(status_bar, 0, 9, message);
|
||||
|
||||
get_time(curr_time);
|
||||
last_time = g_date_time_new_now_local();
|
||||
dirty = TRUE;
|
||||
}
|
||||
|
||||
@ -216,18 +217,17 @@ status_bar_clear(void)
|
||||
static void
|
||||
_status_bar_update_time(void)
|
||||
{
|
||||
char bar_time[6];
|
||||
char tstmp[80];
|
||||
get_time(tstmp);
|
||||
sprintf(bar_time, "%s", tstmp);
|
||||
gchar *date_fmt = g_date_time_format(last_time, "%H:%M");
|
||||
|
||||
wattron(status_bar, COLOUR_BAR_DRAW);
|
||||
mvwaddch(status_bar, 0, 1, '[');
|
||||
wattroff(status_bar, COLOUR_BAR_DRAW);
|
||||
mvwprintw(status_bar, 0, 2, bar_time);
|
||||
mvwprintw(status_bar, 0, 2, date_fmt);
|
||||
wattron(status_bar, COLOUR_BAR_DRAW);
|
||||
mvwaddch(status_bar, 0, 7, ']');
|
||||
wattroff(status_bar, COLOUR_BAR_DRAW);
|
||||
|
||||
free(date_fmt);
|
||||
|
||||
dirty = TRUE;
|
||||
}
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include <ncurses.h>
|
||||
|
||||
#include "command.h"
|
||||
#include "common.h"
|
||||
#include "contact.h"
|
||||
#include "log.h"
|
||||
#include "preferences.h"
|
||||
@ -509,7 +508,6 @@ cons_help(void)
|
||||
cons_show("Navigation:");
|
||||
cons_show("");
|
||||
cons_show("F1 : This console window.");
|
||||
cons_show(" You may need to change the help key in your terminal settings.");
|
||||
cons_show("F2-F10 : Chat windows.");
|
||||
cons_show("UP, DOWN : Navigate input history.");
|
||||
cons_show("LEFT, RIGHT, HOME, END : Edit current input.");
|
||||
@ -759,9 +757,10 @@ _win_switch_if_active(const int i)
|
||||
static void
|
||||
_win_show_time(WINDOW *win)
|
||||
{
|
||||
char tstmp[80];
|
||||
get_time(tstmp);
|
||||
wprintw(win, "%s - ", tstmp);
|
||||
GDateTime *time = g_date_time_new_now_local();
|
||||
gchar *date_fmt = g_date_time_format(time, "%H:%M");
|
||||
wprintw(win, "%s - ", date_fmt);
|
||||
g_date_time_unref(time);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user