Add menu handler
authorJ. Ali Harlow <ali@juiblex.co.uk>
Sat Nov 15 19:10:51 2014 +0000 (2014-11-15)
changeset 25e10f418d8e1d
parent 24 2b9f54d14cc2
child 26 9816b7a56c23
Add menu handler
.gitignore
Makefile.am
configure.ac
plover-open/Makefile.am
plover-open/manifest.xml.in
plover-open/mimetypes-application-x-rpm.svg
plover-open/plover-open.c
plover-open/resources.rc.in
     1.1 --- a/.gitignore	Sat Nov 15 19:04:45 2014 +0000
     1.2 +++ b/.gitignore	Sat Nov 15 19:10:51 2014 +0000
     1.3 @@ -36,3 +36,10 @@
     1.4  app-manager/plover-applications*.pnm
     1.5  app-manager/24x24
     1.6  app-manager/48x48
     1.7 +plover-open/resources.rc
     1.8 +plover-open/plover-open
     1.9 +plover-open/application-x-redhat-package-manager.svg
    1.10 +plover-open/mimetypes-application-x-rpm*.pgm
    1.11 +plover-open/mimetypes-application-x-rpm*.pnm
    1.12 +plover-open/24x24
    1.13 +plover-open/48x48
     2.1 --- a/Makefile.am	Sat Nov 15 19:04:45 2014 +0000
     2.2 +++ b/Makefile.am	Sat Nov 15 19:10:51 2014 +0000
     2.3 @@ -1,1 +1,1 @@
     2.4 -SUBDIRS=plover setup update pre-inst plover-gtk app-manager
     2.5 +SUBDIRS=plover setup update pre-inst plover-gtk app-manager plover-open
     3.1 --- a/configure.ac	Sat Nov 15 19:04:45 2014 +0000
     3.2 +++ b/configure.ac	Sat Nov 15 19:10:51 2014 +0000
     3.3 @@ -19,11 +19,14 @@
     3.4  pre-inst/resources.rc
     3.5  app-manager/Makefile
     3.6  app-manager/resources.rc
     3.7 +plover-open/Makefile
     3.8 +plover-open/resources.rc
     3.9  ])
    3.10  PLOVER_MSWIN_MANIFEST([setup/setup.exe.manifest:setup/manifest.xml.in
    3.11  update/update.exe.manifest:update/manifest.xml.in
    3.12  pre-inst/pre-inst.exe.manifest:pre-inst/manifest.xml.in
    3.13  app-manager/app-manager.exe.manifest:app-manager/manifest.xml.in
    3.14 +plover-open/plover-open.exe.manifest:plover-open/manifest.xml.in
    3.15  ])
    3.16  AM_INIT_AUTOMAKE(no-define)
    3.17  m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/plover-open/Makefile.am	Sat Nov 15 19:10:51 2014 +0000
     4.3 @@ -0,0 +1,67 @@
     4.4 +AM_CFLAGS=$(GUI_CFLAGS) -g -DPLOVER_DATADIR=\""$(pkgdatadir)"\" -I$(top_srcdir)
     4.5 +LDADD=../plover/libplover.la ../plover-gtk/libplover-gtk.la $(GUI_LIBS)
     4.6 +
     4.7 +bin_PROGRAMS=plover-open
     4.8 +plover_open_SOURCES=plover-open.c
     4.9 +if HAVE_WINDRES
    4.10 +plover_open_SOURCES+=resources.rc plover-open.exe.manifest
    4.11 +endif
    4.12 +nodist_plover_open_SOURCES=icons.h
    4.13 +if PLOVER_MINGW
    4.14 +plover_open_LDFLAGS=-mwindows
    4.15 +endif
    4.16 +scaleabledir=$(datadir)/icons/hicolor/scalable/mimetypes
    4.17 +scaleable_DATA=application-x-redhat-package-manager.svg
    4.18 +smallicondir=$(datadir)/icons/hicolor/24x24/mimetypes
    4.19 +smallicon_DATA=24x24/application-x-redhat-package-manager.png
    4.20 +bigicondir=$(datadir)/icons/hicolor/48x48/mimetypes
    4.21 +bigicon_DATA=48x48/application-x-redhat-package-manager.png
    4.22 +
    4.23 +# PLOVER_V_SKIP: Don't echo anything for this command if V=0
    4.24 +PLOVER_V_SKIP = $(PLOVER_V_SKIP_$(V))
    4.25 +PLOVER_V_SKIP_ = $(PLOVER_V_SKIP_$(AM_DEFAULT_VERBOSITY))
    4.26 +PLOVER_V_SKIP_0 = @
    4.27 +
    4.28 +.rc.$(OBJEXT):
    4.29 +	$(AM_V_GEN)$(WINDRES) $< $@
    4.30 +
    4.31 +resources.$(OBJEXT):	plover-open.exe.manifest plover-open.ico
    4.32 +
    4.33 +.png.pnm:
    4.34 +	pngtopnm $< | pnmquant 256 > $@
    4.35 +
    4.36 +mimetypes-application-x-rpm%.pnm:	mimetypes-application-x-rpm.svg
    4.37 +	$(PLOVER_V_SKIP)rsvg -w $* -h $* -f png $< temp.png
    4.38 +	$(AM_V_GEN)pngtopnm temp.png | pnmquant -quiet 256 > $@
    4.39 +	$(PLOVER_V_SKIP)$(RM) temp.png
    4.40 +
    4.41 +mimetypes-application-x-rpm%.pgm:	mimetypes-application-x-rpm.svg
    4.42 +	$(PLOVER_V_SKIP)rsvg -w $* -h $* -f png $< temp.png
    4.43 +	$(AM_V_GEN)pngtopnm -alpha temp.png > $@
    4.44 +	$(PLOVER_V_SKIP)$(RM) temp.png
    4.45 +
    4.46 +24x24/application-x-redhat-package-manager.png:	mimetypes-application-x-rpm.svg
    4.47 +	$(PLOVER_V_SKIP)mkdir -p 24x24
    4.48 +	$(AM_V_GEN)rsvg -w 24 -h 24 -f png $< $@
    4.49 +
    4.50 +48x48/application-x-redhat-package-manager.png:	mimetypes-application-x-rpm.svg
    4.51 +	$(PLOVER_V_SKIP)mkdir -p 48x48
    4.52 +	$(AM_V_GEN)rsvg -w 48 -h 48 -f png $< $@
    4.53 +
    4.54 +plover-open.ico:	mimetypes-application-x-rpm16.pnm \
    4.55 +		mimetypes-application-x-rpm16.pgm \
    4.56 +		mimetypes-application-x-rpm22.pnm \
    4.57 +		mimetypes-application-x-rpm22.pgm \
    4.58 +		mimetypes-application-x-rpm32.pnm \
    4.59 +		mimetypes-application-x-rpm32.pgm \
    4.60 +		mimetypes-application-x-rpm46.pnm \
    4.61 +		mimetypes-application-x-rpm46.pgm
    4.62 +	$(AM_V_GEN)ppmtowinicon -andpgms -output=$@ $^
    4.63 +
    4.64 +clean-local:
    4.65 +	-rm -rf 24x24 48x48
    4.66 +
    4.67 +application-x-redhat-package-manager.svg: mimetypes-application-x-rpm.svg
    4.68 +	$(AM_V_GEN)cp $< $@
    4.69 +
    4.70 +EXTRA_DIST=mimetypes-application-x-rpm.svg
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/plover-open/manifest.xml.in	Sat Nov 15 19:10:51 2014 +0000
     5.3 @@ -0,0 +1,22 @@
     5.4 +changequote([,])dnl
     5.5 +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
     5.6 +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
     5.7 +  <assemblyIdentity
     5.8 +    version="@PLOVER_MAJOR_VERSION@.@PLOVER_MINOR_VERSION@.@PLOVER_MICRO_VERSION@.0"
     5.9 +    name="The plover development team.plover.plover-open" type="win32"
    5.10 +    processorArchitecture="ifelse([@HOST_CPU@],[x86_64],[ia64],[x86])" />
    5.11 +  <description>Package Handler</description>
    5.12 +  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    5.13 +    <application>
    5.14 +      <!-- Windows 7 functionality -->
    5.15 +      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
    5.16 +    </application>
    5.17 +  </compatibility>
    5.18 +  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    5.19 +    <security>
    5.20 +      <requestedPrivileges>
    5.21 +        <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
    5.22 +      </requestedPrivileges>
    5.23 +    </security>
    5.24 +  </trustInfo>
    5.25 +</assembly>
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/plover-open/mimetypes-application-x-rpm.svg	Sat Nov 15 19:10:51 2014 +0000
     6.3 @@ -0,0 +1,26 @@
     6.4 +<?xml version="1.0" encoding="UTF-8" standalone="no"?>
     6.5 +<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://web.resource.org/cc/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="920" height="537.35999" viewBox="0 0 640 409" version="1.0" id="svg2" sodipodi:version="0.32" inkscape:version="0.45.1" sodipodi:docname="RPM_Logo.svg" sodipodi:docbase="/home/butze/Desktop" inkscape:output_extension="org.inkscape.output.svg.inkscape">
     6.6 +  <metadata id="metadata43">
     6.7 +    <rdf:RDF>
     6.8 +      <cc:Work rdf:about="">
     6.9 +        <dc:format>image/svg+xml</dc:format>
    6.10 +        <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
    6.11 +      </cc:Work>
    6.12 +    </rdf:RDF>
    6.13 +  </metadata>
    6.14 +  <sodipodi:namedview inkscape:window-height="752" inkscape:window-width="1280" inkscape:pageshadow="2" inkscape:pageopacity="0.0" guidetolerance="10.0" gridtolerance="10.0" objecttolerance="10.0" borderopacity="1.0" bordercolor="#666666" pagecolor="#ffffff" id="base" width="920px" height="537.36px" inkscape:zoom="0.58998608" inkscape:cx="689.80903" inkscape:cy="89.005306" inkscape:window-x="0" inkscape:window-y="25" inkscape:current-layer="svg2"/>
    6.15 +  <defs id="defs4">
    6.16 +    <clipPath id="clip0">
    6.17 +      <rect width="640" height="409" id="rect7" x="0" y="0"/>
    6.18 +    </clipPath>
    6.19 +  </defs>
    6.20 +  <g id="g2211" transform="matrix(1.1106234,0,0,1.1106234,-37.666982,-15.952596)">
    6.21 +    <path style="fill:#000000;fill-rule:nonzero;stroke:none" d="M 242.1304,26.136154 C 254.70415,24.204163 267.38588,22.791809 280.0975,22.122498 C 282.35576,21.584457 284.69162,21.694412 286.99869,21.611954 C 305.03506,21.036636 323.09628,21.062668 341.12505,21.874893 C 373.66519,24.176361 406.04054,29.582169 437.43091,38.593475 L 437.29799,38.769745 C 432.69597,44.993652 428.08047,51.207764 423.56764,57.495636 C 422.21545,57.745117 421.03183,56.889877 419.8275,56.459152 C 396.0118,46.631683 370.66049,40.927002 345.14435,37.839966 C 303.17429,33.542038 260.20618,36.9953 219.94295,49.910034 C 190.29894,59.497772 161.67183,74.281876 139.5663,96.576553 C 123.90071,112.59686 111.87303,133.32129 110.24046,156.02855 C 108.72133,166.85004 111.31233,177.65282 113.60428,188.15413 L 14.185699,205.68005 C 13.945419,188.13843 18.523071,170.78329 25.80806,154.91394 C 40.297989,124.01501 65.424713,99.327652 93.421997,80.42572 C 112.35318,67.714981 132.81692,57.345383 154.07152,49.122925 C 182.38751,38.052567 212.05559,30.488739 242.1304,26.136154 z " id="path16" sodipodi:nodetypes="cccccccccccccccccc"/>
    6.22 +    <path style="fill:#d72123;fill-rule:nonzero;stroke:none" d="M 423.56764,57.495636 C 428.08047,51.207764 432.69597,44.993652 437.29799,38.769745 C 479.44521,51.113983 520.14622,70.606537 553.3929,99.651688 C 566.98732,111.82498 579.28281,125.5966 588.72606,141.2652 C 599.90866,159.70456 606.9949,180.82132 607.75311,202.45526 C 574.69661,196.67767 541.64931,190.8508 508.59731,185.05354 C 512.66524,172.11536 512.69997,158.02864 509.91435,144.82548 C 504.75171,122.00699 490.12285,102.41544 472.47707,87.543396 C 457.76711,75.165924 440.98531,65.246307 423.20515,57.986771 L 423.56764,57.495636 z " id="path20"/>
    6.23 +    <path style="fill:#000000;fill-rule:nonzero;stroke:none" d="M 301.70334,148.63515 C 303.64912,145.46657 307.07517,142.93918 310.97199,143.40828 C 315.37659,143.52095 318.77077,147.16072 319.68323,151.27986 L 630.43405,206.55775 L 629.39653,211.76382 L 318.71321,157.28287 C 316.23477,161.59503 310.48546,163.82207 305.96864,161.27567 C 302.83719,159.90678 301.76889,156.55594 300.35561,153.74454 L 281.22589,150.67943 L 282.1028,145.29814 L 301.70334,148.63515 z " id="path24" sodipodi:nodetypes="ccccccccccc"/>
    6.24 +    <path style="fill:#000000;fill-rule:nonzero;stroke:none" d="M 13.649231,221.30466 C 31.911636,221.18204 50.175491,221.28207 68.438629,221.25369 C 68.456711,221.93039 68.492889,223.28377 68.510971,223.96046 C 81.78093,221.07069 95.419388,219.84172 108.99162,220.5909 C 118.87418,221.49564 127.94777,225.73082 136.78575,229.935 C 126.82282,236.09672 116.68483,242.03085 106.96231,248.55022 C 96.128143,240.18365 81.403198,240.17624 68.768494,243.83687 C 68.610809,245.18874 68.46254,246.54526 68.449081,247.91402 C 68.455475,279.35362 68.464249,310.79379 68.445374,342.23402 C 50.189575,342.2283 31.934006,342.25079 13.678345,342.22247 C 13.639542,301.91635 13.697601,261.61043 13.649231,221.30466 z " id="path28"/>
    6.25 +    <path style="fill:#000000;fill-rule:nonzero;stroke:none" d="M 155.75305,221.30997 C 171.83302,221.17448 187.91509,221.28622 203.99635,221.25278 C 227.82829,221.11749 252.05051,224.18929 274.19963,233.35588 C 287.95595,239.18071 301.26196,247.78787 309.23721,260.74647 C 315.29393,270.81277 317.41153,283.73701 312.65695,294.75125 C 307.0757,307.96501 295.12288,317.12689 282.95689,323.97429 C 260.65492,335.90702 235.86864,342.25136 210.64117,343.31628 L 210.59746,368.24727 L 155.74669,375.7715 L 155.75305,221.30997 z " id="path32" sodipodi:nodetypes="cccccccccc"/>
    6.26 +    <path style="fill:#000000;fill-rule:nonzero;stroke:none" d="M 350.73776,221.33231 C 413.49503,221.14064 476.25624,221.30894 539.01537,221.24805 C 557.37595,221.32402 576.04198,221.44025 593.90257,226.18999 C 599.04286,227.88318 605.89815,229.89665 607.2502,235.8717 C 607.38423,271.32356 607.30022,306.78361 607.29105,342.23883 C 589.0249,342.23503 570.75967,342.22754 552.49496,342.24268 C 552.491,307.06375 552.41933,271.88358 552.53064,236.70589 C 549.2124,233.82698 544.4819,233.9498 540.36195,233.44704 C 529.09674,233.15378 517.8225,233.36302 506.55541,233.33128 C 506.55789,269.63435 506.59598,305.9377 506.53635,342.24097 C 488.24435,342.22391 469.95316,342.24573 451.66232,342.22978 C 451.60817,313.15071 451.65422,284.07179 451.63918,254.99307 C 451.49283,248.63887 451.95763,242.26082 451.36241,235.92719 C 446.21605,233.7641 440.57843,233.3403 435.06027,233.31384 C 425.26251,233.29803 415.46587,233.32082 405.66998,233.30383 C 405.62199,269.61919 405.72909,305.93532 405.6163,342.25056 C 388.39282,342.22855 371.16965,342.21668 353.94728,342.25768 L 350.62976,342.24453 C 350.91312,302.16914 350.6976,261.41138 350.73776,221.33231 z " id="path36" sodipodi:nodetypes="ccccccccccccccccccc"/>
    6.27 +    <path style="fill:#ffffff;fill-rule:nonzero;stroke:none" d="M 210.67975,234.60013 C 224.72664,236.0097 237.42445,243.94724 247.01939,253.99116 C 255.2939,262.69374 261.14288,274.83727 259.12215,287.06798 C 256.91338,299.32082 248.38773,309.27431 238.80063,316.6837 C 230.47391,322.79636 221.05751,328.07289 210.67726,329.45604 C 210.64148,297.8373 210.6366,266.21844 210.67975,234.60013 z " id="path40"/>
    6.28 +  </g>
    6.29 +</svg>
    6.30 \ No newline at end of file
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/plover-open/plover-open.c	Sat Nov 15 19:10:51 2014 +0000
     7.3 @@ -0,0 +1,222 @@
     7.4 +/*
     7.5 + * Copyright (C) 2014  J. Ali Harlow <ali@juiblex.co.uk>
     7.6 + *
     7.7 + * This program is free software; you can redistribute it and/or modify
     7.8 + * it under the terms of the GNU General Public License as published by
     7.9 + * the Free Software Foundation; either version 2 of the License, or
    7.10 + * (at your option) any later version.
    7.11 + *
    7.12 + * This program is distributed in the hope that it will be useful,
    7.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    7.15 + * GNU General Public License for more details.
    7.16 + *
    7.17 + * You should have received a copy of the GNU General Public License along
    7.18 + * with this program; if not, write to the Free Software Foundation, Inc.,
    7.19 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    7.20 + */
    7.21 +
    7.22 +#include "config.h"
    7.23 +#include <stdlib.h>
    7.24 +#include <string.h>
    7.25 +#ifdef WIN32
    7.26 +#include <windows.h>
    7.27 +#endif	/* WIN32 */
    7.28 +#include <lua.h>
    7.29 +#include <glib.h>
    7.30 +#include <gio/gio.h>
    7.31 +#include <gtk/gtk.h>
    7.32 +#include <whelk/whelk.h>
    7.33 +#include <plover/plover.h>
    7.34 +#include <plover/package.h>
    7.35 +#include <plover/packageset.h>
    7.36 +#include <plover-gtk/transactionhelper.h>
    7.37 +#include <plover-gtk/stockicons.h>
    7.38 +
    7.39 +LUALIB_API int luaopen_posix(lua_State *L);
    7.40 +
    7.41 +#define LOGO_NAME	"application-x-redhat-package-manager"
    7.42 +
    7.43 +gboolean install(PloverPackageSet *installed,const char *path)
    7.44 +{
    7.45 +    gchar *s;
    7.46 +    const char *prefix,*name,*unsatisfied;
    7.47 +    const char *filenames[2];
    7.48 +    GError *error=NULL;
    7.49 +    GSList *packages,*lnk;
    7.50 +    struct plover_vector *selected_packages;
    7.51 +    PloverPackage *package;
    7.52 +    PloverPackageSet *set;
    7.53 +    PloverRepository *upstream;
    7.54 +    PloverTransactionHelper *helper;
    7.55 +    helper=plover_transaction_helper_new(NULL);
    7.56 +    g_signal_connect(helper,"close",G_CALLBACK(gtk_main_quit),NULL);
    7.57 +    plover_transaction_helper_set_installed(helper,installed);
    7.58 +    if (plover_transaction_helper_get_error(helper,NULL))
    7.59 +    {
    7.60 +	plover_transaction_helper_present(helper);
    7.61 +	return TRUE;
    7.62 +    }
    7.63 +    filenames[0]=path;
    7.64 +    filenames[1]=NULL;
    7.65 +    upstream=plover_repository_new_from_files(filenames,&error);
    7.66 +    if (upstream)
    7.67 +	plover_transaction_helper_set_upstream(helper,upstream);
    7.68 +    else
    7.69 +    {
    7.70 +	plover_transaction_helper_set_error(helper,error,
    7.71 +	  "Software installation failed");
    7.72 +	g_clear_error(&error);
    7.73 +	plover_transaction_helper_present(helper);
    7.74 +	return TRUE;
    7.75 +    }
    7.76 +    prefix=plover_transaction_helper_get_prefix(helper,&error);
    7.77 +    if (error)
    7.78 +	g_clear_error(&error);
    7.79 +    else
    7.80 +    {
    7.81 +	s=g_strconcat(prefix?prefix:"","/var/log/open",NULL);
    7.82 +	plover_log_open(s);
    7.83 +	g_free(s);
    7.84 +    }
    7.85 +    set=plover_repository_get_package_set(upstream);
    7.86 +    packages=plover_package_set_get_packages(set);
    7.87 +    selected_packages=plover_vector_new();
    7.88 +    for(lnk=packages;lnk;lnk=lnk->next)
    7.89 +    {
    7.90 +	package=PLOVER_PACKAGE(lnk->data);
    7.91 +	plover_vector_append(selected_packages,
    7.92 +	  plover_package_get_name(package));
    7.93 +    }
    7.94 +    if (!plover_transaction_helper_install_packages(helper,selected_packages,
    7.95 +      &error))
    7.96 +    {
    7.97 +	if (g_error_matches(error,PLOVER_GENERAL_ERROR,
    7.98 +	  PLOVER_GENERAL_ERROR_NO_WORK))
    7.99 +	{
   7.100 +	    g_error_free(error);
   7.101 +	    error=g_error_new_literal(PLOVER_GENERAL_ERROR,
   7.102 +	      PLOVER_GENERAL_ERROR_NO_WORK,
   7.103 +	      "All packages already installed");
   7.104 +	    plover_transaction_helper_set_error(helper,error,
   7.105 +	      "Software installation");
   7.106 +	}
   7.107 +	else if (g_error_matches(error,PLOVER_GENERAL_ERROR,
   7.108 +	  PLOVER_GENERAL_ERROR_REQUIREMENTS_NOT_MET))
   7.109 +	{
   7.110 +	    g_error_free(error);
   7.111 +	    unsatisfied=plover_transaction_helper_get_unsatisfied(helper);
   7.112 +	    error=g_error_new(PLOVER_GENERAL_ERROR,
   7.113 +	      PLOVER_GENERAL_ERROR_REQUIREMENTS_NOT_MET,
   7.114 +	      "Software cannot be installed because the following requirements "
   7.115 +	      "were not met:\n\n%s",unsatisfied);
   7.116 +	    plover_transaction_helper_set_error(helper,error,
   7.117 +	      "Software installation failed");
   7.118 +	}
   7.119 +	else
   7.120 +	    plover_transaction_helper_set_error(helper,error,
   7.121 +	      "Software installation failed");
   7.122 +	g_error_free(error);
   7.123 +    }
   7.124 +    plover_vector_free(selected_packages);
   7.125 +    g_object_unref(upstream);
   7.126 +    plover_transaction_helper_present(helper);
   7.127 +    return TRUE;
   7.128 +}
   7.129 +
   7.130 +static void install_icons(void)
   7.131 +{
   7.132 +    GtkIconSet *icon_set;
   7.133 +    plover_icons_add_to_stock("mimetypes",LOGO_NAME);
   7.134 +    icon_set=gtk_icon_factory_lookup_default(LOGO_NAME);
   7.135 +    gtk_window_set_default_icon_name(LOGO_NAME);
   7.136 +}
   7.137 +
   7.138 +int main(int argc,char **argv)
   7.139 +{
   7.140 +    GError *err=0;
   7.141 +    GtkWidget *w;
   7.142 +    gchar *s,*t,*contents;
   7.143 +    gchar *install_path=NULL;
   7.144 +    gsize len;
   7.145 +    PloverPackageSet *set;
   7.146 +#if 0
   7.147 +    GSList *objects,*lnk;
   7.148 +#endif
   7.149 +    gboolean started;
   7.150 +    GOptionEntry options[]={
   7.151 +	{"install",0,0,G_OPTION_ARG_FILENAME,&install_path,
   7.152 +	  "Install an RPM","path"},
   7.153 +	{NULL}
   7.154 +    };
   7.155 +#ifdef WIN32
   7.156 +    /*
   7.157 +     * plover-open is normally a GUI application, but rpm scripts may well
   7.158 +     * call console applications and it looks ugly if console windows keep
   7.159 +     * popping up. Avoid this by allocating our own console and hiding it.
   7.160 +     * Note:
   7.161 +     *	- If plover-open is a console application (typically for debugging),
   7.162 +     *    then skip this step.
   7.163 +     *  - Call ShowWindow twice to negate special handling on first call.
   7.164 +     */
   7.165 +    if (!GetConsoleWindow())
   7.166 +    {
   7.167 +	AllocConsole();
   7.168 +	ShowWindow(GetConsoleWindow(),SW_HIDE);
   7.169 +	ShowWindow(GetConsoleWindow(),SW_HIDE);
   7.170 +    }
   7.171 +#endif
   7.172 +    razor_set_lua_loader("posix",luaopen_posix);
   7.173 +    razor_set_lua_loader("whelk",luaopen_whelk);
   7.174 +    if (!gtk_init_with_args(&argc,&argv,NULL,options,NULL,&err))
   7.175 +    {
   7.176 +	g_printerr("%s\n",err->message);
   7.177 +	exit(1);
   7.178 +    }
   7.179 +    install_icons();
   7.180 +#if 0
   7.181 +    ui=gtk_builder_new();
   7.182 +    if (!g_file_get_contents("plover-open.ui",&contents,&len,&err) &&
   7.183 +      g_error_matches(err,G_FILE_ERROR,G_FILE_ERROR_NOENT))
   7.184 +    {
   7.185 +#ifdef WIN32
   7.186 +	t=g_win32_get_package_installation_directory_of_module(NULL);
   7.187 +	s=g_build_filename(t,"share","plover","plover-open.ui",NULL);
   7.188 +	g_free(t);
   7.189 +#else
   7.190 +	s=g_build_filename(PLOVER_DATADIR,"plover-open.ui",NULL);
   7.191 +#endif
   7.192 +	g_clear_error(&err);
   7.193 +	(void)g_file_get_contents(s,&contents,&len,&err);
   7.194 +	g_free(s);
   7.195 +    }
   7.196 +    if (!err)
   7.197 +    {
   7.198 +	(void)gtk_builder_add_from_string(ui,contents,len,&err);
   7.199 +	g_free(contents);
   7.200 +    }
   7.201 +    if (err)
   7.202 +    {
   7.203 +	g_error("%s",err->message);
   7.204 +	exit(0);
   7.205 +    }
   7.206 +    gtk_builder_connect_signals(ui,NULL);
   7.207 +#endif
   7.208 +    set=plover_package_set_new();
   7.209 +    (void)plover_package_set_open(set,"",TRUE,NULL);
   7.210 +    if (install_path)
   7.211 +	if (install(set,install_path))
   7.212 +	    gtk_main();
   7.213 +    g_clear_object(&set);
   7.214 +#if 0
   7.215 +    objects=gtk_builder_get_objects(ui);
   7.216 +    for(lnk=objects;lnk;lnk=lnk->next)
   7.217 +	if (GTK_IS_WIDGET(lnk->data) &&
   7.218 +	  gtk_widget_is_toplevel(GTK_WIDGET(lnk->data)))
   7.219 +	    gtk_widget_destroy(GTK_WIDGET(lnk->data));
   7.220 +    g_slist_free(objects);
   7.221 +    g_clear_object(&ui);
   7.222 +#endif
   7.223 +    g_free(install_path);
   7.224 +    exit(0);
   7.225 +}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/plover-open/resources.rc.in	Sat Nov 15 19:10:51 2014 +0000
     8.3 @@ -0,0 +1,37 @@
     8.4 +#include <winver.h>
     8.5 +#include <winuser.h>
     8.6 +
     8.7 +#pragma code_page(65001)
     8.8 +
     8.9 +MAINICON ICON "plover-open.ico"
    8.10 +
    8.11 +VS_VERSION_INFO VERSIONINFO
    8.12 +    FILEVERSION @PLOVER_MAJOR_VERSION@,@PLOVER_MINOR_VERSION@,
    8.13 +      @PLOVER_MICRO_VERSION@,0
    8.14 +    PRODUCTVERSION @PLOVER_MAJOR_VERSION@,@PLOVER_MINOR_VERSION@,
    8.15 +      @PLOVER_MICRO_VERSION@,0
    8.16 +    FILEOS VOS__WINDOWS32
    8.17 +    FILETYPE VFT_APP
    8.18 +    {
    8.19 +	BLOCK "StringFileInfo"
    8.20 +	{
    8.21 +	    BLOCK "080904B0"
    8.22 +	    {
    8.23 +		VALUE "CompanyName","The plover development team"
    8.24 +		VALUE "FileDescription","Plover Menu Handler"
    8.25 +		VALUE "FileVersion","@PACKAGE_VERSION@"
    8.26 +		VALUE "InternalName","plover-open"
    8.27 +		VALUE "LegalCopyright",
    8.28 +		  "Copyright © 2014 J. Ali Harlow et al"
    8.29 +		VALUE "OriginalFilename","plover-open.exe"
    8.30 +		VALUE "ProductName","plover"
    8.31 +		VALUE "ProductVersion","@PACKAGE_VERSION@"
    8.32 +	    }
    8.33 +	}
    8.34 +	BLOCK "VarFileInfo"
    8.35 +	{
    8.36 +	    VALUE "Translation",0x809,0x4B0
    8.37 +	}
    8.38 +    }
    8.39 +
    8.40 +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "plover-open.exe.manifest"