Increased iconview icon size to 64.

Increased iconview icon widths to correspond to 2 icons per row for default window size; the text
will less likely get wrapped in this case.
Changed bundled icons to size 64.
Fixed iconview icon blurriness with GDK_SCALE=2.
Use XDG-style icon names, as per GTK >= 3.10; fallback to old names and bundled icons if needed.
Removed all mention of .glade files from comments; don't use non-standard gnome names anymore.
Don't show empty "()" for drive letters in Linux.
Show "not mounted" for drive letters when no drive letters are present.
Added new "--gdk-scale" and "--gdk-dpi-scale" parameters, since pkexec discards user environment;
pass $GDK_SCALE and $GDK_DPI_SCALE to these from gsmartcontrol-root.
This commit is contained in:
Alexander Shaduri
2017-10-04 21:09:32 +00:00
parent a95be84eac
commit 6888d0862d
22 changed files with 161 additions and 93 deletions
+9
View File
@@ -1,3 +1,12 @@
Version 1.1.2, released on
Version 1.1.1, released on 2017-09-25
Windows: Use Adwaita GTK+ theme for systems which support Classic Windows
theme, since the default win32 GTK+ theme is broken in it; this
includes Windows 7 and Windows Server.
Statistics entry values are formatted with commas for readability.
Moved help information to website.
Version 1.1.0, released on 2017-09-07
New Statistics, Temperature Log, Error Recovery, Physical and Directory
tabs.
+2
View File
@@ -20,6 +20,8 @@ local scope destruction also works if using stack variables.
TODO:
Include hi-res icon_cddvd.png and icon_hdd.png.
Don't rely on smartctl return code (2), parse the output instead.
This will allow us to show the Info page.
+1 -1
View File
@@ -336,7 +336,7 @@ do # on separate line for portability
fi
if test "$RES_BASE_EXT" = "ui"; then
RES_LIBADD="$RES_LIBADD $RES_BASE_NOEXT.ui.$ac_objext" # file.ui.o or file.glade.o
RES_LIBADD="$RES_LIBADD $RES_BASE_NOEXT.ui.$ac_objext" # file.ui.o
RES_TARGETS="$RES_TARGETS
$RES_BASE_NOEXT.ui.cpp: $RES_FILE_CANON
\"\$(top_srcdir)/file2csource.sh\" \"$RES_FILE_CANON\" \"$RES_BASE_NOEXT.ui.cpp\" \"$RES_BASE_NOEXT\"_ui
+3 -3
View File
@@ -71,7 +71,7 @@ fi
# They're basically the same, only the order is different.
# pkexec is for PolKit
# pkexec is for PolKit.
# sux requires xterm to ask for the password.
# xdg-su is basically like this script, except worse :)
# su-to-root is a debian/ubuntu official method (although gksu is available).
@@ -102,7 +102,7 @@ if [ "$GSMARTCONTROL_SU" = "" ]; then
if [ "$found_su" = "" ]; then
xmessage "Error launching ${prog_name}: No suitable su mechanism found.
Try installing kdesu, gnomesu, gksu, beesu or sux first.";
Try installing PolKit, kdesu, gnomesu, gksu, beesu or sux first.";
exit 1;
fi
fi
@@ -138,7 +138,7 @@ if [ "$GSMARTCONTROL_SU" != "" ]; then
full_cmd="$GSMARTCONTROL_SU '$EXEC_BIN $final_args_quoted'";
elif [ "$found_su" = "pkexec" ]; then
full_cmd="pkexec --disable-internal-agent $EXEC_BIN $final_args_quoted";
full_cmd="pkexec --disable-internal-agent $EXEC_BIN $final_args_quoted --gdk-scale='$GDK_SCALE' --gdk-dpi-scale='$GDK_DPI_SCALE'";
elif [ "$found_su" = "sux" ]; then
full_cmd="xterm -e sux -c '$EXEC_BIN $final_args_quoted'";
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

