Refactor a little some code to be more readable

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5885 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Colomban Wendling 2011-08-06 18:33:27 +00:00
parent f1f7cac2fd
commit ee1d546d8f
2 changed files with 18 additions and 32 deletions

View File

@ -1030,8 +1030,9 @@ static void stash_foreach_various_pref(GPtrArray *group_array, stash_foreach_pre
static void stash_tree_append_pref(StashGroup *group, StashPref *entry, GtkListStore *store) static void stash_tree_append_pref(StashGroup *group, StashPref *entry, GtkListStore *store)
{ {
gboolean supported_type = TRUE;
gpointer setting; gpointer setting;
GtkTreeIter iter;
StashTreeValue *value;
switch (entry->setting_type) switch (entry->setting_type)
{ {
@ -1045,13 +1046,12 @@ static void stash_tree_append_pref(StashGroup *group, StashPref *entry, GtkListS
setting = g_strdup(*(gchararray *) entry->setting); setting = g_strdup(*(gchararray *) entry->setting);
break; break;
default: default:
supported_type = FALSE; g_warning("Unhandled type for %s::%s in %s()!", group->name,
entry->key_name, G_STRFUNC);
return;
} }
if (supported_type) value = g_new(StashTreeValue, 1);
{
GtkTreeIter iter;
StashTreeValue *value = g_new(StashTreeValue, 1);
value->setting_type = entry->setting_type; value->setting_type = entry->setting_type;
value->setting = setting; value->setting = setting;
@ -1061,12 +1061,6 @@ static void stash_tree_append_pref(StashGroup *group, StashPref *entry, GtkListS
gtk_list_store_append(store, &iter); gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, STASH_TREE_NAME, value->key_name, gtk_list_store_set(store, &iter, STASH_TREE_NAME, value->key_name,
STASH_TREE_VALUE, value, -1); STASH_TREE_VALUE, value, -1);
}
else
{
g_warning("Unhandled type for %s::%s in %s()!", group->name,
entry->key_name, G_STRFUNC);
}
} }

View File

@ -85,13 +85,9 @@ static gboolean cc_exists_command(const gchar *command)
{ {
gchar *path = g_find_program_in_path(command); gchar *path = g_find_program_in_path(command);
if (path != NULL)
{
g_free(path); g_free(path);
return TRUE;
}
return FALSE; return path != NULL;
} }
@ -99,27 +95,23 @@ static gboolean cc_exists_command(const gchar *command)
static void cc_dialog_update_row_status(GtkListStore *store, GtkTreeIter *iter, const gchar *cmd) static void cc_dialog_update_row_status(GtkListStore *store, GtkTreeIter *iter, const gchar *cmd)
{ {
GError *err = NULL; GError *err = NULL;
const gchar *stock_id; const gchar *stock_id = GTK_STOCK_NO;
gchar *tooltip = NULL; gchar *tooltip = NULL;
gint argc; gint argc;
gchar **argv; gchar **argv;
if (! NZV(cmd)) if (! NZV(cmd))
{
stock_id = GTK_STOCK_YES; stock_id = GTK_STOCK_YES;
}
else if (g_shell_parse_argv(cmd, &argc, &argv, &err)) else if (g_shell_parse_argv(cmd, &argc, &argv, &err))
{ {
if (argc > 0 && cc_exists_command(argv[0])) if (argc > 0 && cc_exists_command(argv[0]))
stock_id = GTK_STOCK_YES; stock_id = GTK_STOCK_YES;
else else
err = g_error_new(G_FILE_ERROR, G_FILE_ERROR_NOENT, _("Command not found")); tooltip = g_strdup_printf(_("Invalid command: %s"), _("Command not found"));
g_strfreev(argv); g_strfreev(argv);
} }
else
if (err != NULL)
{ {
stock_id = GTK_STOCK_NO;
tooltip = g_strdup_printf(_("Invalid command: %s"), err->message); tooltip = g_strdup_printf(_("Invalid command: %s"), err->message);
g_error_free(err); g_error_free(err);
} }