Code cleanup

This commit is contained in:
Pierre Pronchery 2013-11-21 23:56:36 +01:00
parent f3c26b3a69
commit 3d9a1a1c85
4 changed files with 42 additions and 40 deletions

View File

@ -1,6 +1,6 @@
/* $Id$ */
static char const _copyright[] =
"Copyright (c) 2004-2013 DeforaOS Project <contact@defora.org>";
"Copyright © 2004-2013 DeforaOS Project <contact@defora.org>";
/* This file is part of DeforaOS Desktop Panel */
static char const _license[] =
"This program is free software: you can redistribute it and/or modify\n"

View File

@ -88,16 +88,17 @@ static char const * _authors[] =
/* public */
/* prototypes */
int panel_init(Panel * panel, GtkIconSize iconsize);
void panel_destroy(Panel * panel);
void panel_window_init(PanelWindow * panel, GtkIconSize iconsize);
void panel_window_destroy(PanelWindow * panel);
int panel_window_get_height(PanelWindow * panel);
/* private */
/* prototypes */
static int _panel_init(Panel * panel, GtkIconSize iconsize);
static void _panel_destroy(Panel * panel);
static void _panel_window_init(PanelWindow * panel, GtkIconSize iconsize);
static void _panel_window_destroy(PanelWindow * panel);
static int _applet_list(void);
static char * _config_get_filename(void);
@ -121,8 +122,33 @@ static int _helper_append(PanelAppletHelper * helper, PanelWindow * window,
/* public */
/* functions */
/* panel_error */
int panel_error(Panel * panel, char const * message, int ret)
{
fputs(PROGNAME ": ", stderr);
perror(message);
return ret;
}
/* panel_show_preferences */
void panel_show_preferences(Panel * panel, gboolean show)
{
/* XXX just a stub */
}
/* panel_window_get_height */
int panel_window_get_height(PanelWindow * panel)
{
return panel->height;
}
/* private */
/* functions */
/* panel_init */
int panel_init(Panel * panel, GtkIconSize iconsize)
static int _panel_init(Panel * panel, GtkIconSize iconsize)
{
char * filename;
GdkScreen * screen;
@ -135,7 +161,7 @@ int panel_init(Panel * panel, GtkIconSize iconsize)
&& config_load(panel->config, filename) != 0)
error_print(PROGNAME);
free(filename);
panel_window_init(&panel->top, iconsize);
_panel_window_init(&panel->top, iconsize);
panel->window = panel->top.window;
panel->timeout = 0;
panel->source = 0;
@ -153,13 +179,13 @@ int panel_init(Panel * panel, GtkIconSize iconsize)
/* panel_destroy */
void panel_destroy(Panel * panel)
static void _panel_destroy(Panel * panel)
{
if(panel->timeout != 0)
g_source_remove(panel->timeout);
if(panel->source != 0)
g_source_remove(panel->source);
panel_window_destroy(&panel->top);
_panel_window_destroy(&panel->top);
if(panel->ab_window != NULL)
gtk_widget_destroy(panel->ab_window);
if(panel->lo_window != NULL)
@ -169,24 +195,8 @@ void panel_destroy(Panel * panel)
}
/* panel_error */
int panel_error(Panel * panel, char const * message, int ret)
{
fputs(PROGNAME ": ", stderr);
perror(message);
return ret;
}
/* panel_show_preferences */
void panel_show_preferences(Panel * panel, gboolean show)
{
/* XXX just a stub */
}
/* panel_window_init */
void panel_window_init(PanelWindow * panel, GtkIconSize iconsize)
static void _panel_window_init(PanelWindow * panel, GtkIconSize iconsize)
{
GdkRectangle rect;
@ -205,7 +215,7 @@ void panel_window_init(PanelWindow * panel, GtkIconSize iconsize)
/* panel_window_destroy */
void panel_window_destroy(PanelWindow * panel)
static void _panel_window_destroy(PanelWindow * panel)
{
size_t i;
PanelApplet * pa;
@ -221,14 +231,6 @@ void panel_window_destroy(PanelWindow * panel)
}
/* panel_window_get_height */
int panel_window_get_height(PanelWindow * panel)
{
return panel->height;
}
/* functions */
/* applet_list */
static int _applet_list(void)
{

View File

@ -68,7 +68,7 @@ static int _notify(GtkIconSize iconsize, int timeout, char * applets[])
size_t i;
PanelAppletHelper helper;
panel_init(&panel, iconsize);
_panel_init(&panel, iconsize);
#if GTK_CHECK_VERSION(3, 0, 0)
gtk_window_set_has_resize_grip(GTK_WINDOW(panel.top.window), FALSE);
#endif
@ -86,7 +86,7 @@ static int _notify(GtkIconSize iconsize, int timeout, char * applets[])
panel.timeout = g_timeout_add(timeout * 1000,
_notify_on_timeout, &panel);
gtk_main();
panel_destroy(&panel);
_panel_destroy(&panel);
return 0;
}

View File

@ -64,14 +64,14 @@ static int _test(GtkIconSize iconsize, char * applets[])
size_t i;
PanelAppletHelper helper;
panel_init(&panel, iconsize);
_panel_init(&panel, iconsize);
gtk_window_set_title(GTK_WINDOW(panel.top.window), _("Applet tester"));
_helper_init(&helper, &panel, PANEL_APPLET_TYPE_NORMAL, iconsize);
for(i = 0; applets[i] != NULL; i++)
_helper_append(&helper, &panel.top, applets[i]);
gtk_widget_show_all(panel.top.window);
gtk_main();
panel_destroy(&panel);
_panel_destroy(&panel);
return 0;
}