Skip to content

Commit

Permalink
Fix indent & compiling of the external tools
Browse files Browse the repository at this point in the history
  • Loading branch information
dupondje committed Nov 26, 2012
1 parent f878baf commit 015af78
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 44 deletions.
2 changes: 1 addition & 1 deletion remmina/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 0 additions & 2 deletions remmina/external_tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})



82 changes: 44 additions & 38 deletions remmina/src/remmina_external_tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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_"))
Expand All @@ -50,54 +51,59 @@ 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;
const gchar *key, *value;
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;
}
1 change: 0 additions & 1 deletion remmina/src/remmina_external_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions remmina/src/remmina_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -882,7 +882,7 @@ static const GtkActionEntry remmina_main_ui_file_sensitive_menu_entries[] =
{ "ConnectionDelete", GTK_STOCK_DELETE, NULL, "<control>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"), "<control>T", NULL,
G_CALLBACK(remmina_main_action_connection_external_tools) }
Expand Down
5 changes: 5 additions & 0 deletions remmina/src/remmina_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* Boston, MA 02111-1307, USA.
*/

#include "remmina_string_array.h"

#ifndef __REMMINAMAIN_H__
#define __REMMINAMAIN_H__

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 015af78

Please sign in to comment.