mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-31 19:51:52 +02:00
Update to v098r10 release.
byuu says: Changelog: - synchronized tomoko, loki, icarus with extensive changes to nall (118KiB diff)
This commit is contained in:
@@ -6,7 +6,7 @@ static auto BrowserWindow_addFilters(GtkWidget* dialog, lstring filters) -> void
|
||||
for(auto& filter : filters) {
|
||||
GtkFileFilter* gtkFilter = gtk_file_filter_new();
|
||||
gtk_file_filter_set_name(gtkFilter, filter);
|
||||
lstring patterns = filter.split("(", 1L)(1).rtrim(")", 1L).split(",").strip();
|
||||
lstring patterns = filter.split("(", 1L)(1).trimRight(")", 1L).split(",").strip();
|
||||
for(auto& pattern : patterns) gtk_file_filter_add_pattern(gtkFilter, pattern);
|
||||
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), gtkFilter);
|
||||
}
|
||||
|
@@ -35,6 +35,8 @@
|
||||
#include "widget/check-label.cpp"
|
||||
#include "widget/combo-button.cpp"
|
||||
#include "widget/combo-button-item.cpp"
|
||||
#include "widget/combo-edit.cpp"
|
||||
#include "widget/combo-edit-item.cpp"
|
||||
#include "widget/console.cpp"
|
||||
#include "widget/frame.cpp"
|
||||
#include "widget/hex-edit.cpp"
|
||||
|
@@ -46,6 +46,8 @@ namespace hiro {
|
||||
#include "widget/check-label.hpp"
|
||||
#include "widget/combo-button.hpp"
|
||||
#include "widget/combo-button-item.hpp"
|
||||
#include "widget/combo-edit.hpp"
|
||||
#include "widget/combo-edit-item.hpp"
|
||||
#include "widget/console.hpp"
|
||||
#include "widget/frame.hpp"
|
||||
#include "widget/hex-edit.hpp"
|
||||
|
@@ -13,12 +13,12 @@ Settings::Settings() {
|
||||
}
|
||||
|
||||
auto Settings::load() -> void {
|
||||
string path = {configpath(), "hiro/"};
|
||||
string path = {Path::config(), "hiro/"};
|
||||
Configuration::Document::load({path, "gtk.bml"});
|
||||
}
|
||||
|
||||
auto Settings::save() -> void {
|
||||
string path = {configpath(), "hiro/"};
|
||||
string path = {Path::config(), "hiro/"};
|
||||
directory::create(path, 0755);
|
||||
Configuration::Document::save({path, "gtk.bml"});
|
||||
}
|
||||
|
@@ -10,7 +10,6 @@ auto pComboButtonItem::destruct() -> void {
|
||||
|
||||
auto pComboButtonItem::setIcon(const image& icon) -> void {
|
||||
if(auto parent = _parent()) {
|
||||
auto size = pFont::size(self().font(true), " ").height();
|
||||
auto pixbuf = CreatePixbuf(icon, true);
|
||||
gtk_list_store_set(parent->gtkListStore, >kIter, 0, pixbuf, -1);
|
||||
}
|
||||
|
33
hiro/gtk/widget/combo-edit-item.cpp
Normal file
33
hiro/gtk/widget/combo-edit-item.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#if defined(Hiro_ComboEdit)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
auto pComboEditItem::construct() -> void {
|
||||
}
|
||||
|
||||
auto pComboEditItem::destruct() -> void {
|
||||
}
|
||||
|
||||
auto pComboEditItem::setIcon(const image& icon) -> void {
|
||||
if(auto parent = _parent()) {
|
||||
auto pixbuf = CreatePixbuf(icon, true);
|
||||
gtk_list_store_set(parent->gtkListStore, >kIter, 0, pixbuf, -1);
|
||||
}
|
||||
}
|
||||
|
||||
auto pComboEditItem::setText(const string& text) -> void {
|
||||
if(auto parent = _parent()) {
|
||||
gtk_list_store_set(parent->gtkListStore, >kIter, 1, text.data(), -1);
|
||||
}
|
||||
}
|
||||
|
||||
auto pComboEditItem::_parent() -> maybe<pComboEdit&> {
|
||||
if(auto parent = self().parentComboEdit()) {
|
||||
if(auto self = parent->self()) return *self;
|
||||
}
|
||||
return nothing;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
18
hiro/gtk/widget/combo-edit-item.hpp
Normal file
18
hiro/gtk/widget/combo-edit-item.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#if defined(Hiro_ComboEdit)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
struct pComboEditItem : pObject {
|
||||
Declare(ComboEditItem, Object)
|
||||
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
auto _parent() -> maybe<pComboEdit&>;
|
||||
|
||||
GtkTreeIter gtkIter;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
115
hiro/gtk/widget/combo-edit.cpp
Normal file
115
hiro/gtk/widget/combo-edit.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
#if defined(Hiro_ComboEdit)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
static auto ComboEdit_activate(GtkComboBox* comboBox, pComboEdit* p) -> void { p->self().doActivate(); }
|
||||
static auto ComboEdit_change(GtkComboBox* comboBox, pComboEdit* p) -> void { p->_updateText(); }
|
||||
|
||||
auto pComboEdit::construct() -> void {
|
||||
gtkListStore = gtk_list_store_new(2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
|
||||
gtkTreeModel = GTK_TREE_MODEL(gtkListStore);
|
||||
gtkWidget = gtk_combo_box_new_with_model_and_entry(gtkTreeModel);
|
||||
gtkComboBox = GTK_COMBO_BOX(gtkWidget);
|
||||
|
||||
gtk_cell_layout_clear(GTK_CELL_LAYOUT(gtkWidget));
|
||||
gtkCellIcon = gtk_cell_renderer_pixbuf_new();
|
||||
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(gtkWidget), gtkCellIcon, false);
|
||||
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(gtkWidget), gtkCellIcon, "pixbuf", 0, nullptr);
|
||||
gtkCellText = gtk_cell_renderer_text_new();
|
||||
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(gtkWidget), gtkCellText, true);
|
||||
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(gtkWidget), gtkCellText, "text", 1, nullptr);
|
||||
|
||||
//we must call gtk_combo_box_set_entry_text_column(1) in order for GtkComboBoxEntry to pull text
|
||||
//however, this API call throws a Gtk-CRITICAL assertion that column 1 is not a cell renderer
|
||||
//this is, however, incorrect. it *is* a renderer, and the API call works as expected
|
||||
//so in order to suppress the error message, we redirect stderr to /dev/null temporarily
|
||||
int stdErr = dup(STDERR_FILENO);
|
||||
int devNull = open("/dev/null", 0);
|
||||
dup2(devNull, STDERR_FILENO);
|
||||
gtk_combo_box_set_entry_text_column(gtkComboBox, 1);
|
||||
dup2(stdErr, STDERR_FILENO);
|
||||
close(devNull);
|
||||
close(stdErr);
|
||||
|
||||
setBackgroundColor(state().backgroundColor);
|
||||
setForegroundColor(state().foregroundColor);
|
||||
for(auto& item : state().items) append(item);
|
||||
|
||||
g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN(gtkComboBox))), "activate", G_CALLBACK(ComboEdit_activate), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(gtkWidget), "changed", G_CALLBACK(ComboEdit_change), (gpointer)this);
|
||||
|
||||
pWidget::construct();
|
||||
}
|
||||
|
||||
auto pComboEdit::destruct() -> void {
|
||||
gtk_widget_destroy(gtkWidget);
|
||||
}
|
||||
|
||||
auto pComboEdit::append(sComboEditItem item) -> void {
|
||||
lock();
|
||||
if(auto self = item->self()) {
|
||||
gtk_list_store_append(gtkListStore, &self->gtkIter);
|
||||
self->setIcon(item->state.icon);
|
||||
self->setText(item->state.text);
|
||||
}
|
||||
unlock();
|
||||
}
|
||||
|
||||
auto pComboEdit::minimumSize() const -> Size {
|
||||
auto font = self().font(true);
|
||||
int maximumWidth = 0;
|
||||
for(auto& item : state().items) {
|
||||
maximumWidth = max(maximumWidth,
|
||||
(item->state.icon ? pFont::size(font, " ").height() + 2 : 0)
|
||||
+ pFont::size(font, item->state.text).width()
|
||||
);
|
||||
}
|
||||
return {maximumWidth + 40, pFont::size(font, " ").height() + 12};
|
||||
}
|
||||
|
||||
auto pComboEdit::remove(sComboEditItem item) -> void {
|
||||
lock();
|
||||
if(auto delegate = item->self()) {
|
||||
gtk_list_store_remove(gtkListStore, &delegate->gtkIter);
|
||||
}
|
||||
unlock();
|
||||
}
|
||||
|
||||
auto pComboEdit::reset() -> void {
|
||||
lock();
|
||||
gtk_list_store_clear(gtkListStore);
|
||||
unlock();
|
||||
}
|
||||
|
||||
auto pComboEdit::setBackgroundColor(Color color) -> void {
|
||||
GdkColor gdkColor = CreateColor(color);
|
||||
gtk_widget_modify_base(gtk_bin_get_child(GTK_BIN(gtkComboBox)), GTK_STATE_NORMAL, color ? &gdkColor : nullptr);
|
||||
}
|
||||
|
||||
auto pComboEdit::setForegroundColor(Color color) -> void {
|
||||
GdkColor gdkColor = CreateColor(color);
|
||||
gtk_widget_modify_text(gtk_bin_get_child(GTK_BIN(gtkComboBox)), GTK_STATE_NORMAL, color ? &gdkColor : nullptr);
|
||||
}
|
||||
|
||||
auto pComboEdit::setFont(const Font& font) -> void {
|
||||
pWidget::setFont(font);
|
||||
auto fontDescription = pFont::create(font);
|
||||
g_object_set(G_OBJECT(gtkCellText), "font-desc", fontDescription, nullptr);
|
||||
}
|
||||
|
||||
auto pComboEdit::setText(const string& text) -> void {
|
||||
lock();
|
||||
gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(gtkComboBox))), text);
|
||||
unlock();
|
||||
}
|
||||
|
||||
auto pComboEdit::_updateText() -> void {
|
||||
string text = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(gtkComboBox))));
|
||||
if(text == state().text) return;
|
||||
state().text = text;
|
||||
if(!locked()) self().doChange();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
28
hiro/gtk/widget/combo-edit.hpp
Normal file
28
hiro/gtk/widget/combo-edit.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#if defined(Hiro_ComboEdit)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
struct pComboEdit : pWidget {
|
||||
Declare(ComboEdit, Widget)
|
||||
|
||||
auto append(sComboEditItem item) -> void;
|
||||
auto minimumSize() const -> Size override;
|
||||
auto remove(sComboEditItem item) -> void;
|
||||
auto reset() -> void;
|
||||
auto setBackgroundColor(Color color) -> void;
|
||||
auto setForegroundColor(Color color) -> void;
|
||||
auto setFont(const Font& font) -> void override;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
auto _updateText() -> void;
|
||||
|
||||
GtkListStore* gtkListStore = nullptr;
|
||||
GtkTreeModel* gtkTreeModel = nullptr;
|
||||
GtkComboBox* gtkComboBox = nullptr;
|
||||
GtkCellRenderer* gtkCellIcon = nullptr;
|
||||
GtkCellRenderer* gtkCellText = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@@ -136,7 +136,7 @@ auto pWindow::construct() -> void {
|
||||
|
||||
//if program was given a name, try and set the window taskbar icon from one of the pixmaps folders
|
||||
if(!Application::state.name);
|
||||
else if(_setIcon({userpath(), ".local/share/icons/"}));
|
||||
else if(_setIcon({Path::user(), ".local/share/icons/"}));
|
||||
else if(_setIcon("/usr/local/share/pixmaps/"));
|
||||
else if(_setIcon("/usr/share/pixmaps/"));
|
||||
|
||||
|
Reference in New Issue
Block a user