From 015af7846458a244b94280e9b37cf1de94245645 Mon Sep 17 00:00:00 2001 From: Jean-Louis Dupond Date: Mon, 26 Nov 2012 21:08:31 +0100 Subject: [PATCH] Fix indent & compiling of the external tools --- remmina/CMakeLists.txt | 2 +- remmina/external_tools/CMakeLists.txt | 2 - remmina/src/remmina_external_tools.c | 82 ++++++++++++++------------- remmina/src/remmina_external_tools.h | 1 - remmina/src/remmina_main.c | 4 +- remmina/src/remmina_main.h | 5 ++ 6 files changed, 52 insertions(+), 44 deletions(-) diff --git a/remmina/CMakeLists.txt b/remmina/CMakeLists.txt index 2cd103ff44..2d0cbb785e 100644 --- a/remmina/CMakeLists.txt +++ b/remmina/CMakeLists.txt @@ -86,7 +86,7 @@ set(REMMINA_SRCS src/remmina_string_list.h src/remmina_widget_pool.c src/remmina_widget_pool.h - src/remmina_external_tools.c + src/remmina_external_tools.c src/remmina_external_tools.h ) diff --git a/remmina/external_tools/CMakeLists.txt b/remmina/external_tools/CMakeLists.txt index ab5657207d..c0a41a2a44 100644 --- a/remmina/external_tools/CMakeLists.txt +++ b/remmina/external_tools/CMakeLists.txt @@ -23,5 +23,3 @@ file(MAKE_DIRECTORY ${EXTERNAL_TOOLS_DIR}) INSTALL(PROGRAMS launcher.sh pause.sh remmina_filezilla_sftp.sh remmina_filezilla_sftp_pki.sh remmina_nslookup.sh remmina_ping.sh remmina_traceroute.sh DESTINATION ${EXTERNAL_TOOLS_DIR}) - - diff --git a/remmina/src/remmina_external_tools.c b/remmina/src/remmina_external_tools.c index 980a869b9d..87cefe199c 100644 --- a/remmina/src/remmina_external_tools.c +++ b/remmina/src/remmina_external_tools.c @@ -14,20 +14,19 @@ typedef struct _RemminaExternalTools void view_popup_menu_onDoSomething (GtkWidget *menuitem, gpointer userdata) { - /* we passed the view as userdata when we connected the signal */ - RemminaExternalTools *ret = (RemminaExternalTools *)userdata; - //gchar* filename_remmina = ret->remminafilename; - //gchar* filename_script = ret->scriptfilename; + /* we passed the view as userdata when we connected the signal */ + RemminaExternalTools *ret = (RemminaExternalTools *)userdata; + //gchar* filename_remmina = ret->remminafilename; + //gchar* filename_script = ret->scriptfilename; - //g_print ("%s",ret->remminafilename); - remmina_external_tools_launcher(ret->remminafilename,ret->scriptfilename); + remmina_external_tools_launcher(ret->remminafilename,ret->scriptfilename); } gboolean remmina_external_tools_from_filename(RemminaMain *remminamain,gchar* remminafilename) { - GtkWidget *menu, *menuitem; - menu = gtk_menu_new(); - gchar dirname[MAX_PATH_LEN]; + GtkWidget *menu, *menuitem; + menu = gtk_menu_new(); + gchar dirname[MAX_PATH_LEN]; gchar filename[MAX_PATH_LEN]; GDir* dir; const gchar* name; @@ -36,8 +35,10 @@ gboolean remmina_external_tools_from_filename(RemminaMain *remminamain,gchar* re g_snprintf(dirname, MAX_PATH_LEN, "%s/.remmina/external_tools", g_get_home_dir()); dir = g_dir_open(dirname, 0, NULL); + if (dir == NULL) return FALSE; + while ((name = g_dir_read_name(dir)) != NULL) { if (!g_str_has_prefix(name, "remmina_")) @@ -50,28 +51,28 @@ gboolean remmina_external_tools_from_filename(RemminaMain *remminamain,gchar* re menuitem = gtk_menu_item_new_with_label(strndup(name + 8, strlen(name) -8)); g_signal_connect(menuitem, "activate", (GCallback) view_popup_menu_onDoSomething, ret); - //g_signal_connect(menuitem, "activate", - // (GCallback) view_popup_menu_onDoSomething, treeview); + //g_signal_connect(menuitem, "activate", + // (GCallback) view_popup_menu_onDoSomething, treeview); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); } g_dir_close(dir); - gtk_widget_show_all(menu); + gtk_widget_show_all(menu); - /* Note: event can be NULL here when called from view_onPopupMenu; - * gdk_event_get_time() accepts a NULL argument */ - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,0,0); + /* Note: event can be NULL here when called from view_onPopupMenu; + * gdk_event_get_time() accepts a NULL argument + */ + gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,0,0); - return TRUE; + return TRUE; } gboolean remmina_external_tools_launcher(const gchar* filename,const gchar* scriptname) { - gchar launcher[MAX_PATH_LEN]; - g_snprintf(launcher, MAX_PATH_LEN, "%s/.remmina/external_tools/launcher.sh", g_get_home_dir()); - //gchar *launcher="/home/frank/.remmina/external_tools/launcher.sh"; - RemminaFile *remminafile; + RemminaFile *remminafile; + gchar launcher[MAX_PATH_LEN]; + g_snprintf(launcher, MAX_PATH_LEN, "%s/.remmina/external_tools/launcher.sh", g_get_home_dir()); remminafile = remmina_file_load(filename); GHashTableIter iter; @@ -79,25 +80,30 @@ gboolean remmina_external_tools_launcher(const gchar* filename,const gchar* scri g_hash_table_iter_init(&iter, remminafile->settings); while (g_hash_table_iter_next(&iter, (gpointer*) &key, (gpointer*) &value)) { - const char *env_format = "%s=%s"; - const size_t len = strlen(key) +strlen(value) + strlen(env_format); - char *env = (char *) malloc(len); - if (env == NULL){ - return -1; - } - int retval = snprintf(env, len, env_format, key,value); - if (retval < 0 || (size_t)retval >= len) { - /* Handle error */ - } - if (putenv(env) != 0) { - free(env); - } + const char *env_format = "%s=%s"; + const size_t len = strlen(key) +strlen(value) + strlen(env_format); + char *env = (char *) malloc(len); + if (env == NULL) + { + return -1; + } + + int retval = snprintf(env, len, env_format, key,value); + if (retval < 0 || (size_t) retval >= len) + { + /* Handle error */ + } + + if (putenv(env) != 0) + { + free(env); + } } const size_t cmdlen = strlen(launcher) +strlen(scriptname) + 2; gchar *cmd = (gchar *)malloc(cmdlen); - g_snprintf(cmd,cmdlen,"%s %s",launcher,scriptname); - system(cmd); - free(cmd); + g_snprintf(cmd, cmdlen, "%s %s", launcher, scriptname); + system(cmd); + free(cmd); - return TRUE; + return TRUE; } diff --git a/remmina/src/remmina_external_tools.h b/remmina/src/remmina_external_tools.h index a8e16b0db5..5a8860d116 100644 --- a/remmina/src/remmina_external_tools.h +++ b/remmina/src/remmina_external_tools.h @@ -27,7 +27,6 @@ G_BEGIN_DECLS - /* Open a new connection window for a .remmina file */ gboolean remmina_external_tools_from_filename(RemminaMain *remminamain,gchar* filename); gboolean remmina_external_tools_launcher(const gchar* filename,const gchar* scriptname); diff --git a/remmina/src/remmina_main.c b/remmina/src/remmina_main.c index 7e9c4fa62c..9d27a6a2c4 100644 --- a/remmina/src/remmina_main.c +++ b/remmina/src/remmina_main.c @@ -460,7 +460,7 @@ static void remmina_main_action_connection_connect(GtkAction *action, RemminaMai static void remmina_main_action_connection_external_tools(GtkAction *action, RemminaMain *remminamain) { - remmina_external_tools_from_filename(remminamain,remminamain->priv->selected_filename); + remmina_external_tools_from_filename(remminamain, remminamain->priv->selected_filename); } static void remmina_main_file_editor_destroy(GtkWidget *widget, RemminaMain *remminamain) @@ -882,7 +882,7 @@ static const GtkActionEntry remmina_main_ui_file_sensitive_menu_entries[] = { "ConnectionDelete", GTK_STOCK_DELETE, NULL, "D", N_("Delete the selected remote desktop file"), G_CALLBACK( remmina_main_action_connection_delete) }, -{ "ToolsExport", NULL, N_("Export"), NULL, NULL, G_CALLBACK(remmina_main_action_tools_export) } }; +{ "ToolsExport", NULL, N_("Export"), NULL, NULL, G_CALLBACK(remmina_main_action_tools_export) }, { "ConnectionExternalTools", NULL, N_("External Tools"), "T", NULL, G_CALLBACK(remmina_main_action_connection_external_tools) } diff --git a/remmina/src/remmina_main.h b/remmina/src/remmina_main.h index e0a297bc7f..b5a7a60bc0 100644 --- a/remmina/src/remmina_main.h +++ b/remmina/src/remmina_main.h @@ -18,6 +18,8 @@ * Boston, MA 02111-1307, USA. */ +#include "remmina_string_array.h" + #ifndef __REMMINAMAIN_H__ #define __REMMINAMAIN_H__ @@ -53,6 +55,9 @@ struct _RemminaMainPriv GtkToolItem *quick_search_item; GtkWidget *quick_search_entry; + GtkWidget *quickconnect_protocol; + GtkWidget *quickconnect_server; + GtkTreeViewColumn *group_column; GtkActionGroup *main_group;