Skip to content

Commit

Permalink
hoodle is compilable both with gtk2 and with gtk3! gtk2 hoodle works …
Browse files Browse the repository at this point in the history
…as it is supposed to do!
  • Loading branch information
wavewave committed Dec 4, 2014
1 parent b803fa1 commit 45281f4
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 21 deletions.
2 changes: 1 addition & 1 deletion build.sh
Expand Up @@ -3,5 +3,5 @@
# our use cabal-meta
#
# cabal-meta install
cat sources.txt | xargs cabal install --constraint="gtk > 1.0" -fgtk3 --force-reinstalls -j -v
cat sources.txt | xargs cabal install --force-reinstalls -j

7 changes: 7 additions & 0 deletions buildgtk3.sh
@@ -0,0 +1,7 @@
#!/bin/bash

# our use cabal-meta
#
# cabal-meta install
cat sources.txt | xargs cabal install --constraint="gtk > 1.0" -fgtk3 --force-reinstalls -j -v

27 changes: 17 additions & 10 deletions hoodle-core/csrc/c_initdevice.c
Expand Up @@ -2,10 +2,11 @@
#include <stdio.h>
#include <string.h>

#ifndef GTK3
#include "XInput.h"
#endif // GTK3

// #include "XInput.h"

/*
#ifndef GTK3
//
// Globals.
//
Expand Down Expand Up @@ -114,9 +115,9 @@ static bool xinput_findDevices(Display *display, XDeviceInfo *stylus_info, XDevi

return (found == 2);
}
*/

/*


void find_wacom( char* stylus_name, char* eraser_name)
{
Display *display = XOpenDisplay(NULL);
Expand All @@ -138,7 +139,7 @@ void find_wacom( char* stylus_name, char* eraser_name)
}
return ;
}
*/
#endif // not GTK3

void initdevice ( int* core
, int* stylus
Expand All @@ -156,10 +157,14 @@ void initdevice ( int* core

GList* dev_list;
GdkDevice* device;
#ifdef GTK3
GdkDisplay* disp = gdk_display_get_default();
GdkDeviceManager *devman = gdk_display_get_device_manager(disp);

dev_list = gdk_device_manager_list_devices(devman, GDK_DEVICE_TYPE_SLAVE );
#else // GTK3
dev_list = gdk_devices_list();
#endif // GTK3
(*stylus) = 0;
while (dev_list != NULL) {
device = (GdkDevice *)dev_list->data;
Expand All @@ -184,22 +189,24 @@ void initdevice ( int* core
(*core) = (int) device;
}
}
#ifdef GTK3
dev_list = g_list_next(dev_list);
#else // GTK3
dev_list = dev_list->next;
#endif // GTK3
}

}

/*
#ifndef GTK3
void enable_touch( char* touch_name )
{
printf("enable touch: %s\n", touch_name ) ;
}
*/

/*
void disable_touch( GdkDrawable *gdkwin, char* touch_name )
{
printf("disable touch: %s\n", touch_name );

}
*/
#endif // GTK3
6 changes: 3 additions & 3 deletions hoodle-core/src/Hoodle/GUI.hs
Expand Up @@ -69,9 +69,9 @@ startGUI mfname mhook = do
--
let canvases = map (getDrawAreaFromBox) . M.elems . view (unitHoodles.currentUnit.cvsInfoMap) $ st0
#ifndef GTK3
if xinputbool
then mapM_ (flip Gtk.widgetSetExtensionEvents [Gtk.ExtensionEventsAll]) canvases
else mapM_ (flip Gtk.widgetSetExtensionEvents [Gtk.ExtensionEventsNone]) canvases
if xinputbool
then mapM_ (flip Gtk.widgetSetExtensionEvents [Gtk.ExtensionEventsAll]) canvases
else mapM_ (flip Gtk.widgetSetExtensionEvents [Gtk.ExtensionEventsNone]) canvases
#endif // not GTK3
--
outerLayout ui vbox st0
Expand Down
2 changes: 1 addition & 1 deletion hoodle-core/src/Hoodle/ModelAction/Layer.hs
Expand Up @@ -54,7 +54,7 @@ layerChooseDialog layernumref cidx len = do
Gtk.containerAdd upper hbox
#else // GTK3
upper <- Gtk.dialogGetUpper dialog
Gtk.boxPackStart upper hbox PackNatural 0
Gtk.boxPackStart upper hbox Gtk.PackNatural 0
#endif // GTK3
Gtk.boxPackStart hbox layerentry Gtk.PackNatural 0
Gtk.boxPackStart hbox label Gtk.PackGrow 0
Expand Down
6 changes: 3 additions & 3 deletions hoodle-core/src/Hoodle/ModelAction/Window.hs
Expand Up @@ -180,16 +180,16 @@ connectDefaultEventCanvasInfo xstate _uhdl cinfo = do
case x of
[] -> error "No action group? "
y:_ -> return y )
uxinputa <- liftIO (Gtk.actionGroupGetAction agr "UXINPUTA" >>= \(Just x) ->
uxinputa <- liftIO (Gtk.actionGroupGetAction agr ("UXINPUTA" :: String) >>= \(Just x) ->
return (Gtk.castToToggleAction x) )
b <- liftIO $ Gtk.toggleActionGetActive uxinputa
#ifdef GTK3
#else // GTK3
if b then Gtk.widgetSetExtensionEvents canvas [Gtk.ExtensionEventsAll]
else Gtk.widgetSetExtensionEvents canvas [Gtk.ExtensionEventsNone]
#endif // GTK3
hadjconnid <- afterValueChanged hadj $ do
v <- adjustmentGetValue hadj
hadjconnid <- Gtk.afterValueChanged hadj $ do
v <- Gtk.adjustmentGetValue hadj
(callback . UsrEv) (HScrollBarMoved cid v)
vadjconnid <- Gtk.afterValueChanged vadj $ do
v <- Gtk.adjustmentGetValue vadj
Expand Down
2 changes: 1 addition & 1 deletion hoodle-core/src/Hoodle/View/Draw.hs
Expand Up @@ -354,7 +354,7 @@ drawContPageGen render = ContPageDraw func
#ifdef GTK3
Just win <- Gtk.widgetGetWindow canvas
#else // GTK3
win <- widgetGetDrawWindow canvas
win <- Gtk.widgetGetDrawWindow canvas
#endif // GTK3
let ibboxnew = getViewableBBox geometry mbbox
let mbboxnew = toMaybe ibboxnew
Expand Down
2 changes: 1 addition & 1 deletion hoodle-extra/exe/idfilepathdb.hs
Expand Up @@ -47,7 +47,7 @@ import Text.Hoodle.Parse.Attoparsec
import Hoodle.Manage.Connect
import Hoodle.Manage.DocDatabase
import DiffDB
import Migrate
-- import Migrate
import qualified Hoodle.Manage.SqliteDB as SqliteDB
import qualified TextFileDB
import Util
Expand Down
2 changes: 1 addition & 1 deletion hoodle-extra/hoodle-extra.cabal
Expand Up @@ -116,7 +116,7 @@ Executable idfilepathdb
hoodle-extra

Other-modules: DiffDB
Migrate
-- Migrate
TextFileDB
Util

Expand Down
2 changes: 2 additions & 0 deletions hoodle-extra/lib/Hoodle/Manage/DocDatabase.hs
@@ -1,6 +1,8 @@
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
Expand Down

0 comments on commit 45281f4

Please sign in to comment.