Friday, July 8, 2016

I made a build of leptonica-1.73 that can be used to build Tesseract 3.04 in Visual Studio. I build leptonica under MinGW as a .dll, and then I generated a .lib file for that .dll.

The .dll itself has 5-6 other .dlls as dependencies - mostly the image backends and the MinGW runtime.

I created a zip archive that contains everything you need to use leptonica in Visual Studio - the .lib file, the header files and the dll along with the other dlls it depends on.

Here's the link - This is the zip archive.

Sunday, February 23, 2014

Patch for PCManFM to remember view mode

There is a bug in PCManFM that causes it not to remember the view mode (the view mode is icons, compact, thumbnails, or detailed list). This patch fixes it.
 commit 7c137a883350025a9724be1d8c2d8bd0307b1305  
 Author: sashoalm <sashoalm@aspire>  
 Date:  Sun Feb 23 20:59:58 2014 +0200  
   Remember view mode.  
 diff --git a/src/main-win.c b/src/main-win.c  
 index 6a65035..3947de3 100644  
 --- a/src/main-win.c  
 +++ b/src/main-win.c  
 @@ -1266,6 +1266,9 @@ static void on_fullscreen(GtkToggleAction* act, FmMainWin* win)  
 +extern char* profile;  
  static void on_change_mode(GtkRadioAction* act, GtkRadioAction *cur, FmMainWin* win)  
    int mode = gtk_radio_action_get_current_value(cur);  
 @@ -1277,8 +1280,11 @@ static void on_change_mode(GtkRadioAction* act, GtkRadioAction *cur, FmMainWin*  
                       win->current_page->sort_by, mode,  
                       win->current_page->show_hidden, NULL);  
 -  else  
 +  else {  
      win->current_page->view_mode = mode;  
 +    app_config->view_mode = mode;  
 +    fm_app_config_save_profile(app_config, profile);  
 +  }  
  static void on_sort_by(GtkRadioAction* act, GtkRadioAction *cur, FmMainWin* win)  
 diff --git a/src/pcmanfm.c b/src/pcmanfm.c  
 index 2fe3482..7ea63c2 100644  
 --- a/src/pcmanfm.c  
 +++ b/src/pcmanfm.c  
 @@ -52,7 +52,7 @@ static guint save_config_idle = 0;  
  static char** files_to_open = NULL;  
  static int n_files_to_open = 0;  
 -static char* profile = NULL;  
 +char* profile = NULL;  
  static gboolean no_desktop = FALSE;  
  static gboolean show_desktop = FALSE;  
  static gboolean desktop_off = FALSE;  

Saturday, February 22, 2014

Patch to start quick filter instead of quick search when typing in Krusader

