예제 #1
0
int
init ()
{
    WNDCLASS wc;
    char* sr_debug_env;
    int rc;

    sr_debug_env = getenv ("STREAMRIPPER_DEBUG");
    if (sr_debug_env) {
	debug_enable();
	debug_set_filename (sr_debug_env);
    }

    winamp_init (m_hinstance);

    rc = prefs_load ();
    prefs_get_stream_prefs (&g_rmo, "");
    if (rc == 0) {
	options_get_desktop_folder (g_rmo.output_directory);
    }
    prefs_get_wstreamripper_prefs (&g_gui_prefs);
    prefs_save ();

    /* GCS FIX */
    //m_guiOpt.m_enabled = 1;
    //debug_printf ("Checking if enabled.\n");
    //if (!m_guiOpt.m_enabled)
    //	return 0;
    //debug_printf ("Was enabled.\n");

    memset (&wc,0,sizeof(wc));
    wc.lpfnWndProc = WndProc;			// our window procedure
    wc.hInstance = m_hinstance;
    wc.lpszClassName = m_szWindowClass;		// our window class name
    wc.hCursor = LoadCursor (NULL, IDC_ARROW);

    // Load systray popup menu
    m_hmenu_systray = LoadMenu (m_hinstance, MAKEINTRESOURCE(IDR_TASKBAR_POPUP));
    m_hmenu_systray_sub = GetSubMenu (m_hmenu_systray, 0);
    SetMenuDefaultItem (m_hmenu_systray_sub, 0, TRUE);

    if (!RegisterClass(&wc)) {
	MessageBox (NULL,"Error registering window class","blah",MB_OK);
	return 1;
    }

    /* Ref: http://msdn2.microsoft.com/en-us/library/bb776822.aspx */
    if (g_running_standalone) {
	m_hwnd = CreateWindowEx (
			WS_EX_APPWINDOW,
			m_szWindowClass, "Streamripper Plugin", WS_POPUP,
			g_gui_prefs.oldpos_x, g_gui_prefs.oldpos_y, WINDOW_WIDTH, WINDOW_HEIGHT, 
			NULL, NULL, m_hinstance, NULL);
    } else {
	m_hwnd = CreateWindowEx (
			WS_EX_TOOLWINDOW,
			m_szWindowClass, "Streamripper Plugin", WS_POPUP,
			g_gui_prefs.oldpos_x, g_gui_prefs.oldpos_y, WINDOW_WIDTH, WINDOW_HEIGHT, 
			NULL, NULL, m_hinstance, NULL);
    }

    // Create a systray icon
    memset(&m_nid, 0, sizeof(NOTIFYICONDATA));
    m_nid.cbSize = sizeof(NOTIFYICONDATA);
    m_nid.hIcon = LoadImage(m_hinstance, MAKEINTRESOURCE(IDI_SR_ICON), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
    m_nid.hWnd = m_hwnd;
    strcpy(m_nid.szTip, m_szToopTip);
    m_nid.uCallbackMessage = WM_MY_TRAY_NOTIFICATION;
    m_nid.uFlags =  NIF_MESSAGE | NIF_ICON | NIF_TIP;
    m_nid.uID = 1;
    Shell_NotifyIcon(NIM_ADD, &m_nid);

    // Load main popup menu 
    m_hmenu_context = LoadMenu (m_hinstance, MAKEINTRESOURCE(IDR_HISTORY_POPUP));
    m_hmenu_context_sub = GetSubMenu (m_hmenu_context, 0);
    SetMenuDefaultItem (m_hmenu_context_sub, 0, TRUE);

    // Populate main popup menu
    populate_history_popup ();

    if (!g_gui_prefs.m_start_minimized)
	dock_show_window(m_hwnd, SW_SHOWNORMAL);
    else
	dock_show_window(m_hwnd, SW_HIDE);
	
    return 0;
}
예제 #2
0
void sr_debug_enable(void) {
  debug_enable();
}