Ejemplo n.º 1
0
void gtk_assert_dialog_set_message(GtkAssertDialog *dlg, const gchar *msg)
{
    /* prepend and append the <b> tag
       NOTE: g_markup_printf_escaped() is not used because it's available
             only for glib >= 2.4 */
    gchar *escaped_msg = g_markup_escape_text (msg, -1);
    gchar *decorated_msg = g_strdup_printf ("<b>%s</b>", escaped_msg);

    g_return_if_fail (GTK_IS_ASSERT_DIALOG (dlg));
    gtk_label_set_markup (GTK_LABEL(dlg->message), decorated_msg);

    g_free (decorated_msg);
    g_free (escaped_msg);
}
Ejemplo n.º 2
0
void
pn_update_personal_message (MsnSession *session)
{
    PurpleAccount *account;
    PurplePresence *presence;
    gchar *current_media;

    g_return_if_fail (session);

    if (!session->logged_in)
        return;

    account = msn_session_get_user_data (session);
    presence = purple_account_get_presence (account);

    current_media = create_current_media_string (presence);

#ifndef PECAN_USE_PSM
    const gchar *msg;

    msg = purple_account_get_string (account, "personal_message", "");
    pn_set_personal_message (session, (gchar *) msg, current_media);
#else
    PurpleStatus *status;
    const gchar *formatted_msg;

    status = purple_account_get_active_status (account);
    formatted_msg = purple_status_get_attr_string (status, "message");

    if (formatted_msg)
    {
        gchar *msg;
        gchar *tmp;

        tmp = purple_markup_strip_html (formatted_msg);
        msg = g_markup_escape_text (tmp, -1);
        pn_set_personal_message (session, msg, current_media);

        g_free (tmp);
        g_free (msg);
    }
    else
    {
        pn_set_personal_message (session, NULL, current_media);
    }
#endif /* PECAN_USE_PSM */

    if (current_media)
        g_free (current_media);
}
Ejemplo n.º 3
0
static void
output_filters (MonoProfiler *prof, FILE *outfile)
{
	int i;

	if (prof->filters) {
		for (i = 0; i < prof->filters_as_str->len; ++i) {
			char *str = g_ptr_array_index (prof->filters_as_str, i);

			fprintf (outfile, "\t<filter pattern=\"%s\"/>\n", 
					 g_markup_escape_text (str, strlen (str)));
		}
	}
}
Ejemplo n.º 4
0
static gint c_markup_escape(lua_State *ls)
{
	const gchar *str;
	gchar *text;

	arg_check(ls, 1, 1);

	str = luaL_checkstring(ls, 1);
	text = g_markup_escape_text(str, -1);
	lua_pushstring(ls, text);
	g_free(text);

	return 1;
}
Ejemplo n.º 5
0
static int generate_response(void *user_data)
{
	struct pbap_session *pbap = user_data;
	GSList *sorted;
	GSList *l;
	uint16_t max = pbap->params->maxlistcount;

	DBG("");

	if (max == 0) {
		/* Ignore all other parameter and return PhoneBookSize */
		uint16_t size = g_slist_length(pbap->cache.entries);

		pbap->obj->firstpacket = TRUE;
		pbap->obj->apparam = g_obex_apparam_set_uint16(
							pbap->obj->apparam,
							PHONEBOOKSIZE_TAG,
							size);

		return 0;
	}

	/*
	 * Don't free the sorted list content: this list contains
	 * only the reference for the "real" cache entry.
	 */
	sorted = sort_entries(pbap->cache.entries, pbap->params->order,
				pbap->params->searchattrib,
				(const char *) pbap->params->searchval);

	/* Computing offset considering first entry of the phonebook */
	l = g_slist_nth(sorted, pbap->params->liststartoffset);

	pbap->obj->buffer = g_string_new(VCARD_LISTING_BEGIN);
	for (; l && max; l = l->next, max--) {
		const struct cache_entry *entry = l->data;
		char *escaped_name = g_markup_escape_text(entry->name, -1);

		g_string_append_printf(pbap->obj->buffer,
			VCARD_LISTING_ELEMENT, entry->handle, escaped_name);

		g_free(escaped_name);
	}

	pbap->obj->buffer = g_string_append(pbap->obj->buffer,
							VCARD_LISTING_END);
	g_slist_free(sorted);

	return 0;
}
Ejemplo n.º 6
0
static gchar *
tab_get_name (PlumaTab *tab)
{
	PlumaDocument *doc;
	gchar *name;
	gchar *docname;
	gchar *tab_name;

	g_return_val_if_fail (PLUMA_IS_TAB (tab), NULL);

	doc = pluma_tab_get_document (tab);

	name = pluma_document_get_short_name_for_display (doc);

	/* Truncate the name so it doesn't get insanely wide. */
	docname = pluma_utils_str_middle_truncate (name, MAX_DOC_NAME_LENGTH);

	if (gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc)))
	{
		if (pluma_document_get_readonly (doc))
		{
			tab_name = g_markup_printf_escaped ("<i>%s</i> [<i>%s</i>]",
							    docname,
							    _("Read-Only"));
		}
		else
		{
			tab_name = g_markup_printf_escaped ("<i>%s</i>", 
							    docname);
		}
	}
	else
	{
		if (pluma_document_get_readonly (doc))
		{
			tab_name = g_markup_printf_escaped ("%s [<i>%s</i>]",
							    docname,
							    _("Read-Only"));
		}
		else
		{
			tab_name = g_markup_escape_text (docname, -1);
		}
	}

	g_free (docname);
	g_free (name);

	return tab_name;
}
Ejemplo n.º 7
0
/**
 * recalculate_label:
 * @self: object to recalculate label for
 *
 * Recalculates nickname and markup from the label
 *
 */
