}
g_object_get (settings, property, &string, NULL);
- if (!string)
- string = g_strdup ("");
if (!def_string)
def_string = "";
- if (strcmp (string, def_string))
- g_key_file_set_string (key_file, "settings", property, string);
+ if (strcmp (string ? string : "", def_string))
+ g_key_file_set_string (key_file, "settings", property, string ? string : "");
g_free (string);
}
else if (type == G_TYPE_PARAM_INT)
{
katze_item_set_meta_integer (item, "append", 1);
katze_item_set_meta_integer (item, "dont-write-history", 1);
- if (load_on_startup == MIDORI_STARTUP_DELAYED_PAGES
- && katze_item_get_meta_integer (item, "delay") == -1)
+ if (load_on_startup == MIDORI_STARTUP_DELAYED_PAGES)
katze_item_set_meta_integer (item, "delay", 1);
midori_browser_add_item (browser, item);
}
const gchar* value;
if (!keys)
- return g_strdup ("");
+ return NULL;
markup = g_string_new ("<info>\n<metadata");
markdown = g_string_new (NULL);
">\n");
string_append_xml_element (markup, "title", katze_item_get_name (KATZE_ITEM (array)));
string_append_xml_element (markup, "desc", katze_item_get_text (KATZE_ITEM (array)));
- g_string_append (markup, metadata);
+ g_string_append (markup, metadata ? metadata : "");
KATZE_ARRAY_FOREACH_ITEM_L (item, array, list)
string_append_item (markup, item);
g_string_append (markup, "</xbel>\n");
slash = strrchr (uri, '/');
/* Huh, URI without slashes? */
if (!slash)
- return g_strdup ("");
+ return NULL;
ext_end = period = strrchr (slash, '.');
if (!period)
- return g_strdup ("");
+ return NULL;
/* Skip the period */
ext_end++;
/* If *ext_end is 0 here, the URI ended with a period, so skip */
if (!*ext_end)
- return g_strdup ("");
+ return NULL;
/* Find the end of the extension */
while (*ext_end && g_ascii_isalnum (*ext_end))
{
GtkWidget* widget = GTK_WIDGET (browser);
- if (gtk_widget_get_realized (widget) && !browser->alloc_timeout)
+ if (!browser->alloc_timeout && gtk_widget_get_realized (widget))
{
gpointer last_page;
if (!webkit_web_view_can_cut_clipboard (web_view)
&& !webkit_web_view_can_paste_clipboard (web_view))
{
- gchar* text = character ? g_strdup_printf ("%c", character) : g_strdup ("");
- g_signal_emit (view, signals[SEARCH_TEXT], 0, TRUE, text);
+ gchar* text = character ? g_strdup_printf ("%c", character) : NULL;
+ g_signal_emit (view, signals[SEARCH_TEXT], 0, TRUE, text ? text : "");
g_free (text);
return TRUE;
}
else
{
g_free (file_path);
- return g_strdup ("");
+ return NULL;
}
groups = g_key_file_get_groups (key_file, NULL);
}
else
{
- encoded = g_strdup ("");
+ encoded = NULL;
if (load_missing)
midori_view_speed_dial_get_thumb (view, groups[i], uri);
}
"<a class=\"cross\" href=\"#\" onclick='clearShortcut(\"s%d\");'></a>"
"<a href=\"%s\"><img src=\"data:image/png;base64,%s\"></a>"
"</div><div class=\"title\" onclick='renameShortcut(\"s%d\");'>%s</div></div>\n",
- slot, slot, uri, encoded, slot, title ? title : "");
+ slot, slot, uri, encoded ? encoded : "", slot, title ? title : "");
g_free (title);
g_free (encoded);
speeddial_markup = prepare_speed_dial_html (view, TRUE);
midori_view_load_alternate_string (view,
- speeddial_markup, "about:blank", NULL);
+ speeddial_markup ? speeddial_markup : "", "about:blank", NULL);
#ifdef G_ENABLE_DEBUG
if (g_getenv ("MIDORI_STARTTIME") != NULL)
katze_item_set_uri (view->item, view->uri);
g_object_notify (G_OBJECT (view), "uri");
}
- else if (katze_item_get_meta_integer (view->item, "delay") > 0)
+ else if (katze_item_get_meta_boolean (view->item, "delay"))
{
katze_assign (view->uri, g_strdup (uri));
katze_item_set_meta_integer (view->item, "delay", -1);
if (time_estimated > 0)
{
- gchar* eta;
+ gchar* eta = NULL;
if (hours_left > 0)
eta = g_strdup_printf ("%s, %s", hours_str, minutes_str);
else if (minutes_left >= 10)
eta = g_strdup_printf ("%s, %s", minutes_str, seconds_str);
else if (seconds_left > 0)
eta = g_strdup_printf ("%s", seconds_str);
- else
- eta = g_strdup ("");
- /* i18n: Download tooltip (estimated time) : - 1 hour, 5 minutes remaning */
- g_string_append_printf (tooltip, _(" - %s remaining"), eta);
- g_free (eta);
+ if (eta != NULL)
+ {
+ /* i18n: Download tooltip (estimated time) : - 1 hour, 5 minutes remaning */
+ g_string_append_printf (tooltip, _(" - %s remaining"), eta);
+ g_free (eta);
+ }
}
g_free (hours_str);
gchar* sqlcmd;
char* errmsg = NULL;
KatzeItem* old_parent;
- gchar* parent;
- gchar* uri;
- gchar* desc;
+ const gchar* parent;
+ const gchar* uri = NULL;
+ const gchar* desc = NULL;
/* Bookmarks must have a name, import may produce invalid items */
g_return_if_fail (katze_item_get_name (item));
return;
if (KATZE_ITEM_IS_BOOKMARK (item))
- uri = g_strdup (katze_item_get_uri (item));
- else
- uri = g_strdup ("");
+ uri = katze_item_get_uri (item);
if (katze_item_get_text (item))
- desc = g_strdup (katze_item_get_text (item));
- else
- desc = g_strdup ("");
+ desc = katze_item_get_text (item);
/* Use folder, otherwise fallback to parent folder */
old_parent = katze_item_get_parent (item);
if (folder && *folder)
- parent = g_strdup (folder);
+ parent = folder;
else if (old_parent && katze_item_get_name (old_parent))
- parent = g_strdup (katze_item_get_name (old_parent));
+ parent = katze_item_get_name (old_parent);
else
- parent = g_strdup ("");
+ parent = "";
sqlcmd = sqlite3_mprintf (
"INSERT into bookmarks (uri, title, desc, folder, toolbar, app) values"
" ('%q', '%q', '%q', '%q', %d, %d)",
- uri,
+ uri ? uri : "",
katze_item_get_name (item),
- desc,
+ desc ? desc : "",
parent,
katze_item_get_meta_boolean (item, "toolbar"),
katze_item_get_meta_boolean (item, "app"));
sqlite3_free (errmsg);
}
- g_free (uri);
- g_free (parent);
- g_free (desc);
sqlite3_free (sqlcmd);
}
{
KatzeItem* item;
GtkTreeIter parent;
- gchar* parent_name;
+ KatzeItem* new_parent = NULL;
+ const gchar* parent_name;
gtk_tree_model_get (model, iter, 0, &item, -1);
if (gtk_tree_model_iter_parent (model, &parent, iter))
{
- KatzeItem* new_parent;
-
gtk_tree_model_get (model, &parent, 0, &new_parent, -1);
/* Bookmarks must not be moved into non-folder items */
if (!KATZE_ITEM_IS_FOLDER (new_parent))
- parent_name = g_strdup ("");
+ parent_name = "";
else
- parent_name = g_strdup (katze_item_get_name (new_parent));
-
- g_object_unref (new_parent);
+ parent_name = katze_item_get_name (new_parent);
}
else
- parent_name = g_strdup ("");
+ parent_name = "";
katze_array_remove_item (bookmarks->array, item);
katze_item_set_meta_string (item, "folder", parent_name);
katze_array_add_item (bookmarks->array, item);
+
+ g_object_unref (item);
+ if (new_parent)
+ g_object_unref (new_parent);
}
static void