Skip to content

Commit 13e8021

Browse files
authored
Merge pull request #94 from AppImage/code-style
Code style improvements
2 parents 86c4cca + 36fa341 commit 13e8021

File tree

7 files changed

+24
-19
lines changed

7 files changed

+24
-19
lines changed

include/appimage/appimage.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,12 @@ int appimage_unregister_in_system(const char *path, bool verbose);
8585

8686

8787
#ifdef LIBAPPIMAGE_THUMBNAILER_ENABLED
88-
/* Create AppImage thumbnail according to
88+
/*
89+
* Create AppImage thumbnail according to
8990
* https://specifications.freedesktop.org/thumbnail-spec/0.8.0/index.html
91+
* Returns true on success, false otherwise.
9092
*/
91-
void appimage_create_thumbnail(const char* appimage_file_path, bool verbose);
93+
bool appimage_create_thumbnail(const char* appimage_file_path, bool verbose);
9294
#endif // LIBAPPIMAGE_THUMBNAILER_ENABLED
9395

9496
#endif // LIBAPPIMAGE_DESKTOP_INTEGRATION_ENABLED

src/libappimage/desktop_integration/integrator/Integrator.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,19 +275,19 @@ namespace appimage {
275275
};
276276

277277
Integrator::Integrator(const AppImage& appImage, const bf::path& xdgDataHome)
278-
: priv(new Priv(appImage, xdgDataHome)) {}
278+
: d(new Priv(appImage, xdgDataHome)) {}
279279

280280
Integrator::~Integrator() = default;
281281

282282
void Integrator::integrate() {
283283
// an unedited desktop entry is required to identify the resources to be deployed
284-
priv->assertItShouldBeIntegrated();
284+
d->assertItShouldBeIntegrated();
285285

286286
// Must be executed before deployDesktopEntry because it changes the icon names
287-
priv->deployIcons();
288-
priv->deployDesktopEntry();
289-
priv->deployMimeTypePackages();
290-
priv->setExecutionPermission();
287+
d->deployIcons();
288+
d->deployDesktopEntry();
289+
d->deployMimeTypePackages();
290+
d->setExecutionPermission();
291291
}
292292
}
293293
}

src/libappimage/desktop_integration/integrator/Integrator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace appimage {
4444

4545
private:
4646
class Priv;
47-
std::unique_ptr<Priv> priv; // opaque pointer
47+
std::unique_ptr<Priv> d; // opaque pointer
4848
};
4949
}
5050

src/libappimage/libappimage.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,15 @@ bool appimage_is_registered_in_system(const char* path) {
287287
/* Create AppImage thumbanil according to
288288
* https://specifications.freedesktop.org/thumbnail-spec/0.8.0/index.html
289289
*/
290-
void appimage_create_thumbnail(const char* appimage_file_path, bool verbose) {
290+
bool appimage_create_thumbnail(const char* appimage_file_path, bool verbose) {
291291
CATCH_ALL(
292292
AppImage appImage(appimage_file_path);
293293
IntegrationManager manager;
294294
manager.generateThumbnails(appImage);
295+
return true;
295296
);
297+
298+
return false;
296299
}
297300

298301
#endif // LIBAPPIMAGE_THUMBNAILER_ENABLED

src/libappimage/utils/IconHandle.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,23 +420,23 @@ namespace appimage {
420420
}
421421
};
422422

423-
IconHandle::IconHandle(std::vector<char>& data) : priv(new Priv(data)) {}
423+
IconHandle::IconHandle(std::vector<char>& data) : d(new Priv(data)) {}
424424

425-
int IconHandle::getSize() { return priv->getIconSize(); }
425+
int IconHandle::getSize() { return d->getIconSize(); }
426426

427-
std::string IconHandle::format() { return priv->getImageFormat(); }
427+
std::string IconHandle::format() { return d->getImageFormat(); }
428428

429-
void IconHandle::setSize(int size) { priv->setIconSize(size); }
429+
void IconHandle::setSize(int size) { d->setIconSize(size); }
430430

431431
void IconHandle::save(const std::string& path, const std::string& format) {
432432
bf::path bPath(path);
433433
try { bf::create_directories(bPath.parent_path()); }
434434
catch (const bf::filesystem_error&) { throw IconHandleError("Unable to create parent path"); }
435435

436-
priv->save(bPath, format);
436+
d->save(bPath, format);
437437
}
438438

439-
IconHandle::IconHandle(const std::string& path) : priv(new Priv(path)) {}
439+
IconHandle::IconHandle(const std::string& path) : d(new Priv(path)) {}
440440

441441
IconHandle::~IconHandle() = default;
442442

src/libappimage/utils/IconHandle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace appimage {
6161
private:
6262
class Priv;
6363

64-
std::unique_ptr<Priv> priv;
64+
std::unique_ptr<Priv> d;
6565
};
6666

6767
class IconHandleError : public std::runtime_error {

tests/libappimage/legacy/test_libappimage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ TEST_F(LibAppImageTest, test_appimage_shall_not_integrate) {
560560
#ifdef LIBAPPIMAGE_THUMBNAILER_ENABLED
561561

562562
TEST_F(LibAppImageTest, create_thumbnail_appimage_type_1) {
563-
appimage_create_thumbnail(appImage_type_1_file_path.c_str(), false);
563+
EXPECT_TRUE(appimage_create_thumbnail(appImage_type_1_file_path.c_str(), false));
564564

565565
gchar* sum = appimage_get_md5(appImage_type_1_file_path.c_str());
566566

@@ -579,7 +579,7 @@ TEST_F(LibAppImageTest, create_thumbnail_appimage_type_1) {
579579
}
580580

581581
TEST_F(LibAppImageTest, create_thumbnail_appimage_type_2) {
582-
appimage_create_thumbnail(appImage_type_2_file_path.c_str(), false);
582+
EXPECT_TRUE(appimage_create_thumbnail(appImage_type_2_file_path.c_str(), false));
583583

584584
gchar* sum = appimage_get_md5(appImage_type_2_file_path.c_str());
585585

0 commit comments

Comments
 (0)