pidgin/gtkimhtml.c

branch
release-2.x.y
changeset 42586
488055ab5531
parent 41326
0079467afee4
equal deleted inserted replaced
42411:a91c43b65d3e 42586:488055ab5531
1879 g_free(link->url); 1879 g_free(link->url);
1880 g_free(link); 1880 g_free(link);
1881 } 1881 }
1882 1882
1883 /* The callback for an event on a link tag. */ 1883 /* The callback for an event on a link tag. */
1884 static gboolean tag_event(GtkTextTag *tag, GObject *imhtml, GdkEvent *event, GtkTextIter *arg2, gpointer unused) 1884 static gboolean
1885 { 1885 tag_event(GtkTextTag *tag, GObject *event_object, GdkEvent *event, GtkTextIter *arg2, gpointer unused)
1886 {
1887 GtkIMHtml *imhtml = GTK_IMHTML(event_object);
1886 GdkEventButton *event_button = (GdkEventButton *) event; 1888 GdkEventButton *event_button = (GdkEventButton *) event;
1887 if (GTK_IMHTML(imhtml)->editable) 1889
1890 if (imhtml->editable) {
1888 return FALSE; 1891 return FALSE;
1892 }
1893
1889 if (event->type == GDK_BUTTON_RELEASE) { 1894 if (event->type == GDK_BUTTON_RELEASE) {
1890 if ((event_button->button == 1) || (event_button->button == 2)) { 1895 if ((event_button->button == 1) || (event_button->button == 2)) {
1891 GtkTextIter start, end; 1896 GtkTextIter start, end;
1892 /* we shouldn't open a URL if the user has selected something: */ 1897 /* we shouldn't open a URL if the user has selected something: */
1893 if (gtk_text_buffer_get_selection_bounds( 1898 if (gtk_text_buffer_get_selection_bounds(
1894 gtk_text_iter_get_buffer(arg2), &start, &end)) 1899 gtk_text_iter_get_buffer(arg2), &start, &end))
1895 return FALSE; 1900 return FALSE;
1896 gtk_imhtml_activate_tag(GTK_IMHTML(imhtml), tag); 1901 gtk_imhtml_activate_tag(imhtml, tag);
1897 return FALSE; 1902 return FALSE;
1898 } else if(event_button->button == 3) { 1903 } else if(event_button->button == 3) {
1899 GList *children; 1904 GList *children;
1900 GtkWidget *menu; 1905 GtkWidget *menu;
1901 GtkIMHtmlProtocol *proto; 1906 GtkIMHtmlProtocol *proto;
1903 link->imhtml = g_object_ref(imhtml); 1908 link->imhtml = g_object_ref(imhtml);
1904 link->url = g_strdup(g_object_get_data(G_OBJECT(tag), "link_url")); 1909 link->url = g_strdup(g_object_get_data(G_OBJECT(tag), "link_url"));
1905 link->tag = g_object_ref(tag); 1910 link->tag = g_object_ref(tag);
1906 1911
1907 /* Don't want the tooltip around if user right-clicked on link */ 1912 /* Don't want the tooltip around if user right-clicked on link */
1908 if (GTK_IMHTML(imhtml)->tip_window) { 1913 if (imhtml->tip_window) {
1909 gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); 1914 gtk_widget_destroy(imhtml->tip_window);
1910 GTK_IMHTML(imhtml)->tip_window = NULL; 1915 imhtml->tip_window = NULL;
1911 } 1916 }
1912 if (GTK_IMHTML(imhtml)->tip_timer) { 1917 if (imhtml->tip_timer) {
1913 g_source_remove(GTK_IMHTML(imhtml)->tip_timer); 1918 g_source_remove(imhtml->tip_timer);
1914 GTK_IMHTML(imhtml)->tip_timer = 0; 1919 imhtml->tip_timer = 0;
1915 } 1920 }
1916 if (GTK_IMHTML(imhtml)->editable) 1921 if (imhtml->editable) {
1917 gdk_window_set_cursor(event_button->window, GTK_IMHTML(imhtml)->text_cursor); 1922 gdk_window_set_cursor(event_button->window, imhtml->text_cursor);
1918 else 1923 } else {
1919 gdk_window_set_cursor(event_button->window, GTK_IMHTML(imhtml)->arrow_cursor); 1924 gdk_window_set_cursor(event_button->window, imhtml->arrow_cursor);
1925 }
1920 menu = gtk_menu_new(); 1926 menu = gtk_menu_new();
1921 g_object_set_data_full(G_OBJECT(menu), "x-imhtml-url-data", link, 1927 g_object_set_data_full(G_OBJECT(menu), "x-imhtml-url-data", link,
1922 (GDestroyNotify)gtk_imhtml_link_destroy); 1928 (GDestroyNotify)gtk_imhtml_link_destroy);
1923 1929
1924 proto = imhtml_find_protocol(link->url, FALSE); 1930 proto = imhtml_find_protocol(link->url, FALSE);
1925 1931
1926 if (proto && proto->context_menu) { 1932 if (proto && proto->context_menu) {
1927 proto->context_menu(GTK_IMHTML(link->imhtml), link, menu); 1933 proto->context_menu(link->imhtml, link, menu);
1928 } 1934 }
1929 1935
1930 children = gtk_container_get_children(GTK_CONTAINER(menu)); 1936 children = gtk_container_get_children(GTK_CONTAINER(menu));
1931 if (!children) { 1937 if (!children) {
1932 GtkWidget *item = gtk_menu_item_new_with_label(_("No actions available")); 1938 GtkWidget *item = gtk_menu_item_new_with_label(_("No actions available"));

mercurial