/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 *  Authors: Michael Zucchi <notzed@ximian.com>
 *
 *  Copyright 2004 Novell Inc. (www.novell.com)
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of version 2 of the GNU General Public
 *  License as published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
 *
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <string.h>
#include <gtk/gtkimage.h>

#include "e-info-label.h"
#include <gtk/gtklabel.h>
#include "e-clipped-label.h"

#include <e-util/e-icon-factory.h>

static GtkHBoxClass *el_parent;

static void
el_init(GObject *o)
{
	/*EInfoLabel *el = (EInfoLabel *)o;*/
}

static void
el_finalise(GObject *o)
{
	((GObjectClass *)el_parent)->finalize(o);
}

static void
el_destroy (GtkObject *o)
{
	((EInfoLabel *)o)->location = NULL;
	((EInfoLabel *)o)->info = NULL;

	((GtkObjectClass *)el_parent)->destroy(o);
}

static int
el_expose_event(GtkWidget *w, GdkEventExpose *event)
{
	int x = ((GtkContainer *)w)->border_width;

	/* This seems a hack to me, but playing with styles wouldn't affect the background */
	gtk_paint_flat_box(w->style, w->window,
			   GTK_STATE_ACTIVE, GTK_SHADOW_NONE,
			   &event->area, w, "EInfoLabel",
			   w->allocation.x+x, w->allocation.y+x,
			   w->allocation.width-x*2, w->allocation.height-x*2);

	return ((GtkWidgetClass *)el_parent)->expose_event(w, event);
}

static void
el_class_init(GObjectClass *klass)
{
	klass->finalize = el_finalise;
	
	((GtkObjectClass *)klass)->destroy = el_destroy;
	((GtkWidgetClass *)klass)->expose_event = el_expose_event;
}

GType
e_info_label_get_type(void)
{
	static GType type = 0;

	if (type == 0) {
		static const GTypeInfo info = {
			sizeof(EInfoLabelClass),
			NULL, NULL,
			(GClassInitFunc)el_class_init,
			NULL, NULL,
			sizeof(EInfoLabel), 0,
			(GInstanceInitFunc)el_init
		};
		el_parent = g_type_class_ref(gtk_hbox_get_type());
		type = g_type_register_static(gtk_hbox_get_type(), "EInfoLabel", &info, 0);
	}

	return type;
}

/**
 * e_info_label_new:
 * @icon: 
 * 
 * Create a new info label widget.  @icon is the name of the icon
 * (from the icon theme) to use for the icon image.
 * 
 * Return value: 
 **/
GtkWidget *
e_info_label_new(const char *icon)
{
	EInfoLabel *el = g_object_new(e_info_label_get_type(), 0);
	GtkWidget *image;
	char *name = e_icon_factory_get_icon_filename (icon, E_ICON_SIZE_MENU);
	
	image = gtk_image_new_from_file(name);
	g_free(name);
	gtk_misc_set_padding((GtkMisc *)image, 6, 6);
	gtk_box_pack_start((GtkBox *)el, image, FALSE, TRUE, 0);
	gtk_widget_show(image);

	gtk_container_set_border_width((GtkContainer *)el, 3);

	return (GtkWidget *)el;
}

/**
 * e_info_label_set_info:
 * @el: 
 * @location: 
 * @info: 
 * 
 * Set the information to show on the label.  @location is some
 * context about the current view.  e.g. the folder name.  If the
 * label is too wide, this will be truncated.
 *
 * @info is some info about this location.
 **/
void
e_info_label_set_info(EInfoLabel *el, const char *location, const char *info)
{
	char *tmp;

	if (el->location == NULL) {
		el->location = e_clipped_label_new(location, PANGO_WEIGHT_BOLD, 1.0);
		el->info = gtk_label_new(NULL);

		gtk_misc_set_alignment((GtkMisc *)el->location, 0.0, 0.0);
		gtk_misc_set_padding((GtkMisc *)el->location, 0, 6);
		gtk_misc_set_alignment((GtkMisc *)el->info, 0.0, 1.0);
		gtk_misc_set_padding((GtkMisc *)el->info, 0, 6);

		gtk_widget_show(el->location);
		gtk_widget_show(el->info);

		gtk_box_pack_start((GtkBox *)el, (GtkWidget *)el->location, TRUE, TRUE, 0);
		gtk_box_pack_end((GtkBox *)el, (GtkWidget *)el->info, FALSE, TRUE, 6);
		gtk_widget_set_state((GtkWidget *)el, GTK_STATE_ACTIVE);
	} else {
		e_clipped_label_set_text((EClippedLabel *)el->location, location);
	}

	tmp = g_strdup_printf("<span size=\"smaller\">%s</span>", info);
	gtk_label_set_markup((GtkLabel *)el->info, tmp);
	g_free(tmp);
}

