+gchar *make_cur_font_name(void)
+{
+ gchar *str;
+ struct Item *it;
+
+ if (ui.cur_item_type == ITEM_TEXT)
+ str = g_strdup_printf("%s %.1f", ui.cur_item->font_name, ui.cur_item->font_size);
+ else if (ui.selection!=NULL && ui.selection->items!=NULL &&
+ ui.selection->items->next==NULL &&
+ (it=(struct Item*)ui.selection->items->data)->type == ITEM_TEXT)
+ str = g_strdup_printf("%s %.1f", it->font_name, it->font_size);
+ else
+ str = g_strdup_printf("%s %.1f", ui.font_name, ui.font_size);
+ return str;
+}
+
+void update_font_button(void)
+{
+ gchar *str;
+
+ str = make_cur_font_name();
+ gtk_font_button_set_font_name(GTK_FONT_BUTTON(GET_COMPONENT("fontButton")), str);
+ g_free(str);
+}
+
+gboolean can_accel(GtkWidget *widget, guint id, gpointer data)
+{
+ return GTK_WIDGET_SENSITIVE(widget);
+}
+
+void allow_all_accels(void)
+{
+ g_signal_connect((gpointer) GET_COMPONENT("fileNew"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("fileOpen"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("fileSave"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("filePrint"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("filePrintPDF"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("fileQuit"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("editUndo"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("editRedo"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("editCut"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("editCopy"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("editPaste"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("editDelete"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("viewFullscreen"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("viewZoomIn"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("viewZoomOut"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("viewNormalSize"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("viewPageWidth"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("viewFirstPage"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("viewPreviousPage"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("viewNextPage"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("viewLastPage"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("toolsPen"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("toolsEraser"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("toolsHighlighter"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("toolsText"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+/* g_signal_connect((gpointer) GET_COMPONENT("toolsSelectRegion"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL); */
+ g_signal_connect((gpointer) GET_COMPONENT("toolsSelectRectangle"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("toolsVerticalSpace"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("toolsHand"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("toolsTextFont"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("toolsRuler"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+ g_signal_connect((gpointer) GET_COMPONENT("toolsReco"),
+ "can-activate-accel", G_CALLBACK(can_accel), NULL);
+}
+
+void add_scroll_bindings(void)
+{
+ GtkBindingSet *binding_set;
+
+ binding_set = gtk_binding_set_by_class(
+ G_OBJECT_GET_CLASS(GET_COMPONENT("scrolledwindowMain")));
+ gtk_binding_entry_add_signal(binding_set, GDK_Up, 0,
+ "scroll_child", 2, GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_BACKWARD,
+ G_TYPE_BOOLEAN, FALSE);
+ gtk_binding_entry_add_signal(binding_set, GDK_KP_Up, 0,
+ "scroll_child", 2, GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_BACKWARD,
+ G_TYPE_BOOLEAN, FALSE);
+ gtk_binding_entry_add_signal(binding_set, GDK_Down, 0,
+ "scroll_child", 2, GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_FORWARD,
+ G_TYPE_BOOLEAN, FALSE);
+ gtk_binding_entry_add_signal(binding_set, GDK_KP_Down, 0,
+ "scroll_child", 2, GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_FORWARD,
+ G_TYPE_BOOLEAN, FALSE);
+ gtk_binding_entry_add_signal(binding_set, GDK_Left, 0,
+ "scroll_child", 2, GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_BACKWARD,
+ G_TYPE_BOOLEAN, TRUE);
+ gtk_binding_entry_add_signal(binding_set, GDK_KP_Left, 0,
+ "scroll_child", 2, GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_BACKWARD,
+ G_TYPE_BOOLEAN, TRUE);
+ gtk_binding_entry_add_signal(binding_set, GDK_Right, 0,
+ "scroll_child", 2, GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_FORWARD,
+ G_TYPE_BOOLEAN, TRUE);
+ gtk_binding_entry_add_signal(binding_set, GDK_KP_Right, 0,
+ "scroll_child", 2, GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_FORWARD,
+ G_TYPE_BOOLEAN, TRUE);
+}
+
+gboolean is_event_within_textview(GdkEventButton *event)
+{
+ double pt[2];
+
+ if (ui.cur_item_type!=ITEM_TEXT) return FALSE;
+ get_pointer_coords((GdkEvent *)event, pt);
+ if (pt[0]<ui.cur_item->bbox.left || pt[0]>ui.cur_item->bbox.right) return FALSE;
+ if (pt[1]<ui.cur_item->bbox.top || pt[1]>ui.cur_item->bbox.bottom) return FALSE;
+ return TRUE;
+}
+
+void hide_unimplemented(void)
+{
+ gtk_widget_hide(GET_COMPONENT("filePrintOptions"));
+ gtk_widget_hide(GET_COMPONENT("journalFlatten"));
+ gtk_widget_hide(GET_COMPONENT("papercolorOther"));
+ gtk_widget_hide(GET_COMPONENT("toolsSelectRegion"));
+ gtk_widget_hide(GET_COMPONENT("buttonSelectRegion"));
+ gtk_widget_hide(GET_COMPONENT("button2SelectRegion"));
+ gtk_widget_hide(GET_COMPONENT("button3SelectRegion"));
+ gtk_widget_hide(GET_COMPONENT("colorOther"));
+ gtk_widget_hide(GET_COMPONENT("helpIndex"));
+
+ /* config file only works with glib 2.6 */
+ if (glib_minor_version<6) {
+ gtk_widget_hide(GET_COMPONENT("optionsAutoSavePrefs"));
+ gtk_widget_hide(GET_COMPONENT("optionsSavePreferences"));
+ }
+}