Getting the latest version of TeXLive on Fedora 16, and installing packages

In line with Fedora’s (and many other Linux distributions’) design philosophy, all installed packages should be managed centrally through yum. This is great in principal, because it allows all software on the system to be updated with a single click.

The downside is that not all desired packages are available through Fedora’s official repositories. Or, if they are, they may not be regularly updated and properly maintained. The Fedora team also strips out package features that allow updates independent of the operating system.

In this case, I wanted to use TeXLive 2011, but the pre-installed version is TeXLive 2007 (recall that this is the middle of 2012). An update seems to be in progress, but won’t be 100% complete until Fedora 17 [1].

Even if TeXLive 2011 was available, however, the policy on banning alternate update methods means that a part of the TeXLive distribution, tlmgr will be stripped out. tlmgr allows connection to a LaTeX repository and automates the installation/removal of LaTeX packages.

Since I needed some external packages and tlmgr, I downloaded TeXLive manually (see here for instructions). I also needed to install some packages not available via LaTeX repositories. Here’s how to install packages using tlmgr and by hand:

By tlmgr

BASH is unable to find tlmgr without being told its location. To do so, use the export command. The overall process of launching tlmgr is

  • Log into shell as root user.
  • Run: export PATH=/usr/local/texlive/2011/bin/x86_64-linux:$PATH
  • Run: tlmgr --gui
  • Install packages via the GUI

By hand

  • Log into shell as root user
  • Run: mkdir /usr/local/texlive/2011/texmf/tex/latex/[directory_name]
  • Run: mv [file_path] [new_directory_path]
  • Run: texhash /usr/local/texlive/2011/texmf

texhash updates the package database.

Notes
[1] In the meantime, partial updates can be installed using directions found here.


Customizing Gnome 3.2 on Fedora 16

Here are some useful extensions to improve your Gnome 3.2 experience. All extensions can be found at https://extensions.gnome.org/

  1. Alternative Status Menu (by gcampax)
    • Replaces GNOME Shell Status Menu with one showing Suspend/Hibernate and Power Off as separate items
  2. Applications Menu (by gcampax)
    • Add a gnome 2.x style menu for applications
  3. Hide Dash (by zacbarton)
    • If you find you dont use the dash or have a smaller screen you can use this extension to hide the dash and allow the windows and application tabs to have a close to full-screen area.
  4. No Topleft Hot Corner (by azuri)
    • This extension disables the top left hot corner. You can still click on Activities or press the dedicated key to reach the overview.
  5. Overlay Icons (by vdepizzol)
    • Easily discover which application to select by viewing the app icons in the windows overview
  6. Workspace Navigator (by Smotko)
    • Allow selection of workspaces with up and down arrow keys in overlay mode
  7. Workplace Switcher Wraparound (by war1025)
    • When switching workspaces, going down from the bottom workspace switches to the top workspace. Likewise, up from the top workspace goes to the bottom workspace.

Getting Dell WLAN 1397 Wireless card to work with Fedora 16

So I decided to dual-boot my computer with Linux. I’ve been mildly aware of wireless card problems with Linux before, but I never would have thought that it would be this difficult to get things to work right. Here’s the solution, courtesy of a forum post I can’t find the link to now. Thanks to that mysterious person user stoat from fedoraforums.org (link to post) who saved me from hours (more) of frustration.

The Dell WLAN 1397 Wireless card is shown to be the Broadcom BCM4312 802.11b/g LP-PHY (rev 01) card through the lspci command. The file needed is called

broadcom-wl-4.150.10.5.tar.bz2

It should be floating around on the internet, available through a quick search. Too bad WordPress won’t allow upload of .tar.bz2 files.

Get the file onto Fedora through a USB, then navigate to the containing folder using the terminal. Run the following commands in the terminal

tar xjf broadcom-wl-r.150.10.5.tar.bz2
cd su broadcom-wl-r.150.10.5/driver
su 
b43-fwcutter -w /lib/firmware wl_apsta_mimo.o