ome-3.32</option>
<option value='gnome-3.36'>gnome-3.36</option>
<option value='gstreamer'>gstreamer</option>
<option value='gstreamer-1.16'>gstreamer-1.16</option>
<option value='gstreamer0.10-removal'>gstreamer0.10-removal</option>
<option value='main'>main</option>
<option value='master'>master</option>
<option value='mate-1.16'>mate-1.16</option>
<option value='mate-1.18'>mate-1.18</option>
<option value='mate-1.20'>mate-1.20</option>
<option value='mate-1.22'>mate-1.22</option>
</select> <input type='submit' value='switch'/></form></td></tr>
<tr><td class='sub'>FreeBSD GNOME current development ports (https://github.com/freebsd/freebsd-ports-gnome)</td><td class='sub right'></td></tr></table>
<table class='tabs'><tr><td>
<a href='/~lantw44/cgit/freebsd-ports-gnome/about/?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8'>about</a><a href='/~lantw44/cgit/freebsd-ports-gnome/?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8'>summary</a><a href='/~lantw44/cgit/freebsd-ports-gnome/refs/?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&amp;id=e4b238fb6d20d60a8a10ee983f2f7b665b019a2b'>refs</a><a class='active' href='/~lantw44/cgit/freebsd-ports-gnome/log/devel/aarch64-binutils?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8'>log</a><a href='/~lantw44/cgit/freebsd-ports-gnome/tree/devel/aarch64-binutils?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&amp;id=e4b238fb6d20d60a8a10ee983f2f7b665b019a2b'>tree</a><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/devel/aarch64-binutils?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&amp;id=e4b238fb6d20d60a8a10ee983f2f7b665b019a2b'>commit</a><a href='/~lantw44/cgit/freebsd-ports-gnome/diff/devel/aarch64-binutils?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&amp;id=e4b238fb6d20d60a8a10ee983f2f7b665b019a2b'>diff</a><a href='/~lantw44/cgit/freebsd-ports-gnome/stats/devel/aarch64-binutils?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8'>stats</a></td><td class='form'><form class='right' method='get' action='/~lantw44/cgit/freebsd-ports-gnome/log/devel/aarch64-binutils'>
<input type='hidden' name='h' value='dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8'/><input type='hidden' name='id' value='e4b238fb6d20d60a8a10ee983f2f7b665b019a2b'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/~lantw44/cgit/freebsd-ports-gnome/log/?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&amp;id=e4b238fb6d20d60a8a10ee983f2f7b665b019a2b'>root</a>/<a href='/~lantw44/cgit/freebsd-ports-gnome/log/devel?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&amp;id=e4b238fb6d20d60a8a10ee983f2f7b665b019a2b'>devel</a>/<a href='/~lantw44/cgit/freebsd-ports-gnome/log/devel/aarch64-binutils?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&amp;id=e4b238fb6d20d60a8a10ee983f2f7b665b019a2b'>aarch64-binutils</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th></th><th class='left'>Commit message (<a href='/~lantw44/cgit/freebsd-ports-gnome/log/devel/aarch64-binutils?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&amp;id=e4b238fb6d20d60a8a10ee983f2f7b665b019a2b&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Age</th><th class='left'>Files</th><th class='left'>Lines</th></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/devel/aarch64-binutils?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&amp;id=56d511a435a8db91cbb7081bd0f4fb30317ea7a2'>Mark some ports failing on power64.  In cases where the error message</a></td><td>linimon</td><td><span title='2017-05-20 20:02:07 +0800'>2017-05-20</span></td><td>1</td><td><span class='deletions'>-0</span>/<span class='insertions'>+4</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/devel/aarch64-binutils?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&amp;id=7ff589fe719cd3cd371f60ab24ef218bf81e7e82'>Update to binutils 2.28</a></td><td>bapt</td><td><span title='2017-03-23 05:10:39 +0800'>2017-03-23</span></td><td>1</td><td><span class='deletions'>-1</span>/<span class='insertions'>+0</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/devel/aarch64-binutils?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&amp;id=60fded3a1737ff2d409a1aef32bf8275613c3e29'>Build aarch64-binutils as static by default.</a></td><td>bdrewery</td><td><span title='2017-02-23 07:33:44 +0800'>2017-02-23</span></td><td>1</td><td><span class='deletions'>-0</span>/<span class='insertions'>+2</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/devel/aarch64-binutils?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&amp;id=4395921edb159666a1a338bf0688ed945a513ed8'>Remove the trailing slash from MASTERDIR to be in accordance with the</a></td><td>linimon</td><td><span title='2016-11-17 12:50:59 +0800'>2016-11-17</span></td><td>1</td><td><span class='deletions'>-1</span>/<span class='insertions'>+1</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/devel/aarch64-binutils?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&amp;id=ed6947bed38908d07e419b48e3e251f0d22191a6'>Update to 2.27</a></td><td>bapt</td><td><span title='2016-08-26 22:18:50 +0800'>2016-08-26</span></td><td>1</td><td><span class='deletions'>-0</span>/<span class='insertions'>+4</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/devel/aarch64-binutils?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&amp;id=f38bd594b561d73f66fdebde721e7439880238c5'>Revert update to binutils 2.25.1 and bump portepoch to reflect that revert</a></td><td>bapt</td><td><span title='2016-01-27 15:49:45 +0800'>2016-01-27</span></td><td>1</td><td><span class='deletions'>-1</span>/<span class='insertions'>+0</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/devel/aarch64-binutils?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&amp;id=4cdbc67da8901b7674aad20b948e535e20e5c48c'>Update binutils to 2.26</a></td><td>bapt</td><td><span title='2016-01-27 03:25:29 +0800'>2016-01-27</span></td><td>1</td><td><span class='deletions'>-0</span>/<span class='insertions'>+1</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/devel/aarch64-binutils?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&amp;id=8719898df6aef9b44516bccec513c0c519c86638'>devel/aarch64-binutils: add size to pkg-plist</a></td><td>emaste</td><td><span title='2015-04-03 20:53:05 +0800'>2015-04-03</span></td><td>1</td><td><span class='deletions'>-0</span>/<span class='insertions'>+1</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/devel/aarch64-binutils?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&amp;id=880253e7afbb4369b527497652345ed969ce857e'>Update aarch64 patch for binutils 2.25</a></td><td>emaste</td><td><span title='2015-01-14 05:26:59 +0800'>2015-01-14</span>