├── .vscode
└── ipch
│ ├── b9fcabc967f7b934
│ ├── mmap_address.bin
│ └── DiscordRpcBlueprint.ipch
│ └── d34ac24d70d207fb
│ └── mmap_address.bin
├── img
├── demo.png
├── gimp.png
└── gimp-flat.png
├── .gitattributes
├── .gitmodules
├── .gitignore
├── LICENSE
├── README.md
└── plugin.c
/.vscode/ipch/b9fcabc967f7b934/mmap_address.bin:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.vscode/ipch/d34ac24d70d207fb/mmap_address.bin:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/img/demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrousavy/gimp-rpc/HEAD/img/demo.png
--------------------------------------------------------------------------------
/img/gimp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrousavy/gimp-rpc/HEAD/img/gimp.png
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/img/gimp-flat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrousavy/gimp-rpc/HEAD/img/gimp-flat.png
--------------------------------------------------------------------------------
/.vscode/ipch/b9fcabc967f7b934/DiscordRpcBlueprint.ipch:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrousavy/gimp-rpc/HEAD/.vscode/ipch/b9fcabc967f7b934/DiscordRpcBlueprint.ipch
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "discord-rpc"]
2 | path = discord-rpc
3 | url = https://github.com/discordapp/discord-rpc
4 | [submodule "gimp"]
5 | path = gimp
6 | url = https://github.com/GNOME/gimp
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Prerequisites
2 | *.d
3 |
4 | # Object files
5 | *.o
6 | *.ko
7 | *.obj
8 | *.elf
9 |
10 | # Linker output
11 | *.ilk
12 | *.map
13 | *.exp
14 |
15 | # Precompiled Headers
16 | *.gch
17 | *.pch
18 |
19 | # Libraries
20 | *.lib
21 | *.a
22 | *.la
23 | *.lo
24 |
25 | # Shared objects (inc. Windows DLLs)
26 | *.dll
27 | *.so
28 | *.so.*
29 | *.dylib
30 |
31 | # Executables
32 | *.exe
33 | *.out
34 | *.app
35 | *.i*86
36 | *.x86_64
37 | *.hex
38 |
39 | # Debug files
40 | *.dSYM/
41 | *.su
42 | *.idb
43 | *.pdb
44 |
45 | # Kernel Module Compile Results
46 | *.mod*
47 | *.cmd
48 | .tmp_versions/
49 | modules.order
50 | Module.symvers
51 | Mkfile.old
52 | dkms.conf
53 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Marc Rousavy
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | | README.md |
2 | |:---|
3 |
4 |
5 |
6 |
gimp-rpc
7 |
8 |
9 | ### Features
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | * Displays GIMP name and icon
18 | * Displays currently selected tool
19 | * Displays currently opened file
20 | * Displays elapsed time in file
21 |
22 | ### Install
23 |
24 | ```sh
25 | git clone https://github.com/mrousavy/gimp-rpc.git
26 | gimptool-2.0 --install-admin gimp-rpc/plugin.c
27 | ```
28 |
29 | > (Installer script coming soon)
30 |
31 |
32 |
33 | Contribute
34 |
35 |
36 | 1. Clone `gimp-rpc`
37 |
38 | ```sh
39 | git clone https://github.com/mrousavy/gimp-rpc.git
40 | cd gimp-rpc
41 | git submodule update --init --recursive
42 | ```
43 |
44 | 2. Build libraries
45 |
46 | * `gimp`
47 |
48 | ```sh
49 | cd gimp
50 | export INSTALL_PREFIX=$HOME/dev/gimp-prefix/
51 | export SRC_DIR=/vol/scratch/gimp-beta/src
52 | mkdir -p $INSTALL_PREFIX
53 | mkdir -p $SRC_DIR
54 | export PATH=$INSTALL_PREFIX/bin:$PATH
55 | export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH
56 | export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib:$LD_LIBRARY_PATH
57 | ./configure --prefix=$INSTALL_PREFIX
58 | ./autogen.sh --prefix=$INSTALL_PREFIX --disable-gtk-doc
59 | make
60 | make install
61 | ```
62 |
63 | * `discord-rpc`
64 |
65 | ```sh
66 | cd discord-rpc
67 | mkdir build
68 | cd build
69 | cmake .. -DCMAKE_INSTALL_PREFIX=
70 | cmake --build . --config Release --target install
71 | ```
72 |
73 | 3. Make changes to `gimp-rpc`
74 |
75 | The main plugin logic is programmed in the `plugin.c` file. Change as desired.
76 |
77 | 4. Build `gimp-rpc`
78 |
79 | ```sh
80 | gimptool-2.0 --install-admin plugin.c
81 | ```
82 |
83 |
84 |
85 |
86 | Credits
87 |
88 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/plugin.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | static void query(void);
6 | static void run(const gchar *name,
7 | gint nparams,
8 | const GimpParam *param,
9 | gint *nreturn_vals,
10 | GimpParam **return_vals);
11 |
12 | GimpPlugInInfo PLUG_IN_INFO =
13 | {
14 | NULL,
15 | NULL,
16 | query,
17 | run};
18 |
19 | MAIN()
20 |
21 | void handleDiscordReady(const DiscordUser *connectedUser)
22 | {
23 | printf("Discord ready!");
24 | }
25 |
26 | void handleDiscordError(int errcode, const char* message)
27 | {
28 | printf("Discord error!");
29 | }
30 |
31 | void handleDiscordDisconnected(int errcode, const char* message)
32 | {
33 | printf("Discord disconnected!");
34 | }
35 |
36 | void InitDiscord()
37 | {
38 | DiscordEventHandlers handlers;
39 | memset(&handlers, 0, sizeof(handlers));
40 | handlers.ready = handleDiscordReady;
41 | handlers.errored = handleDiscordError;
42 | handlers.disconnected = handleDiscordDisconnected;
43 |
44 | // Discord_Initialize(const char* applicationId, DiscordEventHandlers* handlers, int autoRegister, const char* optionalSteamId, int pipe)
45 | Discord_Initialize("559741941156413461", &handlers, 1, NULL, 0);
46 | }
47 |
48 | typedef struct DiscordRichPresence {
49 | const char* state; /* max 128 bytes */
50 | const char* details; /* max 128 bytes */
51 | int64_t startTimestamp;
52 | int64_t endTimestamp;
53 | const char* largeImageKey; /* max 32 bytes */
54 | const char* largeImageText; /* max 128 bytes */
55 | const char* smallImageKey; /* max 32 bytes */
56 | const char* smallImageText; /* max 128 bytes */
57 | const char* partyId; /* max 128 bytes */
58 | int partySize;
59 | int partyMax;
60 | const char* matchSecret; /* max 128 bytes */
61 | const char* joinSecret; /* max 128 bytes */
62 | const char* spectateSecret; /* max 128 bytes */
63 | int8_t instance;
64 | } DiscordRichPresence;
65 |
66 | void UpdatePresence()
67 | {
68 | gint* images_count = malloc(sizeof(gint));
69 | gint* images = gimp_image_list(images_count);
70 | gchar* uri = gimp_image_get_uri(images[0]);
71 |
72 | char buffer[256];
73 | DiscordRichPresence discordPresence;
74 | memset(&discordPresence, 0, sizeof(discordPresence));
75 | discordPresence.state = "GIMP";
76 | sprintf(buffer, "Editing %s", "debugging.gmp");
77 | discordPresence.details = buffer;
78 | discordPresence.endTimestamp = time(0) + 5 * 60;
79 | discordPresence.largeImageKey = "gimp";
80 | discordPresence.smallImageKey = "gimp-flat";
81 | discordPresence.instance = 1;
82 | Discord_UpdatePresence(&discordPresence);
83 | }
84 |
85 |
86 | static void query(void)
87 | {
88 | static GimpParamDef args[] =
89 | {
90 | {GIMP_PDB_INT32,
91 | "run-mode",
92 | "Run mode"},
93 | {GIMP_PDB_IMAGE,
94 | "image",
95 | "Input image"},
96 | {GIMP_PDB_DRAWABLE,
97 | "drawable",
98 | "Input drawable"}};
99 |
100 | gimp_install_procedure(
101 | "gimp-rpc",
102 | "GIMP RPC",
103 | "Discord Rich Presence for GIMP",
104 | "Marc Rousavy",
105 | "Copyright Marc Rousavy",
106 | "2019",
107 | "_Toggle Discord Rich Presence...",
108 | "RGB*, GRAY*",
109 | GIMP_PLUGIN,
110 | G_N_ELEMENTS(args), 0,
111 | args, NULL);
112 |
113 | gimp_plugin_menu_register("gimp-rpc", "/Tools/Discord Rich Presence");
114 | }
115 |
116 | static void run(const gchar *name,
117 | gint nparams,
118 | const GimpParam *param,
119 | gint *nreturn_vals,
120 | GimpParam **return_vals)
121 | {
122 | static GimpParam values[1];
123 | GimpPDBStatusType status = GIMP_PDB_SUCCESS;
124 | GimpRunMode run_mode;
125 | *nreturn_vals = 1;
126 | *return_vals = values;
127 | values[0].type = GIMP_PDB_STATUS;
128 | values[0].data.d_status = status;
129 | run_mode = param[0].data.d_int32;
130 |
131 | bool enableRichPresence = true;
132 |
133 | if (run_mode != GIMP_RUN_NONINTERACTIVE)
134 | {
135 | if (enableRichPresence)
136 | {
137 | g_message("Enabling..\n");
138 | InitDiscord();
139 | g_message("Enabled!\n");
140 | while(true) {
141 | print("Updating presence...");
142 | UpdatePresence();
143 | sleep(1000);
144 | }
145 | }
146 | else
147 | {
148 | g_message("Disabling..\n");
149 | Discord_Shutdown();
150 | g_message("Disabled!\n");
151 | }
152 | }
153 | }
154 |
--------------------------------------------------------------------------------