]> git.donarmstrong.com Git - xournal.git/blobdiff - src/main.c
focus and other patches
[xournal.git] / src / main.c
index 129716ad971de4dafed350c37d83cdf6e83ae775..1c8acbfca25e16a89d2b5072c69f3a22d60f82fd 100644 (file)
@@ -89,9 +89,11 @@ void init_stuff (int argc, char *argv[])
     for (i=0; i < NUM_STROKE_TOOLS; i++) {
       b = &(ui.brushes[j][i]);
       b->tool_type = i;
-      b->color_rgba = predef_colors_rgba[b->color_no];
-      if (i == TOOL_HIGHLIGHTER) {
-        b->color_rgba &= ui.hiliter_alpha_mask;
+      if (b->color_no>=0) {
+        b->color_rgba = predef_colors_rgba[b->color_no];
+        if (i == TOOL_HIGHLIGHTER) {
+          b->color_rgba &= ui.hiliter_alpha_mask;
+        }
       }
       b->thickness = predef_thickness[i][b->thickness_no];
     }
@@ -99,6 +101,7 @@ void init_stuff (int argc, char *argv[])
     g_memmove(ui.default_brushes+i, &(ui.brushes[0][i]), sizeof(struct Brush));
 
   ui.cur_mapping = 0;
+  ui.which_unswitch_button = 0;
   
   reset_recognizer();
 
@@ -118,10 +121,20 @@ void init_stuff (int argc, char *argv[])
       GTK_TOGGLE_TOOL_BUTTON(GET_COMPONENT("buttonFullscreen")), TRUE);
     gtk_window_fullscreen(GTK_WINDOW(winMain));
   }
+  gtk_button_set_relief(GTK_BUTTON(GET_COMPONENT("buttonColorChooser")), GTK_RELIEF_NONE);
 
   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));
@@ -190,8 +203,6 @@ void init_stuff (int argc, char *argv[])
   ui.use_xinput = ui.allow_xinput && can_xinput;
   ui.need_emergency_disable_xinput = FALSE;
 
-  gtk_check_menu_item_set_active(
-    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsAntialiasBG")), ui.antialias_bg);
   gtk_check_menu_item_set_active(
     GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsProgressiveBG")), ui.progressive_bg);
   gtk_check_menu_item_set_active(
@@ -202,6 +213,8 @@ void init_stuff (int argc, char *argv[])
     GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsShortenMenus")), ui.shorten_menus);
   gtk_check_menu_item_set_active(
     GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsAutoSavePrefs")), ui.auto_save_prefs);
+  gtk_check_menu_item_set_active(
+    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsButtonSwitchMapping")), ui.button_switch_mapping);
   
   hide_unimplemented();
 
@@ -220,9 +233,9 @@ void init_stuff (int argc, char *argv[])
   gtk_check_menu_item_set_active(
     GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsUseXInput")), ui.use_xinput);
 
-  /* fix a bug in GTK+ 2.16 and beyond: scrollbars shouldn't get extended
+  /* fix a bug in GTK+ 2.16 and 2.17: scrollbars shouldn't get extended
      input events from pointer motion when cursor moves into main window */
-#if GTK_CHECK_VERSION(2,14,0)
+
   if (!gtk_check_version(2, 16, 0)) {
     g_signal_connect (
       GET_COMPONENT("menubar"),
@@ -248,12 +261,13 @@ 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),
       NULL);
   }
-#endif
 
   // load the MRU