Fixed error handling while adding applets
This commit is contained in:
parent
479bf89eca
commit
78c9d33bbc
|
@ -19,6 +19,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <System.h>
|
#include <System.h>
|
||||||
#include <Desktop.h>
|
#include <Desktop.h>
|
||||||
|
@ -261,16 +262,16 @@ static int _panel_window_append(PanelWindow * window,
|
||||||
|
|
||||||
if((pa = realloc(window->applets, sizeof(*pa)
|
if((pa = realloc(window->applets, sizeof(*pa)
|
||||||
* (window->applets_cnt + 1))) == NULL)
|
* (window->applets_cnt + 1))) == NULL)
|
||||||
return error_print(PROGNAME);
|
return -error_set_code(1, "%s", strerror(errno));
|
||||||
window->applets = pa;
|
window->applets = pa;
|
||||||
pa = &window->applets[window->applets_cnt];
|
pa = &window->applets[window->applets_cnt];
|
||||||
if((pa->plugin = plugin_new(LIBDIR, "Panel", "applets", applet))
|
if((pa->plugin = plugin_new(LIBDIR, "Panel", "applets", applet))
|
||||||
== NULL)
|
== NULL)
|
||||||
return error_print(PROGNAME);
|
return -1;
|
||||||
if((pa->pad = plugin_lookup(pa->plugin, "applet")) == NULL)
|
if((pa->pad = plugin_lookup(pa->plugin, "applet")) == NULL)
|
||||||
{
|
{
|
||||||
plugin_delete(pa->plugin);
|
plugin_delete(pa->plugin);
|
||||||
return error_print(PROGNAME);
|
return -1;
|
||||||
}
|
}
|
||||||
widget = NULL;
|
widget = NULL;
|
||||||
if((pa->pa = pa->pad->init(helper, &widget)) != NULL && widget != NULL)
|
if((pa->pa = pa->pad->init(helper, &widget)) != NULL && widget != NULL)
|
||||||
|
|
|
@ -78,7 +78,8 @@ static int _notify(GtkIconSize iconsize, int timeout, char * applets[])
|
||||||
GTK_WIN_POS_CENTER_ALWAYS);
|
GTK_WIN_POS_CENTER_ALWAYS);
|
||||||
gtk_window_set_title(GTK_WINDOW(panel.top.window), _("Notification"));
|
gtk_window_set_title(GTK_WINDOW(panel.top.window), _("Notification"));
|
||||||
for(i = 0; applets[i] != NULL; i++)
|
for(i = 0; applets[i] != NULL; i++)
|
||||||
_panel_append(&panel, 0, applets[i]);
|
if(_panel_append(&panel, 0, applets[i]) != 0)
|
||||||
|
error_print(PROGNAME);
|
||||||
gtk_widget_show_all(panel.top.window);
|
gtk_widget_show_all(panel.top.window);
|
||||||
if(timeout > 0)
|
if(timeout > 0)
|
||||||
panel.timeout = g_timeout_add(timeout * 1000,
|
panel.timeout = g_timeout_add(timeout * 1000,
|
||||||
|
|
|
@ -66,7 +66,8 @@ static int _test(GtkIconSize iconsize, char * applets[])
|
||||||
_panel_init(&panel, PANEL_APPLET_TYPE_NORMAL, iconsize);
|
_panel_init(&panel, PANEL_APPLET_TYPE_NORMAL, iconsize);
|
||||||
gtk_window_set_title(GTK_WINDOW(panel.top.window), _("Applet tester"));
|
gtk_window_set_title(GTK_WINDOW(panel.top.window), _("Applet tester"));
|
||||||
for(i = 0; applets[i] != NULL; i++)
|
for(i = 0; applets[i] != NULL; i++)
|
||||||
_panel_append(&panel, 0, applets[i]);
|
if(_panel_append(&panel, 0, applets[i]) != 0)
|
||||||
|
error_print(PROGNAME);
|
||||||
gtk_widget_show_all(panel.top.window);
|
gtk_widget_show_all(panel.top.window);
|
||||||
gtk_main();
|
gtk_main();
|
||||||
_panel_destroy(&panel);
|
_panel_destroy(&panel);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user