PRIVATE GtkMenuItem* font_size_item;
PRIVATE gchar* file_name = NULL;
-PRIVATE GdkCursor* pot;
+PRIVATE GdkCursor* normal_cursor;
+PRIVATE GdkCursor* link_cursor;
+PRIVATE GdkCursor* pot_cursor;
+PRIVATE gboolean loading = FALSE;
PRIVATE guint statusbar_context;
PRIVATE void create_widget_set(void);
gtk_timeout_add(timeout, f, NULL);
+ normal_cursor = gdk_cursor_new(GDK_TOP_LEFT_ARROW);
+ link_cursor = gdk_cursor_new(GDK_HAND2);
+
source = gdk_bitmap_create_from_data (NULL, pot_bits,
pot_width, pot_height);
mask = gdk_bitmap_create_from_data (NULL, pot_mask_bits,
pot_mask_width, pot_mask_height);
- pot = gdk_cursor_new_from_pixmap (source, mask, &fg, &bg, 8, 8);
+ pot_cursor = gdk_cursor_new_from_pixmap (source, mask, &fg, &bg, 8, 8);
gdk_pixmap_unref (source);
gdk_pixmap_unref (mask);
}
{
GtkMathView* math_view;
GtkMathViewClass* klass;
+ gboolean res;
g_return_val_if_fail(name != NULL, -1);
g_return_val_if_fail(main_area != NULL, -1);
klass = (GtkMathViewClass*) gtk_type_class(gtk_math_view_get_type());
g_return_val_if_fail(klass != NULL, -1);
- gdk_window_set_cursor (main_area->window, pot);
+ gdk_window_set_cursor(main_area->window, pot_cursor);
+ loading = TRUE;
+ res = gtk_math_view_load(math_view, name);
+ gdk_window_set_cursor(main_area->window, normal_cursor);
+ loading = FALSE;
- if (!gtk_math_view_load(math_view, name)) {
+ if (!res) {
load_error_msg(name);
return -1;
}
if (strlen(name) > 40) name += strlen(name) - 40;
gtk_statusbar_push(GTK_STATUSBAR(status_bar), statusbar_context, name);
- /*gdk_window_set_cursor(gtk_widget_get_parent_window(main_area), klass->normal_cursor);*/
-
if (file_name != NULL) g_free(file_name);
file_name = g_strdup(name);
file_dialog("Save As...", save_filename);
}
+PRIVATE void
+element_changed(GtkMathView* math_view, mDOMNodeRef node)
+{
+ g_return_if_fail(math_view != NULL);
+ g_return_if_fail(main_area != NULL);
+ g_return_if_fail(GTK_IS_MATH_VIEW(math_view));
+ /* fprintf(stderr, "node changed: %p %s\n", node, (node != NULL) ? mdom_node_get_name(node) : "-"); */
+
+ if (!loading) {
+ while (node != NULL && !mdom_node_has_attribute_ns(node, DOM_CONST_STRING("href"), XLINK_NS_URI))
+ node = mdom_node_get_parent(node);
+
+ if (node != NULL) {
+ gdk_window_set_cursor(main_area->window, link_cursor);
+ } else
+ gdk_window_set_cursor(main_area->window, normal_cursor);
+ }
+}
+
PRIVATE void
selection_changed(GtkMathView* math_view, mDOMNodeRef node)
{
}
PRIVATE void
-jump(GtkMathView* math_view, mDOMNodeRef node)
+jump(mDOMConstStringRef href)
{
- mDOMStringRef href;
-
- g_return_if_fail(node != NULL);
- href = mdom_node_get_attribute_ns(node, DOM_CONST_STRING("href"), XLINK_NS_URI);
-
- if (href != NULL) {
- pid_t pid;
-
- g_assert(main_area != NULL);
- gdk_window_set_cursor (main_area->window, pot);
-
- pid = fork();
- if (pid == -1) exit(-1);
- if (pid == 0) {
- gchar* open_url = g_strdup_printf("openURL(%s,cic)", href);
- gint fd;
-
- close(0);
- close(1);
- close(2);
-
- fd = open("/dev/null", O_RDWR);
- dup(fd);
- dup(fd);
-
- execlp("netscape", "netscape", "-noraise", "-remote", open_url, NULL);
- perror("exec failed:");
- exit(-1);
- }
- mdom_string_free(href);
+ pid_t pid;
+ g_return_if_fail(href != NULL);
+
+ pid = fork();
+ if (pid == -1) exit(-1);
+ if (pid == 0) {
+ gchar* open_url = g_strdup_printf("openURL(%s,cic)", href);
+ gint fd;
+
+ close(0);
+ close(1);
+ close(2);
+
+ fd = open("/dev/null", O_RDWR);
+ dup(fd);
+ dup(fd);
+
+ execlp("netscape", "netscape", "-noraise", "-remote", open_url, NULL);
+ perror("exec failed:");
+ exit(-1);
}
}
PRIVATE void
clicked(GtkMathView* math_view, gpointer user_data)
{
- if (gtk_math_view_get_action(math_view) != NULL)
+ mDOMNodeRef p = gtk_math_view_get_element(math_view);
+ while (p != NULL && !mdom_node_has_attribute_ns(p, DOM_CONST_STRING("href"), XLINK_NS_URI))
+ p = mdom_node_get_parent(p);
+
+ if (p != NULL) {
+ mDOMStringRef href = mdom_node_get_attribute_ns(p, DOM_CONST_STRING("href"), XLINK_NS_URI);
+ g_assert(href != NULL);
+
+ jump(C_CONST_STRING(href));
+ mdom_string_free(href);
+ } else if (gtk_math_view_get_action(math_view) != NULL)
gtk_math_view_action_toggle(math_view);
}
gtk_widget_show(main_area);
gtk_signal_connect_object (GTK_OBJECT (main_area),
- "selection_changed", GTK_SIGNAL_FUNC (selection_changed),
+ "element_changed", GTK_SIGNAL_FUNC (element_changed),
(gpointer) main_area);
gtk_signal_connect_object (GTK_OBJECT (main_area),
- "jump", GTK_SIGNAL_FUNC(jump),
+ "selection_changed", GTK_SIGNAL_FUNC (selection_changed),
(gpointer) main_area);
gtk_signal_connect_object (GTK_OBJECT (main_area),