]> git.donarmstrong.com Git - xournal.git/commitdiff
focus and other patches
authorauroux <auroux>
Sat, 26 Sep 2009 06:50:45 +0000 (06:50 +0000)
committerauroux <auroux>
Sat, 26 Sep 2009 06:50:45 +0000 (06:50 +0000)
src/TODO
src/main.c
src/xo-callbacks.c
src/xo-file.c
src/xo-misc.c
src/xo-misc.h
src/xournal.h

index b0b973b21e4f5c3e0cb7917e5cf43fd9d54e0d0a..a0a8ef6b4f6a9d1245f22a985818b8de313d5b82 100644 (file)
--- a/src/TODO
+++ b/src/TODO
@@ -45,30 +45,31 @@ DONE: disable ctrl-left/right accelerators during text edition
 DONE: custom color chooser button (after a patch contributed by Alex Ray)
 DONE: remember last used directory (after a patch contributed by Lu Zhihe)
 DONE: discard Alt-click and Control-click events
-
-(go through Patches tracker and take the good stuff... now at 2009-05-09)
-
-DONE?? option to have buttons *toggle* the tool rather than act as tool
+DONE: option to have buttons *toggle* the tool rather than act as tool
        (ie button 2 causes button 1 to map to tool 2) [Dylan Thurston]
