#include "launchable-item.h"
bool LaunchableItem::activate(osso_context_t *context) {
- return osso_application_top(context, getService().c_str(), 0) == OSSO_OK;
+ return osso_application_top(context, getService().c_str(), NULL) == OSSO_OK;
}
// vim:ts=2:sw=2:et
#include "launcher-item.h"
-GtkIconTheme *LauncherItem::ourTheme = 0;
+GtkIconTheme *LauncherItem::ourTheme = NULL;
static const char *DESKTOP_ENTRY_GROUP = "Desktop Entry",
*DESKTOP_ENTRY_TYPE_FIELD = "Type",
}
~GKeyFileWrapper() {
- if (myKeyFile != 0) {
+ if (myKeyFile != NULL) {
g_key_file_free(myKeyFile);
}
}
bool load(const std::string& name) {
- GError *error = 0;
+ GError *error = NULL;
bool result = g_key_file_load_from_file(myKeyFile, name.c_str(), G_KEY_FILE_NONE, &error);
- if (error != 0) {
+ if (error != NULL) {
g_error_free(error);
}
}
std::string getString(const gchar *group, const gchar *itemName) {
- gchar *tempo = g_key_file_get_string(myKeyFile, group, itemName, 0);
+ gchar *tempo = g_key_file_get_string(myKeyFile, group, itemName, NULL);
std::string result;
- if (tempo != 0) {
+ if (tempo != NULL) {
result.assign(tempo);
g_free(tempo);
}
std::string getLocaleString(const gchar *group, const gchar *itemName) {
- gchar *tempo = g_key_file_get_locale_string(myKeyFile, group, itemName, 0, 0);
+ gchar *tempo = g_key_file_get_locale_string(myKeyFile, group, itemName, NULL, NULL);
std::string result;
- if (tempo != 0) {
+ if (tempo != NULL) {
result.assign(tempo);
g_free(tempo);
}
GdkPixbuf *LauncherItem::getIcon(int icon_size) const {
- GdkPixbuf *pixbuf = 0;
+ GdkPixbuf *pixbuf = NULL;
if (!myIcon.empty()) {
- if (ourTheme == 0) {
+ if (ourTheme == NULL) {
ourTheme = gtk_icon_theme_get_default();
}
- GError *error = 0;
+ GError *error = NULL;
pixbuf = gtk_icon_theme_load_icon(ourTheme, myIcon.c_str(), icon_size, GTK_ICON_LOOKUP_NO_SVG, &error);
- if (error != 0) {
+ if (error != NULL) {
g_error_free(error);
error = NULL;
}
void *hildon_home_applet_lib_initialize(void *state_data, int *state_size, GtkWidget **widget) {
SimpleLauncherApplet *applet = new SimpleLauncherApplet();
- if (applet != 0) {
+ if (applet != NULL) {
if (applet->doInit(state_data, state_size)) {
*widget = applet->getWidget();
} else {
delete applet;
- applet = 0;
+ applet = NULL;
}
}
"/usr/share/applications/hildon/filemanager.desktop",
"/usr/share/applications/hildon/osso-application-installer.desktop",
"/usr/share/applications/hildon/hildon-control-panel.desktop",
- 0
+ NULL
};
-SimpleLauncherApplet::SimpleLauncherApplet(): myContext(0), myWidget(0), myParent(0) {
+SimpleLauncherApplet::SimpleLauncherApplet(): myContext(NULL), myWidget(NULL), myParent(NULL) {
}
bool SimpleLauncherApplet::doInit(void *state_data, int *state_size) {
- if ((myContext = osso_initialize(SL_APPLET_DBUS_NAME, SL_APPLET_VERSION, FALSE, 0)) == 0) {
+ if ((myContext = osso_initialize(SL_APPLET_DBUS_NAME, SL_APPLET_VERSION, FALSE, NULL)) == NULL) {
g_debug("sla-applet: failed to initialize the osso layer");
return false;
}
- for (int i = 0 ; ourFiles[i] != 0 ; ++i) {
+ for (int i = 0 ; ourFiles[i] != NULL ; ++i) {
LaunchableItem *item = new LaunchableItem();
if (item->load(ourFiles[i])) {
SimpleLauncherApplet::~SimpleLauncherApplet() {
for (LauncherItems::iterator it = myItems.begin(); it != myItems.end(); ++it) {
- if (it->second != 0) {
+ if (it->second != NULL) {
delete it->second;
- it->second = 0;
+ it->second = NULL;
}
}
myItems.resize(0);
- if (myWidget != 0) {
+ if (myWidget != NULL) {
gtk_widget_destroy(myWidget);
- myWidget = 0;
+ myWidget = NULL;
}
- if (myContext != 0) {
+ if (myContext != NULL) {
osso_deinitialize(myContext);
- myContext = 0;
+ myContext = NULL;
}
}
GtkToolbar *toolbar = GTK_TOOLBAR(gtk_toolbar_new());
for (LauncherItems::const_iterator it = myItems.begin(); it != myItems.end(); ++it) {
- GtkToolItem *button = gtk_tool_button_new(gtk_image_new_from_pixbuf(it->second->getIcon(SL_APPLET_ICON_SIZE)), 0);
+ GtkToolItem *button = gtk_tool_button_new(gtk_image_new_from_pixbuf(it->second->getIcon(SL_APPLET_ICON_SIZE)), NULL);
gtk_object_set_user_data(GTK_OBJECT(button), it->second);
g_signal_connect(button, "clicked", G_CALLBACK(_button_clicked), this);
}
if (button_no) {
- myWidget = gtk_frame_new(0);
+ myWidget = gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(myWidget), GTK_SHADOW_ETCHED_IN);
gtk_widget_set_size_request(myWidget, button_no*(SL_APPLET_ICON_SIZE+SL_APPLET_CANVAS_SIZE), SL_APPLET_ICON_SIZE+SL_APPLET_CANVAS_SIZE);
gtk_container_add(GTK_CONTAINER(myWidget), GTK_WIDGET(toolbar));
gtk_widget_destroy(GTK_WIDGET(toolbar));
}
- return myWidget != 0;
+ return myWidget != NULL;
}
void SimpleLauncherApplet::_button_clicked(GtkToolButton *button, void *self) {
}
void SimpleLauncherApplet::buttonClicked(GtkToolButton *button) {
- if (button != 0) {
+ if (button != NULL) {
LaunchableItem *item = (LaunchableItem *)gtk_object_get_user_data(GTK_OBJECT(button));
- if (item != 0) {
+ if (item != NULL) {
item->activate(myContext);
}
}
}
int SimpleLauncherApplet::saveState(void **state_data, int *state_size) {
- if (state_data != 0) {
- *state_data = 0;
+ if (state_data != NULL) {
+ *state_data = NULL;
}
- if (state_size != 0) {
- *state_size = 0;
+ if (state_size != NULL) {
+ *state_size = NULL;
}
return 1;
void SimpleLauncherApplet::runDialog() {
SLAList list(SL_APPLET_ICON_SIZE, myItems);
- GtkDialog *dialog = GTK_DIALOG(gtk_dialog_new_with_buttons("Launcher Settings", myParent, (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), "OK", GTK_RESPONSE_OK, "Cancel", GTK_RESPONSE_CANCEL, 0));
+ GtkDialog *dialog = GTK_DIALOG(gtk_dialog_new_with_buttons("Launcher Settings", myParent, (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), "OK", GTK_RESPONSE_OK, "Cancel", GTK_RESPONSE_CANCEL, NULL));
gtk_container_add(GTK_CONTAINER(dialog->vbox), list.getWidget());
return button;
}
-SLAList::SLAList(int icon_size, LauncherItems& items): myWidget(0), myStore(0), myView(0), mySelection(0), myItems(items) {
+SLAList::SLAList(int icon_size, LauncherItems& items): myWidget(NULL), myStore(NULL), myView(NULL), mySelection(NULL), myItems(items) {
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
gtk_tree_selection_set_mode(mySelection, GTK_SELECTION_SINGLE);
renderer = gtk_cell_renderer_pixbuf_new();
- g_object_set(renderer, "yalign", 0.0, 0);
+ g_object_set(renderer, "yalign", 0.0, NULL);
gtk_cell_renderer_set_fixed_size(renderer, icon_size+4, -1);
- column = GTK_TREE_VIEW_COLUMN(gtk_tree_view_column_new_with_attributes("", renderer, "pixbuf", 0, 0));
+ column = GTK_TREE_VIEW_COLUMN(gtk_tree_view_column_new_with_attributes("", renderer, "pixbuf", 0, NULL));
gtk_tree_view_insert_column(myView, column, -1);
renderer = gtk_cell_renderer_text_new();
- g_object_set(renderer, "yalign", 0.0, 0);
+ g_object_set(renderer, "yalign", 0.0, NULL);
column = gtk_tree_view_column_new();
gtk_tree_view_column_pack_start(column, renderer, TRUE);
- gtk_tree_view_column_set_cell_data_func(column, renderer, _renderText, this, 0);
+ gtk_tree_view_column_set_cell_data_func(column, renderer, _renderText, this, NULL);
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_expand(column, TRUE);
gtk_tree_view_insert_column(myView, column, -1);
renderer = gtk_cell_renderer_toggle_new();
- g_object_set(renderer, "activatable", TRUE, 0);
+ g_object_set(renderer, "activatable", TRUE, NULL);
g_signal_connect(renderer, "toggled", G_CALLBACK(_toggleBool), this);
column = gtk_tree_view_column_new();
gtk_tree_view_column_pack_start(column, renderer, TRUE);
- gtk_tree_view_column_set_cell_data_func(column, renderer, _renderBool, this, 0);
+ gtk_tree_view_column_set_cell_data_func(column, renderer, _renderBool, this, NULL);
gtk_tree_view_insert_column(myView, column, -1);
- GtkWidget *swindow = gtk_scrolled_window_new(0, 0);
+ GtkWidget *swindow = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_container_add(GTK_CONTAINER(swindow), GTK_WIDGET(myView));
#if 1
if (gtk_tree_selection_iter_is_selected(mySelection, iter)) {
gchar *text = g_markup_printf_escaped("%s\n<small>%s</small>", myItems[index].second->getName().c_str(), myItems[index].second->getComment().c_str());
- g_object_set(cell, "markup", text, 0);
+ g_object_set(cell, "markup", text, NULL);
g_free(text);
} else {
#endif
- g_object_set(cell, "text", myItems[index].second->getName().c_str(), 0);
+ g_object_set(cell, "text", myItems[index].second->getName().c_str(), NULL);
#if 1
}
#endif
gtk_tree_model_get(GTK_TREE_MODEL(myStore), iter, 1, &index, -1);
- g_object_set(cell, "active", myItems[index].second->isEnabled(), 0);
+ g_object_set(cell, "active", myItems[index].second->isEnabled(), NULL);
}
void SLAList::toggleBool(GtkCellRendererToggle *renderer, const gchar *spath) {