static void trade_format_maritime(const QuoteInfo * quote, gchar * desc) { /* trade: maritime quote: %1 resources of type %2 for * one resource of type %3 */ sprintf(desc, _("%d:1 %s for %s"), quote->var.m.ratio, resource_name(quote->var.m.supply, FALSE), resource_name(quote->var.m.receive, FALSE)); }
/** \brief return an icon from given name If the current theme has an icon corresponding to the given name, that it selected otherwise it loads DATA_DIR/img/name.svg */ QIcon icon ( QString name ) { if ( QIcon::hasThemeIcon(name) ) // check theme first return QIcon::fromTheme(name); QString image = resource_name( DATA_DIR, "img/"+name+".svg"); return image.isEmpty() ? QIcon() : QIcon( image ); }
uint16_t M2MFirmware::per_resource_count(FirmwareResource res) const { uint16_t count = 0; if(_firmware_instance) { count = _firmware_instance->resource_count(resource_name(res)); } return count; }
uint16_t M2MDevice::per_resource_count(DeviceResource res) const { uint16_t count = 0; if(_device_instance) { count = _device_instance->resource_count(resource_name(res)); } return count; }
bool M2MFirmware::delete_resource(FirmwareResource resource) { bool success = false; if(M2MFirmware::UpdateSupportedObjects == resource || M2MFirmware::PackageName == resource || M2MFirmware::PackageVersion == resource) { if(_firmware_instance) { success = _firmware_instance->remove_resource(resource_name(resource)); } } return success; }
bool M2MDevice::delete_resource(DeviceResource resource) { bool success = false; if(M2MDevice::Reboot != resource && M2MDevice::ErrorCode != resource && M2MDevice::SupportedBindingMode != resource) { if(_device_instance) { success = _device_instance->remove_resource(resource_name(resource)); } } return success; }
void TextureManager::addResource(TextureResource* r) { if(r->resource_name.empty()) { char res_name[256]; snprintf(res_name, 256, "__texture_resource_%d", ++resource_seq); std::string resource_name(res_name); r->setResourceName(resource_name); } resources[r->resource_name] = r; r->addref(); }
/** \brief Conditionally load Tango icons If Tango is disabled, this function does nothing. If Tango is used as fall back theme, the system theme is queried with the "document-new" icon, if that is not present, Tango is loaded. If Tango is used as default theme, it's loaded directly. */ void initialize_icon_theme() { #ifdef TANGO_FALLBACK if ( !QIcon::hasThemeIcon("document-new") ) { QIcon::setThemeSearchPaths( QIcon::themeSearchPaths() << resource_url(DATA_DIR,"themes").toString() ); QIcon::setThemeName("tango-icons"); } #elif defined(TANGO_DEFAULT) QIcon::setThemeSearchPaths( QStringList() << resource_name(DATA_DIR,"themes") ); QIcon::setThemeName("tango-icons"); #endif }
static void rebuild_single_resource(gint resource_type) { gint res[NO_RESOURCE]; gchar *tooltip_text; memset(res, 0, sizeof(res)); res[resource_type] = resource_asset(resource_type); resource_format_type_image(GTK_IMAGE(asset_images[resource_type]), res, asset_size[resource_type]); tooltip_text = g_strdup_printf("%s: %d", resource_name(resource_type, TRUE), resource_asset(resource_type)); gtk_widget_set_tooltip_text(eventbox[resource_type], tooltip_text); g_free(tooltip_text); }
M2MResourceInstance* M2MDevice::get_resource_instance(DeviceResource dev_res, uint16_t instance_id) const { M2MResource* res = NULL; M2MResourceInstance* inst = NULL; if(_device_instance) { res = _device_instance->resource(resource_name(dev_res)); if(res) { if(res->supports_multiple_instances()) { inst = res->resource_instance(instance_id); } else { inst = res; } } } return inst; }
static void create_resource_image(GtkTable * table, gint resource_type, guint column, guint row) { GtkWidget *box; GtkWidget *image; eventbox[resource_type] = box = gtk_event_box_new(); gtk_widget_show(box); gtk_table_attach(table, box, column, column + 1, row, row + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 3, 0); asset_images[resource_type] = image = gtk_image_new(); gtk_widget_show(image); gtk_container_add(GTK_CONTAINER(box), image); gtk_widget_set_tooltip_text(box, resource_name(resource_type, TRUE)); g_signal_connect(G_OBJECT(image), "size_allocate", G_CALLBACK(on_image_size_allocate), GINT_TO_POINTER(resource_type)); }
static GSList *add_resource_btn(GtkWidget * vbox, GSList * grp, Resource resource) { GtkWidget *btn; gboolean active; active = grp == NULL; btn = gtk_radio_button_new_with_label(grp, resource_name(resource, TRUE)); grp = gtk_radio_button_get_group(GTK_RADIO_BUTTON(btn)); gtk_widget_show(btn); gtk_box_pack_start(GTK_BOX(vbox), btn, TRUE, TRUE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(btn), active); g_signal_connect(G_OBJECT(btn), "toggled", G_CALLBACK(monop_toggled), GINT_TO_POINTER(resource)); if (active) monop_type = resource; return grp; }
/** \brief Get a QUrl object for a resource */ QUrl resource_url ( QString base_dir, QString name ) { return "file:///"+resource_name(base_dir,name); }