rosenrot-browser

A hackable browser based on Webkitgtk
Log | Files | Refs | README

config.h (4623B)


      1 #include <stdbool.h>
      2 #include <gtk/gtk.h>
      3 
      4 /* Key user config */
      5 #define HEIGHT      1080 
      6 #define FULL_WIDTH  1920
      7 #define WIDTH       FULL_WIDTH
      8 #define BAR_WIDTH   FULL_WIDTH/2
      9 
     10 /* More user config */
     11 #define ZOOM_START_LEVEL 1.8
     12 #define ZOOM_STEPSIZE .1 
     13 #define MAX_NUM_TABS 8 // 0 or false for unlimited tabs
     14 #define SEARCH "https://search.brave.com/search?q=%s" 
     15 #define HOME "https://search.brave.com/search" 
     16 // #define SEARCH "https://search.nunosempere.com/search?q=%s"
     17 // #define SEARCH "https://lite.duckduckgo.com/html/?q=%s" 
     18 // #define HOME "file:///opt/rosenrot/flower-imgs/rose-homepage.png" 
     19 
     20 /* Plugins */
     21 #define LIBRE_REDIRECT_ENABLED true
     22 #define READABILITY_ENABLED true
     23 #define CUSTOM_USER_AGENT false
     24 /* 
     25 To disable plugins:
     26 1. set their corresponding variable to false
     27 2. recompile 
     28 
     29 To remove plugins completely;
     30 1. Remove the corresponding code in rosenrot.c by looking for the variables above, as well as custom_style_enabled
     31 2. Remove PLUGIN and $(PLUGIN) from the makefile
     32 3. Recompile
     33 
     34 You could also look into commit afe93518a for an approach using stand-in code.
     35 */
     36 
     37 /* Webkit */
     38 // https://webkitgtk.org/reference/webkit2gtk/stable/class.Settings.html 
     39 #define WEBKIT_DEFAULT_SETTINGS \
     40 	"enable-back-forward-navigation-gestures", true, \
     41 	"enable-developer-extras", true, \
     42 	"enable-smooth-scrolling", false, \
     43     "default-charset", "utf-8"
     44 #define DATA_DIR "/home/nuno/.cache/rosenrot"
     45 #define DATA_MANAGER_OPTS "base-cache-directory", DATA_DIR, "base-data-directory", DATA_DIR
     46 #define NETWORK_SESSION_OPTS DATA_DIR, DATA_DIR
     47 
     48 /* GTK  */
     49 // https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gdk/gdkkeysyms.h
     50 // https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gdk/gdkenums.h
     51 #define GTK_SETTINGS_CONFIG_H "gtk-application-prefer-dark-theme", false, "gtk-enable-animations", false
     52 #define KEY(x) GDK_KEY_##x
     53 #define SFT  1 << 0 
     54 #define CTRL 1 << 2
     55 #define ALT  1 << 3
     56 
     57 /* Misc helpers */
     58 #define ABORT_REQUEST_ON_CURRENT_TAB NULL
     59 #define NULLCHECK(x)                                   \
     60     do {                                               \
     61         if (x == NULL) {                               \
     62             printf("\nNULL check not passed");         \
     63             printf("@ %s (%d): ", __FILE__, __LINE__); \
     64             exit(0);                                   \
     65         }                                              \
     66     } while (0)
     67 
     68 /* Shortcuts */
     69 typedef enum {
     70     goback,
     71     goforward,
     72 
     73     refresh,
     74     refresh_force,
     75 
     76     back_to_home,
     77 
     78     toggle_fullscreen,
     79     toggle_custom_style,
     80 
     81     zoomin,
     82     zoomout,
     83     zoom_reset,
     84 
     85     new_tab,
     86     next_tab,
     87     prev_tab,
     88     close_tab,
     89 
     90     show_searchbar,
     91     hide_bar,
     92     show_finder,
     93     finder_next,
     94     finder_prev,
     95 
     96     halve_window,
     97     rebig_window,
     98 
     99     prettify,
    100     save_uri_to_txt,
    101 } func;
    102 
    103 static struct {
    104 	unsigned mod;
    105 	unsigned key;
    106 	func id;
    107 } shortcut[] = {
    108     { CTRL,        KEY(h),             goback               },
    109     { CTRL,        KEY(j),             goforward            },
    110 
    111     { CTRL,        KEY(r),             refresh              },
    112     { CTRL,        KEY(R),             refresh_force        },
    113 
    114     { CTRL,        KEY(H),             back_to_home         },
    115 
    116     { 0x0,         KEY(F11),           toggle_fullscreen    },
    117     { CTRL,        KEY(S),             toggle_custom_style  },
    118 
    119     { CTRL,        KEY(equal),         zoomin               },
    120     { CTRL,        KEY(minus),         zoomout              },
    121     { CTRL,        KEY(0),             zoom_reset           },
    122 
    123     { CTRL | SFT,  KEY(KP_Page_Up),    prev_tab             },  // use SFT just to show one can
    124     { CTRL | SFT,  KEY(KP_Page_Down),  next_tab             }, 
    125     { CTRL | SFT,  KEY(Page_Up),       prev_tab             }, 
    126     // working hypothesis: Page_UP vs KP_Page_Up might depend on whether the user has a numpad
    127     { CTRL | SFT,  KEY(Page_Down),     next_tab             }, 
    128     { CTRL,        KEY(t),             new_tab              },
    129     { CTRL,        KEY(w),             close_tab            },
    130 
    131     { CTRL,        KEY(l),             show_searchbar       },
    132     { CTRL,        KEY(o),             hide_bar             }, // previously: KEY(semicolon)
    133     { CTRL,        KEY(f),             show_finder          },
    134     { CTRL,        KEY(n),             finder_next          },
    135     { CTRL,        KEY(N),             finder_prev          },
    136     { CTRL,        KEY(Up),            halve_window         },
    137     { CTRL,        KEY(Down),          rebig_window         },
    138     { CTRL,        KEY(p),             prettify             },
    139     { CTRL,        KEY(s),             save_uri_to_txt      }
    140 };