summary refs log tree commit diff stats
path: root/src/fe-gtk/setup.c
AgeCommit message (Expand)Author
2015-02-04Implement windows 8.1+ notificationsTingPing
2015-01-13Workaround crash when timestamp format is blankTingPing
2014-12-31Move userlist sorting to frontendTingPing
2014-12-28Remove MSProxy supportTingPing
2014-12-28Fix building as c89TingPing
2014-12-28Use glib for all allocationsTingPing
2014-12-10Create configuration option to control middle click tab close.md_5
2014-06-04Fix dcc dir warning showing when not auto-acceptTingPing
2014-05-12Add global option to suppress nick change eventsBerke Viktor
2014-05-11Add option to bounce dock icon on OSXTingPing
2014-02-15Hide tray balloon option on OSXTingPing
2014-02-14Cleanup the preferences windowTingPing
2014-01-18Update most deprecated gtk functionsTingPing
2014-01-11Add Turkish language to preferencesTingPing
2013-12-25Merge pull request #842 from ManiacTwister/setup-fixTingPing
2013-11-18Fixed setup window title offsetsManiacTwister
2013-11-02Fix invalid timestamps crashing on WindowsTingPing
2013-10-29Round 4 of gtk accessor functions: setup.cTingPing
2013-10-12Better understandable option for the input box's color renderingDenis M.
2013-10-09Remove left over ifdef for spellcheckTingPing
2013-10-08Add preference to change tabs on scrollTingPing
2013-10-03More improvements to libsexyTingPing
2013-10-03Update to gtkspell3's iso code lookupTingPing
2013-10-03Remove gtkspell supportTingPing
2013-09-27Replace xtext's transparency with full window transparencyTingPing
2013-09-25Don't open most windows at mouse positionTingPing
2013-09-20First round of using GTK accessor functionsTingPing
2013-09-14Update tooltip for sound alerts without libcanberraTingPing
2013-08-31Of course mimetype doesn't work on Windows..TingPing
2013-08-31Use mimetypes for audio and imagesTingPing
2013-08-31Improve file dialogsTingPing
2013-07-10Don't grey out log fliename in preferencesTingPing
2013-07-07Increase upper limit for max DCC speed in preferencesTingPing
2013-06-28Added preferences options to enable the server-time extension when available.Diogo Sousa
2013-06-09Add irc_ban_type to preferencesTingPing
2013-06-09Specify what for completion amountTingPing
2013-06-09Add completion_amount to prefsTingPing
2013-05-24Fixed mistake in last commit.Diogo Sousa
2013-05-24Spell check dictionaries were not being updated when changed.Diogo Sousa
2013-05-19Reorganize PreferencesBerke Viktor
2013-05-12Add auto-reconnect to preferencesTingPing
2013-05-07Have gui_input_icon depend on gui_input_nick in prefsTingPing
2013-04-28Remove away announceTingPing
2013-04-28CosmeticsBerke Viktor
2013-04-28Add hints about the beep fileBerke Viktor
2013-04-28Rename Sound to Sounds and reorder Chatting pagesBerke Viktor
2013-04-28Store just the filename if the sound file comes from the default sound dirBerke Viktor
2013-04-28Remove dead code for sound_commandBerke Viktor
2013-04-27Get rid of bundled beepBerke Viktor
2013-04-27Don't use external players on WindowsBerke Viktor
20:53:59 +0200 committer Berke Viktor <bviktor@hexchat.org> 2012-07-26 20:53:59 +0200 Auto-load user plugins and scripts from <config>/addons' href='/git-repos/torxchat.git/commit/src/fe-gtk/plugingui.c?h=feature/flexible-cert&id=ec301a5a5486898cb4d9854a56eb866f1b93f634'>ec301a5a ^
bc651b02 ^
ec301a5a ^
bc651b02 ^
ec301a5a ^
5d9264af ^
4a6ceffb ^






















35821f38 ^
4a6ceffb ^

35821f38 ^
4a6ceffb ^
35821f38 ^
4a6ceffb ^
























e3bdd00f ^
4a6ceffb ^


e3bdd00f ^
4a6ceffb ^


e3bdd00f ^


ecdcc992 ^
4a6ceffb ^



e3bdd00f ^






4a6ceffb ^

e3bdd00f ^
4a6ceffb ^

4a6ceffb ^

e3bdd00f ^
4a6ceffb ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231














                                                                       
                                                                            







                   
                              
                
                                       
                                     



                               
                               
                               
                    
                    


































                                                                                       



                    









                                             
                           














































                                                                                  

                      
                                                                                
 
                                                                                                  
            
                                                                                                                                                  
     
                                                                                                                                                 
      
 
                         






















                                                                               
                                                                        

                   
                                                                       
     
                                                                       
























                                                                                             
                               


                          
                                                 


                       


                                                                                                                                                    
                                               



                                                                   






                                                                                

                                                                      
                                                     

                                                              

                                
                                            
 
/* X-Chat
 * Copyright (C) 1998 Peter Zelezny.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#include "fe-gtk.h"

#include "../common/hexchat.h"
#define PLUGIN_C
typedef struct session hexchat_context;
#include "../common/hexchat-plugin.h"
#include "../common/plugin.h"
#include "../common/util.h"
#include "../common/outbound.h"
#include "../common/fe.h"
#include "../common/hexchatc.h"
#include "../common/cfgfiles.h"
#include "gtkutil.h"
#include "maingui.h"

/* model for the plugin treeview */
enum
{
	NAME_COLUMN,
	VERSION_COLUMN,
	FILE_COLUMN,
	DESC_COLUMN,
	N_COLUMNS
};

