Skip to content

Commit

Permalink
allow dooking on lebel
Browse files Browse the repository at this point in the history
  • Loading branch information
jabiertxof authored and imvenx committed Nov 19, 2023
1 parent 36d18eb commit c062642
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 51 deletions.
36 changes: 12 additions & 24 deletions public/inka-inkscape-preferences-1.3.1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,7 @@
<eventcontext
id="select"
selcue="1"
gradientdrag="0"
changelayer="1"
changepage="1" />
gradientdrag="0" />
<eventcontext
id="connector"
style="fill:none;fill-rule:evenodd;stroke:black;stroke-opacity:1;stroke-linejoin:miter;stroke-width:1px;stroke-linecap:butt;"
Expand Down Expand Up @@ -561,8 +559,7 @@
</group>
</group>
<group
id="dialogs"
traceliveUpdate="1">
id="dialogs">
<group
id="toolbox" />
<group
Expand All @@ -580,7 +577,8 @@
<group
id="xml"
h="500"
w="300" />
w="300"
mono-font="1" />
<group
id="find" />
<group
Expand Down Expand Up @@ -677,8 +675,6 @@
<group
id="objects"
expand_to_layer="1" />
<group
id="livepatheffect" />
</group>
<group
id="printing">
Expand Down Expand Up @@ -746,7 +742,7 @@
uri="" />
<group
id="savewindowgeometry"
value="0" />
value="2" />
<group
id="defaultoffsetwidth"
value="2px" />
Expand Down Expand Up @@ -816,7 +812,7 @@
value="1" />
<group
id="defaultwindowsize"
value="2" />
value="1" />
<group
id="arenatilescachesize"
value="8192" />
Expand Down Expand Up @@ -938,17 +934,6 @@
angle_x="30.0"
angle_z="30.0"
empspacing="5" />
<group
id="modular"
units="mm"
origin_x="0.0"
origin_y="0.0"
spacing_x="40.0"
spacing_y="40.0"
gapx="10"
gapy="10"
marginx="0"
marginy="0" />
</group>
<group
id="workarounds"
Expand All @@ -959,7 +944,7 @@
unitType="2" />
<group
id="boot"
theme="colorful"
theme="custom"
enabled="0">
<group
id="shown"
Expand All @@ -971,6 +956,9 @@
id="threading" />
<group
id="ruler" />
<group
id="savedocviewport"
value="0" />
</group>
<group
id="extensions"
Expand All @@ -985,7 +973,7 @@
height="1"
x="0"
y="0"
maximized="1"
maximized="0"
fullscreen="0"
id="geometry" />
<group
Expand Down Expand Up @@ -1110,7 +1098,7 @@
symbolicDefaultHighColors="0"
gtkTheme="Adwaita"
iconTheme="multicolor"
syntax-color-theme="inkscape-dark">
menuIcons="1">
<group
id="multicolor"
symbolicBaseColor="3958107135"
Expand Down
4 changes: 1 addition & 3 deletions src-electron/electron-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,11 @@ app.whenReady().then(async () => {
const windowSize = mainWindow?.getSize()
ipcMain.handle('dock', () => {
const windowSize = mainWindow?.getSize()
onTop()
let heightOf = resetWindow()
inkscapeH.dock(heightOf * ConfigH.scaleFactor + 5)
inkscapeH.dock(ConfigH.workArea.x,ConfigH.workArea.y, ConfigH.workArea.width, ConfigH.workArea.height - (ConfigH.workArea.y + 5 + (heightOf * ConfigH.scaleFactor)))
//app.relaunch()
})
ipcMain.handle('undock', () => {
onFloat()
inkscapeH.undock()
})
mainWindow?.on('resize', () => {
Expand Down
7 changes: 6 additions & 1 deletion src-electron/handlers/config_h.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export abstract class ConfigH {
static configRootPath = path.join(electron.app.getPath('userData'), 'inkaConfig.json')
static configInkDir = path.join(electron.app.getPath('userData'), 'inkscape')
static configInkDirUI = path.join(electron.app.getPath('userData'), 'inkscape', 'ui')
static configInkCSS = path.join(electron.app.getPath('userData'), 'inkscape', 'ui', 'user.css')
static configInkPREFS = path.join(electron.app.getPath('userData'), 'inkscape', 'preferences.xml')
static configInkSRCPREFS = path.join('public','inka-inkscape-preferences-1.3.1.xml')
private static config: InkaConfig = this.get()
Expand Down Expand Up @@ -64,6 +63,12 @@ export abstract class ConfigH {
}

static async resetInkscapePath() {
try {
p.copyFile(ConfigH.configInkSRCPREFS, ConfigH.configInkPREFS)
}
catch (e) {
logInkaError(e, 'Error on try set default css')
}
this.config.inkscapePath = undefined
await this.save()
}
Expand Down
47 changes: 24 additions & 23 deletions src-electron/handlers/inkscape_h.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,28 @@ export abstract class inkscapeH {
}
}

static async dock(height: number) {
static async dock(x: number,y: number,width: number,height: number) {
try {
const configInkCSS = await ConfigH.configInkCSS
if (!configInkCSS) return
await p.writeFile(configInkCSS, `#DesktopMainBox {padding-bottom:${height}px;}`, { encoding: 'utf-8' })
await this.reopenInkscape()
return true
const configInkPREFS = await ConfigH.configInkPREFS
if (!configInkPREFS) return
await inkscapeH.undock()
try {
let geo = `<group
width="${width}"
height="${height}"
x="${x}"
y="${y}"
maximized="0"
fullscreen="0"
id="geometry" />`
const wpos = await p.readFile(configInkPREFS, 'utf-8')
let nwpos = wpos.replace(/\<group[^\>]*id="geometry"[^\>]*\>/gms,geo)
await p.writeFile(configInkPREFS, nwpos, { encoding: 'utf-8' })
await this.reopenInkscape()
return true
} catch (e) {
console.log(e, 'Error on geting window position file')
}
}
catch (e) {
logInkaError(e, 'Error on try set config')
Expand All @@ -149,9 +164,9 @@ export abstract class inkscapeH {

static async undock() {
try {
const configInkCSS = await ConfigH.configInkCSS
if (existsSync(configInkCSS)) {
await p.unlink(configInkCSS);
const configInkWPOS = await ConfigH.configInkWPOS
if (existsSync(configInkWPOS)) {
await p.unlink(configInkWPOS);
}
return true
}
Expand All @@ -161,20 +176,6 @@ export abstract class inkscapeH {
}
}

static async docked() {
try {
const configInkCSS = await ConfigH.configInkCSS
if (existsSync(configInkCSS)) {
return true
}
return false
}
catch (e) {
logInkaError(e, 'Error on try set config')
return false
}
}

static async profileDir() {
try {
if (!existsSync(ConfigH.configInkDir)) await p.mkdir(ConfigH.configInkDir)
Expand Down

0 comments on commit c062642

Please sign in to comment.