gnome-terminal r2930 - trunk/src
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-terminal r2930 - trunk/src
- Date: Thu, 26 Jun 2008 19:51:11 +0000 (UTC)
Author: chpe
Date: Thu Jun 26 19:51:10 2008
New Revision: 2930
URL: http://svn.gnome.org/viewvc/gnome-terminal?rev=2930&view=rev
Log:
Simplify the match clicked code by unifying the URL and S/Key case.
Modified:
trunk/src/terminal-marshal.list
trunk/src/terminal-screen.c
trunk/src/terminal-screen.h
trunk/src/terminal-window.c
Modified: trunk/src/terminal-marshal.list
==============================================================================
--- trunk/src/terminal-marshal.list (original)
+++ trunk/src/terminal-marshal.list Thu Jun 26 19:51:10 2008
@@ -1 +1 @@
-VOID:STRING,INT
+BOOLEAN:STRING,INT,UINT
Modified: trunk/src/terminal-screen.c
==============================================================================
--- trunk/src/terminal-screen.c (original)
+++ trunk/src/terminal-screen.c Thu Jun 26 19:51:10 2008
@@ -67,16 +67,14 @@
double font_scale;
guint recheck_working_dir_idle;
gboolean user_title; /* title was manually set */
- GSList *url_tags;
- GSList *skey_tags;
+ GSList *match_tags;
};
enum
{
PROFILE_SET,
SHOW_POPUP_MENU,
- SKEY_CLICKED,
- URL_CLICKED,
+ MATCH_CLICKED,
CLOSE_SCREEN,
LAST_SIGNAL
};
@@ -140,18 +138,11 @@
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);
#endif /* VTE < 0.6.15 */
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];
@@ -407,7 +398,7 @@
tag_data->tag = vte_terminal_match_add_gregex (terminal, url_regexes[i], 0);
vte_terminal_match_set_cursor_type (terminal, tag_data->tag, URL_MATCH_CURSOR);
- priv->url_tags = g_slist_prepend (priv->url_tags, tag_data);
+ priv->match_tags = g_slist_prepend (priv->match_tags, tag_data);
}
#else /* VTE < 0.6.15 */
@@ -592,25 +583,15 @@
1,
G_TYPE_POINTER);
- signals[SKEY_CLICKED] =
- g_signal_new (I_("skey-clicked"),
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (TerminalScreenClass, skey_clicked),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1, G_TYPE_STRING);
-
- signals[URL_CLICKED] =
- g_signal_new (I_("url-clicked"),
+ signals[MATCH_CLICKED] =
+ g_signal_new (I_("match-clicked"),
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (TerminalScreenClass, url_clicked),
- NULL, NULL,
- _terminal_marshal_VOID__STRING_INT,
- G_TYPE_NONE,
- 2, G_TYPE_STRING, G_TYPE_INT);
+ G_STRUCT_OFFSET (TerminalScreenClass, match_clicked),
+ g_signal_accumulator_true_handled, NULL,
+ _terminal_marshal_BOOLEAN__STRING_INT_UINT,
+ G_TYPE_BOOLEAN,
+ 3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_UINT);
signals[CLOSE_SCREEN] =
g_signal_new (I_("close-screen"),
@@ -738,11 +719,8 @@
g_strfreev (priv->override_command);
g_free (priv->working_dir);
- g_slist_foreach (priv->url_tags, (GFunc) free_tag_data, NULL);
- g_slist_free (priv->url_tags);
-
- g_slist_foreach (priv->skey_tags, (GFunc) free_tag_data, NULL);
- g_slist_free (priv->skey_tags);
+ g_slist_foreach (priv->match_tags, (GFunc) free_tag_data, NULL);
+ g_slist_free (priv->match_tags);
G_OBJECT_CLASS (terminal_screen_parent_class)->finalize (object);
}
@@ -879,20 +857,20 @@
TagData *tag_data;
tag_data = g_slice_new (TagData);
- tag_data->flavor = FLAVOR_AS_IS;
+ tag_data->flavor = FLAVOR_SKEY;
tag_data->tag = vte_terminal_match_add_gregex (vte_terminal, skey_regexes[i], 0);
vte_terminal_match_set_cursor_type (vte_terminal, tag_data->tag, SKEY_MATCH_CURSOR);
- priv->skey_tags = g_slist_prepend (priv->skey_tags, tag_data);
+ priv->match_tags = g_slist_prepend (priv->match_tags, tag_data);
}
#else /* VTE < 0.6.15 */
- terminal_screen_skey_match_add (screen,
- "s/key [0-9]* [-A-Za-z0-9]*",
- FLAVOR_AS_IS);
-
- terminal_screen_skey_match_add (screen,
- "otp-[a-z0-9]* [0-9]* [-A-Za-z0-9]*",
- FLAVOR_AS_IS);
+ terminal_screen_match_add (screen,
+ "s/key [0-9]* [-A-Za-z0-9]*",
+ FLAVOR_SKEY);
+
+ terminal_screen_match_add (screen,
+ "otp-[a-z0-9]* [0-9]* [-A-Za-z0-9]*",
+ FLAVOR_SKEY);
#endif /* VTE 0.6.15 */
}
else
@@ -1623,6 +1601,8 @@
{
TerminalScreen *screen = TERMINAL_SCREEN (widget);
TerminalScreenPrivate *priv = screen->priv;
+ gboolean (* button_press_event) (GtkWidget*, GdkEventButton*) =
+ GTK_WIDGET_CLASS (terminal_screen_parent_class)->button_press_event;
int char_width, char_height;
gboolean dingus_button;
char *matched_string;
@@ -1633,45 +1613,35 @@
terminal_screen_get_cell_size (screen, &char_width, &char_height);
- matched_string =
- terminal_screen_check_match (screen,
- event->x / char_width,
- event->y / char_height,
- &matched_flavor);
+ matched_string = terminal_screen_check_match (screen,
+ event->x / char_width,
+ event->y / char_height,
+ &matched_flavor);
+
dingus_button = ((event->button == 1) || (event->button == 2));
- if (dingus_button &&
- (state & GDK_CONTROL_MASK) &&
- terminal_profile_get_property_boolean (priv->profile, TERMINAL_PROFILE_USE_SKEY))
- {
- char *skey_match;
-
- skey_match = terminal_screen_skey_check_match (screen,
- event->x / char_width,
- event->y / char_height,
- NULL);
- if (skey_match != NULL)
- {
- g_signal_emit (screen, signals[SKEY_CLICKED], 0, skey_match);
- g_free (skey_match);
- g_free (matched_string);
-
- return TRUE;
- }
- }
-
- if (dingus_button &&
- (state & GDK_CONTROL_MASK) != 0 &&
- matched_string != NULL)
+ if (matched_string != NULL &&
+ (event->button == 1 || event->button == 2) &&
+ (state & GDK_CONTROL_MASK))
{
- gtk_widget_grab_focus (widget);
+ gboolean handled = FALSE;
- g_signal_emit (screen, signals[URL_CLICKED], 0, matched_string, matched_flavor);
- g_free (matched_string);
+ if (matched_flavor != FLAVOR_SKEY ||
+ terminal_profile_get_property_boolean (priv->profile, TERMINAL_PROFILE_USE_SKEY))
+ {
+ g_signal_emit (screen, signals[MATCH_CLICKED], 0,
+ matched_string,
+ matched_flavor,
+ state,
+ &handled);
+ }
- return TRUE; /* don't do anything else such as select with the click */
+ g_free (matched_string);
+
+ if (handled)
+ return TRUE; /* don't do anything else such as select with the click */
}
-
+
if (event->button == 3 &&
(state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0)
{
@@ -1679,6 +1649,7 @@
info = terminal_screen_popup_info_new (screen);
info->button = event->button;
+ info->state = state;
info->timestamp = event->time;
info->string = matched_string; /* adopted */
info->flavour = matched_flavor;
@@ -1690,8 +1661,8 @@
}
/* default behavior is to let the terminal widget deal with it */
- if (GTK_WIDGET_CLASS (terminal_screen_parent_class)->button_press_event)
- return GTK_WIDGET_CLASS (terminal_screen_parent_class)->button_press_event (widget, event);
+ if (button_press_event)
+ return button_press_event (widget, event);
return FALSE;
}
@@ -2237,7 +2208,7 @@
#if !VTE_CHECK_VERSION (0, 16, 15)
static void
-terminal_screen_match_add (TerminalScreen *screen,
+terminal_screen_match_add (TerminalScreen *screen,
const char *regexp,
int flavor)
{
@@ -2253,27 +2224,7 @@
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;
- VteTerminal *terminal = VTE_TERMINAL (screen);
- TagData *tag_data;
- int tag;
-
- tag = vte_terminal_match_add (terminal, regexp);
- vte_terminal_match_set_cursor_type (terminal, tag, SKEY_MATCH_CURSOR);
-
- tag_data = g_slice_new (TagData);
- tag_data->tag = tag;
- tag_data->flavor = flavor;
-
- priv->skey_tags = g_slist_append (priv->skey_tags, tag_data);
+ priv->match_tags = g_slist_append (priv->match_tags, tag_data);
}
#endif /* VTE 0.6.15 */
@@ -2282,15 +2233,22 @@
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) free_tag_data, NULL);
- g_slist_free (priv->skey_tags);
- priv->skey_tags = NULL;
+ GSList *l, *next;
+
+ l = priv->match_tags;
+ while (l != NULL)
+ {
+ TagData *tag_data = (TagData *) l->data;
+
+ next = l->next;
+ if (tag_data->flavor == FLAVOR_SKEY)
+ {
+ vte_terminal_match_remove (VTE_TERMINAL (screen), tag_data->tag);
+ priv->match_tags = g_slist_delete_link (priv->match_tags, l);
+ }
+
+ l = next;
+ }
}
static char*
@@ -2301,41 +2259,14 @@
{
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;
+ int tag;
char *match;
match = vte_terminal_match_check (VTE_TERMINAL (screen), column, row, &tag);
- for (tags = priv->skey_tags; tags != NULL; tags = tags->next)
+ for (tags = priv->match_tags; tags != NULL; tags = tags->next)
{
TagData *tag_data = (TagData*) tags->data;
- if (GPOINTER_TO_INT(tag_data->tag) == tag)
+ if (tag_data->tag == tag)
{
if (flavor)
*flavor = tag_data->flavor;
Modified: trunk/src/terminal-screen.h
==============================================================================
--- trunk/src/terminal-screen.h (original)
+++ trunk/src/terminal-screen.h Thu Jun 26 19:51:10 2008
@@ -36,7 +36,8 @@
FLAVOR_AS_IS,
FLAVOR_DEFAULT_TO_HTTP,
FLAVOR_VOIP_CALL,
- FLAVOR_EMAIL
+ FLAVOR_EMAIL,
+ FLAVOR_SKEY
} TerminalURLFlavour;
/* Forward decls */
@@ -69,11 +70,10 @@
TerminalProfile *old_profile);
void (* show_popup_menu) (TerminalScreen *screen,
TerminalScreenPopupInfo *info);
- void (* skey_clicked) (TerminalScreen *screen,
- const char *skey_challenge);
- void (* url_clicked) (TerminalScreen *screen,
+ gboolean (* match_clicked) (TerminalScreen *screen,
const char *url,
- int flavour);
+ int flavour,
+ guint state);
void (* close_screen) (TerminalScreen *screen);
};
@@ -146,6 +146,7 @@
char *string;
TerminalURLFlavour flavour;
guint button;
+ guint state;
guint32 timestamp;
};
Modified: trunk/src/terminal-window.c
==============================================================================
--- trunk/src/terminal-window.c (original)
+++ trunk/src/terminal-window.c Thu Jun 26 19:51:10 2008
@@ -999,7 +999,7 @@
can_paste = targets != NULL && gtk_targets_include_text (targets, n_targets);
can_paste_uris = targets != NULL && gtk_targets_include_uri (targets, n_targets);
- show_link = info->string != NULL && info->flavour != FLAVOR_EMAIL && info->flavour != FLAVOR_VOIP_CALL;
+ show_link = info->string != NULL && (info->flavour == FLAVOR_AS_IS || info->flavour == FLAVOR_DEFAULT_TO_HTTP);
show_email_link = info->string != NULL && info->flavour == FLAVOR_EMAIL;
show_call_link = info->string != NULL && info->flavour == FLAVOR_VOIP_CALL;
@@ -1084,32 +1084,31 @@
terminal_screen_popup_info_ref (info));
}
-static void
-screen_skey_clicked_cb (TerminalScreen *screen,
- const char *skey_challenge,
- TerminalWindow *window)
+static gboolean
+screen_match_clicked_cb (TerminalScreen *screen,
+ const char *match,
+ int flavour,
+ guint state,
+ TerminalWindow *window)
{
TerminalWindowPrivate *priv = window->priv;
if (screen != priv->active_screen)
- return;
-
- terminal_skey_do_popup (GTK_WINDOW (window), screen, skey_challenge);
-}
-
-static void
-screen_url_clicked_cb (TerminalScreen *screen,
- const char *url,
- int flavour,
- TerminalWindow *window)
-{
- TerminalWindowPrivate *priv = window->priv;
+ return FALSE;
- if (screen != priv->active_screen)
- return;
+ switch (flavour)
+ {
+ case FLAVOR_SKEY:
+ terminal_skey_do_popup (GTK_WINDOW (window), screen, match);
+ break;
+ default:
+ gtk_widget_grab_focus (GTK_WIDGET (screen));
+ terminal_util_open_url (GTK_WIDGET (window), match, flavour,
+ gtk_get_current_event_time ());
+ break;
+ }
- terminal_util_open_url (GTK_WIDGET (window), url, flavour,
- gtk_get_current_event_time ());
+ return TRUE;
}
static void
@@ -2190,10 +2189,8 @@
g_signal_connect (screen, "show-popup-menu",
G_CALLBACK (screen_show_popup_menu_callback), window);
- g_signal_connect (screen, "skey-clicked",
- G_CALLBACK (screen_skey_clicked_cb), window);
- g_signal_connect (screen, "url-clicked",
- G_CALLBACK (screen_url_clicked_cb), window);
+ g_signal_connect (screen, "match-clicked",
+ G_CALLBACK (screen_match_clicked_cb), window);
g_signal_connect (screen, "close-screen",
G_CALLBACK (screen_close_cb), window);
@@ -2277,11 +2274,7 @@
window);
g_signal_handlers_disconnect_by_func (screen,
- G_CALLBACK (screen_skey_clicked_cb),
- window);
-
- g_signal_handlers_disconnect_by_func (screen,
- G_CALLBACK (screen_url_clicked_cb),
+ G_CALLBACK (screen_match_clicked_cb),
window);
g_signal_handlers_disconnect_by_func (screen,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]