Finally, restart the computer. Wireless internet should be working.


Getting Started with WinForms in C++/CLI

Opening a new Visual C++ WinForms project, the first object we see is the designer, which represents a blank form. The designer can be used to add/delete controls, move controls around, and change controls’ basic properties such as name, text, background image, etc. More complex operations should be done within the code, however. To change from designer to code, right-click the designer and select “View code”.

The initial screen of a WinForms project

A form is categorized as a header file. The default form is titled “Form1.h”. As a header file, it contains the ubiquitous #pragma once preprocessor directive by default, so that the file would be included only once.

All the code used to build the form is included in a namespace, which by default has the same name as the project. DO NOT try to change this namespace’s name, because resource files (kept in Form1.resX) use the project name as part of their identifiers. If the namespace name does not match the project name, the resource file won’t be found. I learned this lesson the hard way [1].

Default namespaces are included. To make my Student RecordKeeper project, I included two other useful namespaces:


using namespace System::IO;
using namespace System::Collections::Generic

System::IO is useful for opening, reading, writing to, and closing text files. System::Collections::Generic is useful for using generic collections such as List and Dictionary.

Form1 is an instance of the System::Windows::Forms::Form class. As I understand it, in C++/CLI ref class is used to indicate that a class is managed. The default constructor and destructor follow.

The most interesting part of the code is the InitializeComponent() function. When I first began working with a WinForms project, I kept writing code in the body of the function and wondered why the designer would stop working. Well, turns out you shouldn’t ignore big, multi-line warning comments ;). The InitializeComponent() function is used by the designer and is automatically updated. In short, don’t touch anything within the function [2].

That’s a pretty thorough introduction to a default WinForms application, I think. The full code can be seen below after uncollapsing the section.


#pragma once

namespace Example_GettingStarted_WinForms {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	///
<summary> /// Summary for Form1
 ///
 /// WARNING: If you change the name of this class, you will need to change the
 /// 'Resource File Name' property for the managed resource compiler tool
 /// associated with all .resx files this class depends on. Otherwise,
 /// the designers will not be able to interact properly with localized
 /// resources associated with this form.
 /// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		///
<summary> /// Clean up any resources being used.
 /// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}

	private:
		///
<summary> /// Required designer variable.
 /// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		///
<summary> /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
		void InitializeComponent(void)
		{
			this->SuspendLayout();
			//
			// Form1
			//
			this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(586, 373);
			this->Name = L"Form1";
			this->Text = L"Form1";
			this->ResumeLayout(false);

		}
#pragma endregion
	};
}

[1] As mentioned in a previous post, I began my project (which I called Schedule_UI, even though it’s not really a personal schedule maker but rather a grade recorder) in VS2010 and discovered that there is no Intellisense support for C++/CLI, so I ported my project over to VS2008. Well, when I created a new project for VS2008, I named it Schedule_UI_2008. When I copy-pasted my code from the VS2010 project into the VS2008 project, I kept the namespace as Schedule_UI.

Everything worked just fine until I tried to add a background image to a button. The program simply could not find the image resource, even though it was clearly located in the Form1.resX resource file. Took me a long time before I found the answer.

[2] Note that the InitializeComponents() function is surrounded by the pair of  directives #pragma region/#pragma endregion. This allows the code between the directives to be collapsed, and is useful for creating user-defined regions of code.

However, there is a big disadvantage to doing this: functions within the region can no longer be collapsed! See here for more information. Although the issue in the link was reported in 2011, this problem has existed since VS2005 and I’ve seen several Microsoft responses claiming that it would be fixed in a patch for VS2005, then in VS2008, then finally in VS2010. So I wouldn’t hold my breath for it to be fixed in VS2012 or whatever the next version of Visual Studio becomes.


Code Syntax Highlighting on WordPress.com

I thought that WordPress.com blogs could not do syntax highlighting, but I was wrong! And I am so glad that I am wrong on this! Not only is there syntax highlighting for many languages available (see here), but the code is automatically formatted as well (edit: the syntax highlighter will remove extraneous spaces like initial indentations, but won’t automatically adjust things like braces and parentheses).