Krusader has both quick search and quick filter, but quick filter needs to be started explicitly with Ctrl+I. With this patch, when you start typing, quick filter is started instead of quick search.

 commit a4aaddc554d9c98b6c7a84fe9a2f2b2b79c4582f  
 Author: sashoalm <sashoalm@aspire>  
 Date:  Fri Feb 14 22:49:05 2014 +0200  
   Start quick filter instead of quick search.  
 diff --git a/krusader/Panel/krview.cpp b/krusader/Panel/krview.cpp  
 index d9ff07d..0c738eb 100644  
 --- a/krusader/Panel/krview.cpp  
 +++ b/krusader/Panel/krview.cpp  
 @@ -213,10 +213,14 @@ void KrViewOperator::quickFilterChanged(const QString &text)  
    _quickFilter->setMatch(_view->_count || !_view->_files->numVfiles());  
 -void KrViewOperator::startQuickFilter()  
 +void KrViewOperator::startQuickFilter(QEvent *e)  
 +  if (e) {  
 +    QLineEdit *p = _quickFilter->lineEdit();  
 +    p->event(e);  
 +  }  
  void KrViewOperator::stopQuickFilter(bool refreshView)  
 @@ -964,26 +968,8 @@ bool KrView::handleKeyEventInt(QKeyEvent *e)  
        //if ( _config->readBoolEntry( "Do Quicksearch", _DoQuicksearch ) ) {  
        // are we using krusader's classic quicksearch, or wincmd style?  
 -      KConfigGroup grpSv(_config, "Look&Feel");  
 -      if (!grpSv.readEntry("New Style Quicksearch", _NewStyleQuicksearch))  
 -        return false;  
 -      else {  
 -        // first, show the quicksearch if its hidden  
 -        if (op()->quickSearch()->isHidden()) {  
 -          op()->quickSearch()->show();  
 -          // HACK: if the pressed key requires a scroll down, the selected  
 -          // item is "below" the quick search window, as the icon view will  
 -          // realize its new size after the key processing. The following line  
 -          // will resize the icon view immediately.  
 -          // ACTIVE_PANEL->gui->layout->activate();  
 -          // UPDATE: it seems like this isn't needed anymore, in case I'm wrong  
 -          // do something like op()->emitQuickSearchStartet()  
 -          // -----------------------------  
 -        }  
 -        // now, send the key to the quicksearch  
 -        op()->quickSearch()->myKeyPressEvent(e);  
 -        return true;  
 -      }  
 +      op()->startQuickFilter(e);  
 +      return true;  
      } else {  
        if (!op()->quickSearch()->isHidden()) {  
 diff --git a/krusader/Panel/krview.h b/krusader/Panel/krview.h  
 index 2f3c8a8..7db5fba 100644  
 --- a/krusader/Panel/krview.h  
 +++ b/krusader/Panel/krview.h  
 @@ -205,7 +205,7 @@ public slots:  
    void stopQuickSearch(QKeyEvent*);  
    void handleQuickSearchEvent(QKeyEvent*);  
 -  void startQuickFilter();  
 +  void startQuickFilter(QEvent *e = 0);  
    void stopQuickFilter(bool refreshView = true);  

Patch to enable PCManFM quick search to match mid-string (instead of strictly at the beginning)

PCManFM lets you select a file or directory by typing the first letters of its name.

Unfortunately, it does not let you search the file by typing a sub-string that appears in the middle of the file name. For example, typing "down" will select "Downloads", but typing "loads" will not, even though "loads" appears in the string.

Luckily, there is a way to change that, but it requires patching the source code of libfm, which is used by PCManFM. So, if you have Debian, download the source code and build dependencies:
 apt-get source libfm  
 sudo apt-get build-dep libfm  
After that, apply this patch:
 commit 437943e1ba9a43cd1809a1957d221a44fb22e02f  
 Author: sashoalm <sashoalm@aspire>  
 Date:  Sun Feb 23 12:45:09 2014 +0200  
   Enable mid-string search in PCManFM.  
 diff --git a/src/gtk/exo/exo-icon-view.c b/src/gtk/exo/exo-icon-view.c  
 index 8cf6279..1131580 100644  
 --- a/src/gtk/exo/exo-icon-view.c  
 +++ b/src/gtk/exo/exo-icon-view.c  
 @@ -453,7 +453,7 @@ static void   exo_icon_view_search_preedit_changed  (GtkIMContext  *im_cont  
  static gboolean exo_icon_view_search_start       (ExoIconView  *icon_view,  
                              gboolean    keybinding);  
 -static gboolean exo_icon_view_search_equal_func     (GtkTreeModel  *model,  
 +gboolean exo_icon_view_search_equal_func     (GtkTreeModel  *model,  
                              gint      column,  
                              const gchar  *key,  
                              GtkTreeIter  *iter,  
 @@ -8871,7 +8871,7 @@ exo_icon_view_search_start (ExoIconView *icon_view,  
 -static gboolean  
  exo_icon_view_search_equal_func (GtkTreeModel *model,  
                  gint     column,  
                  const gchar *key,  
 @@ -8918,7 +8918,7 @@ exo_icon_view_search_equal_func (GtkTreeModel *model,  
     case_normalized_key = g_utf8_casefold (normalized_key, -1);  
     /* compare the casefolded strings */  
 -   if (strncmp (case_normalized_key, case_normalized_string, strlen (case_normalized_key)) == 0)  
 +   if (strstr (case_normalized_string, case_normalized_key) != 0)  
      retval = FALSE;  
 diff --git a/src/gtk/exo/exo-tree-view.c b/src/gtk/exo/exo-tree-view.c  
 index 207cc9c..36ac5a7 100644  
 --- a/src/gtk/exo/exo-tree-view.c  
 +++ b/src/gtk/exo/exo-tree-view.c  
 @@ -223,11 +223,18 @@ exo_tree_view_class_init (ExoTreeViewClass *klass)  
 +exo_icon_view_search_equal_func (GtkTreeModel *model,  
 +                 gint     column,  
 +                 const gchar *key,  
 +                 GtkTreeIter *iter,  
 +                 gpointer   user_data);  
  static void  
  exo_tree_view_init (ExoTreeView *tree_view)  
 + gtk_tree_view_set_search_equal_func(&tree_view->__parent__, exo_icon_view_search_equal_func, 0, 0);  
   /* grab a pointer on the private data */  
   tree_view->priv = EXO_TREE_VIEW_GET_PRIVATE (tree_view);  
   tree_view->priv->single_click_timeout_id = -1;  

After that compile and install libfm:
 sudo make install  
This will install it in /usr/local/lib, and our modified libfm will be loaded by PCManFM instead of the stock that comes with Ubuntu, and is in /usr/lib.

Wednesday, February 17, 2010

Reflashing the BIOS of EeePC 904HD

There is always a small chance that updating your bios will brick your eeePC!
Always make sure that your eeePC has a full battery and is connected to the power before doing an upgrade!
You use this tutorial completely at your own risk!

The bios that comes with the eee pcs is updated from time to time by asus, so it can be beneficial to install the newest version. You can get the newest version of the BIOS for EeePC 904HD from the asus support site. Click the plus sign left of BIOS, and it will show all the versions from newest to oldest. Note that I'm talking about EeePC 904HD (that's what I own), if you have 901 or some other model and update it with 904HD BIOS, there's a good chance you'll make your laptop unusable. Make sure you find the page for your own model in asus's site.

Now the next step is more difficult. You have to format a USB stick to FAT16 and make sure that the new FAT16 partition is less than 32 MB (make it 16 MB to be safe, the ROM file is only 512K anyway) . Then copy the ROM file and rename it to "904HD.ROM".

Finally, leave the USB stick attached to the laptop and reboot. As soon as you see the BIOS splash screen press Alt+F2. The BIOS will read the file and reflash. You should see this message
EZ-Flash starting BIOS update
Checking for USB device
USB Device found
Reading file "701.ROM". Completed

It will take some time, during which just don't touch your laptop. After the update has finished the laptop
will turn off.

Friday, January 1, 2010

Patch for LXPanel to close windows on middle click.

I like using middle-click to close tabs in Firefox, and I would like to be able to close windows by middle-clicking their icon-entry on the taskbar in LXDE. Unfortunately, it can only be done by editing the source of lxpanel, which is the LXDE taskbar.

For Debian, you need to get the source code:
 apt-get source lxpanel  
 sudo apt-get build-dep lxpanel  
Then you need to apply this patch:
 commit ec2772ddbbf0f02e9175f195e9f234c2c305e8ee  
 Author: sashoalm <sashoalm@aspire>  
 Date:  Sat Feb 22 16:33:29 2014 +0200  
   Close window on wheel-click.  
 diff --git a/src/plugins/taskbar.c b/src/plugins/taskbar.c  
 index baf6281..95143b9 100644  
 --- a/src/plugins/taskbar.c  
 +++ b/src/plugins/taskbar.c  
 @@ -1111,11 +1111,8 @@ static gboolean taskbar_task_control_event(GtkWidget * widget, GdkEventButton *  
      else if (event->button == 2)  
 -      /* Middle button. Toggle the shaded state of the window. */  
 -      Xclimsg(tk->win, a_NET_WM_STATE,  
 -        2,          /* a_NET_WM_STATE_TOGGLE */  
 -        a_NET_WM_STATE_SHADED,  
 -        0, 0, 0);  
 +      /* Middle button. Close the window. */  
 +      Xclimsgwm(tk->win, a_WM_PROTOCOLS, a_WM_DELETE_WINDOW);  
      else if (event->button == 3)  
And install it:
 sudo make install  
Now you can close windows with middle click on taskbar.