Fixed error handling while adding applets

This commit is contained in:
Pierre Pronchery 2013-11-22 01:40:46 +01:00
parent 479bf89eca
commit 78c9d33bbc
3 changed files with 8 additions and 5 deletions

View File

@ -19,6 +19,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <gtk/gtk.h>
#include <System.h>
#include <Desktop.h>
@ -261,16 +262,16 @@ static int _panel_window_append(PanelWindow * window,
if((pa = realloc(window->applets, sizeof(*pa)
* (window->applets_cnt + 1))) == NULL)
return error_print(PROGNAME);
return -error_set_code(1, "%s", strerror(errno));
window->applets = pa;
pa = &window->applets[window->applets_cnt];
if((pa->plugin = plugin_new(LIBDIR, "Panel", "applets", applet))
== NULL)
return error_print(PROGNAME);
return -1;
if((pa->pad = plugin_lookup(pa->plugin, "applet")) == NULL)
{
plugin_delete(pa->plugin);
return error_print(PROGNAME);
return -1;
}
widget = NULL;
if((pa->pa = pa->pad->init(helper, &widget)) != NULL && widget != NULL)

View File

@ -78,7 +78,8 @@ static int _notify(GtkIconSize iconsize, int timeout, char * applets[])
GTK_WIN_POS_CENTER_ALWAYS);
gtk_window_set_title(GTK_WINDOW(panel.top.window), _("Notification"));
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);
if(timeout > 0)
panel.timeout = g_timeout_add(timeout * 1000,

View File

@ -66,7 +66,8 @@ static int _test(GtkIconSize iconsize, char * applets[])
_panel_init(&panel, PANEL_APPLET_TYPE_NORMAL, iconsize);
gtk_window_set_title(GTK_WINDOW(panel.top.window), _("Applet tester"));
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_main();
_panel_destroy(&panel);