static GtkWidget *plugin_window = NULL;


static GtkWidget *
plugingui_treeview_new (GtkWidget *box)
{
	GtkListStore *store;
	GtkWidget *view;
	GtkTreeViewColumn *col;
	int col_id;

	store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING,
	                            G_TYPE_STRING, G_TYPE_STRING);
	g_return_val_if_fail (store != NULL, NULL);
	view = gtkutil_treeview_new (box, GTK_TREE_MODEL (store), NULL,
	                             NAME_COLUMN, _("Name"),
	                             VERSION_COLUMN, _("Version"),
	                             FILE_COLUMN, _("File"),
	                             DESC_COLUMN, _("Description"), -1);
	gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (view), TRUE);
	for (col_id=0; (col = gtk_tree_view_get_column (GTK_TREE_VIEW (view), col_id));
	     col_id++)
			gtk_tree_view_column_set_alignment (col, 0.5);

	return view;
}

static void
plugingui_close (GtkWidget * wid, gpointer a)
{
	plugin_window = NULL;
}

extern GSList *plugin_list;

void
fe_pluginlist_update (void)
{
	hexchat_plugin *pl;
	GSList *list;
	GtkTreeView *view;
	GtkListStore *store;
	GtkTreeIter iter;

	if (!plugin_window)
		return;

	view = g_object_get_data (G_OBJECT (plugin_window), "view");
	store = GTK_LIST_STORE (gtk_tree_view_get_model (view));
	gtk_list_store_clear (store);

	list = plugin_list;
	while (list)
	{
		pl = list->data;
		if (pl->version[0] != 0)
		{
			gtk_list_store_append (store, &iter);
			gtk_list_store_set (store, &iter, NAME_COLUMN, pl->name,
			                    VERSION_COLUMN, pl->version,
			                    FILE_COLUMN, file_part (pl->filename),
			                    DESC_COLUMN, pl->desc, -1);
		}
		list = list->next;
	}
}

static void
plugingui_load_cb (session *sess, char *file)
{
	if (file)
	{
		char *buf = malloc (strlen (file) + 9);

		if (strchr (file, ' '))
			sprintf (buf, "LOAD \"%s\"", file);
		else
			sprintf (buf, "LOAD %s", file);
		handle_command (sess, buf, FALSE);
		free (buf);
	}
}

void
plugingui_load (void)
{
	char *sub_dir;

	sub_dir = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "addons", get_xdir());

	gtkutil_file_req (_("Select a Plugin or Script to load"), plugingui_load_cb, current_sess,
#ifdef WIN32
							sub_dir, "*.dll;*.lua;*.pl;*.py;*.tcl", FRF_ADDFOLDER|FRF_FILTERISINITIAL|FRF_EXTENSIONS);
#else
							sub_dir, "*.so;*.lua;*.pl;*.py;*.tcl", FRF_ADDFOLDER|FRF_FILTERISINITIAL|FRF_EXTENSIONS);
#endif

	g_free (sub_dir);
}

static void
plugingui_loadbutton_cb (GtkWidget * wid, gpointer unused)
{
	plugingui_load ();
}

static void
plugingui_unload (GtkWidget * wid, gpointer unused)
{
	int len;
	char *modname, *file, *buf;
	GtkTreeView *view;
	GtkTreeIter iter;
	
	view = g_object_get_data (G_OBJECT (plugin_window), "view");
	if (!gtkutil_treeview_get_selected (view, &iter, NAME_COLUMN, &modname,
	                                    FILE_COLUMN, &file, -1))
		return;

	len = strlen (file);
#ifdef WIN32
	if (len > 4 && g_ascii_strcasecmp (file + len - 4, ".dll") == 0)
#else
#if defined(__hpux)
	if (len > 3 && g_ascii_strcasecmp (file + len - 3, ".sl") == 0)
#else
	if (len > 3 && g_ascii_strcasecmp (file + len - 3, ".so") == 0)
#endif
#endif
	{
		if (plugin_kill (modname, FALSE) == 2)
			fe_message (_("That plugin is refusing to unload.\n"), FE_MSG_ERROR);
	} else
	{
		/* let python.so or perl.so handle it */
		buf = malloc (strlen (file) + 10);
		if (strchr (file, ' '))
			sprintf (buf, "UNLOAD \"%s\"", file);
		else
			sprintf (buf, "UNLOAD %s", file);
		handle_command (current_sess, buf, FALSE);
		free (buf);
	}

	g_free (modname);
	g_free (file);
}

void
plugingui_open (void)
{
	GtkWidget *view;
	GtkWidget *vbox, *hbox;

	if (plugin_window)
	{
		mg_bring_tofront (plugin_window);
		return;
	}

	plugin_window = mg_create_generic_tab ("Addons", _(DISPLAY_NAME": Plugins and Scripts"),
														 FALSE, TRUE, plugingui_close, NULL,
														 500, 250, &vbox, 0);
	gtkutil_destroy_on_esc (plugin_window);

	view = plugingui_treeview_new (vbox);
	g_object_set_data (G_OBJECT (plugin_window), "view", view);


	hbox = gtk_hbutton_box_new ();
	gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_SPREAD);
	gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
	gtk_box_pack_end (GTK_BOX (vbox), hbox, 0, 0, 0);

	gtkutil_button (hbox, GTK_STOCK_REVERT_TO_SAVED, NULL,
	                plugingui_loadbutton_cb, NULL, _("_Load..."));

	gtkutil_button (hbox, GTK_STOCK_DELETE, NULL,
	                plugingui_unload, NULL, _("_UnLoad"));

	fe_pluginlist_update ();

	gtk_widget_show_all (plugin_window);
}