parent
a5882a1a1c
commit
2505c0a82d
46
cmake/modules/FindGTK3.cmake
Normal file
46
cmake/modules/FindGTK3.cmake
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# - Try to find GTK+ 3
|
||||||
|
# Once done, this will define
|
||||||
|
#
|
||||||
|
# GTK3_FOUND - system has GTK+ 3.
|
||||||
|
# GTK3_INCLUDE_DIRS - the GTK+ 3. include directories
|
||||||
|
# GTK3_LIBRARIES - link these to use GTK+ 3.
|
||||||
|
#
|
||||||
|
# Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org>
|
||||||
|
# Copyright (C) 2013 Igalia S.L.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
|
||||||
|
# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
find_package(PkgConfig)
|
||||||
|
pkg_check_modules(GTK3 QUIET gtk+-3.0)
|
||||||
|
set(VERSION_OK TRUE)
|
||||||
|
if (GTK3_VERSION)
|
||||||
|
if (GTK3_FIND_VERSION_EXACT)
|
||||||
|
if (NOT("${GTK3_FIND_VERSION}" VERSION_EQUAL "${GTK3_VERSION}"))
|
||||||
|
set(VERSION_OK FALSE)
|
||||||
|
endif ()
|
||||||
|
else ()
|
||||||
|
if ("${GTK3_VERSION}" VERSION_LESS "${GTK3_FIND_VERSION}")
|
||||||
|
set(VERSION_OK FALSE)
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK3 DEFAULT_MSG GTK3_INCLUDE_DIRS GTK3_LIBRARIES VERSION_OK)
|
@ -256,11 +256,11 @@ if (SLIC3R_PCH AND NOT SLIC3R_SYNTAXONLY)
|
|||||||
add_precompiled_header(libslic3r_gui pchheader.hpp FORCEINCLUDE)
|
add_precompiled_header(libslic3r_gui pchheader.hpp FORCEINCLUDE)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
target_include_directories(libslic3r_gui PUBLIC /usr/include/glib-2.0)
|
# We need to implement some hacks for wxWidgets and touch the underlying GTK
|
||||||
target_include_directories(libslic3r_gui PUBLIC /usr/lib/glib-2.0/include)
|
# layer and sub-libraries. This forces us to use the include locations of these
|
||||||
target_include_directories(libslic3r_gui PUBLIC /usr/include/pango-1.0)
|
# libraries. No need to link to them, wxWidgets does that already.
|
||||||
target_include_directories(libslic3r_gui PUBLIC /usr/include/harfbuzz)
|
# See PresetComboBox.cpp for the includes and subsequent workarounds.
|
||||||
target_include_directories(libslic3r_gui PUBLIC /usr/include/gtk-3.0/)
|
if (UNIX AND NOT APPLE)
|
||||||
target_include_directories(libslic3r_gui PUBLIC /usr/include/cairo/)
|
find_package(GTK${SLIC3R_GTK} REQUIRED)
|
||||||
target_include_directories(libslic3r_gui PUBLIC /usr/include/gdk-pixbuf-2.0/)
|
target_include_directories(libslic3r_gui PRIVATE ${GTK${SLIC3R_GTK}_INCLUDE_DIRS})
|
||||||
target_include_directories(libslic3r_gui PUBLIC /usr/include/atk-1.0/)
|
endif ()
|
||||||
|
@ -32,9 +32,13 @@
|
|||||||
#include "PhysicalPrinterDialog.hpp"
|
#include "PhysicalPrinterDialog.hpp"
|
||||||
#include "SavePresetDialog.hpp"
|
#include "SavePresetDialog.hpp"
|
||||||
|
|
||||||
#include <glib-2.0/glib-object.h>
|
// A workaround for a set of issues related to text fitting into gtk widgets:
|
||||||
#include <pango-1.0/pango/pango-layout.h>
|
// See e.g.: https://github.com/prusa3d/PrusaSlicer/issues/4584
|
||||||
#include <gtk/gtk.h>
|
#if defined(__WXGTK20__) || defined(__WXGTK3__)
|
||||||
|
#include <glib-2.0/glib-object.h>
|
||||||
|
#include <pango-1.0/pango/pango-layout.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using Slic3r::GUI::format_wxstr;
|
using Slic3r::GUI::format_wxstr;
|
||||||
|
|
||||||
@ -134,8 +138,6 @@ PresetComboBox::PresetComboBox(wxWindow* parent, Preset::Type preset_type, const
|
|||||||
}
|
}
|
||||||
evt.Skip();
|
evt.Skip();
|
||||||
});
|
});
|
||||||
|
|
||||||
// g_object_set( G_OBJECT( this ), "ellipsize", PANGO_ELLIPSIZE_END, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PresetComboBox::~PresetComboBox()
|
PresetComboBox::~PresetComboBox()
|
||||||
@ -186,19 +188,24 @@ void PresetComboBox::update_selection()
|
|||||||
SetSelection(m_last_selected);
|
SetSelection(m_last_selected);
|
||||||
SetToolTip(GetString(m_last_selected));
|
SetToolTip(GetString(m_last_selected));
|
||||||
|
|
||||||
GList* cells = gtk_cell_layout_get_cells( GTK_CELL_LAYOUT( m_widget ) );
|
// A workaround for a set of issues related to text fitting into gtk widgets:
|
||||||
if( !cells )
|
// See e.g.: https://github.com/prusa3d/PrusaSlicer/issues/4584
|
||||||
return;
|
#if defined(__WXGTK20__) || defined(__WXGTK3__)
|
||||||
|
GList* cells = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(m_widget));
|
||||||
|
|
||||||
GtkCellRendererText* cell = (GtkCellRendererText *) cells->next->data;
|
// 'cells' contains the GtkCellRendererPixBuf for the icon,
|
||||||
|
// 'cells->next' contains GtkCellRendererText for the text we need to ellipsize
|
||||||
|
if (!cells || !cells->next) return;
|
||||||
|
|
||||||
if( !cell )
|
auto cell = static_cast<GtkCellRendererText *>(cells->next->data);
|
||||||
return;
|
|
||||||
|
|
||||||
g_object_set( G_OBJECT( cell ), "ellipsize", PANGO_ELLIPSIZE_END, NULL );
|
if (!cell) return;
|
||||||
|
|
||||||
|
g_object_set(G_OBJECT(cell), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
||||||
|
|
||||||
// Only the list of cells must be freed, the renderer isn't ours to free
|
// Only the list of cells must be freed, the renderer isn't ours to free
|
||||||
g_list_free( cells );
|
g_list_free(cells);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PresetComboBox::update(std::string select_preset_name)
|
void PresetComboBox::update(std::string select_preset_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user