gnome-terminal r2586 - trunk/src
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-terminal r2586 - trunk/src
- Date: Thu, 29 May 2008 19:36:06 +0000 (UTC)
Author: chpe
Date: Thu May 29 19:36:06 2008
New Revision: 2586
URL: http://svn.gnome.org/viewvc/gnome-terminal?rev=2586&view=rev
Log:
Move the dingus/skey matcher to TerminalScreen.
Modified:
trunk/src/terminal-screen.c
trunk/src/terminal-widget-vte.c
trunk/src/terminal-widget.h
Modified: trunk/src/terminal-screen.c
==============================================================================
--- trunk/src/terminal-screen.c (original)
+++ trunk/src/terminal-screen.c Thu May 29 19:36:06 2008
@@ -53,6 +53,12 @@
#define MONOSPACE_FONT_KEY MONOSPACE_FONT_DIR "/monospace_font_name"
#define HTTP_PROXY_DIR "/system/http_proxy"
+typedef struct
+{
+ int tag;
+ int flavor;
+} TagData;
+
struct _TerminalScreenPrivate
{
GtkWidget *term;
@@ -73,6 +79,8 @@
guint recheck_working_dir_idle;
guint gconf_connection_id;
gboolean user_title; /* title was manually set */
+ GSList *url_tags;
+ GSList *skey_tags;
};
enum {
@@ -123,6 +131,22 @@
GConfEntry *entry,
gpointer user_data);
+static void terminal_screen_match_add (TerminalScreen *screen,
+ const char *regexp,
+ int flavor);
+static void terminal_screen_skey_match_add (TerminalScreen *screen,
+ const char *regexp,
+ int flavor);
+static char* terminal_screen_check_match (TerminalScreen *screen,
+ int column,
+ int row,
+ int *flavor);
+static char* terminal_screen_skey_check_match (TerminalScreen *screen,
+ int column,
+ int row,
+ int *flavor);
+static void terminal_screen_skey_match_remove (TerminalScreen *screen);
+
static guint signals[LAST_SIGNAL];
G_DEFINE_TYPE (TerminalScreen, terminal_screen, VTE_TYPE_TERMINAL)
@@ -289,6 +313,8 @@
priv = screen->priv = G_TYPE_INSTANCE_GET_PRIVATE (screen, TERMINAL_TYPE_SCREEN, TerminalScreenPrivate);
+ vte_terminal_set_mouse_autohide (VTE_TERMINAL (screen), TRUE);
+
priv->working_dir = g_get_current_dir ();
if (priv->working_dir == NULL) /* shouldn't ever happen */
priv->working_dir = g_strdup (g_get_home_dir ());
@@ -297,7 +323,6 @@
priv->recheck_working_dir_idle = 0;
priv->term = GTK_WIDGET (screen);
- terminal_widget_set_implementation (priv->term);
priv->font_scale = PANGO_SCALE_MEDIUM;
@@ -309,21 +334,21 @@
#define USER "[" USERCHARS "]+(:["PASSCHARS "]+)?"
#define URLPATH "/[" PATHCHARS "]*[^]'.}>) \t\r\n,\\\"]"
- terminal_widget_match_add (priv->term,
+ terminal_screen_match_add (screen,
"\\<" SCHEME "//(" USER "@)?[" HOSTCHARS ".]+"
"(:[0-9]+)?(" URLPATH ")?\\>/?", FLAVOR_AS_IS);
- terminal_widget_match_add (priv->term,
+ terminal_screen_match_add (screen,
"\\<(www|ftp)[" HOSTCHARS "]*\\.[" HOSTCHARS ".]+"
"(:[0-9]+)?(" URLPATH ")?\\>/?",
FLAVOR_DEFAULT_TO_HTTP);
- terminal_widget_match_add (priv->term,
+ terminal_screen_match_add (screen,
"\\<(mailto:)?[a-z0-9][a-z0-9 -]* [a-z0-9]"
"[a-z0-9-]*(\\.[a-z0-9][a-z0-9-]*)+\\>",
FLAVOR_EMAIL);
- terminal_widget_match_add (priv->term,
+ terminal_screen_match_add (screen,
"\\<news:[-A-Z\\^_a-z{|}~!\"#$%&'()*+,./0-9;:=?`]+"
"@[" HOSTCHARS ".]+(:[0-9]+)?\\>", FLAVOR_AS_IS);
@@ -491,6 +516,12 @@
g_strfreev (priv->override_command);
g_free (priv->working_dir);
+ g_slist_foreach (priv->url_tags, (GFunc) g_free, NULL);
+ g_slist_free (priv->url_tags);
+
+ g_slist_foreach (priv->skey_tags, (GFunc) g_free, NULL);
+ g_slist_free (priv->skey_tags);
+
G_OBJECT_CLASS (terminal_screen_parent_class)->finalize (object);
}
@@ -597,17 +628,17 @@
if (terminal_profile_get_use_skey (priv->profile))
{
- terminal_widget_skey_match_add (priv->term,
+ terminal_screen_skey_match_add (screen,
"s/key [0-9]* [-A-Za-z0-9]*",
FLAVOR_AS_IS);
- terminal_widget_skey_match_add (priv->term,
+ terminal_screen_skey_match_add (screen,
"otp-[a-z0-9]* [0-9]* [-A-Za-z0-9]*",
FLAVOR_AS_IS);
}
else
{
- terminal_widget_skey_match_remove (priv->term);
+ terminal_screen_skey_match_remove (screen);
}
bg_type = terminal_profile_get_background_type (profile);
@@ -1370,7 +1401,7 @@
terminal_screen_get_cell_size (screen, &char_width, &char_height);
matched_string =
- terminal_widget_check_match (term,
+ terminal_screen_check_match (screen,
event->x / char_width,
event->y / char_height,
&matched_flavor);
@@ -1382,7 +1413,7 @@
{
gchar *skey_match;
- skey_match = terminal_widget_skey_check_match (term,
+ skey_match = terminal_screen_skey_check_match (screen,
event->x / char_width,
event->y / char_height,
NULL);
@@ -2241,3 +2272,108 @@
*cell_width_pixels = terminal->char_width;
*cell_height_pixels = terminal->char_height;
}
+
+static void
+terminal_screen_match_add (TerminalScreen *screen,
+ const char *regexp,
+ int flavor)
+{
+ TerminalScreenPrivate *priv = screen->priv;
+ TagData *tag_data;
+ int tag;
+
+ tag = vte_terminal_match_add (VTE_TERMINAL (screen), regexp);
+
+ tag_data = g_new0 (TagData, 1);
+ tag_data->tag = tag;
+ tag_data->flavor = flavor;
+
+ priv->url_tags = g_slist_append (priv->url_tags, tag_data);
+}
+
+static void
+terminal_screen_skey_match_add (TerminalScreen *screen,
+ const char *regexp,
+ int flavor)
+{
+ TerminalScreenPrivate *priv = screen->priv;
+ TagData *tag_data;
+ int tag;
+
+ tag = vte_terminal_match_add ( VTE_TERMINAL (screen), regexp);
+
+ tag_data = g_new0 (TagData, 1);
+ tag_data->tag = tag;
+ tag_data->flavor = flavor;
+
+ priv->skey_tags = g_slist_append (priv->skey_tags, tag_data);
+}
+
+static void
+terminal_screen_skey_match_remove (TerminalScreen *screen)
+{
+ TerminalScreenPrivate *priv = screen->priv;
+ GSList *tags;
+
+ for (tags = priv->skey_tags; tags != NULL; tags = tags->next)
+ vte_terminal_match_remove (VTE_TERMINAL (screen),
+ GPOINTER_TO_INT(((TagData*)tags->data)->tag));
+
+ g_slist_foreach (priv->skey_tags, (GFunc) g_free, NULL);
+ g_slist_free (priv->skey_tags);
+ priv->skey_tags = NULL;
+}
+
+static char*
+terminal_screen_check_match (TerminalScreen *screen,
+ int column,
+ int row,
+ int *flavor)
+{
+ TerminalScreenPrivate *priv = screen->priv;
+ GSList *tags;
+ gint tag;
+ char *match;
+
+ match = vte_terminal_match_check (VTE_TERMINAL (screen), column, row, &tag);
+ for (tags = priv->url_tags; tags != NULL; tags = tags->next)
+ {
+ TagData *tag_data = (TagData*) tags->data;
+ if (GPOINTER_TO_INT(tag_data->tag) == tag)
+ {
+ if (flavor)
+ *flavor = tag_data->flavor;
+ return match;
+ }
+ }
+
+ g_free (match);
+ return NULL;
+}
+
+static char*
+terminal_screen_skey_check_match (TerminalScreen *screen,
+ int column,
+ int row,
+ int *flavor)
+{
+ TerminalScreenPrivate *priv = screen->priv;
+ GSList *tags;
+ gint tag;
+ char *match;
+
+ match = vte_terminal_match_check (VTE_TERMINAL (screen), column, row, &tag);
+ for (tags = priv->skey_tags; tags != NULL; tags = tags->next)
+ {
+ TagData *tag_data = (TagData*) tags->data;
+ if (GPOINTER_TO_INT(tag_data->tag) == tag)
+ {
+ if (flavor)
+ *flavor = tag_data->flavor;
+ return match;
+ }
+ }
+
+ g_free (match);
+ return NULL;
+}
Modified: trunk/src/terminal-widget-vte.c
==============================================================================
--- trunk/src/terminal-widget-vte.c (original)
+++ trunk/src/terminal-widget-vte.c Thu May 29 19:36:06 2008
@@ -32,166 +32,6 @@
#define UNIMPLEMENTED /* g_warning (G_STRLOC": unimplemented") */
-typedef struct
-{
- int tag;
- int flavor;
-} TagData;
-
-typedef struct
-{
- GSList *url_tags;
- GSList *skey_tags;
-} VteData;
-
-static void
-free_vte_data (gpointer data)
-{
- VteData *vte;
-
- vte = data;
-
- g_slist_foreach (vte->url_tags, (GFunc) g_free, NULL);
- g_slist_free(vte->url_tags);
-
- g_slist_foreach (vte->skey_tags, (GFunc) g_free, NULL);
- g_slist_free(vte->skey_tags);
-
- g_free (vte);
-}
-
-/* FIXMEchpe: to be removed later */
-void
-terminal_widget_set_implementation (GtkWidget *terminal)
-{
- VteData *data;
-
- vte_terminal_set_mouse_autohide(VTE_TERMINAL(terminal), TRUE);
-
- data = g_new0 (VteData, 1);
-
- data->url_tags = NULL;
- data->skey_tags = NULL;
-
- g_object_set_data_full (G_OBJECT (terminal), "terminal-widget-data",
- data, free_vte_data);
-}
-
-void
-terminal_widget_match_add (GtkWidget *widget,
- const char *regexp,
- int flavor)
-{
- TagData *tag_data;
- VteData *data;
- int tag;
-
- data = g_object_get_data (G_OBJECT (widget), "terminal-widget-data");
-
- tag = vte_terminal_match_add (VTE_TERMINAL (widget), regexp);
-
- tag_data = g_new0 (TagData, 1);
- tag_data->tag = tag;
- tag_data->flavor = flavor;
-
- data->url_tags = g_slist_append (data->url_tags, tag_data);
-}
-
-void
-terminal_widget_skey_match_add (GtkWidget *widget,
- const char *regexp,
- int flavor)
-{
- TagData *tag_data;
- VteData *data;
- int tag;
-
- data = g_object_get_data (G_OBJECT (widget), "terminal-widget-data");
-
- tag = vte_terminal_match_add(VTE_TERMINAL(widget), regexp);
-
- tag_data = g_new0 (TagData, 1);
- tag_data->tag = tag;
- tag_data->flavor = flavor;
-
- data->skey_tags = g_slist_append (data->skey_tags, tag_data);
-}
-
-void
-terminal_widget_skey_match_remove (GtkWidget *widget)
-{
- VteData *data;
- GSList *tags;
-
- data = g_object_get_data (G_OBJECT (widget), "terminal-widget-data");
-
- for (tags = data->skey_tags; tags != NULL; tags = g_slist_next(tags))
- vte_terminal_match_remove(VTE_TERMINAL(widget),
- GPOINTER_TO_INT(((TagData*)tags->data)->tag));
-
- g_slist_foreach (data->skey_tags, (GFunc) g_free, NULL);
- g_slist_free(data->skey_tags);
- data->skey_tags = NULL;
-}
-
-char*
-terminal_widget_check_match (GtkWidget *widget,
- int column,
- int row,
- int *flavor)
-{
- VteData *data;
- GSList *tags;
- gint tag;
- char *match;
-
- data = g_object_get_data (G_OBJECT (widget), "terminal-widget-data");
-
- match = vte_terminal_match_check(VTE_TERMINAL(widget), column, row, &tag);
- for (tags = data->url_tags; tags != NULL; tags = g_slist_next(tags))
- {
- TagData *tag_data = (TagData*) tags->data;
- if (GPOINTER_TO_INT(tag_data->tag) == tag)
- {
- if (flavor)
- *flavor = tag_data->flavor;
- return match;
- }
- }
-
- g_free (match);
- return NULL;
-}
-
-char*
-terminal_widget_skey_check_match (GtkWidget *widget,
- int column,
- int row,
- int *flavor)
-{
- VteData *data;
- GSList *tags;
- gint tag;
- char *match;
-
- data = g_object_get_data (G_OBJECT (widget), "terminal-widget-data");
-
- match = vte_terminal_match_check(VTE_TERMINAL(widget), column, row, &tag);
- for (tags = data->skey_tags; tags != NULL; tags = g_slist_next(tags))
- {
- TagData *tag_data = (TagData*) tags->data;
- if (GPOINTER_TO_INT(tag_data->tag) == tag)
- {
- if (flavor)
- *flavor = tag_data->flavor;
- return match;
- }
- }
-
- g_free (match);
- return NULL;
-}
-
void
terminal_widget_set_colors (GtkWidget *widget,
const GdkColor *foreground,
Modified: trunk/src/terminal-widget.h
==============================================================================
--- trunk/src/terminal-widget.h (original)
+++ trunk/src/terminal-widget.h Thu May 29 19:36:06 2008
@@ -37,22 +37,6 @@
*
*/
-void terminal_widget_set_implementation (GtkWidget *widget);
-void terminal_widget_match_add (GtkWidget *widget,
- const char *regexp,
- int flavor);
-void terminal_widget_skey_match_add (GtkWidget *widget,
- const char *regexp,
- int flavor);
-char* terminal_widget_check_match (GtkWidget *widget,
- int column,
- int row,
- int *flavor);
-char* terminal_widget_skey_check_match (GtkWidget *widget,
- int column,
- int row,
- int *flavor);
-void terminal_widget_skey_match_remove (GtkWidget *widget);
void terminal_widget_set_colors (GtkWidget *widget,
const GdkColor *foreground,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]