forked from mirrors/gio-qt
parent
31087054fa
commit
224c16ae31
19 changed files with 98 additions and 72 deletions
|
@ -4,30 +4,36 @@
|
|||
configure_file ("gio-qt.pc.in" "gio-qt.pc" @ONLY)
|
||||
|
||||
set (QGIO_PUBLIC_HEADER_FILES
|
||||
dgiovolumemanager.h
|
||||
dgiomountoperation.h
|
||||
dgiomount.h
|
||||
dgiovolume.h
|
||||
dgiofile.h
|
||||
dgiofileinfo.h
|
||||
dgioutils.h
|
||||
dgiofileiterator.h
|
||||
include/dgiovolumemanager.h
|
||||
include/dgiomountoperation.h
|
||||
include/dgiomount.h
|
||||
include/dgiovolume.h
|
||||
include/dgiofile.h
|
||||
include/dgiofileinfo.h
|
||||
include/dgioutils.h
|
||||
include/dgiofileiterator.h
|
||||
)
|
||||
|
||||
set (QGIO_PRIVATE_HEADER_FILES
|
||||
private/dgiohelper.h
|
||||
)
|
||||
|
||||
set (QGIO_PRIVATE_CPP_FILES
|
||||
dgiovolumemanager.cpp
|
||||
dgiomountoperation.cpp
|
||||
dgiomount.cpp
|
||||
dgiovolume.cpp
|
||||
dgiofile.cpp
|
||||
dgiofileinfo.cpp
|
||||
dgioutils.cpp
|
||||
dgiofileiterator.cpp
|
||||
source/dgiovolumemanager.cpp
|
||||
source/dgiomountoperation.cpp
|
||||
source/dgiomount.cpp
|
||||
source/dgiovolume.cpp
|
||||
source/dgiofile.cpp
|
||||
source/dgiofileinfo.cpp
|
||||
source/dgioutils.cpp
|
||||
source/dgiofileiterator.cpp
|
||||
private/dgiohelper.cpp
|
||||
)
|
||||
|
||||
# Library
|
||||
add_library (gio-qt SHARED
|
||||
${QGIO_PUBLIC_HEADER_FILES}
|
||||
${QGIO_PRIVATE_HEADER_FILES}
|
||||
${QGIO_PRIVATE_CPP_FILES}
|
||||
)
|
||||
|
||||
|
@ -40,8 +46,9 @@ set_target_properties(
|
|||
target_include_directories(gio-qt
|
||||
PRIVATE
|
||||
${GIOMM_INCLUDE_DIRS}
|
||||
${CMAKE_CURRENT_LIST_DIR}/private
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
${CMAKE_CURRENT_LIST_DIR}/include
|
||||
)
|
||||
|
||||
target_link_libraries (gio-qt Qt5::Core ${GIOMM_LIBRARIES})
|
||||
|
|
57
gio-qt/private/dgiohelper.cpp
Normal file
57
gio-qt/private/dgiohelper.cpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
#include "dgiohelper.h"
|
||||
|
||||
#include <glibmm/refptr.h>
|
||||
|
||||
#include <giomm/themedicon.h>
|
||||
|
||||
using namespace Gio;
|
||||
|
||||
namespace DGioPrivate {
|
||||
|
||||
QStringList getThemedIconNames(Glib::RefPtr<const Gio::Icon> icon)
|
||||
{
|
||||
QStringList iconNames;
|
||||
|
||||
Glib::RefPtr<const ThemedIcon> themedIcon = Glib::RefPtr<const ThemedIcon>::cast_dynamic(icon);
|
||||
|
||||
// due to https://gitlab.gnome.org/GNOME/glibmm/issues/50 we cannot use the glibmm way to get icon name.
|
||||
// upstream already fixed the issue but we still need debian backport the patch so we can use it.
|
||||
// see: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=932950
|
||||
|
||||
// if (G_IS_THEMED_ICON(themedIcon->gobj()) ) {
|
||||
// qDebug() << "Yes and";
|
||||
// }
|
||||
|
||||
// if (themedIcon) {
|
||||
// qDebug() << "Yes";
|
||||
// }
|
||||
|
||||
if (themedIcon) {
|
||||
char **names;
|
||||
char **iter;
|
||||
names = NULL;
|
||||
g_object_get(G_THEMED_ICON(themedIcon->gobj()), "names", &names, NULL);
|
||||
for (iter = names; *iter; iter++) {
|
||||
iconNames.append(QString(*iter));
|
||||
}
|
||||
g_strfreev(names);
|
||||
return iconNames;
|
||||
}
|
||||
|
||||
// return {QStringList::fromStdList(themedIcon->get_names())};
|
||||
|
||||
// char* name = 0;
|
||||
// g_object_get(G_OBJECT(themedIcon->gobj()), "name", &name, NULL);
|
||||
// return {QString(name)};
|
||||
|
||||
// if (themedIcon) {
|
||||
// auto ustring_names = themedIcon->get_names();
|
||||
//// for (const Glib::ustring &str : ustring_names) {
|
||||
//// iconNames.append(QString::fromStdString(str.raw()));
|
||||
//// }
|
||||
// }
|
||||
return iconNames;
|
||||
}
|
||||
|
||||
}
|
||||
|
12
gio-qt/private/dgiohelper.h
Normal file
12
gio-qt/private/dgiohelper.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef DGIOHELPER_H
|
||||
#define DGIOHELPER_H
|
||||
|
||||
#include <giomm/icon.h>
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
namespace DGioPrivate {
|
||||
QStringList getThemedIconNames(Glib::RefPtr<const Gio::Icon> icon);
|
||||
}
|
||||
|
||||
#endif // DGIOHELPER_H
|
|
@ -11,6 +11,9 @@
|
|||
|
||||
#include <QDebug>
|
||||
|
||||
// private
|
||||
#include "dgiohelper.h"
|
||||
|
||||
using namespace Gio;
|
||||
|
||||
class DGioMountPrivate
|
||||
|
@ -150,71 +153,18 @@ QStringList DGioMount::themedIconNames() const
|
|||
{
|
||||
Q_D(const DGioMount);
|
||||
|
||||
QStringList iconNames;
|
||||
|
||||
Glib::RefPtr<const Icon> icon = d->getGmmMountInstance()->get_icon();
|
||||
Glib::RefPtr<const ThemedIcon> themedIcon = Glib::RefPtr<const ThemedIcon>::cast_dynamic(icon);
|
||||
|
||||
// if (G_IS_THEMED_ICON(themedIcon->gobj()) ) {
|
||||
// qDebug() << "Yes and";
|
||||
// }
|
||||
|
||||
// if (themedIcon) {
|
||||
// qDebug() << "Yes";
|
||||
// }
|
||||
|
||||
if (themedIcon) {
|
||||
QStringList iconNames;
|
||||
char **names;
|
||||
char **iter;
|
||||
names = NULL;
|
||||
g_object_get(G_THEMED_ICON(themedIcon->gobj()), "names", &names, NULL);
|
||||
for (iter = names; *iter; iter++) {
|
||||
iconNames.append(QString(*iter));
|
||||
}
|
||||
g_strfreev(names);
|
||||
return iconNames;
|
||||
}
|
||||
|
||||
// return {QStringList::fromStdList(themedIcon->get_names())};
|
||||
|
||||
// char* name = 0;
|
||||
// g_object_get(G_OBJECT(themedIcon->gobj()), "name", &name, NULL);
|
||||
// return {QString(name)};
|
||||
|
||||
// if (themedIcon) {
|
||||
// auto ustring_names = themedIcon->get_names();
|
||||
//// for (const Glib::ustring &str : ustring_names) {
|
||||
//// iconNames.append(QString::fromStdString(str.raw()));
|
||||
//// }
|
||||
// }
|
||||
|
||||
return iconNames;
|
||||
return DGioPrivate::getThemedIconNames(icon);
|
||||
}
|
||||
|
||||
QStringList DGioMount::themedSymbolicIconNames() const
|
||||
{
|
||||
Q_D(const DGioMount);
|
||||
|
||||
QStringList iconNames;
|
||||
|
||||
Glib::RefPtr<const Icon> icon = d->getGmmMountInstance()->get_symbolic_icon();
|
||||
Glib::RefPtr<const ThemedIcon> themedIcon = Glib::RefPtr<const ThemedIcon>::cast_dynamic(icon);
|
||||
|
||||
if (themedIcon) {
|
||||
QStringList iconNames;
|
||||
char **names;
|
||||
char **iter;
|
||||
names = NULL;
|
||||
g_object_get(G_THEMED_ICON(themedIcon->gobj()), "names", &names, NULL);
|
||||
for (iter = names; *iter; iter++) {
|
||||
iconNames.append(QString(*iter));
|
||||
}
|
||||
g_strfreev(names);
|
||||
return iconNames;
|
||||
}
|
||||
|
||||
return iconNames;
|
||||
return DGioPrivate::getThemedIconNames(icon);
|
||||
}
|
||||
|
||||
void DGioMount::unmount(bool forceUnmount)
|
Loading…
Reference in a new issue