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:
parent
f1f7cac2fd
commit
ee1d546d8f
32
src/stash.c
32
src/stash.c
@ -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)
|
||||
{
|
||||
gboolean supported_type = TRUE;
|
||||
gpointer setting;
|
||||
GtkTreeIter iter;
|
||||
StashTreeValue *value;
|
||||
|
||||
switch (entry->setting_type)
|
||||
{
|
||||
@ -1045,28 +1046,21 @@ static void stash_tree_append_pref(StashGroup *group, StashPref *entry, GtkListS
|
||||
setting = g_strdup(*(gchararray *) entry->setting);
|
||||
break;
|
||||
default:
|
||||
supported_type = FALSE;
|
||||
g_warning("Unhandled type for %s::%s in %s()!", group->name,
|
||||
entry->key_name, G_STRFUNC);
|
||||
return;
|
||||
}
|
||||
|
||||
if (supported_type)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
StashTreeValue *value = g_new(StashTreeValue, 1);
|
||||
value = g_new(StashTreeValue, 1);
|
||||
|
||||
value->setting_type = entry->setting_type;
|
||||
value->setting = setting;
|
||||
value->key_name = entry->key_name;
|
||||
value->group_name = group->name;
|
||||
value->setting_type = entry->setting_type;
|
||||
value->setting = setting;
|
||||
value->key_name = entry->key_name;
|
||||
value->group_name = group->name;
|
||||
|
||||
gtk_list_store_append(store, &iter);
|
||||
gtk_list_store_set(store, &iter, STASH_TREE_NAME, value->key_name,
|
||||
STASH_TREE_VALUE, value, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning("Unhandled type for %s::%s in %s()!", group->name,
|
||||
entry->key_name, G_STRFUNC);
|
||||
}
|
||||
gtk_list_store_append(store, &iter);
|
||||
gtk_list_store_set(store, &iter, STASH_TREE_NAME, value->key_name,
|
||||
STASH_TREE_VALUE, value, -1);
|
||||
}
|
||||
|
||||
|
||||
|
18
src/tools.c
18
src/tools.c
@ -85,13 +85,9 @@ static gboolean cc_exists_command(const gchar *command)
|
||||
{
|
||||
gchar *path = g_find_program_in_path(command);
|
||||
|
||||
if (path != NULL)
|
||||
{
|
||||
g_free(path);
|
||||
return TRUE;
|
||||
}
|
||||
g_free(path);
|
||||
|
||||
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)
|
||||
{
|
||||
GError *err = NULL;
|
||||
const gchar *stock_id;
|
||||
const gchar *stock_id = GTK_STOCK_NO;
|
||||
gchar *tooltip = NULL;
|
||||
gint argc;
|
||||
gchar **argv;
|
||||
|
||||
if (! NZV(cmd))
|
||||
{
|
||||
stock_id = GTK_STOCK_YES;
|
||||
}
|
||||
else if (g_shell_parse_argv(cmd, &argc, &argv, &err))
|
||||
{
|
||||
if (argc > 0 && cc_exists_command(argv[0]))
|
||||
stock_id = GTK_STOCK_YES;
|
||||
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);
|
||||
}
|
||||
|
||||
if (err != NULL)
|
||||
else
|
||||
{
|
||||
stock_id = GTK_STOCK_NO;
|
||||
tooltip = g_strdup_printf(_("Invalid command: %s"), err->message);
|
||||
g_error_free(err);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user