Esempio n. 1
0
INT_PTR LoadLastSession(WPARAM wparam, LPARAM lparam)
{
	if (isLastTRUE)
		return LoadSession(wparam, lparam);
	if (g_bOtherWarnings)
		MessageBox(NULL, TranslateT("Last Sessions is empty"), TranslateT("Sessions Manager"), MB_OK);
	return 0;
}
Esempio n. 2
0
INT_PTR BuildFavMenu(WPARAM, LPARAM)
{
	POINT pt;
	GetCursorPos(&pt);

	HMENU hMenu = CreatePopupMenu();
	FillFavoritesMenu(hMenu, g_ses_count);
	int res = TrackPopupMenu(hMenu, TPM_RETURNCMD | TPM_NONOTIFY, pt.x, pt.y, 0, GetActiveWindow(), NULL);
	if (res == 0) return 1;
	LoadSession(0, (res - 1) + g_ses_limit);
	return 0;
}
Esempio n. 3
0
    void Scrobble(musik::core::TrackPtr track) {
        if (track) {
            auto session = LoadSession();
            if (session.valid) {
                std::string postBody = gernateSignedUrlParams(UPDATE_NOW_PLAYING, {
                    { "track", track->GetString("title") },
                    { "album", track->GetString("album") },
                    { "artist", track->GetString("artist") },
                    { "albumArtist", track->GetString("album_artist") },
                    { "trackNumber", track->GetString("track") },
                    { "timestamp", std::to_string(std::time(0)) },
                    { "sk", session.sessionId }
                });

                createClient()->Url(URL_BASE)
                    .Mode(LastFmClient::Thread::Background)
                    .Header("Content-Type", "application/x-www-form-urlencoded")
                    .Method(LastFmClient::HttpMethod::Post)
                    .PostBody(postBody)
                    .Run();
            }
        }
    }