The only downside is that keyword colors cannot be changed; the default colors aren’t bad, however.

Below is a snippet of C++/CLI code used as a test.


			 // Open a student catalog .txt file
	private: void OpenStudentCatalog(void)
			 {
				 OpenFileDialog^ openStudentCatalog = gcnew OpenFileDialog;
				 openStudentCatalog->Title = "Open student catalog...";
				 openStudentCatalog->Filter = "Text files (*.txt)|*.txt";

				 if (openStudentCatalog->ShowDialog() == System::Windows::Forms::DialogResult::OK)
				 {
					 this->pathStudentCatalog = openStudentCatalog->FileName;
				 }
			 }

Using .ico files in Visual Studio 2008

Today I was putting the finishing touches on my little Student RecordKeeper project when I ran into a very peculiar problem. I had set an ErrorProvider object to show a star icon for several textboxes and comboboxes on my New Student form to show that these fields are mandatory.

I wrote a function to set these ErrorProviders within the form’s constructor, and created KeyUp/SelectedIndexChanged EventHandlers to have them disappear if text was typed or selections chosen within the textboxes and comboboxes. If the text was deleted (only by keystrokes, however) or the selected index set to -1, the icons would reappear.

Well, when I created a new form, the icons would appear, but the stars would have white backgrounds instead of transparent backgrounds.

Stars with ugly white backgrounds

I was certain that the star .ico images had transparent backgrounds, so this was very weird. Even stranger, when text was entered into the textboxes, then deleted so that the star icon would disappear and reappear, they would reappear perfectly normal with transparent backgrounds! The white backgrounds would only be there when the form is first created.

I used a different .ico file and found that it did not have the problem with white backgrounds. This was turning out to be quite a mystery! But as with most mysteries, this one had a mundane solution.

I had converted my star images from .png to .ico files using the website http://www.convertico.com/. The different .ico file I used was downloaded directly as a .ico file. Something strange must have been going on in the conversion process. I used GIMP to simply save my .png file as a .ico file and it worked as I wanted it to. The final result is below:

Stars with nice transparent backgrounds.


The Beginning

I’ll be using this blog to record my progress in building a Schedule/Grade Recorder using WinForms in C++/CLI. I have been working on this project for 3 weeks and it has been both a frustrating and educational experience.

I was going to create this project with WPF but I am unfamiliar with C#, so I resigned myself to using WinForms, which from what I’ve read is already considered obsolete and being replaced by the former. I began this project with only a mediocre background in unmanaged C++ and immediately encountered several problems.

  1. WinForms requires managed C++; that is, C++/CLI. C++/CLI is basically an extension of regular C++ that works within Microsoft’s .NET framework and allows nifty features like memory management. I initially had no idea what the .NET framework or the Common Language Runtime were and boy did I have a hard time making sense of it all; my grasp of the concept is still mostly cursory but I now know enough to write code for my project.
  2. Visual Studio 2010 does not have Intellisense support for C++/CLI. Intellisense is Visual Studio’s auto-completion feature for code. You can read all about it and it doesn’t work for C++/CLI in VS 2010 here. I started my project in VS 2010 and started playing around with the WinForms designer and did not discover this until I began to write code. Moving my project over to VS 2008 was a pain and would cause a very serious problem down the road; more on that later. So why did I have to move my project over to VS 2008? Because…
  3. Previous versions of VS cannot open projects created in VS 2010. To be honest this one makes perfect sense, but it was still very tedious to copy-paste files over to VS 2008.
Furthermore, C++/CLI does not seem to be very popular for writing WinForms applications. Almost all the code examples on MSDN, Stack Overflow, and other websites are geared towards C#. While the functions and classes used in these codes are usually part of the Base Class Library and accessible in C++/CLI, I’d sure like to see some examples specifically targeting the language I’m using.

Follow

Get every new post delivered to your Inbox.