+10 -11
View File
@@ -35,8 +35,7 @@
/// \def APP_UI_RES_DATA_INIT(res_name)
/// Use these in window class definitions to declare ui resources.
/// E.g. APP_UI_RES_DATA_INIT(main_window) will search for
/// main_window.glade or main_window.ui (depending on whether
/// you're using libglade or gtkbuilder) in data file search paths.
/// main_window.ui in data file search paths.
/// Or, if you're using compiled-in buffers, it will make them available.
#define APP_UI_RES_DATA_INIT(res_name) \
HZ_RES_DATA_INIT_NAMED(res_name##_ui, #res_name ".ui", UIResDataBase); \
@@ -91,10 +90,10 @@ inline bool app_ui_res_create_from(app_ui_res_ref_t& ref,
// These allow easy attaching of glade widget signals to member functions
// These allow easy attaching of gtkbuilder widget signals to member functions
/// Connect member function (callback) to signal \c signal_name on widget
/// \c ui_element, where \c ui_element is the widget's glade/gtkbuilder name.
/// \c ui_element, where \c ui_element is the widget's gtkbuilder name.
#define APP_UI_RES_CONNECT(ui_element, signal_name, callback) \
if (true) { \
if (!ui_element) \
@@ -107,7 +106,7 @@ inline bool app_ui_res_create_from(app_ui_res_ref_t& ref,
/// Connect member function (callback) with a name of \c on_<widget_name>_<signal_name>
/// to signal \c signal_name on widget \c ui_element, where \c ui_element is the
/// widget's glade/gtkbuilder name.
/// widget's gtkbuilder name.
#define APP_UI_RES_AUTO_CONNECT(ui_element, signal_name) \
APP_UI_RES_CONNECT(ui_element, signal_name, on_ ## ui_element ## _ ## signal_name)
@@ -115,7 +114,7 @@ inline bool app_ui_res_create_from(app_ui_res_ref_t& ref,
/// Inherit this when using Glade-enabled windows (or any other glade-enabled objects).
/// Inherit this when using GtkBuilder-enabled windows (or any other GtkBuilder-enabled objects).
/// \c Child is the child class that inherits all the functionality of having instance lifetime
/// management and other benefits.
/// If \c MultiInstance is false, create() will return the same instance each time.
@@ -137,7 +136,7 @@ class AppUIResWidget : public WidgetType, public hz::InstanceManager<Child, Mult
std::string error;
app_ui_res_ref_t ui = Gtk::Builder::create();
const typename Child::UIResData data; // this holds the glade data
const typename Child::UIResData data; // this holds the GtkBuilder data
// this does the actual object construction
bool success = app_ui_res_create_from(ui, data.buf, data.size, error);
@@ -226,13 +225,13 @@ class AppUIResWidget : public WidgetType, public hz::InstanceManager<Child, Mult
protected:
typedef Child self_type; ///< This is needed by APP_GLADE_ macros
typedef WidgetType widget_type; ///< This is needed by APP_GLADE_ macros
typedef Child self_type; ///< This is needed by APP_UI_ macros
typedef WidgetType widget_type; ///< This is needed by APP_UI_ macros
// protected constructor / destructor, use create() / destroy() instead of new / delete.
/// Glade needs this constructor in a child.
/// GtkBuilder needs this constructor in a child.
/// BaseObjectType is a C type, defined in specific Gtk:: widget class.
AppUIResWidget(typename WidgetType::BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui)
: WidgetType(gtkcobj), ref_ui_(ref_ui)
@@ -240,7 +239,7 @@ class AppUIResWidget : public WidgetType, public hz::InstanceManager<Child, Mult
// manually connecting signals:
// this->signal_delete_event().connect(sigc::mem_fun(*this, &MainWindow::on_main_window_delete));
// signals of glade-created objects:
// signals of GtkBuilder-created objects:
// Gtk::ToolButton* rescan_devices_toolbutton = 0;
// APP_UI_RES_AUTO_CONNECT(rescan_devices_toolbutton, clicked);
@@ -26,7 +26,7 @@ class AppUiResTestWindow : public AppUIResWidget<AppUiResTestWindow, false>
{
public:
// name of glade/ui file without a .glade/.ui extension and quotes
// name of ui file without a .ui extension and quotes
APP_UI_RES_DATA_INIT(app_ui_res_test_window);
+1 -1
View File
@@ -23,7 +23,7 @@
// glade/gtkbuilder needs this constructor
// GtkBuilder needs this constructor
GscAboutDialog::GscAboutDialog(BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui)
: AppUIResWidget<GscAboutDialog, false, Gtk::AboutDialog>(gtkcobj, ref_ui)
{
+2 -2
View File
@@ -24,7 +24,7 @@
class GscAboutDialog : public AppUIResWidget<GscAboutDialog, false, Gtk::AboutDialog> {
public:
// name of glade/ui file without a .glade/.ui extension and quotes
// name of ui file without a .ui extension and quotes
APP_UI_RES_DATA_INIT(gsc_about_dialog);
// we need the license file to show it.
@@ -35,7 +35,7 @@ class GscAboutDialog : public AppUIResWidget<GscAboutDialog, false, Gtk::AboutDi
HZ_RES_DATA_INIT_NAMED(AUTHORS_txt, "AUTHORS.txt", AuthorsTextResData);
/// Constructor, gtkbuilder/glade needs this.
/// Constructor, GtkBuilder needs this.
GscAboutDialog(BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui);
/// Virtual destructor
+2 -2
View File
@@ -26,11 +26,11 @@ class GscMainWindow;
class GscAddDeviceWindow : public AppUIResWidget<GscAddDeviceWindow, true> {
public:
// name of glade/ui file without a .glade/.ui extension and quotes
// name of ui file without a .ui extension and quotes
APP_UI_RES_DATA_INIT(gsc_add_device_window);
/// Constructor, gtkbuilder/glade needs this.
/// Constructor, GtkBuilder needs this.
GscAddDeviceWindow(BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui);
/// Virtual destructor
+2 -2
View File
@@ -27,11 +27,11 @@
class GscExecutorLogWindow : public AppUIResWidget<GscExecutorLogWindow, false> {
public:
// name of glade/ui file without a .glade/.ui extension and quotes
// name of ui file without a .ui extension and quotes
APP_UI_RES_DATA_INIT(gsc_executor_log_window);
/// Constructor, gtkbuilder/glade needs this.
/// Constructor, GtkBuilder needs this.
GscExecutorLogWindow(BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui);
/// Virtual destructor
+2 -2
View File
@@ -27,11 +27,11 @@
class GscInfoWindow : public AppUIResWidget<GscInfoWindow, true> {
public:
// name of glade/ui file without a .glade/.ui extension and quotes
// name of ui file without a .ui extension and quotes
APP_UI_RES_DATA_INIT(gsc_info_window);
/// Constructor, gtkbuilder/glade needs this.
/// Constructor, GtkBuilder needs this.
GscInfoWindow(BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui);
/// Virtual destructor
+26 -4
View File
@@ -210,7 +210,9 @@ namespace {
arg_scan(TRUE),
arg_hide_tabs(TRUE),
arg_add_virtual(NULL),
arg_add_device(NULL)
arg_add_device(NULL),
arg_gdk_scale(-1),
arg_gdk_dpi_scale(-1)
{ }
// Note: Use GLib types here:
@@ -220,6 +222,8 @@ namespace {
gboolean arg_hide_tabs; ///< if true, hide additional info tabs when smart is disabled. false may help debugging.
gchar** arg_add_virtual; ///< load smartctl data from these files as virtual drives
gchar** arg_add_device; ///< add these device files manually
gint arg_gdk_scale; ///< The value of GDK_SCALE environment variable
gint arg_gdk_dpi_scale; ///< The value of GDK_DPI_SCALE environment variable
};
@@ -243,6 +247,13 @@ namespace {
"Add this device to device list. The format of the device is \"<device>::<type>::<extra_args>\", where type and extra_args are optional."
" This option is useful with --no-scan to list certain drives only. You can specify this option multiple times."
" Example: --add-device /dev/sda --add-device /dev/twa0::3ware,2 --add-device '/dev/sdb::::-T permissive'", NULL },
#ifndef _WIN32
// X11-specific
{ "gdk-scale", 'l', 0, G_OPTION_ARG_INT, &(args.arg_gdk_scale),
"The value of GDK_SCALE environment variable (useful when executing with pkexec)", NULL },
{ "gdk-dpi-scale", 'l', 0, G_OPTION_ARG_INT, &(args.arg_gdk_dpi_scale),
"The value of GDK_DPI_SCALE environment variable (useful when executing with pkexec)", NULL },
#endif
{ NULL }
};
@@ -386,10 +397,21 @@ bool app_init_and_loop(int& argc, char**& argv)
<< "\thide_tabs: " << args.arg_hide_tabs << "\n"
<< "\tscan: " << args.arg_scan << "\n"
<< "\targ_add_virtual: " << (load_virtuals_str.empty() ? "[empty]" : load_virtuals_str) << "\n"
<< "\targ_add_device: " << (load_devices_str.empty() ? "[empty]" : load_devices_str) << "\n");
<< "\targ_add_device: " << (load_devices_str.empty() ? "[empty]" : load_devices_str) << "\n"
<< "\targ_gdk_scale: " << args.arg_gdk_scale << "\n"
<< "\targ_gdk_dpi_scale: " << args.arg_gdk_dpi_scale << "\n");
debug_out_dump("app", "LibDebug options:\n" << debug_get_cmd_args_dump());
#ifndef _WIN32
if (args.arg_gdk_scale > 0) {
hz::env_set_value("GDK_SCALE", hz::number_to_string(args.arg_gdk_scale));
}
if (args.arg_gdk_dpi_scale > 0) {
hz::env_set_value("GDK_DPI_SCALE", hz::number_to_string(args.arg_gdk_dpi_scale));
}
#endif
// Load config files
app_init_config();
@@ -400,8 +422,8 @@ bool app_init_and_loop(int& argc, char**& argv)
static const char* const gtkdomains[] = {
// no atk or cairo, they don't log. libgnomevfs may be loaded by gtk file chooser.
"GLib", "GModule", "GLib-GObject", "GLib-GRegex", "GLib-GIO", "GThread",
"Pango", "Gtk", "Gdk", "GdkPixbuf", "libglade", "libgnomevfs",
"glibmm", "giomm", "atkmm", "pangomm", "gdkmm", "gtkmm", "libglademm" };
"Pango", "Gtk", "Gdk", "GdkPixbuf", "libgnomevfs",
"glibmm", "giomm", "atkmm", "pangomm", "gdkmm", "gtkmm" };
for (unsigned int i = 0; i < G_N_ELEMENTS(gtkdomains); ++i) {
g_log_set_handler(gtkdomains[i], GLogLevelFlags(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
+2 -2
View File
@@ -34,11 +34,11 @@ class GscMainWindow : public AppUIResWidget<GscMainWindow, false> {
friend class GscMainWindowIconView; // It needs our privates
// name of glade/ui file without a .glade/.ui extension and quotes
// name of ui file without a .ui extension and quotes
APP_UI_RES_DATA_INIT(gsc_main_window);
/// Constructor, gtkbuilder/glade needs this.
/// Constructor, GtkBuilder needs this.
GscMainWindow(BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui);
/// Virtual destructor
+85 -49
View File
@@ -29,7 +29,7 @@
/// The icon view of the main window (shows a drive list).
/// Note: The IconView must have a fixed icon width set (e.g. in glade file).
/// Note: The IconView must have a fixed icon width set (e.g. in .ui file).
/// Otherwise, it doesn't re-compute it when clearing and adding new icons.
class GscMainWindowIconView : public Gtk::IconView {
public:
@@ -47,7 +47,7 @@ class GscMainWindowIconView : public Gtk::IconView {
};
/// Constructor, gtkbuilder/glade needs this.
/// Constructor, GtkBuilder needs this.
GscMainWindowIconView(BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui)
: Gtk::IconView(gtkcobj), num_icons(0), main_window(0), empty_view_message(message_none)
{
@@ -57,7 +57,15 @@ class GscMainWindowIconView : public Gtk::IconView {
columns.add(col_description);
columns.add(col_pixbuf);
#if GTK_CHECK_VERSION(3, 10, 0)
// For high quality rendering with GDK_SCALE=2
this->pack_start(cell_renderer_pixbuf, false);
this->set_cell_data_func(cell_renderer_pixbuf,
sigc::mem_fun(this, &GscMainWindowIconView::on_cell_data_render));
#else
this->set_pixbuf_column(col_pixbuf);
#endif
columns.add(col_drive_ptr);
@@ -78,18 +86,14 @@ class GscMainWindowIconView : public Gtk::IconView {
// nothing
}
// Try Gnome icons icons first, they are usually more consistent with Gnome desktop
// (this should work only if gnome-settings-daemon is running, so no harm on other desktops).
// The problem with stock gtk icons is that they are not available in 48x48 size, so
// confirm all sizes manually.
if (app_gtkmm_icon_theme_has_icon(default_icon_theme, "gnome-dev-harddisk", 48))
hd_icon = default_icon_theme->load_icon("gnome-dev-harddisk", 48, Gtk::IconLookupFlags(0));
if (!hd_icon && app_gtkmm_icon_theme_has_icon(default_icon_theme, "gtk-harddisk", 48))
hd_icon = default_icon_theme->load_icon("gtk-harddisk", 48, Gtk::IconLookupFlags(0));
if (!hd_icon) { // still no luck, use bundled ones.
// Try XDG version first
hd_icon = default_icon_theme->load_icon("drive-harddisk", 64, get_scale_factor(), Gtk::IconLookupFlags(0));
if (!hd_icon) {
// Before gtk 3.10 it was called gtk-harddisk.
hd_icon = default_icon_theme->load_icon("gtk-harddisk", 64, get_scale_factor(), Gtk::IconLookupFlags(0));
}
if (!hd_icon) {
// Still no luck, use bundled ones.
std::string icon_file = hz::data_file_find("icon_hdd.png");
if (!icon_file.empty()) {
try {
@@ -98,18 +102,14 @@ class GscMainWindowIconView : public Gtk::IconView {
}
}
// last resort. gtk has gtk-harddisk built-in. it may not be the right size, but what else can we do?
if (!hd_icon && default_icon_theme)
hd_icon = default_icon_theme->load_icon("gtk-harddisk", 48, Gtk::IconLookupFlags(0));
if (app_gtkmm_icon_theme_has_icon(default_icon_theme, "gnome-dev-cdrom", 48))
cddvd_icon = default_icon_theme->load_icon("gnome-dev-cdrom", 48, Gtk::IconLookupFlags(0));
if (!cddvd_icon && app_gtkmm_icon_theme_has_icon(default_icon_theme, "gtk-cdrom", 48))
cddvd_icon = default_icon_theme->load_icon("gtk-cdrom", 48, Gtk::IconLookupFlags(0));
if (!cddvd_icon) { // still no luck, use bundled ones.
// Try XDG version first
cddvd_icon = default_icon_theme->load_icon("media-optical", 64, get_scale_factor(), Gtk::IconLookupFlags(0));
if (!cddvd_icon) {
// Before gtk 3.10 it was called gtk-cdrom.
cddvd_icon = default_icon_theme->load_icon("gtk-cdrom", 64, get_scale_factor(), Gtk::IconLookupFlags(0));
}
if (!cddvd_icon) {
// Still no luck, use bundled ones.
std::string icon_file = hz::data_file_find("icon_cddvd.png");
if (!icon_file.empty()) {
try {
@@ -118,10 +118,6 @@ class GscMainWindowIconView : public Gtk::IconView {
}
}
if (!cddvd_icon && default_icon_theme)
cddvd_icon = default_icon_theme->load_icon("gtk-cdrom", 48, Gtk::IconLookupFlags(0));
this->signal_item_activated().connect(sigc::mem_fun(*this,
&self_type::on_iconview_item_activated) );
@@ -189,6 +185,35 @@ class GscMainWindowIconView : public Gtk::IconView {
#if GTK_CHECK_VERSION(3, 10, 0)
/// Cell data renderer (needed for high quality icons in GDK_SCALE=2).
/// We have to use Cairo surfaces, because pixbufs are scaled by GtkIconView.
void on_cell_data_render(const Gtk::TreeModel::const_iterator& iter)
{
Gtk::TreeRow row = *iter;
Glib::RefPtr<Gdk::Pixbuf> pixbuf = row[col_pixbuf];
// Gtkmm property_surface() doesn't work, so use plain C.
// https://bugzilla.gnome.org/show_bug.cgi?id=788513
// Also, Gtkmm doesn't have gdk_cairo_surface_create_from_pixbuf() wrapper.
// https://bugzilla.gnome.org/show_bug.cgi?id=788533
// Cairo::Format format = Cairo::FORMAT_ARGB32;
// if (pixbuf->get_n_channels() == 3) {
// format = Cairo::FORMAT_RGB24;
// }
// Cairo::RefPtr<Cairo::Surface> surface = get_window()->create_similar_image_surface(
// format, pixbuf->get_width(), pixbuf->get_height(), get_scale_factor());
// cell_renderer_pixbuf.property_surface().set_value(surface);
// gdk_cairo_surface_create_from_pixbuf() (and create_similar_image_surface()) from gtk 3.10.
cairo_surface_t* surface = gdk_cairo_surface_create_from_pixbuf(pixbuf->gobj(), get_scale_factor(), get_window()->gobj());
g_object_set(G_OBJECT(cell_renderer_pixbuf.gobj()), "surface", surface, NULL);
cairo_surface_destroy(surface);
}
#endif
/// Add a drive entry to the icon view
void add_entry(StorageDeviceRefPtr drive, bool scroll_to_it = false)
{
@@ -241,13 +266,19 @@ class GscMainWindowIconView : public Gtk::IconView {
// it needs this space to be symmetric (why?);
std::string name; // = "<big>" + drive->get_device_with_type() + " </big>\n";
Glib::ustring drive_letters = Glib::Markup::escape_text(drive->format_drive_letters());
if (drive_letters.empty()) {
drive_letters = "not mounted";
}
// note: if this wraps, it becomes left-aligned in gtk <= 2.10.
name += (drive->get_model_name().empty() ? Glib::ustring("Unknown model") : Glib::Markup::escape_text(drive->get_model_name()));
if (rconfig::get_data<bool>("gui/icons_show_device_name")) {
if (!drive->get_is_virtual()) {
name += "\n" + Glib::Markup::escape_text(drive->get_device_with_type());
name += " (" + Glib::Markup::escape_text(drive->format_drive_letters()) + ")";
#ifdef _WIN32
name += " (" + drive_letters + ")";
#endif
} else if (!drive->get_virtual_filename().empty()) {
name += "\n" + Glib::Markup::escape_text(drive->get_virtual_filename());
}
@@ -274,9 +305,11 @@ class GscMainWindowIconView : public Gtk::IconView {
} else {
tooltip_strs.push_back("Device: <b>" + Glib::Markup::escape_text(drive->get_device_with_type()) + "</b>");
}
if (!drive->format_drive_letters().empty()) {
tooltip_strs.push_back("Drive letters: <b>" + Glib::Markup::escape_text(drive->format_drive_letters()) + "</b>");
}
#ifdef _WIN32
tooltip_strs.push_back("Drive letters: <b>" + drive_letters + "</b>");
#endif
if (!drive->get_serial_number().empty()) {
tooltip_strs.push_back("Serial number: <b>" + Glib::Markup::escape_text(drive->get_serial_number()) + "</b>");
}
@@ -302,22 +335,24 @@ class GscMainWindowIconView : public Gtk::IconView {
StorageProperty health_prop = drive->get_health_property();
if (health_prop.warning != StorageProperty::warning_none && health_prop.generic_name == "overall_health") {
icon = icon->copy(); // work on a copy
if (icon->get_colorspace() == Gdk::COLORSPACE_RGB && icon->get_bits_per_sample() == 8) {
int n_channels = icon->get_n_channels();
int icon_width = icon->get_width();
int icon_height = icon->get_height();
int rowstride = icon->get_rowstride();
guint8* pixels = icon->get_pixels();
if (icon) {
icon = icon->copy(); // work on a copy
if (icon->get_colorspace() == Gdk::COLORSPACE_RGB && icon->get_bits_per_sample() == 8) {
int n_channels = icon->get_n_channels();
int icon_width = icon->get_width();
int icon_height = icon->get_height();
int rowstride = icon->get_rowstride();
guint8* pixels = icon->get_pixels();
guint8* p = 0;
for (int y = 0; y < icon_height; ++y) {
for (int x = 0; x < icon_width; ++x) {
p = pixels + y * rowstride + x * n_channels;
uint8_t avg = static_cast<uint8_t>(std::floor((p[0] * 0.30) + (p[1] * 0.59) + (p[2] * 0.11) + 0.001 + 0.5));
p[0] = avg; // R
p[1] = 0; // G
p[2] = 0; // B
guint8* p = 0;
for (int y = 0; y < icon_height; ++y) {
for (int x = 0; x < icon_width; ++x) {
p = pixels + y * rowstride + x * n_channels;
uint8_t avg = static_cast<uint8_t>(std::floor((p[0] * 0.30) + (p[1] * 0.59) + (p[2] * 0.11) + 0.001 + 0.5));
p[0] = avg; // R
p[1] = 0; // G
p[2] = 0; // B
}
}
}
}
@@ -507,6 +542,7 @@ class GscMainWindowIconView : public Gtk::IconView {
private:
Gtk::TreeModel::ColumnRecord columns; ///< Model columns
Gtk::CellRendererPixbuf cell_renderer_pixbuf; ///< Cell renderer for icons.
Gtk::TreeModelColumn<std::string> col_name; ///< Model column
Gtk::TreeModelColumn<Glib::ustring> col_description; ///< Model column
+1 -1
View File
@@ -33,7 +33,7 @@ class GscPreferencesDeviceOptionsTreeView : public Gtk::TreeView {
typedef GscPreferencesDeviceOptionsTreeView self_type; ///< Self type, needed for CONNECT_VIRTUAL
/// Constructor, gtkbuilder/glade needs this.
/// Constructor, GtkBuilder needs this.
GscPreferencesDeviceOptionsTreeView(BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui)
: Gtk::TreeView(gtkcobj), preferences_window(0)
{
+2 -2
View File
@@ -29,11 +29,11 @@ class GscMainWindow; // declared in gsc_main_window.h
class GscPreferencesWindow : public AppUIResWidget<GscPreferencesWindow, true> {
public:
// name of glade/ui file without a .glade/.ui extension and quotes
// name of ui file without a .ui extension and quotes
APP_UI_RES_DATA_INIT(gsc_preferences_window);
/// Constructor, gtkbuilder/glade needs this.
/// Constructor, GtkBuilder needs this.
GscPreferencesWindow(BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui);
/// Virtual destructor
+3 -3
View File
@@ -38,14 +38,14 @@ template<class InstanceSwitch>
class GscTextWindow : public AppUIResWidget<GscTextWindow<InstanceSwitch>, InstanceSwitch::multi_instance> {
public:
// name of glade/ui file without a .glade/.ui extension and quotes
// name of ui file without a .ui extension and quotes
APP_UI_RES_DATA_INIT(gsc_text_window);
/// Self type, needed for glade, not inherited from parent because of templates
/// Self type, needed for GtkBuilder, not inherited from parent because of templates
typedef GscTextWindow<InstanceSwitch> self_type;
/// Constructor, gtkbuilder/glade needs this.
/// Constructor, GtkBuilder needs this.
GscTextWindow(typename Gtk::Window::BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui)
: AppUIResWidget<GscTextWindow<InstanceSwitch>, InstanceSwitch::multi_instance>(gtkcobj, ref_ui)
{
+1 -1
View File
@@ -34,7 +34,7 @@ Configuration macros: HZ_ENABLE_COMPILED_RES_DATA (0 | 1).
// Compiled-in buffers:
/// Declare that we have a binary chunk res_name.
/// (You may use this e.g. with glade xml contents, putting it into your window class).
/// (You may use this e.g. with GtkBuilder xml contents, putting it into your window class).
#define HZ_RES_DATA_COMPILED_INIT_NAMED(res_name, dummy, class_name) \
struct class_name { \
class_name() \
+4 -4
View File
@@ -1,9 +1,9 @@
# Disable implicit suffix rules for these extensions.
# The problem is that make sees the .glade.cpp or .ui.cpp files
# with their .glade prerequisites, and decides to rebuild the
# (already existing) .glade files by using .glade.cpp files.
# Implicit rules are to blame, so disable them for .glade.
# The problem is that make sees the .ui.cpp files
# with their .ui prerequisites, and decides to rebuild the
# (already existing) .ui files by using .ui.cpp files.
# Implicit rules are to blame, so disable them for .ui.
SUFFIXES = .ui .txt
AM_CPPFLAGS =
+2 -2
View File
@@ -136,9 +136,9 @@
<property name="is_focus">True</property>
<property name="events">GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="margin">10</property>
<property name="item_width">130</property>
<property name="item_width">250</property>
<property name="spacing">3</property>
<property name="row_spacing">8</property>
<property name="row_spacing">20</property>
<property name="column_spacing">5</property>
</object>
</child>