Esempio n. 4
0
UzblTreeTab::UzblTreeTab(char* name)
{
    running = true;
    currenttab = 0;
    totaltabs = 0;
    fifocount = 0;
    uzblinstances = NULL;
    fb = 0;
    sessionload = false;
    closing = false;
    
    if (name) {
        sprintf(fifopath, "/tmp/uzbltreetab-%s", name);
        strcpy(tabname, name);
    }
    else {
        sprintf(fifopath, "/tmp/uzbltreetab-%d", rand());
        tabname[0] = '\0';
    }
    mkfifo(fifopath, 0766);
    fifofd = open(fifopath, O_NONBLOCK);
    
    window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
    char title[1024];
    sprintf(title, "uzbltreetab - %s", name);
    gtk_window_set_title(window, title);
    
    tabtree = GTK_TREE_VIEW(gtk_tree_view_new());
    GtkScrolledWindow* tabscroll = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL, NULL));
    gtk_scrolled_window_set_policy(tabscroll, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_container_add(GTK_CONTAINER(tabscroll), GTK_WIDGET(tabtree));
    gtk_widget_set_can_focus(GTK_WIDGET(tabtree), false);
    //gtk_tree_view_set_reorderable(tabtree, true);
    tabmodel = gtk_tree_store_new(1, G_TYPE_STRING);
    gtk_tree_view_set_model(tabtree, GTK_TREE_MODEL(tabmodel));
    
    GtkTreeIter iter;
    GtkCellRenderer* trenderer = gtk_cell_renderer_text_new();
    //g_object_set(trenderer, "editable", true, NULL);
    gtk_tree_view_insert_column_with_attributes(tabtree, -1, "",
                                               trenderer, "text", 0, NULL);
    gtk_tree_view_set_headers_visible(tabtree, false);
    //g_signal_connect(trenderer, "edited", G_CALLBACK(cell_edited_callback), this);
    g_signal_connect(tabtree, "cursor-changed", G_CALLBACK(row_clicked), this);
    
    notebook = GTK_NOTEBOOK(gtk_notebook_new());
    gtk_notebook_set_show_tabs(notebook, false);
    gtk_notebook_set_show_border(notebook, false);

    pane = GTK_PANED(gtk_hpaned_new());
    gtk_paned_add1(pane, GTK_WIDGET(tabscroll));
    gtk_paned_add2(pane, GTK_WIDGET(notebook));
    
    gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(pane));

    g_signal_connect(window, "destroy", G_CALLBACK(wdestroy), this);
    gtk_widget_show_all(GTK_WIDGET(window));
    gtk_paned_set_position(pane, 200);
    panepos = 200;
    
    //g_timeout_add(1000, updatetabs, this);
    g_timeout_add(100, checkfifo, this);
    
    LoadSession();
    if (totaltabs == 0)
        NewTab("about:blank");
}
Esempio n. 5
0
INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam)
{
	g_hDlg=hdlg;
	switch(msg)
	{
		case WM_INITDIALOG:
		{
			int iDelay=db_get_w(NULL, MODNAME, "StartupModeDelay", 1500);
			if (g_hghostw == TRUE)
				SetTimer(hdlg, TIMERID_LOAD, iDelay, NULL);
			else
			{
				ses_count=0;
				TranslateDialogDefault(hdlg);
				if ((ses_count=LoadSessionToCombobox(hdlg,0,ses_limit,"SessionDate",0)) == ses_limit)
					EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),TRUE);

				if (LoadSessionToCombobox(hdlg,0,255,"UserSessionDsc",ses_limit) == 0 && ses_count!=0)
					ses_count=0;

				if (session_list_recovered[0])
					ses_count=256;

				SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
				LoadPosition(hdlg, "LoadDlg");
				if (StartUp)
					SetTimer(hdlg, TIMERID_SHOW, iDelay, NULL);
				else
					ShowWindow(g_hDlg,SW_SHOW);
			}
		}break;

		case WM_TIMER:
			if (wparam == TIMERID_SHOW)
			{
				KillTimer(hdlg, TIMERID_SHOW);
				ShowWindow(hdlg,SW_SHOW);
				StartUp=FALSE;
			}
			else
			{
				KillTimer(hdlg, TIMERID_LOAD);
				LoadSession(0,0);
				g_hghostw=StartUp=FALSE;
				DestroyWindow(hdlg);
				g_hDlg=0;
			}
			break;

		case WM_CLOSE:
			SavePosition(hdlg, "LoadDlg");
			DestroyWindow(hdlg);
			g_hDlg=0;
			break;

		case WM_COMMAND:
			switch(LOWORD(wparam))
			{
				case IDC_LIST:
				{
					switch(HIWORD(wparam))
					{
						case CBN_SELCHANGE:
						{
							HWND hCombo = GetDlgItem(hdlg, IDC_LIST);
							int index = SendMessage(hCombo, CB_GETCURSEL, 0, 0);
							if (index != CB_ERR)
								ses_count = SendMessage(hCombo, CB_GETITEMDATA, (WPARAM)index, 0);
						}break;
					}break;
				}break;

				case IDC_SESSDEL:
				{
					if (session_list_recovered[0]&&ses_count == 256)
					{
						int i=0;
						while(session_list_recovered[i])
						{
							db_set_b(session_list_recovered[i], MODNAME, "wasInLastSession", 0);
							i++;
						}
						ZeroMemory(session_list_recovered,SIZEOF(session_list_recovered));
						g_bIncompletedSave=0;

						EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),FALSE);
						SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0);

						if ((ses_count=LoadSessionToCombobox(hdlg,1,ses_limit,"SessionDate",0)) == ses_limit)
							EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),TRUE);

						if (LoadSessionToCombobox(hdlg,1,255,"UserSessionDsc",ses_limit) == 0 && ses_count!=0)
							ses_count=0;

						SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);

					}
					else if (ses_count>=ses_limit)
					{
						ses_count-=ses_limit;
						DelUserDefSession(ses_count);
						EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),FALSE);
						SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0);

						if ((ses_count=LoadSessionToCombobox(hdlg,0,ses_limit,"SessionDate",0)) == ses_limit)
							EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),TRUE);

						if (LoadSessionToCombobox(hdlg,0,255,"UserSessionDsc",ses_limit) == 0 && ses_count!=0)
							ses_count=0;

						if (session_list_recovered[0]) ses_count=256;

						SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
					}
					else
					{
						DeleteAutoSession(ses_count);
						EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),FALSE);
						SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0);
						if ((ses_count=LoadSessionToCombobox(hdlg,0,ses_limit,"SessionDate",0)) == ses_limit)
							EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),TRUE);

						if (LoadSessionToCombobox(hdlg,0,255,"UserSessionDsc",ses_limit) == 0 && ses_count!=0)
							ses_count=0;

						if (session_list_recovered[0]) ses_count=256;

						SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
					}
					if (SendDlgItemMessage(hdlg, IDC_LIST, CB_GETCOUNT, 0, 0))
						EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),TRUE);
					else
						EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),FALSE);
				}break;

				case IDOK:
				{
					if (!LoadSession(0,ses_count))
					{
						SavePosition(hdlg, "LoadDlg");
						DestroyWindow(hdlg);
						g_hDlg=0;
					}
				}break;

				case IDCANCEL:
				{
					SavePosition(hdlg, "LoadDlg");
					DestroyWindow(hdlg);
					g_hDlg=0;
				}break;
			}
			break;

		default:
			return FALSE;
	}
	return TRUE;
}
Esempio n. 6
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
{
	int i;
	HWND hWnd;
	MSG msg;
	WNDCLASS cls;
	RECT desktop_area;
	int win_x, win_y;
	HICON load,save;

	InitCommonControls();
	FixWorkingDirectory(hInstance);
	SystemParametersInfo(SPI_GETWORKAREA, 0, &desktop_area, 0);

	// Register class for our window
	cls.style = CS_OWNDC|CS_HREDRAW|CS_VREDRAW;
	cls.lpfnWndProc = MainDlgProc;
	cls.cbClsExtra = 0;
	cls.cbWndExtra = 0;
	cls.hInstance = hInstance;
	cls.hIcon = LoadIcon (NULL, IDI_APPLICATION);
	cls.hCursor = LoadCursor (NULL, IDC_ARROW);
	cls.hbrBackground = (HBRUSH) (COLOR_3DFACE + 1);
	cls.lpszMenuName = NULL;
	cls.lpszClassName = "ColourPicker";
	RegisterClass(&cls);

	// Create our window
	win_x = desktop_area.left + ((desktop_area.right - desktop_area.left) / 2) - 245;
	win_y = desktop_area.top + ((desktop_area.bottom - desktop_area.top) / 2) - 125;
	hWnd = CreateWindow(cls.lpszClassName, "Colour Picker", DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU,
												win_x, win_y, 490, 251, NULL, NULL, hInstance, 0);
	GetWindowRect(hWnd, &session.window);

	// Add icon
	SetClassLong(hWnd, GCL_HICONSM, (LONG)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAIN), IMAGE_ICON, 16, 16, 0));
	SetClassLong(hWnd, GCL_HICON, (LONG)LoadIcon(hInstance, (LPCTSTR)IDI_MAIN));

	// Set modes
	clds[LINE_H].mode = LINE_MODE_H;
	clds[LINE_S].mode = LINE_MODE_S;
	clds[LINE_V].mode = LINE_MODE_V;
	clds[LINE_R].mode = LINE_MODE_R;
	clds[LINE_G].mode = LINE_MODE_G;
	clds[LINE_B].mode = LINE_MODE_B;

	// Add Controls
	hColourSquare = ColourSquare_Create(hInstance, 7, 7, hWnd, &csd);
	csd.c = &session.current_colour;
	hColourChannel = ColourChannel_Create(hInstance, 217, 7, 10, hWnd, &ccd);
	ccd.c = &session.current_colour;
	for (i = 0; i < 6; i++)
	{
		// Radio buttons
		hColourSquareModes[i] = CreateWindow("BUTTON", ColourSquare_Titles[i], 
																					WS_VISIBLE|BS_AUTORADIOBUTTON|WS_CHILD|(i==0?WS_GROUP|WS_TABSTOP:0),
																					243, (i * 22) + 9, 25, 15, hWnd, NULL, hInstance, 0);
		SendMessage(hColourSquareModes[i], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
	}
	for (i = 0; i < 6; i++)
	{
		// Lines
		clds[i].c = &session.current_colour;
		hColourLines[i] = ColourLine_Create(hInstance, 272, (i * 22) + 7, 15, hWnd, &clds[i]);

		// Line values
		hColourLineValues[i] = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "0", WS_VISIBLE|WS_CHILD|ES_NUMBER|WS_TABSTOP,
																						430, (i * 22) + 7, 45, 19, hWnd, NULL, hInstance, 0);
		SendMessage(hColourLineValues[i], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
		SendMessage(hColourLineValues[i], EM_SETLIMITTEXT, (WPARAM) 3, 0);
		SetOverrideEditCtrlWndProc(hColourLineValues[i]);

		// Line value up/downs
		hColourLineValueUpDowns[i] = CreateWindow(UPDOWN_CLASS, NULL,
																							WS_VISIBLE|WS_CHILD|UDS_ALIGNRIGHT|UDS_SETBUDDYINT|UDS_ARROWKEYS,
																							0, 0, 0, 0, hWnd, NULL, hInstance, 0);
		SendMessage(hColourLineValueUpDowns[i], UDM_SETBUDDY, (WPARAM)hColourLineValues[i], 0);
	}
	// Current colour
	hCurrentColourLabel = CreateWindow("STATIC", "Current colour:", WS_VISIBLE|WS_CHILD, 258, 141, 
																			69, 20, hWnd, NULL, hInstance, 0);
	SendMessage(hCurrentColourLabel, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
	// Current colour block
	hCurrentColourBlock = ColourBlock_Create(hInstance, 271, 158, 43, 36, hWnd, &session.current_colour);

	// Add to previous button
	hAddToPreviousButton = CreateWindow("BUTTON", ">", WS_VISIBLE|WS_CHILD|WS_TABSTOP, 334, 151, 18, 23, hWnd, 
																				NULL, hInstance, 0);
	SendMessage(hAddToPreviousButton, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);

	// Previous colours
	for (i = 0; i < 4; i++)
	{
		csed[i].current = &session.current_colour;
		csed[i].mine = &session.prev_colours[i];
		hPreviousColours[i] = ColourSelectable_Create(hInstance, 357 + (i * 25), 142, 18, 16, hWnd, &csed[i]);
	}
	for (i = 4; i < 8; i++)
	{
		csed[i].current = &session.current_colour;
		csed[i].mine = &session.prev_colours[i];
		hPreviousColours[i] = ColourSelectable_Create(hInstance, 357 + ((i-4) * 25), 165, 18, 16, hWnd, &csed[i]);
	}

	// Open previous colours
	hLoadPreviousColours = CreateWindow("BUTTON", "Open", WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_ICON, 457, 142, 20, 20, 
																				hWnd, NULL, hInstance, 0);
	load = LoadImage(hInstance, MAKEINTRESOURCE(IDI_OPEN), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
	SendMessage(hLoadPreviousColours, BM_SETIMAGE, IMAGE_ICON, (LPARAM)load);

	// Save previous colours
	hSavePreviousColours = CreateWindow("BUTTON", "Save", WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_ICON, 457, 165, 20, 20, 
																				hWnd, NULL, hInstance, 0);
	save = LoadImage(hInstance, MAKEINTRESOURCE(IDI_SAVE), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
	SendMessage(hSavePreviousColours, BM_SETIMAGE, IMAGE_ICON, (LPARAM)save);

	// Hex Label
	hCurrentColourHexLabel = CreateWindow("STATIC", "Hex:", WS_VISIBLE|WS_CHILD, 257, 202, 32, 20, hWnd, NULL, hInstance, 0);
	SendMessage(hCurrentColourHexLabel, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
	// Hex Value
	hCurrentColourHexValue = CreateWindow("EDIT", "#FF0000", WS_VISIBLE|WS_CHILD|ES_READONLY,
																				282, 202, 65, 19, hWnd, NULL, hInstance, 0);
	SendMessage(hCurrentColourHexValue, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);

	// Colour Target
	ctd.c = &session.current_colour;
	hColourPickLabel = CreateWindow("STATIC", "Screen Pick:", WS_VISIBLE|WS_CHILD,
																		372, 199, 65, 23, hWnd, NULL, hInstance, 0);
	SendMessage(hColourPickLabel, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
	hColourPickTarget = ColourTarget_Create(hInstance, 442, 194, hWnd, &ctd);

	// UpDown ranges
	SendMessage(hColourLineValueUpDowns[LINE_H], UDM_SETRANGE, 0, MAKELONG(359, 0));
	SendMessage(hColourLineValueUpDowns[LINE_S], UDM_SETRANGE, 0, MAKELONG(100, 0));
	SendMessage(hColourLineValueUpDowns[LINE_V], UDM_SETRANGE, 0, MAKELONG(100, 0));
	SendMessage(hColourLineValueUpDowns[LINE_R], UDM_SETRANGE, 0, MAKELONG(255, 0));
	SendMessage(hColourLineValueUpDowns[LINE_G], UDM_SETRANGE, 0, MAKELONG(255, 0));
	SendMessage(hColourLineValueUpDowns[LINE_B], UDM_SETRANGE, 0, MAKELONG(255, 0));

	// Load last session
	LoadSession(hWnd);

	// Set some controls to what the session info is
	SendMessage(hColourSquareModes[session.square_mode], BM_SETCHECK, BST_CHECKED, 0);
	SendMessage(hColourLineValueUpDowns[LINE_H], UDM_SETPOS32, 0, (LPARAM)session.current_colour.h);
	SendMessage(hColourLineValueUpDowns[LINE_S], UDM_SETPOS32, 0, (LPARAM)session.current_colour.s);
	SendMessage(hColourLineValueUpDowns[LINE_V], UDM_SETPOS32, 0, (LPARAM)session.current_colour.v);
	SendMessage(hColourLineValueUpDowns[LINE_R], UDM_SETPOS32, 0, (LPARAM)session.current_colour.r);
	SendMessage(hColourLineValueUpDowns[LINE_G], UDM_SETPOS32, 0, (LPARAM)session.current_colour.g);
	SendMessage(hColourLineValueUpDowns[LINE_B], UDM_SETPOS32, 0, (LPARAM)session.current_colour.b);

	// Show the window finally
	ShowWindow(hWnd, SW_SHOW);

	// Wait for messages
	while (GetMessage(&msg, hWnd, 0, 0))
	{
		if (!IsDialogMessage(hWnd, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		
		if (!IsWindow(hWnd)) break;
	}

	return 0;
}