/* This function is taken from gettext.h * GNU gettext uses '\004' to separate context and msgid in .mo files. */ static const char * _dpgettext (const char *domain, const char *msgctxt, const char *msgid) { size_t msgctxt_len = strlen (msgctxt) + 1; size_t msgid_len = strlen (msgid) + 1; const char *translation; char* msg_ctxt_id; msg_ctxt_id = g_alloca (msgctxt_len + msgid_len); memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); msg_ctxt_id[msgctxt_len - 1] = '\004'; memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); translation = g_dgettext (domain, msg_ctxt_id); if (translation == msg_ctxt_id) { /* try the old way of doing message contexts, too */ msg_ctxt_id[msgctxt_len - 1] = '|'; translation = g_dgettext (domain, msg_ctxt_id); if (translation == msg_ctxt_id) return msgid; } return translation; }
/** * g_dpgettext: * @domain: (allow-none): the translation domain to use, or %NULL to use * the domain set with textdomain() * @msgctxtid: a combined message context and message id, separated * by a \004 character * @msgidoffset: the offset of the message id in @msgctxid * * This function is a variant of g_dgettext() which supports * a disambiguating message context. GNU gettext uses the * '\004' character to separate the message context and * message id in @msgctxtid. * If 0 is passed as @msgidoffset, this function will fall back to * trying to use the deprecated convention of using "|" as a separation * character. * * This uses g_dgettext() internally. See that functions for differences * with dgettext() proper. * * Applications should normally not use this function directly, * but use the C_() macro for translations with context. * * Returns: The translated string * * Since: 2.16 */ const gchar * g_dpgettext (const gchar *domain, const gchar *msgctxtid, gsize msgidoffset) { const gchar *translation; gchar *sep; translation = g_dgettext (domain, msgctxtid); if (translation == msgctxtid) { if (msgidoffset > 0) return msgctxtid + msgidoffset; sep = strchr (msgctxtid, '|'); if (sep) { /* try with '\004' instead of '|', in case * xgettext -kQ_:1g was used */ gchar *tmp = g_alloca (strlen (msgctxtid) + 1); strcpy (tmp, msgctxtid); tmp[sep - msgctxtid] = '\004'; translation = g_dgettext (domain, tmp); if (translation == tmp) return sep + 1; } } return translation; }
/** Add a new property of camera to the gui */ dt_lib_camera_property_t *_lib_property_add_new(dt_lib_camera_t * lib, const gchar *label,const gchar *propertyname) { if( dt_camctl_camera_property_exists(darktable.camctl,NULL,propertyname) ) { const char *value; if( (value=dt_camctl_camera_property_get_first_choice(darktable.camctl,NULL,propertyname)) != NULL ) { // We got a value for property lets construct the gui for the property and add values dt_lib_camera_property_t *prop = malloc(sizeof(dt_lib_camera_property_t)); memset(prop,0,sizeof(dt_lib_camera_property_t)); prop->name=label; prop->property_name=propertyname; prop->label = GTK_LABEL(gtk_label_new(label)); gtk_misc_set_alignment(GTK_MISC(prop->label ), 0.0, 0.5); prop->values=GTK_COMBO_BOX(gtk_combo_box_new_text()); prop->osd=DTGTK_TOGGLEBUTTON(dtgtk_togglebutton_new(dtgtk_cairo_paint_eye,0)); g_object_set(G_OBJECT(prop->osd), "tooltip-text", _("toggle view property in center view"), (char *)NULL); do { gtk_combo_box_append_text(prop->values, g_dgettext("libgphoto2-2", value)); } while( (value=dt_camctl_camera_property_get_next_choice(darktable.camctl,NULL,propertyname)) != NULL ); lib->gui.properties=g_list_append(lib->gui.properties,prop); // Does dead lock!!! g_signal_connect(G_OBJECT(prop->values), "changed", G_CALLBACK(property_changed_callback), (gpointer)prop); return prop; } } return NULL; }
GtkWidget* remmina_public_create_combo_map(const gpointer *key_value_list, const gchar *def, gboolean use_icon, const gchar *domain) { gint i; GtkWidget *combo; GtkListStore *store; GtkTreeIter iter; combo = remmina_public_create_combo(use_icon); store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combo))); for (i = 0; key_value_list[i]; i += (use_icon ? 3 : 2)) { gtk_list_store_append(store, &iter); gtk_list_store_set( store, &iter, 0, key_value_list[i], 1, key_value_list[i + 1] && ((char*) key_value_list[i + 1])[0] ? g_dgettext(domain, key_value_list[i + 1]) : "", -1); if (use_icon) { gtk_list_store_set(store, &iter, 2, key_value_list[i + 2], -1); } if (i == 0 || g_strcmp0(key_value_list[i], def) == 0) { gtk_combo_box_set_active(GTK_COMBO_BOX(combo), i / (use_icon ? 3 : 2)); } } return combo; }
/** * glib_gettext: * @str: The string to be translated * * Returns the translated string from the glib translations. * This is an internal function and should only be used by * the internals of glib (such as libgio). * * Returns: the transation of @str to the current locale */ const gchar * glib_gettext (const gchar *str) { ensure_gettext_initialized (); return g_dgettext (GETTEXT_PACKAGE, str); }
static void end_element (GMarkupParseContext *context, const gchar *element_name, gpointer user_data, GError **error) { TextTableParseInfo *info = user_data; pop_attribute_value (&info->gettext_domain); pop_attribute_value (&info->schema_id); pop_attribute_value (&info->key_name); if (info->string) { GHashTable *source_table = NULL; const gchar *gettext_domain; const gchar *schema_id; const gchar *key_name; gettext_domain = get_attribute_value (info->gettext_domain); schema_id = get_attribute_value (info->schema_id); key_name = get_attribute_value (info->key_name); if (g_str_equal (element_name, "summary")) source_table = info->summaries; else if (g_str_equal (element_name, "description")) source_table = info->descriptions; if (source_table && schema_id && key_name) { GHashTable *schema_table; gchar *normalised; schema_table = g_hash_table_lookup (source_table, schema_id); if (schema_table == NULL) { schema_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); g_hash_table_insert (source_table, g_strdup (schema_id), schema_table); } normalised = normalise_whitespace (info->string->str); if (gettext_domain) { gchar *translated; translated = g_strdup (g_dgettext (gettext_domain, normalised)); g_free (normalised); normalised = translated; } g_hash_table_insert (schema_table, g_strdup (key_name), normalised); } g_string_free (info->string, TRUE); info->string = NULL; } }
static gboolean remmina_plugin_manager_show_for_each(RemminaPlugin *plugin, GtkListStore *store) { GtkTreeIter iter; gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, plugin->name, 1, _(remmina_plugin_type_name[plugin->type]), 2, g_dgettext(plugin->domain, plugin->description), 3, plugin->version, -1); return FALSE; }
/** * gstyle_palette_get_name: * @self: a #GstylePalette * * Return the name of the palette. * * Returns: The palette's name. */ const gchar * gstyle_palette_get_name (GstylePalette *self) { g_return_val_if_fail (GSTYLE_IS_PALETTE (self), NULL); if (self->gettext_domain) return g_dgettext (self->gettext_domain, self->name); else return self->name; }
/* * _gweather_parser_get_localized_value: * @parser: a #GWeatherParser * * Looks at the name of the element @parser is currently pointing to, and * returns the content of either that node, or the translation for * it from the gettext domain for gweather locations. * * Return value: the localized (or unlocalized) text, as a * glib-allocated string, or %NULL if the node is empty. **/ char * _gweather_parser_get_localized_value (GWeatherParser *parser) { char *untranslated_value = _gweather_parser_get_value (parser); char *ret; ret = (char*) g_dgettext ("libgweather-locations", (char*) untranslated_value); ret = g_strdup (ret); xmlFree (untranslated_value); return ret; }
const gchar * anerley_presence_chooser_get_default_message (TpConnectionPresenceType presence) { const PresenceTuple *p; g_return_val_if_fail (presence >= 0 && presence < NUM_TP_CONNECTION_PRESENCE_TYPES, NULL); p = &presences[presence]; return g_dgettext (GETTEXT_PACKAGE, p->name); }
static inline const char * schema_translate (const MateConfSchema *schema, const char *string) { if (REAL_SCHEMA (schema)->gettext_domain) { bind_textdomain_codeset (REAL_SCHEMA (schema)->gettext_domain, "UTF-8"); return g_dgettext(REAL_SCHEMA (schema)->gettext_domain, string); } else return string; }
/** Add a new property of camera to the gui */ dt_lib_camera_property_t *_lib_property_add_new(dt_lib_camera_t *lib, const gchar *label, const gchar *propertyname) { if(dt_camctl_camera_property_exists(darktable.camctl, NULL, propertyname)) { const char *value; if((value = dt_camctl_camera_property_get_first_choice(darktable.camctl, NULL, propertyname)) != NULL) { // We got a value for property lets construct the gui for the property and add values int i = 0; const char *current_value = dt_camctl_camera_get_property(darktable.camctl, NULL, propertyname); dt_lib_camera_property_t *prop = calloc(1, sizeof(dt_lib_camera_property_t)); prop->name = strdup(label); prop->property_name = strdup(propertyname); prop->values = dt_bauhaus_combobox_new(NULL); dt_bauhaus_widget_set_label(prop->values, NULL, label); g_object_ref_sink(prop->values); prop->osd = DTGTK_TOGGLEBUTTON(dtgtk_togglebutton_new(dtgtk_cairo_paint_eye, CPF_STYLE_FLAT | CPF_DO_NOT_USE_BORDER)); g_object_ref_sink(prop->osd); gtk_widget_set_size_request(GTK_WIDGET(prop->osd), DT_PIXEL_APPLY_DPI(14), -1); g_object_set(G_OBJECT(prop->osd), "tooltip-text", _("toggle view property in center view"), (char *)NULL); do { dt_bauhaus_combobox_add(prop->values, g_dgettext("libgphoto2-2", value)); if(!strcmp(current_value, g_dgettext("libgphoto2-2", value))) dt_bauhaus_combobox_set(prop->values, i); i++; } while((value = dt_camctl_camera_property_get_next_choice(darktable.camctl, NULL, propertyname)) != NULL); lib->gui.properties = g_list_append(lib->gui.properties, prop); // Does dead lock!!! g_signal_connect(G_OBJECT(prop->values), "value-changed", G_CALLBACK(property_changed_callback), (gpointer)prop); return prop; } } return NULL; }
const gchar * _gtk_builder_parser_translate (const gchar *domain, const gchar *context, const gchar *text) { const gchar *s; if (context) s = g_dpgettext2 (domain, context, text); else s = g_dgettext (domain, text); return s; }
/** * _gitg_gettext: * @msgid: The string to be translated * * Returns the translated string from the libgitg translations. * This is an internal function and should only be used by * the internals of libgitg * * Returns: the transation of @msgid to the current locale */ const gchar * _gitg_gettext (const gchar *msgid) { static gboolean initialized = FALSE; if (G_UNLIKELY (!initialized)) { bindtextdomain (GETTEXT_PACKAGE, GITG_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); initialized = TRUE; } return g_dgettext (GETTEXT_PACKAGE, msgid); }
static GrlMedia * produce_container_from_directory (GrlMedia *media, CategoryInfo *dir, guint index, RaitvMediaType type) { GrlMedia *content; gchar* mediaid=NULL; if (!media) { content = grl_media_box_new (); } else { content = media; } if (!dir) { grl_media_set_id (content, NULL); grl_media_set_title (content, RAITV_ROOT_NAME); } else { switch(type) { case RAITV_MEDIA_TYPE_ROOT : case RAITV_MEDIA_TYPE_POPULARS : case RAITV_MEDIA_TYPE_RECENTS : mediaid = g_strdup_printf("%s",dir[index].id); break; case RAITV_MEDIA_TYPE_POPULAR_THEME : mediaid = g_strdup_printf("%s/%s", RAITV_POPULARS_THEME_ID, dir[index].id); break; case RAITV_MEDIA_TYPE_RECENT_THEME : mediaid = g_strdup_printf("%s/%s", RAITV_RECENTS_THEME_ID, dir[index].id); break; default: break; } GRL_DEBUG ("MediaId=%s, Type:%d, Titolo:%s",mediaid, type, dir[index].name); grl_media_set_id (content, mediaid); grl_media_set_title (content, g_dgettext (GETTEXT_PACKAGE, dir[index].name)); g_free(mediaid); } return content; }
static QuviError _http_metainfo(_quvi_net_t n, CURL *c) { CURLcode curlcode; QuviError rc; curlcode = curl_easy_perform(c); curl_easy_setopt(c, CURLOPT_HTTPGET, 1L); /* HEAD -> GET */ curl_easy_getinfo(c, CURLINFO_RESPONSE_CODE, &n->status.resp_code); rc = QUVI_OK; if (curlcode == CURLE_OK) { if (n->status.resp_code == 200 || n->status.resp_code == 206) { gdouble *l = &n->http_metainfo.content_length; gchar *s = NULL; curl_easy_getinfo(c, CURLINFO_CONTENT_TYPE, &s); curl_easy_getinfo(c, CURLINFO_CONTENT_LENGTH_DOWNLOAD, l); g_string_assign(n->http_metainfo.content_type, s); } else { g_string_printf(n->status.errmsg, g_dgettext(GETTEXT_PACKAGE, _EOK), n->status.resp_code); rc = QUVI_ERROR_CALLBACK; } } else { const gchar *s = curl_easy_strerror(curlcode); const gint r = n->status.resp_code; const gint c = curlcode; #define _ENO "%s (HTTP/%03d, cURL=0x%03x)" g_string_printf(n->status.errmsg, _ENO, s, r, c); #undef _ENO rc = QUVI_ERROR_CALLBACK; } return (rc); }
static gboolean remmina_file_editor_iterate_protocol(gchar* protocol, RemminaPlugin* plugin, gpointer data) { RemminaFileEditor* gfe = REMMINA_FILE_EDITOR(data); GtkListStore* store; GtkTreeIter iter; gboolean first; store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(gfe->priv->protocol_combo))); first = !gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, protocol, 1, g_dgettext(plugin->domain, plugin->description), 2, ((RemminaProtocolPlugin*) plugin)->icon_name, -1); if (first || g_strcmp0(protocol, remmina_file_get_string(gfe->priv->remmina_file, "protocol")) == 0) { gtk_combo_box_set_active_iter(GTK_COMBO_BOX(gfe->priv->protocol_combo), &iter); } return FALSE; }
/* * Small hack since we don't have a proper place where * do gettext initialization. */ const gchar * _gtksourceview_gettext (const gchar *msgid) { static gboolean initialized = FALSE; G_GNUC_UNUSED const char translator_credits[] = N_("translator-credits"); /* above is a dummy variable to get the string into po files */ if (G_UNLIKELY (!initialized)) { gchar *locale_dir; locale_dir = get_locale_dir (); bindtextdomain (GETTEXT_PACKAGE, locale_dir); g_free (locale_dir); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); initialized = TRUE; } return g_dgettext (GETTEXT_PACKAGE, msgid); }
/** * gtk_stock_lookup: * @stock_id: a stock item name * @item: (out): stock item to initialize with values * * Fills @item with the registered values for @stock_id, returning %TRUE * if @stock_id was known. * * * Return value: %TRUE if @item was initialized **/ gboolean gtk_stock_lookup (const gchar *stock_id, GtkStockItem *item) { const GtkStockItem *found; g_return_val_if_fail (stock_id != NULL, FALSE); g_return_val_if_fail (item != NULL, FALSE); init_stock_hash (); found = g_hash_table_lookup (stock_hash, stock_id); if (found) { *item = *found; item->modifier &= ~NON_STATIC_MASK; if (item->label) { GtkStockTranslateFunc *translate; if (item->translation_domain) translate = (GtkStockTranslateFunc *) g_hash_table_lookup (translate_hash, item->translation_domain); else translate = NULL; if (translate != NULL && translate->func != NULL) item->label = (* translate->func) (item->label, translate->data); else item->label = (gchar *) g_dgettext (item->translation_domain, item->label); } } return found != NULL; }
/** * pk_action_lookup_get_message: **/ static gchar * pk_action_lookup_get_message (PolkitBackendActionLookup *lookup, const gchar *action_id, PolkitDetails *details, PolkitActionDescription *action_description) { PkRoleEnum role = PK_ROLE_ENUM_UNKNOWN; gboolean only_trusted = TRUE; const gchar *cmdline; const gchar *role_text; const gchar *only_trusted_text; const gchar *str; const gchar *text; gchar *message = NULL; gchar **package_ids = NULL; GString *string; guint len = 1; if (!g_str_has_prefix (action_id, "org.freedesktop.packagekit.")) goto out; /* get role */ role_text = polkit_details_lookup (details, "role"); if (role_text != NULL) role = pk_role_enum_from_string (role_text); /* get only-trusted */ only_trusted_text = polkit_details_lookup (details, "only-trusted"); if (only_trusted_text != NULL) only_trusted = g_str_equal (only_trusted_text, "true"); /* get the command line */ cmdline = polkit_details_lookup (details, "cmdline"); if (role == PK_ROLE_ENUM_REPO_ENABLE && pk_action_lookup_cmdline_is_debuginfo_install (cmdline)) { message = g_strdup (N_("To install debugging packages, extra sources need to be enabled")); goto out; } /* use the message shipped in the policy file */ if (only_trusted) goto out; /* find out the number of packages so we pluralize corectly */ str = polkit_details_lookup (details, "package_ids"); if (str != NULL) { package_ids = pk_package_ids_from_string (str); len = g_strv_length (package_ids); g_strfreev (package_ids); } /* UpdatePackages */ if (role == PK_ROLE_ENUM_UPDATE_PACKAGES) { string = g_string_new (""); /* TRANSLATORS: is not GPG signed */ g_string_append (string, g_dgettext (GETTEXT_PACKAGE, N_("The software is not from a trusted source."))); g_string_append (string, "\n"); /* TRANSLATORS: user has to trust provider -- I know, this sucks */ text = g_dngettext (GETTEXT_PACKAGE, N_("Do not update this package unless you are sure it is safe to do so."), N_("Do not update these packages unless you are sure it is safe to do so."), len); g_string_append (string, text); message = g_string_free (string, FALSE); goto out; } /* InstallPackages */ if (role == PK_ROLE_ENUM_INSTALL_PACKAGES) { string = g_string_new (""); /* TRANSLATORS: is not GPG signed */ g_string_append (string, g_dgettext (GETTEXT_PACKAGE, N_("The software is not from a trusted source."))); g_string_append (string, "\n"); /* TRANSLATORS: user has to trust provider -- I know, this sucks */ text = g_dngettext (GETTEXT_PACKAGE, N_("Do not install this package unless you are sure it is safe to do so."), N_("Do not install these packages unless you are sure it is safe to do so."), len); g_string_append (string, text); message = g_string_free (string, FALSE); goto out; } out: return message; }
static void _focus_button_clicked(GtkWidget *widget, gpointer user_data) { long int focus = (long int) user_data; if(focus >= 0 && focus <= 5) dt_camctl_camera_set_property(darktable.camctl, NULL, "manualfocusdrive", g_dgettext("libgphoto2-2", focus_array[focus])); }
static gboolean append_menu (RBButtonBar *bar, GMenuModel *menu, gboolean need_separator) { int i; gulong id; id = g_signal_connect (menu, "items-changed", G_CALLBACK (items_changed_cb), bar); g_hash_table_insert (bar->priv->handlers, (gpointer)id, g_object_ref (menu)); for (i = 0; i < g_menu_model_get_n_items (menu); i++) { char *label_text; char *accel; GtkWidget *button; GtkWidget *label; GMenuModel *submenu; /* recurse into sections */ submenu = g_menu_model_get_item_link (menu, i, G_MENU_LINK_SECTION); if (submenu != NULL) { need_separator = append_menu (bar, submenu, TRUE); continue; } /* if this item and the previous item are in different sections, add * a separator between them. this may not be a good idea. */ if (need_separator) { GtkWidget *sep; if (bar->priv->position > 0) { sep = gtk_separator_new (GTK_ORIENTATION_VERTICAL); gtk_widget_show (sep); g_object_set (sep, "margin-start", 6, "margin-end", 6, NULL); gtk_grid_attach (GTK_GRID (bar), sep, bar->priv->position++, 0, 1, 1); } need_separator = FALSE; } button = NULL; /* submenus become menu buttons, normal items become buttons */ submenu = g_menu_model_get_item_link (menu, i, G_MENU_LINK_SUBMENU); if (submenu != NULL) { button = gtk_menu_button_new (); gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), submenu); g_object_set_data_full (G_OBJECT (button), "rb-menu-model", g_object_ref (submenu), (GDestroyNotify)g_object_unref); } else { GMenuAttributeIter *iter; const char *name; GVariant *value; char *str; guint signal_id; /* we can't do more than one of action and rb-property-bind * and rb-signal-bind, so just do whichever turns up first * in the iterator */ iter = g_menu_model_iterate_item_attributes (menu, i); while (g_menu_attribute_iter_get_next (iter, &name, &value)) { if (g_str_equal (name, "action")) { button = gtk_button_new (); g_variant_get (value, "s", &str, NULL); gtk_actionable_set_action_name (GTK_ACTIONABLE (button), str); /* action target too somehow? */ g_free (str); break; } else if (g_str_equal (name, "rb-property-bind")) { /* property has to be a boolean, can't do inverts, etc. etc. */ button = gtk_toggle_button_new (); g_variant_get (value, "s", &str, NULL); g_object_bind_property (bar->priv->target, str, button, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); g_free (str); break; } else if (g_str_equal (name, "rb-signal-bind")) { button = gtk_button_new (); g_variant_get (value, "s", &str, NULL); signal_id = g_signal_lookup (str, G_OBJECT_TYPE (bar->priv->target)); if (signal_id != 0) { g_object_set_data (G_OBJECT (button), "rb-signal-bind-id", GUINT_TO_POINTER (signal_id)); g_signal_connect (button, "clicked", G_CALLBACK (signal_button_clicked_cb), bar); } g_free (str); break; } } g_object_unref (iter); } if (button == NULL) { g_warning ("no idea what's going on here"); continue; } gtk_widget_set_hexpand (button, FALSE); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); label_text = NULL; g_menu_model_get_item_attribute (menu, i, "label", "s", &label_text); label = gtk_label_new (g_dgettext (NULL, label_text)); g_object_set (label, "margin-left", 6, "margin-right", 6, NULL); gtk_container_add (GTK_CONTAINER (button), label); if (g_menu_model_get_item_attribute (menu, i, "accel", "s", &accel)) { g_object_set_data_full (G_OBJECT (button), "rb-accel", accel, (GDestroyNotify) g_free); } gtk_widget_show_all (button); gtk_size_group_add_widget (bar->priv->size_group, button); gtk_grid_attach (GTK_GRID (bar), button, bar->priv->position++, 0, 1, 1); g_free (label_text); } return need_separator; }
static void remmina_file_editor_create_settings(RemminaFileEditor* gfe, GtkWidget* table, const RemminaProtocolSetting* settings) { RemminaFileEditorPriv* priv = gfe->priv; GtkWidget* hbox = NULL; GtkWidget* widget; gint row = 0; gchar** strarr; while (settings->type != REMMINA_PROTOCOL_SETTING_TYPE_END) { if (settings->compact) { if (hbox == NULL) { hbox = gtk_hbox_new(TRUE, 0); gtk_widget_show(hbox); gtk_table_attach_defaults(GTK_TABLE(table), hbox, 0, 2, row, row + 1); } } switch (settings->type) { case REMMINA_PROTOCOL_SETTING_TYPE_SERVER: remmina_file_editor_create_server(gfe, settings, table, row); break; case REMMINA_PROTOCOL_SETTING_TYPE_PASSWORD: remmina_file_editor_create_password(gfe, table, row); break; case REMMINA_PROTOCOL_SETTING_TYPE_RESOLUTION: remmina_file_editor_create_resolution(gfe, settings, table, row); row++; break; case REMMINA_PROTOCOL_SETTING_TYPE_KEYMAP: strarr = remmina_pref_keymap_groups(); priv->keymap_combo = remmina_file_editor_create_select(gfe, table, row, 0, _("Keyboard mapping"), (const gpointer*) strarr, remmina_file_get_string(priv->remmina_file, "keymap")); g_strfreev(strarr); break; case REMMINA_PROTOCOL_SETTING_TYPE_SCALE: widget = gtk_label_new(_("Horizontal scale")); gtk_widget_show(widget); gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), widget, 0, 1, row, row + 1, GTK_FILL, 0, 0, 0); widget = gtk_label_new(_("Vertical scale")); gtk_widget_show(widget); gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), widget, 0, 1, row + 1, row + 2, GTK_FILL, 0, 0, 0); widget = remmina_scaler_new(); gtk_widget_show(widget); gtk_table_attach_defaults(GTK_TABLE(table), widget, 1, 2, row, row + 2); remmina_scaler_set(REMMINA_SCALER(widget), remmina_file_get_int(priv->remmina_file, "hscale", 0), remmina_file_get_int(priv->remmina_file, "vscale", 0), remmina_file_get_int(priv->remmina_file, "aspectscale", FALSE)); priv->scaler_widget = widget; row++; break; case REMMINA_PROTOCOL_SETTING_TYPE_TEXT: widget = remmina_file_editor_create_text(gfe, table, row, 0, g_dgettext(priv->plugin->domain, settings->label), remmina_file_get_string(priv->remmina_file, settings->name)); g_hash_table_insert(priv->setting_widgets, (gchar*) settings->name, widget); break; case REMMINA_PROTOCOL_SETTING_TYPE_SELECT: widget = remmina_file_editor_create_select(gfe, table, row, 0, g_dgettext(priv->plugin->domain, settings->label), (const gpointer*) settings->opt1, remmina_file_get_string(priv->remmina_file, settings->name)); g_hash_table_insert(priv->setting_widgets, (gchar*) settings->name, widget); break; case REMMINA_PROTOCOL_SETTING_TYPE_COMBO: widget = remmina_file_editor_create_combo(gfe, table, row, 0, g_dgettext(priv->plugin->domain, settings->label), (const gchar*) settings->opt1, remmina_file_get_string(priv->remmina_file, settings->name)); g_hash_table_insert(priv->setting_widgets, (gchar*) settings->name, widget); break; case REMMINA_PROTOCOL_SETTING_TYPE_CHECK: widget = remmina_file_editor_create_check(gfe, (hbox ? hbox : table), (hbox ? -1 : row), 0, g_dgettext (priv->plugin->domain, settings->label), remmina_file_get_int (priv->remmina_file, (gchar*) settings->name, FALSE)); g_hash_table_insert(priv->setting_widgets, (gchar*) settings->name, widget); break; case REMMINA_PROTOCOL_SETTING_TYPE_FILE: widget = remmina_file_editor_create_chooser (gfe, table, row, 0, g_dgettext (priv->plugin->domain, settings->label), remmina_file_get_string (priv->remmina_file, settings->name), GTK_FILE_CHOOSER_ACTION_OPEN); g_hash_table_insert(priv->setting_widgets, (gchar*) settings->name, widget); break; case REMMINA_PROTOCOL_SETTING_TYPE_FOLDER: widget = remmina_file_editor_create_chooser (gfe, table, row, 0, g_dgettext (priv->plugin->domain, settings->label), remmina_file_get_string (priv->remmina_file, settings->name), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); g_hash_table_insert(priv->setting_widgets, (gchar*) settings->name, widget); break; default: break; } if (!settings->compact) { hbox = NULL; row++; } settings++; } gtk_table_resize(GTK_TABLE(table), row, 2); }
const gchar * gdk_pixbuf_gettext (const gchar *msgid) { return g_dgettext (GETTEXT_PACKAGE, msgid); }
/** * Display a tip. * * \param force Forcefully display the tip even if show_tip option * has been disabled. */ void display_tip ( gboolean force ) { GtkWidget * checkbox; GtkWidget * dialog = NULL; GtkWidget *btn_back, *btn_forward, *btn_close; gchar *tmpstr; if ( !force && !conf.show_tip ) return; conf.last_tip = CLAMP ( conf.last_tip+1, 0, sizeof(tips)/sizeof(gpointer)-1); dialog = dialogue_special_no_run ( GTK_MESSAGE_INFO, GTK_BUTTONS_NONE, make_hint ( _("Did you know that..."), /* We use the Grisbi-tips catalog */ g_dgettext(NULL, tips[conf.last_tip]) ) ); gtk_window_set_modal ( GTK_WINDOW ( dialog ), FALSE ); checkbox = gsb_automem_checkbutton_new ( _("Display tips at next start"), &(conf.show_tip), NULL, NULL ); gtk_box_pack_start ( GTK_BOX ( GTK_DIALOG(dialog) -> vbox ), checkbox, FALSE, FALSE, 6 ); gtk_widget_show ( checkbox ); btn_back = gtk_dialog_add_button (GTK_DIALOG(dialog), GTK_STOCK_GO_BACK, 1); btn_forward = gtk_dialog_add_button (GTK_DIALOG(dialog), GTK_STOCK_GO_FORWARD, 2); btn_close = gtk_dialog_add_button (GTK_DIALOG(dialog), GTK_STOCK_CLOSE, 3); /* gtk_widget_set_size_request ( dialog, 450, -1 ); */ /* We iterate as user can select several tips. */ while ( TRUE ) { if ( conf.last_tip == sizeof(tips)/sizeof(gpointer)-1) gtk_widget_set_sensitive (btn_forward, FALSE); if ( conf.last_tip == 0) gtk_widget_set_sensitive (btn_back, FALSE); switch ( gtk_dialog_run ( GTK_DIALOG(dialog) ) ) { case 1: if ( conf.last_tip > 0 ) conf.last_tip--; gtk_widget_set_sensitive (btn_forward, TRUE); tmpstr = g_strconcat ( make_pango_attribut ( "size=\"larger\" weight=\"bold\"", _("Did you know that...") ), "\n\n", g_dgettext (NULL, tips[conf.last_tip] ), NULL ); gtk_label_set_markup ( GTK_LABEL ( GTK_MESSAGE_DIALOG(dialog) -> label ), tmpstr ); g_free ( tmpstr ); break; case 2: if ( conf.last_tip < sizeof(tips)/sizeof(gpointer)-1) conf.last_tip++; tmpstr = g_strconcat ( make_pango_attribut ( "size=\"larger\" weight=\"bold\"", _("Did you know that...") ), "\n\n", g_dgettext (NULL, tips[conf.last_tip] ), NULL ); gtk_label_set_markup ( GTK_LABEL ( GTK_MESSAGE_DIALOG(dialog) -> label ), tmpstr ); g_free ( tmpstr ); gtk_widget_set_sensitive (btn_back, TRUE); break; default: gtk_widget_destroy ( dialog ); return; } } }
static void pref_plugin_changed(void) { GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtk_builder_get_object(xml_preferences_window, "plugin_tree"))); GtkTreeModel *model = GTK_TREE_MODEL(plugin_store); GtkTreeIter iter; int id = 0; if (plugin_last >= 0) { gmpc_plugin_preferences_destroy(plugins[plugin_last], (GtkWidget *) gtk_builder_get_object(xml_preferences_window, "plugin_container")); plugin_last = -1; } else if (plugin_last == PLUGIN_STATS) { plugin_stats_destroy((GtkWidget *) gtk_builder_get_object(xml_preferences_window, "plugin_container")); } if (gtk_tree_selection_get_selected(sel, &model, &iter)) { gtk_tree_model_get(GTK_TREE_MODEL(plugin_store), &iter, 0, &id, -1); if (id >= 0 && gmpc_plugin_has_preferences(plugins[id])) { char *buf = NULL; const gchar *translation_domain = gmpc_plugin_get_translation_domain(plugins[id]); if (!gmpc_plugin_is_internal(plugins[id])) { const int *version = gmpc_plugin_get_version(plugins[id]); if (version != NULL) { buf = g_strdup_printf("<span size=\"xx-large\"><b>%s</b></span>\n<i>%s: %i.%i.%i</i>", #if defined(ENABLE_NLS) && GLIB_CHECK_VERSION(2,18,0) g_dgettext(translation_domain, gmpc_plugin_get_name(plugins[id])), #else gmpc_plugin_get_name(plugins[id]), #endif _("Plugin version"), version[0], version[1], version[2]); } else buf = g_strdup_printf("<span size=\"xx-large\"><b>%s</b></span>", gmpc_plugin_get_name(plugins[id])); } else { buf = g_strdup_printf("<span size=\"xx-large\"><b>%s</b></span>", N_(gmpc_plugin_get_name(plugins[id]))); } gmpc_plugin_preferences_construct(plugins[id], (GtkWidget *) gtk_builder_get_object(xml_preferences_window, "plugin_container")); plugin_last = id; gtk_label_set_markup(GTK_LABEL(gtk_builder_get_object(xml_preferences_window, "plugin_label")), buf); q_free(buf); return; } else if (id == PLUGIN_STATS) { gchar *value = g_markup_printf_escaped("<span size=\"xx-large\" weight=\"bold\">%s</span>", _("Plugins")); gtk_label_set_markup(GTK_LABEL(gtk_builder_get_object(xml_preferences_window, "plugin_label")), value); g_free(value); plugin_stats_construct((GtkWidget *) gtk_builder_get_object(xml_preferences_window, "plugin_container")); plugin_last = id; return; } } gtk_label_set_markup(GTK_LABEL(gtk_builder_get_object(xml_preferences_window, "plugin_label")), "<span size=\"xx-large\"><b>Nothing Selected</b></span>"); }
static void plugin_stats_construct(GtkWidget * container) { gchar *path = gmpc_get_full_glade_path("preferences-plugins.ui"); plugin_stat_xml = gtk_builder_new(); gtk_builder_add_from_file(plugin_stat_xml, path, NULL); q_free(path); if (plugin_stat_xml) { GtkWidget *tree = (GtkWidget *) gtk_builder_get_object(plugin_stat_xml, "plugin_stats_tree"); GtkListStore *store = NULL; GtkTreeIter iter; GtkCellRenderer *renderer = NULL; int i = 0; GtkWidget *vbox = (GtkWidget *) gtk_builder_get_object(plugin_stat_xml, "plugin_stats_vbox"); /** * new */ store = gtk_list_store_new(5, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING); gtk_tree_view_set_model(GTK_TREE_VIEW(tree), GTK_TREE_MODEL(store)); renderer = gtk_cell_renderer_toggle_new(); g_object_set_data(G_OBJECT(renderer), "editable", GINT_TO_POINTER(1)); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tree), -1, _("Enabled"), renderer, "active", 0, NULL); g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(pref_plugin_enabled), store); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tree), -1, _("Name"), renderer, "text", 1, NULL); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tree), -1, _("Function"), renderer, "text", 2, NULL); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tree), -1, _("Version"), renderer, "text", 4, NULL); for (i = 0; i < num_plugins; i++) { if (!gmpc_plugin_is_internal(plugins[i])) { const gchar *translation_domain = gmpc_plugin_get_translation_domain(plugins[i]); const int *ver = gmpc_plugin_get_version(plugins[i]); gchar *version = (ver) ? g_strdup_printf("%i.%i.%i", ver[0], ver[1], ver[2]) : g_strdup("n/a"); gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, TRUE, #if defined(ENABLE_NLS) && GLIB_CHECK_VERSION(2,18,0) 1, g_dgettext(translation_domain, gmpc_plugin_get_name(plugins[i])), #else 1, gmpc_plugin_get_name(plugins[i]), #endif 3, (plugins[i]), 4, version, -1); g_free(version); if (gmpc_plugin_get_enabled(plugins[i])) { gtk_list_store_set(store, &iter, 0, TRUE, -1); } else gtk_list_store_set(store, &iter, 0, FALSE, -1); switch (gmpc_plugin_get_type(plugins[i])) { case GMPC_PLUGIN_DUMMY: gtk_list_store_set(store, &iter, 2, _("Dummy"), -1); break; case GMPC_PLUGIN_PL_BROWSER: gtk_list_store_set(store, &iter, 2, _("Browser Extension"), -1); break; case GMPC_PLUGIN_META_DATA: gtk_list_store_set(store, &iter, 2, _("Metadata Provider"), -1); break; case GMPC_PLUGIN_PL_BROWSER | GMPC_PLUGIN_META_DATA: gtk_list_store_set(store, &iter, 2, _("Metadata Provider and Browser Extension"), -1); break; case GMPC_PLUGIN_NO_GUI: gtk_list_store_set(store, &iter, 2, _("Misc."), -1); break; case GMPC_INTERNALL: case GMPC_DEPRECATED: default: gtk_list_store_set(store, &iter, 2, _("Unknown"), -1); break; } } } gtk_container_add(GTK_CONTAINER(container), vbox); } }
void create_preferences_window(void) { GError *error = NULL; GtkWidget *pl3_win = playlist3_get_window(); GtkWidget *dialog; GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkWidget *label; int i = 0; char *string = NULL; if (running) { if (xml_preferences_window == NULL) { running = 0; } else { dialog = (GtkWidget *) gtk_builder_get_object(xml_preferences_window, "preferences_window"); gtk_window_present(GTK_WINDOW(dialog)); return; } } plugin_last = -1; string = gmpc_get_full_glade_path("preferences.ui"); xml_preferences_window = gtk_builder_new(); gtk_builder_add_from_file(xml_preferences_window, string, &error); q_free(string); if (error) { g_log(LOG_DOMAIN, G_LOG_LEVEL_ERROR, "Failed to load preferences.ui: %s", error->message); g_error_free(error); } /* set info from struct */ /* hostname */ dialog = (GtkWidget *) gtk_builder_get_object(xml_preferences_window, "preferences_window"); gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(pl3_win)); gtk_widget_show_all(GTK_WIDGET(dialog)); running = 1; plugin_store_unfiltered = gtk_list_store_new(2, G_TYPE_INT, G_TYPE_STRING); /* Create a filtered list that hides the disabled plugins */ plugin_store = gtk_tree_model_filter_new(GTK_TREE_MODEL(plugin_store_unfiltered), NULL); gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(plugin_store), pref_model_filter_func, NULL, NULL); column = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(column, _("Plugins")); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(column, renderer, TRUE); gtk_tree_view_column_set_attributes(column, renderer, "markup", 1, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(gtk_builder_get_object(xml_preferences_window, "plugin_tree")), column); g_signal_connect(G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW(gtk_builder_get_object(xml_preferences_window, "plugin_tree")))), "changed", G_CALLBACK(pref_plugin_changed), NULL); gtk_tree_view_set_model(GTK_TREE_VIEW(gtk_builder_get_object(xml_preferences_window, "plugin_tree")), GTK_TREE_MODEL(plugin_store)); /* internals */ for (i = 0; i < num_plugins; i++) { if (gmpc_plugin_has_preferences(plugins[i])) { if (gmpc_plugin_is_internal(plugins[i])) { GtkTreeIter iter; gtk_list_store_append(GTK_LIST_STORE(plugin_store_unfiltered), &iter); gtk_list_store_set(GTK_LIST_STORE(plugin_store_unfiltered), &iter, 0, i, #if defined(ENABLE_NLS) && GLIB_CHECK_VERSION(2,18,0) 1, _(gmpc_plugin_get_name(plugins[i])), #else 1, gmpc_plugin_get_name(plugins[i]), #endif -1); } } } // Select the first row // TODO: Move this outside the loop. if (gtk_tree_selection_count_selected_rows (gtk_tree_view_get_selection (GTK_TREE_VIEW(gtk_builder_get_object(xml_preferences_window, "plugin_tree")))) == 0) { GtkTreeIter iter; if(gtk_tree_model_get_iter_first(GTK_TREE_MODEL(plugin_store), &iter)) { gtk_tree_selection_select_iter(gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object(xml_preferences_window, "plugin_tree"))), &iter); } } /* plugins */ { GtkTreeIter iter; gchar *value = g_markup_printf_escaped("<b>%s:</b>", _("Plugins")); gtk_list_store_append(GTK_LIST_STORE(plugin_store_unfiltered), &iter); gtk_list_store_set(GTK_LIST_STORE(plugin_store_unfiltered), &iter, 0, PLUGIN_STATS, 1, value, -1); g_free(value); for (i = 0; i < num_plugins; i++) { if (gmpc_plugin_has_preferences(plugins[i]) && !gmpc_plugin_is_internal(plugins[i])) { const gchar *translation_domain = gmpc_plugin_get_translation_domain(plugins[i]); gtk_list_store_append(GTK_LIST_STORE(plugin_store_unfiltered), &iter); gtk_list_store_set(GTK_LIST_STORE(plugin_store_unfiltered), &iter, 0, i, #if defined(ENABLE_NLS) && GLIB_CHECK_VERSION(2,18,0) 1, g_dgettext(translation_domain, gmpc_plugin_get_name(plugins[i])), #else 1, gmpc_plugin_get_name(plugins[i]), #endif -1); } } } { GtkWidget *widget = (GtkWidget *) gtk_builder_get_object(xml_preferences_window, "eventbox_background"); gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &(dialog->style->base[GTK_STATE_NORMAL])); } label = (GtkWidget *) gtk_builder_get_object(xml_preferences_window, "plugin_label_box"); gtk_widget_set_app_paintable(label, TRUE); g_signal_connect(G_OBJECT(label), "expose-event", G_CALLBACK(misc_header_expose_event), NULL); gtk_widget_set_state(GTK_WIDGET(label), GTK_STATE_SELECTED); gtk_widget_show(dialog); gtk_builder_connect_signals(xml_preferences_window, NULL); }
/*< private > * _clutter_gettext: * @str: a string to localize * * Retrieves the localized version of @str, using the Clutter domain * * Return value: the translated string */ G_CONST_RETURN gchar * _clutter_gettext (const gchar *str) { return g_dgettext (GETTEXT_PACKAGE, str); }