+DONE: patch to fix focus + allow up/dn in single page mode (Bob McElrath)
+      also comment out contents of reset_focus() ? (tracker patch #2494022)
+DONE: patch to fix underscores in MRU filename display (Bob McElrath)
+DONE: patch to avoid tiny file dialogs (Bob McElrath)
 
-** commit patches from Bob McElrath
+(go through Patches tracker and take the good stuff... now at 2009-05-09)
 
 - paper color chooser (see tracker 2083103)
 - prerelease: update help file (remove references to pdftoppm/libgnomeprint
   & update to poppler/gtkprint)
 - REMOVE BINARY INSTALLER (poppler breaks ABI all the time)
+   but add a configure script (+ Makefile.in, etc ?)
 - document config options into manual file?
 - PDF bg memory usage throttling / delete oldest pdf backgrounds
 - replace ttsubset by something more modern? (eg. from cairo ?)
 - auto-hide patch from ~/prog/src/xournal-autohide/ ?
      (check for cpu usage; handle BOTH edges
       and only (un)hide stuff at the correct edge!)
+** remove reset_focus() and calls to it, after enough testing.
+   check if we should call reset_recognizer() in some of those places
+   (e.g., undo/redo?)
 ** if bg pdf not found in absolute path, look in path of xoj file before
    prompting user.
-** patch to fix focus + allow up/dn in single page mode (Bob McElrath)
-   also comment out contents of reset_focus() ? (tracker patch #2494022)
-** patch to fix underscores in MRU filename display (McElrath) (tracker)
-   (fix memory leak)
 ** UI update (Bob McElrath) -- eliminating status bar, compact layout,
    "compact interface" by default; themes, with line in config file
    to load pixmaps from pixmaps/$THEME/ (see Jan 9, 2009 emails)
index 001d09b6e3bdb6f44cede862f4cc0a011b5a8f92..1c8acbfca25e16a89d2b5072c69f3a22d60f82fd 100644 (file)
@@ -126,6 +126,15 @@ void init_stuff (int argc, char *argv[])
   allow_all_accels();
   add_scroll_bindings();
 
+  // prevent interface items from stealing focus
+  // glade doesn't properly handle can_focus, so manually set it
+  gtk_combo_box_set_focus_on_click(GTK_COMBO_BOX(GET_COMPONENT("comboLayer")), FALSE);
+  g_signal_connect(GET_COMPONENT("spinPageNo"), "activate",
+          G_CALLBACK(handle_activate_signal), NULL);
+  gtk_container_foreach(GTK_CONTAINER(winMain), unset_flags, (gpointer)GTK_CAN_FOCUS);
+  GTK_WIDGET_SET_FLAGS(GTK_WIDGET(canvas), GTK_CAN_FOCUS);
+  GTK_WIDGET_SET_FLAGS(GTK_WIDGET(GET_COMPONENT("spinPageNo")), GTK_CAN_FOCUS);
+
   // set up and initialize the canvas
 
   gtk_widget_show (GTK_WIDGET (canvas));
@@ -252,6 +261,8 @@ void init_stuff (int argc, char *argv[])
       (gpointer)(gtk_scrolled_window_get_hscrollbar(GTK_SCROLLED_WINDOW(w))),
       "event", G_CALLBACK (filter_extended_events),
       NULL);
+  }
+  if (!gtk_check_version(2, 17, 0)) {
     g_signal_connect (
       GET_COMPONENT("comboLayer"),
       "notify::popup-shown", G_CALLBACK (combobox_popup_disable_xinput),
index b1b35bb732cdae157317539a8b6edf0137154a6e..7c520229fbbd68c8137da2525b4d139069569eb5 100644 (file)
@@ -53,6 +53,9 @@ on_fileNewBackground_activate          (GtkMenuItem     *menuitem,
   dialog = gtk_file_chooser_dialog_new(_("Open PDF"), GTK_WINDOW (winMain),
      GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
      GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);
+#ifdef FILE_DIALOG_SIZE_BUGFIX
+  gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 400);
+#endif
      
   filt_all = gtk_file_filter_new();
   gtk_file_filter_set_name(filt_all, _("All files"));
@@ -124,6 +127,9 @@ on_fileOpen_activate                   (GtkMenuItem     *menuitem,
   dialog = gtk_file_chooser_dialog_new(_("Open Journal"), GTK_WINDOW (winMain),
      GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
      GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);
+#ifdef FILE_DIALOG_SIZE_BUGFIX
+  gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 400);
+#endif
      
   filt_all = gtk_file_filter_new();
   gtk_file_filter_set_name(filt_all, _("All files"));
@@ -202,6 +208,9 @@ on_fileSaveAs_activate                 (GtkMenuItem     *menuitem,
   dialog = gtk_file_chooser_dialog_new(_("Save Journal"), GTK_WINDOW (winMain),
      GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
      GTK_STOCK_SAVE, GTK_RESPONSE_OK, NULL);
+#ifdef FILE_DIALOG_SIZE_BUGFIX
+  gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 400);
+#endif
      
   if (ui.filename!=NULL) {
     gtk_file_chooser_set_filename(GTK_FILE_CHOOSER (dialog), ui.filename);
@@ -357,6 +366,9 @@ on_filePrintPDF_activate               (GtkMenuItem     *menuitem,
   dialog = gtk_file_chooser_dialog_new(_("Export to PDF"), GTK_WINDOW (winMain),
      GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
      GTK_STOCK_SAVE, GTK_RESPONSE_OK, NULL);
+#ifdef FILE_DIALOG_SIZE_BUGFIX
+  gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 400);
+#endif
      
   if (ui.filename!=NULL) {
     if (g_str_has_suffix(ui.filename, ".xoj")) {
@@ -1446,6 +1458,9 @@ on_journalLoadBackground_activate      (GtkMenuItem     *menuitem,
   dialog = gtk_file_chooser_dialog_new(_("Open Background"), GTK_WINDOW (winMain),
      GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
      GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);
+#ifdef FILE_DIALOG_SIZE_BUGFIX
+  gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 400);
+#endif
 
   filt_all = gtk_file_filter_new();
   gtk_file_filter_set_name(filt_all, _("All files"));
@@ -2608,28 +2623,54 @@ on_canvas_key_press_event              (GtkWidget       *widget,
                                         GdkEventKey     *event,
                                         gpointer         user_data)
 {
+  GtkAdjustment *adj;
+  gint pgheight;
+
   // Esc leaves text edition, or leaves fullscreen mode
   if (event->keyval == GDK_Escape) {
-    if (ui.cur_item_type == ITEM_TEXT) { end_text(); reset_focus(); }
-    else if (ui.fullscreen) do_fullscreen(FALSE);
+    if (ui.cur_item_type == ITEM_TEXT) { 
+      end_text(); 
+      reset_focus();
+      return TRUE;
+    }
+    else if (ui.fullscreen) {
+      do_fullscreen(FALSE);
+      return TRUE;
+    }
+    else return FALSE;
   }
   
-  // If zoomed-out and in single page mode, switch pages with PgUp/PgDn.
-  if (!ui.view_continuous && 
-      (0.96 * ui.zoom * ui.cur_page->height < 
-       GTK_WIDGET(canvas)->allocation.height)) {
-    if (event->keyval == GDK_Page_Down) {
+  /* In single page mode, switch pages with PgUp/PgDn (or Up/Dn) 
+     when there's nowhere else to go. */
+  pgheight = GTK_WIDGET(canvas)->allocation.height;
+  adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(GET_COMPONENT("scrolledwindowMain")));
+
+  if (event->keyval == GDK_Page_Down || event->keyval == GDK_Down) {
+    if (!ui.view_continuous && 
+         (0.96 * ui.zoom * ui.cur_page->height < pgheight ||
+          adj->value == adj->upper-pgheight)) 
+    {
       end_text();
-      reset_focus();
-      if (ui.pageno == journal.npages-1) { return FALSE; }
-      do_switch_page(ui.pageno+1, TRUE, FALSE);
+      if (ui.pageno < journal.npages-1)
+        do_switch_page(ui.pageno+1, TRUE, FALSE);
+      return TRUE;
     }
-    if (event->keyval == GDK_Page_Up) {
+    if (adj->value == adj->upper-pgheight) return TRUE; // don't send focus away
+  }
+
+  if (event->keyval == GDK_Page_Up || event->keyval == GDK_Up) {
+    if (!ui.view_continuous && 
+         (0.96 * ui.zoom * ui.cur_page->height < pgheight ||
+          adj->value == adj->lower))
+    {
       end_text();
-      reset_focus();
-      if (ui.pageno == 0) { return FALSE; }
-      do_switch_page(ui.pageno-1, TRUE, FALSE);
+      if (ui.pageno != 0) {
+        do_switch_page(ui.pageno-1, TRUE, FALSE);
+        gtk_adjustment_set_value(adj, adj->upper-pgheight);
+      }
+      return TRUE;
     }
+    if (adj->value == adj->lower) return TRUE; // don't send focus away
   }
 
   return FALSE;
index 4dd7396b59490db800e1c7a95e5416be61a1c0fc..1ae30fc15317551b3e140f3aba780223a1ebc5f7 100644 (file)
@@ -1209,7 +1209,8 @@ void update_mru_menu(void)
   
   for (i=0; i<MRU_SIZE; i++) {
     if (ui.mru[i]!=NULL) {
-      tmp = g_strdup_printf("_%d %s", i+1, g_basename(ui.mru[i]));
+      tmp = g_strdup_printf("_%d %s", i+1,
+               g_strjoinv("__", g_strsplit_set(g_basename(ui.mru[i]),"_",-1)));
       gtk_label_set_text_with_mnemonic(GTK_LABEL(gtk_bin_get_child(GTK_BIN(ui.mrumenu[i]))),
           tmp);
       g_free(tmp);
index 1c29a306a825d679021cf3fc85793a839e09d1f1..cc4fdc5ff7cfc1bcc58ee7b64329d88cdf08d551 100644 (file)
@@ -1667,11 +1667,13 @@ gboolean ok_to_close(void)
 // send the focus back to the appropriate widget
 void reset_focus(void)
 {
+/*
   if (ui.cur_item_type == ITEM_TEXT)
     gtk_widget_grab_focus(ui.cur_item->widget);
   else
     gtk_widget_grab_focus(GTK_WIDGET(canvas));
   reset_recognizer();
+*/
 }
 
 // selection / clipboard stuff
@@ -2124,3 +2126,21 @@ gboolean combobox_popup_disable_xinput (GtkWidget *widget, GdkEvent *event,
   gtk_widget_set_extension_events(GTK_WIDGET (canvas), 
        (ui.use_xinput && !is_shown)?GDK_EXTENSION_EVENTS_ALL:GDK_EXTENSION_EVENTS_NONE);
 }
+
+/* When enter is pressed into page spinbox, send focus back to canvas. */
+
+gboolean handle_activate_signal(GtkWidget *widget, gpointer user_data)
+{
+  gtk_widget_grab_focus(GTK_WIDGET(canvas));
+  return FALSE;
+}
+
+/* recursively unset widget flags */
+
+void unset_flags(GtkWidget *w, gpointer flag)
+{
+  GTK_WIDGET_UNSET_FLAGS(w, (GtkWidgetFlags)flag);
+  if(GTK_IS_CONTAINER(w))
+    gtk_container_foreach(GTK_CONTAINER(w), unset_flags, flag);
+}
+        
\ No newline at end of file
index 3a6e029dd98f4fcca83d05a92264f06502a5e342..fbfb3372ea45f6bb0dcf6b540b3616762d40227a 100644 (file)
@@ -102,7 +102,9 @@ gboolean filter_extended_events(GtkWidget *widget, GdkEvent *event, gpointer use
 // gboolean fix_extended_events(GtkWidget *widget, GdkEvent *event, gpointer user_data);
 gboolean combobox_popup_disable_xinput(GtkWidget *widget, GdkEvent *event, gpointer user_data);
 
-
+// help with focus
+gboolean handle_activate_signal(GtkWidget *widget, gpointer user_data);
+void unset_flags(GtkWidget *w, gpointer flag);
 
 // defines for paper rulings
 
index 61eb21801e8549334f127d1a25cee6e9add92592..277b1d0b84e91806889a3287a8e6a2d057b7249d 100644 (file)
    XInput and want to try things differently. This will probably break
    on-the-fly display rotation after application startup, though. */
 
+#define FILE_DIALOG_SIZE_BUGFIX
+/* ugly, but should help users with versions of GTK+ that suffer from the
+   "tiny file dialog" syndrome, without hurting those with well-behaved
+   versions of GTK+. Comment out if you'd prefer not to include this fix. */
+
 // PREF FILES INFO
 
 #define CONFIG_DIR ".xournal"