static void
recalculate_label (SeahorseObject *self)
{
	if (!self->pv->markup_explicit) {
		if (take_string_storage (g_markup_escape_text (self->pv->label ? self->pv->label : "", -1),
		                         &self->pv->markup))
			g_object_notify (G_OBJECT (self), "markup");
	}

	if (!self->pv->nickname_explicit) {
		if (set_string_storage (self->pv->label, &self->pv->nickname))
			g_object_notify (G_OBJECT (self), "nickname");
	}
}
Ejemplo n.º 8
0
/**
 * Function that makes a nice title with an optional icon.  It is
 * mainly used to automate preference tabs with titles.
 *
 * \param title Title that will be displayed in window
 * \param filename (relative or absolute) to an image in a file format
 * recognized by gtk_image_new_from_file().  Use NULL if you don't
 * want an image to be displayed
 *
 * \returns A pointer to a vbox widget that will contain all created
 * widgets and user defined widgets
 */
GtkWidget *new_vbox_with_title_and_icon ( gchar *title,
                        gchar *image_filename)
{
    GtkWidget *vbox_pref, *hbox, *label, *image, *eb;
    GtkStyle * style;
	gchar* tmpstr1;
	gchar* tmpstr2;

    vbox_pref = gtk_vbox_new ( FALSE, 6 );
    gtk_widget_show ( vbox_pref );

    eb = gtk_event_box_new ();
    style = gtk_widget_get_style ( eb );
    gtk_widget_modify_bg ( eb, 0, &(style -> bg[GTK_STATE_ACTIVE]) );
    gtk_box_pack_start ( GTK_BOX ( vbox_pref ), eb, FALSE, FALSE, 0);


    /* Title hbox */
    hbox = gtk_hbox_new ( FALSE, 6 );
    gtk_widget_show ( hbox );
    gtk_container_add ( GTK_CONTAINER ( eb ), hbox );
    gtk_container_set_border_width ( GTK_CONTAINER ( hbox ), 3 );

    /* Icon */
    if ( image_filename )
    {
	gchar* tmpstr = g_build_filename ( gsb_dirs_get_pixmaps_dir ( ),
					  image_filename, NULL);
	image = gtk_image_new_from_file (tmpstr);
	g_free(tmpstr);
	gtk_box_pack_start ( GTK_BOX ( hbox ), image, FALSE, FALSE, 0);
	gtk_widget_show ( image );
    }

    /* Nice huge title */
    label = gtk_label_new ( title );
    tmpstr1 = g_markup_escape_text (title, strlen(title));
    tmpstr2 = g_strconcat ("<span size=\"x-large\" weight=\"bold\">",
					tmpstr1,
					"</span>",
					NULL );
    gtk_label_set_markup ( GTK_LABEL(label), tmpstr2);
    g_free(tmpstr1);
    g_free(tmpstr2);
    gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 0);
    gtk_widget_show ( label );

    return vbox_pref;
}
Ejemplo n.º 9
0
static void
gaim_pounces_write(FILE *fp, GaimPounce *pounce)
{
	GaimAccount *pouncer;
	GaimPounceEvent events;
	char *pouncer_name;

	pouncer = gaim_pounce_get_pouncer(pounce);
	events  = gaim_pounce_get_events(pounce);

	pouncer_name = g_markup_escape_text(gaim_account_get_username(pouncer), -1);

	fprintf(fp, " <pounce ui='%s'>\n", pounce->ui_type);
	fprintf(fp, "  <account protocol='%s'>%s</account>\n",
			pouncer->protocol_id, pouncer_name);
	fprintf(fp, "  <pouncee>%s</pouncee>\n", gaim_pounce_get_pouncee(pounce));
	fprintf(fp, "  <events>\n");

	if (events & GAIM_POUNCE_SIGNON)
		fprintf(fp, "   <event type='sign-on'/>\n");
	if (events & GAIM_POUNCE_SIGNOFF)
		fprintf(fp, "   <event type='sign-off'/>\n");
	if (events & GAIM_POUNCE_AWAY)
		fprintf(fp, "   <event type='away'/>\n");
	if (events & GAIM_POUNCE_AWAY_RETURN)
		fprintf(fp, "   <event type='return-from-away'/>\n");
	if (events & GAIM_POUNCE_IDLE)
		fprintf(fp, "   <event type='idle'/>\n");
	if (events & GAIM_POUNCE_IDLE_RETURN)
		fprintf(fp, "   <event type='return-from-idle'/>\n");
	if (events & GAIM_POUNCE_TYPING)
		fprintf(fp, "   <event type='start-typing'/>\n");
	if (events & GAIM_POUNCE_TYPING_STOPPED)
		fprintf(fp, "   <event type='stop-typing'/>\n");

	fprintf(fp, "  </events>\n");
	fprintf(fp, "  <actions>\n");

	g_hash_table_foreach(pounce->actions, write_action_parameter_list, fp);

	fprintf(fp, "  </actions>\n");

	if (gaim_pounce_get_save(pounce))
		fprintf(fp, "  <save/>\n");

	fprintf(fp, " </pounce>\n");

	g_free(pouncer_name);
}
Ejemplo n.º 10
0
static void InfoToConfigXml(std::string &newxml, DictManageInfo &info)
{
	newxml.clear();
	gchar *estr;
	for (std::list<DictManageGroup>::iterator i = info.groups.begin(); i != info.groups.end(); ++i) {
		newxml += "<dictgroup name=\"";
		estr = g_markup_escape_text(i->name.c_str(), -1);
		newxml += estr;
		g_free(estr);
		newxml += "\">";
		itemlist_to_xml(newxml, i->querydict, true);
		itemlist_to_xml(newxml, i->scandict, false);
		newxml += "</dictgroup>";
	}
}
Ejemplo n.º 11
0
static void
write_action_parameter(gpointer key, gpointer value, gpointer user_data)
{
	const char *name, *param_value;
	char *escaped;
	FILE *fp;

	param_value = (const char *)value;
	name        = (const char *)key;
	fp          = (FILE *)user_data;

	escaped = g_markup_escape_text(param_value, -1);
	fprintf(fp, "    <param name='%s'>%s</param>\n", name, escaped);
	g_free(escaped);
}
Ejemplo n.º 12
0
void FilterGenre::OnOptionAdded(FilterOption::Ptr const& new_filter)
{
  std::string tmp_label(new_filter->name);

  glib::String escape(g_markup_escape_text(tmp_label.c_str(), -1));
  std::string label(escape.Value());

  FilterGenreButton* button = new FilterGenreButton(label, NUX_TRACKER_LOCATION);
  button->scale = scale();
  button->SetFilter(new_filter);
  genre_layout_->AddView(button, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
  buttons_.push_back(button);

  QueueRelayout();
}
Ejemplo n.º 13
0
static void
create_row (GeditOpenDocumentSelector *selector,
            const FileItem            *item,
            GRegex                    *filter_regex)
{
	GtkTreeIter iter;
	gchar *uri;
	gchar *dst_path;
	gchar *dst_name;

	uri =item->uri;

	if (filter_regex)
	{
		get_markup_for_path_and_name (filter_regex,
		                              (const gchar *)item->path,
		                              (const gchar *)item->name,
		                              &dst_path,
		                              &dst_name);
	}
	else
	{
		dst_path = g_markup_escape_text (item->path, -1);
		dst_name = g_markup_escape_text (item->name, -1);
	}

	gtk_list_store_append (selector->liststore, &iter);
	gtk_list_store_set (selector->liststore, &iter,
	                    URI_COLUMN, uri,
	                    NAME_COLUMN, dst_name,
	                    PATH_COLUMN, dst_path,
	                    -1);

	g_free (dst_path);
	g_free (dst_name);
}
Ejemplo n.º 14
0
gchar *
i7_node_get_xml(I7Node *self)
{
	I7_NODE_USE_PRIVATE;

	/* Escape the following strings if necessary */
	gchar *command = g_markup_escape_text(priv->command, -1);
	gchar *transcript_text = g_markup_escape_text(priv->transcript_text, -1);
	gchar *expected_text = g_markup_escape_text(priv->expected_text, -1);
	gchar *label = g_markup_escape_text(priv->label, -1);

	GString *string = g_string_new("");
	g_string_append_printf(string, "  <item nodeId=\"%s\">\n", priv->id);
	g_string_append_printf(string, "    <command xml:space=\"preserve\">%s</command>\n", command);
	g_string_append_printf(string, "    <result xml:space=\"preserve\">%s</result>\n", transcript_text);
	g_string_append_printf(string, "    <commentary xml:space=\"preserve\">%s</commentary>\n", expected_text);
	g_string_append_printf(string, "    <played>%s</played>\n", priv->played? "YES" : "NO");
	g_string_append_printf(string, "    <changed>%s</changed>\n", priv->changed? "YES" : "NO");
	g_string_append_printf(string, "    <temporary score=\"%d\">%s</temporary>\n", priv->score, priv->locked? "NO" : "YES");

	if(label)
		g_string_append_printf(string, "    <annotation xml:space=\"preserve\">%s</annotation>\n", label);
	if(self->gnode->children) {
		g_string_append(string, "    <children>\n");
		g_node_children_foreach(self->gnode, G_TRAVERSE_ALL, (GNodeForeachFunc)write_child_pointer, string);
		g_string_append(string, "    </children>\n");
	}
	g_string_append(string, "  </item>\n");
	/* Free strings if necessary */
	g_free(command);
	g_free(transcript_text);
	g_free(expected_text);
	g_free(label);

	return g_string_free(string, FALSE); /* return cstr */
}
Ejemplo n.º 15
0
/* you must g_free the returned string
 * num_chars is utf-8 characters */
static gchar *
truncate_escape_string (const gchar *str,
						int num_chars)
{
	gchar *escaped_str;

	if (g_utf8_strlen (str, num_chars*2+1) > num_chars) {
		gchar *truncated_str;
		gchar *str2;

		/* allocate number of bytes and not number of utf-8 chars */
		str2 = g_malloc ((num_chars-1) * 2 * sizeof(gchar));

		g_utf8_strncpy (str2, str, num_chars-2);
		truncated_str = g_strdup_printf ("%s..", str2);
		escaped_str = g_markup_escape_text (truncated_str, strlen (truncated_str));
		g_free (str2);
		g_free (truncated_str);
	} else {
		escaped_str = g_markup_escape_text (str, strlen (str));
	}

	return escaped_str;
}
static void
activate_uri (GtkWidget  *menuitem,
	      const char *path)
{
	GError    *error = NULL;
	GFile     *file;
	GdkScreen *screen;
	char      *escaped;
	char      *scheme;
	char      *url;

	screen = menuitem_to_screen (menuitem);
	
	scheme = g_uri_parse_scheme (path);
	if (scheme) {
		url = g_strdup (path);
		g_free (scheme);
	} else {
		file = g_file_new_for_path (path);
		url = g_file_get_uri (file);
		g_object_unref (file);
	}
	
	if (g_str_has_prefix (url, "x-nautilus-search:")) {
		//FIXME: this is ugly...
		char *command;

		command = g_strdup_printf ("nautilus --no-desktop %s", url);
		gdk_spawn_command_line_on_screen (screen, command, &error);
	} else
		gnome_url_show_on_screen (url, screen, &error);

	if (error != NULL) {
		if (error->code != GNOME_URL_ERROR_CANCELLED) {
			char *primary;
			escaped = g_markup_escape_text (url, -1);
			primary = g_strdup_printf (_("Could not open location '%s'"),
						   escaped);
			g_free (escaped);
			panel_error_dialog (NULL, screen,
					    "cannot_show_url", TRUE,
					    primary, error->message);
			g_free (primary);
		}
		g_error_free (error);
	}
	g_free (url);
}
Ejemplo n.º 17
0
static void
gimp_widget_accel_changed (GtkAccelGroup   *accel_group,
                           guint            unused1,
                           GdkModifierType  unused2,
                           GClosure        *accel_closure,
                           GtkWidget       *widget)
{
  GClosure *widget_closure;

  widget_closure = g_object_get_data (G_OBJECT (widget), "gimp-accel-closure");

  if (accel_closure == widget_closure)
    {
      GtkAction   *action;
      GtkAccelKey *accel_key;
      const gchar *tooltip;
      const gchar *help_id;

      action = g_object_get_data (G_OBJECT (widget), "gimp-accel-action");

      tooltip = gtk_action_get_tooltip (action);
      help_id = g_object_get_qdata (G_OBJECT (action), GIMP_HELP_ID);

      accel_key = gtk_accel_group_find (accel_group,
                                        gimp_widget_accel_find_func,
                                        accel_closure);

      if (accel_key            &&
          accel_key->accel_key &&
          accel_key->accel_flags & GTK_ACCEL_VISIBLE)
        {
          gchar *escaped = g_markup_escape_text (tooltip, -1);
          gchar *accel   = gtk_accelerator_get_label (accel_key->accel_key,
                                                      accel_key->accel_mods);
          gchar *tmp     = g_strdup_printf ("%s  <b>%s</b>", escaped, accel);

          g_free (accel);
          g_free (escaped);

          gimp_help_set_help_data_with_markup (widget, tmp, help_id);
          g_free (tmp);
        }
      else
        {
          gimp_help_set_help_data (widget, tooltip, help_id);
        }
    }
}
Ejemplo n.º 18
0
static void
mini_dialog_set_title(PidginMiniDialog *self,
                      const char *title)
{
	PidginMiniDialogPrivate *priv = PIDGIN_MINI_DIALOG_GET_PRIVATE(self);

	char *title_esc = g_markup_escape_text(title, -1);
	char *title_markup = g_strdup_printf(
		"<span weight=\"bold\" size=\"smaller\">%s</span>",
		title_esc ? title_esc : "");

	gtk_label_set_markup(priv->title, title_markup);

	g_free(title_esc);
	g_free(title_markup);
}
Ejemplo n.º 19
0
static void
atom10_parse_feed_category (xmlNodePtr cur, feedParserCtxtPtr ctxt, itemPtr ip, struct atom10ParserState *state)
{
	gchar *label = NULL;

	label = xml_get_ns_attribute (cur, "label", NULL);
	if (!label)
		label = xml_get_ns_attribute (cur, "term", NULL);
	
	if (label) {
		gchar *escaped = g_markup_escape_text (label, -1);
		ctxt->subscription->metadata = metadata_list_append (ctxt->subscription->metadata, "category", escaped);
		g_free (escaped);
		xmlFree (label);
	}
}
Ejemplo n.º 20
0
static void
atom10_parse_entry_category (xmlNodePtr cur, feedParserCtxtPtr ctxt, struct atom10ParserState *state)
{
	gchar *category = NULL;

	category = xml_get_ns_attribute (cur, "label", NULL);
	if (!category)
		category = xml_get_ns_attribute (cur, "term", NULL);

	if (category) {
		gchar *escaped = g_markup_escape_text (category, -1);
		ctxt->item->metadata = metadata_list_append (ctxt->item->metadata, "category", escaped);
		g_free (escaped);
		xmlFree (category);
	}
}
Ejemplo n.º 21
0
static void
finish_download_cb (RBPodcastManager *pd,
		    RhythmDBEntry *entry,
		    RBPodcastMainSource *source)
{
	RBShell *shell;
	char *podcast_name;

	podcast_name = g_markup_escape_text (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_TITLE), -1);

	g_object_get (source, "shell", &shell, NULL);
	rb_shell_notify_custom (shell, 4000, _("Finished downloading podcast"), podcast_name, NULL, FALSE);
	g_object_unref (shell);

	g_free (podcast_name);
}
Ejemplo n.º 22
0
gchar *
gpk_package_id_format_oneline (const gchar *package_id, const gchar *summary)
{
	g_autofree gchar *summary_safe = NULL;
	g_auto(GStrv) split = NULL;

	g_return_val_if_fail (package_id != NULL, NULL);

	split = pk_package_id_split (package_id);
	if (summary == NULL || summary[0] == '\0') {
		/* just have name */
		return g_strdup (split[PK_PACKAGE_ID_NAME]);
	}
	summary_safe = g_markup_escape_text (summary, -1);
	return g_strdup_printf ("<b>%s</b> (%s)", summary_safe, split[PK_PACKAGE_ID_NAME]);
}
Ejemplo n.º 23
0
/* fills the tree */
static void
acwin_fill_tree(Tacwin * acw, GList * items, GList * items2, gchar * closetag, gboolean reverse, gint numitems)
{
	GList *tmplist, *list = NULL;
	gint everynth=1, i=0;

	/* to avoid that we show 10000 items in the autocomplete list, we insert every N items where N % everynth == 0 */
	if (numitems > 512) {
		everynth = 1.0 * numitems / 512.0;
		DBG_AUTOCOMP("numitems=%d, everynth=%d\n", numitems, everynth);
	}
	if (items)
		list = g_list_copy(items);
	if (items2)
		list = g_list_concat(g_list_copy(items2), list);

	list = g_list_sort(list, (GCompareFunc) ac_sort_func);
	if (closetag) {
		GList *tlist2;
		tlist2 = find_in_stringlist(list, closetag);
		if (tlist2) {
			list = g_list_remove_link(list, tlist2);
			list = g_list_concat(tlist2, list);
		} else {
			list = g_list_prepend(list, closetag);
		}
	}
	if (reverse) {
		list = g_list_reverse(list);
		DBG_AUTOCOMP("reverse list!\n");
	}
	tmplist = g_list_first(list);
	while (tmplist) {
		if (i % everynth == 0) {
			GtkTreeIter it;
			gchar *tmp;
			gtk_list_store_append(acw->store, &it);
			tmp = g_markup_escape_text(tmplist->data, -1);
			gtk_list_store_set(acw->store, &it, 0, tmp, 1, tmplist->data, -1);
			/*DBG_AUTOCOMP("acwin_fill_tree, add item %s\n",tmp);*/
			g_free(tmp);
		}
		i++;
		tmplist = g_list_next(tmplist);
	}
	g_list_free(list);
}
Ejemplo n.º 24
0
static void
do_nonprogressive (const gchar *filename)
{
  GtkWidget *frame;
  GtkWidget *vbox;
  GtkWidget *image;
  GtkWidget *label;
  GtkWidget *window;
  gchar *str, *escaped;
  
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Animation");

  gtk_container_set_border_width (GTK_CONTAINER (window), 8);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
  gtk_container_add (GTK_CONTAINER (window), vbox);

  label = gtk_label_new (NULL);
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
  escaped = g_markup_escape_text (filename, -1);
  str = g_strdup_printf ("Loaded from file: <b>%s</b>", escaped);
  gtk_label_set_markup (GTK_LABEL (label),
                        str);
  g_free (escaped);
  g_free (str);
  
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
      
  frame = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
  gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
  gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);

  image = gtk_image_new_from_file (filename);
  gtk_container_add (GTK_CONTAINER (frame), image);

  g_signal_connect (window, "destroy",
		    G_CALLBACK (gtk_main_quit), NULL);
  
  g_signal_connect (window, "delete_event",
		    G_CALLBACK (gtk_main_quit), NULL);

  gtk_widget_show_all (window);
}
Ejemplo n.º 25
0
void
purple_smiley_list_remove(PurpleSmileyList *list, PurpleSmiley *smiley)
{
    PurpleSmileyListPrivate *priv = PURPLE_SMILEY_LIST_GET_PRIVATE(list);
    GList *list_elem, *it;
    const gchar *shortcut, *path;
    gchar *shortcut_escaped;

    g_return_if_fail(priv != NULL);
    g_return_if_fail(PURPLE_IS_SMILEY(smiley));

    if (g_object_get_data(G_OBJECT(smiley), "purple-smiley-list") != list) {
        purple_debug_warning("smiley-list", "remove: invalid list");
        return;
    }

    list_elem = g_object_get_data(G_OBJECT(smiley),
                                  "purple-smiley-list-elem");

    shortcut = purple_smiley_get_shortcut(smiley);
    path = smiley_get_uniqid(smiley);

    g_hash_table_remove(priv->shortcut_map, shortcut);
    if (path)
        g_hash_table_remove(priv->path_map, path);

    shortcut_escaped = g_markup_escape_text(shortcut, -1);
    purple_trie_remove(priv->trie, shortcut);
    g_free(shortcut_escaped);

    _list_delete_link2(&priv->smileys, &priv->smileys_end, list_elem);

    /* re-add entry to path_map if smiley was not unique */
    for (it = priv->smileys; it && path; it = g_list_next(it)) {
        PurpleSmiley *smiley = it->data;

        if (g_strcmp0(smiley_get_uniqid(smiley), path) == 0) {
            g_hash_table_insert(priv->path_map,
                                g_strdup(path), smiley);
            break;
        }
    }

    g_object_set_data(G_OBJECT(smiley), "purple-smiley-list", NULL);
    g_object_set_data(G_OBJECT(smiley), "purple-smiley-list-elem", NULL);
    g_object_unref(smiley);
}
Ejemplo n.º 26
0
static GList *
xde_directory(MenuContext *ctx, GMenuTreeDirectory *dir)
{
	GList *text = NULL;
	const char *name, *path;
	char *icon = NULL, *s;
	GIcon *gicon = NULL;
	char *esc;
	int level;

	name = gmenu_tree_directory_get_name(dir);

	esc = g_markup_escape_text(name, -1);

	if (ctx->stack)
		gicon = gmenu_tree_directory_get_icon(ctx->stack->data);
	if ((path = gmenu_tree_directory_get_desktop_file_path(dir))) {
		GKeyFile *file = g_key_file_new();

		g_key_file_load_from_file(file, path, G_KEY_FILE_NONE, NULL);
		icon = xde_get_entry_icon(ctx, file, gicon, "folder", "unknown",
					  GET_ENTRY_ICON_FLAG_XPM | GET_ENTRY_ICON_FLAG_PNG |
					  GET_ENTRY_ICON_FLAG_JPG | GET_ENTRY_ICON_FLAG_SVG);
		g_key_file_unref(file);
	} else
		icon = xde_get_icon2(ctx, "folder", "unknown");
	icon = ctx->wmm.wrap(ctx, icon);

	level = xde_reset_indent(ctx, 0);
	s = g_strdup_printf("%s<menu id=\"%s Menu\" label=\"%s\"%s>\n", ctx->indent, esc, esc,
			    icon);
	text = g_list_append(text, s);
	text = g_list_concat(text, ctx->wmm.ops.menu(ctx, dir));
	s = g_strdup_printf("%s</menu> <!-- %s Menu -->\n\n", ctx->indent, esc);
	text = g_list_append(text, s);
	level = xde_reset_indent(ctx, level);

	ctx->wmm.output = g_list_concat(ctx->wmm.output, text);
	s = g_strdup_printf("%s<menu id=\"%s Menu\" label=\"%s\"%s />\n", ctx->indent, esc, esc,
			    icon);
	text = g_list_append(NULL, s);

	free(icon);
	g_free(esc);
	return (text);
}
Ejemplo n.º 27
0
static char *
trepia_tooltip_text(GaimBuddy *b)
{
	TrepiaProfile *profile = (TrepiaProfile *)b->proto_data;
	const char *value;
	const char *first_name, *last_name;
	int int_value;
	GString *ret = g_string_new("");

	first_name = trepia_profile_get_first_name(profile);
	last_name  = trepia_profile_get_last_name(profile);

	if (first_name != NULL || last_name != NULL)
		g_string_append_printf(ret, "\n<b>%s:</b> %s%s%s", _("Name"),
							  (first_name == NULL ? "" : first_name),
							  (first_name == NULL ? "" : " "),
							  (last_name == NULL ? "" : last_name));

	if ((int_value = trepia_profile_get_age(profile)) != 0)
		g_string_append_printf(ret, "\n<b>%s:</b> %d", _("Age"), int_value);

	g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Gender"),
			(trepia_profile_get_sex(profile) == 'F' ? _("Female") : _("Male")));

	if ((value = trepia_profile_get_city(profile)) != NULL)
		g_string_append_printf(ret, "\n<b>%s:</b> %s", _("City"), value);

	if ((value = trepia_profile_get_state(profile)) != NULL)
		g_string_append_printf(ret, "\n<b>%s:</b> %s", _("State"), value);

	if ((value = trepia_profile_get_country(profile)) != NULL)
		g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Country"), value);

	if ((value = trepia_profile_get_homepage(profile)) != NULL)
		g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Homepage"), value);

	if ((value = trepia_profile_get_profile(profile)) != NULL) {
		char *escaped_val = g_markup_escape_text(value, -1);

		g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Profile"), escaped_val);

		g_free(escaped_val);
	}

	return g_string_free(ret, FALSE);
}
Ejemplo n.º 28
0
static gchar*
clean_text(const gchar* txt) 
{
	gchar *cleaned;
	gchar *result;

	g_return_val_if_fail(txt, NULL);

	cleaned = cong_util_cleanup_text(txt);

	result = g_markup_escape_text(cleaned,
				      strlen(cleaned));

	g_free(cleaned);

	return result;
}
Ejemplo n.º 29
0
static void
append_to_tooltip(PurpleBlistNode *node, GString *text, gboolean full)
{
    if (full) {
        const gchar *note = purple_blist_node_get_string(node, "notes");

        if ((note != NULL) && (*note != '\0')) {
            char *tmp, *esc;
            purple_markup_html_to_xhtml(note, NULL, &tmp);
            esc = g_markup_escape_text(tmp, -1);
            g_free(tmp);
            g_string_append_printf(text, _("\n<b>Buddy Note</b>: %s"),
                                   esc);
            g_free(esc);
        }
    }
}
Ejemplo n.º 30
0
static void
feed_updates_available_cb (RBPodcastManager *pd,
			   RhythmDBEntry *entry,
			   RBPodcastMainSource *source)
{
	RBShell *shell;
	char *podcast_name;

	podcast_name = g_markup_escape_text (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_TITLE), -1);

	g_object_get (source, "shell", &shell, NULL);
	rb_shell_notify_custom (shell, 4000, _("New updates available from"), podcast_name, NULL, FALSE);
	g_object_unref (shell);

	g_free (podcast_name);

}