Avoid some code duplication
This commit is contained in:
parent
9a72d093a9
commit
ceff6bbcfa
|
@ -1177,6 +1177,31 @@ static void _open_with_default(Browser * browser, char const * path,
|
|||
}
|
||||
|
||||
|
||||
/* browser_properties */
|
||||
void browser_properties(Browser * browser)
|
||||
{
|
||||
char const * location;
|
||||
char * p;
|
||||
GList * selection;
|
||||
|
||||
if((location = browser_get_location(browser)) == NULL)
|
||||
return;
|
||||
if((selection = browser_selection_copy(browser)) == NULL)
|
||||
{
|
||||
if((p = strdup(location)) == NULL)
|
||||
{
|
||||
browser_error(browser, strerror(errno), 1);
|
||||
return;
|
||||
}
|
||||
selection = g_list_append(NULL, p);
|
||||
}
|
||||
if(_common_exec("properties", NULL, selection) != 0)
|
||||
browser_error(browser, strerror(errno), 1);
|
||||
g_list_foreach(selection, (GFunc)free, NULL);
|
||||
g_list_free(selection);
|
||||
}
|
||||
|
||||
|
||||
/* browser_refresh */
|
||||
void browser_refresh(Browser * browser)
|
||||
{
|
||||
|
|
|
@ -103,6 +103,8 @@ int browser_unload(Browser * browser, char const * plugin);
|
|||
void browser_open(Browser * browser, char const * path);
|
||||
void browser_open_with(Browser * browser, char const * path);
|
||||
|
||||
void browser_properties(Browser * browser);
|
||||
|
||||
void browser_refresh(Browser * browser);
|
||||
|
||||
/* selection */
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#ifndef PROGNAME
|
||||
# define PROGNAME "browser"
|
||||
#endif
|
||||
#define COMMON_EXEC
|
||||
#define COMMON_SYMLINK
|
||||
#include "common.c"
|
||||
|
||||
|
@ -186,25 +185,8 @@ void on_paste(gpointer data)
|
|||
void on_properties(gpointer data)
|
||||
{
|
||||
Browser * browser = data;
|
||||
char const * location;
|
||||
char * p;
|
||||
GList * selection;
|
||||
|
||||
if((location = browser_get_location(browser)) == NULL)
|
||||
return;
|
||||
if((selection = browser_selection_copy(browser)) == NULL)
|
||||
{
|
||||
if((p = strdup(location)) == NULL)
|
||||
{
|
||||
browser_error(browser, strerror(errno), 1);
|
||||
return;
|
||||
}
|
||||
selection = g_list_append(NULL, p);
|
||||
}
|
||||
if(_common_exec("properties", NULL, selection) != 0)
|
||||
browser_error(browser, strerror(errno), 1);
|
||||
g_list_foreach(selection, (GFunc)free, NULL);
|
||||
g_list_free(selection);
|
||||
browser_properties(browser);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user