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
|
localedir = $(datadir)/locale
bin_PROGRAMS = hexchat
AM_CPPFLAGS = $(GUI_CFLAGS) -DG_DISABLE_CAST_CHECKS -DLOCALEDIR=\"$(localedir)\"
hexchat_LDADD = ../common/libhexchatcommon.a $(GUI_LIBS)
EXTRA_DIST = \
about.h ascii.h banlist.h chanlist.h chanview.h chanview-tabs.c \
chanview-tree.c custom-list.h editlist.h fe-gtk.h fkeys.h gtkutil.h joind.h \
maingui.h menu.h mmx_cmod.S mmx_cmod.h notifygui.h palette.h pixmaps.h \
plugin-tray.h plugingui.c plugingui.h rawlog.h search.h sexy-iso-codes.h \
sexy-spell-entry.h sexy-marshal.h textgui.h urlgrab.h userlistgui.h xtext.h
if USE_MMX
mmx_cmod_S = mmx_cmod.S
endif
if DO_PLUGIN
plugingui_c = plugingui.c
endif
if USE_LIBSEXY
sexy_spell = \
sexy-iso-codes.c sexy-marshal.c sexy-spell-entry.c
endif
hexchat_SOURCES = about.c ascii.c banlist.c chanlist.c chanview.c custom-list.c \
dccgui.c editlist.c fe-gtk.c fkeys.c gtkutil.c ignoregui.c joind.c menu.c \
maingui.c $(mmx_cmod_S) notifygui.c palette.c pixmaps.c plugin-tray.c $(plugingui_c) \
rawlog.c search.c servlistgui.c setup.c $(sexy_spell) textgui.c \
urlgrab.c userlistgui.c xtext.c
color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long *//* 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 char *
plugingui_getfilename (GtkTreeView *view)
{
GtkTreeModel *model;
GtkTreeSelection *sel;
GtkTreeIter iter;
GValue file;
char *str;
memset (&file, 0, sizeof (file));
sel = gtk_tree_view_get_selection (view);
if (gtk_tree_selection_get_selected (sel, &model, &iter))
{
gtk_tree_model_get_value (model, &iter, FILE_COLUMN, &file);
str = g_value_dup_string (&file);
g_value_unset (&file);
return str;
}
return NULL;
}
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_build_filename (get_xdir(), "addons", NULL);
gtkutil_file_req (_("Select a Plugin or Script to load"), plugingui_load_cb, current_sess,
#ifdef WIN32
sub_dir, "*.dll;*.lua;*.pl;*.py;*.tcl;*.js", FRF_FILTERISINITIAL|FRF_EXTENSIONS);
#else
sub_dir, "*.so;*.lua;*.pl;*.py;*.tcl;*.js", 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);
}
static void
plugingui_reloadbutton_cb (GtkWidget *wid, GtkTreeView *view)
{
char *file = plugingui_getfilename(view);
if (file)
{
char *buf = malloc (strlen (file) + 9);
if (strchr (file, ' '))
sprintf (buf, "RELOAD \"%s\"", file);
else
sprintf (buf, "RELOAD %s", file);
handle_command (current_sess, buf, FALSE);
free (buf);
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"));
gtkutil_button (hbox, GTK_STOCK_REFRESH, NULL,
plugingui_reloadbutton_cb, view, _("_Reload"));
fe_pluginlist_update ();
gtk_widget_show_all (plugin_window);
}
|